comparison 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
comparison
equal deleted inserted replaced
697:0c84fb112d70 698:d731ae066158
469 for conf_id in client._waiting_conf: 469 for conf_id in client._waiting_conf:
470 conf_type, data = client._waiting_conf[conf_id][:2] 470 conf_type, data = client._waiting_conf[conf_id][:2]
471 ret.append((conf_id, conf_type, data)) 471 ret.append((conf_id, conf_type, data))
472 return ret 472 return ret
473 473
474 def _sendMessage(self, to_s, msg, subject=None, mess_type='auto', options={}, profile_key='@NONE@'): 474 def _sendMessage(self, to_s, msg, subject=None, mess_type='auto', extra={}, profile_key='@NONE@'):
475 to_jid = jid.JID(to_s) 475 to_jid = jid.JID(to_s)
476 self.sendMessage(to_jid, msg, subject, mess_type, options=options, profile_key=profile_key) 476 #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
477 477 self.sendMessage(to_jid, msg, subject, mess_type, {unicode(key): unicode(value) for key, value in extra.items()}, profile_key=profile_key)
478 def sendMessage(self, to_jid, msg, subject=None, mess_type='auto', options={}, no_trigger=False, profile_key='@NONE@'): 478
479 def sendMessage(self, to_jid, msg, subject=None, mess_type='auto', extra={}, no_trigger=False, profile_key='@NONE@'):
479 #FIXME: check validity of recipient 480 #FIXME: check validity of recipient
480 profile = self.memory.getProfileName(profile_key) 481 profile = self.memory.getProfileName(profile_key)
481 assert(profile) 482 assert(profile)
482 client = self.profiles[profile] 483 client = self.profiles[profile]
483 current_jid = client.jid 484 current_jid = client.jid
484 if options is None: 485 if extra is None:
485 options = {} 486 extra = {}
486 mess_data = { # we put data in a dict, so trigger methods can change them 487 mess_data = { # we put data in a dict, so trigger methods can change them
487 "to": to_jid, 488 "to": to_jid,
488 "message": msg, 489 "message": msg,
489 "subject": subject, 490 "subject": subject,
490 "type": mess_type, 491 "type": mess_type,
491 "options": options, 492 "extra": extra,
492 } 493 }
493 treatments = defer.Deferred() # XXX: plugin can add their treatments to this deferred 494 treatments = defer.Deferred() # XXX: plugin can add their treatments to this deferred
494 495
495 if mess_data["type"] == "auto": 496 if mess_data["type"] == "auto":
496 # we try to guess the type 497 # we try to guess the type
533 # we don't add groupchat message to history, as we get them back 534 # we don't add groupchat message to history, as we get them back
534 # and they will be added then 535 # and they will be added then
535 self.memory.addToHistory(current_jid, mess_data['to'], 536 self.memory.addToHistory(current_jid, mess_data['to'],
536 unicode(mess_data["message"]), 537 unicode(mess_data["message"]),
537 unicode(mess_data["type"]), 538 unicode(mess_data["type"]),
539 mess_data['extra'],
538 profile=profile) 540 profile=profile)
539 # We send back the message, so all clients are aware of it 541 # We send back the message, so all clients are aware of it
540 if mess_data["message"]: 542 if mess_data["message"]:
541 self.bridge.newMessage(mess_data['xml']['from'], 543 self.bridge.newMessage(mess_data['xml']['from'],
542 unicode(mess_data["message"]), 544 unicode(mess_data["message"]),
543 mess_type=mess_data["type"], 545 mess_type=mess_data["type"],
544 to_jid=mess_data['xml']['to'], extra={}, 546 to_jid=mess_data['xml']['to'], extra=mess_data['extra'],
545 profile=profile) 547 profile=profile)
546 548
547 treatments.addCallback(sendAndStore) 549 treatments.addCallback(sendAndStore)
548 treatments.callback(mess_data) 550 treatments.callback(mess_data)
549 551