soc.2010.detachablepurple: 790409d3: Added a "mirror" running purple state, u...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Sat Jul 17 12:37:27 EDT 2010


----------------------------------------------------------------------
Revision: 790409d38476baf6d2a53cf12290cc07c67d53be
Parent:   fe682f8af7024f4c99c9d29b3535aaea8f49aca9
Author:   gillux at soc.pidgin.im
Date:     07/17/10 11:37:11
Branch:   im.pidgin.soc.2010.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/790409d38476baf6d2a53cf12290cc07c67d53be

Changelog: 

Added a "mirror" running purple state, used by clients to locally set an object
property, without triggering any inappropriate hook for remote mode.

Changes against parent fe682f8af7024f4c99c9d29b3535aaea8f49aca9

  patched  libpurple/account.c
  patched  libpurple/core.h
  patched  libpurple/dbus-constructor.c
  patched  libpurple/pobject.c

-------------- next part --------------
============================================================
--- libpurple/core.h	aef43be581c1ed25d6dd9ec65258896a73dd23f4
+++ libpurple/core.h	0388740f6d2200ad49bcb7c4328f08b82e0b5eec
@@ -84,6 +84,10 @@ typedef struct
  * PURPLE_RUN_DAEMON_MODE: used in detachable session context, for the daemon
  *     instance, which wraps libpurple and communicate with several UI clients
  *     through DBus.
+ * PURPLE_RUN_MIRROR_MODE: a special mode used in detachable sessions context
+ *     by the UI clients. It is used to handle "mirror" objects, to temporarly
+ *     and locally set a property without triggering any of the usual hooks
+ *     not desired in remote mode.
  * PURPLE_RUN_REMOTE_MODE: used in detachable session context, for UI client
  *     instance, which makes its libpurple to connects to the daemon a forward
  *     calls and events.
@@ -92,6 +96,7 @@ enum _PurpleRunningMode {
 	PURPLE_RUN_NORMAL_MODE,
 	PURPLE_RUN_DAEMON_MODE,
 	PURPLE_RUN_REMOTE_MODE,
+	PURPLE_RUN_MIRROR_MODE,
 	PURPLE_RUN_MODE_LAST
 };
 
@@ -109,11 +114,14 @@ extern "C" {
 	(purple_core_get_running_mode() == PURPLE_RUN_DAEMON_MODE)
 #  define purple_core_is_normal_mode() \
 	(purple_core_get_running_mode() == PURPLE_RUN_NORMAL_MODE)
+#  define purple_core_is_mirror_mode() \
+	(purple_core_get_running_mode() == PURPLE_RUN_MIRROR_MODE)
 
 #else /* !HAVE_DBUS */
 #  define purple_core_is_remote_mode() (FALSE)
 #  define purple_core_is_daemon_mode() (FALSE)
 #  define purple_core_is_normal_mode() (TRUE )
+#  define purple_core_is_mirror_mode() (FALSE)
 #endif
 
 /**
============================================================
--- libpurple/account.c	a571fda69f5b9bbecfde7d5049f8c10faae4d4cc
+++ libpurple/account.c	2869a2919b24f8814fe77c1dfd01203ab45ef41d
@@ -1002,6 +1002,9 @@ purple_account_connect(PurpleAccount *ac
 	/* Handle remote mode case */
 	if (purple_core_is_remote_mode())
 		return purple_account_connect_RPC(account);
+	/* Handle mirror mode case */
+	if (purple_core_is_mirror_mode())
+		return;
 
 	purple_debug_info("account", "Connecting to account %s.\n", username);
 
============================================================
--- libpurple/pobject.c	3e17f3f13a85a5014f65295ae29d0920c4afbd34
+++ libpurple/pobject.c	8a219f45bf7c4c7c4c6bb633d614056136dfce78
@@ -318,7 +318,7 @@ purple_object_notify_cb(DBusGProxy *prox
 
 	/* Update the local state of this property */
 	mode = purple_core_get_running_mode();
-	purple_core_set_running_mode(PURPLE_RUN_NORMAL_MODE);
+	purple_core_set_running_mode(PURPLE_RUN_MIRROR_MODE);
 	purple_debug_info("dbus", "Recieved notify about property '%s' of a %s\n",
 	                  prop_name, G_OBJECT_TYPE_NAME(obj));
 	g_object_set_property(G_OBJECT(obj), prop_name, prop_val);
============================================================
--- libpurple/dbus-constructor.c	b967df285f76dbd6f557a0fc49452357908a8f09
+++ libpurple/dbus-constructor.c	9f98c0044fac7bca44cea28e6347374232623494
@@ -309,12 +309,12 @@ load_accounts_cb(GValueArray* box)
 			"Couldn't load the account: username not found\n");
 		return;
 	}
-	/* Temporarly go in normal mode, and it will create a local account */
+	/* Temporarly go in mirror mode, and it will create a local account */
 	mode = purple_core_get_running_mode();
-	purple_core_set_running_mode(PURPLE_RUN_NORMAL_MODE);
+	purple_core_set_running_mode(PURPLE_RUN_MIRROR_MODE);
 	acc = purple_account_new(g_value_get_string(username), protocol_id);
 
-	/* Then load the others properties. Keep the normal mode here,
+	/* Then load the others properties. Keep the mirror mode here,
 	 * otherwise it will try to remotely set the properties.
 	 */
 	g_ptr_array_foreach(prop_array, (GFunc)load_account_prop_cb, acc);


More information about the Commits mailing list