[telepathy-mission-control/master] McdDispatcher: serialize calls to ListNames and ListActivatableNames

Simon McVittie simon.mcvittie at collabora.co.uk
Mon May 25 04:24:01 PDT 2009


They should both be happening "quickly", and forcing ListNames to complete
before ListActivatableNames completes means that we will deal with
clients that are both running and activatable as though they were
running (which involves a bit of extra processing).

Also rename new_names_cb to mcd_dispatcher_add_clients for clarity, and
eliminate an unnecessary g_strdup/g_free pair.
---
 src/mcd-dispatcher.c |   39 +++++++++++++++++++--------------------
 1 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 51f8063..aa0f42b 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -2273,9 +2273,9 @@ create_mcd_client (McdDispatcher *self,
  * Telepathy clients and create McdClient objects for each of them.
  */
 static void
-new_names_cb (McdDispatcher *self,
-              const gchar **names,
-              gboolean activatable)
+mcd_dispatcher_add_clients (McdDispatcher *self,
+                            const gchar **names,
+                            gboolean activatable)
 {
     McdDispatcherPrivate *priv = MCD_DISPATCHER_PRIV (self);
   
@@ -2321,7 +2321,7 @@ new_names_cb (McdDispatcher *self,
 }
 
 static void
-list_names_cb (TpDBusDaemon *proxy,
+list_activatable_names_cb (TpDBusDaemon *proxy,
     const gchar **out0,
     const GError *error,
     gpointer user_data,
@@ -2329,16 +2329,16 @@ list_names_cb (TpDBusDaemon *proxy,
 {
     McdDispatcher *self = MCD_DISPATCHER (weak_object);
 
-    DEBUG ("ListNames returned");
+    DEBUG ("ListActivatableNames returned");
 
-    new_names_cb (self, out0, FALSE);
+    mcd_dispatcher_add_clients (self, out0, TRUE);
 
-    /* paired with one of the two locks in _constructed */
+    /* paired with the lock taken in _constructed */
     mcd_dispatcher_release_startup_lock (self);
 }
 
 static void
-list_activatable_names_cb (TpDBusDaemon *proxy,
+list_names_cb (TpDBusDaemon *proxy,
     const gchar **out0,
     const GError *error,
     gpointer user_data,
@@ -2346,12 +2346,16 @@ list_activatable_names_cb (TpDBusDaemon *proxy,
 {
     McdDispatcher *self = MCD_DISPATCHER (weak_object);
 
-    DEBUG ("ListActivatableNames returned");
+    DEBUG ("ListNames returned");
 
-    new_names_cb (self, out0, TRUE);
+    mcd_dispatcher_add_clients (self, out0, FALSE);
 
-    /* paired with one of the two locks in _constructed */
-    mcd_dispatcher_release_startup_lock (self);
+    tp_cli_dbus_daemon_call_list_activatable_names (self->priv->dbus_daemon,
+        -1, list_activatable_names_cb, NULL, NULL, weak_object);
+    /* deliberately not calling mcd_dispatcher_release_startup_lock here -
+     * this function is "lock-neutral" (we would take a lock for
+     * ListActivatableNames then release the one used for ListNames),
+     * so simplify by doing nothing */
 }
 
 static void
@@ -2368,10 +2372,8 @@ name_owner_changed_cb (TpDBusDaemon *proxy,
     if (g_strcmp0 (arg1, "") == 0 && g_strcmp0 (arg2, "") != 0)
     {
         /* the name appeared on the bus */
-        gchar *names[2] = {NULL, NULL};
-        names[0] = g_strdup (arg0);
-        new_names_cb (self, (const gchar **) names, FALSE);
-        g_free (names[0]);
+        const gchar *names[2] = { arg0, NULL};
+        mcd_dispatcher_add_clients (self, (const gchar **) names, FALSE);
     }
     else if (g_strcmp0 (arg1, "") != 0 && g_strcmp0 (arg2, "") == 0)
     {
@@ -2418,14 +2420,11 @@ mcd_dispatcher_constructed (GObject *object)
 
     DEBUG ("Starting to look for clients");
     priv->startup_completed = FALSE;
-    priv->startup_lock = 2;   /* ListNames + ListActivatableNames */
+    priv->startup_lock = 1;   /* the ListNames call we're about to make */
 
     tp_cli_dbus_daemon_connect_to_name_owner_changed (priv->dbus_daemon,
         name_owner_changed_cb, NULL, NULL, object, NULL);
 
-    tp_cli_dbus_daemon_call_list_activatable_names (priv->dbus_daemon,
-        -1, list_activatable_names_cb, NULL, NULL, object);
-
     tp_cli_dbus_daemon_call_list_names (priv->dbus_daemon,
         -1, list_names_cb, NULL, NULL, object);
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list