[empathy: 77/80] empathy_contact_from_tpl_contact: check the accounts match



commit c5353cf8c819b549de202faa3326406f3638a899
Author: Emilio Pozuelo Monfort <emilio pozuelo collabora co uk>
Date:   Thu Jun 9 14:57:14 2011 +0100

    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.

 libempathy/empathy-contact.c |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)
---
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 7c66a28..8cca709 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)
     {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]