aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-09-08 23:02:44 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-09-08 23:23:50 +0800
commitad119467cf50c8437a62ba6e6f483eb9032771a9 (patch)
tree218e3f60e970c1fba3b365af43e73d8131c3c9be /libempathy
parentc8b29cfe85216cc692cc7e95c969e3678c153d72 (diff)
downloadgsoc2013-empathy-ad119467cf50c8437a62ba6e6f483eb9032771a9.tar
gsoc2013-empathy-ad119467cf50c8437a62ba6e6f483eb9032771a9.tar.gz
gsoc2013-empathy-ad119467cf50c8437a62ba6e6f483eb9032771a9.tar.bz2
gsoc2013-empathy-ad119467cf50c8437a62ba6e6f483eb9032771a9.tar.lz
gsoc2013-empathy-ad119467cf50c8437a62ba6e6f483eb9032771a9.tar.xz
gsoc2013-empathy-ad119467cf50c8437a62ba6e6f483eb9032771a9.tar.zst
gsoc2013-empathy-ad119467cf50c8437a62ba6e6f483eb9032771a9.zip
factor out empathy_get_tp_contact_for_individual
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-utils.c38
-rw-r--r--libempathy/empathy-utils.h3
2 files changed, 41 insertions, 0 deletions
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index 24fdf97f3..172e9e182 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -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;
+}
+
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
index fb25d7a99..69a7d6287 100644
--- a/libempathy/empathy-utils.h
+++ b/libempathy/empathy-utils.h
@@ -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) \