telepathy-gabble: GabbleMucFactory: announce tube channels individually

Simon McVittie smcv at kemper.freedesktop.org
Thu Sep 12 03:33:10 PDT 2013


Module: telepathy-gabble
Branch: master
Commit: 5fea368bffc42db3fbaaca4b48f86dd937aff239
URL:    http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=5fea368bffc42db3fbaaca4b48f86dd937aff239

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Tue Sep 10 19:49:06 2013 +0100

GabbleMucFactory: announce tube channels individually

tp_channel_manager_emit_new_channels() is deprecated, because
announcing bundles of related channels together seemed a nice idea, but
it turns out to be really difficult to deal with in practice.

We preserve the order in which we did things, as much as possible:
the text channel is announced (if it's going to be) before any of the
tubes.

Signed-off-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
Reviewed-by: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69194

---

 src/muc-factory.c |   35 +++++++++++++++--------------------
 1 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/src/muc-factory.c b/src/muc-factory.c
index 0f1dbcb..39f4685 100644
--- a/src/muc-factory.c
+++ b/src/muc-factory.c
@@ -266,56 +266,51 @@ muc_ready_cb (GabbleMucChannel *text_chan,
 {
   GabbleMucFactory *fac = GABBLE_MUC_FACTORY (data);
   GabbleMucFactoryPrivate *priv = fac->priv;
-  GHashTable *channels;
   TpBaseChannel *base = TP_BASE_CHANNEL (text_chan);
-
   GSList *requests_satisfied_text = NULL;
   GQueue *tube_channels;
 
   DEBUG ("text chan=%p", text_chan);
 
-  channels = g_hash_table_new_full (g_direct_hash, g_direct_equal,
-      NULL, (GDestroyNotify) g_slist_free);
-
   requests_satisfied_text = g_hash_table_lookup (
       priv->queued_requests, text_chan);
   g_hash_table_steal (priv->queued_requests, text_chan);
   requests_satisfied_text = g_slist_reverse (requests_satisfied_text);
 
+  /* only announce channels which are on the bus (requested or
+   * requested with an invite, not channels only around because they
+   * have to be) */
+  if (tp_base_channel_is_registered (base))
+    {
+      tp_channel_manager_emit_new_channel (fac,
+          TP_EXPORTABLE_CHANNEL (text_chan), requests_satisfied_text);
+    }
+
   /* Announce tube channels now */
   tube_channels = g_hash_table_lookup (priv->text_needed_for_tube, text_chan);
+
   if (tube_channels != NULL)
     {
       GList *l;
 
       for (l = tube_channels->head; l != NULL; l = l->next)
         {
-          GabbleTubeIface *tube_chan = GABBLE_TUBE_IFACE (l->data);
+          TpExportableChannel *tube_chan = TP_EXPORTABLE_CHANNEL (l->data);
           GSList *requests_satisfied_tube;
 
           requests_satisfied_tube = g_hash_table_lookup (
               priv->queued_requests, tube_chan);
           g_hash_table_steal (priv->queued_requests, tube_chan);
+
           requests_satisfied_tube = g_slist_reverse (requests_satisfied_tube);
 
-          g_hash_table_insert (channels, tube_chan, requests_satisfied_tube);
+          tp_channel_manager_emit_new_channel (fac, tube_chan,
+              requests_satisfied_tube);
+          g_slist_free (requests_satisfied_tube);
         }
 
       g_hash_table_remove (priv->text_needed_for_tube, text_chan);
     }
-
-  /* only announce channels which are on the bus (requested or
-   * requested with an invite, not channels only around because they
-   * have to be) */
-  if (tp_base_channel_is_registered (base))
-    {
-      tp_channel_manager_emit_new_channel (fac,
-          TP_EXPORTABLE_CHANNEL (text_chan), requests_satisfied_text);
-    }
-
-  tp_channel_manager_emit_new_channels (fac, channels);
-
-  g_hash_table_unref (channels);
 }
 
 static void



More information about the telepathy-commits mailing list