changeset 1592:d6d655238a93

bridge: new core method profileStartSession to start a session without connecting the profile
author Goffi <goffi@goffi.org>
date Sat, 14 Nov 2015 19:18:10 +0100
parents 0df9c6247474
children 791c45ed8659
files frontends/src/bridge/DBus.py src/bridge/DBus.py src/bridge/bridge_constructor/bridge_template.ini src/core/sat_main.py
diffstat 4 files changed, 61 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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):
--- 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
--- 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)