]> git.0d.be Git - empathy.git/commitdiff
factor out empathy_create_individual_from_tp_contact()
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 4 Nov 2011 12:45:38 +0000 (13:45 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 24 Nov 2011 11:28:44 +0000 (12:28 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=663387

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

index 6d93e68136f0bd6c6a23292247fe9deef176d03c..cba419beac4459d39121ed17116e3a718bc433dd 100644 (file)
@@ -14,6 +14,8 @@
 
 #include "empathy-contact-chooser.h"
 
 
 #include "empathy-contact-chooser.h"
 
+#include <libempathy/empathy-utils.h>
+
 #include <libempathy-gtk/empathy-individual-store-manager.h>
 #include <libempathy-gtk/empathy-individual-view.h>
 #include <libempathy-gtk/empathy-ui-utils.h>
 #include <libempathy-gtk/empathy-individual-store-manager.h>
 #include <libempathy-gtk/empathy-individual-view.h>
 #include <libempathy-gtk/empathy-ui-utils.h>
@@ -209,11 +211,7 @@ get_contacts_cb (TpConnection *connection,
   EmpathyContactChooser *self =
     (EmpathyContactChooser *) weak_object;
   AddTemporaryIndividualCtx *ctx = user_data;
   EmpathyContactChooser *self =
     (EmpathyContactChooser *) weak_object;
   AddTemporaryIndividualCtx *ctx = user_data;
-  TpAccount *account;
-  TpfPersonaStore *store;
   FolksIndividual *individual;
   FolksIndividual *individual;
-  TpfPersona *persona;
-  GeeSet *personas;
 
   if (self->priv->add_temp_ctx != ctx)
     /* another request has been started */
 
   if (self->priv->add_temp_ctx != ctx)
     /* another request has been started */
@@ -222,18 +220,7 @@ get_contacts_cb (TpConnection *connection,
   if (n_contacts != 1)
     return;
 
   if (n_contacts != 1)
     return;
 
-  account = tp_connection_get_account (connection);
-
-  store = tpf_persona_store_new (account);
-  personas = GEE_SET (
-      gee_hash_set_new (FOLKS_TYPE_PERSONA, g_object_ref, g_object_unref,
-      g_direct_hash, g_direct_equal));
-
-  persona = tpf_persona_new (contacts[0], store);
-
-  gee_collection_add (GEE_COLLECTION (personas), persona);
-
-  individual = folks_individual_new (personas);
+  individual =  empathy_create_individual_from_tp_contact (contacts[0]);
 
   /* listen for updates to the capabilities */
   tp_g_signal_connect_object (contacts[0], "notify::capabilities",
 
   /* listen for updates to the capabilities */
   tp_g_signal_connect_object (contacts[0], "notify::capabilities",
@@ -249,10 +236,6 @@ get_contacts_cb (TpConnection *connection,
         gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->view)),
         NULL, NULL))
     empathy_individual_view_select_first (self->priv->view);
         gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->view)),
         NULL, NULL))
     empathy_individual_view_select_first (self->priv->view);
-
-  g_clear_object (&persona);
-  g_clear_object (&personas);
-  g_object_unref (store);
 }
 
 static void
 }
 
 static void
index 83fe4ce7e50bfa52d79ed56cff39a74ec0544202..972abe65e2ae6011aef33d1f5a6a0a6b4851145a 100644 (file)
@@ -1163,3 +1163,35 @@ empathy_sasl_channel_supports_mechanism (TpChannel *channel,
 
   return tp_strv_contains (available_mechanisms, mechanism);
 }
 
   return tp_strv_contains (available_mechanisms, mechanism);
 }
+
+FolksIndividual *
+empathy_create_individual_from_tp_contact (TpContact *contact)
+{
+  TpAccount *account;
+  TpConnection *connection;
+  TpfPersonaStore *store;
+  GeeSet *personas;
+  TpfPersona *persona;
+  FolksIndividual *individual;
+
+  connection = tp_contact_get_connection (contact);
+  account = tp_connection_get_account (connection);
+
+  store = tpf_persona_store_new (account);
+
+  personas = GEE_SET (
+      gee_hash_set_new (FOLKS_TYPE_PERSONA, g_object_ref, g_object_unref,
+      g_direct_hash, g_direct_equal));
+
+  persona = tpf_persona_new (contact, store);
+
+  gee_collection_add (GEE_COLLECTION (personas), persona);
+
+  individual = folks_individual_new (personas);
+
+  g_clear_object (&persona);
+  g_clear_object (&personas);
+  g_object_unref (store);
+
+  return individual;
+}
index f8d47ec8aaf08a53277e2474226f39aa2824dfc6..ac5fef82066e1b84d082db2bf6a418d7210bd459 100644 (file)
@@ -121,6 +121,9 @@ void empathy_individual_can_audio_video_call (FolksIndividual *individual,
 gboolean empathy_sasl_channel_supports_mechanism (TpChannel *channel,
     const gchar *mechanism);
 
 gboolean empathy_sasl_channel_supports_mechanism (TpChannel *channel,
     const gchar *mechanism);
 
+FolksIndividual * empathy_create_individual_from_tp_contact (
+    TpContact *contact);
+
 /* Copied from wocky/wocky-utils.h */
 
 #define empathy_implement_finish_void(source, tag) \
 /* Copied from wocky/wocky-utils.h */
 
 #define empathy_implement_finish_void(source, tag) \