From 16cdbbbe1f37584197163f89306dd38b3bdd01f5 Mon Sep 17 00:00:00 2001 From: souliane Date: Tue, 3 Mar 2015 22:17:57 +0100 Subject: [PATCH] frontends: add listeners 'profilePlugged', 'disconnect' and 'gotMenus' (the last one to be removed when the menus are refactored to quick_app) --- frontends/src/primitivus/primitivus | 2 +- frontends/src/quick_frontend/constants.py | 2 +- frontends/src/quick_frontend/quick_app.py | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/frontends/src/primitivus/primitivus b/frontends/src/primitivus/primitivus index d3a017ce..4fa25d7b 100755 --- a/frontends/src/primitivus/primitivus +++ b/frontends/src/primitivus/primitivus @@ -721,7 +721,7 @@ class PrimitivusApp(QuickApp, InputHistory): 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 --git a/frontends/src/quick_frontend/constants.py b/frontends/src/quick_frontend/constants.py index 860ebbce..8e9e035b 100644 --- a/frontends/src/quick_frontend/constants.py +++ b/frontends/src/quick_frontend/constants.py @@ -71,4 +71,4 @@ class Const(constants.Const): WIDGET_RAISE = 'RAISE' WIDGET_RECREATE = 'RECREATE' - LISTENERS = {'avatar', 'nick', 'presence'} + LISTENERS = {'avatar', 'nick', 'presence', 'profilePlugged', 'disconnect', 'gotMenus'} diff --git a/frontends/src/quick_frontend/quick_app.py b/frontends/src/quick_frontend/quick_app.py index 11f64d7f..c4c73ba1 100644 --- a/frontends/src/quick_frontend/quick_app.py +++ b/frontends/src/quick_frontend/quick_app.py @@ -390,6 +390,8 @@ class QuickApp(object): 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 @@ class QuickApp(object): """ 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 @@ class QuickApp(object): 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)