/srv/mercurial-server/detachablepurple: beafc3a013c9: Going mult...

Gilles Bedel gillux at cpw.pidgin.im
Fri Jun 15 22:01:41 EDT 2012


Changeset: beafc3a013c9f2858f15add63e2300cc132debaf
Author:	 Gilles Bedel <gillux at cpw.pidgin.im>
Date:	 2012-05-20 14:39 +0000
Branch:	 cpw.gillux.detachablepurple
URL: http://hg.pidgin.im/srv/mercurial-server/detachablepurple/rev/beafc3a013c9

Description:

Going multi-interface. Changed the way objects say they want their
property changes to be propagated on D-Bus. Now we already have the
PurpleObject D-Bus interface already registered, we only need to
register a "notify" gobject callback if objects want so.

diffstat:

 libpurple/account.c          |   4 ++--
 libpurple/connection.c       |   4 ++--
 libpurple/dbus/account.c     |   2 --
 libpurple/dbus/constructor.c |   6 ++++--
 libpurple/pobject.c          |  20 ++++++--------------
 libpurple/pobject.h          |  18 ++++++------------
 6 files changed, 20 insertions(+), 34 deletions(-)

diffs (141 lines):

diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -838,8 +838,8 @@
 
 	g_signal_emit_by_name(G_OBJECT(account), "new");
 
-	/* D-Bus-related initialization. */
-	purple_object_dbus_init(account);
+	/* Export this new object on D-Bus and propagate any property change. */
+	purple_object_dbus_init(account, TRUE);
 
 	return account;
 }
diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -232,8 +232,8 @@
 
 	priv->password = g_strdup(password);
 
-	/* D-Bus-related initialization. */
-	purple_object_dbus_init(gc);
+	/* Export this new object on D-Bus and propagate any property change. */
+	purple_object_dbus_init(gc, TRUE);
 
 	g_signal_emit(G_OBJECT(gc), signals[SIG_SIGNING_ON], 0);
 
diff --git a/libpurple/dbus/account.c b/libpurple/dbus/account.c
--- a/libpurple/dbus/account.c
+++ b/libpurple/dbus/account.c
@@ -173,8 +173,6 @@
 
 	/* Publish/listen for the object on the bus. */
 	purple_dbus_connect_object(account);
-	/* Keep the properties synchronized between client and daemon. */
-	purple_object_dbus_bind_notify(pobject);
 
 	if (purple_core_is_daemon_mode()) {
 		/* Tell the clients about this new account. */
diff --git a/libpurple/dbus/constructor.c b/libpurple/dbus/constructor.c
--- a/libpurple/dbus/constructor.c
+++ b/libpurple/dbus/constructor.c
@@ -259,7 +259,8 @@
 
 	pobject = PURPLE_OBJECT(obj);
 	purple_object_set_dbus_path(pobject, dbus_path);
-	purple_object_dbus_init(obj);
+	/* Note: we are in remote mode so the 2nd parameter doesn't matter. */
+	purple_object_dbus_init(obj, FALSE);
 
 	g_variant_unref(props);
 	g_free((gchar*)dbus_path);
@@ -359,7 +360,8 @@
 	purple_object_set_dbus_path(PURPLE_OBJECT(obj), dbus_path);
 	g_free((gchar*)dbus_path);
 
-	purple_object_dbus_init(obj);
+	/* Note: we are in remote mode so the 2nd parameter doesn't matter. */
+	purple_object_dbus_init(obj, FALSE);
 	purple_object_set_synchronized(PURPLE_OBJECT(obj), TRUE);
 }
 
diff --git a/libpurple/pobject.c b/libpurple/pobject.c
--- a/libpurple/pobject.c
+++ b/libpurple/pobject.c
@@ -722,19 +722,6 @@
 }
 
 void
-purple_object_dbus_bind_notify(PurpleObject *pobj)
-{
-	if (purple_core_is_remote_mode() || purple_core_is_mirror_mode()) {
-		purple_object_bind_dbus_callback
-		  (PURPLE_OBJECT_GET_CLASS(pobj), "PropertyChanged",
-		   G_CALLBACK(purple_object_dbus_prop_changed));
-	} else if (purple_core_is_daemon_mode())
-		g_signal_connect(pobj, "notify",
-		                 G_CALLBACK(purple_object_forward_notify_cb),
-		                 NULL);
-}
-
-void
 purple_object_bind_dbus_callback(PurpleObjectClass *klass,
                                  const char *iface_name, const char *cb_name,
                                  GCallback func)
@@ -1039,10 +1026,15 @@
 }
 
 void
-purple_object_dbus_init(gpointer object)
+purple_object_dbus_init(gpointer object, gboolean propagate_props_changes)
 {
 	PurpleObjectClass *pclass = PURPLE_OBJECT_GET_CLASS(object);
 
+	if (purple_core_is_daemon_mode() && propagate_props_changes)
+		g_signal_connect(object, "notify",
+		                 G_CALLBACK(purple_object_forward_notify_cb),
+		                 NULL);
+
 	if (pclass->dbus_init) {
 		pclass->dbus_init(object);
 	}
diff --git a/libpurple/pobject.h b/libpurple/pobject.h
--- a/libpurple/pobject.h
+++ b/libpurple/pobject.h
@@ -242,17 +242,6 @@
                                       GCallback          func);
 
 /**
- * Makes the relevant object properties changes to be transmitted over DBus.
- * "Relevant" properties are the one listed in the matching XML file of the
- * PurpleObject subclass, e.g. account.xml. In client context, it binds a
- * DBus signal handler that receives properties changes. In daemon context,
- * it propagates the properties changes with a DBus signal.
- *
- * @param pobj The PurpleObject we want to bind notifications for.
- */
-void purple_object_dbus_bind_notify(PurpleObject *pobj);
-
-/**
  * Gets the GClosure created to handle the call of the DBus method
  * (in dameon context) or signal handler (in client context) named name.
  *
@@ -428,10 +417,15 @@
 
 /**
  * Calls the dbus_init function pointer on a child of PurpleObject.
+ * Additionally, if propagate_props_changes is TRUE, registers a "notify"
+ * sighandler that propagates any property change of this object on D-Bus.
  *
  * @param object A child of PurpleObject.
+ * @param propagate_props_changes Wether to send D-Bus signals when a property
+ *        changes on daemon mode.
  */
-void purple_object_dbus_init(gpointer object);
+void purple_object_dbus_init(gpointer object,
+                             gboolean propagate_props_changes);
 
 /**
  * A convenience function that emits signal_name D-Bus signal on pobj



More information about the Commits mailing list