core,bridge: sendMessage bridge method is now async
This commit is contained in:
parent
b6aaecc5c2
commit
bc776be0f2
5 changed files with 11 additions and 8 deletions
|
|
@ -391,9 +391,9 @@ 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", extra={}, profile_key="@NONE@"):
|
||||
return self._callback("sendMessage", unicode(to_jid), unicode(message), unicode(subject), unicode(mess_type), extra, unicode(profile_key))
|
||||
async_callbacks=('callback', 'errback'))
|
||||
def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, profile_key="@NONE@", callback=None, errback=None):
|
||||
return self._callback("sendMessage", unicode(to_jid), unicode(message), unicode(subject), unicode(mess_type), extra, unicode(profile_key), callback=callback, errback=errback)
|
||||
|
||||
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
|
||||
in_signature='sssis', out_signature='',
|
||||
|
|
|
|||
|
|
@ -342,6 +342,7 @@ doc_return=List of confirmation request data, same as for [askConfirmation]
|
|||
|
||||
|
||||
[sendMessage]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
sig_in=ssssa{ss}s
|
||||
|
|
|
|||
|
|
@ -509,7 +509,7 @@ class SAT(service.Service):
|
|||
def _sendMessage(self, to_s, msg, subject=None, mess_type='auto', extra={}, profile_key='@NONE@'):
|
||||
to_jid = jid.JID(to_s)
|
||||
#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)
|
||||
return 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', extra={}, no_trigger=False, profile_key='@NONE@'):
|
||||
#FIXME: check validity of recipient
|
||||
|
|
@ -550,7 +550,7 @@ class SAT(service.Service):
|
|||
|
||||
if not no_trigger:
|
||||
if not self.trigger.point("sendMessage", mess_data, treatments, profile):
|
||||
return
|
||||
return defer.succeed(None)
|
||||
|
||||
debug(_("Sending jabber message of type [%(type)s] to %(to)s...") % {"type": mess_data["type"], "to": to_jid.full()})
|
||||
mess_data['xml'] = domish.Element((None, 'message'))
|
||||
|
|
@ -569,12 +569,14 @@ class SAT(service.Service):
|
|||
debug(text)
|
||||
elif e.check(AbortSendMessage):
|
||||
warning(text)
|
||||
return e
|
||||
else:
|
||||
error("Unmanaged exception: %s" % text)
|
||||
return e
|
||||
|
||||
treatments.addCallbacks(self.sendAndStoreMessage, sendErrback, [False, profile])
|
||||
treatments.callback(mess_data)
|
||||
return treatments
|
||||
|
||||
def sendAndStoreMessage(self, mess_data, skip_send=False, profile=None):
|
||||
"""Actually send and store the message to history, after all the treatments
|
||||
|
|
|
|||
Loading…
Reference in a new issue