]> git.0d.be Git - empathy.git/commitdiff
Remove folks_individual_dup_from_empathy_contact()
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Wed, 7 Jul 2010 12:26:19 +0000 (13:26 +0100)
committerTravis Reitter <treitter@gmail.com>
Wed, 21 Jul 2010 20:25:04 +0000 (13:25 -0700)
As EmpathyContact is now a wrapper around FolksPersona, we can mutate the
persona instead of acquiring an individual and mutating that instead.

libempathy-gtk/empathy-contact-widget.c
libempathy/empathy-contact.c
libempathy/empathy-utils.c
libempathy/empathy-utils.h

index 9bdad553428f90a962237d731eafe41a0ddac8a5..0da9e0091379aa5fdc941a9b6daac3521acc50b6 100644 (file)
@@ -579,15 +579,11 @@ contact_widget_cell_toggled (GtkCellRendererToggle *cell,
 
   if (group != NULL)
     {
-      FolksIndividual *individual = folks_individual_dup_from_empathy_contact (
+      FolksPersona *persona = empathy_contact_get_persona (
           information->contact);
 
-      if (individual != NULL)
-        {
-          folks_groups_change_group (FOLKS_GROUPS (individual), group,
-              !was_enabled);
-          g_object_unref (individual);
-        }
+      if (persona != NULL && FOLKS_IS_GROUPS (persona))
+        folks_groups_change_group (FOLKS_GROUPS (persona), group, !was_enabled);
 
       g_free (group);
     }
@@ -795,7 +791,7 @@ contact_widget_button_group_clicked_cb (GtkButton *button,
   GtkTreeView *view;
   GtkListStore *store;
   GtkTreeIter iter;
-  FolksIndividual *individual;
+  FolksPersona *persona;
   const gchar *group;
 
   view = GTK_TREE_VIEW (information->treeview_groups);
@@ -809,13 +805,10 @@ contact_widget_button_group_clicked_cb (GtkButton *button,
       COL_ENABLED, TRUE,
       -1);
 
-  individual = folks_individual_dup_from_empathy_contact (information->contact);
+  persona = empathy_contact_get_persona (information->contact);
 
-  if (individual != NULL)
-    {
-      folks_groups_change_group (FOLKS_GROUPS (individual), group, TRUE);
-      g_object_unref (individual);
-    }
+  if (persona != NULL && FOLKS_IS_GROUPS (persona))
+    folks_groups_change_group (FOLKS_GROUPS (persona), group, TRUE);
 }
 
 static void
@@ -1337,14 +1330,7 @@ contact_widget_entry_alias_focus_event_cb (GtkEditable *editable,
         }
       else
         {
-          FolksIndividual *individual =
-              folks_individual_dup_from_empathy_contact (information->contact);
-
-          if (individual != NULL)
-            {
-              folks_alias_set_alias (FOLKS_ALIAS (individual), alias);
-              g_object_unref (individual);
-            }
+          empathy_contact_set_alias (information->contact, alias);
         }
     }
 
@@ -1535,17 +1521,15 @@ contact_widget_contact_update (EmpathyContactWidget *information)
 
       if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_FAVOURITE)
         {
-          FolksIndividual *individual =
-              folks_individual_dup_from_empathy_contact (information->contact);
+          FolksPersona *persona = empathy_contact_get_persona (
+              information->contact);
 
-          if (individual != NULL)
+          if (persona != NULL && FOLKS_IS_FAVOURITE (persona))
             {
               gboolean is_favourite = folks_favourite_get_is_favourite (
-                  FOLKS_FAVOURITE (individual));
+                  FOLKS_FAVOURITE (persona));
               contact_widget_favourites_changed_cb (information->manager,
                   information->contact, is_favourite, information);
-
-              g_object_unref (individual);
             }
         }
 
@@ -1672,14 +1656,12 @@ static void
 favourite_toggled_cb (GtkToggleButton *button,
     EmpathyContactWidget *information)
 {
-  FolksIndividual *individual = folks_individual_dup_from_empathy_contact (
-      information->contact);
+  FolksPersona *persona = empathy_contact_get_persona (information->contact);
 
-  if (individual != NULL)
+  if (persona != NULL && FOLKS_IS_FAVOURITE (persona))
     {
       gboolean active = gtk_toggle_button_get_active (button);
-      folks_favourite_set_is_favourite (FOLKS_FAVOURITE (individual), active);
-      g_object_unref (individual);
+      folks_favourite_set_is_favourite (FOLKS_FAVOURITE (persona), active);
     }
 }
 
