[telepathy-mission-control/master] McdClientProxy: move the beginning of the Client introspection chain here

Simon McVittie simon.mcvittie at collabora.co.uk
Wed Sep 23 10:58:09 PDT 2009


---
 src/mcd-client.c     |   58 +++++++++++++++++++++++++++++++++++---------
 src/mcd-dispatcher.c |   65 --------------------------------------------------
 2 files changed, 46 insertions(+), 77 deletions(-)

diff --git a/src/mcd-client.c b/src/mcd-client.c
index d40c303..2a6b1cd 100644
--- a/src/mcd-client.c
+++ b/src/mcd-client.c
@@ -51,7 +51,6 @@ enum
 enum
 {
     S_READY,
-    S_UNIQUE_NAME_KNOWN,
     S_IS_HANDLING_CHANNEL,
     S_HANDLER_CAPABILITIES_CHANGED,
     N_SIGNALS
@@ -787,14 +786,56 @@ static gboolean
 mcd_client_proxy_introspect (gpointer data)
 {
     McdClientProxy *self = data;
+    const gchar *bus_name = tp_proxy_get_bus_name (self);
+
+    if (self->priv->introspect_started)
+    {
+        return FALSE;
+    }
+
+    self->priv->introspect_started = TRUE;
 
-    if (!self->priv->introspect_started)
+    /* The .client file is not mandatory as per the spec. However if it
+     * exists, it is better to read it than activating the service to read the
+     * D-Bus properties.
+     */
+    if (!_mcd_client_proxy_parse_client_file (self))
     {
-        self->priv->introspect_started = TRUE;
-        g_signal_emit (self, signals[S_UNIQUE_NAME_KNOWN], 0);
-        _mcd_client_proxy_dec_ready_lock (self);
+        DEBUG ("No .client file for %s. Ask on D-Bus.", bus_name);
+
+        _mcd_client_proxy_inc_ready_lock (self);
+
+        tp_cli_dbus_properties_call_get (self, -1,
+            TP_IFACE_CLIENT, "Interfaces", _mcd_client_proxy_get_interfaces_cb,
+            NULL, NULL, NULL);
+    }
+    else
+    {
+        if (tp_proxy_has_interface_by_id (self, TP_IFACE_QUARK_CLIENT_HANDLER))
+        {
+            if (_mcd_client_proxy_is_active (self))
+            {
+                DEBUG ("%s is an active, activatable Handler", bus_name);
+
+                /* We need to investigate whether it is handling any channels */
+
+                _mcd_client_proxy_inc_ready_lock (self);
+
+                tp_cli_dbus_properties_call_get_all (self, -1,
+                    TP_IFACE_CLIENT_HANDLER,
+                    _mcd_client_proxy_handler_get_all_cb,
+                    NULL, NULL, NULL);
+            }
+            else
+            {
+                DEBUG ("%s is a Handler but not active", bus_name);
+                g_signal_emit (self,
+                               signals[S_HANDLER_CAPABILITIES_CHANGED], 0);
+            }
+        }
     }
 
+    _mcd_client_proxy_dec_ready_lock (self);
     return FALSE;
 }
 
@@ -941,13 +982,6 @@ _mcd_client_proxy_class_init (McdClientProxyClass *klass)
     object_class->finalize = mcd_client_proxy_finalize;
     object_class->set_property = mcd_client_proxy_set_property;
 
-    signals[S_UNIQUE_NAME_KNOWN] = g_signal_new ("unique-name-known",
-        G_OBJECT_CLASS_TYPE (klass),
-        G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
-        0, NULL, NULL,
-        g_cclosure_marshal_VOID__VOID,
-        G_TYPE_NONE, 0);
-
     signals[S_READY] = g_signal_new ("ready",
         G_OBJECT_CLASS_TYPE (klass),
         G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index d4b4189..be1b2f0 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -1737,9 +1737,6 @@ mcd_dispatcher_client_capabilities_changed_cb (McdClientProxy *client,
     }
 }
 
-static void mcd_client_start_introspection (McdClientProxy *client,
-                                            McdDispatcher *dispatcher);
-
 static void mcd_dispatcher_client_ready_cb (McdClientProxy *client,
                                             McdDispatcher *dispatcher);
 
@@ -1748,10 +1745,6 @@ mcd_dispatcher_discard_client (McdDispatcher *self,
                                McdClientProxy *client)
 {
     g_signal_handlers_disconnect_by_func (client,
-                                          mcd_client_start_introspection,
-                                          self);
-
-    g_signal_handlers_disconnect_by_func (client,
         mcd_dispatcher_client_capabilities_changed_cb, self);
 
     g_signal_handlers_disconnect_by_func (client,
@@ -1897,60 +1890,6 @@ mcd_dispatcher_update_client_caps (McdDispatcher *self,
     g_ptr_array_free (vas, TRUE);
 }
 
-/* FIXME: eventually this whole chain should move into McdClientProxy */
-static void
-mcd_client_start_introspection (McdClientProxy *client,
-                                McdDispatcher *dispatcher)
-{
-    gboolean file_found;
-    const gchar *bus_name = tp_proxy_get_bus_name (client);
-
-    g_signal_handlers_disconnect_by_func (client,
-                                          mcd_client_start_introspection,
-                                          dispatcher);
-
-    /* The .client file is not mandatory as per the spec. However if it
-     * exists, it is better to read it than activating the service to read the
-     * D-Bus properties.
-     */
-    file_found = _mcd_client_proxy_parse_client_file (client);
-
-    if (!file_found)
-    {
-        DEBUG ("No .client file for %s. Ask on D-Bus.", bus_name);
-
-        _mcd_client_proxy_inc_ready_lock (client);
-
-        tp_cli_dbus_properties_call_get (client, -1,
-            TP_IFACE_CLIENT, "Interfaces", _mcd_client_proxy_get_interfaces_cb,
-            NULL, NULL, NULL);
-    }
-    else
-    {
-        if (tp_proxy_has_interface_by_id (client, TP_IFACE_QUARK_CLIENT_HANDLER))
-        {
-            if (_mcd_client_proxy_is_active (client))
-            {
-                DEBUG ("%s is an active, activatable Handler", bus_name);
-
-                /* We need to investigate whether it is handling any channels */
-
-                _mcd_client_proxy_inc_ready_lock (client);
-
-                tp_cli_dbus_properties_call_get_all (client, -1,
-                    TP_IFACE_CLIENT_HANDLER,
-                    _mcd_client_proxy_handler_get_all_cb,
-                    NULL, NULL, NULL);
-            }
-            else
-            {
-                DEBUG ("%s is a Handler but not active", bus_name);
-                mcd_dispatcher_update_client_caps (dispatcher, client);
-            }
-        }
-    }
-}
-
 static void
 mcd_dispatcher_client_ready_cb (McdClientProxy *client,
                                 McdDispatcher *dispatcher)
@@ -2036,10 +1975,6 @@ mcd_dispatcher_add_client (McdDispatcher *self,
     g_signal_connect (client, "handler-capabilities-changed",
                       G_CALLBACK (mcd_dispatcher_client_capabilities_changed_cb),
                       self);
-
-    g_signal_connect (client, "unique-name-known",
-                      G_CALLBACK (mcd_client_start_introspection),
-                      self);
 }
 
 static void
-- 
1.5.6.5




More information about the telepathy-commits mailing list