soc.2010.detachablepurple: eacfa3ae: Wrapped the purple_account_unregister() ...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Wed Jul 28 13:46:05 EDT 2010


----------------------------------------------------------------------
Revision: eacfa3ae69ce431ea2ee4c27cfa43b5a230938cf
Parent:   d5eca9b19a96e36d49abc257439a5a0f38832399
Author:   gillux at soc.pidgin.im
Date:     07/28/10 13:40:43
Branch:   im.pidgin.soc.2010.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/eacfa3ae69ce431ea2ee4c27cfa43b5a230938cf

Changelog: 

Wrapped the purple_account_unregister() method for dbus, thanks to the new
system that handle callbacks.

Changes against parent d5eca9b19a96e36d49abc257439a5a0f38832399

  patched  libpurple/account-dbus.c
  patched  libpurple/account-dbus.h
  patched  libpurple/account.c
  patched  libpurple/dbus-callback.c
  patched  libpurple/dbus-callback.h
  patched  libpurple/dbus-prototypes/account.xml

-------------- next part --------------
============================================================
--- libpurple/account.c	ddaac54688feadc04e8c583201e87929962386b7
+++ libpurple/account.c	4e445cfa9c4273157049022162b6388be42c23c7
@@ -896,6 +896,10 @@ purple_account_unregister(PurpleAccount 
 {
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
+	/* Handle remote mode case */
+	if (purple_core_is_remote_mode())
+		return purple_account_unregister_RPC(account, cb, user_data);
+
 	purple_debug_info("account", "Unregistering account %s\n",
 					  purple_account_get_username(account));
 
============================================================
--- libpurple/account-dbus.c	b3e17ce50a5971eb6c10314192eaf55ac96b8444
+++ libpurple/account-dbus.c	0e3f10364345a859490dd0d47bfed04a31f7ac5b
@@ -6,6 +6,7 @@
 #include "account.h"
 #include "account-dbus.h"
 #include "dbus-account-client.h"
+#include "dbus-callback.h"
 #include "dbus-constructor-client.h"
 #include "dbus-maybe.h"
 
@@ -82,6 +83,38 @@ void
 }
 
 void
+purple_account_unregister_RPC(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data)
+{
+	DBusGProxy* proxy;
+	GError *error = NULL;
+	guint64 callback_id;
+	GClosure* closure;
+
+	proxy = purple_object_get_dbus_obj_proxy(PURPLE_OBJECT(account));
+	if (!im_pidgin_purple_account_unregister(proxy, &callback_id, &error)) {
+		PURPLE_RPC_FAILED(purple_account_unregister, error);
+		return;
+	}
+
+	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);
+}
+
+gboolean
+DBUS_purple_account_unregister(PurpleAccount *account, guint64 *callback_id, GError** error)
+{
+	guint64 *id = g_new0(guint64, 1);
+
+	/* Generate a new callback id */
+	*callback_id = *id = purple_dbus_callback_new_id();
+
+	/* Call the function with a wrapper callback */
+	purple_account_unregister(account, (PurpleAccountUnregistrationCb)purple_dbus_callback__b, id);
+	return TRUE;
+}
+
+void
 purple_account_set_status_list_RPC(PurpleAccount *account, const char *status_id, gboolean active, GList *attrs)
 {
 	DBusGProxy* proxy;
============================================================
--- libpurple/account-dbus.h	36cd1d5aabad98d13551c72745e62496c5d7506c
+++ libpurple/account-dbus.h	d37cde3ed930ebe696ec57e2724374f59bf7592c
@@ -36,11 +36,22 @@ gboolean DBUS_purple_account_set_status_
  */
 gboolean DBUS_purple_account_set_status_list(PurpleAccount *account, char *status_id, gboolean active, GPtrArray* attrs, GError** error);
 
+/**
+ * Client side purple_account_unregister() wrapper.
+ */
+void purple_account_unregister_RPC(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data);
+
+/**
+ * Server side purple_account_unregister() wrapper.
+ */
+gboolean DBUS_purple_account_unregister(PurpleAccount *account, guint64 *callback_id, GError** error);
+
 #else /* !HAVE_DBUS */
 
 #define purple_account_new_RPC(username, protocol_id) (NULL)
 #define purple_account_connect_RPC(account)           ((void)0)
 #define purple_account_register_RPC(account)          ((void)0)
 #define purple_account_set_status_list_RPC(acc, status, active, attr) ((void)0)
+#define purple_account_unregister(account, cb, user_data) ((void)0)
 
 #endif /* HAVE_DBUS */
============================================================
--- libpurple/dbus-prototypes/account.xml	d8375ed33082a33ea1ccbe044281f73ac9f0463e
+++ libpurple/dbus-prototypes/account.xml	4de2b25b9e670df726f50a2f51c5b25a522bb25d
@@ -12,6 +12,9 @@
 
 		<method name="Connect" />
 		<method name="Register" />
+		<method name="Unregister">
+			<arg type="t"  name="callback_id" direction="out" />
+		</method>
 		<method name="SetStatusList">
 			<arg type="s"  name="status_id"  direction="in" />
 			<arg type="b"  name="active"     direction="in" />
============================================================
--- libpurple/dbus-callback.c	a45a5f5c4d48871e3ee651dbf62123c0d9e4d407
+++ libpurple/dbus-callback.c	f747cb61398ed24e325357cbd164cfdb4045dc06
@@ -179,6 +179,17 @@ build_args_list(unsigned int n_args, ...
 	return values;
 }
 
+void
+purple_dbus_callback__b(void *obj, gboolean arg1, guint64 *id)
+{
+	PurpleDBusCallback* handler = g_object_new(PURPLE_TYPE_DBUS_CALLBACK, NULL);
+	GPtrArray* params = build_args_list(1, G_TYPE_BOOLEAN, arg1);
+	g_signal_emit(handler, signals[SIG_DBUS_RUN_CALLBACK], 0, *id, params);
+	g_ptr_array_foreach(params, (GFunc)g_value_unset, NULL);
+	g_ptr_array_free(params, TRUE);
+	g_free(id);
+}
+
 /**
  * Callback, called when we receive a dbus "RunCallback" signal.
  */
============================================================
--- libpurple/dbus-callback.h	88ebfb4d399c5499ed04c8f2b972035a8a258f59
+++ libpurple/dbus-callback.h	d3f3d8113fe3adc485c821ffc3aa3b9b9e9c138c
@@ -60,4 +60,10 @@ void purple_dbus_callback_register(guint
  */
 void purple_dbus_callback_register(guint64 id, GClosure *closure);
 
+/**
+ * Fake callback for using with callbacks that takes the following parameters:
+ * gboolean
+ */
+void purple_dbus_callback__b(void *obj, gboolean arg1, guint64 *id);
+
 #endif /* _DBUS_CALLBACK_H_ */


More information about the Commits mailing list