/srv/mercurial-server/detachablepurple: bde1ea59dcdb: Added a "s...
Gilles Bedel
gillux at cpw.pidgin.im
Fri Jun 15 22:01:32 EDT 2012
Changeset: bde1ea59dcdbf2f4320e7677769edbb0f81df4ca
Author: Gilles Bedel <gillux at cpw.pidgin.im>
Date: 2012-05-12 17:45 +0000
Branch: cpw.gillux.detachablepurple
URL: http://hg.pidgin.im/srv/mercurial-server/detachablepurple/rev/bde1ea59dcdb
Description:
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.
diffstat:
libpurple/pobject.c | 31 +++++++++++++++++++++++++++++++
libpurple/pobject.h | 28 ++++++++++++++++++++++++++--
2 files changed, 57 insertions(+), 2 deletions(-)
diffs (100 lines):
diff --git a/libpurple/pobject.c b/libpurple/pobject.c
--- a/libpurple/pobject.c
+++ b/libpurple/pobject.c
@@ -55,6 +55,16 @@
* 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 @@
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 @@
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)),
diff --git a/libpurple/pobject.h b/libpurple/pobject.h
--- a/libpurple/pobject.h
+++ b/libpurple/pobject.h
@@ -188,6 +188,29 @@
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 @@
/**
* 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