bridge: new core method profileStartSession to start a session without connecting the profile

This commit is contained in:
Goffi 2015-11-14 19:18:10 +01:00
commit d620805fc7
4 changed files with 61 additions and 0 deletions

View file

@ -543,6 +543,29 @@ class DBusBridgeFrontend(BridgeFrontend):
kwargs['error_handler'] = error_handler
return self.db_core_iface.paramsRegisterApp(xml, security_limit, app, **kwargs)
def profileIsSessionStarted(self, profile_key="@DEFAULT@", callback=None, errback=None):
if callback is None:
error_handler = None
else:
if errback is None:
errback = log.error
error_handler = lambda err:errback(dbus_to_bridge_exception(err))
kwargs={}
if callback is not None:
kwargs['timeout'] = const_TIMEOUT
kwargs['reply_handler'] = callback
kwargs['error_handler'] = error_handler
return self.db_core_iface.profileIsSessionStarted(profile_key, **kwargs)
def profileStartSession(self, password='', profile_key="@DEFAULT@", callback=None, errback=None):
if callback is None:
error_handler = None
else:
if errback is None:
errback = log.error
error_handler = lambda err:errback(dbus_to_bridge_exception(err))
return self.db_core_iface.profileStartSession(password, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
def progressGet(self, id, profile, callback=None, errback=None):
if callback is None:
error_handler = None

View file

@ -422,6 +422,18 @@ class DbusObject(dbus.service.Object):
def paramsRegisterApp(self, xml, security_limit=-1, app=''):
return self._callback("paramsRegisterApp", unicode(xml), security_limit, unicode(app))
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='s', out_signature='b',
async_callbacks=None)
def profileIsSessionStarted(self, profile_key="@DEFAULT@"):
return self._callback("profileIsSessionStarted", unicode(profile_key))
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='ss', out_signature='b',
async_callbacks=('callback', 'errback'))
def profileStartSession(self, password='', profile_key="@DEFAULT@", callback=None, errback=None):
return self._callback("profileStartSession", unicode(password), unicode(profile_key), callback=callback, errback=errback)
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='ss', out_signature='a{ss}',
async_callbacks=None)

View file

@ -298,6 +298,30 @@ doc_return=a deferred boolean or failure:
- False if the XMPP connection has been initiated (it may still fail)
- failure if the profile authentication failed
[profileStartSession]
async=
type=method
category=core
sig_in=ss
sig_out=b
param_0_default=''
param_1_default="@DEFAULT@"
doc=Start a profile session without connecting it (if it's not already the case)
doc_param_0=password: the SàT profile password
doc_param_1=%(doc_profile_key)s
doc_return=D(bool):
- True if the profile session was already started
- False else
[profileIsSessionStarted]
type=method
category=core
sig_in=s
sig_out=b
param_0_default="@DEFAULT@"
doc=Tell if a profile session is loaded
doc_param_0=%(doc_profile_key)s
[disconnect]
type=method
category=core

View file

@ -74,6 +74,8 @@ class SAT(service.Service):
self.bridge.register("getEntitiesData", self.memory._getEntitiesData)
self.bridge.register("asyncCreateProfile", self.memory.asyncCreateProfile)
self.bridge.register("asyncDeleteProfile", self.memory.asyncDeleteProfile)
self.bridge.register("profileStartSession", self.memory._startSession)
self.bridge.register("profileIsSessionStarted", self.memory._isSessionStarted)
self.bridge.register("asyncConnect", self._asyncConnect)
self.bridge.register("disconnect", self.disconnect)
self.bridge.register("getContacts", self.getContacts)