[empathy] Use Account.Nickname to set our own alias (#613044)



commit 8a541771a297fd390b5dae66340ea3fa2c1f4933
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Wed Mar 31 17:14:24 2010 +0200

    Use Account.Nickname to set our own alias (#613044)

 libempathy-gtk/empathy-contact-widget.c |   38 +++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c
index 82a5ac7..138ec21 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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]