Mercurial > libervia-backend
comparison src/core/sat_main.py @ 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 |
parents | bb9c32249778 |
children | 49f967fc87aa |
comparison
equal
deleted
inserted
replaced
1315:be3a301540c0 | 1316:8adcdf2cdfe1 |
---|---|
263 | 263 |
264 plugin_conn_cb = [] | 264 plugin_conn_cb = [] |
265 for plugin in self.plugins.iteritems(): | 265 for plugin in self.plugins.iteritems(): |
266 if plugin[1].is_handler: | 266 if plugin[1].is_handler: |
267 plugin[1].getHandler(profile).setHandlerParent(current) | 267 plugin[1].getHandler(profile).setHandlerParent(current) |
268 connected_cb = getattr(plugin[1], "profileConnected", None) | 268 connected_cb = getattr(plugin[1], "profileConnected", None) # profile connected is called after client is ready and roster is got |
269 if connected_cb: | 269 if connected_cb: |
270 plugin_conn_cb.append((plugin[0], connected_cb)) | 270 plugin_conn_cb.append((plugin[0], connected_cb)) |
271 try: | |
272 yield plugin[1].profileConnecting(profile) # profile connecting is called before actually starting client | |
273 except AttributeError: | |
274 pass | |
271 | 275 |
272 current.startService() | 276 current.startService() |
273 | 277 |
274 yield current.getConnectionDeferred() | 278 yield current.getConnectionDeferred() |
275 yield current.roster.got_roster # we want to be sure that we got the roster | 279 yield current.roster.got_roster # we want to be sure that we got the roster |
288 if not success: | 292 if not success: |
289 log.error("error (plugin %(name)s): %(failure)s" % | 293 log.error("error (plugin %(name)s): %(failure)s" % |
290 {'name': plugin_conn_cb[idx][0], 'failure': result}) | 294 {'name': plugin_conn_cb[idx][0], 'failure': result}) |
291 | 295 |
292 yield list_d.addCallback(logPluginResults) # FIXME: we should have a timeout here, and a way to know if a plugin freeze | 296 yield list_d.addCallback(logPluginResults) # FIXME: we should have a timeout here, and a way to know if a plugin freeze |
293 # TODO: mesure time to launch of each plugin | 297 # TODO: mesure launch time of each plugin |
294 | 298 |
295 def _authenticateProfile(self, password, profile): | 299 def _authenticateProfile(self, password, profile): |
296 """Authenticate the profile. | 300 """Authenticate the profile. |
297 | 301 |
298 @param password (string): the SàT profile password | 302 @param password (string): the SàT profile password |