network-manager-applet r565 - in branches/network-manager-applet-0-6: . editor src



Author: dcbw
Date: Thu Feb 28 20:08:37 2008
New Revision: 565
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=565&view=rev

Log:
2008-02-28  Dan Williams  <dcbw redhat com>

	* editor/editor-app.c
	  editor/editor-app.h
		- Split WEP options out to match applet's usage

	* src/applet.glade
		- Add "Set password" buttons to WPA-EAP password
		- Remove standalone set password dialogs

	* editor/widget-wso-leap.c
	  editor/widget-wso-wep.c
	  editor/widget-wso-wpa-enterprise.c
	  editor/widget-wso-wpa-personal.c
		- Make "Show password" just obfuscate/unobfuscate passwords
		- Only set passwords in the keyring when the "Set Password" button is
			clicked
		- Do validation on WEP and WPA-PSK keys
		- Populate the password/key entries when security widget is shown



Modified:
   branches/network-manager-applet-0-6/ChangeLog
   branches/network-manager-applet-0-6/editor/editor-app.c
   branches/network-manager-applet-0-6/editor/editor-app.h
   branches/network-manager-applet-0-6/editor/widget-wso-leap.c
   branches/network-manager-applet-0-6/editor/widget-wso-wep.c
   branches/network-manager-applet-0-6/editor/widget-wso-wpa-enterprise.c
   branches/network-manager-applet-0-6/editor/widget-wso-wpa-personal.c
   branches/network-manager-applet-0-6/src/applet.glade

Modified: branches/network-manager-applet-0-6/editor/editor-app.c
==============================================================================
--- branches/network-manager-applet-0-6/editor/editor-app.c	(original)
+++ branches/network-manager-applet-0-6/editor/editor-app.c	Thu Feb 28 20:08:37 2008
@@ -56,16 +56,6 @@
 #define WNTV_DATA_COLUMN	2
 #define WNTV_NUM_COLUMNS	3
 
-// Security Options for Combo Box
-#define SEC_OPTION_NONE				0
-#define SEC_OPTION_WEP64			1
-#define SEC_OPTION_WEP128			2
-#define SEC_OPTION_WPA_PERSONAL		3
-#define SEC_OPTION_WPA2_PERSONAL	4
-#define SEC_OPTION_WPA_ENTERPRISE	5
-#define SEC_OPTION_WPA2_ENTERPRISE	6
-#define SEC_OPTION_LEAP				7
-
 // This function not only updated the gconf entry with the new
 // essid entry, but also moves the gconf dir for the entire set
 // of entries since they are stored in gconf by the essid
@@ -187,6 +177,7 @@
 change_security_settings (gint option, gpointer data)
 {
 	WE_DATA		*we_data;
+	gint we_cipher;
 
 	we_data = data;
 	g_return_if_fail(we_data != NULL);
@@ -200,16 +191,16 @@
 			eh_gconf_client_unset(we_data, "wep_auth_algorithm");
 			eh_gconf_client_unset(we_data, "wpa_psk_wpa_version");
 			break;
-		case SEC_OPTION_WEP64:
-			eh_gconf_client_set_int(we_data, "we_cipher", 
-					IW_AUTH_CIPHER_WEP40);
-			eh_gconf_client_set_int(we_data, "wep_auth_algorithm", 
-					IW_AUTH_ALG_OPEN_SYSTEM);
-			eh_gconf_client_unset(we_data, "wpa_psk_wpa_version");
-			break;
-		case SEC_OPTION_WEP128:
-			eh_gconf_client_set_int(we_data, "we_cipher", 
-					IW_AUTH_CIPHER_WEP104);
+		case SEC_OPTION_WEP_PASSPHRASE:
+		case SEC_OPTION_WEP_HEX:
+		case SEC_OPTION_WEP_ASCII:
+			/* Only update the cipher if it's not already a WEP cipher */
+			we_cipher = eh_gconf_client_get_int(we_data, "we_cipher");
+			if (   (we_cipher != IW_AUTH_CIPHER_WEP104)
+			    && (we_cipher != IW_AUTH_CIPHER_WEP40)) {
+				eh_gconf_client_set_int(we_data, "we_cipher", 
+						IW_AUTH_CIPHER_WEP104);
+			}
 			eh_gconf_client_set_int(we_data, "wep_auth_algorithm", 
 					IW_AUTH_ALG_OPEN_SYSTEM);
 			eh_gconf_client_unset(we_data, "wpa_psk_wpa_version");
@@ -277,14 +268,16 @@
 		we_data->sub_xml = NULL;
 	}
 
+	we_data->sec_option = option;
 	switch(option)
 	{
 		default:
 		case SEC_OPTION_NONE:
 			childWidget = NULL;
 			break;
-		case SEC_OPTION_WEP64:
-		case SEC_OPTION_WEP128:
+		case SEC_OPTION_WEP_PASSPHRASE:
+		case SEC_OPTION_WEP_HEX:
+		case SEC_OPTION_WEP_ASCII:
 			childWidget = get_wep_widget(we_data);
 			break;
 		case SEC_OPTION_WPA_PERSONAL:
@@ -598,12 +591,17 @@
 
 	gtk_list_store_append (store, &iter);
 	gtk_list_store_set (store, &iter, 
-			0, _("WEP 64-bit"), 
+			0, _("WEP 128-bit Passphrase"), 
+			-1);
+
+	gtk_list_store_append (store, &iter);
+	gtk_list_store_set (store, &iter, 
+			0, _("WEP 64/128-bit Hex"), 
 			-1);
 
 	gtk_list_store_append (store, &iter);
 	gtk_list_store_set (store, &iter, 
-			0, _("WEP 128-bit"), 
+			0, _("WEP 64/128-bit ASCII"), 
 			-1);
 
 	gtk_list_store_append (store, &iter);
@@ -893,10 +891,8 @@
 			set_security_combo(SEC_OPTION_NONE, we_data);
 			break;
 		case IW_AUTH_CIPHER_WEP40:		// WEP 64bit
-			set_security_combo(SEC_OPTION_WEP64, we_data);
-			break;
 		case IW_AUTH_CIPHER_WEP104:		// WEP 128bit
-			set_security_combo(SEC_OPTION_WEP128, we_data);
+			set_security_combo(SEC_OPTION_WEP_HEX, we_data);
 			break;
 		case NM_AUTH_TYPE_WPA_PSK_AUTO:	// WPA or WPA2 PERSONAL
 		case IW_AUTH_CIPHER_TKIP:

Modified: branches/network-manager-applet-0-6/editor/editor-app.h
==============================================================================
--- branches/network-manager-applet-0-6/editor/editor-app.h	(original)
+++ branches/network-manager-applet-0-6/editor/editor-app.h	Thu Feb 28 20:08:37 2008
@@ -33,24 +33,18 @@
 #include <dbus/dbus-glib.h>
 #include <net/ethernet.h>
 
+#include <iwlib.h>
 
-// FIX THIS... these should be included from the proper files!
-/* IW_AUTH_WPA_VERSION values (bit field) */
-#define IW_AUTH_WPA_VERSION_DISABLED    0x00000001
-#define IW_AUTH_WPA_VERSION_WPA     0x00000002
-#define IW_AUTH_WPA_VERSION_WPA2    0x00000004
-
-/* IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values (bit field) */
-#define IW_AUTH_CIPHER_NONE 0x00000001
-#define IW_AUTH_CIPHER_WEP40    0x00000002
-#define IW_AUTH_CIPHER_TKIP 0x00000004
-#define IW_AUTH_CIPHER_CCMP 0x00000008
-#define IW_AUTH_CIPHER_WEP104   0x00000010
-
-/* IW_AUTH_80211_AUTH_ALG values (bit field) */
-#define IW_AUTH_ALG_OPEN_SYSTEM	0x00000001
-#define IW_AUTH_ALG_SHARED_KEY	0x00000002
-#define IW_AUTH_ALG_LEAP	0x00000004
+// Security Options for Combo Box
+#define SEC_OPTION_NONE				0
+#define SEC_OPTION_WEP_PASSPHRASE	1
+#define SEC_OPTION_WEP_HEX			2
+#define SEC_OPTION_WEP_ASCII		3
+#define SEC_OPTION_WPA_PERSONAL		4
+#define SEC_OPTION_WPA2_PERSONAL	5
+#define SEC_OPTION_WPA_ENTERPRISE	6
+#define SEC_OPTION_WPA2_ENTERPRISE	7
+#define SEC_OPTION_LEAP				8
 
 
 typedef struct _wireless_editor_data
@@ -72,6 +66,8 @@
 	gulong		stamp_date_shid;
 	gulong		stamp_time_shid;
 	gulong		combo_shid;
+
+	guint       sec_option;
 } WE_DATA;
 
 

