[telepathy-gabble/master] Return success from RequestStreams(h, [])

Will Thompson will.thompson at collabora.co.uk
Tue Jun 23 03:20:25 PDT 2009


If a UI requested a list of no streams, the pending_stream_request would
never terminate, as it would be waiting for the "new-content" signal
forever.

This patch moves the special handling of a request for no streams out of
_request_initial_streams() into _request_streams().
---
 src/media-channel.c |   50 +++++++++++++++++++++++++-------------------------
 1 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/src/media-channel.c b/src/media-channel.c
index bdd4b4e..231c3c3 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -1894,6 +1894,17 @@ media_channel_request_streams (GabbleMediaChannel *self,
   PendingStreamRequest *psr;
   GError *error = NULL;
 
+  if (types->len == 0)
+    {
+      GPtrArray *empty = g_ptr_array_sized_new (0);
+
+      DEBUG ("no streams to request");
+      succeeded_cb (context, empty);
+      g_ptr_array_free (empty, TRUE);
+
+      return;
+    }
+
   /* If we know the caps haven't arrived yet, delay stream creation
    * and check again later. Else, give up. */
   if (!contact_is_media_capable (self, contact_handle, &wait, &error))
@@ -1967,6 +1978,7 @@ gabble_media_channel_request_streams (TpSvcChannelTypeStreamedMedia *iface,
       DEBUG ("that's not a handle, sonny! (%u)", contact_handle);
       dbus_g_method_return_error (context, error);
       g_error_free (error);
+      return;
     }
   else
     {
@@ -1998,6 +2010,8 @@ gabble_media_channel_request_initial_streams (GabbleMediaChannel *chan,
     gpointer user_data)
 {
   GabbleMediaChannelPrivate *priv = chan->priv;
+  GArray *types = g_array_sized_new (FALSE, FALSE, sizeof (guint), 2);
+  guint media_type;
 
   /* This has to be an outgoing call... */
   g_assert (priv->creator == priv->conn->parent.self_handle);
@@ -2013,36 +2027,22 @@ gabble_media_channel_request_initial_streams (GabbleMediaChannel *chan,
       g_assert (!priv->initial_video);
     }
 
-  if (!priv->initial_audio && !priv->initial_video)
+  if (priv->initial_audio)
     {
-      GPtrArray *empty = g_ptr_array_sized_new (0);
-
-      succeeded_cb (user_data, empty);
-
-      g_ptr_array_free (empty, TRUE);
+      media_type = TP_MEDIA_STREAM_TYPE_AUDIO;
+      g_array_append_val (types, media_type);
     }
-  else
-    {
-      GArray *types = g_array_sized_new (FALSE, FALSE, sizeof (guint), 2);
-      guint media_type;
-
-      if (priv->initial_audio)
-        {
-          media_type = TP_MEDIA_STREAM_TYPE_AUDIO;
-          g_array_append_val (types, media_type);
-        }
 
-      if (priv->initial_video)
-        {
-          media_type = TP_MEDIA_STREAM_TYPE_VIDEO;
-          g_array_append_val (types, media_type);
-        }
+  if (priv->initial_video)
+    {
+      media_type = TP_MEDIA_STREAM_TYPE_VIDEO;
+      g_array_append_val (types, media_type);
+    }
 
-      media_channel_request_streams (chan, priv->initial_peer, types,
-          succeeded_cb, failed_cb, user_data);
+  media_channel_request_streams (chan, priv->initial_peer, types,
+      succeeded_cb, failed_cb, user_data);
 
-      g_array_free (types, TRUE);
-    }
+  g_array_free (types, TRUE);
 }
 
 static gboolean
-- 
1.5.6.5




More information about the telepathy-commits mailing list