diff frontends/src/quick_frontend/quick_profile_manager.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 2daf7b4c6756
children 1d3f73e065e1
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_profile_manager.py	Sun Dec 04 21:35:23 2016 +0100
+++ b/frontends/src/quick_frontend/quick_profile_manager.py	Tue Dec 13 22:27:48 2016 +0100
@@ -108,15 +108,22 @@
                 self._autoconnect=False
             self.host.actionManager(data, callback=authenticate_cb, profile=profile)
 
-        for profile_key in profile_keys:
-            profile = self.host.bridge.getProfileName(profile_key)
+        def getProfileNameCb(profile):
             if not profile:
+                # FIXME: this method is not handling manual mode correclty anymore
+                #        must be thought to be handled asynchronously
                 self._autoconnect = False # manual mode
                 msg = _("Trying to plug an unknown profile key ({})".format(profile_key))
                 log.warning(msg)
-                self.showDialog(_("Profile plugging in error"), msg, 'error')
-                break
-            self.host.launchAction(C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb, profile=profile)
+                self.host.showDialog(_("Profile plugging in error"), msg, 'error')
+            else:
+                self.host.launchAction(C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb, profile=profile)
+
+        def getProfileNameEb(failure):
+            log.error(u"Can't retrieve profile name: {}".format(failure))
+
+        for profile_key in profile_keys:
+            self.host.bridge.getProfileName(profile_key, callback=getProfileNameCb, errback=getProfileNameEb)
 
 
     def getParamError(self, dummy):