aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-02-10 21:52:28 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-02-15 17:48:22 +0800
commit54bd693510f9aa2c1791d8ccf51f2b0371c66a3a (patch)
treee7e5e619df43513fb2c06e37196b12881da9f91b
parent894ce49de11658ae2b66907bf609f0e6810acb3e (diff)
downloadgsoc2013-empathy-54bd693510f9aa2c1791d8ccf51f2b0371c66a3a.tar
gsoc2013-empathy-54bd693510f9aa2c1791d8ccf51f2b0371c66a3a.tar.gz
gsoc2013-empathy-54bd693510f9aa2c1791d8ccf51f2b0371c66a3a.tar.bz2
gsoc2013-empathy-54bd693510f9aa2c1791d8ccf51f2b0371c66a3a.tar.lz
gsoc2013-empathy-54bd693510f9aa2c1791d8ccf51f2b0371c66a3a.tar.xz
gsoc2013-empathy-54bd693510f9aa2c1791d8ccf51f2b0371c66a3a.tar.zst
gsoc2013-empathy-54bd693510f9aa2c1791d8ccf51f2b0371c66a3a.zip
add empathy_ensure_individual_from_tp_contact()
https://bugzilla.gnome.org/show_bug.cgi?id=669676
-rw-r--r--libempathy/empathy-utils.c20
-rw-r--r--libempathy/empathy-utils.h3
2 files changed, 23 insertions, 0 deletions
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index 8e3509b02..2f4c9edde 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -1195,3 +1195,23 @@ empathy_create_individual_from_tp_contact (TpContact *contact)
return individual;
}
+
+/* Look for a FolksIndividual containing @contact as one of his persona
+ * and create one if needed */
+FolksIndividual *
+empathy_ensure_individual_from_tp_contact (TpContact *contact)
+{
+ EmpathyIndividualManager *mgr;
+ FolksIndividual *individual;
+
+ mgr = empathy_individual_manager_dup_singleton ();
+ individual = empathy_individual_manager_lookup_by_contact (mgr, contact);
+
+ if (individual != NULL)
+ g_object_ref (individual);
+ else
+ individual = empathy_create_individual_from_tp_contact (contact);
+
+ g_object_unref (mgr);
+ return individual;
+}
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
index ac5fef820..5ce8cc8cb 100644
--- a/libempathy/empathy-utils.h
+++ b/libempathy/empathy-utils.h
@@ -124,6 +124,9 @@ gboolean empathy_sasl_channel_supports_mechanism (TpChannel *channel,
FolksIndividual * empathy_create_individual_from_tp_contact (
TpContact *contact);
+FolksIndividual * empathy_ensure_individual_from_tp_contact (
+ TpContact *contact);
+
/* Copied from wocky/wocky-utils.h */
#define empathy_implement_finish_void(source, tag) \