static void aggregator_add_persona_from_details_cb (GObject *source, GAsyncResult *result, gpointer user_data) { FolksIndividualAggregator *aggregator = FOLKS_INDIVIDUAL_AGGREGATOR (source); EmpathyContact *contact = EMPATHY_CONTACT (user_data); FolksPersona *persona; GError *error = NULL; persona = folks_individual_aggregator_add_persona_from_details_finish ( aggregator, result, &error); if (error != NULL) { g_warning ("failed to add individual from contact: %s", error->message); g_clear_error (&error); } /* The persona can be NULL even if there wasn't an error, if the persona was * already in the contact list */ if (persona != NULL) { /* Set the contact's persona */ empathy_contact_set_persona (contact, persona); g_object_unref (persona); } g_object_unref (contact); }
/* Calculate whether the Individual can do audio or video calls. * FIXME: We can remove this once libfolks has grown capabilities support * again: bgo#626179. */ void empathy_individual_can_audio_video_call (FolksIndividual *individual, gboolean *can_audio_call, gboolean *can_video_call, EmpathyContact **out_contact) { GeeSet *personas; GeeIterator *iter; gboolean can_audio = FALSE, can_video = FALSE; personas = folks_individual_get_personas (individual); iter = gee_iterable_iterator (GEE_ITERABLE (personas)); while (gee_iterator_next (iter)) { FolksPersona *persona = gee_iterator_get (iter); TpContact *tp_contact; if (!empathy_folks_persona_is_interesting (persona)) goto while_finish; tp_contact = tpf_persona_get_contact (TPF_PERSONA (persona)); if (tp_contact != NULL) { EmpathyContact *contact; contact = empathy_contact_dup_from_tp_contact (tp_contact); empathy_contact_set_persona (contact, persona); can_audio = can_audio || empathy_contact_get_capabilities (contact) & EMPATHY_CAPABILITIES_AUDIO; can_video = can_video || empathy_contact_get_capabilities (contact) & EMPATHY_CAPABILITIES_VIDEO; if (out_contact != NULL) *out_contact = g_object_ref (contact); g_object_unref (contact); } while_finish: g_clear_object (&persona); if (can_audio && can_video) break; } g_clear_object (&iter); if (can_audio_call != NULL) *can_audio_call = can_audio; if (can_video_call != NULL) *can_video_call = can_video; }
/* Retrieve the EmpathyContact corresponding to the first TpContact contained * within the given Individual. Note that this is a temporary convenience. See * the TODO above. */ EmpathyContact * empathy_contact_dup_from_folks_individual (FolksIndividual *individual) { GeeSet *personas; GeeIterator *iter; EmpathyContact *contact = NULL; g_return_val_if_fail (FOLKS_IS_INDIVIDUAL (individual), NULL); personas = folks_individual_get_personas (individual); iter = gee_iterable_iterator (GEE_ITERABLE (personas)); while (gee_iterator_next (iter) && (contact == NULL)) { TpfPersona *persona = gee_iterator_get (iter); if (empathy_folks_persona_is_interesting (FOLKS_PERSONA (persona))) { TpContact *tp_contact; tp_contact = tpf_persona_get_contact (persona); if (tp_contact != NULL) { contact = empathy_contact_dup_from_tp_contact (tp_contact); empathy_contact_set_persona (contact, FOLKS_PERSONA (persona)); } } g_clear_object (&persona); } g_clear_object (&iter); if (contact == NULL) { DEBUG ("Can't create an EmpathyContact for Individual %s", folks_individual_get_id (individual)); } return contact; }