diff frontends/src/quick_frontend/quick_chat.py @ 2024:01aff34e8873

quick frontends, primitivus: messageState signal handling
author Goffi <goffi@goffi.org>
date Tue, 02 Aug 2016 23:11:44 +0200
parents 88c41a195728
children cdb2591d0b8b
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_chat.py	Thu Jul 28 19:11:31 2016 +0200
+++ b/frontends/src/quick_frontend/quick_chat.py	Tue Aug 02 23:11:44 2016 +0200
@@ -55,6 +55,7 @@
         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 @@
             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 @@
                 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)