Modified: branches/network-manager-applet-0-6/editor/widget-wso-leap.c
==============================================================================
--- branches/network-manager-applet-0-6/editor/widget-wso-leap.c	(original)
+++ branches/network-manager-applet-0-6/editor/widget-wso-leap.c	Thu Feb 28 20:08:37 2008
@@ -80,93 +80,73 @@
 	GtkWidget *widget;
 
 	widget = glade_xml_get_widget (we_data->sub_xml, "leap_password_entry");
-
-	if (gtk_toggle_button_get_active (button)) {
-		gchar *key;
-		GnomeKeyringResult kresult;
-
-		kresult = get_key_from_keyring (we_data->essid_value, &key);
-		if (kresult == GNOME_KEYRING_RESULT_OK || kresult == GNOME_KEYRING_RESULT_NO_SUCH_KEYRING) {
-			gtk_widget_set_sensitive (widget, TRUE);
-
-			if (key) {
-				gtk_entry_set_text (GTK_ENTRY (widget), key);
-				g_free (key);
-			}
-		} else
-			gtk_toggle_button_set_active (button, FALSE);
-
-		if (kresult == GNOME_KEYRING_RESULT_DENIED)
-			gtk_entry_set_text (GTK_ENTRY (widget), _("Unable to read key"));
-	} else {
-		gtk_widget_set_sensitive (widget, FALSE);
-		gtk_entry_set_text (GTK_ENTRY (widget), "");
-	}
+	gtk_entry_set_visibility (GTK_ENTRY (widget), gtk_toggle_button_get_active (button));
 }
 
 static void
 password_changed (GtkButton *button, gpointer user_data)
 {
 	WE_DATA *we_data = (WE_DATA *) user_data;
-	GladeXML			*glade_xml;
-	GtkWidget			*dialog;
-	GtkWindow			*parentWindow;
-	gint result;
-
-	glade_xml = glade_xml_new (we_data->glade_file, "set_password_dialog", NULL);
-	dialog = glade_xml_get_widget (glade_xml, "set_password_dialog");
-
-	parentWindow = GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_WINDOW));
-	gtk_window_set_transient_for (GTK_WINDOW (dialog), parentWindow);
-
-	result = gtk_dialog_run (GTK_DIALOG (dialog));
-	if (result == GTK_RESPONSE_OK) {
-		GtkWidget *entry;
+	GtkWidget *widget;
+	const gchar *key;
+	GnomeKeyringResult kresult;
 
-		const gchar *key;
-		GnomeKeyringResult kresult;
+	widget = glade_xml_get_widget (we_data->sub_xml, "leap_password_entry");
+	key = gtk_entry_get_text (GTK_ENTRY (widget));
+	if (!key)
+		return;
+
+	kresult = set_key_in_keyring (we_data->essid_value, key);
+	if (kresult != GNOME_KEYRING_RESULT_OK) {
+		GtkWindow *parent;
+
+		parent = GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_WINDOW));
+		widget = gtk_message_dialog_new (parent,
+										 GTK_DIALOG_DESTROY_WITH_PARENT,
+										 GTK_MESSAGE_ERROR,
+										 GTK_BUTTONS_CLOSE,
+										 _("Unable to set password"));
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (widget),
+										  _("There was a problem storing the password in the gnome keyring. Error 0x%02X."),
+										  (int) kresult);
 
-		entry = glade_xml_get_widget (glade_xml, "leap_password_entry");
-		key = gtk_entry_get_text (GTK_ENTRY (entry));
-		if (key) {
-			kresult = set_key_in_keyring (we_data->essid_value, key);
-			if (kresult != GNOME_KEYRING_RESULT_OK) {
-				GtkWidget *errorDialog = gtk_message_dialog_new (parentWindow,
-													    GTK_DIALOG_DESTROY_WITH_PARENT,
-													    GTK_MESSAGE_ERROR,
-													    GTK_BUTTONS_CLOSE,
-													    _("Unable to set password"));
-				gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (errorDialog),
-												  _("There was a problem storing the password in the gnome keyring. Error 0x%02X."),
-												  (int) kresult);
-
-				gtk_dialog_run (GTK_DIALOG (errorDialog));
-				gtk_widget_destroy (errorDialog);
-			}
-		}
+		gtk_dialog_run (GTK_DIALOG (widget));
+		gtk_widget_destroy (widget);
 	}
-
-	gtk_widget_destroy (dialog);
-	g_object_unref (glade_xml);
 }
 
 GtkWidget *
 get_leap_widget (WE_DATA *we_data)
 {
 	GtkWidget *main_widget;
-	GtkWidget	*widget;
+	GtkWidget *widget;
 	char *username;
 	char *key_mgmt;
 	GtkTreeModel *tree_model;
 	GtkTreeIter iter;
+	GnomeKeyringResult kresult;
+	gchar *key;
 
 	we_data->sub_xml = glade_xml_new (we_data->glade_file, "leap_notebook", NULL);
 	if (!we_data->sub_xml)
 		return NULL;
 
 	main_widget = glade_xml_get_widget (we_data->sub_xml, "leap_notebook");
-	if (!main_widget)
+	if (!main_widget) {
+		g_object_unref (we_data->sub_xml);
+		we_data->sub_xml = NULL;
 		return NULL;
+	}
+
+	/* Try to grab key from the keyring */
+	widget = glade_xml_get_widget (we_data->sub_xml, "leap_password_entry");
+	kresult = get_key_from_keyring (we_data->essid_value, &key);
+	if (kresult == GNOME_KEYRING_RESULT_OK || kresult == GNOME_KEYRING_RESULT_NO_SUCH_KEYRING) {
+		if (key) {
+			gtk_entry_set_text (GTK_ENTRY (widget), key);
+			g_free (key);
+		}
+	}
 
 	widget = glade_xml_get_widget (we_data->sub_xml, "leap_show_password");
 	g_signal_connect (widget, "toggled", G_CALLBACK (show_password_toggled), we_data);

Modified: branches/network-manager-applet-0-6/editor/widget-wso-wep.c
==============================================================================
--- branches/network-manager-applet-0-6/editor/widget-wso-wep.c	(original)
+++ branches/network-manager-applet-0-6/editor/widget-wso-wep.c	Thu Feb 28 20:08:37 2008
@@ -38,6 +38,10 @@
 #include <glade/glade.h>
 #include <gconf/gconf-client.h>
 #include <NetworkManager.h>
+#include <cipher.h>
+#include <cipher-wep-ascii.h>
+#include <cipher-wep-passphrase.h>
+#include <cipher-wep-hex.h>
 
 #include "widget-wso.h"
 
@@ -55,105 +59,105 @@
 }
 
 static void
