[Telepathy-commits] [telepathy-salut/master] SalutMucManager: initialise and release priv->queued_requests

Alban Crequy alban.crequy at collabora.co.uk
Thu Nov 27 10:07:56 PST 2008


---
 src/salut-muc-manager.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/src/salut-muc-manager.c b/src/salut-muc-manager.c
index d105e6b..0cda504 100644
--- a/src/salut-muc-manager.c
+++ b/src/salut-muc-manager.c
@@ -111,6 +111,9 @@ salut_muc_manager_init (SalutMucManager *obj)
   priv->tubes_channels = g_hash_table_new_full (g_direct_hash, g_direct_equal,
       NULL, g_object_unref);
 #endif
+
+  priv->queued_requests = g_hash_table_new_full (g_direct_hash,
+      g_direct_equal, NULL, NULL);
 }
 
 static void
@@ -166,6 +169,29 @@ closed_channel_foreach (TpHandle handle,
   salut_muc_channel_emit_closed (channel);
 }
 
+static gboolean
+cancel_queued_requests (gpointer k,
+                        gpointer v,
+                        gpointer d)
+{
+  SalutMucManager *self = SALUT_MUC_MANAGER (d);
+  GSList *requests_satisfied = v;
+  GSList *iter;
+
+  requests_satisfied = g_slist_reverse (requests_satisfied);
+
+  for (iter = requests_satisfied; iter != NULL; iter = iter->next)
+    {
+      tp_channel_manager_emit_request_failed (self,
+          iter->data, TP_ERRORS, TP_ERROR_DISCONNECTED,
+          "Unable to complete this channel request, we're disconnecting!");
+    }
+
+  g_slist_free (requests_satisfied);
+
+  return TRUE;
+}
+
 static void
 salut_muc_manager_close_all (SalutMucManager *self)
 {
@@ -179,6 +205,14 @@ salut_muc_manager_close_all (SalutMucManager *self)
       priv->status_changed_id = 0;
     }
 
+  if (priv->queued_requests != NULL)
+    {
+      g_hash_table_foreach_steal (priv->queued_requests,
+          cancel_queued_requests, self);
+      g_hash_table_destroy (priv->queued_requests);
+      priv->queued_requests = NULL;
+    }
+
   if (priv->text_channels)
     {
       GHashTable *tmp = priv->text_channels;
-- 
1.5.6.5




More information about the Telepathy-commits mailing list