[Galago-commits] r2688 - in trunk/libgalago: . libgalago

galago-commits at freedesktop.org galago-commits at freedesktop.org
Sun Apr 9 21:25:54 PDT 2006


Author: chipx86
Date: 2006-04-09 21:25:49 -0700 (Sun, 09 Apr 2006)
New Revision: 2688

Modified:
   trunk/libgalago/ChangeLog
   trunk/libgalago/libgalago/galago-object.c
Log:
Last minute, important change. Implement galago_object_get_attributes() for local objects.


Modified: trunk/libgalago/ChangeLog
===================================================================
--- trunk/libgalago/ChangeLog	2006-04-09 03:06:27 UTC (rev 2687)
+++ trunk/libgalago/ChangeLog	2006-04-10 04:25:49 UTC (rev 2688)
@@ -1,3 +1,9 @@
+Sun Apr 09 21:24:53 PDT 2006  Christian Hammond <chipx86 at chipx86.com>
+
+	* libgalago/galago-object.c:
+	  - Last minute, important change. Implement
+	    galago_object_get_attributes() for local objects.
+
 Sat Apr 08 19:37:47 PDT 2006  Christian Hammond <chipx86 at chipx86.com>
 
 	* po/da.po:

Modified: trunk/libgalago/libgalago/galago-object.c
===================================================================
--- trunk/libgalago/libgalago/galago-object.c	2006-04-09 03:06:27 UTC (rev 2687)
+++ trunk/libgalago/libgalago/galago-object.c	2006-04-10 04:25:49 UTC (rev 2688)
@@ -23,6 +23,7 @@
 #include <libgalago/galago-context-priv.h>
 #include <libgalago/galago-core.h>
 #include <libgalago/galago-enum-types.h>
+#include <libgalago/galago-key-value.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -32,6 +33,7 @@
 	gchar *dbus_path;
 	GalagoOrigin origin;
 	GHashTable *attrs_table;
+	GList *attrs_list;
 	gboolean watched : 1;
 };
 
@@ -423,6 +425,18 @@
 }
 
 static void
+reset_attrs_list(GalagoObject *object)
+{
+	if (object->priv->attrs_list != NULL)
+	{
+		g_list_foreach(object->priv->attrs_list,
+					   (GFunc)galago_key_value_destroy, NULL);
+		g_list_free(object->priv->attrs_list);
+		object->priv->attrs_list = NULL;
+	}
+}
+
+static void
 destroy_value(GValue *value)
 {
 	g_value_unset(value);
@@ -440,6 +454,8 @@
 								  (GFreeFunc)destroy_value);
 	}
 
+	reset_attrs_list(object);
+
 	g_hash_table_replace(object->priv->attrs_table,
 						 g_ascii_strdown(name, -1), value);
 
@@ -470,12 +486,29 @@
 galago_object_real_remove_attribute(GalagoObject *object, const char *name)
 {
 	char *temp;
+	GList *l;
 
 	if (object->priv->attrs_table == NULL)
 		return TRUE;
 
+	reset_attrs_list(object);
+
 	temp = g_ascii_strdown(name, -1);
 	g_hash_table_remove(object->priv->attrs_table, temp);
+
+	for (l = object->priv->attrs_list; l != NULL; l = l->next)
+	{
+		GalagoKeyValue *key_value = (GalagoKeyValue *)l->data;
+
+		if (!strcmp(galago_key_value_get_key(key_value), temp))
+		{
+			object->priv->attrs_list =
+				g_list_remove_link(object->priv->attrs_list, l);
+			g_list_free_1(l);
+			break;
+		}
+	}
+
 	g_free(temp);
 
 	if (GALAGO_OBJECT_IS_LOCAL(object) && galago_is_connected() &&
@@ -627,13 +660,24 @@
 	return galago_object_get_attribute(object, name) != NULL;
 }
 
+static void
+get_attributes_foreach(const char *key, GValue *value, GalagoObject *object)
+{
+	object->priv->attrs_list = g_list_append(object->priv->attrs_list,
+											 galago_key_value_new(key, value));
+}
+
 static GList *
 galago_object_real_get_attributes(const GalagoObject *object)
 {
-	/* TODO */
-	g_warning("galago_object_real_get_attributes has not been "
-			  "implemented yet.");
-	return NULL;
+	if (object->priv->attrs_list == NULL && object->priv->attrs_table != NULL)
+	{
+		g_hash_table_foreach(object->priv->attrs_table,
+							 (GHFunc)get_attributes_foreach,
+							 (gpointer)object);
+	}
+
+	return object->priv->attrs_list;
 }
 
 GList *



More information about the galago-commits mailing list