diff frontends/src/primitivus/status.py @ 1417:176de79c8c39

core, plugin XEP-0045, frontends: change frontend method "setStatusOnline" for "setPresenceStatus": - remove parameter "online" (can be guess from "presence" value) - process "statuses" dict in quick_frontend, so this method can get a simple unicode "status" - add C.PRESENCE_STATUSES_DEFAULT to define the key to use for fallback status
author souliane <souliane@mailoo.org>
date Mon, 20 Apr 2015 16:39:38 +0200
parents 069ad98b360d
children b06047e1c1fb
line wrap: on
line diff
--- a/frontends/src/primitivus/status.py	Sat Apr 18 00:27:39 2015 +0200
+++ b/frontends/src/primitivus/status.py	Mon Apr 20 16:39:38 2015 +0200
@@ -21,7 +21,7 @@
 import urwid
 from urwid_satext import sat_widgets
 from sat_frontends.quick_frontend.constants import Const as commonConst
-from sat_frontends.primitivus.constants import Const
+from sat_frontends.primitivus.constants import Const as C
 
 
 class StatusBar(urwid.Columns):
@@ -32,7 +32,7 @@
         status_prefix = urwid.Text('[')
         status_suffix = urwid.Text(']')
         self.status = sat_widgets.ClickableText('')
-        self.setPresenceStatus('unavailable', '')
+        self.setPresenceStatus(C.PRESENCE_UNAVAILABLE, '')
         urwid.Columns.__init__(self, [('weight', 1, self.presence), ('weight', 1, status_prefix),
                                       ('weight', 9, self.status), ('weight', 1, status_suffix)])
         urwid.connect_signal(self.presence, 'click', self.onPresenceClick)
@@ -55,19 +55,20 @@
 
     def onChange(self, sender=None, user_data=None):
         new_value = user_data.get_text()
-        previous = ([key for key in Const.PRESENCE if Const.PRESENCE[key][0] == self.presence.get_text()][0], self.status.get_text())
+        previous = ([key for key in C.PRESENCE if C.PRESENCE[key][0] == self.presence.get_text()][0], self.status.get_text())
         if isinstance(user_data, sat_widgets.ClickableText):
             new = ([key for key in commonConst.PRESENCE if commonConst.PRESENCE[key] == new_value][0], previous[1])
         elif isinstance(user_data, sat_widgets.AdvancedEdit):
             new = (previous[0], new_value[0])
         if new != previous:
             for profile in self.host.profiles:  # FIXME: for now all the profiles share the same status
-                self.host.bridge.setPresence(show=new[0], statuses={'default': new[1]}, profile_key=profile)  # FIXME: manage multilingual statuses
+                self.host.bridge.setPresence(show=new[0], status=new[1], profile_key=profile)  # FIXME: manage multilingual statuses
             self.setPresenceStatus(new[0], new[1])
         self.host.removePopUp()
 
     def setPresenceStatus(self, show, status):
-        show_icon, show_attr = Const.PRESENCE.get(show)
+        show_icon, show_attr = C.PRESENCE.get(show)
         self.presence.set_text(('show_normal', show_icon))
-        self.status.set_text((show_attr, status))
+        if status is not None:
+            self.status.set_text((show_attr, status))
         self.host.redraw()