[Sugar-devel] [PATCH sugar] Fully update the salut account information when the nick name changes #10749

Simon Schampijer simon at schampijer.de
Wed Mar 16 13:57:17 EDT 2011


Signed-off-by: Simon Schampijer <simon at laptop.org>
---
 src/jarabe/model/neighborhood.py |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/jarabe/model/neighborhood.py b/src/jarabe/model/neighborhood.py
index aef03b8..1394f44 100644
--- a/src/jarabe/model/neighborhood.py
+++ b/src/jarabe/model/neighborhood.py
@@ -695,7 +695,7 @@ class Neighborhood(gobject.GObject):
         if account == self._server_account:
             self._link_local_account.enable()
 
-    def _limit_published_name(nick):
+    def _limit_published_name(self, nick):
         """ Limit the nick name to be only 8 characters maximum
 
         The avahi service name has a 64 character limit. It consists of
@@ -812,10 +812,22 @@ class Neighborhood(gobject.GObject):
         logging.debug('__nick_changed_cb')
 
         nick = client.get_string('/desktop/sugar/user/nick')
-        for account in self._server_account, self._link_local_account:
-            bus = dbus.Bus()
-            obj = bus.get_object(ACCOUNT_MANAGER_SERVICE, account.object_path)
-            obj.Set(ACCOUNT, 'Nickname', nick, dbus_interface=PROPERTIES_IFACE)
+
+        bus = dbus.Bus()
+        account = bus.get_object(ACCOUNT_MANAGER_SERVICE,
+                                 self._server_account.object_path)
+        account.Set(ACCOUNT, 'Nickname', nick, dbus_interface=PROPERTIES_IFACE)
+
+        account = bus.get_object(ACCOUNT_MANAGER_SERVICE,
+                                 self._link_local_account.object_path)
+        account.Set(ACCOUNT, 'Nickname', nick, dbus_interface=PROPERTIES_IFACE)
+        needs_reconnect = account.UpdateParameters( \
+            {'nickname': nick,
+             'published-name': self._limit_published_name(nick)},
+            dbus.Array([], 's'),
+            dbus_interface=ACCOUNT)
+        if needs_reconnect:
+            account.Reconnect()
 
         self._update_jid()
 
-- 
1.7.4



More information about the Sugar-devel mailing list