From ef0d55ead126f53aa4544877d2df5ab712f00f28 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 4 Nov 2011 13:45:38 +0100 Subject: factor out empathy_create_individual_from_tp_contact() https://bugzilla.gnome.org/show_bug.cgi?id=663387 --- libempathy/empathy-utils.c | 32 ++++++++++++++++++++++++++++++++ libempathy/empathy-utils.h | 3 +++ 2 files changed, 35 insertions(+) (limited to 'libempathy') diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index 83fe4ce7e..972abe65e 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -1163,3 +1163,35 @@ empathy_sasl_channel_supports_mechanism (TpChannel *channel, return tp_strv_contains (available_mechanisms, mechanism); } + +FolksIndividual * +empathy_create_individual_from_tp_contact (TpContact *contact) +{ + TpAccount *account; + TpConnection *connection; + TpfPersonaStore *store; + GeeSet *personas; + TpfPersona *persona; + FolksIndividual *individual; + + connection = tp_contact_get_connection (contact); + account = tp_connection_get_account (connection); + + store = tpf_persona_store_new (account); + + personas = GEE_SET ( + gee_hash_set_new (FOLKS_TYPE_PERSONA, g_object_ref, g_object_unref, + g_direct_hash, g_direct_equal)); + + persona = tpf_persona_new (contact, store); + + gee_collection_add (GEE_COLLECTION (personas), persona); + + individual = folks_individual_new (personas); + + g_clear_object (&persona); + g_clear_object (&personas); + g_object_unref (store); + + return individual; +} diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h index f8d47ec8a..ac5fef820 100644 --- a/libempathy/empathy-utils.h +++ b/libempathy/empathy-utils.h @@ -121,6 +121,9 @@ void empathy_individual_can_audio_video_call (FolksIndividual *individual, gboolean empathy_sasl_channel_supports_mechanism (TpChannel *channel, const gchar *mechanism); +FolksIndividual * empathy_create_individual_from_tp_contact ( + TpContact *contact); + /* Copied from wocky/wocky-utils.h */ #define empathy_implement_finish_void(source, tag) \ -- cgit v1.2.3