[telepathy-mission-control/master] McdClientRegistry: move watching for clients to be ready here

Simon McVittie simon.mcvittie at collabora.co.uk
Mon Oct 19 07:01:09 PDT 2009


---
 src/client-registry.c |   33 +++++++++++++++++++++++++++++++++
 src/mcd-dispatcher.c  |   37 -------------------------------------
 2 files changed, 33 insertions(+), 37 deletions(-)

diff --git a/src/client-registry.c b/src/client-registry.c
index d925a04..6645af2 100644
--- a/src/client-registry.c
+++ b/src/client-registry.c
@@ -103,6 +103,8 @@ _mcd_client_registry_dec_startup_lock (McdClientRegistry *self)
     }
 }
 
+static void mcd_client_registry_ready_cb (McdClientProxy *client,
+    McdClientRegistry *self);
 static void mcd_client_registry_gone_cb (McdClientProxy *client,
     McdClientRegistry *self);
 
@@ -124,6 +126,14 @@ _mcd_client_registry_add_new (McdClientRegistry *self,
     g_hash_table_insert (self->priv->clients, g_strdup (well_known_name),
         client);
 
+    /* paired with one in mcd_client_registry_ready_cb, when the
+     * McdClientProxy is ready */
+    _mcd_client_registry_inc_startup_lock (self);
+
+    g_signal_connect (client, "ready",
+                      G_CALLBACK (mcd_client_registry_ready_cb),
+                      self);
+
     g_signal_connect (client, "gone",
                       G_CALLBACK (mcd_client_registry_gone_cb),
                       self);
@@ -146,7 +156,17 @@ mcd_client_registry_disconnect_client_signals (gpointer k G_GNUC_UNUSED,
     gpointer v,
     gpointer data)
 {
+  g_signal_handlers_disconnect_by_func (v, mcd_client_registry_ready_cb, data);
   g_signal_handlers_disconnect_by_func (v, mcd_client_registry_gone_cb, data);
+
+  if (!_mcd_client_proxy_is_ready (v))
+    {
+      /* we'll never receive the ready signal now, so release the lock that
+       * it would otherwise have released */
+      DEBUG ("client %s disappeared before it became ready - treating it "
+             "as ready for our purposes", tp_proxy_get_bus_name (v));
+      mcd_client_registry_ready_cb (v, data);
+    }
 }
 
 static void
@@ -317,6 +337,19 @@ _mcd_client_registry_new (TpDBusDaemon *dbus_daemon)
 }
 
 static void
+mcd_client_registry_ready_cb (McdClientProxy *client,
+    McdClientRegistry *self)
+{
+  DEBUG ("%s", tp_proxy_get_bus_name (client));
+
+  g_signal_handlers_disconnect_by_func (client,
+      mcd_client_registry_ready_cb, self);
+
+  /* paired with the one in _mcd_client_registry_add_new */
+  _mcd_client_registry_dec_startup_lock (self);
+}
+
+static void
 mcd_client_registry_gone_cb (McdClientProxy *client,
     McdClientRegistry *self)
 {
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index e549792..347bcbb 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -1715,8 +1715,6 @@ mcd_dispatcher_client_capabilities_changed_cb (McdClientProxy *client,
     mcd_dispatcher_update_client_caps (self, client);
 }
 
-static void mcd_dispatcher_client_ready_cb (McdClientProxy *client,
-                                            McdDispatcher *dispatcher);
 static void mcd_dispatcher_client_gone_cb (McdClientProxy *client,
                                            McdDispatcher *self);
 
@@ -1731,21 +1729,8 @@ mcd_dispatcher_discard_client (McdDispatcher *self,
         mcd_dispatcher_client_handling_channel_cb, self);
 
     g_signal_handlers_disconnect_by_func (client,
-                                          mcd_dispatcher_client_ready_cb,
-                                          self);
-
-    g_signal_handlers_disconnect_by_func (client,
                                           mcd_dispatcher_client_gone_cb,
                                           self);
-
-    if (!_mcd_client_proxy_is_ready (client))
-    {
-        /* we'll never receive the ready signal now, so release the lock that
-         * it would otherwise have released */
-        DEBUG ("client %s disappeared before it became ready - treating it "
-               "as ready for our purposes", tp_proxy_get_bus_name (client));
-        mcd_dispatcher_client_ready_cb (client, self);
-    }
 }
 
 static void
@@ -1760,14 +1745,6 @@ mcd_dispatcher_client_added_cb (McdClientRegistry *clients,
                                 McdClientProxy *client,
                                 McdDispatcher *self)
 {
-    /* paired with one in mcd_dispatcher_client_ready_cb, when the
-     * McdClientProxy is ready */
-    _mcd_client_registry_inc_startup_lock (clients);
-
-    g_signal_connect (client, "ready",
-                      G_CALLBACK (mcd_dispatcher_client_ready_cb),
-                      self);
-
     g_signal_connect (client, "gone",
                       G_CALLBACK (mcd_dispatcher_client_gone_cb),
                       self);
@@ -1894,20 +1871,6 @@ mcd_dispatcher_update_client_caps (McdDispatcher *self,
     g_ptr_array_free (vas, TRUE);
 }
 
-static void
-mcd_dispatcher_client_ready_cb (McdClientProxy *client,
-                                McdDispatcher *dispatcher)
-{
-    DEBUG ("%s", tp_proxy_get_bus_name (client));
-
-    g_signal_handlers_disconnect_by_func (client,
-                                          mcd_dispatcher_client_ready_cb,
-                                          dispatcher);
-
-    /* paired with the one in mcd_dispatcher_client_added_cb */
-    _mcd_client_registry_dec_startup_lock (dispatcher->priv->clients);
-}
-
 /* Check the list of strings whether they are valid well-known names of
  * Telepathy clients and create McdClientProxy objects for each of them.
  */
-- 
1.5.6.5




More information about the telepathy-commits mailing list