Mercurial > libervia-backend
changeset 698:d731ae066158
core: sendMessage's options parameter has been renamed to extra to be consistent with newMessage
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 13 Nov 2013 13:58:10 +0100 |
parents | 0c84fb112d70 |
children | e819630c6737 |
files | frontends/src/bridge/DBus.py frontends/src/quick_frontend/quick_app.py src/bridge/DBus.py src/bridge/bridge_constructor/bridge_template.ini src/core/sat_main.py src/plugins/plugin_misc_text_commands.py src/plugins/plugin_xep_0085.py |
diffstat | 7 files changed, 24 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/frontends/src/bridge/DBus.py Wed Nov 13 13:57:36 2013 +0100 +++ b/frontends/src/bridge/DBus.py Wed Nov 13 13:58:10 2013 +0100 @@ -196,8 +196,8 @@ def registerNewAccount(self, login, password, email, host, port=5222): return unicode(self.db_core_iface.registerNewAccount(login, password, email, host, port)) - def sendMessage(self, to_jid, message, subject='', mess_type="auto", options={}, profile_key="@NONE@"): - return self.db_core_iface.sendMessage(to_jid, message, subject, mess_type, options, profile_key) + def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, profile_key="@NONE@"): + return self.db_core_iface.sendMessage(to_jid, message, subject, mess_type, extra, profile_key) def setParam(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@"): return self.db_core_iface.setParam(name, value, category, security_limit, profile_key)
--- a/frontends/src/quick_frontend/quick_app.py Wed Nov 13 13:57:36 2013 +0100 +++ b/frontends/src/quick_frontend/quick_app.py Wed Nov 13 13:58:10 2013 +0100 @@ -282,11 +282,11 @@ timestamp = extra.get('archive') self.chat_wins[win.bare].printMessage(from_jid, msg, profile, float(timestamp) if timestamp else '') - def sendMessage(self, to_jid, message, subject='', mess_type="auto", options={}, profile_key="@NONE@"): + def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, profile_key="@NONE@"): if to_jid.startswith(const_PRIVATE_PREFIX): to_jid = unescapePrivate(to_jid) mess_type = "chat" - self.bridge.sendMessage(to_jid, message, subject, mess_type, options, profile_key) + self.bridge.sendMessage(to_jid, message, subject, mess_type, extra, profile_key) def newAlert(self, msg, title, alert_type, profile): if not self.check_profile(profile):
--- a/src/bridge/DBus.py Wed Nov 13 13:57:36 2013 +0100 +++ b/src/bridge/DBus.py Wed Nov 13 13:58:10 2013 +0100 @@ -387,8 +387,8 @@ @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, in_signature='ssssa{ss}s', out_signature='', async_callbacks=None) - def sendMessage(self, to_jid, message, subject='', mess_type="auto", options={}, profile_key="@NONE@"): - return self._callback("sendMessage", unicode(to_jid), unicode(message), unicode(subject), unicode(mess_type), options, unicode(profile_key)) + def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, profile_key="@NONE@"): + return self._callback("sendMessage", unicode(to_jid), unicode(message), unicode(subject), unicode(mess_type), extra, unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, in_signature='sssis', out_signature='',
--- a/src/bridge/bridge_constructor/bridge_template.ini Wed Nov 13 13:57:36 2013 +0100 +++ b/src/bridge/bridge_constructor/bridge_template.ini Wed Nov 13 13:58:10 2013 +0100 @@ -355,7 +355,7 @@ doc_param_1=message: body of the message doc_param_2=subject: Subject of the message ('' if no subject) doc_param_3=mess_type: Type of the message (cf RFC 3921 #2.1.1) or "auto" for automatic type detection -doc_param_4=options: optional data that can be used by a plugin to build more specific messages +doc_param_4=extra: optional data that can be used by a plugin to build more specific messages doc_param_5=%(doc_profile_key)s [setPresence]
--- a/src/core/sat_main.py Wed Nov 13 13:57:36 2013 +0100 +++ b/src/core/sat_main.py Wed Nov 13 13:58:10 2013 +0100 @@ -471,24 +471,25 @@ ret.append((conf_id, conf_type, data)) return ret - def _sendMessage(self, to_s, msg, subject=None, mess_type='auto', options={}, profile_key='@NONE@'): + def _sendMessage(self, to_s, msg, subject=None, mess_type='auto', extra={}, profile_key='@NONE@'): to_jid = jid.JID(to_s) - self.sendMessage(to_jid, msg, subject, mess_type, options=options, profile_key=profile_key) + #XXX: we need to use the dictionary comprehension because D-Bus return its own types, and pickle can't manage them. TODO: Need to find a better way + self.sendMessage(to_jid, msg, subject, mess_type, {unicode(key): unicode(value) for key, value in extra.items()}, profile_key=profile_key) - def sendMessage(self, to_jid, msg, subject=None, mess_type='auto', options={}, no_trigger=False, profile_key='@NONE@'): + def sendMessage(self, to_jid, msg, subject=None, mess_type='auto', extra={}, no_trigger=False, profile_key='@NONE@'): #FIXME: check validity of recipient profile = self.memory.getProfileName(profile_key) assert(profile) client = self.profiles[profile] current_jid = client.jid - if options is None: - options = {} + if extra is None: + extra = {} mess_data = { # we put data in a dict, so trigger methods can change them "to": to_jid, "message": msg, "subject": subject, "type": mess_type, - "options": options, + "extra": extra, } treatments = defer.Deferred() # XXX: plugin can add their treatments to this deferred @@ -535,13 +536,14 @@ self.memory.addToHistory(current_jid, mess_data['to'], unicode(mess_data["message"]), unicode(mess_data["type"]), + mess_data['extra'], profile=profile) # We send back the message, so all clients are aware of it if mess_data["message"]: self.bridge.newMessage(mess_data['xml']['from'], unicode(mess_data["message"]), mess_type=mess_data["type"], - to_jid=mess_data['xml']['to'], extra={}, + to_jid=mess_data['xml']['to'], extra=mess_data['extra'], profile=profile) treatments.addCallback(sendAndStore)
--- a/src/plugins/plugin_misc_text_commands.py Wed Nov 13 13:57:36 2013 +0100 +++ b/src/plugins/plugin_misc_text_commands.py Wed Nov 13 13:58:10 2013 +0100 @@ -210,17 +210,17 @@ def cmd_whois(self, mess_data, profile): """show informations on entity""" debug("Catched whois command") - + entity = mess_data["unparsed"].strip() - + if mess_data['type'] == "groupchat": room = mess_data["to"] if self.host.plugins["XEP-0045"].isNickInRoom(room, entity, profile): entity = u"%s/%s" % (room, entity) - + if not entity: target_jid = mess_data["to"] - else: + else: try: target_jid = jid.JID(entity) if not target_jid.user or not target_jid.host: @@ -231,7 +231,7 @@ whois_msg = [_(u"whois for %(jid)s") % {'jid': target_jid}] #TODO: add informations here (client version, vcard, etc) - + self._feedBack(u"\n".join(whois_msg), mess_data, profile) return False
--- a/src/plugins/plugin_xep_0085.py Wed Nov 13 13:57:36 2013 +0100 +++ b/src/plugins/plugin_xep_0085.py Wed Nov 13 13:58:10 2013 +0100 @@ -185,8 +185,8 @@ # launch the chat state machine (init the timer) self.__chatStateActive(to_jid, mess_data["type"], profile) except StopIteration: - if "chat_state" in mess_data["options"]: - state = mess_data["options"]["chat_state"] + if "chat_state" in mess_data["extra"]: + state = mess_data["extra"].pop("chat_state") assert(state in CHAT_STATES) message.addElement(state, NS_CHAT_STATES) return mess_data @@ -303,7 +303,7 @@ '', '', self.mess_type, - options={"chat_state": state}, + extra={"chat_state": state}, profile_key=self.profile) self.state = state if not self.timer is None: