cpw.gillux.detachablepurple: 3bd19521: Going multi-interface. Adapted the signa...
gillux at soc.pidgin.im
gillux at soc.pidgin.im
Sun May 20 13:21:15 EDT 2012
----------------------------------------------------------------------
Revision: 3bd19521f44ac3540bcce65108dcd18871538581
Parent: e40bc5ea24e2b3af38d792bcddc2db9e950ccfd4
Author: gillux at soc.pidgin.im
Date: 05/20/12 09:21:18
Branch: im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/3bd19521f44ac3540bcce65108dcd18871538581
Changelog:
Going multi-interface. Adapted the signal registration part,
so that we register every interface of the given object.
Changes against parent e40bc5ea24e2b3af38d792bcddc2db9e950ccfd4
patched libpurple/pobject.c
patched libpurple/pobject.h
-------------- next part --------------
============================================================
--- libpurple/pobject.c 4103522e5b92d8e7ecd8a301730dfa841bd3f0ac
+++ libpurple/pobject.c c1d5be4a6b69be9403bb3e8320de3900b160bcec
@@ -902,26 +902,44 @@ purple_object_generic_dbus_sighandler(GD
g_free (paramv);
}
-guint
+void
purple_object_generic_dbus_signal_subscribe(gpointer object, GDBusConnection *dbus_conn)
{
PurpleObject *pobj = PURPLE_OBJECT(object);
+ PurpleObjectClass *pobjclass = PURPLE_OBJECT_GET_CLASS(pobj);
+ GDBusInterfaceInfo *ifaceinfo;
+ GType type, child;
guint reg_id;
- reg_id = g_dbus_connection_signal_subscribe
- (dbus_conn, NULL, /* TODO: is NULL for 'sender' what we want? */
- PURPLE_OBJECT_GET_CLASS(pobj)->dbus_ifaceinfo->name,
- NULL, /* any signal name */
- purple_object_get_dbus_path(pobj),
- NULL, /* any first arg */
- G_DBUS_SIGNAL_FLAGS_NONE,
- purple_object_generic_dbus_sighandler, object, NULL);
+ /* Step from the most derived type to PurpleObject
+ * type and retreive 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) {
+ reg_id = g_dbus_connection_signal_subscribe
+ (dbus_conn, NULL, /* TODO: is NULL for 'sender' what we want? */
+ ifaceinfo->name,
+ NULL, /* any signal name */
+ purple_object_get_dbus_path(pobj),
+ NULL, /* any first arg */
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ purple_object_generic_dbus_sighandler,
+ object, NULL);
- if (reg_id == 0) {
- purple_debug_error("dbus", "Failed to subscribe %s to D-Bus signals\n",
- G_OBJECT_TYPE_NAME(object));
+ if (reg_id == 0) {
+ purple_debug_error("dbus",
+ "Failed to subscribe a %s with interface %s to D-Bus signals\n",
+ G_OBJECT_TYPE_NAME(object), ifaceinfo->name);
+ } else {
+ purple_object_add_dbus_reg_id(pobj, reg_id);
+ }
+ }
+ child = type;
+ type = g_type_parent(type);
}
- return reg_id;
+ while (child != PURPLE_TYPE_OBJECT && child != 0);
}
void
@@ -936,11 +954,9 @@ purple_object_dbus_connect(gpointer obje
purple_object_dbus_connect(gpointer object, GDBusConnection *dbus_conn)
{
PurpleObjectClass *pclass = PURPLE_OBJECT_GET_CLASS(object);
- guint reg_id;
if (pclass->on_dbus_connected) {
- reg_id = pclass->on_dbus_connected(object, dbus_conn);
- purple_object_set_dbus_reg_id(PURPLE_OBJECT(object), reg_id);
+ pclass->on_dbus_connected(object, dbus_conn);
}
}
============================================================
--- libpurple/pobject.h 0ba1763353e82c302094d0ec27b97f0ff4128789
+++ libpurple/pobject.h 3d74708889ea6536bfe107c872a32aaa9fe4372f
@@ -51,9 +51,8 @@ struct _PurpleObjectClass
#ifdef HAVE_DBUS
/* A function called when the DBus connection is acquiered. Usually,
in deamon context the object should register itself on the bus,
- whereas on client context it should put DBus signals handlers.
- Returns the registration or subscription id provided by GDbus/ */
- guint (*on_dbus_connected)(gpointer object, GDBusConnection *connection);
+ whereas on client context it should put DBus signals handlers. */
+ void (*on_dbus_connected)(gpointer object, GDBusConnection *connection);
/* A data set of DBus methods (in daemon context) or signals (in client
context) names as keys and GClosures as values. */
GData *dbus_callbacks;
@@ -385,9 +384,9 @@ void purple_object_generic_dbus_register
*
* @param object An object derived from PurpleObject.
* @param dbus_conn The GDBus handle.
- * @return The registration id returned by g_dbus_connection_signal_subscribe().
*/
-guint purple_object_generic_dbus_signal_subscribe(gpointer object, GDBusConnection *dbus_conn);
+void purple_object_generic_dbus_signal_subscribe(gpointer object, GDBusConnection *dbus_conn);
+
/**
* Adds an D-Bus interface definition to the pool of handled interfaces
* by the object class of the given type. This function should be ran by
More information about the Commits
mailing list