soc.2010.detachablepurple: 03ac4786: Moved the RPC related code from purple_a...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Thu Jul 15 17:35:47 EDT 2010


----------------------------------------------------------------------
Revision: 03ac478656ac3fc032ed66d98643727b1624d3dc
Parent:   5d6c8a19188d84d34a70a730fdea9385d81cb9a8
Author:   gillux at soc.pidgin.im
Date:     07/15/10 09:44:15
Branch:   im.pidgin.soc.2010.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/03ac478656ac3fc032ed66d98643727b1624d3dc

Changelog: 

Moved the RPC related code from purple_account_new() to the dbus-aware file
account-dbus.c, so that account.c requires quite a bit less #ifdef HAVE_DBUS.

Changes against parent 5d6c8a19188d84d34a70a730fdea9385d81cb9a8

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

-------------- next part --------------
============================================================
--- libpurple/account.c	b1e48a37c7034a4f03be4e5f3b4fed4669ce233b
+++ libpurple/account.c	f7bf70ea28bb9dc72244c69f387d76daf3c383b2
@@ -25,6 +25,7 @@
  */
 #include "internal.h"
 #include "account.h"
+#include "account-dbus.h"
 #include "accountlist.h"
 #include "core.h"
 #include "dbus-maybe.h"
@@ -43,6 +44,10 @@
 #include "util.h"
 #include "xmlnode.h"
 
+#ifdef HAVE_DBUS
+#  include "dbus-account-server.h"
+#endif
+
 #define PURPLE_ACCOUNT_GET_PRIVATE(account) \
 	(G_TYPE_INSTANCE_GET_PRIVATE((account), PURPLE_TYPE_ACCOUNT, PurpleAccountPrivate))
 typedef struct _PurpleAccountPrivate		PurpleAccountPrivate;
@@ -817,49 +822,15 @@ purple_account_new(const char *username,
 	PurplePluginProtocolInfo *prpl_info = NULL;
 	PurpleStatusType *status_type;
 	PurpleAccountPrivate *priv;
-#ifdef HAVE_DBUS
 	char* dbus_path;
-	DBusGProxy* dbus_proxy;
-	GError *error = NULL;
-#endif
 
 	g_return_val_if_fail(username != NULL, NULL);
 	g_return_val_if_fail(protocol_id != NULL, NULL);
 
-#ifdef HAVE_DBUS
-	/**
-	 * If we are in remote mode we only create a dummy object which
-	 * contains a dbus_proxy in its PurpleObject parent class.
-	 */
-	if(purple_core_get_remote_mode()) {
-		/* First, remotely create a new account */
-		dbus_proxy = dbus_g_proxy_new_for_name(purple_dbus_get_g_connection(),
-											DBUS_PURPLE_SERVICE,
-											DBUS_CONSTRUCTOR_PATH,
-											DBUS_CONSTRUCTOR_INTERFACE);
-		if (!im_pidgin_purple_constructor_new_account(dbus_proxy, username,
-													protocol_id, &dbus_path,
-													&error)) {
-			PURPLE_RPC_FAILED(purple_account_new, error);
-			return NULL;
-		}
+	/* Handle remote mode case */
+	if(purple_core_get_remote_mode())
+		return purple_account_new_RPC(username, protocol_id);
 
-		/* Then, locally create a dummy account that will hold a proxy */
-		account = g_object_new(PURPLE_TYPE_ACCOUNT, NULL);
-		/* One for the im.pidgin.purple.account interface */
-		dbus_proxy = dbus_g_proxy_new_for_name(purple_dbus_get_g_connection(),
-											DBUS_PURPLE_SERVICE, dbus_path,
-											DBUS_ACCOUNT_INTERFACE);
-		purple_object_set_dbus_obj_proxy(PURPLE_OBJECT(account), dbus_proxy);
-		/* One for the org.freedesktop.DBus.Properties interface */
-		dbus_proxy = dbus_g_proxy_new_for_name(purple_dbus_get_g_connection(),
-											DBUS_PURPLE_SERVICE, dbus_path,
-											DBUS_INTERFACE_PROPERTIES);
-		purple_object_set_dbus_props_proxy(PURPLE_OBJECT(account), dbus_proxy);
-		return account;
-	}
-#endif
-
 	account = purple_accounts_find(username, protocol_id);
 
 	if (account != NULL)
============================================================
--- libpurple/account-dbus.c	0a3aa4aa7cd025b470c59681ca70c2b1dfe69f74
+++ libpurple/account-dbus.c	def408db023ae3d7a88fba5cd5d049e05db172e7
@@ -1,4 +1,44 @@
 
-#include <glib.h>
+/* Provides DBUS_SERVICE_DBUS etc. */
+#include <dbus/dbus-glib-bindings.h>
+
+#include "internal.h"
 #include "account.h"
+#include "account-dbus.h"
+#include "dbus-constructor-client.h"
+#include "dbus-maybe.h"
 
+PurpleAccount*
+purple_account_new_RPC(const char *username, const char *protocol_id)
+{
+	PurpleAccount* account;
+	char* dbus_path;
+	DBusGProxy* dbus_proxy;
+	GError *error = NULL;
+
+	/* First, remotely create a new account */
+	dbus_proxy = dbus_g_proxy_new_for_name(purple_dbus_get_g_connection(),
+	                                       DBUS_PURPLE_SERVICE,
+	                                       DBUS_CONSTRUCTOR_PATH,
+	                                       DBUS_CONSTRUCTOR_INTERFACE);
+	if (!im_pidgin_purple_constructor_new_account(dbus_proxy, username,
+	                                              protocol_id, &dbus_path,
+	                                              &error)) {
+		PURPLE_RPC_FAILED(purple_account_new, error);
+		return NULL;
+	}
+
+	/* Then, locally create a dummy account that will hold a proxy */
+	account = g_object_new(PURPLE_TYPE_ACCOUNT, NULL);
+	/* One for the im.pidgin.purple.account interface */
+	dbus_proxy = dbus_g_proxy_new_for_name(purple_dbus_get_g_connection(),
+	                                       DBUS_PURPLE_SERVICE, dbus_path,
+	                                       DBUS_ACCOUNT_INTERFACE);
+	purple_object_set_dbus_obj_proxy(PURPLE_OBJECT(account), dbus_proxy);
+	/* One for the org.freedesktop.DBus.Properties interface */
+	dbus_proxy = dbus_g_proxy_new_for_name(purple_dbus_get_g_connection(),
+	                                       DBUS_PURPLE_SERVICE, dbus_path,
+	                                       DBUS_INTERFACE_PROPERTIES);
+	purple_object_set_dbus_props_proxy(PURPLE_OBJECT(account), dbus_proxy);
+	return account;
+}
============================================================
--- libpurple/account-dbus.h	adc83b19e793491b1c6ea0fd8b46cd9f32e592fc
+++ libpurple/account-dbus.h	72d07e3bbebbe67a058d4591e5b02988ba8f4212
@@ -1 +1,13 @@
 
+#ifdef HAVE_DBUS
+
+/**
+ * Used in remote mode context, to remotely call purple_account_new().
+ */
+PurpleAccount* purple_account_new_RPC(const char *username, const char *protocol_id);
+
+#else /* !HAVE_DBUS */
+
+#define purple_account_new_RPC(username, protocol_id) (NULL)
+
+#endif /* HAVE_DBUS */


More information about the Commits mailing list