-wep_show_toggled (GtkToggleButton *button, gpointer data)
+show_password_toggled (GtkToggleButton *button, gpointer data)
 {
 	WE_DATA *we_data = (WE_DATA *) data;
-	GtkEntry *entry;
-
-	entry = GTK_ENTRY (glade_xml_get_widget (we_data->sub_xml, "wep_key_entry"));
-
-	if (gtk_toggle_button_get_active (button)) {
-		gchar *key;
-		GnomeKeyringResult kresult;
+	GtkWidget *widget;
 
-		kresult = get_key_from_keyring (we_data->essid_value, &key);
-		if (kresult == GNOME_KEYRING_RESULT_OK || kresult == GNOME_KEYRING_RESULT_NO_SUCH_KEYRING) {
-			gtk_widget_set_sensitive (GTK_WIDGET (entry), TRUE);
+	widget = glade_xml_get_widget (we_data->sub_xml, "wep_key_entry");
+	gtk_entry_set_visibility (GTK_ENTRY (widget), gtk_toggle_button_get_active (button));
+}
 
-			if (key) {
-				gtk_entry_set_text (entry, key);
-				g_free (key);
-			}
-		} else
-			gtk_toggle_button_set_active (button, FALSE);
+static void
+wep_key_entry_changed_cb (GtkEditable *editable, gpointer user_data)
+{
+	WE_DATA *we_data = (WE_DATA *) user_data;
+	GtkEntry *entry = GTK_ENTRY (editable);
+	GtkWidget *widget;
+	const char *key;
+	IEEE_802_11_Cipher *cipher128 = NULL;
+	gboolean cipher128_valid = FALSE;
+	IEEE_802_11_Cipher *cipher64 = NULL;
+	gboolean cipher64_valid = FALSE;
+
+	key = gtk_entry_get_text (entry);
+
+	cipher128 = g_object_get_data (G_OBJECT (entry), "cipher128");
+	if (cipher128 && (ieee_802_11_cipher_validate (cipher128, we_data->essid_value, key) == 0))
+		cipher128_valid = TRUE;
+
+	cipher64 = g_object_get_data (G_OBJECT (entry), "cipher64");
+	if (cipher64 && (ieee_802_11_cipher_validate (cipher64, we_data->essid_value, key) == 0))
+		cipher64_valid = TRUE;
 
-		if (kresult == GNOME_KEYRING_RESULT_DENIED)
-			gtk_entry_set_text (entry, _("Unable to read key"));
-	} else {
-		gtk_widget_set_sensitive (GTK_WIDGET (entry), FALSE);
-		gtk_entry_set_text (entry, "");
-	}
+	widget = glade_xml_get_widget (we_data->sub_xml, "wep_set_key");
+	gtk_widget_set_sensitive (widget, (cipher128_valid || cipher64_valid) ? TRUE : FALSE);
 }
 
 static void
 set_key_button_clicked_cb (GtkButton *button, gpointer user_data)
 {
 	WE_DATA *we_data = (WE_DATA *) user_data;
-	GladeXML *glade_xml;
-	GtkListStore *store;
-	GtkTreeIter iter;
 	GtkWindow *parent;
 	GtkWidget *widget;
 	gint we_cipher;
 	gint result;
-
-	glade_xml = glade_xml_new (we_data->glade_file, "wep_key_editor", NULL);
-
-	store = gtk_list_store_new (1, G_TYPE_STRING);
-
-	gtk_list_store_append (store, &iter);
-	gtk_list_store_set (store, &iter, 0, _("Hex"), -1);
-
-	gtk_list_store_append (store, &iter);
-	gtk_list_store_set (store, &iter, 0, _("ASCII"), -1);
-
-	we_cipher = eh_gconf_client_get_int (we_data, "we_cipher");
-	if (we_cipher == IW_AUTH_CIPHER_WEP104) {
-		gtk_list_store_append (store, &iter);
-		gtk_list_store_set (store, &iter, 0, _("Passphrase"), -1);
+	const gchar *key;
+	char *hashed_key = NULL;
+	GnomeKeyringResult kresult;
+	IEEE_802_11_Cipher *cipher128 = NULL;
+	gboolean cipher128_valid = FALSE;
+	IEEE_802_11_Cipher *cipher64 = NULL;
+	gboolean cipher64_valid = FALSE;
+
+	widget = glade_xml_get_widget (we_data->sub_xml, "wep_key_entry");
+	key = gtk_entry_get_text (GTK_ENTRY (widget));
+	if (!key)
+		return;
+
+	cipher128 = g_object_get_data (G_OBJECT (widget), "cipher128");
+	if (cipher128 && (ieee_802_11_cipher_validate (cipher128, we_data->essid_value, key) == 0)) {
+		hashed_key = ieee_802_11_cipher_hash (cipher128, we_data->essid_value, key);
+		cipher128_valid = TRUE;
 	}
 
-	widget = glade_xml_get_widget (glade_xml, "wep_key_editor_combo");
-	gtk_combo_box_set_model (GTK_COMBO_BOX (widget), GTK_TREE_MODEL (store));
-	g_object_unref (store);
-	gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
-
-	parent = GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_WINDOW));
-
-	widget = glade_xml_get_widget (glade_xml, "wep_key_editor");
-	gtk_window_set_transient_for (GTK_WINDOW (widget), parent);
-	result = gtk_dialog_run (GTK_DIALOG (widget));
-	gtk_widget_hide (widget);
-
-	if (result == GTK_RESPONSE_OK) {
-		const gchar *key;
-		GnomeKeyringResult kresult;
-
-		widget = (glade_xml_get_widget (glade_xml, "wep_key_editor_entry"));
-		key = gtk_entry_get_text (GTK_ENTRY (widget));
+	cipher64 = g_object_get_data (G_OBJECT (widget), "cipher64");
+	if (!cipher128_valid) {
+		if (cipher64 && (ieee_802_11_cipher_validate (cipher64, we_data->essid_value, key) == 0)) {
+			hashed_key = ieee_802_11_cipher_hash (cipher64, we_data->essid_value, key);
+			cipher64_valid = TRUE;
+		}
+	}
 
-		/* FIXME: Nothing is done with the wep_key_editor_combo value ????? */
+	if (!cipher128_valid && !cipher64_valid) {
+		g_warning ("%s: Couldn't validate the WEP key.", __func__);
+		goto done;
+	}
 
-		if (key) {
-			kresult = set_key_in_keyring (we_data->essid_value, key);
+	kresult = set_key_in_keyring (we_data->essid_value, hashed_key);
+	if (kresult == GNOME_KEYRING_RESULT_OK) {
+		eh_gconf_client_set_int(we_data, "we_cipher",
+			ieee_802_11_cipher_get_we_cipher (cipher128_valid ? cipher128 : cipher64));
+	} else {
+		GtkWidget *dialog;
+		GtkWindow *parent;
 
-			if (kresult != GNOME_KEYRING_RESULT_OK) {
-				GtkWidget *errorDialog = gtk_message_dialog_new (parent,
-													    GTK_DIALOG_DESTROY_WITH_PARENT,
-													    GTK_MESSAGE_ERROR,
-													    GTK_BUTTONS_CLOSE,
-													    _("Unable to set key"));
-				gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (errorDialog),
-												  _("There was a problem setting the wireless key to the gnome keyring. Error 0x%02X."),
-												  (int) kresult);
+		parent = GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_WINDOW));
+		dialog = gtk_message_dialog_new (parent,
+										 GTK_DIALOG_DESTROY_WITH_PARENT,
+										 GTK_MESSAGE_ERROR,
+										 GTK_BUTTONS_CLOSE,
+										 _("Unable to set key"));
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+										  _("There was a problem setting the wireless key to the gnome keyring. Error 0x%02X."),
+										  (int) kresult);
 
