diff browser_side/panels.py @ 223:624a87377412

browser_side, plugin XEP-0085: limit the number of bridge methods calls for "chatStateComposing".
author souliane <souliane@mailoo.org>
date Thu, 26 Sep 2013 11:13:40 +0200
parents 4e6467efd6bf
children 744426c2b699
line wrap: on
line diff
--- a/browser_side/panels.py	Sun Sep 22 20:52:59 2013 +0200
+++ b/browser_side/panels.py	Thu Sep 26 11:13:40 2013 +0200
@@ -45,6 +45,7 @@
 from time import time
 import dialog
 import base_widget
+from plugin_xep_0085 import ChatStateMachine
 from pyjamas import Window
 from __pyjamas__ import doc
 
@@ -212,8 +213,7 @@
     def __onComposing(self):
         """Callback when the user is composing a text."""
         if hasattr(self._selected_cache, "target"):
-            target_s = str(self._selected_cache.target)
-            self.host.bridge.call('chatStateComposing', None, target_s)
+            self._selected_cache.state_machine._onEvent("composing")
 
     def onMouseUp(self, sender, x, y):
         size = (self.getOffsetWidth(), self.getOffsetHeight())
@@ -605,6 +605,7 @@
         self.vpanel.add(self.__body)
         self.addStyleName('chatPanel')
         self.setWidget(self.vpanel)
+        self.state_machine = ChatStateMachine(self.host, str(self.target))
 
     """def doDetachChildren(self):
         #We need to force the use of a panel subclass method here,
@@ -640,6 +641,7 @@
     def onTextEntered(self, text):
         mess_type = "groupchat" if self.type == 'group' else "chat"
         self.host.bridge.call('sendMessage', None, str(self.target), text, '', mess_type)
+        self.state_machine._onEvent("active")
 
     def onQuit(self):
         base_widget.LiberviaWidget.onQuit(self)