[telepathy-gabble/master] Extract sending more disco requests to a function

Will Thompson will.thompson at collabora.co.uk
Wed May 6 09:17:51 PDT 2009


---
 src/presence-cache.c |   42 ++++++++++++++++++++----------------------
 1 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/src/presence-cache.c b/src/presence-cache.c
index 27a28e1..54e216b 100644
--- a/src/presence-cache.c
+++ b/src/presence-cache.c
@@ -831,6 +831,24 @@ static void _caps_disco_cb (GabbleDisco *disco,
     gpointer user_data);
 
 static void
+redisco (GabblePresenceCache *cache,
+    GabbleDisco *disco,
+    DiscoWaiter *waiter,
+    const gchar *node,
+    TpHandleRepoIface *contact_repo)
+{
+  const gchar *waiter_jid;
+  gchar *full_jid;
+
+  waiter_jid = tp_handle_inspect (contact_repo, waiter->handle);
+  full_jid = g_strdup_printf ("%s/%s", waiter_jid, waiter->resource);
+
+  gabble_disco_request (disco, GABBLE_DISCO_TYPE_INFO, full_jid,
+      node, _caps_disco_cb, cache, G_OBJECT (cache), NULL);
+  waiter->disco_requested = TRUE;
+}
+
+static void
 disco_failed (GabblePresenceCache *cache,
     GabbleDisco *disco,
     const gchar *node,
@@ -848,14 +866,7 @@ disco_failed (GabblePresenceCache *cache,
 
       if (!waiter->disco_requested)
         {
-          const gchar *waiter_jid;
-
-          waiter_jid = tp_handle_inspect (contact_repo, waiter->handle);
-          full_jid = g_strdup_printf ("%s/%s", waiter_jid, waiter->resource);
-
-          gabble_disco_request (disco, GABBLE_DISCO_TYPE_INFO, full_jid,
-              node, _caps_disco_cb, cache, G_OBJECT(cache), NULL);
-          waiter->disco_requested = TRUE;
+          redisco (cache, disco, waiter, node, contact_repo);
           break;
         }
     }
@@ -1091,20 +1102,7 @@ _caps_disco_cb (GabbleDisco *disco,
            * anybody we still haven't to be able to get more trusted replies */
 
           if (!waiter->disco_requested)
-            {
-              const gchar *waiter_jid;
-
-              waiter_jid = tp_handle_inspect (contact_repo, waiter->handle);
-              full_jid = g_strdup_printf ("%s/%s", waiter_jid,
-                  waiter->resource);
-
-              gabble_disco_request (disco, GABBLE_DISCO_TYPE_INFO, full_jid,
-                  node, _caps_disco_cb, cache, G_OBJECT(cache), NULL);
-              waiter->disco_requested = TRUE;
-
-              g_free (full_jid);
-              full_jid = NULL;
-            }
+            redisco (cache, disco, waiter, node, contact_repo);
 
           i = i->next;
         }
-- 
1.5.6.5




More information about the telepathy-commits mailing list