]> git.0d.be Git - empathy.git/commitdiff
factor out empathy_get_tp_contact_for_individual
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 8 Sep 2011 15:02:44 +0000 (17:02 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 8 Sep 2011 15:23:50 +0000 (17:23 +0200)
libempathy/empathy-utils.c
libempathy/empathy-utils.h
src/empathy-invite-participant-dialog.c

index 24fdf97f354113c6ebf216d31a7ae26fa1b32156..172e9e182cff9404d16f42586a52f615a9ca470c 100644 (file)
@@ -992,3 +992,41 @@ empathy_account_has_uri_scheme_tel (TpAccount *account)
 
   return FALSE;
 }
+
+/* Return the TpContact on @conn associated with @individual, if any */
+TpContact *
+empathy_get_tp_contact_for_individual (FolksIndividual *individual,
+    TpConnection *conn)
+{
+  TpContact *contact = NULL;
+  GeeSet *personas;
+  GeeIterator *iter;
+
+  personas = folks_individual_get_personas (individual);
+  iter = gee_iterable_iterator (GEE_ITERABLE (personas));
+  while (contact == NULL && gee_iterator_next (iter))
+    {
+      TpfPersona *persona = gee_iterator_get (iter);
+      TpConnection *contact_conn;
+      TpContact *contact_cur = NULL;
+
+      if (TPF_IS_PERSONA (persona))
+        {
+          contact_cur = tpf_persona_get_contact (persona);
+          if (contact_cur != NULL)
+            {
+              contact_conn = tp_contact_get_connection (contact_cur);
+
+              if (!tp_strdiff (tp_proxy_get_object_path (contact_conn),
+                    tp_proxy_get_object_path (conn)))
+                contact = contact_cur;
+            }
+        }
+
+      g_clear_object (&persona);
+    }
+  g_clear_object (&iter);
+
+  return contact;
+}
+
index fb25d7a99373f54ed72127088fc1f40d39f8fcef..69a7d628756e790b14b8eb6f6d66cd039a35f54e 100644 (file)
@@ -108,6 +108,9 @@ gchar *empathy_format_currency (gint amount,
 
 gboolean empathy_account_has_uri_scheme_tel (TpAccount *account);
 
+TpContact * empathy_get_tp_contact_for_individual (FolksIndividual *individual,
+    TpConnection *conn);
+
 /* Copied from wocky/wocky-utils.h */
 
 #define empathy_implement_finish_void(source, tag) \
index ec5a275d4f3812b503dffd796407a5016d9e369d..9280dda3274125a9c85aaf4a51418e37e0a7393a 100644 (file)
@@ -14,6 +14,8 @@
 
 #include "empathy-invite-participant-dialog.h"
 
+#include <libempathy/empathy-utils.h>
+
 #include <libempathy-gtk/empathy-contact-chooser.h>
 #include <libempathy-gtk/empathy-individual-view.h>
 #include <libempathy-gtk/empathy-ui-utils.h>
@@ -101,39 +103,11 @@ static TpContact *
 get_tp_contact_for_chat (EmpathyInviteParticipantDialog *self,
     FolksIndividual *individual)
 {
-  TpContact *contact = NULL;
   TpConnection *chat_conn;
-  GeeSet *personas;
-  GeeIterator *iter;
 
   chat_conn = tp_channel_borrow_connection (TP_CHANNEL (self->priv->tp_chat));
 
-  personas = folks_individual_get_personas (individual);
-  iter = gee_iterable_iterator (GEE_ITERABLE (personas));
-  while (contact == FALSE && gee_iterator_next (iter))
-    {
-      TpfPersona *persona = gee_iterator_get (iter);
-      TpConnection *contact_conn;
-      TpContact *contact_cur = NULL;
-
-      if (TPF_IS_PERSONA (persona))
-        {
-          contact_cur = tpf_persona_get_contact (persona);
-          if (contact_cur != NULL)
-            {
-              contact_conn = tp_contact_get_connection (contact_cur);
-
-              if (!tp_strdiff (tp_proxy_get_object_path (contact_conn),
-                    tp_proxy_get_object_path (chat_conn)))
-                contact = contact_cur;
-            }
-        }
-
-      g_clear_object (&persona);
-    }
-  g_clear_object (&iter);
-
-  return contact;
+  return empathy_get_tp_contact_for_individual (individual, chat_conn);
 }
 
 static gboolean