2005-12-10 Dan Williams <dcbw@redhat.com>

* gnome/applet/Makefile.am
		- Add libnm-util to includes
		- Add libnm-util to link list
		- Add wireless-security-common.* to compile list

	* gnome/applet/other-network-dialog.c
		- Convert to using the WirelessSecurityManager code and
			widgets

	* gnome/applet/passphrase-dialog.c
		- Comment out references to stuff in the glade file that
			cause runtime errors until it can be fixed up
			to use the WirelessSecurityManager code

	* gnome/applet/wireless-applet.glade
		- Rename some widgets
		- Add widgets for the WirelessSecurityManager code
		- Remove passphrase-related stuff since that's now
			handled by the WirelessSecurityManager code


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1156 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2005-12-10 19:45:06 +00:00
parent 8bc5acbc99
commit 5093c26462
7 changed files with 987 additions and 304 deletions

View file

@ -1,3 +1,25 @@
2005-12-10 Dan Williams <dcbw@redhat.com>
* gnome/applet/Makefile.am
- Add libnm-util to includes
- Add libnm-util to link list
- Add wireless-security-common.* to compile list
* gnome/applet/other-network-dialog.c
- Convert to using the WirelessSecurityManager code and
widgets
* gnome/applet/passphrase-dialog.c
- Comment out references to stuff in the glade file that
cause runtime errors until it can be fixed up
to use the WirelessSecurityManager code
* gnome/applet/wireless-applet.glade
- Rename some widgets
- Add widgets for the WirelessSecurityManager code
- Remove passphrase-related stuff since that's now
handled by the WirelessSecurityManager code
2005-12-10 Dan Williams <dcbw@redhat.com>
* gnome/applet/applet-dbus-devices.c

View file

@ -2,7 +2,7 @@ SUBDIRS=icons
NULL=
INCLUDES = -I${top_srcdir} -I${top_srcdir}/utils -I${top_srcdir}/include
INCLUDES = -I${top_srcdir} -I${top_srcdir}/utils -I${top_srcdir}/include -I${top_srcdir}/libnm-util
bin_PROGRAMS = nm-applet
@ -58,6 +58,8 @@ nm_applet_SOURCES = \
vpn-password-dialog.h \
vpn-connection.c \
vpn-connection.h \
wireless-security-common.c \
wireless-security-common.h \
$(NULL)
nm_applet_LDADD = \
@ -72,6 +74,7 @@ nm_applet_LDADD = \
$(LIBGNOMEUI_LIBS) \
$(GNOME_KEYRING_LIBS) \
$(top_builddir)/utils/libnmutils.la \
$(top_builddir)/libnm-util/libnm-util.la \
$(NULL)

View file

