quick frontends, primitivus: messageState signal handling

This commit is contained in:
Goffi 2016-08-02 23:11:44 +02:00
commit 2d468f9e94
2 changed files with 38 additions and 0 deletions

View file

@ -254,6 +254,7 @@ class QuickApp(object):
self.registerSignal("mucRoomUserChangedNick", iface="plugin")
self.registerSignal("mucRoomNewSubject", iface="plugin")
self.registerSignal("chatStateReceived", iface="plugin")
self.registerSignal("messageState", iface="plugin")
self.registerSignal("psEvent", iface="plugin")
# FIXME: do it dynamically
@ -491,6 +492,10 @@ class QuickApp(object):
chat_widget.messageNew(uid, timestamp, from_jid, target, msg, subject, type_, extra, profile)
def messageStateHandler(self, uid, status, profile):
for widget in self.widgets.getWidgets(quick_chat.QuickChat, profiles=(profile,)):
widget.onMessageState(uid, status, profile)
def messageSend(self, to_jid, message, subject=None, mess_type="auto", extra=None, callback=None, errback=None, profile_key=C.PROF_KEY_NONE):
if subject is None:
subject = {}

View file

@ -55,6 +55,7 @@ class Message(object):
self.type = type_
self.extra = extra
self.nick = self.getNick(from_jid)
self._status = None
# own_mess is True if message was sent by profile's jid
self.own_mess = (from_jid.resource == self.parent.nick) if self.parent.type == C.CHAT_GROUP else (from_jid.bare == self.host.profiles[profile].whoami.bare)
# is user mentioned here ?
@ -112,6 +113,16 @@ class Message(object):
return contact_list.getCache(entity, 'nick') or contact_list.getCache(entity, 'name') or entity.node or entity
return entity.node or entity
@property
def status(self):
return self._status
@status.setter
def status(self, status):
self._status = status
for w in self.widgets:
w.updated(["status"])
class Occupant(object):
"""Occupant metadata"""
@ -468,5 +479,13 @@ class QuickChat(quick_widgets.QuickWidget):
log.warning(u"{nick} not found in {room}, ignoring new chat state".format(
nick=nick, room=self.target.bare))
def onMessageState(self, uid, status, profile):
try:
mess_data = self.messages[uid]
except KeyError:
pass
else:
mess_data.status = status
quick_widgets.register(QuickChat)