From 1bb25d90a896e9b412c05a836b45f5fb679b9b28 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 13 May 2014 11:45:19 +0200 Subject: [PATCH] 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..7d4fb85 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 threat 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++) -- 1.9.0