backend, bridge: asynchronous history
quick_frontend: use of asynchronous history
This commit is contained in:
parent
88d0fceb2a
commit
f1966d9692
3 changed files with 94 additions and 79 deletions
|
|
@ -80,13 +80,13 @@ class DbusObject(dbus.service.Object):
|
|||
result = self.cb[name](*args, **kwargs)
|
||||
if async:
|
||||
if not isinstance(result, Deferred):
|
||||
error("Asynchrone method [%s] does not return a Deferred." % name)
|
||||
error("Asynchronous method [%s] does not return a Deferred." % name)
|
||||
raise AsyncNotDeferred
|
||||
result.addCallback(callback)
|
||||
result.addErrback(lambda err:errback(GenericException(err)))
|
||||
else:
|
||||
if isinstance(result, Deferred):
|
||||
error("Synchrone method [%s] return a Deferred." % name)
|
||||
error("Synchronous method [%s] return a Deferred." % name)
|
||||
raise DeferredNotAsync
|
||||
return result
|
||||
|
||||
|
|
@ -252,10 +252,10 @@ class DbusObject(dbus.service.Object):
|
|||
return self._callback("getContacts", unicode(profile_key))
|
||||
|
||||
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
|
||||
in_signature='ssi', out_signature='a{i(ss)}',
|
||||
async_callbacks=None)
|
||||
def getHistory(self, from_jid, to_jid, size):
|
||||
return self._callback("getHistory", unicode(from_jid), unicode(to_jid), size)
|
||||
in_signature='ssib', out_signature='a{i(sss)}',
|
||||
async_callbacks=('callback', 'errback'))
|
||||
def getHistory(self, from_jid, to_jid, limit, between=True, callback=None, errback=None):
|
||||
return self._callback("getHistory", unicode(from_jid), unicode(to_jid), limit, between, callback=callback, errback=errback)
|
||||
|
||||
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
|
||||
in_signature='ss', out_signature='s',
|
||||
|
|
|
|||
|
|
@ -434,15 +434,18 @@ doc=Get all categories currently existing in parameters
|
|||
doc_return=list of categories
|
||||
|
||||
[getHistory]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
sig_in=ssi
|
||||
sig_out=a{i(ss)}
|
||||
sig_in=ssib
|
||||
sig_out=a{i(sss)}
|
||||
param_3_default=True
|
||||
doc=Get history of a communication between two entities
|
||||
doc_param_0=from_jid: source JID
|
||||
doc_param_1=to_jid: dest JID
|
||||
doc_param_2=size: size of the history (0 for the whole history)
|
||||
doc_return=Dict where key is timestamp (seconds this the Epoch), and value is a tuple (from_jid, message)
|
||||
doc_param_0=from_jid: source JID (bare jid for catch all, full jid else)
|
||||
doc_param_1=to_jid: dest JID (bare jid for catch all, full jid else)
|
||||
doc_param_2=limit: max number of history elements to get (0 for the whole history)
|
||||
doc_param_3=between: True if we want history between the two jids (in both direction), False if we only want messages from from_jid to to_jid
|
||||
doc_return=Dict where key is timestamp (seconds this the Epoch), and value is a tuple (full from_jid, full to_jid, message)
|
||||
|
||||
[addContact]
|
||||
type=method
|
||||
|
|
|
|||
|
|
@ -80,13 +80,13 @@ class DbusObject(dbus.service.Object):
|
|||
result = self.cb[name](*args, **kwargs)
|
||||
if async:
|
||||
if not isinstance(result, Deferred):
|
||||
error("Asynchrone method [%s] does not return a Deferred." % name)
|
||||
error("Asynchronous method [%s] does not return a Deferred." % name)
|
||||
raise AsyncNotDeferred
|
||||
result.addCallback(callback)
|
||||
result.addErrback(lambda err:errback(GenericException(err)))
|
||||
else:
|
||||
if isinstance(result, Deferred):
|
||||
error("Synchrone method [%s] return a Deferred." % name)
|
||||
error("Synchronous method [%s] return a Deferred." % name)
|
||||
raise DeferredNotAsync
|
||||
return result
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue