Mercurial > libervia-web
diff 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 |
line wrap: on
line diff
--- a/browser_side/panels.py Sun Nov 17 17:57:14 2013 +0100 +++ b/browser_side/panels.py Sun Nov 17 21:16:07 2013 +0100 @@ -230,17 +230,10 @@ # if keycode == KEY_ENTER and not self.visible: if keycode == KEY_ENTER: if _txt: - target_hook, _type, msg = target + target_hook, type_, msg = target if target_hook: parsed_txt, data = target_hook - if _type == "PUBLIC": - self.host.bridge.call("sendMblog", None, "PUBLIC", None, parsed_txt, {}) - elif _type == "GROUP": - self.host.bridge.call("sendMblog", None, "GROUP", data, parsed_txt, {}) - elif _type == "STATUS": - self.host.bridge.call('setStatus', None, parsed_txt) - else: - print "ERROR: Unknown target hook type" + self.host.send([(type_, data)], parsed_txt) else: # we send the message to the selected target self._selected_cache.onTextEntered(_txt) self.host._updateInputHistory(_txt) @@ -440,14 +433,15 @@ comments_node = self.selected_entry.comments if not comments_node: raise Exception("ERROR: comments node is empty") - self.host.bridge.call("sendMblogComment", None, comments_node, text, {}) + target = ("COMMENT", comments_node) elif not self._accepted_groups: # we are entering a public microblog - self.host.bridge.call("sendMblog", None, "PUBLIC", None, text, {}) + target = ("PUBLIC", None) else: # we are entering a microblog restricted to a group # FIXME: manage several groups - self.host.bridge.call("sendMblog", None, "GROUP", self._accepted_groups[0], text, {}) + target = ("GROUP", self._accepted_groups[0]) + self.host.send([target], text) def accept_all(self): return not self._accepted_groups # we accept every microblog only if we are not filtering by groups @@ -753,8 +747,7 @@ return ("ONE2ONE" if self.type == "one2one" else "GROUP", msg) 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.host.send([("groupchat" if self.type == 'group' else "chat", str(self.target))], text) self.state_machine._onEvent("active") def onQuit(self):