From 8a541771a297fd390b5dae66340ea3fa2c1f4933 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 31 Mar 2010 17:14:24 +0200 Subject: Use Account.Nickname to set our own alias (#613044) --- libempathy-gtk/empathy-contact-widget.c | 38 +++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index 82a5ac703..138ec215e 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -886,6 +886,29 @@ contact_widget_avatar_changed_cb (EmpathyAvatarChooser *chooser, data, size, mime_type); } +static void +set_nickname_cb (GObject *source, + GAsyncResult *res, + gpointer user_data) +{ + GError *error = NULL; + + if (!tp_account_set_nickname_finish (TP_ACCOUNT (source), res, &error)) + { + DEBUG ("Failed to set Account.Nickname: %s", error->message); + g_error_free (error); + } +} + +static void +set_alias_on_account (TpAccount *account, + const gchar *alias) +{ + DEBUG ("Set Account.Nickname to %s", alias); + + tp_account_set_nickname_async (account, alias, set_nickname_cb, NULL); +} + static gboolean contact_widget_entry_alias_focus_event_cb (GtkEditable *editable, GdkEventFocus *event, @@ -896,8 +919,19 @@ contact_widget_entry_alias_focus_event_cb (GtkEditable *editable, const gchar *alias; alias = gtk_entry_get_text (GTK_ENTRY (editable)); - empathy_tp_contact_factory_set_alias (information->factory, - information->contact, alias); + + if (empathy_contact_is_user (information->contact)) + { + TpAccount * account; + + account = empathy_contact_get_account (information->contact); + set_alias_on_account (account, alias); + } + else + { + empathy_tp_contact_factory_set_alias (information->factory, + information->contact, alias); + } } return FALSE; -- cgit v1.2.3