-				gtk_dialog_run (GTK_DIALOG (errorDialog));
-				gtk_widget_destroy (errorDialog);
-			}
-		}
+		gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
 	}
 
-	g_object_unref (glade_xml);
+done:
+	g_free (hashed_key);
 }
 
 GtkWidget *
@@ -161,18 +165,69 @@
 {
 	GtkWidget *main_widget;
 	GtkWidget *widget;
+	GtkWidget *entry;
+	gchar *key;
 	gint intValue;
+	IEEE_802_11_Cipher *cipher128 = NULL;
+	IEEE_802_11_Cipher *cipher64 = NULL;
 
 	we_data->sub_xml = glade_xml_new (we_data->glade_file, "wep_key_notebook", NULL);
 	if (!we_data->sub_xml)
 		return NULL;
 
 	main_widget = glade_xml_get_widget (we_data->sub_xml, "wep_key_notebook");
-	if (!main_widget)
+	if (!main_widget) {
+		g_object_unref (we_data->sub_xml);
+		we_data->sub_xml = NULL;
 		return NULL;
+	}
+
+	entry = glade_xml_get_widget (we_data->sub_xml, "wep_key_entry");
+	g_signal_connect (entry, "changed", G_CALLBACK (wep_key_entry_changed_cb), we_data);
+
+	switch (we_data->sec_option) {
+		case SEC_OPTION_WEP_PASSPHRASE:
+			cipher128 = cipher_wep128_passphrase_new ();
+			break;
+		case SEC_OPTION_WEP_HEX:
+			cipher128 = cipher_wep128_hex_new ();
+			cipher64 = cipher_wep64_hex_new ();
+			break;
+		case SEC_OPTION_WEP_ASCII:
+			cipher128 = cipher_wep128_ascii_new ();
+			cipher64 = cipher_wep64_ascii_new ();
+			break;
+		default:
+			g_assert_not_reached ();
+			break;
+	}
+	g_object_set_data_full (G_OBJECT (entry), "cipher128", cipher128,
+	                        (GDestroyNotify) ieee_802_11_cipher_unref);
+	g_object_set_data_full (G_OBJECT (entry), "cipher64", cipher64,
+	                        (GDestroyNotify) ieee_802_11_cipher_unref);
 
 	widget = glade_xml_get_widget (we_data->sub_xml, "show_checkbutton");
-	g_signal_connect (widget, "toggled", G_CALLBACK (wep_show_toggled), we_data);
+	g_signal_connect (widget, "toggled", G_CALLBACK (show_password_toggled), we_data);
+
+	widget = glade_xml_get_widget (we_data->sub_xml, "wep_set_key");
+	gtk_widget_show (widget);
+	g_signal_connect (widget, "clicked", G_CALLBACK (set_key_button_clicked_cb), we_data);
+
+	/* Try to grab key from the keyring, but only if the user chose Hex,
+	 * because the key is always stored as hex in the keyring.
+	 */
+	if (we_data->sec_option == SEC_OPTION_WEP_HEX) {
+		GnomeKeyringResult kresult;
+
+		kresult = get_key_from_keyring (we_data->essid_value, &key);
+		if (kresult == GNOME_KEYRING_RESULT_OK || kresult == GNOME_KEYRING_RESULT_NO_SUCH_KEYRING) {
+			if (key) {
+				gtk_entry_set_text (GTK_ENTRY (entry), key);
+				g_free (key);
+			}
+		}
+	}
+	wep_key_entry_changed_cb (GTK_EDITABLE (entry), we_data);
 
 	widget = glade_xml_get_widget (we_data->sub_xml, "auth_method_combo");
 	intValue = eh_gconf_client_get_int (we_data, "wep_auth_algorithm");
@@ -183,9 +238,5 @@
 
 	g_signal_connect (widget, "changed", GTK_SIGNAL_FUNC (wep_auth_method_changed), we_data);
 
-	widget = glade_xml_get_widget (we_data->sub_xml, "wep_set_key");
-	gtk_widget_show (widget);
-	g_signal_connect (widget, "clicked", G_CALLBACK (set_key_button_clicked_cb), we_data);
-
 	return main_widget;
 }

Modified: branches/network-manager-applet-0-6/editor/widget-wso-wpa-enterprise.c
==============================================================================
--- branches/network-manager-applet-0-6/editor/widget-wso-wpa-enterprise.c	(original)
+++ branches/network-manager-applet-0-6/editor/widget-wso-wpa-enterprise.c	Thu Feb 28 20:08:37 2008
@@ -129,79 +129,69 @@
 }
 
 static void
