[network-manager-applet] editor: fix secrets requests after 78b7101d570aa874cd748b0488ddeda15d7657df



commit 6878f6343b64dedc30ff977ab30c6b44ae62d95c
Author: Dan Williams <dcbw redhat com>
Date:   Fri Oct 2 12:30:36 2009 -0700

    editor: fix secrets requests after 78b7101d570aa874cd748b0488ddeda15d7657df
    
    After 78b7101d570aa874cd748b0488ddeda15d7657df, the page's connection
    would of course be the duplicated connection which is a plain
    NMConnection that user edits are done on.  THat of course doesn't
    implement NMSettingsConnectionInterface, and thus can't respond to
    requests for secrets.
    
    Instead, we have the CEPage subclasses for each setting type pass back
    the name of the setting they want secrets for, if they need secrets,
    and let the editor ask for the secrets since it has the original
    connection which usually implements NMSettingsConnectionInterface.
    
    By moving the addition of the page's GtkWidget to after page
    initialization, we also fix system VPN connections, which were broken
    because the VPN page's plugin-provided widget is only valid after
    the page is initialized, but the editor expected it to be valid
    right after requesting secrets.  In the case of system secrets, the
    request is over D-Bus and is async, which meant that the call would
    complete and the page would initalize long after the connection editor
    had tried to add the page to the UI.

 src/connection-editor/ce-page.c                |   61 ++++-----------
 src/connection-editor/ce-page.h                |   13 ++-
 src/connection-editor/nm-connection-editor.c   |   96 +++++++++++++++++++++---
 src/connection-editor/page-dsl.c               |   11 ++-
 src/connection-editor/page-dsl.h               |    5 +-
 src/connection-editor/page-ip4.c               |    9 +-
 src/connection-editor/page-ip4.h               |    5 +-
 src/connection-editor/page-ip6.c               |    9 +-
 src/connection-editor/page-ip6.h               |    5 +-
 src/connection-editor/page-mobile.c            |   17 ++--
 src/connection-editor/page-mobile.h            |    5 +-
 src/connection-editor/page-ppp.c               |   11 ++-
 src/connection-editor/page-ppp.h               |    5 +-
 src/connection-editor/page-vpn.c               |   11 ++-
 src/connection-editor/page-vpn.h               |    5 +-
 src/connection-editor/page-wired-security.c    |   14 ++--
 src/connection-editor/page-wired-security.h    |    5 +-
 src/connection-editor/page-wired.c             |    9 +-
 src/connection-editor/page-wired.h             |    5 +-
 src/connection-editor/page-wireless-security.c |   14 ++--
 src/connection-editor/page-wireless-security.h |    5 +-
 src/connection-editor/page-wireless.c          |    9 +-
 src/connection-editor/page-wireless.h          |    5 +-
 23 files changed, 205 insertions(+), 129 deletions(-)
---
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c
index 211d897..af4b69a 100644
--- a/src/connection-editor/ce-page.c
+++ b/src/connection-editor/ce-page.c
@@ -175,34 +175,40 @@ emit_initialized (CEPage *self, GError *error)
 	g_signal_emit (self, signals[INITIALIZED], 0, NULL, error);
 }
 
