cpw.gillux.detachablepurple: 4dcffaff: Initial update of PurpleDBusCallback tow...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Fri May 25 15:46:56 EDT 2012


----------------------------------------------------------------------
Revision: 4dcffaff1c53b9897b12840ad523b266a5f4a099
Parent:   1945499a5666a886a2b049a0260de03406f2c68d
Author:   gillux at soc.pidgin.im
Date:     05/25/12 14:42:32
Branch:   im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/4dcffaff1c53b9897b12840ad523b266a5f4a099

Changelog: 

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

Changes against parent 1945499a5666a886a2b049a0260de03406f2c68d

  patched  libpurple/dbus/callback.c
  patched  libpurple/dbus/callback.h

-------------- next part --------------
============================================================
--- libpurple/dbus/callback.c	82a73884b9599f7efa395322422e4f4f9d73b138
+++ libpurple/dbus/callback.c	974bf3bc878090da6acaa6aeeca666945a65d415
@@ -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,16 +63,8 @@ G_DEFINE_TYPE(PurpleDBusCallback, purple
 
 G_DEFINE_TYPE(PurpleDBusCallback, purple_dbus_callback, PURPLE_TYPE_OBJECT)
 
-/* Our signals */
-enum
-{
-	SIG_DBUS_RUN_CALLBACK,
-	SIG_DBUS_REQUEST_CLOSED,
-	SIG_LAST
-};
+#define PURPLE_TYPE_CALLBACK                   (purple_dbus_callback_get_type())
 
-static guint signals[SIG_LAST] = {0, };
-
 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 @@ purple_dbus_callback_get_instance(void)
 PurpleDBusCallback*
 purple_dbus_callback_get_instance(void)
 {
-	DBusGProxy* proxy;
 	PurpleDBusCallbackClass *klass;
 	PurpleDBusCallback *instance;
 
@@ -104,28 +96,6 @@ purple_dbus_callback_get_instance(void)
 		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 @@ purple_dbus_callback_finalize(GObject *s
 	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;
 
-	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 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;
 
-		/* 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);
+	if (purple_core_is_daemon_mode()) {
 	}
-	/* 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 @@ purple_dbus_callback_init(PurpleDBusCall
 		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
 }
 
 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();
============================================================
--- libpurple/dbus/callback.h	c1729e822bb045c2296961f5c9e7aceb13c2f7ce
+++ libpurple/dbus/callback.h	f1d91fe1db306502deb42a55b37e83ddd2ac3e95
@@ -57,10 +57,6 @@ typedef struct {
 	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(gui
 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