diff --git a/frontends/src/bridge/DBus.py b/frontends/src/bridge/DBus.py index e5943dc4..8fca657f 100644 --- a/frontends/src/bridge/DBus.py +++ b/frontends/src/bridge/DBus.py @@ -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 diff --git a/src/bridge/DBus.py b/src/bridge/DBus.py index 542d8e24..c5b8097c 100755 --- a/src/bridge/DBus.py +++ b/src/bridge/DBus.py @@ -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) diff --git a/src/bridge/bridge_constructor/bridge_template.ini b/src/bridge/bridge_constructor/bridge_template.ini index 21f59250..4d816b3e 100644 --- a/src/bridge/bridge_constructor/bridge_template.ini +++ b/src/bridge/bridge_constructor/bridge_template.ini @@ -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 diff --git a/src/core/sat_main.py b/src/core/sat_main.py index d4471900..8c769b50 100644 --- a/src/core/sat_main.py +++ b/src/core/sat_main.py @@ -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)