summary refs log tree commit diff
path: root/src/settings/nm-settings.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2011-10-28 23:04:16 +0200
committerMichael Biebl <biebl@debian.org>2011-10-28 23:04:16 +0200
commit485d149fe80915d94ed49ea6c2c0552cf7a3e79a (patch)
tree6a48492b46b8c1e3df1c58626c28f05a978c61f7 /src/settings/nm-settings.c
parent263bf4c0c89bb88dc995acd9a6a2de9095fbd461 (diff)
Imported Upstream version 0.9.1.95 upstream/0.9.1.95
Diffstat (limited to 'src/settings/nm-settings.c')
-rw-r--r--src/settings/nm-settings.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index 733e9145..f0bfc162 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -27,6 +27,7 @@
 
 #include <unistd.h>
 #include <string.h>
+#include <ctype.h>
 #include <gmodule.h>
 #include <net/ethernet.h>
 #include <netinet/ether.h>
@@ -546,24 +547,23 @@ find_plugin (GSList *list, const char *pname)
 }
 
 static gboolean
-load_plugins (NMSettings *self, const char *plugins, GError **error)
+load_plugins (NMSettings *self, const char **plugins, GError **error)
 {
 	GSList *list = NULL;
-	char **plist;
-	char **iter;
+	const char **iter;
 	gboolean success = TRUE;
 
-	plist = g_strsplit (plugins, ",", 0);
-	if (!plist)
-		return FALSE;
-
-	for (iter = plist; *iter; iter++) {
+	for (iter = plugins; *iter; iter++) {
 		GModule *plugin;
 		char *full_name, *path;
-		const char *pname = g_strstrip (*iter);
+		const char *pname = *iter;
 		GObject *obj;
 		GObject * (*factory_func) (void);
 
+		/* strip leading spaces */
+		while (isblank (*pname))
+			pname++;
+
 		/* keyfile plugin built in now */
 		if (!strcmp (pname, "keyfile"))
 			continue;
@@ -616,8 +616,6 @@ load_plugins (NMSettings *self, const char *plugins, GError **error)
 		list = g_slist_append (list, obj);
 	}
 
-	g_strfreev (plist);
-
 	g_slist_foreach (list, (GFunc) g_object_unref, NULL);
 	g_slist_free (list);
 
@@ -634,6 +632,7 @@ connection_removed (NMSettingsConnection *obj, gpointer user_data)
 {
 	GObject *connection = G_OBJECT (obj);
 	guint id;
+
 	g_object_ref (connection);
 
 	/* Disconnect signal handlers, as plugins might still keep references
@@ -653,7 +652,7 @@ connection_removed (NMSettingsConnection *obj, gpointer user_data)
 	if (id)
 		g_signal_handler_disconnect (connection, id);
 
-	/* Forget about the connection internall */
+	/* Forget about the connection internally */
 	g_hash_table_remove (NM_SETTINGS_GET_PRIVATE (user_data)->connections,
 	                     (gpointer) nm_connection_get_path (NM_CONNECTION (connection)));
 
@@ -840,9 +839,6 @@ claim_connection (NMSettings *self,
 	}
 }
 
-// TODO it seems that this is only ever used to remove a
-// NMDefaultWiredConnection, and it probably needs to stay that way. So this
-// *needs* a better name!
 static void
 remove_default_wired_connection (NMSettings *self,
                                  NMSettingsConnection *connection,
@@ -852,7 +848,8 @@ remove_default_wired_connection (NMSettings *self,
 	const char *path = nm_connection_get_path (NM_CONNECTION (connection));
 
 	if (g_hash_table_lookup (priv->connections, path)) {
-		g_signal_emit_by_name (G_OBJECT (connection), NM_SETTINGS_CONNECTION_REMOVED);
+		if (do_signal)
+			g_signal_emit_by_name (G_OBJECT (connection), NM_SETTINGS_CONNECTION_REMOVED);
 		g_hash_table_remove (priv->connections, path);
 	}
 }
@@ -1378,7 +1375,7 @@ delete_cb (NMSettingsConnection *connection, GError *error, gpointer user_data)
 {
 }
 
-static gboolean
+static void
 default_wired_try_update (NMDefaultWiredConnection *wired,
                           NMSettings *self)
 {
@@ -1390,6 +1387,9 @@ default_wired_try_update (NMDefaultWiredConnection *wired,
 	 * persistent storage.
 	 */
 
+	/* Keep it alive over removal so we can re-add it if we need to */
+	g_object_ref (wired);
+
 	id = nm_connection_get_id (NM_CONNECTION (wired));
 	g_assert (id);
 
@@ -1402,21 +1402,21 @@ default_wired_try_update (NMDefaultWiredConnection *wired,
 		                   DEFAULT_WIRED_TAG,
 		                   NULL);
 		nm_log_info (LOGD_SETTINGS, "Saved default wired connection '%s' to persistent storage", id);
-		return FALSE;
+	} else {
+		nm_log_warn (LOGD_SETTINGS, "couldn't save default wired connection '%s': %d / %s",
+			         id,
+			         error ? error->code : -1,
+			         (error && error->message) ? error->message : "(unknown)");
+		g_clear_error (&error);
+
+		/* If there was an error, don't destroy the default wired connection,
+		 * but add it back to the system settings service. Connection is already
+		 * exported on the bus, don't export it again, thus do_export == FALSE.
+		 */
+		claim_connection (self, NM_SETTINGS_CONNECTION (wired), FALSE);
 	}
 
-	nm_log_warn (LOGD_SETTINGS, "couldn't save default wired connection '%s': %d / %s",
-	             id,
-	             error ? error->code : -1,
-	             (error && error->message) ? error->message : "(unknown)");
-	g_clear_error (&error);
-
-	/* If there was an error, don't destroy the default wired connection,
-	 * but add it back to the system settings service. Connection is already
-	 * exported on the bus, don't export it again, thus do_export == FALSE.
-	 */
-	claim_connection (self, NM_SETTINGS_CONNECTION (wired), FALSE);
-	return TRUE;
+	g_object_unref (wired);
 }
 
 void
@@ -1492,7 +1492,7 @@ nm_settings_device_removed (NMSettings *self, NMDevice *device)
 
 NMSettings *
 nm_settings_new (const char *config_file,
-                 const char *plugins,
+                 const char **plugins,
                  GError **error)
 {
 	NMSettings *self;