index 64235ea9a4375e8ee3a38e39bb294b279bca8704..3a16c3e3773fbacfcdd207a26b8e96ec93acdf2d 100644 (file)
@@ -636,42 +636,22 @@ empathy_contact_set_name (EmpathyContact *contact,
   g_object_unref (contact);
 }
 
-static void
-contact_set_aliases_cb (TpConnection *connection,
-    const GError *error,
-    gpointer user_data,
-    GObject *weak_object)
-{
-       if (error)
-               DEBUG ("Error: %s", error->message);
-}
-
 void
 empathy_contact_set_alias (EmpathyContact *contact,
     const gchar *alias)
 {
-       TpConnection *connection;
-       GHashTable *new_alias;
-       guint handle;
-
-       g_return_if_fail (EMPATHY_IS_CONTACT (contact));
-
-       handle = empathy_contact_get_handle (contact);
-
-       DEBUG ("Setting alias for contact %s (%d) to %s",
-               empathy_contact_get_id (contact),
-               handle, alias);
+  FolksPersona *persona;
 
-       new_alias = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
-           g_free);
+  g_return_if_fail (EMPATHY_IS_CONTACT (contact));
 
-       g_hash_table_insert (new_alias, GUINT_TO_POINTER (handle), g_strdup (alias));
+  persona = empathy_contact_get_persona (contact);
+  if (persona == NULL || !FOLKS_IS_ALIAS (persona))
+    return;
 
-       connection = empathy_contact_get_connection (contact);
-       tp_cli_connection_interface_aliasing_call_set_aliases (connection, -1,
-           new_alias, contact_set_aliases_cb, NULL, NULL, NULL);
+  DEBUG ("Setting alias for contact %s to %s", empathy_contact_get_id (contact),
+      alias);
 
-       g_hash_table_destroy (new_alias);
+  folks_alias_set_alias (FOLKS_ALIAS (persona), alias);
 }
 
 EmpathyAvatar *
index d460f55825d51a643578fe4b81edb3a0275d1f9e..9a5e28c177bb7bc961142ca9a71b4169cb0ad461 100644 (file)
@@ -621,38 +621,6 @@ empathy_contact_dup_from_folks_individual (FolksIndividual *individual)
   return contact;
 }
 
-/* TODO: This also needs to be eliminated, and is horrifically slow. */
-
-/* Retrieve the first Individual containing a TpContact that corresponds to the
- * given EmpathyContact. Note that this is a temporary convenience. See
- * the TODO above. */
-FolksIndividual *
-folks_individual_dup_from_empathy_contact (EmpathyContact *contact)
-{
-  EmpathyIndividualManager *manager;
-  FolksIndividual *individual = NULL;
-  GList *individuals, *l;
-
-  manager = empathy_individual_manager_dup_singleton ();
-  individuals = empathy_individual_manager_get_members (manager);
-
-  for (l = individuals; (l != NULL) && (individual == NULL); l = l->next)
-    {
-      FolksIndividual *i = FOLKS_INDIVIDUAL (l->data);
-      EmpathyContact *c = empathy_contact_dup_from_folks_individual (i);
-
-      if (c == contact)
-        individual = g_object_ref (i);
-
-      g_object_unref (c);
-    }
-
-  g_list_free (individuals);
-  g_object_unref (manager);
-
-  return individual;
-}
-
 TpChannelGroupChangeReason
 tp_chanel_group_change_reason_from_folks_groups_change_reason (
     FolksGroupsChangeReason reason)
index f35d9e5c3c5f409e0f29b1cd193ae3ba6e616079..da0edc58cde01e14b2ae3b5330c323ad5bb398a7 100644 (file)
@@ -93,7 +93,6 @@ void empathy_connect_new_account (TpAccount *account,
 TpConnectionPresenceType empathy_folks_presence_type_to_tp (FolksPresenceType type);
 gboolean empathy_folks_individual_contains_contact (FolksIndividual *individual);
 EmpathyContact * empathy_contact_dup_from_folks_individual (FolksIndividual *individual);
-FolksIndividual *folks_individual_dup_from_empathy_contact (EmpathyContact *contact);
 TpChannelGroupChangeReason tp_chanel_group_change_reason_from_folks_groups_change_reason (FolksGroupsChangeReason reason);
 
 G_END_DECLS