/srv/mercurial-server/detachablepurple: c77b131c8bd9: Going mult...

Gilles Bedel gillux at cpw.pidgin.im
Fri Jun 15 22:01:40 EDT 2012


Changeset: c77b131c8bd9ff1c2994cead9493ecdb6ad98f23
Author:	 Gilles Bedel <gillux at cpw.pidgin.im>
Date:	 2012-05-20 13:47 +0000
Branch:	 cpw.gillux.detachablepurple
URL: http://hg.pidgin.im/srv/mercurial-server/detachablepurple/rev/c77b131c8bd9

Description:

Going multi-interface. Adapted the method caller function.
It now takes the target interface as parameter.

diffstat:

 libpurple/dbus/constructor.c |   4 +++-
 libpurple/pobject.c          |  31 +++++++++++++++++++++++++++++--
 libpurple/pobject.h          |   3 ++-
 3 files changed, 34 insertions(+), 4 deletions(-)

diffs (85 lines):

diff --git a/libpurple/dbus/constructor.c b/libpurple/dbus/constructor.c
--- a/libpurple/dbus/constructor.c
+++ b/libpurple/dbus/constructor.c
@@ -312,7 +312,9 @@
 	PurpleConstructor* con = purple_constructor_get_instance();
 	GVariant *ret;
 
-	ret = purple_object_dbus_call(PURPLE_OBJECT(con), method);
+	ret = purple_object_dbus_call(PURPLE_OBJECT(con),
+	                              purple_constructor_interface_info.name,
+	                              method);
 	if (ret) {
 		load_pobjects(ret, type);
 		g_variant_unref(ret);
diff --git a/libpurple/pobject.c b/libpurple/pobject.c
--- a/libpurple/pobject.c
+++ b/libpurple/pobject.c
@@ -973,6 +973,32 @@
 	while (child != PURPLE_TYPE_OBJECT && child != 0);
 }
 
+/* Looks for a GDBusInterfaceInfo named 'name' inside the PurpleObject 'pobj'. */
+static GDBusInterfaceInfo *
+find_interface_info_by_name(PurpleObject *pobj, const gchar *name)
+{
+	PurpleObjectClass *pobjclass = PURPLE_OBJECT_GET_CLASS(pobj);
+	GDBusInterfaceInfo *ifaceinfo;
+	GType type, child;
+
+	/* Step from the most derived type to PurpleObject
+	 * type and check for each associated D-Bus interface info. */
+	type = G_OBJECT_TYPE(pobj);
+	do {
+		ifaceinfo = g_datalist_id_get_data(&pobjclass->dbus_ifaceinfos,
+		                                   g_type_qname(type));
+		if (ifaceinfo) {
+			if (!strcmp(ifaceinfo->name, name))
+				return ifaceinfo;
+		}
+		child = type;
+		type = g_type_parent(type);
+	}
+	while (child != PURPLE_TYPE_OBJECT && child != 0);
+
+	return NULL;
+}
+
 void
 purple_object_class_register_dbus_iface(PurpleObjectClass *pclass,
                                         GType type,
@@ -1048,7 +1074,8 @@
 }
 
 GVariant *
-purple_object_dbus_call(PurpleObject *pobj, const char *method_name, ...)
+purple_object_dbus_call(PurpleObject *pobj, const char *interface_name,
+                        const char *method_name, ...)
 {
 	va_list ap;
 	GDBusInterfaceInfo *iface;
@@ -1063,7 +1090,7 @@
 	if (!connection) /* TODO: handle this properly. */
 		return NULL;
 
-	iface = PURPLE_OBJECT_GET_CLASS(pobj)->dbus_ifaceinfo;
+	iface = find_interface_info_by_name(pobj, interface_name);
 	method_info = g_dbus_interface_info_lookup_method(iface, method_name);
 	g_return_val_if_fail(method_info != NULL, NULL);
 
diff --git a/libpurple/pobject.h b/libpurple/pobject.h
--- a/libpurple/pobject.h
+++ b/libpurple/pobject.h
@@ -451,10 +451,11 @@
  * signature described in the XML file.
  *
  * @param pobj The PurpleObject on which the method is called.
+ * @param interface_name The name of the interface method_name is tied to.
  * @param method_name The name of the method.
  * @returns The output parameters of the method, as described in the XML file. They must be freed using g_variant_unref().
  */
-GVariant* purple_object_dbus_call(PurpleObject *pobj, const char *method_name, ...);
+GVariant* purple_object_dbus_call(PurpleObject *pobj, const char *interface_name, const char *method_name, ...);
 
 #endif /* HAVE_DBUS */
 



More information about the Commits mailing list