From 3455dd0f87a3746404e0a0cf2069116991e2526e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 10 Sep 2013 19:49:06 +0100 Subject: [PATCH 2/3] 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. --- src/muc-factory.c | 35 +++++++++++++++-------------------- 1 file 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 -- 1.8.4.rc3