primitivus: display chat states (with symbols) for MUC participants

This commit is contained in:
souliane 2014-03-17 13:24:55 +01:00
commit 67d15eb488
2 changed files with 80 additions and 41 deletions

View file

@ -496,6 +496,31 @@ class QuickApp(object):
if room_jid in self.chat_wins:
self.chat_wins[room_jid].getGame("Quiz").quizGameTimerRestarted(time_left)
def chatStateReceived(self, from_jid_s, state, profile):
"""Callback when a new chat state is received.
@param from_jid_s: JID of the contact who sent his state, or '@ALL@'
@param state: new state (string)
@profile: current profile
"""
if not self.check_profile(profile):
return
if from_jid_s == '@ALL@':
target = '@ALL@'
nick = Const.ALL_OCCUPANTS
else:
from_jid = JID(from_jid_s)
target = from_jid.bare
nick = from_jid.resource
for bare in self.chat_wins.keys():
if target == '@ALL' or target == bare:
chat_win = self.chat_wins[bare]
if chat_win.type == 'one2one':
chat_win.updateChatState(state)
elif chat_win.type == 'group':
chat_win.updateChatState(state, nick=nick)
def _subscribe_cb(self, answer, data):
entity, profile = data
if answer:

View file

@ -153,3 +153,12 @@ class QuickChat(object):
#No need to raise an error as game are not mandatory
warning(_('getGame is not implemented in this frontend'))
def updateChatState(self, state, nick=None):
"""Set the chat state (XEP-0085) of the contact. Leave nick to None
to set the state for a one2one conversation, or give a nickname or
Const.ALL_OCCUPANTS to set the state of a participant within a MUC.
@param state: the new chat state
@param nick: None for one2one, the MUC user nick or ALL_OCCUPANTS
"""
raise NotImplementedError