diff options
author | Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> | 2011-06-09 21:57:14 +0800 |
---|---|---|
committer | Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> | 2011-06-10 16:03:32 +0800 |
commit | c5353cf8c819b549de202faa3326406f3638a899 (patch) | |
tree | c63053ced213eb4a6be8a6706ec41a3db4413bcf | |
parent | d74b660be9a8717615a01df58c3d7fa2a3d55bd0 (diff) | |
download | gsoc2013-empathy-c5353cf8c819b549de202faa3326406f3638a899.tar gsoc2013-empathy-c5353cf8c819b549de202faa3326406f3638a899.tar.gz gsoc2013-empathy-c5353cf8c819b549de202faa3326406f3638a899.tar.bz2 gsoc2013-empathy-c5353cf8c819b549de202faa3326406f3638a899.tar.lz gsoc2013-empathy-c5353cf8c819b549de202faa3326406f3638a899.tar.xz gsoc2013-empathy-c5353cf8c819b549de202faa3326406f3638a899.tar.zst gsoc2013-empathy-c5353cf8c819b549de202faa3326406f3638a899.zip |
empathy_contact_from_tpl_contact: check the accounts match
Two contacts may not be the same if only their ids match, so
also check the accounts.
This was causing us to return the same contact from another
account, which would cause "is-user" to not be properly set,
confusing the log viewer.
-rw-r--r-- | libempathy/empathy-contact.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c index 7c66a28f8..8cca70944 100644 --- a/libempathy/empathy-contact.c +++ b/libempathy/empathy-contact.c @@ -652,16 +652,25 @@ empathy_contact_new (TpContact *tp_contact) return retval; } +typedef struct +{ + TplEntity *entity; + TpAccount *account; +} FindContactData; + static gboolean contact_is_tpl_entity (gpointer key, gpointer value, gpointer user_data) { - TpContact *contact = key; - TplEntity *entity = user_data; + EmpathyContact *contact = value; + FindContactData *data = user_data; - return !tp_strdiff (tp_contact_get_identifier (contact), - tpl_entity_get_identifier (entity)); + return !tp_strdiff (empathy_contact_get_id (contact), + tpl_entity_get_identifier (data->entity)) && + !tp_strdiff (tp_proxy_get_object_path (data->account), + tp_proxy_get_object_path ( + empathy_contact_get_account (contact))); } EmpathyContact * @@ -675,8 +684,15 @@ empathy_contact_from_tpl_contact (TpAccount *account, g_return_val_if_fail (TPL_IS_ENTITY (tpl_entity), NULL); if (contacts_table != NULL) - existing_contact = g_hash_table_find (contacts_table, - contact_is_tpl_entity, tpl_entity); + { + FindContactData data; + + data.entity = tpl_entity; + data.account = account; + + existing_contact = g_hash_table_find (contacts_table, + contact_is_tpl_entity, &data); + } if (existing_contact != NULL) { |