-wpa_eap_password_entry_changed (GtkEntry *password_entry, gpointer data)
+wpa_eap_set_password_cb (GtkButton *button, gpointer data)
 {
 	WE_DATA *we_data = (WE_DATA *) data;
-	const gchar *password;
+	GtkWidget *widget;
+	const gchar *key;
+	GnomeKeyringResult kresult;
 
-	password = gtk_entry_get_text (password_entry);
-	if (password) {
-		GnomeKeyringResult kresult;
-
-		kresult = set_eap_key_in_keyring (we_data->essid_value, password);
-		if (kresult != GNOME_KEYRING_RESULT_OK) {
-			GtkWindow *parentWindow;
-			GtkWidget *errorDialog;
-
-			parentWindow = GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (password_entry), GTK_TYPE_WINDOW));
-			errorDialog = gtk_message_dialog_new (parentWindow,
-										   GTK_DIALOG_DESTROY_WITH_PARENT,
-										   GTK_MESSAGE_ERROR,
-										   GTK_BUTTONS_CLOSE,
-										   _("Unable to set password"));
-			gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (errorDialog),
-											  _("There was a problem storing the private password in the gnome keyring. Error 0x%02X."),
-											  (int) kresult);
-
-			gtk_dialog_run (GTK_DIALOG (errorDialog));
-			gtk_widget_destroy (errorDialog);
-		}
-	}
-}
+	widget = glade_xml_get_widget (we_data->sub_xml, "wpa_eap_passwd_entry");
+	key = gtk_entry_get_text (GTK_ENTRY (widget));
+	if (!key)
+		return;
+
+	kresult = set_eap_key_in_keyring (we_data->essid_value, key);
+	if (kresult != GNOME_KEYRING_RESULT_OK) {
+		GtkWindow *parent;
+		GtkWidget *dialog;
+
+		parent = GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_WINDOW));
+		dialog = gtk_message_dialog_new (parent,
+										 GTK_DIALOG_DESTROY_WITH_PARENT,
+										 GTK_MESSAGE_ERROR,
+										 GTK_BUTTONS_CLOSE,
+										 _("Unable to set password"));
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+										  _("There was a problem storing the EAP password in the gnome keyring. Error 0x%02X."),
+										  (int) kresult);
 
-static gboolean
-wpa_eap_password_entry_focus_lost (GtkWidget *widget, GdkEventFocus *event, gpointer data)
-{
-	wpa_eap_password_entry_changed (GTK_ENTRY (widget), data);
-	return FALSE;
+		gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
+	}
 }
 
 static void
-wpa_eap_priv_password_entry_changed (GtkEntry *pass_entry, gpointer data)
+wpa_eap_set_private_key_password_cb (GtkButton *button, gpointer data)
 {
 	WE_DATA *we_data = (WE_DATA *) data;
-	const gchar *password;
+	GtkWidget *widget;
+	const gchar *key;
+	GnomeKeyringResult kresult;
 
-	password = gtk_entry_get_text (pass_entry);
-	if (password) {
-		GnomeKeyringResult kresult;
-
-		kresult = set_key_in_keyring (we_data->essid_value, password);
-		if (kresult != GNOME_KEYRING_RESULT_OK) {
-			GtkWindow *parentWindow;
-			GtkWidget *errorDialog;
-
-			parentWindow = GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (pass_entry), GTK_TYPE_WINDOW));
-			errorDialog = gtk_message_dialog_new (parentWindow,
-										   GTK_DIALOG_DESTROY_WITH_PARENT,
-										   GTK_MESSAGE_ERROR,
-										   GTK_BUTTONS_CLOSE,
-										   _("Unable to set password"));
-			gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (errorDialog),
-											  _("There was a problem storing the private password in the gnome keyring. Error 0x%02X."),
-											  (int) kresult);
-
-			gtk_dialog_run (GTK_DIALOG (errorDialog));
-			gtk_widget_destroy (errorDialog);
-		}
-	}
-}
+	widget = glade_xml_get_widget (we_data->sub_xml, "wpa_eap_private_key_passwd_entry");
+	key = gtk_entry_get_text (GTK_ENTRY (widget));
+	if (!key)
+		return;
+
+	kresult = set_key_in_keyring (we_data->essid_value, key);
+	if (kresult != GNOME_KEYRING_RESULT_OK) {
+		GtkWindow *parent;
+		GtkWidget *dialog;
+
+		parent = GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_WINDOW));
+		dialog = gtk_message_dialog_new (parent,
+										 GTK_DIALOG_DESTROY_WITH_PARENT,
+										 GTK_MESSAGE_ERROR,
+										 GTK_BUTTONS_CLOSE,
+										 _("Unable to set password"));
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+										  _("There was a problem storing the private key password in the gnome keyring. Error 0x%02X."),
+										  (int) kresult);
 
-static gboolean
-wpa_eap_priv_password_entry_focus_lost (GtkWidget *widget, GdkEventFocus *event, gpointer data)
-{
-	wpa_eap_priv_password_entry_changed (GTK_ENTRY (widget), data);
-	return FALSE;
+		gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
+	}
 }
 
 static void
@@ -209,69 +199,12 @@
 {
 	WE_DATA *we_data = (WE_DATA *) data;
 	GtkWidget *widget;
-	gint32	sid;
-	gchar *key = NULL;
-	GnomeKeyringResult kresult;
 
 	widget = glade_xml_get_widget (we_data->sub_xml, "wpa_eap_passwd_entry");
-	if (gtk_toggle_button_get_active (button)) {
-		kresult = get_eap_key_from_keyring (we_data->essid_value, &key);
-		if (key) {
-			gtk_entry_set_text (GTK_ENTRY (widget), key);
-			g_free (key);
-		} else
-			gtk_entry_set_text (GTK_ENTRY (widget), "");
-
-		gtk_widget_set_sensitive (widget, TRUE);
-		gtk_entry_set_editable (GTK_ENTRY (widget), TRUE);
-
-		sid = g_signal_connect (widget, "activate", 
-						    GTK_SIGNAL_FUNC (wpa_eap_password_entry_changed), we_data);
-		g_object_set_data (G_OBJECT (widget), "password_activate_sid", GINT_TO_POINTER (sid));
-		sid = g_signal_connect (widget, "focus-out-event", 
-						    GTK_SIGNAL_FUNC (wpa_eap_password_entry_focus_lost), 
-						    we_data);
-		g_object_set_data (G_OBJECT (widget), "password_focus_out_sid", GINT_TO_POINTER (sid));
-	} else {
-		gtk_widget_set_sensitive (widget, FALSE);
-		gtk_entry_set_editable (GTK_ENTRY (widget), FALSE);
-		gtk_entry_set_text (GTK_ENTRY (widget), "");
+	gtk_entry_set_visibility (GTK_ENTRY (widget), gtk_toggle_button_get_active (button));
 
-		sid = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "password_activate_sid"));
-		g_signal_handler_disconnect (widget, sid);
-		sid = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "password_focus_out_sid"));
-		g_signal_handler_disconnect (widget, sid);
-	}
-
-	widget = glade_xml_get_widget(we_data->sub_xml, "wpa_eap_private_key_passwd_entry");
-	if (gtk_toggle_button_get_active(button)) {
-		kresult = get_key_from_keyring (we_data->essid_value, &key);
-		if(key) {
-			gtk_entry_set_text (GTK_ENTRY (widget), key);
-			g_free (key);
-		}
-
-		gtk_widget_set_sensitive (widget, TRUE);
-		gtk_entry_set_editable (GTK_ENTRY (widget), TRUE);
-
-		sid = g_signal_connect (widget, "activate", 
-						    GTK_SIGNAL_FUNC (wpa_eap_priv_password_entry_changed), 
-						    we_data);
-		g_object_set_data (G_OBJECT (widget), "priv_password_activate_sid", GINT_TO_POINTER (sid));
-		sid = g_signal_connect (widget, "focus-out-event", 
-						    GTK_SIGNAL_FUNC (wpa_eap_priv_password_entry_focus_lost), 
-						    we_data);
-		g_object_set_data (G_OBJECT (widget), "priv_password_focus_out_sid", GINT_TO_POINTER(sid));
-	} else {
-		gtk_widget_set_sensitive (widget, FALSE);
-		gtk_entry_set_editable (GTK_ENTRY (widget), FALSE);
-		gtk_entry_set_text (GTK_ENTRY (widget), "");
-
-		sid = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "priv_password_activate_sid"));
-		g_signal_handler_disconnect(widget, sid);
-		sid = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "priv_password_focus_out_sid"));
-		g_signal_handler_disconnect (widget, sid);
-	}
+	widget = glade_xml_get_widget (we_data->sub_xml, "wpa_eap_private_key_passwd_entry");
+	gtk_entry_set_visibility (GTK_ENTRY (widget), gtk_toggle_button_get_active (button));
 }
 
 static void
