#include <glib/gi18n-lib.h>
-#include <telepathy-glib/account-manager.h>
-#include <telepathy-glib/interfaces.h>
-#include <telepathy-glib/util.h>
-
#include <folks/folks.h>
#include <folks/folks-telepathy.h>
guint handle;
EmpathyCapabilities capabilities;
gboolean is_user;
- guint hash;
/* Location is composed of string keys and GValues.
* Example: a "city" key would have "Helsinki" as string GValue,
* a "latitude" would have 65.0 as double GValue.
EmpathyContact *contact = (EmpathyContact *) object;
EmpathyContactPriv *priv = GET_PRIV (contact);
GHashTable *location;
- TpHandle self_handle;
- TpHandle handle;
+ TpContact *self_contact;
const gchar * const *client_types;
if (priv->tp_contact == NULL)
/* Set is-user property. Note that it could still be the handle is
* different from the connection's self handle, in the case the handle
* comes from a group interface. */
- self_handle = tp_connection_get_self_handle (
+ self_contact = tp_connection_get_self_contact (
tp_contact_get_connection (priv->tp_contact));
- handle = tp_contact_get_handle (priv->tp_contact);
- empathy_contact_set_is_user (contact, self_handle == handle);
+ empathy_contact_set_is_user (contact, self_contact == priv->tp_contact);
g_signal_connect (priv->tp_contact, "notify",
G_CALLBACK (tp_contact_notify_cb), contact);
g_clear_object (&priv->groups);
g_free (priv->alias);
+ g_free (priv->logged_alias);
g_free (priv->id);
g_strfreev (priv->client_types);
}
static void
-get_contacts_cb (TpConnection *connection,
- guint n_contacts,
- TpContact * const *contacts,
- const gchar * const *requested_ids,
- GHashTable *failed_id_errors,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyContact *self = (EmpathyContact *) weak_object;
- EmpathyContactPriv *priv = GET_PRIV (self);
- TpContact *tp_contact;
+get_contacts_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ TpWeakRef *wr = user_data;
+ EmpathyContactPriv *priv;
+ EmpathyContact *self;
- if (n_contacts != 1)
- return;
+ self = tp_weak_ref_dup_object (wr);
+ if (self == NULL)
+ goto out;
- tp_contact = contacts[0];
+ priv = GET_PRIV (self);
g_return_if_fail (priv->tp_contact == NULL);
- priv->tp_contact = g_object_ref (tp_contact);
+
+ priv->tp_contact = tp_connection_dup_contact_by_id_finish (
+ TP_CONNECTION (source), result, NULL);
+ if (priv->tp_contact == NULL)
+ goto out;
+
g_object_notify (G_OBJECT (self), "tp-contact");
/* Update capabilities now that we have a TpContact */
set_capabilities_from_tp_caps (self,
- tp_contact_get_capabilities (tp_contact));
+ tp_contact_get_capabilities (priv->tp_contact));
+
+out:
+ g_clear_object (&self);
+ tp_weak_ref_destroy (wr);
}
EmpathyContact *
TpContactFeature features[] = { TP_CONTACT_FEATURE_CAPABILITIES };
conn = tp_account_get_connection (account);
- tp_connection_get_contacts_by_id (conn, 1, &id,
+ tp_connection_dup_contact_by_id_async (conn, id,
G_N_ELEMENTS (features), features, get_contacts_cb,
- NULL, NULL, G_OBJECT (retval));
+ tp_weak_ref_new (retval, NULL, NULL));
}
}
avatar_path = g_build_filename (g_get_user_cache_dir (),
"telepathy",
"avatars",
- tp_account_get_connection_manager (account),
- tp_account_get_protocol (account),
+ tp_account_get_cm_name (account),
+ tp_account_get_protocol_name (account),
NULL);
g_mkdir_with_parents (avatar_path, 0700);
tp_caps_to_capabilities (TpCapabilities *caps)
{
EmpathyCapabilities capabilities = 0;
- guint i;
- GPtrArray *classes;
if (tp_capabilities_supports_file_transfer (caps))
capabilities |= EMPATHY_CAPABILITIES_FT;
capabilities |= EMPATHY_CAPABILITIES_AUDIO;
}
- classes = tp_capabilities_get_channel_classes (caps);
-
- for (i = 0; i < classes->len; i++)
- {
- GValueArray *class_struct;
- GHashTable *fixed_prop;
- GStrv allowed_prop;
- TpHandleType handle_type;
- const gchar *chan_type;
-
- class_struct = g_ptr_array_index (classes, i);
- tp_value_array_unpack (class_struct, 2,
- &fixed_prop,
- &allowed_prop);
-
- handle_type = tp_asv_get_uint32 (fixed_prop,
- TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, NULL);
- if (handle_type != TP_HANDLE_TYPE_CONTACT)
- continue;
-
- chan_type = tp_asv_get_string (fixed_prop,
- TP_PROP_CHANNEL_CHANNEL_TYPE);
-
- if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_TEXT))
- {
- if (tp_asv_get_boolean (fixed_prop,
- TP_PROP_CHANNEL_INTERFACE_SMS_SMS_CHANNEL, NULL))
- capabilities |= EMPATHY_CAPABILITIES_SMS;
- }
- }
+ if (tp_capabilities_supports_sms (caps))
+ capabilities |= EMPATHY_CAPABILITIES_SMS;
return capabilities;
}