/srv/mercurial-server/detachablepurple: ac71e15189d4: Initial up...

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


Changeset: ac71e15189d4549945ab89c7dbab64b60f612fa2
Author:	 Gilles Bedel <gillux at cpw.pidgin.im>
Date:	 2012-05-25 18:42 +0000
Branch:	 cpw.gillux.detachablepurple
URL: http://hg.pidgin.im/srv/mercurial-server/detachablepurple/rev/ac71e15189d4

Description:

Initial update of PurpleDBusCallback towards gdbus-based API: gobject part.

diffstat:

 libpurple/dbus/callback.c |  84 ++++++++++------------------------------------
 libpurple/dbus/callback.h |   9 -----
 2 files changed, 18 insertions(+), 75 deletions(-)

diffs (173 lines):

diff --git a/libpurple/dbus/callback.c b/libpurple/dbus/callback.c
--- a/libpurple/dbus/callback.c
+++ b/libpurple/dbus/callback.c
@@ -24,6 +24,7 @@
 #include "internal.h"
 #include "core.h"
 #include "dbus/callback.h"
+#include "dbus/callback.xml.h"
 #include "dbus/callback-server.h"
 #include "dbus/callback-client.h"
 #include "dbus-maybe.h"
@@ -62,15 +63,7 @@
 
 G_DEFINE_TYPE(PurpleDBusCallback, purple_dbus_callback, PURPLE_TYPE_OBJECT)
 
-/* Our signals */
-enum
-{
-	SIG_DBUS_RUN_CALLBACK,
-	SIG_DBUS_REQUEST_CLOSED,
-	SIG_LAST
-};
-
-static guint signals[SIG_LAST] = {0, };
+#define PURPLE_TYPE_CALLBACK                   (purple_dbus_callback_get_type())
 
 static void run_callback_cb(DBusGProxy *proxy, const guint64 callback_id, GPtrArray *params, gpointer data);
 static void request_closed_cb(DBusGProxy *proxy, const guint request_id, gpointer data);
@@ -95,7 +88,6 @@
 PurpleDBusCallback*
 purple_dbus_callback_get_instance(void)
 {
-	DBusGProxy* proxy;
 	PurpleDBusCallbackClass *klass;
 	PurpleDBusCallback *instance;
 
@@ -104,28 +96,6 @@
 		instance = g_object_new(PURPLE_TYPE_DBUS_CALLBACK, NULL);
 		klass = g_type_class_peek(PURPLE_TYPE_DBUS_CALLBACK);
 		klass->instance = instance;
-
-		/* Register this object on DBus */
-		purple_object_install_dbus_infos(PURPLE_OBJECT(klass->instance),
-		                                 DBUS_CALLBACK_INTERFACE,
-		                                 DBUS_CALLBACK_PATH);
-
-		/* In remote mode, get informed from its signals */
-		if (purple_core_is_remote_mode()) {
-			proxy = purple_object_get_dbus_obj_proxy(PURPLE_OBJECT(klass->instance));
-			dbus_g_proxy_add_signal(proxy, "RunCallback", 
-			                        G_TYPE_UINT64,
-			                        DBUS_GVALUE_ARRAY,
-			                        G_TYPE_INVALID);
-			dbus_g_proxy_connect_signal(proxy, "RunCallback",
-			                            G_CALLBACK(run_callback_cb),
-			                            klass->instance, NULL);
-			dbus_g_proxy_add_signal(proxy, "RequestClosed", 
-			                        G_TYPE_UINT, G_TYPE_INVALID);
-			dbus_g_proxy_connect_signal(proxy, "RequestClosed",
-			                        G_CALLBACK(request_closed_cb),
-			                        klass->instance, NULL);
-		}
 	}
 
 	return klass->instance;
@@ -146,45 +116,30 @@
 	G_OBJECT_CLASS(purple_dbus_callback_parent_class)->finalize(self);
 }
 
