]> git.0d.be Git - empathy.git/commitdiff
factor out empathy_individual_get_client_types()
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 22 May 2012 12:54:56 +0000 (14:54 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 25 May 2012 08:48:29 +0000 (10:48 +0200)
libempathy-gtk/empathy-individual-store.c
libempathy/empathy-utils.c
libempathy/empathy-utils.h

index f27aad95cd0fc446b591b5dab8a4bec871ba1047..06ef65a331eddec0d4db0e965c9f4c53bf56f707 100644 (file)
@@ -100,48 +100,6 @@ static void individual_store_contact_update (EmpathyIndividualStore *self,
 G_DEFINE_TYPE (EmpathyIndividualStore, empathy_individual_store,
     GTK_TYPE_TREE_STORE);
 
-static const gchar * const *
-individual_get_client_types (FolksIndividual *individual)
-{
-  GeeSet *personas;
-  GeeIterator *iter;
-  const gchar * const *types = NULL;
-  FolksPresenceType presence_type = FOLKS_PRESENCE_TYPE_UNSET;
-
-  personas = folks_individual_get_personas (individual);
-  iter = gee_iterable_iterator (GEE_ITERABLE (personas));
-  while (gee_iterator_next (iter))
-    {
-      FolksPresenceDetails *presence;
-      FolksPersona *persona = gee_iterator_get (iter);
-
-      /* We only want personas which have presence and a TpContact */
-      if (!empathy_folks_persona_is_interesting (persona))
-        goto while_finish;
-
-      presence = FOLKS_PRESENCE_DETAILS (persona);
-
-      if (folks_presence_details_typecmp (
-              folks_presence_details_get_presence_type (presence),
-              presence_type) > 0)
-        {
-          TpContact *tp_contact;
-
-          presence_type = folks_presence_details_get_presence_type (presence);
-
-          tp_contact = tpf_persona_get_contact (TPF_PERSONA (persona));
-          if (tp_contact != NULL)
-            types = tp_contact_get_client_types (tp_contact);
-        }
-
-while_finish:
-      g_clear_object (&persona);
-    }
-  g_clear_object (&iter);
-
-  return types;
-}
-
 static void
 add_individual_to_store (GtkTreeStore *store,
     GtkTreeIter *iter,
@@ -156,7 +114,7 @@ add_individual_to_store (GtkTreeStore *store,
   empathy_individual_can_audio_video_call (individual, &can_audio_call,
       &can_video_call, NULL);
 
-  types = individual_get_client_types (individual);
+  types = empathy_individual_get_client_types (individual);
 
   gtk_tree_store_insert_with_values (store, iter, parent, 0,
       EMPATHY_INDIVIDUAL_STORE_COL_NAME,
@@ -703,7 +661,7 @@ individual_store_contact_update (EmpathyIndividualStore *self,
       empathy_individual_can_audio_video_call (individual, &can_audio_call,
           &can_video_call, NULL);
 
-      types = individual_get_client_types (individual);
+      types = empathy_individual_get_client_types (individual);
 
       gtk_tree_store_set (GTK_TREE_STORE (self), l->data,
           EMPATHY_INDIVIDUAL_STORE_COL_ICON_STATUS, pixbuf_status,
index c73f6514e2d407f712ea6d0d0d8d8c2cfa22417e..30d40e9a573853a98a0db58a61d3763bec8a0c47 100644 (file)
@@ -1231,3 +1231,45 @@ empathy_ensure_individual_from_tp_contact (TpContact *contact)
   g_object_unref (persona);
   return individual;
 }
+
+const gchar * const *
+empathy_individual_get_client_types (FolksIndividual *individual)
+{
+  GeeSet *personas;
+  GeeIterator *iter;
+  const gchar * const *types = NULL;
+  FolksPresenceType presence_type = FOLKS_PRESENCE_TYPE_UNSET;
+
+  personas = folks_individual_get_personas (individual);
+  iter = gee_iterable_iterator (GEE_ITERABLE (personas));
+  while (gee_iterator_next (iter))
+    {
+      FolksPresenceDetails *presence;
+      FolksPersona *persona = gee_iterator_get (iter);
+
+      /* We only want personas which have presence and a TpContact */
+      if (!empathy_folks_persona_is_interesting (persona))
+        goto while_finish;
+
+      presence = FOLKS_PRESENCE_DETAILS (persona);
+
+      if (folks_presence_details_typecmp (
+              folks_presence_details_get_presence_type (presence),
+              presence_type) > 0)
+        {
+          TpContact *tp_contact;
+
+          presence_type = folks_presence_details_get_presence_type (presence);
+
+          tp_contact = tpf_persona_get_contact (TPF_PERSONA (persona));
+          if (tp_contact != NULL)
+            types = tp_contact_get_client_types (tp_contact);
+        }
+
+while_finish:
+      g_clear_object (&persona);
+    }
+  g_clear_object (&iter);
+
+  return types;
+}
index 5ce8cc8cb42bd23d80ac26ef32325de266fb3184..dae2506081ad6d71ec30ba84a665af7b788b36b7 100644 (file)
@@ -127,6 +127,9 @@ FolksIndividual * empathy_create_individual_from_tp_contact (
 FolksIndividual * empathy_ensure_individual_from_tp_contact (
     TpContact *contact);
 
+const gchar * const * empathy_individual_get_client_types (
+    FolksIndividual *individual);
+
 /* Copied from wocky/wocky-utils.h */
 
 #define empathy_implement_finish_void(source, tag) \