Mercurial > libervia-backend
comparison sat_frontends/bridge/dbus_bridge.py @ 3123:130f9cb6e0ab
core (memory/params): added `extra` argument to filter out params notably in `getParamsUI`:
In some case, it may be desirable for a frontend to not expose some parameters to user
(e.g. it is the case on Android with the `autoconnect_backend` parameter). An new `extra`
parameter has been added to a couple of parameters method for that: it can contain the
`ignore` key with a list of [category, name] of parameters to skip.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 25 Jan 2020 21:08:40 +0100 |
parents | 7574f795bd1e |
children | 9d0df638c8b4 |
comparison
equal
deleted
inserted
replaced
3122:4486d72658b9 | 3123:130f9cb6e0ab |
---|---|
182 if errback is None: | 182 if errback is None: |
183 errback = log.error | 183 errback = log.error |
184 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | 184 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) |
185 return str(self.db_core_iface.asyncGetParamA(name, category, attribute, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)) | 185 return str(self.db_core_iface.asyncGetParamA(name, category, attribute, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)) |
186 | 186 |
187 def asyncGetParamsValuesFromCategory(self, category, security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None): | 187 def asyncGetParamsValuesFromCategory(self, category, security_limit=-1, app="", extra="", profile_key="@DEFAULT@", callback=None, errback=None): |
188 if callback is None: | 188 if callback is None: |
189 error_handler = None | 189 error_handler = None |
190 else: | 190 else: |
191 if errback is None: | 191 if errback is None: |
192 errback = log.error | 192 errback = log.error |
193 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | 193 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) |
194 return self.db_core_iface.asyncGetParamsValuesFromCategory(category, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) | 194 return self.db_core_iface.asyncGetParamsValuesFromCategory(category, security_limit, app, extra, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) |
195 | 195 |
196 def connect(self, profile_key="@DEFAULT@", password='', options={}, callback=None, errback=None): | 196 def connect(self, profile_key="@DEFAULT@", password='', options={}, callback=None, errback=None): |
197 if callback is None: | 197 if callback is None: |
198 error_handler = None | 198 error_handler = None |
199 else: | 199 else: |
398 kwargs['timeout'] = const_TIMEOUT | 398 kwargs['timeout'] = const_TIMEOUT |
399 kwargs['reply_handler'] = callback | 399 kwargs['reply_handler'] = callback |
400 kwargs['error_handler'] = error_handler | 400 kwargs['error_handler'] = error_handler |
401 return self.db_core_iface.getParamsCategories(**kwargs) | 401 return self.db_core_iface.getParamsCategories(**kwargs) |
402 | 402 |
403 def getParamsUI(self, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None): | 403 def getParamsUI(self, security_limit=-1, app='', extra='', profile_key="@DEFAULT@", callback=None, errback=None): |
404 if callback is None: | 404 if callback is None: |
405 error_handler = None | 405 error_handler = None |
406 else: | 406 else: |
407 if errback is None: | 407 if errback is None: |
408 errback = log.error | 408 errback = log.error |
409 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) | 409 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) |
410 return str(self.db_core_iface.getParamsUI(security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)) | 410 return str(self.db_core_iface.getParamsUI(security_limit, app, extra, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)) |
411 | 411 |
412 def getPresenceStatuses(self, profile_key="@DEFAULT@", callback=None, errback=None): | 412 def getPresenceStatuses(self, profile_key="@DEFAULT@", callback=None, errback=None): |
413 if callback is None: | 413 if callback is None: |
414 error_handler = None | 414 error_handler = None |
415 else: | 415 else: |
906 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | 906 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) |
907 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | 907 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) |
908 self.db_core_iface.asyncGetParamA(name, category, attribute, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | 908 self.db_core_iface.asyncGetParamA(name, category, attribute, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) |
909 return fut | 909 return fut |
910 | 910 |
911 def asyncGetParamsValuesFromCategory(self, category, security_limit=-1, profile_key="@DEFAULT@"): | 911 def asyncGetParamsValuesFromCategory(self, category, security_limit=-1, app="", extra="", profile_key="@DEFAULT@"): |
912 loop = asyncio.get_running_loop() | 912 loop = asyncio.get_running_loop() |
913 fut = loop.create_future() | 913 fut = loop.create_future() |
914 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | 914 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) |
915 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | 915 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) |
916 self.db_core_iface.asyncGetParamsValuesFromCategory(category, security_limit, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | 916 self.db_core_iface.asyncGetParamsValuesFromCategory(category, security_limit, app, extra, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) |
917 return fut | 917 return fut |
918 | 918 |
919 def connect(self, profile_key="@DEFAULT@", password='', options={}): | 919 def connect(self, profile_key="@DEFAULT@", password='', options={}): |
920 loop = asyncio.get_running_loop() | 920 loop = asyncio.get_running_loop() |
921 fut = loop.create_future() | 921 fut = loop.create_future() |
1058 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | 1058 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) |
1059 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | 1059 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) |
1060 self.db_core_iface.getParamsCategories(timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | 1060 self.db_core_iface.getParamsCategories(timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) |
1061 return fut | 1061 return fut |
1062 | 1062 |
1063 def getParamsUI(self, security_limit=-1, app='', profile_key="@DEFAULT@"): | 1063 def getParamsUI(self, security_limit=-1, app='', extra='', profile_key="@DEFAULT@"): |
1064 loop = asyncio.get_running_loop() | 1064 loop = asyncio.get_running_loop() |
1065 fut = loop.create_future() | 1065 fut = loop.create_future() |
1066 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) | 1066 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) |
1067 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) | 1067 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) |
1068 self.db_core_iface.getParamsUI(security_limit, app, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) | 1068 self.db_core_iface.getParamsUI(security_limit, app, extra, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) |
1069 return fut | 1069 return fut |
1070 | 1070 |
1071 def getPresenceStatuses(self, profile_key="@DEFAULT@"): | 1071 def getPresenceStatuses(self, profile_key="@DEFAULT@"): |
1072 loop = asyncio.get_running_loop() | 1072 loop = asyncio.get_running_loop() |
1073 fut = loop.create_future() | 1073 fut = loop.create_future() |