[network-manager-applet] applet: request secrets in the applet's wireless dialog



commit 39bf65351dd8d8dc6a5740ff0644999efddad049
Author: Dan Williams <dcbw redhat com>
Date:   Mon Oct 19 12:27:23 2009 -0700

    applet: request secrets in the applet's wireless dialog
    
    Somewhat broken by the libnm-glib settings service refactor,
    but it wouldn't have worked with system connections before anyway,
    since nothing explicitly requested system setting secrets from
    the wireless dialog. (The connection editor was OK)
    
    This commit basically refactors the population of the various
    GtkEntry widgets for secrets and the TLS private key filepicker to
    happen both at UI creation time, *and* to update them after
    getting secrets.  The wireless dialog now explicitly requests
    secrets from a connection every time that connection is selected
    from the Connection: combo, and when the secrets come back populates
    the UI with them, which triggers dialog validation, which will
    then enable the Connect... button.

 src/wireless-dialog.c                     |   95 +++++++++++++++++++++++++++++
 src/wireless-security/eap-method-leap.c   |   24 +++++---
 src/wireless-security/eap-method-leap.h   |    3 +-
 src/wireless-security/eap-method-peap.c   |   12 +++-
 src/wireless-security/eap-method-peap.h   |    3 +-
 src/wireless-security/eap-method-simple.c |   24 +++++---
 src/wireless-security/eap-method-simple.h |    3 +-
 src/wireless-security/eap-method-tls.c    |   74 ++++++++++++++++-------
 src/wireless-security/eap-method-tls.h    |    3 +-
 src/wireless-security/eap-method-ttls.c   |   10 +++
 src/wireless-security/eap-method-ttls.h   |    3 +-
 src/wireless-security/eap-method.c        |   44 +++++++++++++
 src/wireless-security/eap-method.h        |   13 ++++-
 src/wireless-security/helpers.c           |   21 ++++---
 src/wireless-security/helpers.h           |    9 ++-
 src/wireless-security/wireless-security.c |   45 +++++++++++++-
 src/wireless-security/wireless-security.h |   13 ++++-
 src/wireless-security/ws-dynamic-wep.c    |   10 +++-
 src/wireless-security/ws-dynamic-wep.h    |    3 +-
 src/wireless-security/ws-leap.c           |   24 +++++---
 src/wireless-security/ws-leap.h           |    3 +-
 src/wireless-security/ws-wep-key.c        |   23 ++++---
 src/wireless-security/ws-wep-key.h        |    3 +-
 src/wireless-security/ws-wpa-eap.c        |   10 +++-
 src/wireless-security/ws-wpa-eap.h        |    3 +-
 src/wireless-security/ws-wpa-psk.c        |   24 +++++---
 src/wireless-security/ws-wpa-psk.h        |    3 +-
 27 files changed, 407 insertions(+), 98 deletions(-)
---
diff --git a/src/wireless-dialog.c b/src/wireless-dialog.c
index 419972c..95041e5 100644
--- a/src/wireless-dialog.c
+++ b/src/wireless-dialog.c
@@ -717,6 +717,79 @@ add_security_item (NMAWirelessDialog *self,
 	wireless_security_unref (sec);
 }
 
+typedef struct {
+	NMAWirelessDialog *self;
+	NMConnection *connection;
+} GetSecretsInfo;
+
+static void
+get_secrets_cb (NMSettingsConnectionInterface *connection,
+                GHashTable *secrets,
+                GError *error,
+                gpointer user_data)
+{
+	GetSecretsInfo *info = user_data;
+	NMAWirelessDialogPrivate *priv = NMA_WIRELESS_DIALOG_GET_PRIVATE (info->self);
+	GHashTableIter hash_iter;
+	gpointer key, value;
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+
+	if (error) {
+		g_warning ("%s: error getting connection secrets: (%d) %s",
+		           __func__,
+		           error ? error->code : -1,
+		           error && error->message ? error->message : "(unknown)");
+		goto out;
+	}
+
+	/* User might have changed the connection while the secrets call was in
+	 * progress, so don't try to update the wrong connection with the secrets
+	 * we just received.
+	 */
+	if (   (priv->connection != info->connection)
+	    || !secrets
+	    || !g_hash_table_size (secrets))
+		goto out;
+
+	/* Try to update the connection's secrets; log errors but we don't care */
+	g_hash_table_iter_init (&hash_iter, secrets);
+	while (g_hash_table_iter_next (&hash_iter, &key, &value)) {
+		GError *update_error = NULL;
+		const char *setting_name = key;
+		GHashTable *setting_hash = value;
+
+		if (!nm_connection_update_secrets (priv->connection,
+		                                   setting_name,
+		                                   setting_hash,
+		                                   &update_error)) {
+			g_warning ("%s: error updating connection secrets: (%d) %s",
+			           __func__,
+			           update_error ? update_error->code : -1,
+			           update_error && update_error->message ? update_error->message : "(unknown)");
+			g_clear_error (&update_error);
+		}
+	}
+
+	/* Update each security method's UI elements with the new secrets */
+	model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->sec_combo));
+	if (gtk_tree_model_get_iter_first (model, &iter)) {
+		do {
+			WirelessSecurity *sec = NULL;
+
+			gtk_tree_model_get (model, &iter, S_SEC_COLUMN, &sec, -1);
+			if (sec) {
+				wireless_security_update_secrets (sec, priv->connection);
+				wireless_security_unref (sec);
+			}
+		} while (gtk_tree_model_iter_next (model, &iter));
+	}
+
+out:
+	g_object_unref (info->connection);
+	g_free (info);
+}
+
 static gboolean
 security_combo_init (NMAWirelessDialog *self, gboolean auth_only)
 {
@@ -882,6 +955,28 @@ security_combo_init (NMAWirelessDialog *self, gboolean auth_only)
 	gtk_combo_box_set_model (GTK_COMBO_BOX (priv->sec_combo), GTK_TREE_MODEL (sec_model));
 	gtk_combo_box_set_active (GTK_COMBO_BOX (priv->sec_combo), active < 0 ? 0 : (guint32) active);
 	g_object_unref (G_OBJECT (sec_model));
+
+	/* Request secrets for the connection if it needs any */
+	if (NM_IS_SETTINGS_CONNECTION_INTERFACE (priv->connection)) {
+		const char *setting_name;
+
+		setting_name = nm_connection_need_secrets (priv->connection, NULL);
+		if (setting_name) {
+			GetSecretsInfo *info;
+
+			info = g_malloc0 (sizeof (GetSecretsInfo));
+			info->self = self;
+			info->connection = g_object_ref (priv->connection);
+
+			nm_settings_connection_interface_get_secrets (NM_SETTINGS_CONNECTION_INTERFACE (priv->connection),
+			                                              setting_name,
+			                                              NULL,
+			                                              FALSE,
+			                                              get_secrets_cb,
+			                                              info);
+		}
+	}
+
 	return TRUE;
 }
 