-static void
-get_secrets_cb (NMSettingsConnectionInterface *connection,
-                GHashTable *secrets,
-                GError *error,
-                gpointer user_data)
+void
+ce_page_complete_init (CEPage *self,
+                       const char *setting_name,
+                       GHashTable *secrets,
+                       GError *error)
 {
-	CEPage *self = user_data;
 	GError *update_error = NULL;
 	GHashTable *setting_hash;
 
+	g_return_if_fail (self != NULL);
+	g_return_if_fail (CE_IS_PAGE (self));
+
 	if (error) {
 		emit_initialized (self, error);
 		return;
+	} else if (!setting_name || !secrets) {
+		/* Success, no secrets */
+		emit_initialized (self, NULL);
+		return;
 	}
 
+	g_assert (setting_name);
 	g_assert (secrets);
 
 	/* Update the connection with the new secrets */
-	setting_hash = g_hash_table_lookup (secrets, self->setting_name);
-
-	/* No secrets? */
+	setting_hash = g_hash_table_lookup (secrets, setting_name);
 	if (!setting_hash) {
+		/* Success, no secrets */
 		emit_initialized (self, NULL);
 		return;
 	}
 
 	if (nm_connection_update_secrets (self->connection,
-	                                  self->setting_name,
+	                                  setting_name,
 	                                  setting_hash,
 	                                  &update_error)) {
 		/* Success */
@@ -219,40 +225,6 @@ get_secrets_cb (NMSettingsConnectionInterface *connection,
 	g_clear_error (&update_error);
 }
 
-gboolean
-ce_page_initialize (CEPage *self,
-                    const char *setting_name,
-                    GError **error)
-{
-	g_return_val_if_fail (self != NULL, FALSE);
-	g_return_val_if_fail (self->connection != NULL, FALSE);
-
-	/* Don't need to request secrets for settings which are known not to have any */
-	if (!setting_name) {
-		emit_initialized (self, NULL);
-		return TRUE;
-	}
-
-	/* Don't request secrets from a plain NMConnection either, since we only
-	 * use those during add/import where the secrets are already filled in.
-	 */
-	if (!NM_IS_SETTINGS_CONNECTION_INTERFACE (self->connection)) {
-		emit_initialized (self, NULL);
-		return TRUE;
-	}
-
-	if (self->setting_name)
-		g_free (self->setting_name);
-	self->setting_name = g_strdup (setting_name);
-
-	return nm_settings_connection_interface_get_secrets (NM_SETTINGS_CONNECTION_INTERFACE (self->connection),
-	                                                     self->setting_name,
-	                                                     NULL,
-	                                                     FALSE,
-	                                                     get_secrets_cb,
-	                                                     self);
-}
-
 static void
 ce_page_init (CEPage *self)
 {
@@ -289,7 +261,6 @@ finalize (GObject *object)
 	CEPage *self = CE_PAGE (object);
 
 	g_free (self->title);
-	g_free (self->setting_name);
 
 	G_OBJECT_CLASS (ce_page_parent_class)->finalize (object);
 }
diff --git a/src/connection-editor/ce-page.h b/src/connection-editor/ce-page.h
index 63fabc0..88d4c0b 100644
--- a/src/connection-editor/ce-page.h
+++ b/src/connection-editor/ce-page.h
@@ -66,7 +66,6 @@ typedef struct {
 	DBusGProxy *proxy;
 	gulong secrets_done_validate;
 
-	char *setting_name;
 	NMConnection *connection;
 	GtkWindow *parent_window;
 
@@ -85,7 +84,10 @@ typedef struct {
 } CEPageClass;
 
 
-typedef CEPage* (*CEPageNewFunc)(NMConnection *connection, GtkWindow *parent, GError **error);
+typedef CEPage* (*CEPageNewFunc)(NMConnection *connection,
+                                 GtkWindow *parent,
+                                 const char **out_secrets_setting_name,
+                                 GError **error);
 
 
 GType ce_page_get_type (void);
@@ -106,9 +108,10 @@ gint ce_spin_output_with_default (GtkSpinButton *spin, gpointer user_data);
 
 int ce_get_property_default (NMSetting *setting, const char *property_name);
 
-gboolean ce_page_initialize (CEPage *self,
-                             const char *setting_name,
-                             GError **error);
+void ce_page_complete_init (CEPage *self,
+                            const char *setting_name,
+                            GHashTable *secrets,
+                            GError *error);
 
 gboolean ce_page_get_initialized (CEPage *self);
 
diff --git a/src/connection-editor/nm-connection-editor.c b/src/connection-editor/nm-connection-editor.c
index 6cf7fc0..43405d8 100644
--- a/src/connection-editor/nm-connection-editor.c
+++ b/src/connection-editor/nm-connection-editor.c
@@ -511,16 +511,94 @@ static void
 page_initialized (CEPage *page, gpointer unused, GError *error, gpointer user_data)
 {
 	NMConnectionEditor *editor = NM_CONNECTION_EDITOR (user_data);
+	GtkWidget *widget;
+	GtkWidget *notebook;
+	GtkWidget *label;
 
 	if (error) {
+		g_object_unref (page);
 		gtk_widget_hide (editor->window);
 		g_signal_emit (editor, editor_signals[EDITOR_DONE], 0, GTK_RESPONSE_NONE, error);
 		return;
 	}
 
+	/* Add the page to the UI */
+	notebook = glade_xml_get_widget (editor->xml, "notebook");
+	label = gtk_label_new (ce_page_get_title (page));
+	widget = ce_page_get_page (page);
+	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, label);
+	editor->pages = g_slist_append (editor->pages, page);
+
 	recheck_initialization (editor);
 }
 
+typedef struct {
+	NMConnectionEditor *self;
+	CEPage *page;
+	char *setting_name;
+} GetSecretsInfo;
+
+static void
+get_secrets_cb (NMSettingsConnectionInterface *connection,
+                GHashTable *secrets,
+                GError *error,
+                gpointer user_data)
+{
+	GetSecretsInfo *info = user_data;
+
+	ce_page_complete_init (info->page, info->setting_name, secrets, error);
+
+	g_free (info->setting_name);
+	g_free (info);
+}
+
+static void
+get_secrets_for_page (NMConnectionEditor *self,
+                      CEPage *page,
+                      const char *setting_name)
+{
+	GetSecretsInfo *info;
+	gboolean success = FALSE;
+
+	if (!setting_name) {
+		/* page doesn't need any secrets */
+		ce_page_complete_init (page, NULL, NULL, NULL);
+		return;
+	}
+
+	/* Try to get secrets from ->orig_connection, because it's the one that
+	 * implements NMSettingsConnectionInterface and can respond to requests for
+	 * its secrets.  ->connection is a plain NMConnection copy of ->orig_connection
+	 * which is the connection that's actually changed when the user clicks stuff.
+	 * When creating importing or creating new connections though, ->orig_connection
+	 * is an NMConnection because it hasn't been exported over D-Bus yet, so we
+	 * can't ask it for secrets, because it doesn't implement NMSettingsConnectionInterface.
+	 */
+	if (!NM_IS_SETTINGS_CONNECTION_INTERFACE (self->orig_connection)) {
+		ce_page_complete_init (page, setting_name, NULL, NULL);
+		return;
+	}
+
+	info = g_malloc0 (sizeof (GetSecretsInfo));
+	info->self = self;
+	info->page = page;
+	info->setting_name = g_strdup (setting_name);
+
+	success = nm_settings_connection_interface_get_secrets (NM_SETTINGS_CONNECTION_INTERFACE (self->orig_connection),
+	                                                        setting_name,
+	                                                        NULL,
+	                                                        FALSE,
+	                                                        get_secrets_cb,
+	                                                        info);
+	if (!success) {
+		GError *error;
+
+		error = g_error_new_literal (0, 0, _("Failed to update connection secrets due to an unknown error."));
+		get_secrets_cb (NM_SETTINGS_CONNECTION_INTERFACE (self->orig_connection), NULL, error, info);
+		g_error_free (error);
+	}
+}
+
 static gboolean
 add_page (NMConnectionEditor *editor,
           CEPageNewFunc func,
@@ -528,28 +606,24 @@ add_page (NMConnectionEditor *editor,
           GError **error)
 {
 	CEPage *page;
-	GtkWidget *widget;
-	GtkWidget *notebook;
-	GtkWidget *label;
+	const char *secrets_setting_name = NULL;
 
 	g_return_val_if_fail (editor != NULL, FALSE);
 	g_return_val_if_fail (func != NULL, FALSE);
 	g_return_val_if_fail (connection != NULL, FALSE);
 
-	page = (*func) (connection, GTK_WINDOW (editor->window), error);
+	page = (*func) (connection, GTK_WINDOW (editor->window), &secrets_setting_name, error);
 	if (!page)
 		return FALSE;
 
-	notebook = glade_xml_get_widget (editor->xml, "notebook");
-	label = gtk_label_new (ce_page_get_title (page));
-	widget = ce_page_get_page (page);
-	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, label);
-
-	editor->pages = g_slist_append (editor->pages, page);
-
 	g_signal_connect (page, "changed", G_CALLBACK (page_changed), editor);
 	g_signal_connect (page, "initialized", G_CALLBACK (page_initialized), editor);
 
+	/* Request any secrets the page might require; or if it doesn't want any,
+	 * let the page initialize.
+	 */
+	get_secrets_for_page (editor, page, secrets_setting_name);
+
 	return TRUE;
 }
 
diff --git a/src/connection-editor/page-dsl.c b/src/connection-editor/page-dsl.c
index 92a49b9..63519dc 100644
--- a/src/connection-editor/page-dsl.c
+++ b/src/connection-editor/page-dsl.c
@@ -120,7 +120,10 @@ finish_setup (CEPageDsl *self, gpointer unused, GError *error, gpointer user_dat
 }
 
 CEPage *
-ce_page_dsl_new (NMConnection *connection, GtkWindow *parent_window, GError **error)
+ce_page_dsl_new (NMConnection *connection,
+                 GtkWindow *parent_window,
+                 const char **out_secrets_setting_name,
+                 GError **error)
 {
 	CEPageDsl *self;
 	CEPageDslPrivate *priv;
@@ -159,10 +162,8 @@ ce_page_dsl_new (NMConnection *connection, GtkWindow *parent_window, GError **er
 	}
 
 	g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL);
-	if (!ce_page_initialize (parent, NM_SETTING_PPPOE_SETTING_NAME, error)) {
-		g_object_unref (self);
-		return NULL;
-	}
+
+	*out_secrets_setting_name = NM_SETTING_PPPOE_SETTING_NAME;
 
 	return CE_PAGE (self);
 }
diff --git a/src/connection-editor/page-dsl.h b/src/connection-editor/page-dsl.h
index 8e19e14..e373645 100644
--- a/src/connection-editor/page-dsl.h
+++ b/src/connection-editor/page-dsl.h
@@ -47,7 +47,10 @@ typedef struct {
 
 GType ce_page_dsl_get_type (void);
 
-CEPage *ce_page_dsl_new (NMConnection *connection, GtkWindow *parent, GError **error);
+CEPage *ce_page_dsl_new (NMConnection *connection,
+                         GtkWindow *parent,
+                         const char **out_secrets_setting_name,
+                         GError **error);
 
 void dsl_connection_new (GtkWindow *parent,
                          PageNewConnectionResultFunc callback,
diff --git a/src/connection-editor/page-ip4.c b/src/connection-editor/page-ip4.c
index ac2d9ee..bf656bc 100644
--- a/src/connection-editor/page-ip4.c
+++ b/src/connection-editor/page-ip4.c
@@ -690,7 +690,10 @@ finish_setup (CEPageIP4 *self, gpointer unused, GError *error, gpointer user_dat
 }
 
 CEPage *
-ce_page_ip4_new (NMConnection *connection, GtkWindow *parent_window, GError **error)
+ce_page_ip4_new (NMConnection *connection,
+                 GtkWindow *parent_window,
+                 const char **out_secrets_setting_name,
+                 GError **error)
 {
 	CEPageIP4 *self;
 	CEPageIP4Private *priv;
@@ -736,10 +739,6 @@ ce_page_ip4_new (NMConnection *connection, GtkWindow *parent_window, GError **er
 	}
 
 	g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL);
-	if (!ce_page_initialize (parent, NULL, error)) {
-		g_object_unref (self);
-		return NULL;
-	}
 
 	return CE_PAGE (self);
 }
diff --git a/src/connection-editor/page-ip4.h b/src/connection-editor/page-ip4.h
index 167c89b..034ec60 100644
--- a/src/connection-editor/page-ip4.h
+++ b/src/connection-editor/page-ip4.h
@@ -47,7 +47,10 @@ typedef struct {
 
 GType ce_page_ip4_get_type (void);
 
-CEPage *ce_page_ip4_new (NMConnection *connection, GtkWindow *parent, GError **error);
+CEPage *ce_page_ip4_new (NMConnection *connection,
+                         GtkWindow *parent,
+                         const char **out_secrets_setting_name,
+                         GError **error);
 
 #endif  /* __PAGE_IP4_H__ */
 
diff --git a/src/connection-editor/page-ip6.c b/src/connection-editor/page-ip6.c
index da96c26..315e43c 100644
--- a/src/connection-editor/page-ip6.c
+++ b/src/connection-editor/page-ip6.c
@@ -649,7 +649,10 @@ finish_setup (CEPageIP6 *self, gpointer unused, GError *error, gpointer user_dat
 }
 
 CEPage *
-ce_page_ip6_new (NMConnection *connection, GtkWindow *parent_window, GError **error)
+ce_page_ip6_new (NMConnection *connection,
+                 GtkWindow *parent_window,
+                 const char **out_secrets_setting_name,
+                 GError **error)
 {
 	CEPageIP6 *self;
 	CEPageIP6Private *priv;
@@ -695,10 +698,6 @@ ce_page_ip6_new (NMConnection *connection, GtkWindow *parent_window, GError **er
 	}
 
 	g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL);
-	if (!ce_page_initialize (parent, NULL, error)) {
-		g_object_unref (self);
-		return NULL;
-	}
 
 	return CE_PAGE (self);
 }
diff --git a/src/connection-editor/page-ip6.h b/src/connection-editor/page-ip6.h
index 081b1fc..fd73a87 100644
--- a/src/connection-editor/page-ip6.h
+++ b/src/connection-editor/page-ip6.h
@@ -47,7 +47,10 @@ typedef struct {
 
 GType ce_page_ip6_get_type (void);
 
-CEPage *ce_page_ip6_new (NMConnection *connection, GtkWindow *parent, GError **error);
+CEPage *ce_page_ip6_new (NMConnection *connection,
+                         GtkWindow *parent,
+                         const char **out_secrets_setting_name,
+                         GError **error);
 
 #endif  /* __PAGE_IP6_H__ */
 
diff --git a/src/connection-editor/page-mobile.c b/src/connection-editor/page-mobile.c
index 9d25f39..2c964e2 100644
--- a/src/connection-editor/page-mobile.c
+++ b/src/connection-editor/page-mobile.c
@@ -293,12 +293,14 @@ finish_setup (CEPageMobile *self, gpointer unused, GError *error, gpointer user_
 }
 
 CEPage *
-ce_page_mobile_new (NMConnection *connection, GtkWindow *parent_window, GError **error)
+ce_page_mobile_new (NMConnection *connection,
+                    GtkWindow *parent_window,
+                    const char **out_secrets_setting_name,
+                    GError **error)
 {
 	CEPageMobile *self;
 	CEPageMobilePrivate *priv;
 	CEPage *parent;
-	const char *setting_name = NM_SETTING_GSM_SETTING_NAME;
 
 	self = CE_PAGE_MOBILE (g_object_new (CE_TYPE_PAGE_MOBILE,
 	                                     CE_PAGE_CONNECTION, connection,
@@ -327,9 +329,12 @@ ce_page_mobile_new (NMConnection *connection, GtkWindow *parent_window, GError *
 	priv = CE_PAGE_MOBILE_GET_PRIVATE (self);
 
 	priv->setting = nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM);
-	if (!priv->setting) {
+	if (priv->setting)
+		*out_secrets_setting_name = NM_SETTING_GSM_SETTING_NAME;
+	else {
 		priv->setting = nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA);
-		setting_name = NM_SETTING_CDMA_SETTING_NAME;
+		if (priv->setting)
+			*out_secrets_setting_name = NM_SETTING_CDMA_SETTING_NAME;
 	}
 
 	if (!priv->setting) {
@@ -339,10 +344,6 @@ ce_page_mobile_new (NMConnection *connection, GtkWindow *parent_window, GError *
 	}
 
 	g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL);
-	if (!ce_page_initialize (parent, setting_name, error)) {
-		g_object_unref (self);
-		return NULL;
-	}
 
 	return CE_PAGE (self);
 }
diff --git a/src/connection-editor/page-mobile.h b/src/connection-editor/page-mobile.h
index aca36cc..5db4b67 100644
--- a/src/connection-editor/page-mobile.h
+++ b/src/connection-editor/page-mobile.h
@@ -47,7 +47,10 @@ typedef struct {
 
 GType ce_page_mobile_get_type (void);
 
-CEPage *ce_page_mobile_new (NMConnection *connection, GtkWindow *parent, GError **error);
+CEPage *ce_page_mobile_new (NMConnection *connection,
+                            GtkWindow *parent,
+                            const char **out_secrets_setting_name,
+                            GError **error);
 
 void mobile_connection_new (GtkWindow *parent,
                             PageNewConnectionResultFunc result_func,
diff --git a/src/connection-editor/page-ppp.c b/src/connection-editor/page-ppp.c
index 0e3567a..4684f38 100644
--- a/src/connection-editor/page-ppp.c
+++ b/src/connection-editor/page-ppp.c
@@ -262,7 +262,10 @@ finish_setup (CEPagePpp *self, gpointer unused, GError *error, gpointer user_dat
 }
 
 CEPage *
-ce_page_ppp_new (NMConnection *connection, GtkWindow *parent_window, GError **error)
+ce_page_ppp_new (NMConnection *connection,
+                 GtkWindow *parent_window,
+                 const char **out_secrets_setting_name,
+                 GError **error)
 {
 	CEPagePpp *self;
 	CEPagePppPrivate *priv;
@@ -308,10 +311,8 @@ ce_page_ppp_new (NMConnection *connection, GtkWindow *parent_window, GError **er
 	priv->connection_id = g_strdup (nm_setting_connection_get_id (s_con));
 
 	g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL);
-	if (!ce_page_initialize (parent, NM_SETTING_PPP_SETTING_NAME, error)) {
-		g_object_unref (self);
-		return NULL;
-	}
+
+	*out_secrets_setting_name = NM_SETTING_PPP_SETTING_NAME;
 
 	return CE_PAGE (self);
 }
diff --git a/src/connection-editor/page-ppp.h b/src/connection-editor/page-ppp.h
index ce15093..6960a36 100644
--- a/src/connection-editor/page-ppp.h
+++ b/src/connection-editor/page-ppp.h
@@ -47,6 +47,9 @@ typedef struct {
 
 GType ce_page_ppp_get_type (void);
 
-CEPage *ce_page_ppp_new (NMConnection *connection, GtkWindow *parent, GError **error);
+CEPage *ce_page_ppp_new (NMConnection *connection,
+                         GtkWindow *parent,
+                         const char **out_secrets_setting_name,
+                         GError **error);
 
 #endif  /* __PAGE_PPP_H__ */
diff --git a/src/connection-editor/page-vpn.c b/src/connection-editor/page-vpn.c
index 8f755af..dd26758 100644
--- a/src/connection-editor/page-vpn.c
+++ b/src/connection-editor/page-vpn.c
@@ -88,7 +88,10 @@ finish_setup (CEPageVpn *self, gpointer unused, GError *error, gpointer user_dat
 }
 
 CEPage *
-ce_page_vpn_new (NMConnection *connection, GtkWindow *parent_window, GError **error)
+ce_page_vpn_new (NMConnection *connection,
+                 GtkWindow *parent_window,
+                 const char **out_secrets_setting_name,
+                 GError **error)
 {
 	CEPageVpn *self;
 	CEPageVpnPrivate *priv;
@@ -119,10 +122,8 @@ ce_page_vpn_new (NMConnection *connection, GtkWindow *parent_window, GError **er
 	}
 
 	g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL);
-	if (!ce_page_initialize (parent, NM_SETTING_VPN_SETTING_NAME, error)) {
-		g_object_unref (self);
-		return NULL;
-	}
+
+	*out_secrets_setting_name = NM_SETTING_VPN_SETTING_NAME;
 
 	return CE_PAGE (self);
 }
diff --git a/src/connection-editor/page-vpn.h b/src/connection-editor/page-vpn.h
index 28026f1..c198125 100644
--- a/src/connection-editor/page-vpn.h
+++ b/src/connection-editor/page-vpn.h
@@ -47,7 +47,10 @@ typedef struct {
 
 GType ce_page_vpn_get_type (void);
 
-CEPage *ce_page_vpn_new (NMConnection *connection, GtkWindow *parent, GError **error);
+CEPage *ce_page_vpn_new (NMConnection *connection,
+                         GtkWindow *parent,
+                         const char **out_secrets_setting_name,
+                         GError **error);
 
 gboolean ce_page_vpn_save_secrets (CEPage *page, NMConnection *connection);
 
diff --git a/src/connection-editor/page-wired-security.c b/src/connection-editor/page-wired-security.c
index 492fbe7..766ec62 100644
--- a/src/connection-editor/page-wired-security.c
+++ b/src/connection-editor/page-wired-security.c
@@ -96,7 +96,10 @@ finish_setup (CEPageWiredSecurity *self, gpointer unused, GError *error, gpointe
 }
 
 CEPage *
-ce_page_wired_security_new (NMConnection *connection, GtkWindow *parent_window, GError **error)
+ce_page_wired_security_new (NMConnection *connection,
+                            GtkWindow *parent_window,
+                            const char **out_secrets_setting_name,
+                            GError **error)
 {
 	CEPageWiredSecurity *self;
 	CEPage *parent;
@@ -120,12 +123,9 @@ ce_page_wired_security_new (NMConnection *connection, GtkWindow *parent_window,
 	priv->enabled = GTK_TOGGLE_BUTTON (gtk_check_button_new_with_label (_("Use 802.1X security for this connection")));
 
 	g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL);
-	if (!ce_page_initialize (parent,
-	                         priv->initial_have_8021x ? NM_SETTING_802_1X_SETTING_NAME : NULL,
-	                         error)) {
-		g_object_unref (self);
-		return NULL;
-	}
+
+	if (priv->initial_have_8021x)
+		*out_secrets_setting_name = NM_SETTING_802_1X_SETTING_NAME;
 
 	return CE_PAGE (self);
 }
diff --git a/src/connection-editor/page-wired-security.h b/src/connection-editor/page-wired-security.h
index 29493f9..80bce08 100644
--- a/src/connection-editor/page-wired-security.h
+++ b/src/connection-editor/page-wired-security.h
@@ -49,6 +49,9 @@ typedef struct {
 
 GType ce_page_wired_security_get_type (void);
 
-CEPage *ce_page_wired_security_new (NMConnection *connection, GtkWindow *parent, GError **error);
+CEPage *ce_page_wired_security_new (NMConnection *connection,
+                                    GtkWindow *parent,
+                                    const char **out_secrets_setting_name,
+                                    GError **error);
 
 #endif  /* __PAGE_WIRED_SECURITY_H__ */
diff --git a/src/connection-editor/page-wired.c b/src/connection-editor/page-wired.c
index df85dcd..88474df 100644
--- a/src/connection-editor/page-wired.c
+++ b/src/connection-editor/page-wired.c
@@ -187,7 +187,10 @@ finish_setup (CEPageWired *self, gpointer unused, GError *error, gpointer user_d
 }
 
 CEPage *
-ce_page_wired_new (NMConnection *connection, GtkWindow *parent_window, GError **error)
+ce_page_wired_new (NMConnection *connection,
+                   GtkWindow *parent_window,
+                   const char **out_secrets_setting_name,
+                   GError **error)
 {
 	CEPageWired *self;
 	CEPageWiredPrivate *priv;
@@ -226,10 +229,6 @@ ce_page_wired_new (NMConnection *connection, GtkWindow *parent_window, GError **
 	}
 
 	g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL);
-	if (!ce_page_initialize (parent, NULL, error)) {
-		g_object_unref (self);
-		return NULL;
-	}
 
 	return CE_PAGE (self);
 }
diff --git a/src/connection-editor/page-wired.h b/src/connection-editor/page-wired.h
index 1d10f2f..6a6fd57 100644
--- a/src/connection-editor/page-wired.h
+++ b/src/connection-editor/page-wired.h
@@ -47,7 +47,10 @@ typedef struct {
 
 GType ce_page_wired_get_type (void);
 
-CEPage *ce_page_wired_new (NMConnection *connection, GtkWindow *parent, GError **error);
+CEPage *ce_page_wired_new (NMConnection *connection,
+                           GtkWindow *parent,
+                           const char **out_secrets_setting_name,
+                           GError **error);
 
 void wired_connection_new (GtkWindow *parent,
                            PageNewConnectionResultFunc result_func,
diff --git a/src/connection-editor/page-wireless-security.c b/src/connection-editor/page-wireless-security.c
index 51a1a72..bd96058 100644
--- a/src/connection-editor/page-wireless-security.c
+++ b/src/connection-editor/page-wireless-security.c
@@ -342,13 +342,15 @@ finish_setup (CEPageWirelessSecurity *self, gpointer unused, GError *error, gpoi
 }
 
 CEPage *
-ce_page_wireless_security_new (NMConnection *connection, GtkWindow *parent_window, GError **error)
+ce_page_wireless_security_new (NMConnection *connection,
+                               GtkWindow *parent_window,
+                               const char **out_secrets_setting_name,
+                               GError **error)
 {
 	CEPageWirelessSecurity *self;
 	CEPage *parent;
 	NMSettingWireless *s_wireless;
 	NMSettingWirelessSecurity *s_wsec = NULL;
-	const char *setting_name = NULL;
 	NMUtilsSecurityType default_type = NMU_SEC_NONE;
 	const char *security;
 
@@ -398,21 +400,17 @@ ce_page_wireless_security_new (NMConnection *connection, GtkWindow *parent_windo
 	    || default_type == NMU_SEC_LEAP
 	    || default_type == NMU_SEC_WPA_PSK
 	    || default_type == NMU_SEC_WPA2_PSK) {
-		setting_name = NM_SETTING_WIRELESS_SECURITY_SETTING_NAME;
+		*out_secrets_setting_name = NM_SETTING_WIRELESS_SECURITY_SETTING_NAME;
 	}
 
 	/* Or if it is 802.1x enabled */
 	if (   default_type == NMU_SEC_DYNAMIC_WEP
 	    || default_type == NMU_SEC_WPA_ENTERPRISE
 	    || default_type == NMU_SEC_WPA2_ENTERPRISE) {
-		setting_name = NM_SETTING_802_1X_SETTING_NAME;
+		*out_secrets_setting_name = NM_SETTING_802_1X_SETTING_NAME;
 	}
 
 	g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL);
-	if (!ce_page_initialize (parent, setting_name, error)) {
-		g_object_unref (self);
-		return NULL;
-	}
 
 	return CE_PAGE (self);
 }
diff --git a/src/connection-editor/page-wireless-security.h b/src/connection-editor/page-wireless-security.h
index c931c08..d1cc529 100644
--- a/src/connection-editor/page-wireless-security.h
+++ b/src/connection-editor/page-wireless-security.h
@@ -54,7 +54,10 @@ typedef struct {
 
 GType ce_page_wireless_security_get_type (void);
 
-CEPage *ce_page_wireless_security_new (NMConnection *connection, GtkWindow *parent, GError **error);
+CEPage *ce_page_wireless_security_new (NMConnection *connection,
+                                       GtkWindow *parent,
+                                       const char **out_secrets_setting_name,
+                                       GError **error);
 
 #endif  /* __PAGE_WIRELESS_SECURITY_H__ */
 
diff --git a/src/connection-editor/page-wireless.c b/src/connection-editor/page-wireless.c
index 4fb3b81..078108c 100644
--- a/src/connection-editor/page-wireless.c
+++ b/src/connection-editor/page-wireless.c
@@ -329,7 +329,10 @@ finish_setup (CEPageWireless *self, gpointer unused, GError *error, gpointer use
 }
 
 CEPage *
-ce_page_wireless_new (NMConnection *connection, GtkWindow *parent_window, GError **error)
+ce_page_wireless_new (NMConnection *connection,
+                      GtkWindow *parent_window,
+                      const char **out_secrets_setting_name,
+                      GError **error)
 {
 	CEPageWireless *self;
 	CEPageWirelessPrivate *priv;
@@ -370,10 +373,6 @@ ce_page_wireless_new (NMConnection *connection, GtkWindow *parent_window, GError
 	}
 
 	g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL);
-	if (!ce_page_initialize (parent, NULL, error)) {
-		g_object_unref (self);
-		return NULL;
-	}
 
 	return CE_PAGE (self);
 }
diff --git a/src/connection-editor/page-wireless.h b/src/connection-editor/page-wireless.h
index fb0a632..9010161 100644
--- a/src/connection-editor/page-wireless.h
+++ b/src/connection-editor/page-wireless.h
@@ -47,7 +47,10 @@ typedef struct {
 
 GType ce_page_wireless_get_type (void);
 
-CEPage *ce_page_wireless_new (NMConnection *connection, GtkWindow *parent, GError **error);
+CEPage *ce_page_wireless_new (NMConnection *connection,
+                              GtkWindow *parent,
+                              const char **out_secrets_setting_name,
+                              GError **error);
 
 /* Caller must free returned array */
 GByteArray *ce_page_wireless_get_ssid (CEPageWireless *self);



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