[telepathy-gabble/master] Guess missing content creators for broken Gabbles

Will Thompson will.thompson at collabora.co.uk
Thu Jun 18 11:10:29 PDT 2009


---
 src/jingle-session.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/src/jingle-session.c b/src/jingle-session.c
index 1380045..decc96e 100644
--- a/src/jingle-session.c
+++ b/src/jingle-session.c
@@ -38,6 +38,7 @@
  */
 #include "jingle-media-rtp.h"
 #include "namespaces.h"
+#include "presence-cache.h"
 #include "util.h"
 
 G_DEFINE_TYPE(GabbleJingleSession, gabble_jingle_session, G_TYPE_OBJECT);
@@ -591,7 +592,27 @@ lookup_content (GabbleJingleSession *sess,
     }
   else
     {
-      if (!tp_strdiff (creator, "initiator"))
+      /* Versions of Gabble between 0.7.16 and 0.7.28 (inclusive) omitted the
+       * 'creator' attribute from transport-info (and possibly other) stanzas.
+       * We try to detect contacts using such a version of Gabble from their
+       * caps; if 'creator' is missing and the peer has that caps flag, we look
+       * up the content in both hashes.
+       */
+      GabblePresence *presence = gabble_presence_cache_get (
+          priv->conn->presence_cache, sess->peer);
+
+      if (creator == NULL && presence != NULL &&
+          gabble_presence_resource_has_caps (presence, priv->peer_resource,
+              PRESENCE_CAP_JINGLE_OMITS_CONTENT_CREATOR))
+        {
+          DEBUG ("working around missing 'creator'");
+
+          *c = g_hash_table_lookup (priv->initiator_contents, name);
+
+          if (*c == NULL)
+            *c = g_hash_table_lookup (priv->responder_contents, name);
+        }
+      else if (!tp_strdiff (creator, "initiator"))
         {
           *c = g_hash_table_lookup (priv->initiator_contents, name);
         }
-- 
1.5.6.5




More information about the telepathy-commits mailing list