summaryrefslogtreecommitdiff
path: root/telepathy-glib
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.co.uk>2012-06-08 16:28:49 +0200
committerXavier Claessens <xavier.claessens@collabora.co.uk>2012-09-11 10:35:34 +0200
commit6555f449c4b6490f08d7b2c8c523faa4c542b89d (patch)
treede9f7fcf40440551266b86239501a3dc5dbfc81f /telepathy-glib
parent0e224c223a3a78f20c3b940129c7bba84f815f6d (diff)
downloadtelepathy-glib-6555f449c4b6490f08d7b2c8c523faa4c542b89d.tar.gz
TpContact: do not override properties with attributes we didn't request
We check wanted flags for everything but States and Groups, there is no reason for that. Besides, if we did not request those attributes, there are chances we didn't bind to change notification neither.
Diffstat (limited to 'telepathy-glib')
-rw-r--r--telepathy-glib/connection-contact-list.c5
-rw-r--r--telepathy-glib/contact.c61
2 files changed, 39 insertions, 27 deletions
diff --git a/telepathy-glib/connection-contact-list.c b/telepathy-glib/connection-contact-list.c
index 9e59af2d4..4d53dfe7f 100644
--- a/telepathy-glib/connection-contact-list.c
+++ b/telepathy-glib/connection-contact-list.c
@@ -294,6 +294,7 @@ static void
prepare_roster (TpConnection *self,
GSimpleAsyncResult *result)
{
+ TpContactFeature feature_states = TP_CONTACT_FEATURE_SUBSCRIPTION_STATES;
GArray *features;
const gchar **supported_interfaces;
@@ -306,6 +307,10 @@ prepare_roster (TpConnection *self,
features = tp_simple_client_factory_dup_contact_features (
tp_proxy_get_factory (self), self);
+ /* We'll get subscription states for free, but we still need to tell
+ * TpContact to bind to change notification. */
+ g_array_append_val (features, feature_states);
+
supported_interfaces = _tp_contacts_bind_to_signals (self, features->len,
(TpContactFeature *) features->data);
diff --git a/telepathy-glib/contact.c b/telepathy-glib/contact.c
index ea2c178a7..988be1120 100644
--- a/telepathy-glib/contact.c
+++ b/telepathy-glib/contact.c
@@ -3649,6 +3649,7 @@ tp_contact_set_attributes (TpContact *contact,
const gchar *s;
gpointer boxed;
+ /* Identifier */
s = tp_asv_get_string (asv, TP_TOKEN_CONNECTION_CONTACT_ID);
if (s == NULL)
@@ -3676,7 +3677,7 @@ tp_contact_set_attributes (TpContact *contact,
return FALSE;
}
-
+ /* Alias */
if (wanted & CONTACT_FEATURE_FLAG_ALIAS)
{
s = tp_asv_get_string (asv,
@@ -3697,6 +3698,7 @@ tp_contact_set_attributes (TpContact *contact,
}
}
+ /* Avatar */
if (wanted & CONTACT_FEATURE_FLAG_AVATAR_TOKEN)
{
s = tp_asv_get_string (asv,
@@ -3711,6 +3713,7 @@ tp_contact_set_attributes (TpContact *contact,
contact_maybe_update_avatar_data (contact);
}
+ /* Presence */
if (wanted & CONTACT_FEATURE_FLAG_PRESENCE)
{
boxed = tp_asv_get_boxed (asv,
@@ -3764,34 +3767,38 @@ tp_contact_set_attributes (TpContact *contact,
}
/* ContactList subscription states */
- {
- TpSubscriptionState subscribe;
- TpSubscriptionState publish;
- const gchar *publish_request;
- gboolean subscribe_valid = FALSE;
- gboolean publish_valid = FALSE;
-
- subscribe = tp_asv_get_uint32 (asv,
- TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST_SUBSCRIBE,
- &subscribe_valid);
- publish = tp_asv_get_uint32 (asv,
- TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST_PUBLISH,
- &publish_valid);
- publish_request = tp_asv_get_string (asv,
- TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST_PUBLISH_REQUEST);
-
- if (subscribe_valid && publish_valid)
- {
- contact_set_subscription_states (contact, subscribe, publish,
- publish_request);
- }
- }
+ if (wanted & CONTACT_FEATURE_FLAG_STATES)
+ {
+ TpSubscriptionState subscribe;
+ TpSubscriptionState publish;
+ const gchar *publish_request;
+ gboolean subscribe_valid = FALSE;
+ gboolean publish_valid = FALSE;
+
+ subscribe = tp_asv_get_uint32 (asv,
+ TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST_SUBSCRIBE,
+ &subscribe_valid);
+ publish = tp_asv_get_uint32 (asv,
+ TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST_PUBLISH,
+ &publish_valid);
+ publish_request = tp_asv_get_string (asv,
+ TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST_PUBLISH_REQUEST);
+
+ if (subscribe_valid && publish_valid)
+ {
+ contact_set_subscription_states (contact, subscribe, publish,
+ publish_request);
+ }
+ }
/* ContactGroups */
- boxed = tp_asv_get_boxed (asv,
- TP_TOKEN_CONNECTION_INTERFACE_CONTACT_GROUPS_GROUPS,
- G_TYPE_STRV);
- contact_maybe_set_contact_groups (contact, boxed);
+ if (wanted & CONTACT_FEATURE_FLAG_CONTACT_GROUPS)
+ {
+ boxed = tp_asv_get_boxed (asv,
+ TP_TOKEN_CONNECTION_INTERFACE_CONTACT_GROUPS_GROUPS,
+ G_TYPE_STRV);
+ contact_maybe_set_contact_groups (contact, boxed);
+ }
/* ContactBlocking */
if (wanted & CONTACT_FEATURE_FLAG_CONTACT_BLOCKING)