[empathy] empathy_contact_get_persona: use tpf_persona_dup_for_contact()



commit aa802500fc09133e196a5087867a1743d3911100
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Fri Dec 9 12:31:18 2011 +0100

    empathy_contact_get_persona: use tpf_persona_dup_for_contact()
    
    We can finally get rid of this horrible code iterating over all the
    individuals. \o/
    
    https://bugzilla.gnome.org/show_bug.cgi?id=665853

 libempathy/empathy-contact.c |   42 +++++-------------------------------------
 1 files changed, 5 insertions(+), 37 deletions(-)
---
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 216ef6d..c947fad 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -1003,46 +1003,14 @@ empathy_contact_get_persona (EmpathyContact *contact)
 
   if (priv->persona == NULL && priv->tp_contact != NULL)
     {
-      /* FIXME: This is disgustingly slow */
-      /* Query for the persona */
-      EmpathyIndividualManager *manager;
-      GList *individuals, *l;
+      TpfPersona *persona;
 
-      manager = empathy_individual_manager_dup_singleton ();
-      individuals = empathy_individual_manager_get_members (manager);
-
-      for (l = individuals; l != NULL; l = l->next)
+      persona = tpf_persona_dup_for_contact (priv->tp_contact);
+      if (persona != NULL)
         {
-          FolksIndividual *individual = FOLKS_INDIVIDUAL (l->data);
-          GeeSet *personas;
-          GeeIterator *iter;
-          gboolean persona_found = FALSE;
-
-          personas = folks_individual_get_personas (individual);
-          iter = gee_iterable_iterator (GEE_ITERABLE (personas));
-          while (!persona_found && gee_iterator_next (iter))
-            {
-              TpfPersona *persona = gee_iterator_get (iter);
-
-              if (empathy_folks_persona_is_interesting (FOLKS_PERSONA (persona)))
-                {
-                  TpContact *tp_contact = tpf_persona_get_contact (persona);
-
-                  if (tp_contact == priv->tp_contact)
-                    {
-                      /* Found the right persona */
-                      empathy_contact_set_persona (contact,
-                          (FolksPersona *) persona);
-                      persona_found = TRUE;
-                    }
-                  g_clear_object (&persona);
-                }
-            }
-          g_clear_object (&iter);
+          empathy_contact_set_persona (contact, (FolksPersona *) persona);
+          g_object_unref (persona);
         }
-
-      g_list_free (individuals);
-      g_object_unref (manager);
     }
 
   return priv->persona;



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