]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-individual-store.c
Merge branch 'sasl'
[empathy.git] / libempathy-gtk / empathy-individual-store.c
index 807afb2a220c174567817b1613ca14565ae71e15..4b07131a60ac1691ce63cf3398ab01e08b306a7b 100644 (file)
@@ -154,6 +154,39 @@ individual_can_audio_video_call (FolksIndividual *individual,
   *can_video_call = can_video;
 }
 
+static const gchar * const *
+individual_get_client_types (FolksIndividual *individual)
+{
+  GList *personas, *l;
+  const gchar * const *types = NULL;
+  FolksPresenceType presence_type = FOLKS_PRESENCE_TYPE_UNSET;
+
+  personas = folks_individual_get_personas (individual);
+  for (l = personas; l != NULL; l = l->next)
+    {
+      FolksPresence *presence;
+
+      /* We only want personas which implement FolksPresence */
+      if (!FOLKS_IS_PRESENCE (l->data))
+        continue;
+
+      presence = FOLKS_PRESENCE (l->data);
+
+      if (folks_presence_typecmp (folks_presence_get_presence_type (presence),
+              presence_type) > 0)
+        {
+          TpContact *tp_contact;
+
+          presence_type = folks_presence_get_presence_type (presence);
+
+          tp_contact = tpf_persona_get_contact (TPF_PERSONA (l->data));
+          types = tp_contact_get_client_types (tp_contact);
+        }
+    }
+
+  return types;
+}
+
 static void
 add_individual_to_store (GtkTreeStore *self,
     GtkTreeIter *iter,
@@ -161,10 +194,13 @@ add_individual_to_store (GtkTreeStore *self,
     FolksIndividual *individual)
 {
   gboolean can_audio_call, can_video_call;
+  const gchar * const *types;
 
   individual_can_audio_video_call (individual, &can_audio_call,
       &can_video_call);
 
+  types = individual_get_client_types (individual);
+
   gtk_tree_store_insert_with_values (self, iter, parent, 0,
       EMPATHY_INDIVIDUAL_STORE_COL_NAME,
       folks_aliasable_get_alias (FOLKS_ALIASABLE (individual)),
@@ -173,6 +209,7 @@ add_individual_to_store (GtkTreeStore *self,
       EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, FALSE,
       EMPATHY_INDIVIDUAL_STORE_COL_CAN_AUDIO_CALL, can_audio_call,
       EMPATHY_INDIVIDUAL_STORE_COL_CAN_VIDEO_CALL, can_video_call,
+      EMPATHY_INDIVIDUAL_STORE_COL_CLIENT_TYPES, types,
       -1);
 }
 
@@ -324,6 +361,13 @@ individual_store_find_contact (EmpathyIndividualStore *self,
   return l;
 }
 
+static void
+free_iters (GList *iters)
+{
+  g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL);
+  g_list_free (iters);
+}
+
 static void
 individual_store_remove_individual (EmpathyIndividualStore *self,
     FolksIndividual *individual)
@@ -360,8 +404,7 @@ individual_store_remove_individual (EmpathyIndividualStore *self,
         }
     }
 
-  g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL);
-  g_list_free (iters);
+  free_iters (iters);
 }
 
 static void
@@ -483,9 +526,7 @@ individual_store_contact_set_active (EmpathyIndividualStore *self,
         }
     }
 
-  g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL);
-  g_list_free (iters);
-
+  free_iters (iters);
 }
 
 static void individual_store_contact_active_free (ShowActiveData *data);
@@ -610,6 +651,8 @@ individual_avatar_pixbuf_received_cb (FolksIndividual *individual,
               EMPATHY_INDIVIDUAL_STORE_COL_PIXBUF_AVATAR, pixbuf,
               -1);
         }
+
+      free_iters (iters);
     }
 
   /* Free things */
@@ -623,6 +666,7 @@ individual_avatar_pixbuf_received_cb (FolksIndividual *individual,
           data->cancellable);
     }
 
+  tp_clear_object (&pixbuf);
   g_object_unref (data->cancellable);
   g_slice_free (LoadAvatarData, data);
 }
@@ -738,10 +782,13 @@ individual_store_contact_update (EmpathyIndividualStore *self,
   for (l = iters; l && set_model; l = l->next)
     {
       gboolean can_audio_call, can_video_call;
+      const gchar * const *types;
 
       individual_can_audio_video_call (individual, &can_audio_call,
           &can_video_call);
 
+      types = individual_get_client_types (individual);
+
       gtk_tree_store_set (GTK_TREE_STORE (self), l->data,
           EMPATHY_INDIVIDUAL_STORE_COL_ICON_STATUS, pixbuf_status,
           EMPATHY_INDIVIDUAL_STORE_COL_PIXBUF_AVATAR_VISIBLE, show_avatar,
@@ -757,6 +804,7 @@ individual_store_contact_update (EmpathyIndividualStore *self,
           EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, FALSE,
           EMPATHY_INDIVIDUAL_STORE_COL_CAN_AUDIO_CALL, can_audio_call,
           EMPATHY_INDIVIDUAL_STORE_COL_CAN_VIDEO_CALL, can_video_call,
+          EMPATHY_INDIVIDUAL_STORE_COL_CLIENT_TYPES, types,
           -1);
     }
 
@@ -780,8 +828,7 @@ individual_store_contact_update (EmpathyIndividualStore *self,
    * timeout removes the user from the contact list, really we
    * should remove the first timeout.
    */
-  g_list_foreach (iters, (GFunc) gtk_tree_iter_free, NULL);
-  g_list_free (iters);
+  free_iters (iters);
 }
 
 static void
@@ -859,6 +906,8 @@ individual_personas_changed_cb (FolksIndividual *individual,
       g_object_set_data (G_OBJECT (contact), "individual", individual);
       g_signal_connect (contact, "notify::capabilities",
           (GCallback) individual_store_contact_updated_cb, self);
+      g_signal_connect (contact, "notify::client-types",
+          (GCallback) individual_store_contact_updated_cb, self);
 
       g_object_unref (contact);
     }
@@ -1470,6 +1519,8 @@ individual_store_name_sort_func (GtkTreeModel *model,
 
   tp_clear_object (&individual_a);
   tp_clear_object (&individual_b);
+  g_free (name_a);
+  g_free (name_b);
 
   return ret_val;
 }
@@ -1494,6 +1545,7 @@ individual_store_setup (EmpathyIndividualStore *self)
     G_TYPE_BOOLEAN,             /* Can make audio calls */
     G_TYPE_BOOLEAN,             /* Can make video calls */
     G_TYPE_BOOLEAN,             /* Is a fake group */
+    G_TYPE_STRV,                /* Client types */
   };
 
   priv = GET_PRIV (self);