diff sat_frontends/bridge/dbus_bridge.py @ 3163:d10b2368684e

bridge: added methods to let frontends store/retrieve/delete private data
author Goffi <goffi@goffi.org>
date Mon, 10 Feb 2020 22:01:53 +0100
parents 830fce0db15d
children 439e2f88c3a9
line wrap: on
line diff
--- a/sat_frontends/bridge/dbus_bridge.py	Sun Feb 09 23:56:42 2020 +0100
+++ b/sat_frontends/bridge/dbus_bridge.py	Mon Feb 10 22:01:53 2020 +0100
@@ -641,6 +641,33 @@
             kwargs['error_handler'] = error_handler
         return self.db_core_iface.paramsRegisterApp(xml, security_limit, app, **kwargs)
 
+    def privateDataDelete(self, namespace, key, arg_2, 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.privateDataDelete(namespace, key, arg_2, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
+
+    def privateDataGet(self, namespace, key, profile_key, 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 str(self.db_core_iface.privateDataGet(namespace, key, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler))
+
+    def privateDataSet(self, namespace, key, data, profile_key, 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.privateDataSet(namespace, key, data, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
+
     def profileCreate(self, profile, password='', component='', callback=None, errback=None):
         if callback is None:
             error_handler = None
@@ -1226,6 +1253,30 @@
         self.db_core_iface.paramsRegisterApp(xml, security_limit, app, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
         return fut
 
+    def privateDataDelete(self, namespace, key, arg_2):
+        loop = asyncio.get_running_loop()
+        fut = loop.create_future()
+        reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
+        error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
+        self.db_core_iface.privateDataDelete(namespace, key, arg_2, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
+        return fut
+
+    def privateDataGet(self, namespace, key, profile_key):
+        loop = asyncio.get_running_loop()
+        fut = loop.create_future()
+        reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
+        error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
+        self.db_core_iface.privateDataGet(namespace, key, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
+        return fut
+
+    def privateDataSet(self, namespace, key, data, profile_key):
+        loop = asyncio.get_running_loop()
+        fut = loop.create_future()
+        reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
+        error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
+        self.db_core_iface.privateDataSet(namespace, key, data, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
+        return fut
+
     def profileCreate(self, profile, password='', component=''):
         loop = asyncio.get_running_loop()
         fut = loop.create_future()