comparison frontends/src/quick_frontend/quick_chat.py @ 2007:19b9d3f8a6c7

plugin XEP-0085, quick_frontends, primitivus: chat states are working again
author Goffi <goffi@goffi.org>
date Sun, 17 Jul 2016 16:47:33 +0200
parents 981e2abbb56c
children b536dd121da1
comparison
equal deleted inserted replaced
2006:0ddf3edf643a 2007:19b9d3f8a6c7
124 if not self.entity: 124 if not self.entity:
125 self.entity = jid.JID(u"{}/{}".format(parent.target.bare, self.nick)), 125 self.entity = jid.JID(u"{}/{}".format(parent.target.bare, self.nick)),
126 self.affiliation = data['affiliation'] 126 self.affiliation = data['affiliation']
127 self.role = data['role'] 127 self.role = data['role']
128 self.widgets = set() # widgets linked to this occupant 128 self.widgets = set() # widgets linked to this occupant
129 self._state = None
129 130
130 @property 131 @property
131 def host(self): 132 def host(self):
132 return self.parent.host 133 return self.parent.host
134
135 @property
136 def state(self):
137 return self._state
138
139 @state.setter
140 def state(self, new_state):
141 self._state = new_state
142 for w in self.widgets:
143 w.updated(["state"])
133 144
134 145
135 class QuickChat(quick_widgets.QuickWidget): 146 class QuickChat(quick_widgets.QuickWidget):
136 147
137 visible_states = ['chat_state'] 148 visible_states = ['chat_state']
405 416
406 @param entity (jid.JID): entity to update 417 @param entity (jid.JID): entity to update
407 """ 418 """
408 raise NotImplementedError 419 raise NotImplementedError
409 420
421 ## events ##
422
423 def onChatState(self, from_jid, state, profile):
424 """A chat state has been received"""
425 if self.type == C.CHAT_GROUP:
426 nick = from_jid.resource
427 try:
428 self.occupants[nick].state = state
429 except KeyError:
430 log.warning(u"{nick} not found in {room}, ignoring new chat state".format(
431 nick=nick, room=self.target.bare))
432
410 433
411 quick_widgets.register(QuickChat) 434 quick_widgets.register(QuickChat)