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
|
|
@ -574,16 +574,22 @@ class QuickApp(object):
|
|||
log.debug("new subject for room [%(room_jid)s]: %(subject)s" % {'room_jid': room_jid, "subject": subject})
|
||||
|
||||
def chatStateReceivedHandler(self, from_jid_s, state, profile):
|
||||
"""Called when a new chat state is received.
|
||||
"""Called when a new chat state (XEP-0085) is received.
|
||||
|
||||
@param from_jid_s: JID of the contact who sent his state, or '@ALL@'
|
||||
@param state: new state (string)
|
||||
@profile: current profile
|
||||
@param from_jid_s (unicode): JID of a contact or C.ENTITY_ALL
|
||||
@param state (unicode): new state
|
||||
@param profile (unicode): current profile
|
||||
"""
|
||||
from_jid = jid.JID(from_jid_s) if from_jid_s != C.ENTITY_ALL else C.ENTITY_ALL
|
||||
for widget in self.widgets.getWidgets(quick_chat.QuickChat):
|
||||
if from_jid == C.ENTITY_ALL or from_jid.bare == widget.target.bare:
|
||||
widget.updateChatState(from_jid, state)
|
||||
if profile != widget.profile:
|
||||
continue
|
||||
to_display = C.USER_CHAT_STATES[state] if (state and widget.type == C.CHAT_GROUP) else state
|
||||
if widget.type == C.CHAT_GROUP and from_jid_s == C.ENTITY_ALL:
|
||||
for occupant in [jid.newResource(self.target, nick) for nick in widget.occupants]:
|
||||
widget.updateEntityState(occupant, 'chat_state', to_display)
|
||||
elif from_jid.bare == widget.target.bare: # roster contact or MUC occupant
|
||||
widget.updateEntityState(from_jid, 'chat_state', to_display)
|
||||
|
||||
def personalEventHandler(self, sender, event_type, data):
|
||||
"""Called when a PEP event is received.
|
||||
|
|
|
|||
Loading…
Reference in a new issue