core: sendMessage's options parameter has been renamed to extra to be consistent with newMessage

This commit is contained in:
Goffi 2013-11-13 13:58:10 +01:00
commit 9d42c269db
7 changed files with 24 additions and 22 deletions

View file

@ -196,8 +196,8 @@ class DBusBridgeFrontend(BridgeFrontend):
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)

View file

@ -282,11 +282,11 @@ class QuickApp(object):
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):

View file

@ -387,8 +387,8 @@ class DbusObject(dbus.service.Object):
@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='',

View file

@ -355,7 +355,7 @@ doc_param_0=to_jid: JID of the recipient
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]

View file

@ -471,24 +471,25 @@ class SAT(service.Service):
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 @@ class SAT(service.Service):
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)

View file

@ -210,17 +210,17 @@ class TextCommands(object):
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 @@ class TextCommands(object):
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

View file

@ -185,8 +185,8 @@ class XEP_0085(object):
# 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 @@ class ChatStateMachine:
'',
'',
self.mess_type,
options={"chat_state": state},
extra={"chat_state": state},
profile_key=self.profile)
self.state = state
if not self.timer is None: