diff src/browser/sat_browser/chat.py @ 944:5d9f6d25c586

browser: various fixes this is a first pass to fix main Libervia features which have been broken with changes in backend: - fixed Chat signature - added/removed/replaced a couple of missing methods - use contact_list_widget instead of contact_list when needed
author Goffi <goffi@goffi.org>
date Fri, 19 May 2017 17:03:04 +0200
parents 0c0551967bdf
children fd4eae654182
line wrap: on
line diff
--- a/src/browser/sat_browser/chat.py	Fri May 19 13:54:49 2017 +0200
+++ b/src/browser/sat_browser/chat.py	Fri May 19 17:03:04 2017 +0200
@@ -94,14 +94,14 @@
 
 class Chat(QuickChat, libervia_widget.LiberviaWidget, KeyboardHandler):
 
-    def __init__(self, host, target, type_=C.CHAT_ONE2ONE, profiles=None):
+    def __init__(self, host, target, type_=C.CHAT_ONE2ONE, nick=None, occupants=None, subject=None, profiles=None):
         """Panel used for conversation (one 2 one or group chat)
 
         @param host: SatWebFrontend instance
         @param target: entity (jid.JID) with who we have a conversation (contact's jid for one 2 one chat, or MUC room)
         @param type: one2one for simple conversation, group for MUC
         """
-        QuickChat.__init__(self, host, target, type_, profiles=profiles)
+        QuickChat.__init__(self, host, target, type_, nick, occupants, subject, profiles=profiles)
         self.vpanel = VerticalPanel()
         self.vpanel.setSize('100%', '100%')
 
@@ -127,6 +127,9 @@
             host.addListener('avatar', self.avatarListener, [C.PROF_KEY_NONE])
             Window.addWindowResizeListener(self)
 
+        else:
+            self.chat_state = None
+
         self._body.add(chat_area)
         self.content = AbsolutePanel()
         self.content.setStyleName('chatContent')
@@ -283,14 +286,19 @@
             title += ' %s' % extra
         libervia_widget.LiberviaWidget.setTitle(self, title)
 
+    def onChatState(self, from_jid, state, profile):
+        super(Chat, self).onChatState(from_jid, state, profile)
+        if self.type == C.CHAT_ONE2ONE:
+            self.title_dynamic = C.CHAT_STATE_ICON[state]
+
     def update(self, entity=None):
         """Update one or all entities.
 
         @param entity (jid.JID): entity to update
         """
-        states = self.getEntityStates(self.target)
         if self.type == C.CHAT_ONE2ONE:  # only update the chat title
-            self.setTitle(extra=' '.join([u'({})'.format(value) for value in states.values()]))
+            if self.chat_state:
+                self.setTitle(extra='({})'.format(self.chat_state))
         else:
             if entity is None:  # rebuild all the occupants list
                 nicks = list(self.occupants)
@@ -302,11 +310,14 @@
                 if show == C.PRESENCE_UNAVAILABLE or show is None:
                     self.occupants_panel.removeContactBox(entity)
                 else:
-                    box = self.occupants_panel.updateContactBox(entity)
-                    box.states.setHTML(u''.join(states.values()))
+                    pass
+                    # FIXME: legacy code, chat state must be checked
+                    # box = self.occupants_panel.updateContactBox(entity)
+                    # box.states.setHTML(u''.join(states.values()))
 
-        if 'chat_state' in states.keys():  # start/stop sending "composing" state from now
-            self.chat_state_machine.started = not not states['chat_state']
+        # FIXME: legacy code, chat state must be checked
+        # if 'chat_state' in states.keys():  # start/stop sending "composing" state from now
+        #     self.chat_state_machine.started = not not states['chat_state']
 
         self.onWindowResized()  # be sure to set the good height