soc.2010.detachablepurple: bf7a0c0e: Moved some initialization code that belo...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Tue Jul 6 17:01:12 EDT 2010


----------------------------------------------------------------------
Revision: bf7a0c0ef62b447f5b1d6f835956646d060eb6e7
Parent:   29f6b38b49e0bdceed76a5a74735f696f35ca4a2
Author:   gillux at soc.pidgin.im
Date:     07/06/10 16:45:08
Branch:   im.pidgin.soc.2010.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/bf7a0c0ef62b447f5b1d6f835956646d060eb6e7

Changelog: 

Moved some initialization code that belongs to dbus rather than purple accounts.

Changes against parent 29f6b38b49e0bdceed76a5a74735f696f35ca4a2

  patched  libpurple/account.c
  patched  libpurple/dbus-server.c

-------------- next part --------------
============================================================
--- libpurple/account.c	23ae997924a6573ee4440bceaa2eadb793fc9ad9
+++ libpurple/account.c	e29d108344e99dec8fab101d3c6ed084075a4029
@@ -51,7 +51,6 @@
 #  include "account-dbus.h"
 #  include "dbus-account-server.h"
 #  include "dbus-account-client.h"
-#  include "dbus-constructor.h"
 #  include "dbus-constructor-client.h"
 #endif
 
@@ -3027,11 +3026,6 @@ purple_accounts_init(void)
 void
 purple_accounts_init(void)
 {
-#ifdef HAVE_DBUS
-	DBusGProxy* dbus_proxy;
-	GError *error = NULL;
-	guint request_ret;
-#endif
 	void *handle = purple_accounts_get_handle();
 
 	purple_signal_register(handle, "account-connecting",
@@ -3116,35 +3110,6 @@ purple_accounts_init(void)
 	purple_signal_connect(conn_handle, "connection-error", handle,
 	                      PURPLE_CALLBACK(connection_error_cb), NULL);
 #endif
-
-#ifdef HAVE_DBUS
-	/* Export our objects only if we are in normal mode. */
-	if (!purple_core_get_remote_mode()) {
-		/*
-		 * Create a proxy for the account objects, so we can register them
-		 * on the bus.
-		 */
-		dbus_proxy = dbus_g_proxy_new_for_name(purple_dbus_get_g_connection(),
-											DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
-											DBUS_INTERFACE_DBUS);
-		if (!dbus_proxy) {
-			purple_debug_error("dbus", "Unable to create proxy\n");
-		} else {
-			if (!org_freedesktop_DBus_request_name(dbus_proxy,
-												DBUS_PURPLE_SERVICE, 0,
-												&request_ret, &error)) {
-				purple_debug_error("dbus", "Unable to request the name of service "
-								DBUS_PURPLE_SERVICE ": %s\n", error->message);
-				g_error_free(error);
-			}
-			/* We should also care about request_ret */
-		}
-
-		dbus_g_connection_register_g_object(purple_dbus_get_g_connection(),
-										DBUS_CONSTRUCTOR_PATH,
-										G_OBJECT(purple_constructor_get_instance()));
-	}
-#endif
 }
 
 void
============================================================
--- libpurple/dbus-server.c	64719562c572c07f0e63850e964e40abf20e957e
+++ libpurple/dbus-server.c	d350d5f71d70186edfc3745fe403b7d847cdffc8
@@ -34,10 +34,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <dbus/dbus-glib-bindings.h>
 
 #include "account.h"
 #include "blist.h"
 #include "conversation.h"
+#include "dbus-constructor.h"
 #include "dbus-purple.h"
 #include "dbus-server.h"
 #include "dbus-useful.h"
@@ -663,8 +665,46 @@ purple_dbus_dispatch_init(void)
 	PURPLE_DBUS_REGISTER_BINDINGS(purple_dbus_get_handle());
 }
 
+static void
+purple_dbus_g_init(void)
+{
+	DBusGProxy* dbus_proxy;
+	GError *error = NULL;
+	guint request_ret;
 
+	/* Export our objects only if we are in normal mode. */
+	if (purple_core_get_remote_mode())
+		return;
+	/*
+	 * Create a proxy for the purple service, so we can
+	 * publish our gobjects on DBus.
+	 */
+	dbus_proxy = dbus_g_proxy_new_for_name(purple_dbus_get_g_connection(),
+					DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
+					DBUS_INTERFACE_DBUS);
+	if (!dbus_proxy) {
+		purple_debug_error("dbus", "Unable to create proxy\n");
+	} else {
+		if (!org_freedesktop_DBus_request_name(dbus_proxy,
+						DBUS_PURPLE_SERVICE, 0,
+						&request_ret, &error)) {
+			purple_debug_error("dbus",
+					"Unable to request the name of service "
+					DBUS_PURPLE_SERVICE ": %s\n",
+					error->message);
+			g_error_free(error);
+		}
+		/* We should also care about request_ret */
+	}
 
+	/* Instantiate and publish the PurpleConstructor */
+	dbus_g_connection_register_g_object(purple_dbus_get_g_connection(),
+					DBUS_CONSTRUCTOR_PATH,
+					G_OBJECT(purple_constructor_get_instance()));
+}
+
+
+
 /**************************************************************************/
 /** @name Signals                                                         */
 /**************************************************************************/
@@ -847,6 +887,8 @@ purple_dbus_init(void)
 	purple_dbus_dispatch_init();
 	if (init_error != NULL)
 		purple_debug_error("dbus", "%s\n", init_error);
+
+	purple_dbus_g_init();
 }
 
 void


More information about the Commits mailing list