[telepathy-gabble/master] Add a cap for Gabbles that don't send creator=''

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


---
 src/capabilities.c |   48 +++++++++++++++++++++++++++++++++++++++++++++++-
 src/types.h        |    1 +
 2 files changed, 48 insertions(+), 1 deletions(-)

diff --git a/src/capabilities.c b/src/capabilities.c
index f814361..42453a1 100644
--- a/src/capabilities.c
+++ b/src/capabilities.c
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "capabilities.h"
 
+#include <stdlib.h>
 #include <string.h>
 
 #include <telepathy-glib/interfaces.h>
@@ -99,6 +100,46 @@ capabilities_get_features (GabblePresenceCapabilities caps,
   return features;
 }
 
+static gboolean
+omits_content_creators (LmMessageNode *identity)
+{
+  const gchar *name, *suffix;
+  gchar *end;
+  int ver;
+
+  if (tp_strdiff (identity->name, "identity"))
+    return FALSE;
+
+  name = lm_message_node_get_attribute (identity, "name");
+
+  if (name == NULL)
+    return FALSE;
+
+#define PREFIX "Telepathy Gabble 0.7."
+
+  if (!g_str_has_prefix (name, PREFIX))
+    return FALSE;
+
+  suffix = name + strlen (PREFIX);
+  ver = strtol (suffix, &end, 10);
+
+  if (*end != '\0')
+    return FALSE;
+
+  /* Gabble versions since 0.7.16 did not send the creator='' attribute for
+   * contents. The bug is fixed in 0.7.29.
+   */
+  if (ver >= 16 && ver < 29)
+    {
+      DEBUG ("contact is using '%s' which omits 'creator'", name);
+      return TRUE;
+    }
+  else
+    {
+      return FALSE;
+    }
+}
+
 GabblePresenceCapabilities
 capabilities_parse (LmMessageNode *query_result)
 {
@@ -110,7 +151,12 @@ capabilities_parse (LmMessageNode *query_result)
   for (child = query_result->children; NULL != child; child = child->next)
     {
       if (0 != strcmp (child->name, "feature"))
-        continue;
+        {
+          if (omits_content_creators (child))
+            ret |= PRESENCE_CAP_JINGLE_OMITS_CONTENT_CREATOR;
+
+          continue;
+        }
 
       var = lm_message_node_get_attribute (child, "var");
 
diff --git a/src/types.h b/src/types.h
index bb95394..f304401 100644
--- a/src/types.h
+++ b/src/types.h
@@ -76,6 +76,7 @@ typedef enum {
     PRESENCE_CAP_JINGLE_TRANSPORT_RAWUDP = 1 << 15,
     PRESENCE_CAP_GEOLOCATION = 1 << 16,
     PRESENCE_CAP_SI_FILE_TRANSFER = 1 << 17,
+    PRESENCE_CAP_JINGLE_OMITS_CONTENT_CREATOR = 1 << 18,
 } GabblePresenceCapabilities;
 
 G_END_DECLS
-- 
1.5.6.5




More information about the telepathy-commits mailing list