/srv/mercurial-server/detachablepurple: 9e19e7d5cf64: Rewritten ...
Gilles Bedel
gillux at cpw.pidgin.im
Fri Jun 15 22:01:49 EDT 2012
Changeset: 9e19e7d5cf641d3b83f74fc73db91e9db72d1c3a
Author: Gilles Bedel <gillux at cpw.pidgin.im>
Date: 2012-05-25 18:59 +0000
Branch: cpw.gillux.detachablepurple
URL: http://hg.pidgin.im/srv/mercurial-server/detachablepurple/rev/9e19e7d5cf64
Description:
Rewritten the "Unregister" D-Bus method of PurpleAccount,
according to the new gdbus-based API.
diffstat:
libpurple/dbus/account.c | 35 +++++++++++++++++++----------------
1 files changed, 19 insertions(+), 16 deletions(-)
diffs (76 lines):
diff --git a/libpurple/dbus/account.c b/libpurple/dbus/account.c
--- a/libpurple/dbus/account.c
+++ b/libpurple/dbus/account.c
@@ -204,10 +204,10 @@
purple_object_bind_dbus_callback
(pobjclass, purple_account_interface_info.name,
"Register", (GCallback)purple_account_register);
+ purple_object_bind_dbus_callback
+ (pobjclass, purple_account_interface_info.name,
+ "Unregister",(GCallback)account_unregister_cb);
/* Those are more complicated, we will handle them later.
- purple_object_bind_dbus_method(PURPLE_OBJECT_CLASS(klass),
- "Unregister",
- (GCallback)purple_account_unregister);
purple_object_bind_dbus_method(pobjclass, "SetStatusList",
(GCallback)purple_account_set_status_list);
*/
@@ -273,42 +273,45 @@
void
purple_account_unregister_RPC(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data)
{
- DBusGProxy* proxy;
- GError *error = NULL;
guint64 callback_id;
gboolean have_cb = (cb != NULL);
GClosure* closure;
+ GVariant *ret;
- proxy = purple_object_get_dbus_obj_proxy(PURPLE_OBJECT(account));
- if (!im_pidgin_purple_account_unregister(proxy, have_cb, &callback_id, &error)) {
- PURPLE_RPC_FAILED(purple_account_unregister, error);
- return;
- }
-
+ ret = purple_object_dbus_call(PURPLE_OBJECT(account),
+ purple_account_interface_info.name,
+ "Unregister", have_cb);
+ if (!ret)
+ return; /* Likely a connection problem. */
+
if (have_cb) {
+ g_variant_get(ret, "(t)", &callback_id);
closure = g_cclosure_new(G_CALLBACK(cb), user_data, NULL);
g_closure_set_marshal(closure, g_cclosure_marshal_VOID__BOOLEAN);
purple_dbus_callback_register(callback_id, closure);
}
+ g_variant_unref(ret);
}
-gboolean
-DBUS_purple_account_unregister(PurpleAccount *account, gboolean have_callback, guint64 *callback_id, GError** error)
+/* Server-side implementation of the "Unregister" D-Bus method. */
+static GVariant *
+account_unregister_cb(PurpleAccount *account, gboolean have_callback)
{
PurpleAccountUnregistrationCb cb = NULL;
guint64 *id = NULL;
+ guint64 ret = 0;
if (have_callback) {
/* Use a void(*cb)(GObject*, gboolean, void*) prototype */
cb = (PurpleAccountUnregistrationCb)purple_dbus_callback__b;
/* Generate a new callback id */
id = g_new0(guint64, 1);
- *callback_id = *id = purple_dbus_callback_new_id();
+ ret = *id = purple_dbus_callback_new_id();
}
- /* Call the function, perhabs with a wrapper callback */
+ /* Call the function, perhaps with a wrapper callback */
purple_account_unregister(account, cb, id);
- return TRUE;
+ return g_variant_new("(t)", ret);
}
void
More information about the Commits
mailing list