comparison browser_side/panels.py @ 269:9eb9c7d41bdc

browser_side: added generic method "send" in SatWebFrontend
author souliane <souliane@mailoo.org>
date Sun, 17 Nov 2013 21:16:07 +0100
parents a76243c02074
children 11718798ab8a
comparison
equal deleted inserted replaced
268:79970bf6af93 269:9eb9c7d41bdc
228 Timer(5, lambda: self.setCursorPos(len(text))) 228 Timer(5, lambda: self.setCursorPos(len(text)))
229 229
230 # if keycode == KEY_ENTER and not self.visible: 230 # if keycode == KEY_ENTER and not self.visible:
231 if keycode == KEY_ENTER: 231 if keycode == KEY_ENTER:
232 if _txt: 232 if _txt:
233 target_hook, _type, msg = target 233 target_hook, type_, msg = target
234 if target_hook: 234 if target_hook:
235 parsed_txt, data = target_hook 235 parsed_txt, data = target_hook
236 if _type == "PUBLIC": 236 self.host.send([(type_, data)], parsed_txt)
237 self.host.bridge.call("sendMblog", None, "PUBLIC", None, parsed_txt, {})
238 elif _type == "GROUP":
239 self.host.bridge.call("sendMblog", None, "GROUP", data, parsed_txt, {})
240 elif _type == "STATUS":
241 self.host.bridge.call('setStatus', None, parsed_txt)
242 else:
243 print "ERROR: Unknown target hook type"
244 else: # we send the message to the selected target 237 else: # we send the message to the selected target
245 self._selected_cache.onTextEntered(_txt) 238 self._selected_cache.onTextEntered(_txt)
246 self.host._updateInputHistory(_txt) 239 self.host._updateInputHistory(_txt)
247 self.setText('') 240 self.setText('')
248 self._timeCb(None) # we remove the popup 241 self._timeCb(None) # we remove the popup
438 if self.selected_entry: 431 if self.selected_entry:
439 # we are entering a comment 432 # we are entering a comment
440 comments_node = self.selected_entry.comments 433 comments_node = self.selected_entry.comments
441 if not comments_node: 434 if not comments_node:
442 raise Exception("ERROR: comments node is empty") 435 raise Exception("ERROR: comments node is empty")
443 self.host.bridge.call("sendMblogComment", None, comments_node, text, {}) 436 target = ("COMMENT", comments_node)
444 elif not self._accepted_groups: 437 elif not self._accepted_groups:
445 # we are entering a public microblog 438 # we are entering a public microblog
446 self.host.bridge.call("sendMblog", None, "PUBLIC", None, text, {}) 439 target = ("PUBLIC", None)
447 else: 440 else:
448 # we are entering a microblog restricted to a group 441 # we are entering a microblog restricted to a group
449 # FIXME: manage several groups 442 # FIXME: manage several groups
450 self.host.bridge.call("sendMblog", None, "GROUP", self._accepted_groups[0], text, {}) 443 target = ("GROUP", self._accepted_groups[0])
444 self.host.send([target], text)
451 445
452 def accept_all(self): 446 def accept_all(self):
453 return not self._accepted_groups # we accept every microblog only if we are not filtering by groups 447 return not self._accepted_groups # we accept every microblog only if we are not filtering by groups
454 448
455 def getEntries(self): 449 def getEntries(self):
751 elif self.type == "group": 745 elif self.type == "group":
752 msg = "This message will be sent to all the participants of the multi-user room <span class='warningTarget'>%s</span>" % self.target 746 msg = "This message will be sent to all the participants of the multi-user room <span class='warningTarget'>%s</span>" % self.target
753 return ("ONE2ONE" if self.type == "one2one" else "GROUP", msg) 747 return ("ONE2ONE" if self.type == "one2one" else "GROUP", msg)
754 748
755 def onTextEntered(self, text): 749 def onTextEntered(self, text):
756 mess_type = "groupchat" if self.type == 'group' else "chat" 750 self.host.send([("groupchat" if self.type == 'group' else "chat", str(self.target))], text)
757 self.host.bridge.call('sendMessage', None, str(self.target), text, '', mess_type, {})
758 self.state_machine._onEvent("active") 751 self.state_machine._onEvent("active")
759 752
760 def onQuit(self): 753 def onQuit(self):
761 base_widget.LiberviaWidget.onQuit(self) 754 base_widget.LiberviaWidget.onQuit(self)
762 if self.type == 'group': 755 if self.type == 'group':