/srv/mercurial-server/detachablepurple: 2d8421eaf96f: Going mult...

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


Changeset: 2d8421eaf96f27a88c547f2de32ac1f48c214f2c
Author:	 Gilles Bedel <gillux at cpw.pidgin.im>
Date:	 2012-05-20 14:26 +0000
Branch:	 cpw.gillux.detachablepurple
URL: http://hg.pidgin.im/srv/mercurial-server/detachablepurple/rev/2d8421eaf96f

Description:

Going multi-interface. Callback binder function now takes
the target interface as parameter, so that signal or method
of the same name cannot clash between two interfaces.

diffstat:

 libpurple/pobject.c |  20 +++++++++++++++-----
 libpurple/pobject.h |  10 +++++++---
 2 files changed, 22 insertions(+), 8 deletions(-)

diffs (99 lines):

diff --git a/libpurple/pobject.c b/libpurple/pobject.c
--- a/libpurple/pobject.c
+++ b/libpurple/pobject.c
@@ -725,22 +725,32 @@
 
 void
 purple_object_bind_dbus_callback(PurpleObjectClass *klass,
-                                 const char *name,
+                                 const char *iface_name, const char *cb_name,
                                  GCallback func)
 {
 	GClosure* closure;
+	gchar *name;
 
 	closure = g_cclosure_new(G_CALLBACK(func), NULL, NULL);
 	g_closure_set_marshal(closure, g_cclosure_marshal_generic);
+	name = g_strjoin(".", iface_name, cb_name, NULL);
 	g_datalist_set_data(&klass->dbus_callbacks, name, closure);
+	g_free(name);
 
 }
 
 GClosure *
 purple_object_get_dbus_closure(PurpleObjectClass *klass,
-                               const char *name)
+                               const gchar *interface_name,
+                               const gchar *name)
 {
-	return g_datalist_get_data(&klass->dbus_callbacks, name);
+	GClosure *ret;
+	gchar *fqn;
+
+	fqn = g_strjoin(".", interface_name, name, NULL);
+	ret = g_datalist_get_data(&klass->dbus_callbacks, fqn);
+	g_free(fqn);
+	return ret;
 }
 
 /*
@@ -788,7 +798,7 @@
 
 	/* Get the binded function back. */
 	closure = purple_object_get_dbus_closure(PURPLE_OBJECT_GET_CLASS(object),
-	                                         method_name);
+	                                         interface_name, method_name);
 	if (!closure)
 		return g_dbus_method_invocation_return_error
 		        (invoc, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD,
@@ -916,7 +926,7 @@
 
 	/* Get the sighandler back. */
 	closure = purple_object_get_dbus_closure(PURPLE_OBJECT_GET_CLASS(object),
-	                                         signal_name);
+	                                         interface_name, signal_name);
 	if (!closure) {
 		purple_debug_warning("dbus", "Signal %s received on interface %s lacks a sighandler.", signal_name, interface_name);
 		return;
diff --git a/libpurple/pobject.h b/libpurple/pobject.h
--- a/libpurple/pobject.h
+++ b/libpurple/pobject.h
@@ -223,7 +223,7 @@
 /**
  * Binds the function func with the D-Bus method (in daemon context) or
  * D-Bus signal (in client context) named name. The parameters of the method
- * or sighandler will be as in the dbus_ifaceinfo field of the class (which is
+ * or sighandler will be as in the dbus_ifaceinfos field of the class (which is
  * a C structure based representation of the DBus XML interface). The given
  * PurpleObjectClass klass must be the super-class the class intended to
  * provide the method or signal, e.g. the super-class of PurpleAccountClass.
@@ -231,12 +231,14 @@
  * dbus_callbacks data set, in klass.
  *
  * @param klass The super-class of the class providing the method or signal.
- * @param name The name of the method or signal on DBus.
+ * @param interface_name The name of the interface callback_name is tied to.
+ * @param callback_name The name of the method or signal on DBus.
  * @param func The function called when one calls the method or receive the signal on D-Bus.
  *
  */
 void purple_object_bind_dbus_callback(PurpleObjectClass *klass,
-                                      const char        *name,
+                                      const char        *interface_name,
+                                      const char        *callback_name,
                                       GCallback          func);
 
 /**
@@ -255,10 +257,12 @@
  * (in dameon context) or signal handler (in client context) named name.
  *
  * @param klass The super-class of the class handling name.
+ * @param interface_name The name of the interface 'name' is tied to.
  * @param name The name of the method or signal on DBus.
  * @see purple_object_bind_dbus_callback
  */
 GClosure *purple_object_get_dbus_closure(PurpleObjectClass *klass,
+                                         const char        *interface_name,
                                          const char        *name);
 
 /**



More information about the Commits mailing list