cpw.gillux.detachablepurple: 05824342: Updated PurpleConnection for to the new ...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Mon May 14 23:26:52 EDT 2012


----------------------------------------------------------------------
Revision: 05824342d517e79f17199138aa8b3117240951dd
Parent:   62c6e7dd846e535c8aa65ff17443ec6107f7f607
Author:   gillux at soc.pidgin.im
Date:     05/14/12 23:21:58
Branch:   im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/05824342d517e79f17199138aa8b3117240951dd

Changelog: 

Updated PurpleConnection for to the new gdbus-based API.

Changes against parent 62c6e7dd846e535c8aa65ff17443ec6107f7f607

  patched  libpurple/connection.c
  patched  libpurple/dbus/connection.c
  patched  libpurple/dbus/connection.h

-------------- next part --------------
============================================================
--- libpurple/connection.c	4225e2862833c94d6bd02f35fa4cb0368045dded
+++ libpurple/connection.c	20c35dfd092229d84b3bd031cdd4c10ebdeb9124
@@ -227,15 +227,13 @@ _purple_connection_new(PurpleAccount *ac
 
 	gc = g_object_new(PURPLE_TYPE_CONNECTION, "account", account, NULL);
 	PURPLE_DBUS_REGISTER_POINTER(gc, PurpleConnection);
-	purple_connection_dbus_init(gc, account, regist, password);
 
 	priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
 
 	priv->password = g_strdup(password);
 
-	/* In mirror mode we don't want to sign on. */
-	if (purple_core_is_mirror_mode())
-		return;
+	/* D-Bus-related initialization. */
+	purple_object_dbus_init(gc);
 
 	g_signal_emit(G_OBJECT(gc), signals[SIG_SIGNING_ON], 0);
 
@@ -354,10 +352,11 @@ purple_connection_set_state(PurpleConnec
 
 	PurpleConnectionPrivate *priv;
 
-	/* We shouldn't get there in remote mode, connection state should
-	 * only be set by the prpls. */
-	if(purple_core_is_remote_mode())
-		g_return_if_reached();
+	/* In remote mode, the only situation where we may set this property
+	 * is when the object is initializing. */
+	if (purple_core_is_remote_mode()
+	    && purple_object_get_synchronized(PURPLE_OBJECT(gc)))
+			g_return_if_reached();
 
 	g_return_if_fail(PURPLE_IS_CONNECTION(gc));
 	priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
@@ -367,6 +366,9 @@ purple_connection_set_state(PurpleConnec
 
 	priv->state = state;
 
+	/* In remote mode we only need to keep track of the state value. */
+	if (purple_core_is_remote_mode())
+		return;
 #if 0
 	ops = purple_connections_get_ui_ops();
 
@@ -450,10 +452,11 @@ void purple_connection_set_flags(PurpleC
 {
 	PurpleConnectionPrivate *priv;
 
-	/* We shouldn't get there in remote mode, connection flags should
-	 * only be set by the prpls. */
-	if(purple_core_is_remote_mode())
-		g_return_if_reached();
+	/* In remote mode, the only situation where we may set this property
+	 * is when the object is initializing. */
+	if (purple_core_is_remote_mode()
+	    && purple_object_get_synchronized(PURPLE_OBJECT(gc)))
+			g_return_if_reached();
 
 	g_return_if_fail(PURPLE_IS_CONNECTION(gc));
 	priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
@@ -465,10 +468,11 @@ purple_connection_set_account(PurpleConn
 {
 	PurpleConnectionPrivate *priv;
 
-	/* We shouldn't get there in remote mode, the account should
-	 * only be set on the daemon. */
-	if(purple_core_is_remote_mode())
-		g_return_if_reached();
+	/* In remote mode, the only situation where we may set this property
+	 * is when the object is initializing. */
+	if (purple_core_is_remote_mode()
+	    && purple_object_get_synchronized(PURPLE_OBJECT(gc)))
+			g_return_if_reached();
 
 	g_return_if_fail(account != NULL);
 	priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
@@ -1092,7 +1096,7 @@ purple_connection_class_init(PurpleConne
 					 0);
 
 	/* Install dbus stuff */
-	purple_connection_class_dbus_init();
+	purple_connection_class_dbus_init(klass);
 }
 
 /******************************************************************************
============================================================
--- libpurple/dbus/connection.c	8c5d4d3f8923307a5be2b4c243c7833085f0a628
+++ libpurple/dbus/connection.c	279b335e1ea7a5d99feac0ded9118fd65febc90b
@@ -22,16 +22,17 @@
 #include "internal.h"
 #include "core.h"
 #include "dbus/connection.h"
-#include "dbus/connection-client.h"
-#include "dbus/connection-server.h"
+#include "dbus/connection.xml.h"
 #include "dbus/constructor.h"
 #include "dbus-server.h"
 #include "dbus-purple.h"
 #include "pobject.h"
 
 static char*
-purple_connection_build_dbus_path(PurpleAccount *account)
+purple_connection_build_dbus_path(PurpleObject *pobject)
 {
+	PurpleConnection *gc = PURPLE_CONNECTION(pobject);
+	PurpleAccount *account = purple_connection_get_account(gc);
 	const char *proto;
 	const char *username;
 	gchar *path;
@@ -46,32 +47,33 @@ purple_connection_build_dbus_path(Purple
         return path_valid;
 }
 
-void
-purple_connection_class_dbus_init(void)
+static void
+purple_connection_dbus_init(gpointer object)
 {
+	PurpleConnection *gc = PURPLE_CONNECTION(object);
+	PurpleObject *pobject = PURPLE_OBJECT(gc);
+
+	/* Publish/listen for the object on the bus. */
+	purple_dbus_connect_object(gc);
+	/* Keep the properties synchronized between client and daemon. */
+	purple_object_dbus_bind_notify(pobject);
+
 	if (purple_core_is_daemon_mode()) {
-		/* Install method introspection data */
-		purple_object_type_install_dbus_infos(PURPLE_TYPE_CONNECTION,
-		                &dbus_glib_DBUS_purple_connection_object_info);
+		/* Tell the clients about this new account. */
+		purple_constructor_announce_pobject_creation(pobject);
 	}
 }
 
 void
-purple_connection_dbus_init(PurpleConnection *gc, PurpleAccount *account, gboolean regist, const char *password)
+purple_connection_class_dbus_init(PurpleConnectionClass *klass)
 {
-	char* dbus_path;
+	PurpleObjectClass *pobjclass = PURPLE_OBJECT_CLASS(klass);
 
-	dbus_path = purple_connection_build_dbus_path(account);
-	purple_object_install_dbus_infos(PURPLE_OBJECT(gc),
-	                                 DBUS_CONNECTION_INTERFACE, dbus_path);
-	g_free(dbus_path);
-
+	pobjclass->dbus_ifaceinfo = &purple_connection_interface_info;
+	pobjclass->dbus_init = purple_connection_dbus_init;
 	if (purple_core_is_daemon_mode()) {
-		/* Inform the clients we have a new PurpleConnection. */
-		g_signal_emit_by_name(
-		           G_OBJECT(purple_constructor_get_instance()),
-	                   "purple_connection_created",
-	                   purple_object_get_dbus_path(PURPLE_OBJECT(account)),
-	                   regist, password);
+		/* Only the daemon shall build path names,
+		 * and may give them to the clients. */
+		pobjclass->build_dbus_path = purple_connection_build_dbus_path;
 	}
 }
============================================================
--- libpurple/dbus/connection.h	dab0143460d392532577c9c82d06f868ac02fed0
+++ libpurple/dbus/connection.h	d0f6d0c4bf6a24db081c55f6a55dbb6f0306b802
@@ -28,13 +28,8 @@ G_BEGIN_DECLS
 /**
  * Initialize the dbus data of the connection class.
  */
-void purple_connection_class_dbus_init(void);
+void purple_connection_class_dbus_init(PurpleConnectionClass *klass);
 
-/**
- * Initialize the dbus data of a new connection.
- */
-void purple_connection_dbus_init(PurpleConnection *gc, PurpleAccount *account, gboolean regist, const char *password);
-
 G_END_DECLS
 
 #else /* !HAVE_DBUS */


More information about the Commits mailing list