cpw.gillux.detachablepurple: c3661cd1: Going multi-interface. Adapted PurpleCon...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Sun May 20 13:21:56 EDT 2012


----------------------------------------------------------------------
Revision: c3661cd112ccc4e794c23ff65fdaeefc93835ef8
Parent:   72f7290ae890b0d08a1e9dfae7c5337074fbb1cc
Author:   gillux at soc.pidgin.im
Date:     05/20/12 09:35:52
Branch:   im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/c3661cd112ccc4e794c23ff65fdaeefc93835ef8

Changelog: 

Going multi-interface. Adapted PurpleConstructor's pack_pobject_properties()
function so that it packs all the properties of all the interfaces of the
given object.

Changes against parent 72f7290ae890b0d08a1e9dfae7c5337074fbb1cc

  patched  libpurple/dbus/constructor.c

-------------- next part --------------
============================================================
--- libpurple/dbus/constructor.c	e872531096da84204d33958e7b8cd47a7cf09000
+++ libpurple/dbus/constructor.c	271254774cfc69617719a1e5f854eefac8cb0f49
@@ -192,26 +192,46 @@ pack_pobject_properties(PurpleObject *po
 	GVariantBuilder builder;
 	GParamSpec *pspec;
 	GVariant *prop;
+	GDBusInterfaceInfo *ifaceinfo;
 	GDBusPropertyInfo **props_info;
 	char *prop_name;
+	PurpleObjectClass *pobjclass = PURPLE_OBJECT_GET_CLASS(pobject);
+	GType type;
 
 	g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
-	props_info = PURPLE_OBJECT_GET_CLASS(pobject)->dbus_ifaceinfo->properties;
-	for (; *props_info; props_info++) {
-		prop_name = (*props_info)->name;
-		if (!prop_name)
+
+	/* Step from the most derived type to PurpleObject's direct child
+	 * type and retreive each D-Bus property list. */
+	for (type = G_OBJECT_TYPE(pobject);
+	     type != PURPLE_TYPE_OBJECT && type != 0;
+	     type = g_type_parent(type))
+	{
+		ifaceinfo = g_datalist_id_get_data(&pobjclass->dbus_ifaceinfos,
+		                                   g_type_qname(type));
+		if (!ifaceinfo)
 			continue;
 
-		pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(pobject),
-		                                     prop_name);
-		if (!pspec)
+		props_info = ifaceinfo->properties;
+		if (!props_info)
 			continue;
 
-		prop = purple_object_get_dbus_property(pobject, prop_name);
-		if (!prop)
-			continue;
-		prop = g_variant_new("(sv)", prop_name, prop);
-		g_variant_builder_add_value(&builder, prop);
+		for (; *props_info; props_info++) {
+			prop_name = (*props_info)->name;
+			if (!prop_name)
+				continue;
+
+			pspec = g_object_class_find_property
+			          (G_OBJECT_GET_CLASS(pobject), prop_name);
+			if (!pspec)
+				continue;
+
+			prop = purple_object_get_dbus_property
+			         (pobject, prop_name);
+			if (!prop)
+				continue;
+			prop = g_variant_new("(sv)", prop_name, prop);
+			g_variant_builder_add_value(&builder, prop);
+		}
 	}
 	return g_variant_builder_end(&builder);
 }


More information about the Commits mailing list