plugin XEP-0085, quick_frontends, primitivus: chat states are working again
This commit is contained in:
parent
3a89365ac2
commit
cc160e03d7
1 changed files with 59 additions and 24 deletions
|
|
@ -126,11 +126,22 @@ class Occupant(object):
|
|||
self.affiliation = data['affiliation']
|
||||
self.role = data['role']
|
||||
self.widgets = set() # widgets linked to this occupant
|
||||
self._state = None
|
||||
|
||||
@property
|
||||
def host(self):
|
||||
return self.parent.host
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
return self._state
|
||||
|
||||
@state.setter
|
||||
def state(self, new_state):
|
||||
self._state = new_state
|
||||
for w in self.widgets:
|
||||
w.updated(["state"])
|
||||
|
||||
|
||||
class QuickChat(quick_widgets.QuickWidget):
|
||||
|
||||
|
|
@ -407,5 +418,17 @@ class QuickChat(quick_widgets.QuickWidget):
|
|||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
## events ##
|
||||
|
||||
def onChatState(self, from_jid, state, profile):
|
||||
"""A chat state has been received"""
|
||||
if self.type == C.CHAT_GROUP:
|
||||
nick = from_jid.resource
|
||||
try:
|
||||
self.occupants[nick].state = state
|
||||
except KeyError:
|
||||
log.warning(u"{nick} not found in {room}, ignoring new chat state".format(
|
||||
nick=nick, room=self.target.bare))
|
||||
|
||||
|
||||
quick_widgets.register(QuickChat)
|
||||
|
|
|
|||
Loading…
Reference in a new issue