]> git.0d.be Git - empathy.git/commitdiff
add empathy_ensure_individual_from_tp_contact()
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 10 Feb 2012 13:52:28 +0000 (14:52 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 15 Feb 2012 09:48:22 +0000 (10:48 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=669676

libempathy/empathy-utils.c
libempathy/empathy-utils.h

index 8e3509b025f9cc71ecde40017c61f4e711e6e013..2f4c9eddece5c09d9ab92bb2ed126f9d8cd147c0 100644 (file)
@@ -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;
+}
index ac5fef82066e1b84d082db2bf6a418d7210bd459..5ce8cc8cb42bd23d80ac26ef32325de266fb3184 100644 (file)
@@ -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) \