]> git.0d.be Git - empathy.git/commitdiff
empathy_contact_get_persona: use tpf_persona_dup_for_contact()
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 9 Dec 2011 11:31:18 +0000 (12:31 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 14 Dec 2011 09:52:33 +0000 (10:52 +0100)
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

index 216ef6d733f9ece52cfa359195b77b1f554cbf82..c947fad6295d10e85006c93ef0c64363317bdfe0 100644 (file)
@@ -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;