]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-persona-store.c
Merge branch 'sasl'
[empathy.git] / libempathy-gtk / empathy-persona-store.c
index 7997150bc9520f215a6bf3cdd8299c106ffcf480..fbeeb6991ae5c1a2a7fd8536eddf254646588f41 100644 (file)
@@ -142,7 +142,7 @@ persona_active_new (EmpathyPersonaStore *self,
   ShowActiveData *data;
 
   DEBUG ("Contact:'%s' now active, and %s be removed",
-      folks_alias_get_alias (FOLKS_ALIAS (persona)),
+      folks_aliasable_get_alias (FOLKS_ALIASABLE (persona)),
       remove_ ? "WILL" : "WILL NOT");
 
   data = g_slice_new0 (ShowActiveData);
@@ -212,7 +212,8 @@ persona_set_active (EmpathyPersonaStore *self,
 static gboolean
 persona_active_cb (ShowActiveData *data)
 {
-  const gchar *alias = folks_alias_get_alias (FOLKS_ALIAS (data->persona));
+  const gchar *alias =
+      folks_aliasable_get_alias (FOLKS_ALIASABLE (data->persona));
 
   if (data->remove)
     {
@@ -234,7 +235,7 @@ persona_updated_cb (FolksPersona *persona,
     EmpathyPersonaStore *self)
 {
   DEBUG ("Contact:'%s' updated, checking roster is in sync...",
-      folks_alias_get_alias (FOLKS_ALIAS (persona)));
+      folks_aliasable_get_alias (FOLKS_ALIASABLE (persona)));
 
   update_persona (self, persona);
 }
@@ -288,7 +289,7 @@ add_persona (EmpathyPersonaStore *self,
 
   priv = GET_PRIV (self);
 
-  alias = folks_alias_get_alias (FOLKS_ALIAS (persona));
+  alias = folks_aliasable_get_alias (FOLKS_ALIASABLE (persona));
   if (EMP_STR_EMPTY (alias))
     return;
 
@@ -407,7 +408,7 @@ update_persona (EmpathyPersonaStore *self,
   const gchar *alias;
 
   path = find_persona (self, persona);
-  alias = folks_alias_get_alias (FOLKS_ALIAS (persona));
+  alias = folks_aliasable_get_alias (FOLKS_ALIASABLE (persona));
 
   if (path == NULL)
     {
@@ -524,42 +525,20 @@ update_persona (EmpathyPersonaStore *self,
 }
 
 static void
-individual_notify_personas_cb (GObject *object,
-    GParamSpec *pspec,
+individual_personas_changed_cb (GObject *object,
+    GList *added,
+    GList *removed,
     EmpathyPersonaStore *self)
 {
-  EmpathyPersonaStorePriv *priv = GET_PRIV (self);
-  GList *old_personas, *new_personas, *removed_personas, *l;
-
-  /* Remove old personas which are no longer in the individual.
-   * Build a list of such personas to remove from our hash table.
-   * This is slow. */
-  old_personas = g_hash_table_get_keys (priv->personas);
-  new_personas = folks_individual_get_personas (FOLKS_INDIVIDUAL (object));
-  removed_personas = NULL;
+  GList *l;
 
-  for (l = old_personas; l != NULL; l = l->next)
-    {
-      GList *i = g_list_find (new_personas, l->data);
-      if (i == NULL)
-        removed_personas = g_list_prepend (removed_personas, l->data);
-    }
-  g_list_free (old_personas);
-
-  /* Remove the removed personas. We can't do this from inside the above loop,
-   * as old_personas is only valid until the hash table is modified. */
-  for (l = removed_personas; l != NULL; l = l->next)
+  /* Remove the old personas. */
+  for (l = removed; l != NULL; l = l->next)
     remove_persona_and_disconnect (self, FOLKS_PERSONA (l->data));
-  g_list_free (removed_personas);
 
   /* Add each of the new personas to the tree model */
-  for (l = new_personas; l != NULL; l = l->next)
-    {
-      FolksPersona *persona = FOLKS_PERSONA (l->data);
-
-      if (g_hash_table_lookup (priv->personas, persona) == NULL)
-        add_persona_and_connect (self, persona);
-    }
+  for (l = added; l != NULL; l = l->next)
+    add_persona_and_connect (self, FOLKS_PERSONA (l->data));
 }
 
 static gint
@@ -573,8 +552,9 @@ sort_personas (FolksPersona *persona_a,
   g_return_val_if_fail (persona_a != NULL || persona_b != NULL, 0);
 
   /* alias */
-  ret_val = g_utf8_collate (folks_alias_get_alias (FOLKS_ALIAS (persona_a)),
-          folks_alias_get_alias (FOLKS_ALIAS (persona_b)));
+  ret_val = g_utf8_collate (
+      folks_aliasable_get_alias (FOLKS_ALIASABLE (persona_a)),
+      folks_aliasable_get_alias (FOLKS_ALIASABLE (persona_b)));
 
   if (ret_val != 0)
     goto out;
@@ -1009,7 +989,7 @@ empathy_persona_store_set_individual (EmpathyPersonaStore *self,
       GList *personas, *l;
 
       g_signal_handlers_disconnect_by_func (priv->individual,
-          (GCallback) individual_notify_personas_cb, self);
+          (GCallback) individual_personas_changed_cb, self);
 
       /* Disconnect from and remove all personas belonging to this individual */
       personas = folks_individual_get_personas (priv->individual);
@@ -1028,8 +1008,8 @@ empathy_persona_store_set_individual (EmpathyPersonaStore *self,
 
       g_object_ref (individual);
 
-      g_signal_connect (individual, "notify::personas",
-          (GCallback) individual_notify_personas_cb, self);
+      g_signal_connect (individual, "personas-changed",
+          (GCallback) individual_personas_changed_cb, self);
 
       /* Add pre-existing Personas */
       personas = folks_individual_get_personas (individual);