@@ -313,15 +246,17 @@
 GtkWidget *
 get_wpa_enterprise_widget (WE_DATA *we_data)
 {
-	GtkWidget			*main_widget = NULL;
-	GtkWidget			*widget = NULL;
-	gint				intValue;
-	gchar				*strValue;
+	GtkWidget *main_widget = NULL;
+	GtkWidget *widget = NULL;
+	gint intValue;
+	gchar* strValue;
 	GtkTreeModel *tree_model;
 	GtkTreeIter iter;
 	GtkCellRenderer *renderer;
 	int num_added;
 	int capabilities = 0xFFFFFFFF;
+	GnomeKeyringResult kresult;
+	char *key = NULL;
 
 	we_data->sub_xml = glade_xml_new (we_data->glade_file, "wpa_eap_notebook", NULL);
 	if (!we_data->sub_xml)
@@ -331,9 +266,6 @@
 	if (!main_widget)
 		return NULL;
 
-	widget = glade_xml_get_widget (we_data->sub_xml, "show_checkbutton");
-	g_signal_connect (widget, "toggled", G_CALLBACK (wpa_eap_show_toggled), we_data);
-
 	renderer = gtk_cell_renderer_text_new ();
 
 	/* EAP method combo */
@@ -427,5 +359,31 @@
 
 	g_signal_connect (widget, "selection-changed", GTK_SIGNAL_FUNC (wpa_eap_ca_key_changed), we_data);
 
+	widget = glade_xml_get_widget (we_data->sub_xml, "show_checkbutton");
+	g_signal_connect (widget, "toggled", G_CALLBACK (wpa_eap_show_toggled), we_data);
+
+	widget = glade_xml_get_widget (we_data->sub_xml, "wpa_eap_set_password");
+	g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK (wpa_eap_set_password_cb), we_data);
+	gtk_widget_show (widget);
+
+	widget = glade_xml_get_widget (we_data->sub_xml, "wpa_eap_passwd_entry");
+	kresult = get_eap_key_from_keyring (we_data->essid_value, &key);
+	if (key) {
+		gtk_entry_set_text (GTK_ENTRY (widget), key);
+		g_free (key);
+		key = NULL;
+	}
+
+	widget = glade_xml_get_widget (we_data->sub_xml, "wpa_eap_set_private_key_password");
+	g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK (wpa_eap_set_private_key_password_cb), we_data);
+	gtk_widget_show (widget);
+
+	widget = glade_xml_get_widget (we_data->sub_xml, "wpa_eap_private_key_passwd_entry");
+	kresult = get_key_from_keyring (we_data->essid_value, &key);
+	if (key) {
+		gtk_entry_set_text (GTK_ENTRY (widget), key);
+		g_free (key);
+	}
+
 	return main_widget;
 }

Modified: branches/network-manager-applet-0-6/editor/widget-wso-wpa-personal.c
==============================================================================
--- branches/network-manager-applet-0-6/editor/widget-wso-wpa-personal.c	(original)
+++ branches/network-manager-applet-0-6/editor/widget-wso-wpa-personal.c	Thu Feb 28 20:08:37 2008
@@ -38,6 +38,10 @@
 #include <glade/glade.h>
 #include <gconf/gconf-client.h>
 #include <NetworkManager.h>
+#include <cipher.h>
+#include <cipher-wpa-psk-hex.h>
+#include <cipher-wpa-psk-passphrase.h>
+
 #include "widget-wso.h"
 #include "libnma/libnma.h"
 
@@ -58,92 +62,116 @@
 }
 
 static void
+wpa_psk_key_entry_changed_cb (GtkEditable *editable, gpointer user_data)
+{
+	WE_DATA *we_data = (WE_DATA *) user_data;
+	GtkEntry *entry = GTK_ENTRY (editable);
+	GtkWidget *widget;
+	const char *key;
+	IEEE_802_11_Cipher *cipher_passphrase = NULL;
+	gboolean cipher_passphrase_valid = FALSE;
+	IEEE_802_11_Cipher *cipher_hex = NULL;
+	gboolean cipher_hex_valid = FALSE;
+
+	key = gtk_entry_get_text (entry);
+
+	cipher_passphrase = g_object_get_data (G_OBJECT (entry), "cipher-passphrase");
+	if (cipher_passphrase && (ieee_802_11_cipher_validate (cipher_passphrase, we_data->essid_value, key) == 0))
+		cipher_passphrase_valid = TRUE;
+
+	cipher_hex = g_object_get_data (G_OBJECT (entry), "cipher-hex");
+	if (cipher_hex && (ieee_802_11_cipher_validate (cipher_hex, we_data->essid_value, key) == 0))
+		cipher_hex_valid = TRUE;
+
+	widget = glade_xml_get_widget (we_data->sub_xml, "wpa_psk_set_password");
+	gtk_widget_set_sensitive (widget, (cipher_passphrase_valid || cipher_hex_valid) ? TRUE : FALSE);
+}
+
+static void
 wpa_psk_show_toggled (GtkToggleButton *button, gpointer data)
 {
 	WE_DATA *we_data = (WE_DATA *) data;
 	GtkWidget *widget;
 
 	widget = glade_xml_get_widget (we_data->sub_xml, "wpa_psk_entry");
-
-	if (gtk_toggle_button_get_active (button)) {
-		gchar *key;
-		GnomeKeyringResult kresult;
-
-		kresult = get_key_from_keyring (we_data->essid_value, &key);
-		if (kresult == GNOME_KEYRING_RESULT_OK || kresult == GNOME_KEYRING_RESULT_NO_SUCH_KEYRING) {
-			gtk_widget_set_sensitive (widget, TRUE);
-
-			if (key) {
-				gtk_entry_set_text (GTK_ENTRY (widget), key);
-				g_free (key);
-			}
-		} else
-			gtk_toggle_button_set_active (button, FALSE);
-
-		if (kresult == GNOME_KEYRING_RESULT_DENIED)
-			gtk_entry_set_text (GTK_ENTRY (widget), _("Unable to read key"));
-	} else {
-		gtk_widget_set_sensitive (widget, FALSE);
-		gtk_entry_set_text (GTK_ENTRY (widget), "");
-	}
+	gtk_entry_set_visibility (GTK_ENTRY (widget), gtk_toggle_button_get_active (button));
 }
 
 static void
 wpa_psk_set_password_button_clicked_cb (GtkButton *button, gpointer user_data)
 {
 	WE_DATA *we_data = (WE_DATA *) user_data;
-	GladeXML			*glade_xml;
-	GtkWidget			*dialog;
-	GtkWindow			*parentWindow;
 	gint result;
+	GtkWidget *entry;
+	const gchar *key;
+	char *hashed_key = NULL;
+	GnomeKeyringResult kresult;
+	IEEE_802_11_Cipher *cipher_passphrase = NULL;
+	gboolean cipher_passphrase_valid = FALSE;
+	IEEE_802_11_Cipher *cipher_hex = NULL;
+	gboolean cipher_hex_valid = FALSE;
+
+	entry = glade_xml_get_widget (we_data->sub_xml, "password_entry");
+	key = gtk_entry_get_text (GTK_ENTRY (entry));
+	if (!key)
+		return;
+
+	cipher_passphrase = g_object_get_data (G_OBJECT (entry), "cipher-passphrase");
+	if (cipher_passphrase && (ieee_802_11_cipher_validate (cipher_passphrase, we_data->essid_value, key) == 0)) {
+		hashed_key = ieee_802_11_cipher_hash (cipher_passphrase, we_data->essid_value, key);
+		cipher_passphrase_valid = TRUE;
+	}
 
-	glade_xml = glade_xml_new (we_data->glade_file, "set_password_dialog", NULL);
-	dialog = glade_xml_get_widget (glade_xml, "set_password_dialog");
-
-	parentWindow = GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_WINDOW));
-	gtk_window_set_transient_for (GTK_WINDOW (dialog), parentWindow);
+	cipher_hex = g_object_get_data (G_OBJECT (entry), "cipher-hex");
+	if (!cipher_passphrase_valid) {
+		if (cipher_hex && (ieee_802_11_cipher_validate (cipher_hex, we_data->essid_value, key) == 0)) {
+			hashed_key = ieee_802_11_cipher_hash (cipher_hex, we_data->essid_value, key);
+			cipher_hex_valid = TRUE;
+		}
+	}
 
