comparison frontends/src/quick_frontend/quick_app.py @ 1388:a025242bebe7

quick_frontend, primitivus: remove QuickChat.updateEntityState and QuickChat.setContactStates, use more general QuickChat.update (also called when joining the room to initialise the occupants list)
author souliane <souliane@mailoo.org>
date Tue, 24 Mar 2015 17:31:08 +0100
parents 1f3513cfb246
children 1276e6a0716b
comparison
equal deleted inserted replaced
1387:3511ff4b40a0 1388:a025242bebe7
532 log.debug("Room [%(room_jid)s] joined by %(profile)s, users presents:%(users)s" % {'room_jid': room_jid_s, 'profile': profile, 'users': room_nicks}) 532 log.debug("Room [%(room_jid)s] joined by %(profile)s, users presents:%(users)s" % {'room_jid': room_jid_s, 'profile': profile, 'users': room_nicks})
533 room_jid = jid.JID(room_jid_s) 533 room_jid = jid.JID(room_jid_s)
534 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile) 534 chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile)
535 chat_widget.setUserNick(unicode(user_nick)) 535 chat_widget.setUserNick(unicode(user_nick))
536 self.contact_lists[profile].setSpecial(room_jid, C.CONTACT_SPECIAL_GROUP) 536 self.contact_lists[profile].setSpecial(room_jid, C.CONTACT_SPECIAL_GROUP)
537 chat_widget.update()
537 538
538 def roomLeftHandler(self, room_jid_s, profile): 539 def roomLeftHandler(self, room_jid_s, profile):
539 """Called when a MUC room is left""" 540 """Called when a MUC room is left"""
540 log.debug("Room [%(room_jid)s] left by %(profile)s" % {'room_jid': room_jid_s, 'profile': profile}) 541 log.debug("Room [%(room_jid)s] left by %(profile)s" % {'room_jid': room_jid_s, 'profile': profile})
541 room_jid = jid.JID(room_jid_s) 542 room_jid = jid.JID(room_jid_s)
577 578
578 @param from_jid_s (unicode): JID of a contact or C.ENTITY_ALL 579 @param from_jid_s (unicode): JID of a contact or C.ENTITY_ALL
579 @param state (unicode): new state 580 @param state (unicode): new state
580 @param profile (unicode): current profile 581 @param profile (unicode): current profile
581 """ 582 """
583 log.debug(_(u"Received new chat state {} from {} [{}]").format(state, from_jid_s, profile))
582 from_jid = jid.JID(from_jid_s) if from_jid_s != C.ENTITY_ALL else C.ENTITY_ALL 584 from_jid = jid.JID(from_jid_s) if from_jid_s != C.ENTITY_ALL else C.ENTITY_ALL
585 contact_list = self.contact_lists[profile]
583 for widget in self.widgets.getWidgets(quick_chat.QuickChat): 586 for widget in self.widgets.getWidgets(quick_chat.QuickChat):
584 if profile != widget.profile: 587 if profile != widget.profile:
585 continue 588 continue
586 to_display = C.USER_CHAT_STATES[state] if (state and widget.type == C.CHAT_GROUP) else state 589 to_display = C.USER_CHAT_STATES[state] if (state and widget.type == C.CHAT_GROUP) else state
587 if widget.type == C.CHAT_GROUP and from_jid_s == C.ENTITY_ALL: 590 if widget.type == C.CHAT_GROUP and from_jid_s == C.ENTITY_ALL:
588 for occupant in [jid.newResource(widget.target, nick) for nick in widget.occupants]: 591 for occupant in [jid.newResource(widget.target, nick) for nick in widget.occupants]:
589 widget.updateEntityState(occupant, 'chat_state', to_display) 592 contact_list.setCache(occupant, 'chat_state', to_display)
593 widget.update(occupant)
590 elif from_jid.bare == widget.target.bare: # roster contact or MUC occupant 594 elif from_jid.bare == widget.target.bare: # roster contact or MUC occupant
591 widget.updateEntityState(from_jid, 'chat_state', to_display) 595 contact_list.setCache(from_jid, 'chat_state', to_display)
596 widget.update(from_jid)
592 597
593 def personalEventHandler(self, sender, event_type, data): 598 def personalEventHandler(self, sender, event_type, data):
594 """Called when a PEP event is received. 599 """Called when a PEP event is received.
595 600
596 @param sender (jid.JID): event sender 601 @param sender (jid.JID): event sender