changeset 1316:8adcdf2cdfe1 frontends_multi_profiles

core: added a "profileConnecting" method check: if a plugin has a profileConnecting method, it will be called when the profile is being connected but before the client stream is started. That can be usefull if things need to be done before the communication is started: e.g. putting triggers, loading PersistentDict, etc.
author Goffi <goffi@goffi.org>
date Mon, 09 Feb 2015 21:39:51 +0100 (2015-02-09)
parents be3a301540c0
children bd69d341d969
files src/core/sat_main.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/sat_main.py	Mon Feb 09 21:39:51 2015 +0100
+++ b/src/core/sat_main.py	Mon Feb 09 21:39:51 2015 +0100
@@ -265,9 +265,13 @@
         for plugin in self.plugins.iteritems():
             if plugin[1].is_handler:
                 plugin[1].getHandler(profile).setHandlerParent(current)
-            connected_cb = getattr(plugin[1], "profileConnected", None)
+            connected_cb = getattr(plugin[1], "profileConnected", None) # profile connected is called after client is ready and roster is got
             if connected_cb:
                 plugin_conn_cb.append((plugin[0], connected_cb))
+            try:
+                yield plugin[1].profileConnecting(profile) # profile connecting is called before actually starting client
+            except AttributeError:
+                pass
 
         current.startService()
 
@@ -290,7 +294,7 @@
                                   {'name': plugin_conn_cb[idx][0], 'failure': result})
 
         yield list_d.addCallback(logPluginResults) # FIXME: we should have a timeout here, and a way to know if a plugin freeze
-        # TODO: mesure time to launch of each plugin
+        # TODO: mesure launch time of each plugin
 
     def _authenticateProfile(self, password, profile):
         """Authenticate the profile.