[next] telepathy-glib: allow CMs to put 'TargetEntityType=None' in contact search requests

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Tue May 13 05:50:18 PDT 2014


Module: telepathy-glib
Branch: next
Commit: 3cb2d943e85b59ae2ef3872b9c745cb70384158a
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=3cb2d943e85b59ae2ef3872b9c745cb70384158a

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Tue May 13 11:45:19 2014 +0200

allow CMs to put 'TargetEntityType=None' in contact search requests

Fix https://bugs.freedesktop.org/show_bug.cgi?id=77030

---

 telepathy-glib/capabilities.c |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/telepathy-glib/capabilities.c b/telepathy-glib/capabilities.c
index 1181b47..cc5dc9f 100644
--- a/telepathy-glib/capabilities.c
+++ b/telepathy-glib/capabilities.c
@@ -910,17 +910,27 @@ tp_capabilities_supports_contact_search (TpCapabilities *self,
         &allowed_properties))
     {
       const gchar *chan_type;
-
-      /* ContactSearch channel should have ChannelType and TargetEntityType=NONE
-       * but CM implementations are wrong and omitted TargetEntityType,
-       * so it's set in stone now.  */
-      if (g_variant_n_children (fixed) != 1)
-        continue;
+      TpEntityType entity_type;
+      gboolean valid;
+      /* ChannelType is mandatory, TargetEntityType is optionnal */
+      guint nb_fixed_props = 1;
 
       chan_type = tp_vardict_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
       if (tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_CONTACT_SEARCH1))
         continue;
 
+      entity_type = tp_vardict_get_uint32 (fixed,
+          TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, &valid);
+      /* If TargetEntityType is missing we treat it as NONE */
+      if (valid && entity_type != TP_ENTITY_TYPE_NONE)
+        continue;
+
+      if (valid)
+        nb_fixed_props++;
+
+      if (g_variant_n_children (fixed) != nb_fixed_props)
+        continue;
+
       ret = TRUE;
 
       for (j = 0; allowed_properties[j] != NULL; j++)



More information about the telepathy-commits mailing list