# HG changeset patch # User souliane # Date 1425417477 -3600 # Node ID a39d2db03c80a898b3383e4a245546d67acf28cf # Parent ba41a81d14c2e2bf7b00c325b2e145e84c8fbd52 frontends: add listeners 'profilePlugged', 'disconnect' and 'gotMenus' (the last one to be removed when the menus are refactored to quick_app) diff -r ba41a81d14c2 -r a39d2db03c80 frontends/src/primitivus/primitivus --- a/frontends/src/primitivus/primitivus Tue Mar 03 15:05:10 2015 +0100 +++ b/frontends/src/primitivus/primitivus Tue Mar 03 22:17:57 2015 +0100 @@ -721,7 +721,7 @@ QuickApp.asyncConnect(self, self.current_profile) def onDisconnectRequest(self, menu): - self.bridge.disconnect(self.current_profile) + self.disconnect(self.current_profile) def onParam(self, menu): def success(params): diff -r ba41a81d14c2 -r a39d2db03c80 frontends/src/quick_frontend/constants.py --- a/frontends/src/quick_frontend/constants.py Tue Mar 03 15:05:10 2015 +0100 +++ b/frontends/src/quick_frontend/constants.py Tue Mar 03 22:17:57 2015 +0100 @@ -71,4 +71,4 @@ WIDGET_RAISE = 'RAISE' WIDGET_RECREATE = 'RECREATE' - LISTENERS = {'avatar', 'nick', 'presence'} + LISTENERS = {'avatar', 'nick', 'presence', 'profilePlugged', 'disconnect', 'gotMenus'} diff -r ba41a81d14c2 -r a39d2db03c80 frontends/src/quick_frontend/quick_app.py --- a/frontends/src/quick_frontend/quick_app.py Tue Mar 03 15:05:10 2015 +0100 +++ b/frontends/src/quick_frontend/quick_app.py Tue Mar 03 22:17:57 2015 +0100 @@ -390,6 +390,8 @@ for function_name, handler, args, kwargs in cached_signals: log.debug(u"Calling cached signal [%s] with args %s and kwargs %s" % (function_name, args, kwargs)) + self.callListeners('profilePlugged', profile=profile) + def asyncConnect(self, profile, callback=None, errback=None): if not callback: callback = lambda dummy: None @@ -740,6 +742,11 @@ """ raise NotImplementedError + def disconnect(self, profile): + log.info("disconnecting") + self.callListeners('disconnect', profile=profile) + self.bridge.disconnect(profile) + def onExit(self): """Must be called when the frontend is terminating""" to_unplug = [] @@ -747,7 +754,7 @@ if self.bridge.isConnected(profile): if C.bool(self.bridge.getParamA("autodisconnect", "Connection", profile_key=profile)): #The user wants autodisconnection - self.bridge.disconnect(profile) + self.disconnect(profile) to_unplug.append(profile) for profile in to_unplug: self.unplug_profile(profile)