File nma-brc546117.patch of Package NetworkManager-gnome

Index: nm-applet-0.7.0/src/applet.c
===================================================================
--- nm-applet-0.7.0.orig/src/applet.c
+++ nm-applet-0.7.0/src/applet.c
@@ -2380,15 +2380,11 @@ constructor (GType type,
 
 	applet->dbus_settings = (NMDBusSettings *) nm_dbus_settings_system_new (applet_dbus_manager_get_connection (dbus_mgr));
 
-	applet->gconf_settings = nma_gconf_settings_new ();
+	applet->gconf_settings = nma_gconf_settings_new (applet_dbus_manager_get_connection (dbus_mgr));
 	g_signal_connect (applet->gconf_settings, "new-secrets-requested",
 	                  G_CALLBACK (applet_settings_new_secrets_requested_cb),
 	                  applet);
 
-	dbus_g_connection_register_g_object (applet_dbus_manager_get_connection (dbus_mgr),
-										 NM_DBUS_PATH_SETTINGS,
-										 G_OBJECT (applet->gconf_settings));
-
     /* Start our DBus service */
     if (!applet_dbus_manager_start_service (dbus_mgr)) {
 		g_object_unref (applet);
Index: nm-applet-0.7.0/src/connection-editor/nm-connection-list.c
===================================================================
--- nm-applet-0.7.0.orig/src/connection-editor/nm-connection-list.c
+++ nm-applet-0.7.0/src/connection-editor/nm-connection-list.c
@@ -1686,7 +1686,7 @@ nm_connection_list_new (const char *def_
 				   G_CALLBACK (connection_added),
 				   list);
 
-	list->gconf_settings = nma_gconf_settings_new ();
+	list->gconf_settings = nma_gconf_settings_new (NULL);
 	g_signal_connect (list->gconf_settings, "new-connection",
 				   G_CALLBACK (connection_added),
 				   list);
Index: nm-applet-0.7.0/src/gconf-helpers/nma-gconf-connection.c
===================================================================
--- nm-applet-0.7.0.orig/src/gconf-helpers/nma-gconf-connection.c
+++ nm-applet-0.7.0/src/gconf-helpers/nma-gconf-connection.c
@@ -503,7 +503,6 @@ constructor (GType type,
 	GObject *object;
 	NMAGConfConnectionPrivate *priv;
 	NMConnection *connection;
-	DBusGConnection *bus;
 	GError *error = NULL;
 
 	object = G_OBJECT_CLASS (nma_gconf_connection_parent_class)->constructor (type, n_construct_params, construct_params);
@@ -546,18 +545,6 @@ constructor (GType type,
 
 	fill_vpn_user_name (connection);
 
-	bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
-	if (!bus) {
-		nm_warning ("Could not get the system bus: %s", error->message);
-		g_error_free (error);
-		goto err;
-	}
-
-	nm_exported_connection_register_object (NM_EXPORTED_CONNECTION (object),
-	                                        NM_CONNECTION_SCOPE_USER,
-	                                        bus);
-	dbus_g_connection_unref (bus);
-
 	return object;
 
  err:
Index: nm-applet-0.7.0/src/gconf-helpers/nma-gconf-settings.c
===================================================================
--- nm-applet-0.7.0.orig/src/gconf-helpers/nma-gconf-settings.c
+++ nm-applet-0.7.0/src/gconf-helpers/nma-gconf-settings.c
@@ -6,6 +6,7 @@
 #include "gconf-helpers.h"
 #include "nma-marshal.h"
 #include "nm-utils.h"
+#include <NetworkManager.h>
 
 G_DEFINE_TYPE (NMAGConfSettings, nma_gconf_settings, NM_TYPE_SETTINGS)
 
@@ -18,6 +19,8 @@ typedef struct {
 	guint read_connections_id;
 	GHashTable *pending_changes;
 
+	DBusGConnection *bus;
+
 	gboolean disposed;
 } NMAGConfSettingsPrivate;
 
@@ -31,9 +34,22 @@ static guint signals[LAST_SIGNAL] = { 0
 
 
 NMAGConfSettings *
-nma_gconf_settings_new (void)
+nma_gconf_settings_new (DBusGConnection *bus)
 {
-	return (NMAGConfSettings *) g_object_new (NMA_TYPE_GCONF_SETTINGS, NULL);
+	NMAGConfSettings *self;
+	NMAGConfSettingsPrivate *priv;
+
+	self = (NMAGConfSettings *) g_object_new (NMA_TYPE_GCONF_SETTINGS, NULL);
+	if (!self)
+		return NULL;
+
+	priv = NMA_GCONF_SETTINGS_GET_PRIVATE (self);
+	if (bus) {
+		priv->bus = dbus_g_connection_ref (bus);
+		dbus_g_connection_register_g_object (bus, NM_DBUS_PATH_SETTINGS, G_OBJECT (self));
+	}
+
+	return self;
 }
 
 static void
@@ -64,15 +80,21 @@ add_connection_real (NMAGConfSettings *s
 {
 	NMAGConfSettingsPrivate *priv = NMA_GCONF_SETTINGS_GET_PRIVATE (self);
 
-	if (connection) {
-		priv->connections = g_slist_prepend (priv->connections, connection);
-		g_signal_connect (connection, "new-secrets-requested",
-					   G_CALLBACK (connection_new_secrets_requested_cb),
-					   self);
+	g_return_if_fail (connection != NULL);
 
-		nm_settings_signal_new_connection (NM_SETTINGS (self),
-									NM_EXPORTED_CONNECTION (connection));
-	}
+	priv->connections = g_slist_prepend (priv->connections, connection);
+	g_signal_connect (connection, "new-secrets-requested",
+				   G_CALLBACK (connection_new_secrets_requested_cb),
+				   self);
+
+	/* Export the connection over dbus if requested */
+	if (priv->bus) {
+		nm_exported_connection_register_object (NM_EXPORTED_CONNECTION (connection),
+		                                        NM_CONNECTION_SCOPE_USER,
+		                                        priv->bus);
+ 	}
+
+	nm_settings_signal_new_connection (NM_SETTINGS (self), NM_EXPORTED_CONNECTION (connection));
 }
 
 NMAGConfConnection *
@@ -205,8 +227,11 @@ read_connections (NMAGConfSettings *sett
 
 	for (iter = dir_list; iter; iter = iter->next) {
 		char *dir = (char *) iter->data;
+		NMAGConfConnection *connection;
 
-		add_connection_real (settings, nma_gconf_connection_new (priv->client, dir));
+		connection = nma_gconf_connection_new (priv->client, dir);
+		if (connection)
+			add_connection_real (settings, connection);
 		g_free (dir);
 	}
 
@@ -263,14 +288,8 @@ connection_changes_done (gpointer data)
 	if (!connection) {
 		/* New connection */
 		connection = nma_gconf_connection_new (priv->client, info->path);
-		if (connection) {
-			g_signal_connect (connection, "new-secrets-requested",
-						   G_CALLBACK (connection_new_secrets_requested_cb),
-						   info->settings);
-			priv->connections = g_slist_append (priv->connections, connection);
-			nm_settings_signal_new_connection (NM_SETTINGS (info->settings),
-										NM_EXPORTED_CONNECTION (connection));
-		}
+		if (connection)
+			add_connection_real (info->settings, connection);
 	} else {
 		if (gconf_client_dir_exists (priv->client, info->path, NULL)) {
 			/* Updated connection */
@@ -386,6 +405,9 @@ dispose (GObject *object)
 
 	priv->disposed = TRUE;
 
+	if (priv->bus)
+		dbus_g_connection_unref (priv->bus);
+
 	g_hash_table_destroy (priv->pending_changes);
 
 	if (priv->read_connections_id) {
Index: nm-applet-0.7.0/src/gconf-helpers/nma-gconf-settings.h
===================================================================
--- nm-applet-0.7.0.orig/src/gconf-helpers/nma-gconf-settings.h
+++ nm-applet-0.7.0/src/gconf-helpers/nma-gconf-settings.h
@@ -35,7 +35,7 @@ typedef struct {
 
 GType nma_gconf_settings_get_type (void);
 
-NMAGConfSettings *nma_gconf_settings_new (void);
+NMAGConfSettings *nma_gconf_settings_new (DBusGConnection *bus);
 
 NMAGConfConnection *nma_gconf_settings_add_connection (NMAGConfSettings *self,
 											NMConnection *connection);