diff --git a/src/wireless-security/eap-method-leap.c b/src/wireless-security/eap-method-leap.c
index e766488..8314647 100644
--- a/src/wireless-security/eap-method-leap.c
+++ b/src/wireless-security/eap-method-leap.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #include <glade/glade.h>
@@ -105,6 +106,16 @@ fill_connection (EAPMethod *parent, NMConnection *connection)
 	g_object_set (s_8021x, NM_SETTING_802_1X_PASSWORD, gtk_entry_get_text (GTK_ENTRY (widget)), NULL);
 }
 
+static void
+update_secrets (EAPMethod *parent, NMConnection *connection)
+{
+	helper_fill_secret_entry (connection,
+	                          parent->xml,
+	                          "eap_leap_password_entry",
+	                          NM_TYPE_SETTING_802_1X,
+	                          (HelperSecretFunc) nm_setting_802_1x_get_password);
+}
+
 EAPMethodLEAP *
 eap_method_leap_new (const char *glade_file,
                      WirelessSecurity *parent,
@@ -137,6 +148,7 @@ eap_method_leap_new (const char *glade_file,
 	                 validate,
 	                 add_to_size_group,
 	                 fill_connection,
+	                 update_secrets,
 	                 destroy,
 	                 xml,
 	                 widget,
@@ -162,14 +174,8 @@ eap_method_leap_new (const char *glade_file,
 	                  parent);
 
 	/* Fill secrets, if any */
-	if (connection) {
-		helper_fill_secret_entry (connection,
-		                          GTK_ENTRY (widget),
-		                          NM_TYPE_SETTING_802_1X,
-		                          (HelperSecretFunc) nm_setting_802_1x_get_password,
-		                          NM_SETTING_802_1X_SETTING_NAME,
-		                          NM_SETTING_802_1X_PASSWORD);
-	}
+	if (connection)
+		update_secrets (EAP_METHOD (method), connection);
 
 	widget = glade_xml_get_widget (xml, "show_checkbutton");
 	g_assert (widget);
diff --git a/src/wireless-security/eap-method-leap.h b/src/wireless-security/eap-method-leap.h
index 3fb306a..dc6de16 100644
--- a/src/wireless-security/eap-method-leap.h
+++ b/src/wireless-security/eap-method-leap.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #ifndef EAP_METHOD_LEAP_H
diff --git a/src/wireless-security/eap-method-peap.c b/src/wireless-security/eap-method-peap.c
index 4905c40..5c849fa 100644
--- a/src/wireless-security/eap-method-peap.c
+++ b/src/wireless-security/eap-method-peap.c
@@ -17,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #include <glib/gi18n.h>
@@ -293,6 +293,15 @@ inner_auth_combo_init (EAPMethodPEAP *method,
 	return combo;
 }
 
+static void
+update_secrets (EAPMethod *parent, NMConnection *connection)
+{
+	eap_method_phase2_update_secrets_helper (parent,
+	                                         connection,
+	                                         "eap_peap_inner_auth_combo",
+	                                         I_METHOD_COLUMN);
+}
+
 EAPMethodPEAP *
 eap_method_peap_new (const char *glade_file,
                      WirelessSecurity *parent,
@@ -328,6 +337,7 @@ eap_method_peap_new (const char *glade_file,
 	                 validate,
 	                 add_to_size_group,
 	                 fill_connection,
+	                 update_secrets,
 	                 destroy,
 	                 xml,
 	                 widget,
diff --git a/src/wireless-security/eap-method-peap.h b/src/wireless-security/eap-method-peap.h
index b3da5bf..82f9d06 100644
--- a/src/wireless-security/eap-method-peap.h
+++ b/src/wireless-security/eap-method-peap.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #ifndef EAP_METHOD_PEAP_H
diff --git a/src/wireless-security/eap-method-simple.c b/src/wireless-security/eap-method-simple.c
index dfae3c6..0eea74a 100644
--- a/src/wireless-security/eap-method-simple.c
+++ b/src/wireless-security/eap-method-simple.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #include <glade/glade.h>
@@ -128,6 +129,16 @@ fill_connection (EAPMethod *parent, NMConnection *connection)
 	g_object_set (s_8021x, NM_SETTING_802_1X_PASSWORD, gtk_entry_get_text (GTK_ENTRY (widget)), NULL);
 }
 
+static void
+update_secrets (EAPMethod *parent, NMConnection *connection)
+{
+	helper_fill_secret_entry (connection,
+	                          parent->xml,
+	                          "eap_simple_password_entry",
+	                          NM_TYPE_SETTING_802_1X,
+	                          (HelperSecretFunc) nm_setting_802_1x_get_password);
+}
+
 EAPMethodSimple *
 eap_method_simple_new (const char *glade_file,
                        WirelessSecurity *parent,
@@ -161,6 +172,7 @@ eap_method_simple_new (const char *glade_file,
 	                 validate,
 	                 add_to_size_group,
 	                 fill_connection,
+	                 update_secrets,
 	                 destroy,
 	                 xml,
 	                 widget,
@@ -188,14 +200,8 @@ eap_method_simple_new (const char *glade_file,
 	                  parent);
 
 	/* Fill secrets, if any */
-	if (connection) {
-		helper_fill_secret_entry (connection,
-		                          GTK_ENTRY (widget),
-		                          NM_TYPE_SETTING_802_1X,
-		                          (HelperSecretFunc) nm_setting_802_1x_get_password,
-		                          NM_SETTING_802_1X_SETTING_NAME,
-		                          NM_SETTING_802_1X_PASSWORD);
-	}
+	if (connection)
+		update_secrets (EAP_METHOD (method), connection);
 
 	widget = glade_xml_get_widget (xml, "show_checkbutton");
 	g_assert (widget);
diff --git a/src/wireless-security/eap-method-simple.h b/src/wireless-security/eap-method-simple.h
index 0069d43..01000bb 100644
--- a/src/wireless-security/eap-method-simple.h
+++ b/src/wireless-security/eap-method-simple.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #ifndef EAP_METHOD_SIMPLE_H
diff --git a/src/wireless-security/eap-method-tls.c b/src/wireless-security/eap-method-tls.c
index bd340ae..f706771 100644
--- a/src/wireless-security/eap-method-tls.c
+++ b/src/wireless-security/eap-method-tls.c
@@ -17,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #include <glade/glade.h>
@@ -322,6 +322,45 @@ setup_filepicker (GladeXML *xml,
 		g_signal_connect (G_OBJECT (widget), "notify::filter", (GCallback) reset_filter, filter);
 }
 
+static void
+update_secrets (EAPMethod *parent, NMConnection *connection)
+{
+	EAPMethodTLS *method = (EAPMethodTLS *) parent;
+	NMSetting8021x *s_8021x;
+	HelperSecretFunc password_func;
+	SchemeFunc scheme_func;
+	PathFunc path_func;
+	const char *filename;
+	GtkWidget *widget;
+
+	if (method->phase2) {
+		password_func = (HelperSecretFunc) nm_setting_802_1x_get_phase2_private_key_password;
+		scheme_func = nm_setting_802_1x_get_phase2_private_key_scheme;
+		path_func = nm_setting_802_1x_get_phase2_private_key_path;
+	} else {
+		password_func = (HelperSecretFunc) nm_setting_802_1x_get_private_key_password;
+		scheme_func = nm_setting_802_1x_get_private_key_scheme;
+		path_func = nm_setting_802_1x_get_private_key_path;
+	}
+
+	helper_fill_secret_entry (connection,
+	                          parent->xml,
+	                          "eap_tls_private_key_password_entry",
+	                          NM_TYPE_SETTING_802_1X,
+	                          password_func);
+
+	/* Set the private key filepicker button path if we have a private key */
+	s_8021x = (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
+	if (s_8021x && (scheme_func (s_8021x) == NM_SETTING_802_1X_CK_SCHEME_PATH)) {
+		filename = path_func (s_8021x);
+		if (filename) {
+			widget = glade_xml_get_widget (parent->xml, "eap_tls_private_key_button");
+			g_assert (widget);
+			gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), filename);
+		}
+	}
+}
+
 EAPMethodTLS *
 eap_method_tls_new (const char *glade_file,
                     WirelessSecurity *parent,
@@ -356,6 +395,7 @@ eap_method_tls_new (const char *glade_file,
 	                 validate,
 	                 add_to_size_group,
 	                 fill_connection,
+	                 update_secrets,
 	                 destroy,
 	                 xml,
 	                 widget,
@@ -380,25 +420,6 @@ eap_method_tls_new (const char *glade_file,
 	if (s_8021x && nm_setting_802_1x_get_identity (s_8021x))
 		gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_identity (s_8021x));
 
-	widget = glade_xml_get_widget (xml, "eap_tls_private_key_password_entry");
-	g_assert (widget);
-
-	/* Fill secrets, if any */
-	if (connection) {
-		helper_fill_secret_entry (connection,
-		                          GTK_ENTRY (widget),
-		                          NM_TYPE_SETTING_802_1X,
-		                          phase2 ? (HelperSecretFunc) nm_setting_802_1x_get_phase2_private_key_password :
-		                                   (HelperSecretFunc) nm_setting_802_1x_get_private_key_password,
-		                          NM_SETTING_802_1X_SETTING_NAME,
-		                          phase2 ? NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD :
-		                                   NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD);
-	}
-
-	g_signal_connect (G_OBJECT (widget), "changed",
-	                  (GCallback) wireless_security_changed_cb,
-	                  parent);
-
 	setup_filepicker (xml, "eap_tls_user_cert_button",
 	                  _("Choose your personal certificate..."),
 	                  parent, method, s_8021x,
@@ -411,14 +432,23 @@ eap_method_tls_new (const char *glade_file,
 	                  phase2 ? nm_setting_802_1x_get_phase2_ca_cert_scheme : nm_setting_802_1x_get_ca_cert_scheme,
 	                  phase2 ? nm_setting_802_1x_get_phase2_ca_cert_path : nm_setting_802_1x_get_ca_cert_path,
 	                  FALSE, FALSE);
-	setup_filepicker (xml,
-	                  "eap_tls_private_key_button",
+	setup_filepicker (xml, "eap_tls_private_key_button",
 	                  _("Choose your private key..."),
 	                  parent, method, s_8021x,
 	                  phase2 ? nm_setting_802_1x_get_phase2_private_key_scheme : nm_setting_802_1x_get_private_key_scheme,
 	                  phase2 ? nm_setting_802_1x_get_phase2_private_key_path : nm_setting_802_1x_get_private_key_path,
 	                  TRUE, FALSE);
 
+	/* Fill secrets, if any */
+	if (connection)
+		update_secrets (EAP_METHOD (method), connection);
+
+	widget = glade_xml_get_widget (xml, "eap_tls_private_key_password_entry");
+	g_assert (widget);
+	g_signal_connect (G_OBJECT (widget), "changed",
+	                  (GCallback) wireless_security_changed_cb,
+	                  parent);
+
 	widget = glade_xml_get_widget (xml, "show_checkbutton");
 	g_assert (widget);
 	g_signal_connect (G_OBJECT (widget), "toggled",
diff --git a/src/wireless-security/eap-method-tls.h b/src/wireless-security/eap-method-tls.h
index a5c233f..939ae5e 100644
--- a/src/wireless-security/eap-method-tls.h
+++ b/src/wireless-security/eap-method-tls.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #ifndef EAP_METHOD_TLS_H
diff --git a/src/wireless-security/eap-method-ttls.c b/src/wireless-security/eap-method-ttls.c
index 9ccb1f8..1192907 100644
--- a/src/wireless-security/eap-method-ttls.c
+++ b/src/wireless-security/eap-method-ttls.c
@@ -291,6 +291,15 @@ inner_auth_combo_init (EAPMethodTTLS *method,
 	return combo;
 }
 
+static void
+update_secrets (EAPMethod *parent, NMConnection *connection)
+{
+	eap_method_phase2_update_secrets_helper (parent,
+	                                         connection,
+	                                         "eap_ttls_inner_auth_combo",
+	                                         I_METHOD_COLUMN);
+}
+
 EAPMethodTTLS *
 eap_method_ttls_new (const char *glade_file,
                      WirelessSecurity *parent,
@@ -326,6 +335,7 @@ eap_method_ttls_new (const char *glade_file,
 	                 validate,
 	                 add_to_size_group,
 	                 fill_connection,
+	                 update_secrets,
 	                 destroy,
 	                 xml,
 	                 widget,
diff --git a/src/wireless-security/eap-method-ttls.h b/src/wireless-security/eap-method-ttls.h
index 444b132..d61ef59 100644
--- a/src/wireless-security/eap-method-ttls.h
+++ b/src/wireless-security/eap-method-ttls.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #ifndef EAP_METHOD_TTLS_H
diff --git a/src/wireless-security/eap-method.c b/src/wireless-security/eap-method.c
index 7ab7bbd..5587e28 100644
--- a/src/wireless-security/eap-method.c
+++ b/src/wireless-security/eap-method.c
@@ -88,6 +88,16 @@ eap_method_fill_connection (EAPMethod *method, NMConnection *connection)
 	return (*(method->fill_connection)) (method, connection);
 }
 
+void
+eap_method_update_secrets (EAPMethod *method, NMConnection *connection)
+{
+	g_return_if_fail (method != NULL);
+	g_return_if_fail (connection != NULL);
+
+	if (method->update_secrets)
+		method->update_secrets (method, connection);
+}
+
 static void
 nag_dialog_response_cb (GtkDialog *nag_dialog,
                         gint response,
@@ -203,10 +213,43 @@ eap_method_get_ignore_ca_cert (EAPMethod *method)
 }
 
 void
+eap_method_phase2_update_secrets_helper (EAPMethod *method,
+                                         NMConnection *connection,
+                                         const char *combo_name,
+                                         guint32 column)
+{
+	GtkWidget *combo;
+	GtkTreeIter iter;
+	GtkTreeModel *model;
+
+	g_return_if_fail (method != NULL);
+	g_return_if_fail (connection != NULL);
+	g_return_if_fail (combo_name != NULL);
+
+	combo = glade_xml_get_widget (method->xml, combo_name);
+	g_assert (combo);
+
+	/* Let each EAP phase2 method try to update its secrets */
+	model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
+	if (gtk_tree_model_get_iter_first (model, &iter)) {
+		do {
+			EAPMethod *eap = NULL;
+
+			gtk_tree_model_get (model, &iter, column, &eap, -1);
+			if (eap) {
+				eap_method_update_secrets (eap, connection);
+				eap_method_unref (eap);
+			}
+		} while (gtk_tree_model_iter_next (model, &iter));
+	}
+}
+
+void
 eap_method_init (EAPMethod *method,
                  EMValidateFunc validate,
                  EMAddToSizeGroupFunc add_to_size_group,
                  EMFillConnectionFunc fill_connection,
+                 EMUpdateSecretsFunc update_secrets,
                  EMDestroyFunc destroy,
                  GladeXML *xml,
                  GtkWidget *ui_widget,
@@ -217,6 +260,7 @@ eap_method_init (EAPMethod *method,
 	method->validate = validate;
 	method->add_to_size_group = add_to_size_group;
 	method->fill_connection = fill_connection;
+	method->update_secrets = update_secrets;
 	method->destroy = destroy;
 
 	method->xml = xml;
diff --git a/src/wireless-security/eap-method.h b/src/wireless-security/eap-method.h
index dd4a345..160c125 100644
--- a/src/wireless-security/eap-method.h
+++ b/src/wireless-security/eap-method.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #ifndef EAP_METHOD_H
@@ -33,6 +34,7 @@ typedef struct _EAPMethod EAPMethod;
 
 typedef void        (*EMAddToSizeGroupFunc) (EAPMethod *method, GtkSizeGroup *group);
 typedef void        (*EMFillConnectionFunc) (EAPMethod *method, NMConnection *connection);
+typedef void        (*EMUpdateSecretsFunc)  (EAPMethod *method, NMConnection *connection);
 typedef void        (*EMDestroyFunc)        (EAPMethod *method);
 typedef gboolean    (*EMValidateFunc)       (EAPMethod *method);
 
@@ -50,6 +52,7 @@ struct _EAPMethod {
 
 	EMAddToSizeGroupFunc add_to_size_group;
 	EMFillConnectionFunc fill_connection;
+	EMUpdateSecretsFunc update_secrets;
 	EMValidateFunc validate;
 	EMDestroyFunc destroy;
 };
@@ -65,6 +68,8 @@ void eap_method_add_to_size_group (EAPMethod *method, GtkSizeGroup *group);
 
 void eap_method_fill_connection (EAPMethod *method, NMConnection *connection);
 
+void eap_method_update_secrets (EAPMethod *method, NMConnection *connection);
+
 GtkWidget * eap_method_nag_user (EAPMethod *method);
 
 EAPMethod *eap_method_ref (EAPMethod *method);
@@ -85,6 +90,7 @@ void eap_method_init (EAPMethod *method,
                       EMValidateFunc validate,
                       EMAddToSizeGroupFunc add_to_size_group,
                       EMFillConnectionFunc fill_connection,
+                      EMUpdateSecretsFunc update_secrets,
                       EMDestroyFunc destroy,
                       GladeXML *xml,
                       GtkWidget *ui_widget,
@@ -110,5 +116,10 @@ gboolean eap_method_nag_init (EAPMethod *method,
 
 gboolean eap_method_get_ignore_ca_cert (EAPMethod *method);
 
+void eap_method_phase2_update_secrets_helper (EAPMethod *method,
+                                              NMConnection *connection,
+                                              const char *combo_name,
+                                              guint32 column);
+
 #endif /* EAP_METHOD_H */
 
diff --git a/src/wireless-security/helpers.c b/src/wireless-security/helpers.c
index 47deb6a..c881ca5 100644
--- a/src/wireless-security/helpers.c
+++ b/src/wireless-security/helpers.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -24,26 +25,28 @@
 
 void
 helper_fill_secret_entry (NMConnection *connection,
-                          GtkEntry *entry,
+                          GladeXML *xml,
+                          const char *entry_name,
                           GType setting_type,
-                          HelperSecretFunc func,
-                          const char *setting_name,
-                          const char *secret_name)
+                          HelperSecretFunc func)
 {
+	GtkWidget *widget;
 	NMSetting *setting;
 	const char *tmp;
 
 	g_return_if_fail (connection != NULL);
-	g_return_if_fail (entry != NULL);
+	g_return_if_fail (xml != NULL);
+	g_return_if_fail (entry_name != NULL);
 	g_return_if_fail (func != NULL);
-	g_return_if_fail (setting_name != NULL);
-	g_return_if_fail (secret_name != NULL);
 
 	setting = nm_connection_get_setting (connection, setting_type);
 	if (setting) {
 		tmp = (*func) (setting);
-		if (tmp)
-			gtk_entry_set_text (entry, tmp);
+		if (tmp) {
+			widget = glade_xml_get_widget (xml, entry_name);
+			g_assert (widget);
+			gtk_entry_set_text (GTK_ENTRY (widget), tmp);
+		}
 	}
 }
 
diff --git a/src/wireless-security/helpers.h b/src/wireless-security/helpers.h
index 9512676..f71cfe3 100644
--- a/src/wireless-security/helpers.h
+++ b/src/wireless-security/helpers.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -24,17 +25,17 @@
 
 #include <glib.h>
 #include <gtk/gtk.h>
+#include <glade/glade.h>
 #include <nm-connection.h>
 #include <nm-setting.h>
 
 typedef const char * (*HelperSecretFunc)(NMSetting *);
 
 void helper_fill_secret_entry (NMConnection *connection,
-                               GtkEntry *entry,
+                               GladeXML *xml,
+                               const char *entry_name,
                                GType setting_type,
-                               HelperSecretFunc func,
-                               const char *setting_name,
-                               const char *secret_name);
+                               HelperSecretFunc func);
 
 #endif  /* _HELPERS_H_ */
 
diff --git a/src/wireless-security/wireless-security.c b/src/wireless-security/wireless-security.c
index a14b182..ce60ba6 100644
--- a/src/wireless-security/wireless-security.c
+++ b/src/wireless-security/wireless-security.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #include <string.h>
@@ -106,6 +107,16 @@ wireless_security_fill_connection (WirelessSecurity *sec,
 	return (*(sec->fill_connection)) (sec, connection);
 }
 
+void
+wireless_security_update_secrets (WirelessSecurity *sec, NMConnection *connection)
+{
+	g_return_if_fail (sec != NULL);
+	g_return_if_fail (connection != NULL);
+
+	if (sec->update_secrets)
+		sec->update_secrets (sec, connection);
+}
+
 WirelessSecurity *
 wireless_security_ref (WirelessSecurity *sec)
 {
@@ -137,6 +148,7 @@ wireless_security_init (WirelessSecurity *sec,
                         WSValidateFunc validate,
                         WSAddToSizeGroupFunc add_to_size_group,
                         WSFillConnectionFunc fill_connection,
+                        WSUpdateSecretsFunc update_secrets,
                         WSDestroyFunc destroy,
                         GladeXML *xml,
                         GtkWidget *ui_widget,
@@ -147,6 +159,7 @@ wireless_security_init (WirelessSecurity *sec,
 	sec->validate = validate;
 	sec->add_to_size_group = add_to_size_group;
 	sec->fill_connection = fill_connection;
+	sec->update_secrets = update_secrets;
 	sec->destroy = destroy;
 
 	sec->xml = xml;
@@ -403,6 +416,36 @@ ws_802_1x_fill_connection (WirelessSecurity *sec,
 	eap_method_unref (eap);
 }
 
+void
+ws_802_1x_update_secrets (WirelessSecurity *sec,
+                          const char *combo_name,
+                          NMConnection *connection)
+{
+	GtkWidget *widget;
+	EAPMethod *eap = NULL;
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+
+	g_return_if_fail (sec != NULL);
+	g_return_if_fail (combo_name != NULL);
+	g_return_if_fail (connection != NULL);
+
+	widget = glade_xml_get_widget (sec->xml, combo_name);
+	g_return_if_fail (widget != NULL);
+	model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
+
+	/* Let each EAP method try to update its secrets */
+	if (gtk_tree_model_get_iter_first (model, &iter)) {
+		do {
+			gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1);
+			if (eap) {
+				eap_method_update_secrets (eap, connection);
+				eap_method_unref (eap);
+			}
+		} while (gtk_tree_model_iter_next (model, &iter));
+	}
+}
+
 GtkWidget *
 ws_802_1x_nag_user (WirelessSecurity *sec,
                     const char *combo_name)
diff --git a/src/wireless-security/wireless-security.h b/src/wireless-security/wireless-security.h
index 99d86ad..908c6fe 100644
--- a/src/wireless-security/wireless-security.h
+++ b/src/wireless-security/wireless-security.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #ifndef WIRELESS_SECURITY_H
@@ -34,6 +35,7 @@ typedef void (*WSChangedFunc) (WirelessSecurity *sec, gpointer user_data);
 
 typedef void (*WSAddToSizeGroupFunc) (WirelessSecurity *sec, GtkSizeGroup *group);
 typedef void (*WSFillConnectionFunc) (WirelessSecurity *sec, NMConnection *connection);
+typedef void (*WSUpdateSecretsFunc)  (WirelessSecurity *sec, NMConnection *connection);
 typedef void (*WSDestroyFunc)        (WirelessSecurity *sec);
 typedef gboolean (*WSValidateFunc)   (WirelessSecurity *sec, const GByteArray *ssid);
 typedef GtkWidget * (*WSNagUserFunc) (WirelessSecurity *sec);
@@ -48,6 +50,7 @@ struct _WirelessSecurity {
 
 	WSAddToSizeGroupFunc add_to_size_group;
 	WSFillConnectionFunc fill_connection;
+	WSUpdateSecretsFunc update_secrets;
 	WSValidateFunc validate;
 	WSNagUserFunc nag_user;
 	WSDestroyFunc destroy;
@@ -70,6 +73,9 @@ void wireless_security_add_to_size_group (WirelessSecurity *sec,
 void wireless_security_fill_connection (WirelessSecurity *sec,
                                         NMConnection *connection);
 
+void wireless_security_update_secrets (WirelessSecurity *sec,
+                                       NMConnection *connection);
+
 GtkWidget * wireless_security_nag_user (WirelessSecurity *sec);
 
 WirelessSecurity *wireless_security_ref (WirelessSecurity *sec);
@@ -90,6 +96,7 @@ void wireless_security_init (WirelessSecurity *sec,
                              WSValidateFunc validate,
                              WSAddToSizeGroupFunc add_to_size_group,
                              WSFillConnectionFunc fill_connection,
+                             WSUpdateSecretsFunc update_secrets,
                              WSDestroyFunc destroy,
                              GladeXML *xml,
                              GtkWidget *ui_widget,
@@ -124,6 +131,10 @@ void ws_802_1x_fill_connection (WirelessSecurity *sec,
                                 const char *combo_name,
                                 NMConnection *connection);
 
+void ws_802_1x_update_secrets (WirelessSecurity *sec,
+                               const char *combo_name,
+                               NMConnection *connection);
+
 GtkWidget * ws_802_1x_nag_user (WirelessSecurity *sec,
                                 const char *combo_name);
 
diff --git a/src/wireless-security/ws-dynamic-wep.c b/src/wireless-security/ws-dynamic-wep.c
index 9112fa4..dd86c46 100644
--- a/src/wireless-security/ws-dynamic-wep.c
+++ b/src/wireless-security/ws-dynamic-wep.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #include <glib/gi18n.h>
@@ -96,6 +97,12 @@ nag_user (WirelessSecurity *parent)
 	return ws_802_1x_nag_user (parent, "dynamic_wep_auth_combo");
 }
 
+static void
+update_secrets (WirelessSecurity *parent, NMConnection *connection)
+{
+	ws_802_1x_update_secrets (parent, "dynamic_wep_auth_combo", connection);
+}
+
 WirelessSecurityDynamicWEP *
 ws_dynamic_wep_new (const char *glade_file,
                     NMConnection *connection)
@@ -127,6 +134,7 @@ ws_dynamic_wep_new (const char *glade_file,
 	                        validate,
 	                        add_to_size_group,
 	                        fill_connection,
+	                        update_secrets,
 	                        destroy,
 	                        xml,
 	                        widget,
diff --git a/src/wireless-security/ws-dynamic-wep.h b/src/wireless-security/ws-dynamic-wep.h
index afcf099..b409736 100644
--- a/src/wireless-security/ws-dynamic-wep.h
+++ b/src/wireless-security/ws-dynamic-wep.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #ifndef WS_DYNAMIC_WEP_H
diff --git a/src/wireless-security/ws-leap.c b/src/wireless-security/ws-leap.c
index 00de8cc..aa2e320 100644
--- a/src/wireless-security/ws-leap.c
+++ b/src/wireless-security/ws-leap.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #include <glade/glade.h>
@@ -114,6 +115,16 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
 	              NULL);
 }
 
+static void
+update_secrets (WirelessSecurity *parent, NMConnection *connection)
+{
+	helper_fill_secret_entry (connection,
+	                          parent->xml,
+	                          "leap_password_entry",
+	                          NM_TYPE_SETTING_WIRELESS_SECURITY,
+	                          (HelperSecretFunc) nm_setting_wireless_security_get_leap_password);
+}
+
 WirelessSecurityLEAP *
 ws_leap_new (const char *glade_file, NMConnection *connection)
 {
@@ -145,6 +156,7 @@ ws_leap_new (const char *glade_file, NMConnection *connection)
 	                        validate,
 	                        add_to_size_group,
 	                        fill_connection,
+	                        update_secrets,
 	                        destroy,
 	                        xml,
 	                        widget,
@@ -167,14 +179,8 @@ ws_leap_new (const char *glade_file, NMConnection *connection)
 	g_signal_connect (G_OBJECT (widget), "changed",
 	                  (GCallback) wireless_security_changed_cb,
 	                  sec);
-	if (wsec) {
-		helper_fill_secret_entry (connection,
-		                          GTK_ENTRY (widget),
-		                          NM_TYPE_SETTING_WIRELESS_SECURITY,
-		                          (HelperSecretFunc) nm_setting_wireless_security_get_leap_password,
-		                          NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
-		                          NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD);
-	}
+	if (wsec)
+		update_secrets (WIRELESS_SECURITY (sec), connection);
 
 	widget = glade_xml_get_widget (xml, "leap_username_entry");
 	g_assert (widget);
diff --git a/src/wireless-security/ws-leap.h b/src/wireless-security/ws-leap.h
index c57e8b0..2fee9d1 100644
--- a/src/wireless-security/ws-leap.h
+++ b/src/wireless-security/ws-leap.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #ifndef WS_LEAP_H
diff --git a/src/wireless-security/ws-wep-key.c b/src/wireless-security/ws-wep-key.c
index fc4be18..85841b3 100644
--- a/src/wireless-security/ws-wep-key.c
+++ b/src/wireless-security/ws-wep-key.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #include <glade/glade.h>
@@ -215,21 +216,24 @@ out:
 }
 
 static void
-fill_secrets (WirelessSecurityWEPKey *sec, NMConnection *connection)
+update_secrets (WirelessSecurity *parent, NMConnection *connection)
 {
+	WirelessSecurityWEPKey *sec = (WirelessSecurityWEPKey *) parent;
 	NMSettingWirelessSecurity *s_wsec;
+	GtkWidget *widget;
 	const char *tmp;
 	int i;
 
-	g_return_if_fail (sec != NULL);
-	g_return_if_fail (connection != NULL);
-
 	s_wsec = (NMSettingWirelessSecurity *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
 	for (i = 0; s_wsec && i < 4; i++) {
 		tmp = nm_setting_wireless_security_get_wep_key (s_wsec, i);
 		if (tmp)
 			strcpy (sec->keys[i], tmp);
 	}
+
+	widget = glade_xml_get_widget (parent->xml, "wep_key_entry");
+	if (strlen (sec->keys[sec->cur_index]))
+		gtk_entry_set_text (GTK_ENTRY (widget), sec->keys[sec->cur_index]);
 }
 
 WirelessSecurityWEPKey *
@@ -270,6 +274,7 @@ ws_wep_key_new (const char *glade_file,
 	                        validate,
 	                        add_to_size_group,
 	                        fill_connection,
+	                        update_secrets,
 	                        destroy,
 	                        xml,
 	                        widget,
@@ -284,9 +289,6 @@ ws_wep_key_new (const char *glade_file,
 		NMSettingWireless *s_wireless;
 		const char *mode, *auth_alg;
 
-		/* Fill secrets, if any */
-		fill_secrets (sec, connection);
-
 		s_wireless = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
 		mode = s_wireless ? nm_setting_wireless_get_mode (s_wireless) : NULL;
 		if (mode && !strcmp (mode, "adhoc"))
@@ -329,9 +331,8 @@ ws_wep_key_new (const char *glade_file,
 	}
 
 	/* Fill the key entry with the key for that index */
-	widget = glade_xml_get_widget (xml, "wep_key_entry");
-	if (strlen (sec->keys[default_key_idx]))
-		gtk_entry_set_text (GTK_ENTRY (widget), sec->keys[default_key_idx]);
+	if (connection)
+		update_secrets (WIRELESS_SECURITY (sec), connection);
 
 	widget = glade_xml_get_widget (xml, "show_checkbutton");
 	g_assert (widget);
diff --git a/src/wireless-security/ws-wep-key.h b/src/wireless-security/ws-wep-key.h
index 1561480..0189ed8 100644
--- a/src/wireless-security/ws-wep-key.h
+++ b/src/wireless-security/ws-wep-key.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #ifndef WS_WEP_KEY_H
diff --git a/src/wireless-security/ws-wpa-eap.c b/src/wireless-security/ws-wpa-eap.c
index f445982..7a0afe2 100644
--- a/src/wireless-security/ws-wpa-eap.c
+++ b/src/wireless-security/ws-wpa-eap.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #include <glib/gi18n.h>
@@ -91,6 +92,12 @@ nag_user (WirelessSecurity *parent)
 	return ws_802_1x_nag_user (parent, "wpa_eap_auth_combo");
 }
 
+static void
+update_secrets (WirelessSecurity *parent, NMConnection *connection)
+{
+	ws_802_1x_update_secrets (parent, "wpa_eap_auth_combo", connection);
+}
+
 WirelessSecurityWPAEAP *
 ws_wpa_eap_new (const char *glade_file,
                 NMConnection *connection)
@@ -122,6 +129,7 @@ ws_wpa_eap_new (const char *glade_file,
 	                        validate,
 	                        add_to_size_group,
 	                        fill_connection,
+	                        update_secrets,
 	                        destroy,
 	                        xml,
 	                        widget,
diff --git a/src/wireless-security/ws-wpa-eap.h b/src/wireless-security/ws-wpa-eap.h
index bace87e..36dbb85 100644
--- a/src/wireless-security/ws-wpa-eap.h
+++ b/src/wireless-security/ws-wpa-eap.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #ifndef WS_WPA_EAP_H
diff --git a/src/wireless-security/ws-wpa-psk.c b/src/wireless-security/ws-wpa-psk.c
index 35b3dbb..e7cf1c1 100644
--- a/src/wireless-security/ws-wpa-psk.c
+++ b/src/wireless-security/ws-wpa-psk.c
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #include <glade/glade.h>
@@ -140,6 +141,16 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
 	}
 }
 
+static void
+update_secrets (WirelessSecurity *parent, NMConnection *connection)
+{
+	helper_fill_secret_entry (connection,
+	                          parent->xml,
+	                          "wpa_psk_entry",
+	                          NM_TYPE_SETTING_WIRELESS_SECURITY,
+	                          (HelperSecretFunc) nm_setting_wireless_security_get_psk);
+}
+
 WirelessSecurityWPAPSK *
 ws_wpa_psk_new (const char *glade_file, NMConnection *connection)
 {
@@ -170,6 +181,7 @@ ws_wpa_psk_new (const char *glade_file, NMConnection *connection)
 	                        validate,
 	                        add_to_size_group,
 	                        fill_connection,
+	                        update_secrets,
 	                        destroy,
 	                        xml,
 	                        widget,
@@ -183,14 +195,8 @@ ws_wpa_psk_new (const char *glade_file, NMConnection *connection)
 	gtk_entry_set_width_chars (GTK_ENTRY (widget), 28);
 
 	/* Fill secrets, if any */
-	if (connection) {
-		helper_fill_secret_entry (connection,
-		                          GTK_ENTRY (widget),
-		                          NM_TYPE_SETTING_WIRELESS_SECURITY,
-		                          (HelperSecretFunc) nm_setting_wireless_security_get_psk,
-		                          NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
-		                          NM_SETTING_WIRELESS_SECURITY_PSK);
-	}
+	if (connection)
+		update_secrets (WIRELESS_SECURITY (sec), connection);
 
 	widget = glade_xml_get_widget (xml, "show_checkbutton");
 	g_assert (widget);
diff --git a/src/wireless-security/ws-wpa-psk.h b/src/wireless-security/ws-wpa-psk.h
index 732fcea..c1dd3ad 100644
--- a/src/wireless-security/ws-wpa-psk.h
+++ b/src/wireless-security/ws-wpa-psk.h
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 /* NetworkManager Wireless Applet -- Display wireless access points and allow user control
  *
  * Dan Williams <dcbw redhat com>
@@ -16,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2007 Red Hat, Inc.
+ * (C) Copyright 2007 - 2009 Red Hat, Inc.
  */
 
 #ifndef WS_WPA_PSK_H



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