cpw.gillux.detachablepurple: 8fdb17ac: Rewritten the "Unregister" D-Bus method ...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Fri May 25 15:47:08 EDT 2012


----------------------------------------------------------------------
Revision: 8fdb17ac4d4551273dd61006908e89691fcba6f7
Parent:   675c21b5c52aa592fd4a13c00ad8cbbeb7e2c3a7
Author:   gillux at soc.pidgin.im
Date:     05/25/12 14:59:19
Branch:   im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/8fdb17ac4d4551273dd61006908e89691fcba6f7

Changelog: 

Rewritten the "Unregister" D-Bus method of PurpleAccount,
according to the new gdbus-based API.

Changes against parent 675c21b5c52aa592fd4a13c00ad8cbbeb7e2c3a7

  patched  libpurple/dbus/account.c

-------------- next part --------------
============================================================
--- libpurple/dbus/account.c	5203c8fe31d7d17209473894f47f680c9cbf7ed3
+++ libpurple/dbus/account.c	b1f8bc5e75b9ed81de64575a6547590877a9ce95
@@ -204,10 +204,10 @@ purple_account_class_dbus_init(PurpleAcc
 		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 @@ purple_account_unregister_RPC(PurpleAcco
 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