Mercurial > libervia-backend
comparison frontends/src/quick_frontend/quick_app.py @ 1939:e68483c5a999
quick app (contact list): when a new profile is plugged, updates are locked until the end of the process, this avoid many useless refreshes
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 18 Apr 2016 18:33:55 +0200 |
parents | 011eff37e21d |
children | 633b5c21aefd |
comparison
equal
deleted
inserted
replaced
1938:011eff37e21d | 1939:e68483c5a999 |
---|---|
213 """ | 213 """ |
214 self.xmlui = xmlui | 214 self.xmlui = xmlui |
215 self.menus = quick_menus.QuickMenusManager(self) | 215 self.menus = quick_menus.QuickMenusManager(self) |
216 ProfileManager.host = self | 216 ProfileManager.host = self |
217 self.profiles = ProfilesManager() | 217 self.profiles = ProfilesManager() |
218 self._plugs_in_progress = set() # profiles currently being plugged, used to (un)lock contact list updates | |
218 self.ready_profiles = set() # profiles which are connected and ready | 219 self.ready_profiles = set() # profiles which are connected and ready |
219 self.signals_cache = {} # used to keep signal received between start of plug_profile and when the profile is actualy ready | 220 self.signals_cache = {} # used to keep signal received between start of plug_profile and when the profile is actualy ready |
220 self.contact_lists = quick_contact_list.QuickContactListHandler(self) | 221 self.contact_lists = quick_contact_list.QuickContactListHandler(self) |
221 self.widgets = quick_widgets.QuickWidgetsManager(self) | 222 self.widgets = quick_widgets.QuickWidgetsManager(self) |
222 if check_options is not None: | 223 if check_options is not None: |
399 /!\ if you override the method and don't call the parent, be sure to add the profile to ready_profiles ! | 400 /!\ if you override the method and don't call the parent, be sure to add the profile to ready_profiles ! |
400 if you don't, all signals will stay in cache | 401 if you don't, all signals will stay in cache |
401 | 402 |
402 @param profile(unicode): %(doc_profile)s | 403 @param profile(unicode): %(doc_profile)s |
403 """ | 404 """ |
405 self._plugs_in_progress.remove(profile) | |
404 self.ready_profiles.add(profile) | 406 self.ready_profiles.add(profile) |
405 | 407 |
406 # profile is ready, we can call send signals that where is cache | 408 # profile is ready, we can call send signals that where is cache |
407 cached_signals = self.signals_cache.pop(profile, []) | 409 cached_signals = self.signals_cache.pop(profile, []) |
408 for function_name, handler, args, kwargs in cached_signals: | 410 for function_name, handler, args, kwargs in cached_signals: |
409 log.debug(u"Calling cached signal [%s] with args %s and kwargs %s" % (function_name, args, kwargs)) | 411 log.debug(u"Calling cached signal [%s] with args %s and kwargs %s" % (function_name, args, kwargs)) |
410 handler(*args, **kwargs) | 412 handler(*args, **kwargs) |
411 | 413 |
412 self.callListeners('profilePlugged', profile=profile) | 414 self.callListeners('profilePlugged', profile=profile) |
415 if not self._plugs_in_progress: | |
416 self.contact_lists.lockUpdate(False) | |
413 | 417 |
414 def asyncConnect(self, profile, callback=None, errback=None): | 418 def asyncConnect(self, profile, callback=None, errback=None): |
415 if not callback: | 419 if not callback: |
416 callback = lambda dummy: None | 420 callback = lambda dummy: None |
417 if not errback: | 421 if not errback: |
426 def plug_profiles(self, profiles): | 430 def plug_profiles(self, profiles): |
427 """Tell application which profiles must be used | 431 """Tell application which profiles must be used |
428 | 432 |
429 @param profiles: list of valid profile names | 433 @param profiles: list of valid profile names |
430 """ | 434 """ |
435 self.contact_lists.lockUpdate() | |
436 self._plugs_in_progress.update(profiles) | |
431 self.plugging_profiles() | 437 self.plugging_profiles() |
432 for profile in profiles: | 438 for profile in profiles: |
433 self.profiles.plug(profile) | 439 self.profiles.plug(profile) |
434 | 440 |
435 def plugging_profiles(self): | 441 def plugging_profiles(self): |