@ -46,6 +46,7 @@
#include "applet-dbus.h"
#include "applet-dbus-devices.h"
#include "other-network-dialog.h"
#include "wireless-security-common.h"
static void update_button_cb (GtkWidget *widget, GladeXML *xml)
@ -53,24 +54,24 @@ static void update_button_cb (GtkWidget *widget, GladeXML *xml)
gboolean enable = FALSE;
const char * text;
GtkButton * button;
GtkEntry * essid_entry;
GtkEntry * network_name_entry;
GtkCheckButton * enc_check_button;
g_return_if_fail (xml != NULL);
essid_entry = GTK_ENTRY (glade_xml_get_widget (xml, "essid_entry"));
network_name_entry = GTK_ENTRY (glade_xml_get_widget (xml, "network_name_entry"));
button = GTK_BUTTON (glade_xml_get_widget (xml, "ok_button"));
enc_check_button = GTK_CHECK_BUTTON (glade_xml_get_widget (xml, "use_encryption_checkbox"));
/* An ESSID is required */
text = gtk_entry_get_text (essid_entry);
text = gtk_entry_get_text (network_name_entry);
if (text && strlen (text) > 0)
enable = TRUE;
/* If we're using encryption, validate the settings */
/*
if (enable && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (enc_check_button)))
{
GtkComboBox * combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "key_type_combo"));
GtkComboBox * combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "security_combo"));
GtkEntry * passphrase_entry = GTK_ENTRY (glade_xml_get_widget (xml, "passphrase_entry"));
const char * passphrase_text = gtk_entry_get_text (passphrase_entry);
@ -93,6 +94,7 @@ static void update_button_cb (GtkWidget *widget, GladeXML *xml)
break;
}
}
*/
gtk_widget_set_sensitive (GTK_WIDGET (button), enable);
}
@ -130,84 +132,62 @@ static GtkTreeModel *create_wireless_adapter_model (NMWirelessApplet *applet)
/*
* nmwa_other_network_dialog_key_type_combo_changed
* nmwa_other_network_dialog_security_combo_changed
*
* Change the text of the passphrase entry label to match the selected
* key type.
* Replace the current wireless security widgets with new ones
* according to what the user chose.
*
*/
static void nmwa_other_network_dialog_key_type_combo_changed (GtkWidget *key_type_combo, gpointer user_data)
static void nmwa_other_network_dialog_security_combo_changed (GtkWidget *security_combo, gpointer user_data)
{
GtkLabel *entry_label;
int combo_choice;
GladeXML *xml = (GladeXML *)user_data;
int choice;
GtkDialog * dialog = (GtkDialog *) user_data;
WirelessSecurityManager * wsm;
GtkWidget * ws_notebook;
GladeXML * xml;
GtkWidget * vbox;
GList * children;
GList * elt;
g_return_if_fail (dialog != NULL);
xml = (GladeXML *) g_object_get_data (G_OBJECT (dialog), "glade-xml");
g_return_if_fail (xml != NULL);
entry_label = GTK_LABEL (glade_xml_get_widget (xml, "passphrase_entry_label"));
switch ((combo_choice = gtk_combo_box_get_active (GTK_COMBO_BOX (key_type_combo))))
wsm = g_object_get_data (G_OBJECT (dialog), "wireless-security-manager");
g_return_if_fail (wsm != NULL);
vbox = GTK_WIDGET (glade_xml_get_widget (xml, "wireless_security_vbox"));
children = gtk_container_get_children (GTK_CONTAINER (vbox));
for (elt = children; elt; elt = elt->next)
{
case KEY_TYPE_128_BIT_PASSPHRASE:
gtk_label_set_text_with_mnemonic (entry_label, _("_Passphrase:"));
break;
case KEY_TYPE_ASCII_KEY:
gtk_label_set_text_with_mnemonic (entry_label, _("_ASCII Key:"));
break;
case KEY_TYPE_HEX_KEY:
gtk_label_set_text_with_mnemonic (entry_label, _("_Hex Key:"));
break;
default:
GtkWidget * child = GTK_WIDGET (elt->data);
if (wsm_is_ws_widget (wsm, child))
{
gtk_container_remove (GTK_CONTAINER (vbox), child);
break;
}
}
update_button_cb (key_type_combo, xml);
}
choice = gtk_combo_box_get_active (GTK_COMBO_BOX (security_combo));
ws_notebook = wsm_get_widget_for_index (wsm, choice);
if (ws_notebook)
gtk_container_add (GTK_CONTAINER (vbox), ws_notebook);
/*
* nmwa_other_network_dialog_enc_check_toggled
*
* Enable/disable the encryption-related dialog items based on the
* widget's status.
*
*/
static void nmwa_other_network_dialog_enc_check_toggled (GtkWidget *enc_check_button, gpointer user_data)
{
GladeXML *xml = (GladeXML *)user_data;
GtkComboBox *combo;
GtkEntry *entry;
GtkLabel *combo_label;
GtkLabel *entry_label;
gboolean active;
g_return_if_fail (xml != NULL);
combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "key_type_combo"));
combo_label = GTK_LABEL (glade_xml_get_widget (xml, "key_type_combo_label"));
entry = GTK_ENTRY (glade_xml_get_widget (xml, "passphrase_entry"));
entry_label = GTK_LABEL (glade_xml_get_widget (xml, "passphrase_entry_label"));
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (enc_check_button));
gtk_widget_set_sensitive (GTK_WIDGET (combo), active);
gtk_widget_set_sensitive (GTK_WIDGET (combo_label), active);
gtk_widget_set_sensitive (GTK_WIDGET (entry), active);
gtk_widget_set_sensitive (GTK_WIDGET (entry_label), active);
update_button_cb (enc_check_button, xml);
update_button_cb (security_combo, xml);
}
static GtkDialog *nmwa_other_network_dialog_init (GladeXML *xml, NMWirelessApplet *applet, NetworkDevice **def_dev, gboolean create_network)
{
GtkDialog *dialog = NULL;
GtkWidget *essid_entry;
GtkWidget *button;
GtkComboBox *key_type_combo;
GtkEntry *passphrase_entry;
gint n_wireless_interfaces = 0;
GSList *element;
char *label;
GtkCheckButton *enc_check_button;
GtkDialog * dialog = NULL;
GtkWidget * network_name_entry;
GtkWidget * button;
WirelessSecurityManager * wsm;
GtkComboBox * security_combo;
gint n_wireless_interfaces = 0;
GSList * element;
char * label;
g_return_val_if_fail (xml != NULL, NULL);
g_return_val_if_fail (applet != NULL, NULL);
@ -215,10 +195,12 @@ static GtkDialog *nmwa_other_network_dialog_init (GladeXML *xml, NMWirelessApple
g_return_val_if_fail (*def_dev == NULL, NULL);
/* Set up the dialog */
if (!(dialog = GTK_DIALOG (glade_xml_get_widget (xml, "custom_essid_dialog"))))
if (!(dialog = GTK_DIALOG (glade_xml_get_widget (xml, "other_network_dialog"))))
return NULL;
essid_entry = glade_xml_get_widget (xml, "essid_entry");
g_object_set_data (G_OBJECT (dialog), "glade-xml", xml);
network_name_entry = glade_xml_get_widget (xml, "network_name_entry");
button = glade_xml_get_widget (xml, "ok_button");
gtk_widget_grab_default (GTK_WIDGET (button));
#if GTK_CHECK_VERSION(2,6,0)
@ -228,9 +210,9 @@ static GtkDialog *nmwa_other_network_dialog_init (GladeXML *xml, NMWirelessApple
}
#endif
gtk_widget_grab_focus (essid_entry);
gtk_widget_grab_focus (network_name_entry);
gtk_widget_set_sensitive (button, FALSE);
g_signal_connect (essid_entry, "changed", G_CALLBACK (update_button_cb), xml);
g_signal_connect (network_name_entry, "changed", G_CALLBACK (update_button_cb), xml);
if (create_network)
{
@ -245,8 +227,8 @@ static GtkDialog *nmwa_other_network_dialog_init (GladeXML *xml, NMWirelessApple
hostname[HOST_NAME_MAX-1] = '\n'; /* unspecified whether a truncated hostname is terminated */
#endif
gtk_entry_set_text (GTK_ENTRY (essid_entry), hostname);
gtk_editable_set_position (GTK_EDITABLE (essid_entry), -1);
gtk_entry_set_text (GTK_ENTRY (network_name_entry), hostname);
gtk_editable_set_position (GTK_EDITABLE (network_name_entry), -1);
default_essid_text = g_strdup_printf (_("By default, the ESSID is set to your computer's name, %s, with no encryption enabled"),
hostname);
@ -268,7 +250,7 @@ static GtkDialog *nmwa_other_network_dialog_init (GladeXML *xml, NMWirelessApple
gtk_window_set_title (GTK_WINDOW(dialog), _("Connect to Other Wireless Network"));
}
gtk_label_set_markup (GTK_LABEL (glade_xml_get_widget (xml, "essid_label")), label);
gtk_label_set_markup (GTK_LABEL (glade_xml_get_widget (xml, "caption_label")), label);
g_free (label);
/* Do we have multiple Network cards? */
@ -296,7 +278,7 @@ static GtkDialog *nmwa_other_network_dialog_init (GladeXML *xml, NMWirelessApple
if (n_wireless_interfaces < 1)
{
/* Run away!!! */
return (NULL);
return NULL;
}
else if (n_wireless_interfaces == 1)
{
@ -316,22 +298,21 @@ static GtkDialog *nmwa_other_network_dialog_init (GladeXML *xml, NMWirelessApple
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
}
/* Uncheck the "use encryption" checkbox and disable relevant encryption widgets */
enc_check_button = GTK_CHECK_BUTTON (glade_xml_get_widget (xml, "use_encryption_checkbox"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enc_check_button), 0);
g_signal_connect (G_OBJECT (enc_check_button), "toggled", GTK_SIGNAL_FUNC (nmwa_other_network_dialog_enc_check_toggled), xml);
nmwa_other_network_dialog_enc_check_toggled (GTK_WIDGET (enc_check_button), xml);
wsm = wsm_new (applet);
g_object_set_data (G_OBJECT (dialog), "wireless-security-manager", (gpointer) wsm);
/* Set initial passphrase entry label and key type combo box item */
key_type_combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "key_type_combo"));
gtk_combo_box_set_active (key_type_combo, KEY_TYPE_128_BIT_PASSPHRASE);
g_signal_connect (G_OBJECT (key_type_combo), "changed", GTK_SIGNAL_FUNC (nmwa_other_network_dialog_key_type_combo_changed), xml);
nmwa_other_network_dialog_key_type_combo_changed (GTK_WIDGET (key_type_combo), xml);
security_combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "security_combo"));
wsm_populate_combo (wsm, security_combo);
g_signal_connect (G_OBJECT (security_combo), "changed", GTK_SIGNAL_FUNC (nmwa_other_network_dialog_security_combo_changed), dialog);
nmwa_other_network_dialog_security_combo_changed (GTK_WIDGET (security_combo), dialog);
/*
passphrase_entry = GTK_ENTRY (glade_xml_get_widget (xml, "passphrase_entry"));
g_signal_connect (passphrase_entry, "changed", G_CALLBACK (update_button_cb), xml);
*/
return (dialog);
return dialog;
}
typedef struct OtherNetworkDialogCBData
@ -353,7 +334,7 @@ static void nmwa_other_network_dialog_response_cb (GtkDialog *dialog, gint respo
if (response == GTK_RESPONSE_OK)
{
GtkEntry *essid_entry;
GtkEntry *network_name_entry;
GtkCheckButton *enc_check_button;
GtkEntry *passphrase_entry;
GtkComboBox *key_type_combo;
@ -361,8 +342,8 @@ static void nmwa_other_network_dialog_response_cb (GtkDialog *dialog, gint respo
const char *passphrase = NULL;
int key_type = -1;
essid_entry = GTK_ENTRY (glade_xml_get_widget (xml, "essid_entry"));
essid = gtk_entry_get_text (essid_entry);
network_name_entry = GTK_ENTRY (glade_xml_get_widget (xml, "network_name_entry"));
essid = gtk_entry_get_text (network_name_entry);
enc_check_button = GTK_CHECK_BUTTON (glade_xml_get_widget (xml, "use_encryption_checkbox"));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (enc_check_button)))
@ -416,15 +397,15 @@ static void nmwa_other_network_dialog_response_cb (GtkDialog *dialog, gint respo
void nmwa_other_network_dialog_run (NMWirelessApplet *applet, gboolean create_network)
{
GtkDialog *dialog;
NetworkDevice *def_dev = NULL;
GladeXML *xml;
GtkDialog * dialog;
NetworkDevice * def_dev = NULL;
GladeXML * xml;
OtherNetworkDialogCBData *cb_data;
g_return_if_fail (applet != NULL);
g_return_if_fail (applet->glade_file != NULL);
if (!(xml = glade_xml_new (applet->glade_file, "custom_essid_dialog", NULL)))
if (!(xml = glade_xml_new (applet->glade_file, "other_network_dialog", NULL)))
{
nmwa_schedule_warning_dialog (applet, _("The NetworkManager Applet could not find some required resources (the glade file was not found)."));
return;

View file

@ -62,6 +62,7 @@ static void update_button_cb (GtkWidget *widget, GladeXML *xml)
button = GTK_BUTTON (glade_xml_get_widget (xml, "login_button"));
combo = GTK_COMBO_BOX (glade_xml_get_widget (xml, "key_type_combo"));
/*
passphrase_entry = GTK_ENTRY (glade_xml_get_widget (xml, "passphrase_entry"));
passphrase_text = gtk_entry_get_text (passphrase_entry);
@ -82,6 +83,7 @@ static void update_button_cb (GtkWidget *widget, GladeXML *xml)
default:
break;
}
*/
gtk_widget_set_sensitive (GTK_WIDGET (button), enable);
}
@ -121,8 +123,10 @@ static void nmi_passphrase_dialog_clear (GtkWidget *dialog)
if ((xml = (GladeXML *)g_object_get_data (G_OBJECT (dialog), "glade-xml")))
{
/*
entry = glade_xml_get_widget (xml, "passphrase_entry");
gtk_entry_set_text (GTK_ENTRY (entry), "");
*/
}
gtk_widget_hide (dialog);
@ -387,15 +391,17 @@ GtkWidget *nmi_passphrase_dialog_init (NMWirelessApplet *applet)
ok_button = GTK_BUTTON (glade_xml_get_widget (dialog_xml, "login_button"));
gtk_widget_grab_default (GTK_WIDGET (ok_button));
entry = GTK_ENTRY (glade_xml_get_widget (dialog_xml, "passphrase_entry"));
// entry = GTK_ENTRY (glade_xml_get_widget (dialog_xml, "passphrase_entry"));
nmi_passphrase_dialog_clear (dialog);
gtk_widget_set_sensitive (GTK_WIDGET (ok_button), FALSE);
g_signal_connect (entry, "changed", G_CALLBACK (update_button_cb), dialog_xml);
// g_signal_connect (entry, "changed", G_CALLBACK (update_button_cb), dialog_xml);
/*
key_type_combo = GTK_COMBO_BOX (glade_xml_get_widget (dialog_xml, "key_type_combo"));
gtk_combo_box_set_active (key_type_combo, 0);
g_signal_connect (G_OBJECT (key_type_combo), "changed", GTK_SIGNAL_FUNC (nmi_passphrase_dialog_key_type_combo_changed), applet);
nmi_passphrase_dialog_key_type_combo_changed (GTK_WIDGET (key_type_combo), applet);
*/
return dialog;
}

View file

@ -302,7 +302,7 @@ You have chosen to log in to the wireless network '%s'. If you are sure that th
</child>
</widget>
<widget class="GtkDialog" id="custom_essid_dialog">
<widget class="GtkDialog" id="other_network_dialog">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="title" translatable="yes">Other Wireless Network...</property>
@ -398,7 +398,7 @@ You have chosen to log in to the wireless network '%s'. If you are sure that th
<property name="spacing">12</property>
<child>
<widget class="GtkLabel" id="essid_label">
<widget class="GtkLabel" id="caption_label">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
@ -478,9 +478,9 @@ You have chosen to log in to the wireless network '%s'. If you are sure that th
</child>
<child>
<widget class="GtkLabel" id="label2">
<widget class="GtkLabel" id="network_name_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Wireless _network:</property>
<property name="label" translatable="yes">_Network Name:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@ -490,7 +490,6 @@ You have chosen to log in to the wireless network '%s'. If you are sure that th
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">essid_entry</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
@ -507,7 +506,7 @@ You have chosen to log in to the wireless network '%s'. If you are sure that th
</child>
<child>
<widget class="GtkEntry" id="essid_entry">
<widget class="GtkEntry" id="network_name_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
@ -535,22 +534,59 @@ You have chosen to log in to the wireless network '%s'. If you are sure that th
</child>
<child>
<widget class="GtkVBox" id="vbox4">
<widget class="GtkVBox" id="wireless_security_vbox">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkCheckButton" id="use_encryption_checkbox">
<widget class="GtkHBox" id="hbox4">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Connect with _encryption enabled</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkLabel" id="security_combo_label">
<property name="visible">True</property>
<property name="label" translatable="yes">_Wireless Security:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="security_combo">
<property name="visible">True</property>
<property name="items" translatable="yes">None
WEP Passphrase
WEP 40/128-bit hex
WEP 40/128-bit ASCII
</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
@ -560,130 +596,7 @@ You have chosen to log in to the wireless network '%s'. If you are sure that th
</child>
<child>
<widget class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">3</property>
<property name="bottom_padding">6</property>
<property name="left_padding">24</property>
<property name="right_padding">6</property>
<child>
<widget class="GtkTable" id="table5">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">3</property>
<property name="homogeneous">False</property>
<property name="row_spacing">12</property>
<property name="column_spacing">6</property>
<child>
<widget class="GtkLabel" id="key_type_combo_label">
<property name="visible">True</property>
<property name="label" translatable="yes">_Key type:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="passphrase_entry_label">
<property name="visible">True</property>
<property name="label" translatable="yes">_Passphrase:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">passphrase_entry</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="passphrase_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="key_type_combo">
<property name="visible">True</property>
<property name="items" translatable="yes">128-bit passphrase (WEP)
ASCII key (WEP)
Hex key (WEP)</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
<placeholder/>
</child>
</widget>
<packing>
@ -831,25 +744,24 @@ A passphrase or encryption key is required to access the wireless network '%s'.<
</child>
<child>
<widget class="GtkHBox" id="hbox3">
<widget class="GtkHBox" id="hbox7">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkLabel" id="label3">
<widget class="GtkLabel" id="security_combo_label">
<property name="visible">True</property>
<property name="label" translatable="yes">_Key Type:</property>
<property name="label" translatable="yes">_Wireless Security:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">key_type_combo</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
@ -863,11 +775,13 @@ A passphrase or encryption key is required to access the wireless network '%s'.<
</child>
<child>
<widget class="GtkComboBox" id="key_type_combo">
<widget class="GtkComboBox" id="security_combo">
<property name="visible">True</property>
<property name="items" translatable="yes">128-bit Passphrase (WEP)
ASCII Key (WEP)
Hex Key (WEP)</property>
<property name="items" translatable="yes">None
WEP Passphrase
WEP 40/128-bit hex
WEP 40/128-bit ASCII
</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>
@ -877,10 +791,6 @@ Hex Key (WEP)</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="padding">0</property>
@ -890,62 +800,7 @@ Hex Key (WEP)</property>
</child>
<child>
<widget class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkLabel" id="passphrase_entry_label">
<property name="visible">True</property>
<property name="label" translatable="yes">_Passphrase:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="mnemonic_widget">passphrase_entry</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="passphrase_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
<placeholder/>
</child>
</widget>
<packing>
@ -1743,4 +1598,466 @@ Hex Key (WEP)</property>
</child>
</widget>
<widget class="GtkWindow" id="wep_key_subwindow">
<property name="visible">True</property>
<property name="title" translatable="yes">wep_key_subwindow</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<child>
<widget class="GtkNotebook" id="wep_key_notebook">
<property name="visible">True</property>
<property name="show_tabs">False</property>
<property name="show_border">False</property>
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">False</property>
<property name="enable_popup">False</property>
<child>
<widget class="GtkHBox" id="hbox5">
<property name="border_width">8</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkLabel" id="wep_key_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Key:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">6</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="wep_key_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label23">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkLabel" id="label24">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkWindow" id="leap_subwindow">
<property name="visible">True</property>
<property name="title" translatable="yes">leap_subwindow</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<child>
<widget class="GtkNotebook" id="leap_notebook">
<property name="visible">True</property>
<property name="show_tabs">False</property>
<property name="show_border">False</property>
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">False</property>
<property name="enable_popup">False</property>
<child>
<widget class="GtkTable" id="table5">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<widget class="GtkEntry" id="leap_username_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="leap_password_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="leap_username">
<property name="visible">True</property>
<property name="label" translatable="yes">User Name:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_RIGHT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">1</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="leap_password">
<property name="visible">True</property>
<property name="label" translatable="yes">Password:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_RIGHT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">1</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkLabel" id="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkWindow" id="wpa_psk_subwindow">
<property name="visible">True</property>
<property name="title" translatable="yes">wpa_psk_subwindow</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<child>
<widget class="GtkNotebook" id="wpa_psk_notebook">
<property name="visible">True</property>
<property name="show_tabs">False</property>
<property name="show_border">False</property>
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">False</property>
<property name="enable_popup">False</property>
<child>
<widget class="GtkHBox" id="hbox6">
<property name="border_width">8</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkLabel" id="wpa_psk_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Key:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">6</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="wpa_psk_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkLabel" id="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View file

@ -0,0 +1,316 @@
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2005 Red Hat, Inc.
*/
#include <glib.h>
#include <glib/gi18n.h>
#include <string.h>
#include <glade/glade.h>
#include "wireless-security-common.h"
#include "cipher.h"
#include "applet.h"
#include "cipher-wep-passphrase.h"
#include "cipher-wep-hex.h"
#include "cipher-wep-ascii.h"
#include "cipher-wpa-psk-passphrase.h"
static const char * wsm_get_glade_file (WirelessSecurityManager *wsm);
static NMWirelessApplet * wsm_get_applet (WirelessSecurityManager *wsm);
/* Encapsulates and controls a single wireless security option */
struct WirelessSecurityOption
{
/* Human readable name for the option */
char * name;
/* Corresponding IEEE_802_11_Cipher objects */
GSList * ciphers;
/* Name of the widget for this item */
const char * widget_name;
/* The Glade UI for this option */
GladeXML * uixml;
};
struct WirelessSecurityManager
{
NMWirelessApplet * applet;
GSList * options;
};
static const char * wso_get_name (WirelessSecurityOption * opt)
{
g_return_val_if_fail (opt != NULL, NULL);
return opt->name;
}
#define WS_TAG_MAGIC 0xa7f4
#define WS_TAG_NAME "ws-tag"
static GtkWidget * wso_get_widget (WirelessSecurityOption *opt)
{
GtkWidget * widget = NULL;
g_return_val_if_fail (opt != NULL, NULL);
/* Some options may not have any UI */
if (opt->uixml)
{
widget = glade_xml_get_widget (opt->uixml, opt->widget_name);
g_object_set_data (G_OBJECT (widget), WS_TAG_NAME, GINT_TO_POINTER (WS_TAG_MAGIC));
}
return widget;
}
static void wso_free (WirelessSecurityOption * opt)
{
g_free (opt->name);
if (opt->uixml)
g_object_unref (opt->uixml);
g_slist_foreach (opt->ciphers, (GFunc) ieee_802_11_cipher_unref, NULL);
g_slist_free (opt->ciphers);
memset (opt, 0, sizeof (WirelessSecurityOption));
g_free (opt);
}
static WirelessSecurityOption * wsm_opt_none_init (WirelessSecurityManager *wsm)
{
WirelessSecurityOption * opt = NULL;
g_return_val_if_fail (wsm != NULL, NULL);
opt = g_malloc0 (sizeof (WirelessSecurityOption));
opt->name = g_strdup (_("None"));
return opt;
}
static WirelessSecurityOption * wsm_opt_wep_passphrase_init (WirelessSecurityManager *wsm)
{
WirelessSecurityOption * opt = NULL;
GladeXML * xml = NULL;
g_return_val_if_fail (wsm != NULL, NULL);
opt = g_malloc0 (sizeof (WirelessSecurityOption));
opt->name = g_strdup (_("WEP Passphrase"));
opt->widget_name = "wep_key_notebook";
if (!(opt->uixml = glade_xml_new (wsm_get_glade_file (wsm), "wep_key_notebook", NULL)))
{
nmwa_schedule_warning_dialog (wsm_get_applet (wsm),
_("The NetworkManager Applet could not find some required resources (the glade file was not found)."));
wso_free (opt);
return NULL;
}
opt->ciphers = g_slist_append (opt->ciphers, cipher_wep128_passphrase_new ());
return opt;
}
static WirelessSecurityOption * wsm_opt_wep_hex_init (WirelessSecurityManager *wsm)
{
WirelessSecurityOption * opt = NULL;
GladeXML * xml = NULL;
g_return_val_if_fail (wsm != NULL, NULL);
opt = g_malloc0 (sizeof (WirelessSecurityOption));
opt->name = g_strdup (_("WEP 40/128-bit hex"));
opt->widget_name = "wep_key_notebook";
if (!(opt->uixml = glade_xml_new (wsm_get_glade_file (wsm), "wep_key_notebook", NULL)))
{
nmwa_schedule_warning_dialog (wsm_get_applet (wsm),
_("The NetworkManager Applet could not find some required resources (the glade file was not found)."));
wso_free (opt);
return NULL;
}
opt->ciphers = g_slist_append (opt->ciphers, cipher_wep128_hex_new ());
opt->ciphers = g_slist_append (opt->ciphers, cipher_wep64_hex_new ());
return opt;
}
static WirelessSecurityOption * wsm_opt_wep_ascii_init (WirelessSecurityManager *wsm)
{
WirelessSecurityOption * opt = NULL;
GladeXML * xml = NULL;
g_return_val_if_fail (wsm != NULL, NULL);
opt = g_malloc0 (sizeof (WirelessSecurityOption));
opt->name = g_strdup (_("WEP 40/128-bit ASCII"));
opt->widget_name = "wep_key_notebook";
if (!(opt->uixml = glade_xml_new (wsm_get_glade_file (wsm), "wep_key_notebook", NULL)))
{
nmwa_schedule_warning_dialog (wsm_get_applet (wsm),
_("The NetworkManager Applet could not find some required resources (the glade file was not found)."));
wso_free (opt);
return NULL;
}
opt->ciphers = g_slist_append (opt->ciphers, cipher_wep128_ascii_new ());
opt->ciphers = g_slist_append (opt->ciphers, cipher_wep64_ascii_new ());
return opt;
}
static WirelessSecurityOption * wsm_opt_wpa_psk_passphrase_init (WirelessSecurityManager *wsm)
{
WirelessSecurityOption * opt = NULL;
GladeXML * xml = NULL;
g_return_val_if_fail (wsm != NULL, NULL);
opt = g_malloc0 (sizeof (WirelessSecurityOption));
opt->name = g_strdup (_("WPA Personal Passphrase"));
opt->widget_name = "wpa_psk_notebook";
if (!(opt->uixml = glade_xml_new (wsm_get_glade_file (wsm), "wpa_psk_notebook", NULL)))
{
nmwa_schedule_warning_dialog (wsm_get_applet (wsm),
_("The NetworkManager Applet could not find some required resources (the glade file was not found)."));
wso_free (opt);
return NULL;
}
opt->ciphers = g_slist_append (opt->ciphers, cipher_wpa_psk_passphrase_new ());
return opt;
}
WirelessSecurityManager * wsm_new (NMWirelessApplet *applet)
{
WirelessSecurityManager * wsm = NULL;
WirelessSecurityOption * opt;
g_return_val_if_fail (applet, NULL);
wsm = g_malloc0 (sizeof (WirelessSecurityManager));
wsm->applet = applet;
/* Add the items */
if ((opt = wsm_opt_none_init (wsm)))
wsm->options = g_slist_append (wsm->options, opt);
if ((opt = wsm_opt_wep_passphrase_init (wsm)))
wsm->options = g_slist_append (wsm->options, opt);
if ((opt = wsm_opt_wep_hex_init (wsm)))
wsm->options = g_slist_append (wsm->options, opt);
if ((opt = wsm_opt_wep_ascii_init (wsm)))
wsm->options = g_slist_append (wsm->options, opt);
/*
if ((opt = wsm_opt_wpa_psk_passphrase_init (wsm)))
wsm->options = g_slist_append (wsm->options, opt);
*/
return wsm;
}
void wsm_populate_combo (WirelessSecurityManager *wsm, GtkComboBox *combo)
{
GtkListStore * model;
GSList * elt;
g_return_if_fail (wsm != NULL);
g_return_if_fail (combo != NULL);
model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
for (elt = wsm->options; elt; elt = elt->next)
{
WirelessSecurityOption * opt = (WirelessSecurityOption *) (elt->data);
GtkTreeIter iter;
g_assert (opt);
gtk_list_store_append (model, &iter);
gtk_list_store_set (model, &iter, 0, wso_get_name (opt), 1, opt, -1);
}
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (model));
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
}
GtkWidget * wsm_get_widget_for_index (WirelessSecurityManager *wsm, guint index)
{
GtkWidget * widget = NULL;
WirelessSecurityOption * opt;
g_return_val_if_fail (wsm != NULL, NULL);
g_return_val_if_fail (index >= 0, NULL);
g_return_val_if_fail (index < g_slist_length (wsm->options), NULL);
if ((opt = g_slist_nth_data (wsm->options, index)))
widget = wso_get_widget (opt);
return widget;
}
gboolean wsm_is_ws_widget (WirelessSecurityManager *wsm, GtkWidget * widget)
{
gpointer tag;
g_return_val_if_fail (wsm != NULL, FALSE);
g_return_val_if_fail (widget != NULL, FALSE);
tag = g_object_get_data (G_OBJECT (widget), WS_TAG_NAME);
if (tag && (GPOINTER_TO_INT (tag) == WS_TAG_MAGIC))
return TRUE;
return FALSE;
}
static const char * wsm_get_glade_file (WirelessSecurityManager *wsm)
{
g_return_val_if_fail (wsm != NULL, NULL);
g_return_val_if_fail (wsm->applet != NULL, NULL);
return wsm->applet->glade_file;
}
static NMWirelessApplet * wsm_get_applet (WirelessSecurityManager *wsm)
{
g_return_val_if_fail (wsm != NULL, NULL);
return wsm->applet;
}
void wsm_free (WirelessSecurityManager *wsm)
{
g_return_if_fail (wsm != NULL);
g_slist_foreach (wsm->options, (GFunc) wso_free, NULL);
g_slist_free (wsm->options);
memset (wsm, 0, sizeof (WirelessSecurityManager));
g_free (wsm);
}

View file

@ -0,0 +1,38 @@
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2005 Red Hat, Inc.
*/
#ifndef WIRELESS_SECURITY_COMMON_H
#define WIRELESS_SECURITY_COMMON_H
#include <gtk/gtk.h>
#include "applet.h"
typedef struct WirelessSecurityManager WirelessSecurityManager;
typedef struct WirelessSecurityOption WirelessSecurityOption;
WirelessSecurityManager * wsm_new (NMWirelessApplet *applet);
void wsm_free (WirelessSecurityManager *wsm);
void wsm_populate_combo (WirelessSecurityManager *wsm, GtkComboBox *combo);
GtkWidget * wsm_get_widget_for_index (WirelessSecurityManager *wsm, guint index);
gboolean wsm_is_ws_widget (WirelessSecurityManager *wsm, GtkWidget * widget);
#endif /* WIRELESS_SECURITY_COMMON_H */