cpw.gillux.detachablepurple: 70e50cdc: Going multi-interface. Callback binder f...
gillux at soc.pidgin.im
gillux at soc.pidgin.im
Sun May 20 13:21:26 EDT 2012
----------------------------------------------------------------------
Revision: 70e50cdc3d778baf886cf633f13aa6608330fbcb
Parent: fa6a30e4942a02af3502e6727997679f884aa588
Author: gillux at soc.pidgin.im
Date: 05/20/12 10:26:27
Branch: im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/70e50cdc3d778baf886cf633f13aa6608330fbcb
Changelog:
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.
Changes against parent fa6a30e4942a02af3502e6727997679f884aa588
patched libpurple/pobject.c
patched libpurple/pobject.h
-------------- next part --------------
============================================================
--- libpurple/pobject.c f20ab71494e9fdb10d64a043fb9d93aaf781918a
+++ libpurple/pobject.c 9cea83784ec00ea8cc258f39024c0ea24d7108b3
@@ -725,22 +725,32 @@ purple_object_bind_dbus_callback(PurpleO
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 @@ purple_object_generic_dbus_method_handle
/* 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 @@ purple_object_generic_dbus_sighandler(GD
/* 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;
============================================================
--- libpurple/pobject.h 1d967ec3f74e0f9efc6380b9adaef192d9a0537a
+++ libpurple/pobject.h bf1f5d642667e9fee19e7e2dc3a8c5858ad92a06
@@ -223,7 +223,7 @@ gboolean purple_object_get_synchronized(
/**
* 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 @@ gboolean purple_object_get_synchronized(
* 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 @@ void purple_object_dbus_bind_notify(Purp
* (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