+static char*
+purple_callback_build_dbus_path(PurpleObject *object)
+{
+	return g_strdup(DBUS_CALLBACK_PATH);
+}
+
 static void
 purple_dbus_callback_class_init(PurpleDBusCallbackClass *klass)
 {
 	GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
+	PurpleObjectClass *pobjclass = PURPLE_OBJECT_CLASS(klass);
 
 	gobject_class->finalize     = purple_dbus_callback_finalize;
 	klass->instance = NULL;
 
+	/* Register our interface. */
+	purple_object_class_register_dbus_iface
+	 (pobjclass, PURPLE_TYPE_CALLBACK, &purple_callback_interface_info);
+	/* Both client and daemon can build this well-known name. */
+	pobjclass->build_dbus_path = purple_callback_build_dbus_path;
+
 	if (purple_core_is_daemon_mode()) {
-		/* dbus_glib_DBUS_purple_callback_object_info is defined in
-		 * dbus-callback-server.h, which is autogenerated. */
-		purple_object_type_install_dbus_infos(PURPLE_TYPE_DBUS_CALLBACK,
-		                  &dbus_glib_DBUS_purple_callback_object_info);
-
-		/* Register the signals */
-		signals[SIG_DBUS_RUN_CALLBACK] =
-			g_signal_new("run_callback",
-			 G_OBJECT_CLASS_TYPE(klass),
-			 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
-			 purple_smarshal_VOID__UINT64_BOXED,
-			 G_TYPE_NONE, 2, G_TYPE_UINT64, DBUS_GVALUE_ARRAY);
-		signals[SIG_DBUS_REQUEST_CLOSED] =
-			g_signal_new("request_closed",
-			 G_OBJECT_CLASS_TYPE(klass),
-			 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
-			 g_cclosure_marshal_VOID__UINT,
-			 G_TYPE_NONE, 1, G_TYPE_UINT);
 	}
-	/* In remote mode we need to register the marshallers
-	 * we will use to receive the signals sent by the daemon */
 	else if (purple_core_is_remote_mode()) {
-		/* Marshaller for the RunCallback dbus signal */
-		dbus_g_object_register_marshaller(
-			purple_smarshal_VOID__UINT64_BOXED,
-			G_TYPE_NONE,  G_TYPE_UINT64, G_TYPE_BOXED,
-			G_TYPE_INVALID);
-		/* The marshaller for the RequestClosed signal doesn't need to
-		 * be registered, because it's one of glib marshallers and
-		 * dbus-glib use it. */
 	}
 }
 
@@ -211,6 +166,9 @@
 		self->client_reqs = g_hash_table_new_full(g_direct_hash,
 		                            g_direct_equal, NULL,
 		                            (GDestroyNotify)free_pending_req);
+
+	/* Publish/listen for the object on the bus. */
+	purple_dbus_connect_object(self);
 }
 
 guint64
@@ -405,12 +363,6 @@
 }
 
 gboolean
-DBUS_purple_callback_run_request(PurpleDBusCallback *handler, guint request_id, guint choice, GError** error)
-{
-	return purple_callback_run_request(request_id, choice);
-}
-
-gboolean
 purple_callback_run_request(guint request_id, guint choice)
 {
 	PurpleDBusCallback* handler = purple_dbus_callback_get_instance();
diff --git a/libpurple/dbus/callback.h b/libpurple/dbus/callback.h
--- a/libpurple/dbus/callback.h
+++ b/libpurple/dbus/callback.h
@@ -57,10 +57,6 @@
 	PurpleDBusCallback *instance;
 } PurpleDBusCallbackClass;
 
-/* DBus transfered data formats */
-#define DBUS_GVALUE_ARRAY \
-	dbus_g_type_get_collection("GPtrArray",	G_TYPE_VALUE)
-
 G_BEGIN_DECLS
 
 /**
@@ -146,11 +142,6 @@
 void purple_callback_run_request_RPC(guint request_id, guint choice);
 
 /**
- * Daemon side purple_callback_run_request() wrapper.
- */
-gboolean DBUS_purple_callback_run_request(PurpleDBusCallback *handler, guint request_id, guint choice, GError** error);
-
-/**
  * Closes a pending client request, executing its closing closure provided
  * in purple_callback_register_req_id().
  *



More information about the Commits mailing list