# HG changeset patch # User Goffi # Date 1447525090 -3600 # Node ID d6d655238a932b40deb7b366b85e47fc30ee1add # Parent 0df9c62474742888c53ecf514446ec7d699803d3 bridge: new core method profileStartSession to start a session without connecting the profile diff -r 0df9c6247474 -r d6d655238a93 frontends/src/bridge/DBus.py --- a/frontends/src/bridge/DBus.py Sat Nov 14 19:18:10 2015 +0100 +++ b/frontends/src/bridge/DBus.py Sat Nov 14 19:18:10 2015 +0100 @@ -543,6 +543,29 @@ 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 -r 0df9c6247474 -r d6d655238a93 src/bridge/DBus.py --- a/src/bridge/DBus.py Sat Nov 14 19:18:10 2015 +0100 +++ b/src/bridge/DBus.py Sat Nov 14 19:18:10 2015 +0100 @@ -423,6 +423,18 @@ 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) def progressGet(self, id, profile): diff -r 0df9c6247474 -r d6d655238a93 src/bridge/bridge_constructor/bridge_template.ini --- a/src/bridge/bridge_constructor/bridge_template.ini Sat Nov 14 19:18:10 2015 +0100 +++ b/src/bridge/bridge_constructor/bridge_template.ini Sat Nov 14 19:18:10 2015 +0100 @@ -298,6 +298,30 @@ - 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 -r 0df9c6247474 -r d6d655238a93 src/core/sat_main.py --- a/src/core/sat_main.py Sat Nov 14 19:18:10 2015 +0100 +++ b/src/core/sat_main.py Sat Nov 14 19:18:10 2015 +0100 @@ -74,6 +74,8 @@ 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)