Mercurial > libervia-backend
comparison frontends/src/quick_frontend/quick_app.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 | 8aa32bcc3a9c |
comparison
equal
deleted
inserted
replaced
1377:017270e6eea4 | 1378:3dae6964c071 |
---|---|
572 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile) | 572 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile) |
573 chat_widget.setSubject(subject) | 573 chat_widget.setSubject(subject) |
574 log.debug("new subject for room [%(room_jid)s]: %(subject)s" % {'room_jid': room_jid, "subject": subject}) | 574 log.debug("new subject for room [%(room_jid)s]: %(subject)s" % {'room_jid': room_jid, "subject": subject}) |
575 | 575 |
576 def chatStateReceivedHandler(self, from_jid_s, state, profile): | 576 def chatStateReceivedHandler(self, from_jid_s, state, profile): |
577 """Called when a new chat state is received. | 577 """Called when a new chat state (XEP-0085) is received. |
578 | 578 |
579 @param from_jid_s: JID of the contact who sent his state, or '@ALL@' | 579 @param from_jid_s (unicode): JID of a contact or C.ENTITY_ALL |
580 @param state: new state (string) | 580 @param state (unicode): new state |
581 @profile: current profile | 581 @param profile (unicode): current profile |
582 """ | 582 """ |
583 from_jid = jid.JID(from_jid_s) if from_jid_s != C.ENTITY_ALL else C.ENTITY_ALL | 583 from_jid = jid.JID(from_jid_s) if from_jid_s != C.ENTITY_ALL else C.ENTITY_ALL |
584 for widget in self.widgets.getWidgets(quick_chat.QuickChat): | 584 for widget in self.widgets.getWidgets(quick_chat.QuickChat): |
585 if from_jid == C.ENTITY_ALL or from_jid.bare == widget.target.bare: | 585 if profile != widget.profile: |
586 widget.updateChatState(from_jid, state) | 586 continue |
587 to_display = C.USER_CHAT_STATES[state] if (state and widget.type == C.CHAT_GROUP) else state | |
588 if widget.type == C.CHAT_GROUP and from_jid_s == C.ENTITY_ALL: | |
589 for occupant in [jid.newResource(self.target, nick) for nick in widget.occupants]: | |
590 widget.updateEntityState(occupant, 'chat_state', to_display) | |
591 elif from_jid.bare == widget.target.bare: # roster contact or MUC occupant | |
592 widget.updateEntityState(from_jid, 'chat_state', to_display) | |
587 | 593 |
588 def personalEventHandler(self, sender, event_type, data): | 594 def personalEventHandler(self, sender, event_type, data): |
589 """Called when a PEP event is received. | 595 """Called when a PEP event is received. |
590 | 596 |
591 @param sender (jid.JID): event sender | 597 @param sender (jid.JID): event sender |