From 23aa28f5e242496287f122d14f24717ea2d5e47e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 1 Oct 2013 16:25:49 +0100 Subject: [PATCH 1/4] tp_contact_set_attributes: don't warn on genuinely absent interfaces The warning message says something like "... supposedly implements Contacts and Aliasing" but we don't actually check that the connection claims to implement Aliasing (in either its ContactAttributeInterfaces or Interfaces). SimplePresence has the same bug. The Mission Control regression tests trigger this, since they include some simulated connections with small subsets of interfaces. --- telepathy-glib/contact.c | 80 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 15 deletions(-) diff --git a/telepathy-glib/contact.c b/telepathy-glib/contact.c index abf38ef..a145686 100644 --- a/telepathy-glib/contact.c +++ b/telepathy-glib/contact.c @@ -1644,9 +1644,13 @@ struct _ContactsContext { /* ID => GError, NULL unless we started from IDs */ GHashTable *request_errors; - /* features we need before this request can finish */ + /* features we need to get, if possible, before this request can finish */ ContactFeatureFlags wanted; + /* features we can expect to get from GetContactAttributes + * (subset of wanted) */ + ContactFeatureFlags getting; + /* callback for when we've finished, plus the usual misc */ ContactsSignature signature; union { @@ -3788,6 +3792,7 @@ static gboolean tp_contact_set_attributes (TpContact *contact, GHashTable *asv, ContactFeatureFlags wanted, + ContactFeatureFlags getting, GError **error) { TpConnection *connection = tp_contact_get_connection (contact); @@ -3830,9 +3835,12 @@ tp_contact_set_attributes (TpContact *contact, if (s == NULL) { - WARNING ("%s supposedly implements Contacts and Aliasing, but " - "omitted " TP_TOKEN_CONNECTION_INTERFACE_ALIASING_ALIAS, - tp_proxy_get_object_path (connection)); + if (getting & CONTACT_FEATURE_FLAG_ALIAS) + { + WARNING ("%s supposedly implements Contacts and Aliasing, but " + "omitted " TP_TOKEN_CONNECTION_INTERFACE_ALIASING_ALIAS, + tp_proxy_get_object_path (connection)); + } } else { @@ -3866,13 +3874,20 @@ tp_contact_set_attributes (TpContact *contact, TP_STRUCT_TYPE_SIMPLE_PRESENCE); if (boxed == NULL) - WARNING ("%s supposedly implements Contacts and SimplePresence, " - "but omitted the mandatory " - TP_TOKEN_CONNECTION_INTERFACE_SIMPLE_PRESENCE_PRESENCE - " attribute", - tp_proxy_get_object_path (connection)); + { + if (getting & CONTACT_FEATURE_FLAG_PRESENCE) + { + WARNING ("%s supposedly implements Contacts and SimplePresence, " + "but omitted the mandatory " + TP_TOKEN_CONNECTION_INTERFACE_SIMPLE_PRESENCE_PRESENCE + " attribute", + tp_proxy_get_object_path (connection)); + } + } else - contact_maybe_set_simple_presence (contact, boxed); + { + contact_maybe_set_simple_presence (contact, boxed); + } } /* Location */ @@ -3975,7 +3990,8 @@ _tp_contact_set_attributes (TpContact *contact, if (!get_feature_flags (n_features, features, &feature_flags)) return FALSE; - return tp_contact_set_attributes (contact, asv, feature_flags, error); + return tp_contact_set_attributes (contact, asv, feature_flags, + 0 /* can't know what we expected to get */, error); } static void @@ -4038,7 +4054,7 @@ contacts_got_attributes (TpConnection *connection, else { /* set up the contact with its attributes */ - tp_contact_set_attributes (contact, asv, c->wanted, &e); + tp_contact_set_attributes (contact, asv, c->wanted, c->getting, &e); } if (e != NULL) @@ -4054,7 +4070,8 @@ contacts_got_attributes (TpConnection *connection, static const gchar ** contacts_bind_to_signals (TpConnection *connection, - ContactFeatureFlags wanted) + ContactFeatureFlags wanted, + ContactFeatureFlags *getting) { GArray *contact_attribute_interfaces = connection->priv->contact_attribute_interfaces; @@ -4062,6 +4079,9 @@ contacts_bind_to_signals (TpConnection *connection, guint i; guint len = 0; + if (getting != NULL) + *getting = 0; + if (contact_attribute_interfaces != NULL) len = contact_attribute_interfaces->len; @@ -4081,6 +4101,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_ALIASING); contacts_bind_to_aliases_changed (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_ALIAS; } } else if (q == TP_IFACE_QUARK_CONNECTION_INTERFACE_AVATARS) @@ -4090,6 +4113,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_AVATARS); contacts_bind_to_avatar_updated (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_AVATAR_TOKEN; } if ((wanted & CONTACT_FEATURE_FLAG_AVATAR_DATA) != 0) @@ -4104,6 +4130,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE); contacts_bind_to_presences_changed (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_PRESENCE; } } else if (q == TP_IFACE_QUARK_CONNECTION_INTERFACE_LOCATION) @@ -4113,6 +4142,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_LOCATION); contacts_bind_to_location_updated (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_LOCATION; } } else if (q == TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_CAPABILITIES) @@ -4122,6 +4154,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES); contacts_bind_to_capabilities_updated (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_CAPABILITIES; } } else if (q == TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_INFO) @@ -4131,6 +4166,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO); contacts_bind_to_contact_info_changed (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_CONTACT_INFO; } } else if (q == TP_IFACE_QUARK_CONNECTION_INTERFACE_CLIENT_TYPES) @@ -4140,6 +4178,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_CLIENT_TYPES); contacts_bind_to_client_types_updated (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_CLIENT_TYPES; } } else if (q == TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_LIST) @@ -4149,6 +4190,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST); contacts_bind_to_contacts_changed (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_STATES; } } else if (q == TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_GROUPS) @@ -4158,6 +4202,9 @@ contacts_bind_to_signals (TpConnection *connection, g_ptr_array_add (array, TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS); contacts_bind_to_contact_groups_changed (connection); + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_CONTACT_GROUPS; } } else if (q == TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING) @@ -4178,6 +4225,9 @@ contacts_bind_to_signals (TpConnection *connection, { tp_proxy_prepare_async (connection, features, NULL, NULL); } + + if (getting != NULL) + *getting |= CONTACT_FEATURE_FLAG_CONTACT_BLOCKING; } } } @@ -4199,7 +4249,7 @@ _tp_contacts_bind_to_signals (TpConnection *connection, if (!get_feature_flags (n_features, features, &feature_flags)) return NULL; - return contacts_bind_to_signals (connection, feature_flags); + return contacts_bind_to_signals (connection, feature_flags, NULL); } static void @@ -4216,7 +4266,7 @@ contacts_get_attributes (ContactsContext *context) } supported_interfaces = contacts_bind_to_signals (context->connection, - context->wanted); + context->wanted, &context->getting); if (supported_interfaces[0] == NULL && !(context->signature == CB_BY_HANDLE && context->contacts->len == 0) && -- 1.8.4.rc3