diff src/core/sat_main.py @ 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 ab9620029aa8
line wrap: on
line diff
--- 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)