summary refs log tree commit diff
path: root/libnm-glib/nm-object.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2011-05-27 19:57:25 +0200
committerMichael Biebl <biebl@debian.org>2011-05-27 19:57:25 +0200
commitd465e5fac63f36bcf4069e36827f4b62c494556d (patch)
tree65f4ba9567e091233cdf3279f7ba3c9479e74a1c /libnm-glib/nm-object.c
parent9f806e97a24bba61417ae312fcc0da40914266fb (diff)
Imported Upstream version 0.8.9997 upstream/0.8.9997
Diffstat (limited to 'libnm-glib/nm-object.c')
-rw-r--r--libnm-glib/nm-object.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c
index 0b88be2c..614f6afc 100644
--- a/libnm-glib/nm-object.c
+++ b/libnm-glib/nm-object.c
@@ -333,6 +333,7 @@ handle_property_changed (gpointer key, gpointer data, gpointer user_data)
 	GParamSpec *pspec;
 	gboolean success = FALSE, found = FALSE;
 	GSList *iter;
+	GValue *value = data;
 
 	prop_name = wincaps_to_dash ((char *) key);
 	pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (self)), prop_name);
@@ -344,12 +345,19 @@ handle_property_changed (gpointer key, gpointer data, gpointer user_data)
 		goto out;
 	}
 
-	/* Iterate through the object and it's parents to find the property */
+	/* Iterate through the object and its parents to find the property */
 	for (iter = priv->pcs; iter; iter = g_slist_next (iter)) {
 		pci = g_hash_table_lookup ((GHashTable *) iter->data, prop_name);
 		if (pci) {
 			found = TRUE;
-			success = (*(pci->func)) (self, pspec, (GValue *) data, pci->field);
+
+			/* Handle NULL object paths */
+			if (G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) {
+				if (g_strcmp0 (g_value_get_boxed (value), "/") == 0)
+					value = NULL;
+			}
+
+			success = (*(pci->func)) (self, pspec, value, pci->field);
 			if (success)
 				break;
 		}
@@ -453,6 +461,11 @@ _nm_object_demarshal_generic (NMObject *object,
 			char **param = (char **) field;
 			g_free (*param);
 			*param = g_strdup (g_value_get_boxed (value));
+			/* Handle "NULL" object paths */
+			if (g_strcmp0 (*param, "/") == 0) {
+				g_free (*param);
+				*param = NULL;
+			}
 		} else {
 			success = FALSE;
 			goto done;
@@ -558,13 +571,18 @@ _nm_object_get_string_property (NMObject *object,
                                 GError **error)
 {
 	char *str = NULL;
+	const char *tmp;
 	GValue value = {0,};
 
 	if (_nm_object_get_property (object, interface, prop_name, &value, error)) {
 		if (G_VALUE_HOLDS_STRING (&value))
 			str = g_strdup (g_value_get_string (&value));
-		else if (G_VALUE_HOLDS (&value, DBUS_TYPE_G_OBJECT_PATH))
-			str = g_strdup (g_value_get_boxed (&value));
+		else if (G_VALUE_HOLDS (&value, DBUS_TYPE_G_OBJECT_PATH)) {
+			tmp = g_value_get_boxed (&value);
+			/* Handle "NULL" object paths */
+			if (g_strcmp0 (tmp, "/") != 0)
+				str = g_strdup (tmp);
+		}
 		g_value_unset (&value);
 	}
 
@@ -578,10 +596,13 @@ _nm_object_get_object_path_property (NMObject *object,
                                      GError **error)
 {
 	char *path = NULL;
+	const char *tmp;
 	GValue value = {0,};
 
 	if (_nm_object_get_property (object, interface, prop_name, &value, error)) {
-		path = g_strdup (g_value_get_boxed (&value));
+		tmp = g_value_get_boxed (&value);
+		if (g_strcmp0 (tmp, "/") != 0)
+			path = g_strdup (tmp);
 		g_value_unset (&value);
 	}