[telepathy-gabble/telepathy-gabble-0.8] util: allow GabbleConnection to be NULL in _normalize_room

Jonny Lamb jonny.lamb at collabora.co.uk
Mon Dec 7 04:13:00 PST 2009


The handle test, test-handles, has no connection, but calls this
function.

Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
 src/util.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/util.c b/src/util.c
index d5308d9..c839b24 100644
--- a/src/util.c
+++ b/src/util.c
@@ -601,18 +601,28 @@ gabble_normalize_room (TpHandleRepoIface *repo,
                        gpointer context,
                        GError **error)
 {
-  GabbleConnection *conn = GABBLE_CONNECTION (context);
+  GabbleConnection *conn;
   gchar *qualified_name, *resource;
 
-  qualified_name = gabble_connection_get_canonical_room_name (conn, jid);
+  /* Only look up the canonical room name if we got a GabbleConnection.
+   * This should only happen in the test-handles test. */
+  if (context != NULL)
+    {
+      conn = GABBLE_CONNECTION (context);
+      qualified_name = gabble_connection_get_canonical_room_name (conn, jid);
 
-  if (qualified_name == NULL)
+      if (qualified_name == NULL)
+        {
+          INVALID_HANDLE (error,
+              "requested room handle %s does not specify a server, but we "
+              "have not discovered any local conference servers and no "
+              "fallback was provided", jid);
+          return NULL;
+        }
+    }
+  else
     {
-      INVALID_HANDLE (error,
-          "requested room handle %s does not specify a server, but we "
-          "have not discovered any local conference servers and no "
-          "fallback was provided", jid);
-      return NULL;
+      qualified_name = g_strdup (jid);
     }
 
   if (!gabble_decode_jid (qualified_name, NULL, NULL, &resource))
-- 
1.5.6.5




More information about the telepathy-commits mailing list