cpw.gillux.detachablepurple: dc9df517: Added a "synchronized" flag to the Purpl...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Sat May 12 16:56:46 EDT 2012


----------------------------------------------------------------------
Revision: dc9df5177b2708d8ccc884d5cf2dd51cb70e7e0d
Parent:   a09cbed718d0fad0b27e4203c2c4c97a822e3ef4
Author:   gillux at soc.pidgin.im
Date:     05/12/12 13:45:43
Branch:   im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/dc9df5177b2708d8ccc884d5cf2dd51cb70e7e0d

Changelog: 

Added a "synchronized" flag to the PurpleObjects.
This aims to replace the "mirror mode" hack to something more
object-specific. With this, object setters shouldn't confuse
between local update of a property that aims to keep the object
synchronized, and a regular set that should be executed on the daemon.

Changes against parent a09cbed718d0fad0b27e4203c2c4c97a822e3ef4

  patched  libpurple/pobject.c
  patched  libpurple/pobject.h

-------------- next part --------------
============================================================
--- libpurple/pobject.c	556742176928e158eabd0c6fad27faa5de3d6a35
+++ libpurple/pobject.c	d4564b8ecb4f7399d3e4e2a5f42ff7b8844c12b3
@@ -55,6 +55,16 @@ struct _PurpleObjectPrivate
 	 * interface org.freedesktop.DBus.Properties. */
 	DBusGProxy *dbus_props_proxy;
 	char* dbus_path;
+	/* Whether this object is considered as synchronized or not.
+	 * This flag is used to decide whether this object must act as a proxy,
+	 * propagating local changes over D-Bus, or it must keep these private
+	 * because they are part of a synchronization. This avoids endless
+	 * notification loops between daemon and clients.
+	 * If this value is TRUE, then all the get/set of an object will go
+	 * This flag is initialized as FALSE by glib by zeroing the gobject
+	 * private struct, and thus will not mess with object construction and
+	 * properties initialization. */
+	gboolean dbus_synchronized;
 };
 
 enum
@@ -363,6 +373,26 @@ purple_object_set_dbus_path(PurpleObject
 	priv->dbus_path = g_strdup(path);
 }
 
+void
+purple_object_set_synchronized(PurpleObject *pobj, gboolean is_synced)
+{
+	PurpleObjectPrivate *priv;
+
+	g_return_if_fail(pobj);
+	priv = PURPLE_OBJECT_GET_PRIVATE(pobj);
+	priv->dbus_synchronized = is_synced;
+}
+
+gboolean
+purple_object_get_synchronized(PurpleObject *pobj)
+{
+	PurpleObjectPrivate *priv;
+
+	g_return_val_if_fail(pobj != NULL, FALSE);
+	priv = PURPLE_OBJECT_GET_PRIVATE(pobj);
+	return priv->dbus_synchronized;
+}
+
 GVariant *
 purple_object_get_dbus_property(PurpleObject *pobj, const gchar *prop_name)
 {
@@ -412,6 +442,7 @@ purple_object_set_dbus_property(PurpleOb
 	GDBusPropertyInfo *prop_info;
 	GValue gval = {0, };
 	GValue gval2 = {0, };
+	gboolean is_sync;
 
 	/* Check if such a named property exists. */
 	pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(pobj)),
============================================================
--- libpurple/pobject.h	c42d85c7dcc4af5edbaf65ec6b61e33bb3f6e58a
+++ libpurple/pobject.h	c1df6822f96a102774f63f4bae4f945cb7f0b6d4
@@ -188,6 +188,29 @@ void purple_object_set_dbus_path(PurpleO
 void purple_object_set_dbus_path(PurpleObject *pobj, char* path);
 
 /**
+ * Flag the object as synchronized. This is used by clients in detachable
+ * sessions context to make the get/set functions to be remotely set on the
+ * daemon objects (synched) or only on the client objects (not synched).
+ * It is initialized as FALSE, and thus will not mess with object construction
+ * and properties initialization. After the object is properly synchronized
+ * (i.e., constructed, most of the time), you must set it to TRUE yourself
+ * with this function.
+ *
+ * @param pobj The PurpleObject.
+ * @param is_synced Whether the object becomes synchronized or not.
+ */
+void purple_object_set_synchronized(PurpleObject *pobj, gboolean is_synced);
+
+/**
+ * Get the synchronized status of a PurpleObject.
+ * See purple_object_set_synchronized() for more informations.
+ *
+ * @param pobj The PurpleObject.
+ * @return TRUE if the object is marked as synchronized, FALSE otherwise.
+ */
+gboolean purple_object_get_synchronized(PurpleObject *pobj);
+
+/**
  * Binds the function func with the D-Bus method (in daemon context) or
  * D-Bus signal (in client context) named name. The parameters of the method
  * or sighandler will be as in the dbus_ifaceinfo field of the class (which is
@@ -243,8 +266,9 @@ GVariant *purple_object_get_dbus_propert
 /**
  * Sets a property exported on D-Bus. It's like directly setting the
  * property on the object, but it also check if the property is
- * exported on D-Bus and eventually converts dbus object names to
- * their object refereces.
+ * exported on D-Bus, eventually converts dbus object names to
+ * their object refereces, and avoid propagating the property change
+ * with a D-Bus signal.
  *
  * @param pobj The PurpleObject holding prop_name.
  * @param prop_name The property name held by pobj.


More information about the Commits mailing list