cpw.gillux.detachablepurple: fa6a30e4: Going multi-interface. Adapted the metho...
gillux at soc.pidgin.im
gillux at soc.pidgin.im
Sun May 20 13:22:07 EDT 2012
----------------------------------------------------------------------
Revision: fa6a30e4942a02af3502e6727997679f884aa588
Parent: a0c45a2c7bf849466234579e0b626ab20cf26784
Author: gillux at soc.pidgin.im
Date: 05/20/12 09:47:09
Branch: im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/fa6a30e4942a02af3502e6727997679f884aa588
Changelog:
Going multi-interface. Adapted the method caller function.
It now takes the target interface as parameter.
Changes against parent a0c45a2c7bf849466234579e0b626ab20cf26784
patched libpurple/dbus/constructor.c
patched libpurple/pobject.c
patched libpurple/pobject.h
-------------- next part --------------
============================================================
--- libpurple/pobject.c 7803fb7eecc509b1e1be27edc5099dd9598a3fbd
+++ libpurple/pobject.c f20ab71494e9fdb10d64a043fb9d93aaf781918a
@@ -973,6 +973,32 @@ purple_object_generic_dbus_signal_subscr
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 *
}
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 @@ purple_object_dbus_call(PurpleObject *po
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);
============================================================
--- libpurple/pobject.h 60fcd05fc4cbbad8ef75be1798546bb001377d73
+++ libpurple/pobject.h 1d967ec3f74e0f9efc6380b9adaef192d9a0537a
@@ -451,10 +451,11 @@ gboolean purple_object_emit_dbus_signal(
* 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 */
============================================================
--- libpurple/dbus/constructor.c 368877382422976c2e8cd34f8ab533bbdf0a5cae
+++ libpurple/dbus/constructor.c d1628a9523e6afe70ea5a85bbce706cf925a8965
@@ -312,7 +312,9 @@ purple_constructor_load_all_pobj(const c
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);
More information about the Commits
mailing list