From b014019bb9303a17c5ca4d10ef25f3d60f71dab2 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 22 May 2012 14:54:56 +0200 Subject: factor out empathy_individual_get_client_types() --- libempathy/empathy-utils.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'libempathy/empathy-utils.c') diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index c73f6514e..30d40e9a5 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -1231,3 +1231,45 @@ empathy_ensure_individual_from_tp_contact (TpContact *contact) g_object_unref (persona); return individual; } + +const gchar * const * +empathy_individual_get_client_types (FolksIndividual *individual) +{ + GeeSet *personas; + GeeIterator *iter; + const gchar * const *types = NULL; + FolksPresenceType presence_type = FOLKS_PRESENCE_TYPE_UNSET; + + personas = folks_individual_get_personas (individual); + iter = gee_iterable_iterator (GEE_ITERABLE (personas)); + while (gee_iterator_next (iter)) + { + FolksPresenceDetails *presence; + FolksPersona *persona = gee_iterator_get (iter); + + /* We only want personas which have presence and a TpContact */ + if (!empathy_folks_persona_is_interesting (persona)) + goto while_finish; + + presence = FOLKS_PRESENCE_DETAILS (persona); + + if (folks_presence_details_typecmp ( + folks_presence_details_get_presence_type (presence), + presence_type) > 0) + { + TpContact *tp_contact; + + presence_type = folks_presence_details_get_presence_type (presence); + + tp_contact = tpf_persona_get_contact (TPF_PERSONA (persona)); + if (tp_contact != NULL) + types = tp_contact_get_client_types (tp_contact); + } + +while_finish: + g_clear_object (&persona); + } + g_clear_object (&iter); + + return types; +} -- cgit v1.2.3