# HG changeset patch # User souliane # Date 1413980237 -7200 # Node ID c6380dd3060212d89218abb5c1fc759efe23852b # Parent 1c1dbe03d3c60a0e43ff594ca7d49a064746d00f plugin XEP-0085: follow the changes in sat plugin diff -r 1c1dbe03d3c6 -r c6380dd30602 src/browser/sat_browser/plugin_xep_0085.py --- a/src/browser/sat_browser/plugin_xep_0085.py Mon Oct 20 10:00:44 2014 +0200 +++ b/src/browser/sat_browser/plugin_xep_0085.py Wed Oct 22 14:17:17 2014 +0200 @@ -46,7 +46,8 @@ self.timer = None def _onEvent(self, state): - """Pyjamas callback takes no extra argument so we need this trick""" + # Pyjamas callback takes no extra argument so we need this trick + # Here we should check the value of the parameter "Send chat state notifications" # but this costs two messages. It's even better to call chatStateComposing # with a doubt, it will be checked by the back-end anyway before sending @@ -58,25 +59,19 @@ self.__onEvent(None) def __onEvent(self, timer): - # print "on event %s" % self.next_state state = self.next_state - self.next_state = "" + + assert(state in TRANSITIONS) + transition = TRANSITIONS[state] + assert("next_state" in transition and "delay" in transition) + if state != self.state and state == "composing": self.host.bridge.call('chatStateComposing', None, self.target_s) + self.state = state - if not self.timer is None: + if self.timer is not None: self.timer.cancel() - if not state in TRANSITIONS: - return - if not "next_state" in TRANSITIONS[state]: - return - if not "delay" in TRANSITIONS[state]: - return - next_state = TRANSITIONS[state]["next_state"] - delay = TRANSITIONS[state]["delay"] - if next_state == "" or delay < 0: - return - self.next_state = next_state - # pyjamas timer in milliseconds - self.timer = Timer(delay * 1000, self.__onEvent) + if transition["next_state"] and transition["delay"] > 0: + self.next_state = transition["next_state"] + self.timer = Timer(transition["delay"] * 1000, self.__onEvent) # pyjamas timer is in milliseconds