Mercurial > libervia-backend
diff frontends/src/primitivus/chat.py @ 1378:3dae6964c071
quick_frontends, primitivus: move the chat states logic to quick_frontend
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 20 Mar 2015 16:28:19 +0100 |
parents | 017270e6eea4 |
children | b01efa1c0f5e |
line wrap: on
line diff
--- a/frontends/src/primitivus/chat.py Fri Mar 20 16:25:38 2015 +0100 +++ b/frontends/src/primitivus/chat.py Fri Mar 20 16:28:19 2015 +0100 @@ -150,25 +150,29 @@ menu.addMenu(_("Action"), _("Send file"), self.onSendFileRequest) return menu - def updateChatState(self, from_jid, state): - if self.type == C.CHAT_GROUP: - if from_jid == C.ENTITY_ALL: - occupants = self.occupants - else: - nick = from_jid.resource - if not nick: - log.debug("no nick found for chatstate") - return - occupants = [nick] - options = self.present_wid.getAllValues() - for index in xrange(0, len(options)): - nick = options[index].value - if nick in occupants: - options[index] = (nick, '%s %s' % (C.MUC_USER_STATES[state], nick)) - self.present_wid.changeValues(options) - self.host.redraw() - else: - self.title_dynamic = '({})'.format(state) + def setOccupantStates(self, occupant_jid, states): + """Set a MUC occupant's states. + + @param occupant_jid (jid.JID): occupant to update + @param states (dict{unicode: unicode}): new states + """ + options = self.present_wid.getAllValues() + for index in xrange(0, len(options)): + nick = options[index].value + if nick == occupant_jid.resource: + options[index] = (nick, "%s %s" % (u''.join(states.values()), nick)) + self.present_wid.changeValues(options) + break + self.host.redraw() + + def setContactStates(self, contact_jid, states): + """Set a one2one contact's states. + + @param contact_jid (jid.JID): contact + @param states (dict{unicode: unicode}): new states + """ + self.title_dynamic = ' '.join([u'({})'.format(state) for state in states.values()]) + self.host.redraw() def _presentClicked(self, list_wid, clicked_wid): assert self.type == C.CHAT_GROUP