+static void
+get_contact_by_id_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)
+{
+ GetContactsData *data = user_data;
+ EmpathyContact *contact = NULL;
+
+ if (n_contacts == 1) {
+ contact = dup_contact_for_tp_contact (data->tp_factory,
+ contacts[0]);
+ }
+ else if (error == NULL) {
+ GHashTableIter iter;
+ gpointer value;
+
+ g_hash_table_iter_init (&iter, failed_id_errors);
+ while (g_hash_table_iter_next (&iter, NULL, &value)) {
+ if (value) {
+ error = value;
+ break;
+ }
+ }
+ }
+
+ if (data->callback.contact_cb) {
+ data->callback.contact_cb (data->tp_factory,
+ contact,
+ error,
+ data->user_data, weak_object);
+ }
+}
+
+void
+empathy_tp_contact_factory_get_from_id (EmpathyTpContactFactory *tp_factory,
+ const gchar *id,
+ EmpathyTpContactFactoryContactCb callback,
+ gpointer user_data,
+ GDestroyNotify destroy,
+ GObject *weak_object)
+{
+ EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
+ GetContactsData *data;
+
+ g_return_if_fail (EMPATHY_IS_TP_CONTACT_FACTORY (tp_factory));
+ g_return_if_fail (id != NULL);
+
+ data = g_slice_new (GetContactsData);
+ data->callback.contact_cb = callback;
+ data->user_data = user_data;
+ data->destroy = destroy;
+ data->tp_factory = g_object_ref (tp_factory);
+ tp_connection_get_contacts_by_id (priv->connection,
+ 1, &id,
+ G_N_ELEMENTS (contact_features),
+ contact_features,
+ get_contact_by_id_cb,
+ data,
+ (GDestroyNotify) get_contacts_data_free,
+ weak_object);
+}
+
+static void
+get_contacts_by_handle_cb (TpConnection *connection,
+ guint n_contacts,
+ TpContact * const *contacts,
+ guint n_failed,
+ const TpHandle *failed,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ GetContactsData *data = user_data;
+ EmpathyContact **empathy_contacts;
+
+ empathy_contacts = contacts_array_new (data->tp_factory,
+ n_contacts, contacts);
+ if (data->callback.handles_cb) {
+ data->callback.handles_cb (data->tp_factory,
+ n_contacts, empathy_contacts,
+ n_failed, failed,
+ error,
+ data->user_data, weak_object);
+ }
+
+ contacts_array_free (n_contacts, empathy_contacts);
+}
+