694
694
!tp_strdiff (tp_proxy_get_object_path (data->account), path);
698
get_contacts_cb (TpConnection *connection,
700
TpContact * const *contacts,
701
const gchar * const *requested_ids,
702
GHashTable *failed_id_errors,
705
GObject *weak_object)
707
EmpathyContact *self = (EmpathyContact *) weak_object;
708
EmpathyContactPriv *priv = GET_PRIV (self);
709
TpContact *tp_contact;
714
tp_contact = contacts[0];
716
g_return_if_fail (priv->tp_contact == NULL);
717
priv->tp_contact = g_object_ref (tp_contact);
718
g_object_notify (G_OBJECT (self), "tp-contact");
720
/* Update capabilities now that we have a TpContact */
721
set_capabilities_from_tp_caps (self,
722
tp_contact_get_capabilities (tp_contact));
698
726
empathy_contact_from_tpl_contact (TpAccount *account,
699
727
TplEntity *tpl_entity)
727
758
is_user = (TPL_ENTITY_SELF == tpl_entity_get_entity_type (tpl_entity));
760
id = tpl_entity_get_identifier (tpl_entity);
729
762
retval = g_object_new (EMPATHY_TYPE_CONTACT,
730
"id", tpl_entity_get_identifier (tpl_entity),
731
764
"alias", tpl_entity_get_alias (tpl_entity),
732
765
"account", account,
733
766
"is-user", is_user,
769
/* Try to get a TpContact associated to have at least contact
770
* capabilities if possible. This is useful for CM supporting calling
771
* offline contacts for example. */
772
conn = tp_account_get_connection (account);
775
TpContactFeature features[] = { TP_CONTACT_FEATURE_CAPABILITIES };
776
conn = tp_account_get_connection (account);
778
tp_connection_get_contacts_by_id (conn, 1, &id,
779
G_N_ELEMENTS (features), features, get_contacts_cb,
780
NULL, NULL, G_OBJECT (retval));
737
784
if (!EMP_STR_EMPTY (tpl_entity_get_avatar_token (tpl_entity)))
957
1004
if (priv->persona == NULL && priv->tp_contact != NULL)
959
/* FIXME: This is disgustingly slow */
960
/* Query for the persona */
961
EmpathyIndividualManager *manager;
962
GList *individuals, *l;
964
manager = empathy_individual_manager_dup_singleton ();
965
individuals = empathy_individual_manager_get_members (manager);
967
for (l = individuals; l != NULL; l = l->next)
1006
TpfPersona *persona;
1008
persona = tpf_persona_dup_for_contact (priv->tp_contact);
1009
if (persona != NULL)
969
FolksIndividual *individual = FOLKS_INDIVIDUAL (l->data);
972
gboolean persona_found = FALSE;
974
personas = folks_individual_get_personas (individual);
975
iter = gee_iterable_iterator (GEE_ITERABLE (personas));
976
while (!persona_found && gee_iterator_next (iter))
978
TpfPersona *persona = gee_iterator_get (iter);
980
if (empathy_folks_persona_is_interesting (FOLKS_PERSONA (persona)))
982
TpContact *tp_contact = tpf_persona_get_contact (persona);
984
if (tp_contact == priv->tp_contact)
986
/* Found the right persona */
987
empathy_contact_set_persona (contact,
988
(FolksPersona *) persona);
989
persona_found = TRUE;
991
g_clear_object (&persona);
994
g_clear_object (&iter);
1011
empathy_contact_set_persona (contact, (FolksPersona *) persona);
1012
g_object_unref (persona);
997
g_list_free (individuals);
998
g_object_unref (manager);
1001
1016
return priv->persona;