[telepathy-mission-control/master] McdConnection: ignore NewChannel until we know whether we have Requests

Simon McVittie simon.mcvittie at collabora.co.uk
Tue May 19 04:42:47 PDT 2009


Before Requests became mandatory, this was a minor optimization and a
questionable correctness fix: MC could remember whether legacy channels
had Suppress_Handler or not, and avoided calling ListChannels.

Not calling ListChannels avoided accidentally dispatching old channels
which in fact had Suppress_Handler (before Requests, this information
couldn't be recovered) but potentially meant that we failed to dispatch
old undispatched channels that did not have Suppress_Handler, so we can't
really win.

Now that we expect all CMs to implement Requests, this code is just
confusing. Getting rid of it means that channels which appear before
the TpConnection is ready will cause crash-recovery code to be invoked,
altering the behaviour of one of the tests, so I've adjusted the test to
reflect this.

This does mean we'll potentially re-dispatch channels that are already
being handled by a handler that is not a Client, but as noted above, with
pre-Requests CMs we can't win anyway.
---
 src/mcd-connection.c                           |   35 +-----------------------
 test/twisted/dispatcher/already-has-channel.py |   17 +++++++++++
 2 files changed, 18 insertions(+), 34 deletions(-)

diff --git a/src/mcd-connection.c b/src/mcd-connection.c
index 7fa21f0..9601a49 100644
--- a/src/mcd-connection.c
+++ b/src/mcd-connection.c
@@ -489,23 +489,6 @@ on_new_channel (TpConnection *proxy, const gchar *chan_obj_path,
                                        g_list_prepend (NULL, channel),
                                        FALSE);
     }
-    else
-    {
-        /* create a void channel, but no TpProxy yet. Bundle the channel data,
-         * to be used later */
-        McdTmpChannelData *tcd;
-
-        channel = _mcd_channel_new_undispatched ();
-        tcd = g_slice_new (McdTmpChannelData);
-        tcd->object_path = g_strdup (chan_obj_path);
-        tcd->channel_type = g_strdup (chan_type);
-        tcd->handle = handle;
-        tcd->handle_type = handle_type;
-        g_object_set_data_full (G_OBJECT (channel), MCD_TMP_CHANNEL_DATA,
-                                tcd, mcd_tmp_channel_data_free);
-        mcd_operation_take_mission (MCD_OPERATION (connection),
-                                    MCD_MISSION (channel));
-    }
 }
 
 static void
@@ -1130,7 +1113,7 @@ on_new_channels (TpConnection *proxy, const GPtrArray *channels,
     }
 
     /* we can completely ignore the channels that arrive while can_dispatch is
-     * FALSE: the on_new_channel handler is already recording them */
+     * FALSE: they'll also be in Channels in the GetAll(Requests) result */
     if (!priv->can_dispatch) return;
 
     /* first, check if we have to dispatch the channels at all */
@@ -1210,7 +1193,6 @@ mcd_connection_found_channel (McdConnection *self,
     for (; list != NULL; list = list->next)
     {
         McdChannel *channel = MCD_CHANNEL (list->data);
-        McdTmpChannelData *tcd;
 
         if (g_strcmp0 (object_path,
                        mcd_channel_get_object_path (channel)) == 0)
@@ -1222,21 +1204,6 @@ mcd_connection_found_channel (McdConnection *self,
         if (mcd_channel_get_status (channel) !=
             MCD_CHANNEL_STATUS_UNDISPATCHED)
             continue;
-
-        tcd = g_object_get_data (G_OBJECT (channel), MCD_TMP_CHANNEL_DATA);
-        if (tcd && strcmp (tcd->object_path, object_path) == 0)
-        {
-            _mcd_channel_create_proxy (channel, self->priv->tp_conn,
-                                       object_path, channel_props);
-            g_object_set_data (G_OBJECT (channel), MCD_TMP_CHANNEL_DATA,
-                               NULL);
-            /* channel is ready for dispatching */
-            _mcd_dispatcher_take_channels (self->priv->dispatcher,
-                                           g_list_prepend (NULL, channel),
-                                           FALSE);
-            found = TRUE;
-            break;
-        }
     }
 
     if (!found)
diff --git a/test/twisted/dispatcher/already-has-channel.py b/test/twisted/dispatcher/already-has-channel.py
index 0983de8..0381c3a 100644
--- a/test/twisted/dispatcher/already-has-channel.py
+++ b/test/twisted/dispatcher/already-has-channel.py
@@ -96,6 +96,23 @@ def test(q, bus, mc):
                 path=conn.object_path, handled=True),
             )
 
+    # MC asks the clients whether they know anything about this channel
+    e, k = q.expect_many(
+            EventPattern('dbus-method-call',
+                path=empathy.object_path,
+                interface=cs.PROPERTIES_IFACE, method='Get',
+                args=[cs.HANDLER, 'HandledChannels'],
+                handled=False),
+            EventPattern('dbus-method-call',
+                path=kopete.object_path,
+                interface=cs.PROPERTIES_IFACE, method='Get',
+                args=[cs.HANDLER, 'HandledChannels'],
+                handled=False),
+            )
+    # they don't
+    q.dbus_return(e.message, dbus.Array([], signature='o'), signature='v')
+    q.dbus_return(k.message, dbus.Array([], signature='o'), signature='v')
+
     # A channel dispatch operation is created for the channel we already had
 
     e = q.expect('dbus-signal',
-- 
1.5.6.5




More information about the telepathy-commits mailing list