-	result = gtk_dialog_run (GTK_DIALOG (dialog));
-	if (result == GTK_RESPONSE_OK) {
-		GtkWidget *entry;
+	if (!cipher_passphrase_valid && !cipher_hex_valid) {
+		g_warning ("%s: Couldn't validate the WPA passphrase/key.", __func__);
+		goto done;
+	}
 
-		const gchar *key;
-		GnomeKeyringResult kresult;
+	kresult = set_key_in_keyring (we_data->essid_value, hashed_key);
+	if (kresult != GNOME_KEYRING_RESULT_OK) {
+		GtkWindow *parent;
+		GtkWidget *dialog;
+
+		parent = GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_WINDOW));
+		dialog = gtk_message_dialog_new (parent,
+										 GTK_DIALOG_DESTROY_WITH_PARENT,
+										 GTK_MESSAGE_ERROR,
+										 GTK_BUTTONS_CLOSE,
+										 _("Unable to set password"));
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+										  _("There was a problem storing the password in the gnome keyring. Error 0x%02X."),
+										  (int) kresult);
 
-		entry = glade_xml_get_widget (glade_xml, "password_entry");
-		key = gtk_entry_get_text (GTK_ENTRY (entry));
-		if (key) {
-			kresult = set_key_in_keyring (we_data->essid_value, key);
-			if (kresult != GNOME_KEYRING_RESULT_OK) {
-				GtkWidget *errorDialog = gtk_message_dialog_new (parentWindow,
-													    GTK_DIALOG_DESTROY_WITH_PARENT,
-													    GTK_MESSAGE_ERROR,
-													    GTK_BUTTONS_CLOSE,
-													    _("Unable to set password"));
-				gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (errorDialog),
-												  _("There was a problem storing the password in the gnome keyring. Error 0x%02X."),
-												  (int) kresult);
-
-				gtk_dialog_run (GTK_DIALOG (errorDialog));
-				gtk_widget_destroy (errorDialog);
-			}
-		}
+		gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
 	}
 
