comparison 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
comparison
equal deleted inserted replaced
222:759fd7386e1e 223:624a87377412
43 from tools import html_sanitize, addURLToText 43 from tools import html_sanitize, addURLToText
44 from datetime import datetime 44 from datetime import datetime
45 from time import time 45 from time import time
46 import dialog 46 import dialog
47 import base_widget 47 import base_widget
48 from plugin_xep_0085 import ChatStateMachine
48 from pyjamas import Window 49 from pyjamas import Window
49 from __pyjamas__ import doc 50 from __pyjamas__ import doc
50 51
51 52
52 class UniBoxPanel(SimplePanel): 53 class UniBoxPanel(SimplePanel):
210 self.__onComposing() 211 self.__onComposing()
211 212
212 def __onComposing(self): 213 def __onComposing(self):
213 """Callback when the user is composing a text.""" 214 """Callback when the user is composing a text."""
214 if hasattr(self._selected_cache, "target"): 215 if hasattr(self._selected_cache, "target"):
215 target_s = str(self._selected_cache.target) 216 self._selected_cache.state_machine._onEvent("composing")
216 self.host.bridge.call('chatStateComposing', None, target_s)
217 217
218 def onMouseUp(self, sender, x, y): 218 def onMouseUp(self, sender, x, y):
219 size = (self.getOffsetWidth(), self.getOffsetHeight()) 219 size = (self.getOffsetWidth(), self.getOffsetHeight())
220 if size != self.__size: 220 if size != self.__size:
221 self.__size = size 221 self.__size = size
603 chat_area.add(self.content_scroll) 603 chat_area.add(self.content_scroll)
604 chat_area.setCellWidth(self.content_scroll, '100%') 604 chat_area.setCellWidth(self.content_scroll, '100%')
605 self.vpanel.add(self.__body) 605 self.vpanel.add(self.__body)
606 self.addStyleName('chatPanel') 606 self.addStyleName('chatPanel')
607 self.setWidget(self.vpanel) 607 self.setWidget(self.vpanel)
608 self.state_machine = ChatStateMachine(self.host, str(self.target))
608 609
609 """def doDetachChildren(self): 610 """def doDetachChildren(self):
610 #We need to force the use of a panel subclass method here, 611 #We need to force the use of a panel subclass method here,
611 #for the same reason as doAttachChildren 612 #for the same reason as doAttachChildren
612 base_widget.ScrollPanelWrapper.doDetachChildren(self) 613 base_widget.ScrollPanelWrapper.doDetachChildren(self)
638 return ("ONE2ONE" if self.type == "one2one" else "GROUP", msg) 639 return ("ONE2ONE" if self.type == "one2one" else "GROUP", msg)
639 640
640 def onTextEntered(self, text): 641 def onTextEntered(self, text):
641 mess_type = "groupchat" if self.type == 'group' else "chat" 642 mess_type = "groupchat" if self.type == 'group' else "chat"
642 self.host.bridge.call('sendMessage', None, str(self.target), text, '', mess_type) 643 self.host.bridge.call('sendMessage', None, str(self.target), text, '', mess_type)
644 self.state_machine._onEvent("active")
643 645
644 def onQuit(self): 646 def onQuit(self):
645 base_widget.LiberviaWidget.onQuit(self) 647 base_widget.LiberviaWidget.onQuit(self)
646 if self.type == 'group': 648 if self.type == 'group':
647 self.host.bridge.call('mucLeave', None, self.target.bare) 649 self.host.bridge.call('mucLeave', None, self.target.bare)