]> git.0d.be Git - empathy.git/blobdiff - libempathy/empathy-individual-manager.c
Merge branch 'sasl'
[empathy.git] / libempathy / empathy-individual-manager.c
index 1e76cbf834b0adbe7d0a7ef510dabc7416aa992d..82884e4d1f6e26003e5d5739afcf4261cc4556a0 100644 (file)
@@ -34,8 +34,6 @@
 #include <extensions/extensions.h>
 
 #include "empathy-individual-manager.h"
-#include "empathy-contact-manager.h"
-#include "empathy-contact-list.h"
 #include "empathy-marshal.h"
 #include "empathy-utils.h"
 
@@ -51,7 +49,6 @@
 typedef struct
 {
   FolksIndividualAggregator *aggregator;
-  EmpathyContactManager *contact_manager;
   GHashTable *individuals; /* Individual.id -> Individual */
 } EmpathyIndividualManagerPriv;
 
@@ -173,6 +170,20 @@ aggregator_individuals_changed_cb (FolksIndividualAggregator *aggregator,
   EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
   GList *l, *added_filtered = NULL;
 
+  /* Handle the removals first, as one of the added Individuals might have the
+   * same ID as one of the removed Individuals (due to linking). */
+  for (l = removed; l; l = l->next)
+    {
+      FolksIndividual *ind = FOLKS_INDIVIDUAL (l->data);
+
+      g_signal_handlers_disconnect_by_func (ind,
+          individual_notify_personas_cb, self);
+
+      if (g_hash_table_lookup (priv->individuals,
+          folks_individual_get_id (ind)) != NULL)
+        remove_individual (self, ind);
+    }
+
   /* Filter the individuals for ones which contain EmpathyContacts */
   for (l = added; l; l = l->next)
     {
@@ -188,18 +199,6 @@ aggregator_individuals_changed_cb (FolksIndividualAggregator *aggregator,
         }
     }
 
-  for (l = removed; l; l = l->next)
-    {
-      FolksIndividual *ind = FOLKS_INDIVIDUAL (l->data);
-
-      g_signal_handlers_disconnect_by_func (ind,
-          individual_notify_personas_cb, self);
-
-      if (g_hash_table_lookup (priv->individuals,
-          folks_individual_get_id (ind)) != NULL)
-        remove_individual (self, ind);
-    }
-
   /* Bail if we have no individuals left */
   if (added_filtered == NULL && removed == NULL)
     return;
@@ -208,7 +207,7 @@ aggregator_individuals_changed_cb (FolksIndividualAggregator *aggregator,
 
   g_signal_emit (self, signals[MEMBERS_CHANGED], 0, message,
       added_filtered, removed,
-      tp_chanel_group_change_reason_from_folks_groups_change_reason (reason),
+      tp_channel_group_change_reason_from_folks_groups_change_reason (reason),
       TRUE);
 
   g_list_free (added_filtered);
@@ -220,7 +219,6 @@ individual_manager_dispose (GObject *object)
   EmpathyIndividualManagerPriv *priv = GET_PRIV (object);
 
   g_hash_table_destroy (priv->individuals);
-  tp_clear_object (&priv->contact_manager);
   tp_clear_object (&priv->aggregator);
 
   G_OBJECT_CLASS (empathy_individual_manager_parent_class)->dispose (object);
@@ -314,7 +312,6 @@ empathy_individual_manager_init (EmpathyIndividualManager *self)
       EMPATHY_TYPE_INDIVIDUAL_MANAGER, EmpathyIndividualManagerPriv);
 
   self->priv = priv;
-  priv->contact_manager = empathy_contact_manager_dup_singleton ();
   priv->individuals = g_hash_table_new_full (g_str_hash, g_str_equal,
       NULL, g_object_unref);
 
@@ -451,7 +448,7 @@ empathy_individual_manager_remove (EmpathyIndividualManager *self,
 
   DEBUG ("removing individual %s (%s)",
       folks_individual_get_id (individual),
-      folks_individual_get_alias (individual));
+      folks_aliasable_get_alias (FOLKS_ALIASABLE (individual)));
 
   folks_individual_aggregator_remove_individual (priv->aggregator, individual,
       aggregator_remove_individual_cb, self);
@@ -462,10 +459,10 @@ groups_change_group_cb (GObject *source,
     GAsyncResult *result,
     gpointer user_data)
 {
-  FolksGroups *groups = FOLKS_GROUPS (source);
+  FolksGroupable *groupable = FOLKS_GROUPABLE (source);
   GError *error = NULL;
 
-  folks_groups_change_group_finish (groups, result, &error);
+  folks_groupable_change_group_finish (groupable, result, &error);
   if (error != NULL)
     {
       g_warning ("failed to change group: %s", error->message);
@@ -478,7 +475,7 @@ remove_group_cb (const gchar *id,
     FolksIndividual *individual,
     const gchar *group)
 {
-  folks_groups_change_group (FOLKS_GROUPS (individual), group, FALSE,
+  folks_groupable_change_group (FOLKS_GROUPABLE (individual), group, FALSE,
       groups_change_group_cb, NULL);
 }
 
@@ -500,36 +497,6 @@ empathy_individual_manager_remove_group (EmpathyIndividualManager *manager,
       (gpointer) group);
 }
 
-EmpathyIndividualManagerFlags
-empathy_individual_manager_get_flags_for_connection (
-    EmpathyIndividualManager *self,
-    TpConnection *connection)
-{
-  EmpathyIndividualManagerPriv *priv;
-  EmpathyContactListFlags list_flags;
-  EmpathyIndividualManagerFlags flags;
-
-  g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self),
-      EMPATHY_INDIVIDUAL_MANAGER_NO_FLAGS);
-
-  priv = GET_PRIV (self);
-
-  list_flags = empathy_contact_manager_get_flags_for_connection (
-    priv->contact_manager, connection);
-
-  flags = EMPATHY_INDIVIDUAL_MANAGER_NO_FLAGS;
-  if (list_flags & EMPATHY_CONTACT_LIST_CAN_ADD)
-    flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_ADD;
-  if (list_flags & EMPATHY_CONTACT_LIST_CAN_REMOVE)
-    flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_REMOVE;
-  if (list_flags & EMPATHY_CONTACT_LIST_CAN_ALIAS)
-    flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_ALIAS;
-  if (list_flags & EMPATHY_CONTACT_LIST_CAN_GROUP)
-    flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_GROUP;
-
-  return flags;
-}
-
 static void
 link_personas_cb (FolksIndividualAggregator *aggregator,
     GAsyncResult *async_result,