Mercurial > libervia-web
diff browser_side/base_panels.py @ 407:6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 16 Mar 2014 21:03:50 +0100 |
parents | 41b8b96f2248 |
children | 9977de10b7da |
line wrap: on
line diff
--- a/browser_side/base_panels.py Sun Mar 16 20:55:50 2014 +0100 +++ b/browser_side/base_panels.py Sun Mar 16 21:03:50 2014 +0100 @@ -39,6 +39,7 @@ from html_tools import html_sanitize, html_strip, inlineRoot, convertNewLinesToXHTML +from constants import Const from sat_frontends.tools.strings import addURLToText, addURLToImage from sat.core.i18n import _ @@ -62,15 +63,25 @@ class Occupant(HTML): """Occupant of a MUC room""" - def __init__(self, nick, special=""): + def __init__(self, nick, state=None, special=""): + """ + @param nick: the user nickname + @param state: the user chate state (XEP-0085) + @param special: a string of symbols (e.g: for activities) + """ HTML.__init__(self) self.nick = nick + self._state = state self.special = special self._refresh() def __str__(self): return self.nick + def setState(self, state): + self._state = state + self._refresh() + def addSpecial(self, special): """@param special: unicode""" if special not in self.special: @@ -86,8 +97,9 @@ self._refresh() def _refresh(self): + state = (' %s' % Const.MUC_USER_STATES[self._state]) if self._state else '' special = "" if len(self.special) == 0 else " %s" % self.special - self.setHTML("<div class='occupant'>%s%s</div>" % (html_sanitize(self.nick), special)) + self.setHTML("<div class='occupant'>%s%s%s</div>" % (html_sanitize(self.nick), special, state)) class OccupantsList(AbsolutePanel):