diff options
author | Xavier Claessens <xavier.claessens@collabora.co.uk> | 2012-04-16 16:15:12 +0200 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.co.uk> | 2012-04-17 12:38:13 +0200 |
commit | bb1105761f7a42179a670485d3d910ba033e2ca9 (patch) | |
tree | 22bce043bedf34a77e4dc0466312a75ad9fcec34 /telepathy-glib/capabilities.c | |
parent | bb5d7690cb32a4caa7989de5ada684b0b91d5521 (diff) | |
download | telepathy-glib-bb1105761f7a42179a670485d3d910ba033e2ca9.tar.gz |
TpCapabilities: Verify fixed properties does not contain extra fields we don't understand
Diffstat (limited to 'telepathy-glib/capabilities.c')
-rw-r--r-- | telepathy-glib/capabilities.c | 83 |
1 files changed, 53 insertions, 30 deletions
diff --git a/telepathy-glib/capabilities.c b/telepathy-glib/capabilities.c index 2aafdd11c..c071bdf0b 100644 --- a/telepathy-glib/capabilities.c +++ b/telepathy-glib/capabilities.c @@ -456,6 +456,7 @@ supports_call_full (TpCapabilities *self, const gchar *chan_type; TpHandleType handle_type; gboolean valid; + guint nb_fixed_props = 2; tp_value_array_unpack (arr, 2, &fixed_prop, @@ -470,22 +471,39 @@ supports_call_full (TpCapabilities *self, if (!valid || handle_type != expected_handle_type) continue; - if (expected_initial_audio && - !tp_asv_get_boolean (fixed_prop, - TP_PROP_CHANNEL_TYPE_CALL_INITIAL_AUDIO, NULL) && - !tp_strv_contains (allowed_prop, - TP_PROP_CHANNEL_TYPE_CALL_INITIAL_AUDIO)) - continue; + if (expected_initial_audio) + { + /* We want audio, INITIAL_AUDIO must be in either fixed or allowed */ + if (tp_asv_get_boolean (fixed_prop, + TP_PROP_CHANNEL_TYPE_CALL_INITIAL_AUDIO, NULL)) + { + nb_fixed_props++; + } + else if (!tp_strv_contains (allowed_prop, + TP_PROP_CHANNEL_TYPE_CALL_INITIAL_AUDIO)) + { + continue; + } + } - if (expected_initial_video && - !tp_asv_get_boolean (fixed_prop, - TP_PROP_CHANNEL_TYPE_CALL_INITIAL_VIDEO, NULL) && - !tp_strv_contains (allowed_prop, - TP_PROP_CHANNEL_TYPE_CALL_INITIAL_VIDEO)) - continue; + if (expected_initial_video) + { + /* We want video, INITIAL_VIDEO must be in either fixed or allowed */ + if (tp_asv_get_boolean (fixed_prop, + TP_PROP_CHANNEL_TYPE_CALL_INITIAL_VIDEO, NULL)) + { + nb_fixed_props++; + } + else if (!tp_strv_contains (allowed_prop, + TP_PROP_CHANNEL_TYPE_CALL_INITIAL_VIDEO)) + { + continue; + } + } /* We found the right class */ - return TRUE; + if (g_hash_table_size (fixed_prop) == nb_fixed_props) + return TRUE; } return FALSE; @@ -577,35 +595,31 @@ tp_capabilities_supports_tubes_common (TpCapabilities *self, const gchar *chan_type; TpHandleType handle_type; gboolean valid; - const gchar *service; + guint nb_fixed_props = 2; fixed = g_value_get_boxed (g_value_array_get_nth (arr, 0)); chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE); - if (tp_strdiff (chan_type, expected_channel_type)) continue; handle_type = tp_asv_get_uint32 (fixed, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, &valid); - - if (!valid) - continue; - - if (handle_type != expected_handle_type) + if (!valid || handle_type != expected_handle_type) continue; - if (expected_service == NULL || !self->priv->contact_specific) - /* No need to check the service */ - return TRUE; - - service = tp_asv_get_string (fixed, service_prop); + if (expected_service != NULL && self->priv->contact_specific) + { + const gchar *service; - if (tp_strdiff (service, expected_service)) - continue; + nb_fixed_props++; + service = tp_asv_get_string (fixed, service_prop); + if (tp_strdiff (service, expected_service)) + continue; + } - /* We found the right service */ - return TRUE; + if (g_hash_table_size (fixed) == nb_fixed_props) + return TRUE; } return FALSE; @@ -814,14 +828,23 @@ tp_capabilities_supports_room_list (TpCapabilities *self, GHashTable *fixed; const gchar *chan_type; const gchar **allowed_properties; + TpHandleType handle_type; + gboolean valid; tp_value_array_unpack (arr, 2, &fixed, &allowed_properties); - chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE); + if (g_hash_table_size (fixed) != 2) + continue; + chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE); if (tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_ROOM_LIST)) continue; + handle_type = tp_asv_get_uint32 (fixed, + TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, &valid); + if (!valid || handle_type != TP_HANDLE_TYPE_NONE) + continue; + result = TRUE; server = tp_strv_contains (allowed_properties, |