[Telepathy-commits] [telepathy-mission-control/master] Create a DO on new unrequested channels

Alberto Mardegan alberto.mardegan at nokia.com
Mon Nov 3 00:28:06 PST 2008


When the NewChannels signal is emitted for unrequested channels, create a
DispatchOperation and dispatch all the channels together.
---
 src/mcd-connection.c |   19 +++++++++++++++----
 src/mcd-dispatcher.c |   18 ++++++++++--------
 2 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/src/mcd-connection.c b/src/mcd-connection.c
index 96c0b9f..a0ee2c0 100644
--- a/src/mcd-connection.c
+++ b/src/mcd-connection.c
@@ -1304,14 +1304,14 @@ on_new_channels (TpConnection *proxy, const GPtrArray *channels,
     McdConnection *connection = MCD_CONNECTION (weak_object);
     McdConnectionPrivate *priv = user_data;
     McdChannel *channel;
+    GList *channel_list = NULL;
+    gboolean requested = FALSE;
     guint i;
 
     /* we can completely ignore the channels that arrive while can_dispatch is
      * FALSE: the on_new_channel handler is already recording them */
     if (!priv->can_dispatch) return;
 
-    /* For the time being, dispatch each channel separately.
-     * TODO: these channels should be dispatched together */
     for (i = 0; i < channels->len; i++)
     {
         GValueArray *va;
@@ -1327,7 +1327,13 @@ on_new_channels (TpConnection *proxy, const GPtrArray *channels,
         /* Don't do anything for requested channels */
         value = g_hash_table_lookup (props, TP_IFACE_CHANNEL ".Requested");
         if (value && g_value_get_boolean (value))
+        {
+            requested = TRUE;
+            /* FIXME: once the CMs emit this signal _after_ having returned
+             * from CreateChannel(), we can handle requested channels here,
+             * too. */
             continue;
+        }
 
         /* get channel type, handle type, handle */
         value = g_hash_table_lookup (props, TP_IFACE_CHANNEL ".ChannelType");
@@ -1352,9 +1358,14 @@ on_new_channels (TpConnection *proxy, const GPtrArray *channels,
         mcd_operation_take_mission (MCD_OPERATION (connection),
                                     MCD_MISSION (channel));
 
-        /* Dispatch the incoming channel */
-        mcd_dispatcher_send (priv->dispatcher, channel);
+        channel_list = g_list_prepend (channel_list, channel);
     }
+
+    /* FIXME: once the CMs emit this signal _after_ having returned from
+     * CreateChannel(), we can handle requested channels here, too. */
+    if (requested) return;
+
+    _mcd_dispatcher_send_channels (priv->dispatcher, channel_list, requested);
 }
 
 static void get_all_requests_cb (TpProxy *proxy, GHashTable *properties,
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 41cc939..f7901fa 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -68,6 +68,7 @@ struct _McdDispatcherContext
 
     GList *channels;
     McdChannel *main_channel;
+    McdDispatchOperation *operation;
 
     gchar *protocol;
 
@@ -1205,6 +1206,9 @@ _mcd_dispatcher_enter_state_machine (McdDispatcher *dispatcher,
     context->dispatcher = dispatcher;
     context->channels = channels;
     context->chain = chain;
+    if (!requested)
+        context->operation =
+            _mcd_dispatch_operation_new (priv->dbus_daemon, channels);
 
     for (list = channels; list != NULL; list = list->next)
     {
@@ -1837,7 +1841,11 @@ mcd_dispatcher_context_unref (McdDispatcherContext * context)
                 G_CALLBACK (on_channel_abort_context), context);
             g_object_unref (channel);
         }
-        g_list_free (context->channels);
+        /* disposing the dispatch operation also frees the channels list */
+        if (context->operation)
+            g_object_unref (context->operation);
+        else
+            g_list_free (context->channels);
 
         g_free (context->protocol);
         g_free (context);
@@ -2146,12 +2154,6 @@ void
 _mcd_dispatcher_send_channels (McdDispatcher *dispatcher, GList *channels,
                                gboolean requested)
 {
-    McdDispatcherPrivate *priv = dispatcher->priv;
-    McdDispatchOperation *operation;
-
-    if (!requested)
-        operation = _mcd_dispatch_operation_new (priv->dbus_daemon, channels);
-    else
-        operation = NULL;
+    _mcd_dispatcher_enter_state_machine (dispatcher, channels, requested);
 }
 
-- 
1.5.6.5




More information about the Telepathy-commits mailing list