-	gtk_widget_destroy (dialog);
-	g_object_unref (glade_xml);
+done:
+	g_free (hashed_key);
 }
 
 GtkWidget *
 get_wpa_personal_widget (WE_DATA *we_data)
 {
 	GtkWidget *main_widget;
-	GtkWidget	*widget;
+	GtkWidget *widget;
 	gint intValue;
 	GtkTreeModel *tree_model;
 	GtkTreeIter iter;
 	int num_added;
 	int capabilities = 0xFFFFFFFF;
+	IEEE_802_11_Cipher *cipher_passphrase = NULL;
+	IEEE_802_11_Cipher *cipher_hex = NULL;
+	GnomeKeyringResult kresult;
+	char *key = NULL;
 
 	we_data->sub_xml = glade_xml_new (we_data->glade_file, "wpa_psk_notebook", NULL);
 	if (!we_data->sub_xml)
@@ -169,6 +197,25 @@
 
 	g_signal_connect (widget, "changed", GTK_SIGNAL_FUNC (wpa_psk_type_changed), we_data);
 
+	widget = glade_xml_get_widget (we_data->sub_xml, "wpa_psk_entry");
+	g_signal_connect (widget, "changed", GTK_SIGNAL_FUNC (wpa_psk_key_entry_changed_cb), we_data);
+	cipher_passphrase = cipher_wpa_psk_passphrase_new ();
+	cipher_hex = cipher_wpa_psk_hex_new ();
+	g_object_set_data_full (G_OBJECT (widget), "cipher-passphrase", cipher_passphrase,
+	                        (GDestroyNotify) ieee_802_11_cipher_unref);
+	g_object_set_data_full (G_OBJECT (widget), "cipher-hex", cipher_hex,
+	                        (GDestroyNotify) ieee_802_11_cipher_unref);
+
+	/* Try to grab key from the keyring */
+	kresult = get_key_from_keyring (we_data->essid_value, &key);
+	if (kresult == GNOME_KEYRING_RESULT_OK || kresult == GNOME_KEYRING_RESULT_NO_SUCH_KEYRING) {
+		if (key) {
+			gtk_entry_set_text (GTK_ENTRY (widget), key);
+			g_free (key);
+		}
+	}
+	wpa_psk_key_entry_changed_cb (GTK_EDITABLE (widget), we_data);
+
 	widget = glade_xml_get_widget (we_data->sub_xml, "wpa_psk_set_password");
 	g_signal_connect (widget, "clicked", G_CALLBACK (wpa_psk_set_password_button_clicked_cb), we_data);
 	gtk_widget_show (widget);

Modified: branches/network-manager-applet-0-6/src/applet.glade
==============================================================================
--- branches/network-manager-applet-0-6/src/applet.glade	(original)
+++ branches/network-manager-applet-0-6/src/applet.glade	Thu Feb 28 20:08:37 2008
@@ -2572,26 +2572,6 @@
 	  </child>
 
 	  <child>
-	    <widget class="GtkEntry" id="wpa_eap_private_key_passwd_entry">
-	      <property name="visible">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="editable">True</property>
-	      <property name="visibility">False</property>
-	      <property name="max_length">0</property>
-	      <property name="text" translatable="yes"></property>
-	      <property name="has_frame">True</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">9</property>
-	      <property name="bottom_attach">10</property>
-	      <property name="y_options"></property>
-	    </packing>
-	  </child>
-
-	  <child>
 	    <widget class="GtkLabel" id="wpa-eap-client-cert-file-label">
 	      <property name="visible">True</property>
 	      <property name="label" translatable="yes">Client Certificate File:</property>
@@ -2744,26 +2724,6 @@
 	  </child>
 
 	  <child>
-	    <widget class="GtkEntry" id="wpa_eap_passwd_entry">
-	      <property name="visible">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="editable">True</property>
-	      <property name="visibility">False</property>
-	      <property name="max_length">0</property>
-	      <property name="text" translatable="yes"></property>
-	      <property name="has_frame">True</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">4</property>
-	      <property name="bottom_attach">5</property>
-	      <property name="y_options"></property>
-	    </packing>
-	  </child>
-
-	  <child>
 	    <widget class="GtkEntry" id="wpa_eap_anon_identity_entry">
 	      <property name="visible">True</property>
 	      <property name="can_focus">True</property>
@@ -2964,6 +2924,104 @@
 	      <property name="y_options"></property>
 	    </packing>
 	  </child>
+
+	  <child>
+	    <widget class="GtkHBox" id="hbox18">
+	      <property name="visible">True</property>
+	      <property name="homogeneous">False</property>
+	      <property name="spacing">0</property>
+
+	      <child>
+		<widget class="GtkEntry" id="wpa_eap_passwd_entry">
+		  <property name="visible">True</property>
+		  <property name="can_focus">True</property>
+		  <property name="editable">True</property>
+		  <property name="visibility">False</property>
+		  <property name="max_length">0</property>
+		  <property name="text" translatable="yes"></property>
+		  <property name="has_frame">True</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>
+
+	      <child>
+		<widget class="GtkButton" id="wpa_eap_set_password">
+		  <property name="can_focus">True</property>
+		  <property name="label" translatable="yes">Set _Password</property>
+		  <property name="use_underline">True</property>
+		  <property name="relief">GTK_RELIEF_NORMAL</property>
+		  <property name="focus_on_click">True</property>
+		</widget>
+		<packing>
+		  <property name="padding">0</property>
+		  <property name="expand">False</property>
+		  <property name="fill">False</property>
+		</packing>
+	      </child>
+	    </widget>
+	    <packing>
+	      <property name="left_attach">1</property>
+	      <property name="right_attach">2</property>
+	      <property name="top_attach">4</property>
+	      <property name="bottom_attach">5</property>
+	      <property name="x_options">fill</property>
+	      <property name="y_options">fill</property>
+	    </packing>
+	  </child>
+
+	  <child>
+	    <widget class="GtkHBox" id="hbox19">
+	      <property name="visible">True</property>
+	      <property name="homogeneous">False</property>
+	      <property name="spacing">0</property>
+
+	      <child>
+		<widget class="GtkEntry" id="wpa_eap_private_key_passwd_entry">
+		  <property name="visible">True</property>
+		  <property name="can_focus">True</property>
+		  <property name="editable">True</property>
+		  <property name="visibility">False</property>
+		  <property name="max_length">0</property>
+		  <property name="text" translatable="yes"></property>
+		  <property name="has_frame">True</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>
+
+	      <child>
+		<widget class="GtkButton" id="wpa_eap_set_private_key_password">
+		  <property name="can_focus">True</property>
+		  <property name="label" translatable="yes">Set _Password</property>
+		  <property name="use_underline">True</property>
+		  <property name="relief">GTK_RELIEF_NORMAL</property>
+		  <property name="focus_on_click">True</property>
+		</widget>
+		<packing>
+		  <property name="padding">0</property>
+		  <property name="expand">False</property>
+		  <property name="fill">False</property>
+		</packing>
+	      </child>
+	    </widget>
+	    <packing>
+	      <property name="left_attach">1</property>
+	      <property name="right_attach">2</property>
+	      <property name="top_attach">9</property>
+	      <property name="bottom_attach">10</property>
+	      <property name="x_options">fill</property>
+	      <property name="y_options">fill</property>
+	    </packing>
+	  </child>
 	</widget>
 	<packing>
 	  <property name="tab_expand">False</property>
@@ -3390,183 +3448,6 @@
   </child>
 </widget>
 
-<widget class="GtkDialog" id="wep_key_editor">
-  <property name="title" translatable="yes">Set WEP Key</property>
-  <property name="type">GTK_WINDOW_TOPLEVEL</property>
-  <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
-  <property name="modal">False</property>
-  <property name="resizable">False</property>
-  <property name="destroy_with_parent">True</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_DIALOG</property>
-  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
-  <property name="focus_on_map">True</property>
-  <property name="urgency_hint">False</property>
-  <property name="has_separator">False</property>
-
-  <child internal-child="vbox">
-    <widget class="GtkVBox" id="vbox4">
-      <property name="visible">True</property>
-      <property name="homogeneous">False</property>
-      <property name="spacing">0</property>
-
-      <child internal-child="action_area">
-	<widget class="GtkHButtonBox" id="hbuttonbox2">
-	  <property name="visible">True</property>
-	  <property name="layout_style">GTK_BUTTONBOX_END</property>
-
-	  <child>
-	    <widget class="GtkButton" id="button1">
-	      <property name="visible">True</property>
-	      <property name="can_default">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label">gtk-cancel</property>
-	      <property name="use_stock">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="focus_on_click">True</property>
-	      <property name="response_id">-6</property>
-	    </widget>
-	  </child>
-
-	  <child>
-	    <widget class="GtkButton" id="button2">
-	      <property name="visible">True</property>
-	      <property name="can_default">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label">gtk-ok</property>
-	      <property name="use_stock">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="focus_on_click">True</property>
-	      <property name="response_id">-5</property>
-	    </widget>
-	  </child>
-	</widget>
-	<packing>
-	  <property name="padding">0</property>
-	  <property name="expand">False</property>
-	  <property name="fill">True</property>
-	  <property name="pack_type">GTK_PACK_END</property>
-	</packing>
-      </child>
-
-      <child>
-	<widget class="GtkTable" id="table9">
-	  <property name="border_width">5</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">12</property>
-
-	  <child>
-	    <widget class="GtkLabel" id="label35">
-	      <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</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="GtkEntry" id="wep_key_editor_entry">
-	      <property name="width_request">300</property>
-	      <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="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="GtkLabel" id="label36">
-	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">Format:</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</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>
-
-	  <child>
-	    <widget class="GtkComboBox" id="wep_key_editor_combo">
-	      <property name="visible">True</property>
-	      <property name="items" translatable="yes">Hex
-ASCII
-Passphrase</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">1</property>
-	      <property name="bottom_attach">2</property>
-	      <property name="x_options">fill</property>
-	      <property name="y_options">fill</property>
-	    </packing>
-	  </child>
-	</widget>
-	<packing>
-	  <property name="padding">0</property>
-	  <property name="expand">True</property>
-	  <property name="fill">True</property>
-	</packing>
-      </child>
-    </widget>
-  </child>
-</widget>
-
 <widget class="GtkWindow" id="wireless_editor">
   <property name="title" translatable="yes">Wireless Networks</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]