diff frontends/src/bridge/dbus_bridge.py @ 2091:f413bfc24458

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
author Goffi <goffi@goffi.org>
date Tue, 13 Dec 2016 22:27:48 +0100
parents 4633cfcbcccb
children 9c861d07b5b6
line wrap: on
line diff
--- a/frontends/src/bridge/dbus_bridge.py	Sun Dec 04 21:35:23 2016 +0100
+++ b/frontends/src/bridge/dbus_bridge.py	Tue Dec 13 22:27:48 2016 +0100
@@ -60,7 +60,8 @@
 
 
 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 @@
         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"):