From 54bd693510f9aa2c1791d8ccf51f2b0371c66a3a Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 10 Feb 2012 14:52:28 +0100 Subject: add empathy_ensure_individual_from_tp_contact() https://bugzilla.gnome.org/show_bug.cgi?id=669676 --- libempathy/empathy-utils.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libempathy/empathy-utils.c') 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; +} -- cgit v1.2.3