quick_frontends, primitivus: move the chat states logic to quick_frontend
This commit is contained in:
parent
c6419871ac
commit
14f4b4b8ec
1 changed files with 70 additions and 35 deletions
|
|
@ -150,25 +150,29 @@ class Chat(PrimitivusWidget, QuickChat):
|
|||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue