bridge, quick_frontend: preparation for async bridge

bridge can currently have sync and async methods. This commit prepare the transition to fully async bridges:
    - a new bridgeConnect method must be called to prepare the bridge
    - quick app, quick profile manager: changed sync calls to async ones
    - quick app: bridgeConnect can be called automatically or manually depending on connect_bridge parameter of QuickApp
This commit is contained in:
Goffi 2016-12-13 22:27:48 +01:00
commit 34cec8fe14
3 changed files with 82 additions and 37 deletions

View file

@ -176,7 +176,7 @@ class Constructor(object):
@param name: dictionary of arguments name like given by getArgumentsDoc
@param default: dictionary of default values, like given by getDefault
@param unicode_protect: activate unicode protection on strings (return strings as unicode(str))
@return: list of arguments that correspond to a signature (e.g.: "sss" return "arg1, arg2, arg3")
@return (str): arguments that correspond to a signature (e.g.: "sss" return "arg1, arg2, arg3")
"""
idx = 0
attr_string = []

View file

@ -60,7 +60,8 @@ def dbus_to_bridge_exception(dbus_e):
class Bridge(BridgeFrontend):
def __init__(self):
def bridgeConnect(self, callback, errback):
try:
self.sessions_bus = dbus.SessionBus()
self.db_object = self.sessions_bus.get_object(const_INT_PREFIX,
@ -72,12 +73,13 @@ class Bridge(BridgeFrontend):
except dbus.exceptions.DBusException, e:
if e._dbus_error_name in ('org.freedesktop.DBus.Error.ServiceUnknown',
'org.freedesktop.DBus.Error.Spawn.ExecFailed'):
raise BridgeExceptionNoService
errback(BridgeExceptionNoService())
elif e._dbus_error_name == 'org.freedesktop.DBus.Error.NotSupported':
log.error(_(u"D-Bus is not launched, please see README to see instructions on how to launch it"))
raise BridgeInitError
errback(BridgeInitError)
else:
raise e
errback(e)
callback()
#props = self.db_core_iface.getProperties()
def register_signal(self, functionName, handler, iface="core"):

View file

@ -31,6 +31,9 @@ class _Bridge(object):
"plugin": {}
}
def bridgeConnect(self, callback, errback):
callback()
def register_method(self, name, callback):
log.debug(u"registering embedded bridge method [{}]".format(name))
if name in self._methods_cbs: