aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-05-11 16:23:25 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-05-11 16:26:59 +0800
commit7b02ae3c3a6aee6c02f050e5fd8a31c0c454a467 (patch)
treee2ec8d75df790e71c430207ae1a472670930868e
parent3f172c2a512373ab479602a833400778ade8d4d7 (diff)
downloadgsoc2013-empathy-7b02ae3c3a6aee6c02f050e5fd8a31c0c454a467.tar
gsoc2013-empathy-7b02ae3c3a6aee6c02f050e5fd8a31c0c454a467.tar.gz
gsoc2013-empathy-7b02ae3c3a6aee6c02f050e5fd8a31c0c454a467.tar.bz2
gsoc2013-empathy-7b02ae3c3a6aee6c02f050e5fd8a31c0c454a467.tar.lz
gsoc2013-empathy-7b02ae3c3a6aee6c02f050e5fd8a31c0c454a467.tar.xz
gsoc2013-empathy-7b02ae3c3a6aee6c02f050e5fd8a31c0c454a467.tar.zst
gsoc2013-empathy-7b02ae3c3a6aee6c02f050e5fd8a31c0c454a467.zip
contact-blocking-dialog: use tp_connection_dup_contact_by_id_async()
https://bugzilla.gnome.org/show_bug.cgi?id=675808
-rw-r--r--libempathy-gtk/empathy-contact-blocking-dialog.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/libempathy-gtk/empathy-contact-blocking-dialog.c b/libempathy-gtk/empathy-contact-blocking-dialog.c
index f22da44d7..58d574925 100644
--- a/libempathy-gtk/empathy-contact-blocking-dialog.c
+++ b/libempathy-gtk/empathy-contact-blocking-dialog.c
@@ -299,38 +299,39 @@ block_cb (GObject *source,
}
static void
-block_contact_got_contact (TpConnection *conn,
- guint n_contacts,
- TpContact * const *contacts,
- const gchar * const *requested_ids,
- GHashTable *failed_id_errors,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
+block_contact_got_contact (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
{
- EmpathyContactBlockingDialog *self =
- EMPATHY_CONTACT_BLOCKING_DIALOG (weak_object);
- gchar *id = user_data;
+ EmpathyContactBlockingDialog *self;
+ TpConnection *conn = TP_CONNECTION (source);
+ TpWeakRef *wr = user_data;
+ TpContact *contact;
+ GError *error = NULL;
- if (error != NULL)
- goto error;
+ self = tp_weak_ref_dup_object (wr);
+ if (self == NULL)
+ goto finally;
- error = g_hash_table_lookup (failed_id_errors, id);
- if (error != NULL)
- goto error;
+ contact = tp_connection_dup_contact_by_id_finish (conn, result, &error);
+ if (contact == NULL)
+ {
+ DEBUG ("Error getting contact on %s: %s",
+ get_pretty_conn_name (conn), error->message);
- tp_contact_block_async (contacts[0], FALSE, block_cb, self);
- goto finally;
+ contact_blocking_dialog_set_error (
+ EMPATHY_CONTACT_BLOCKING_DIALOG (self), error);
-error:
- DEBUG ("Error getting contact on %s: %s",
- get_pretty_conn_name (conn), error->message);
+ g_error_free (error);
+ goto finally;
+ }
- contact_blocking_dialog_set_error (
- EMPATHY_CONTACT_BLOCKING_DIALOG (self), error);
+ tp_contact_block_async (contact, FALSE, block_cb, self);
+ g_object_unref (contact);
finally:
- g_free (id);
+ g_clear_object (&self);
+ tp_weak_ref_destroy (wr);
}
static void
@@ -339,17 +340,17 @@ contact_blocking_dialog_add_contact (GtkWidget *widget,
{
TpConnection *conn = empathy_account_chooser_get_connection (
EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser));
- const char *identifiers[2] = { NULL, };
+ const char *identifier;
- identifiers[0] = gtk_entry_get_text (
+ identifier = gtk_entry_get_text (
GTK_ENTRY (self->priv->add_contact_entry));
DEBUG ("Looking up handle for '%s' on %s",
- identifiers[0], get_pretty_conn_name (conn));
+ identifier, get_pretty_conn_name (conn));
- tp_connection_get_contacts_by_id (conn, 1, identifiers,
+ tp_connection_dup_contact_by_id_async (conn, identifier,
0, NULL, block_contact_got_contact,
- g_strdup (identifiers[0]), NULL, G_OBJECT (self));
+ tp_weak_ref_new (self, NULL, NULL));
gtk_entry_set_text (GTK_ENTRY (self->priv->add_contact_entry), "");
gtk_widget_hide (self->priv->info_bar);