# HG changeset patch # User Goffi # Date 1320184356 -3600 # Node ID f6f94e21c6427aa1e2544ab75f4c791113a0f95b # Parent dd4caab17008ed71a6a0e835802a82bdfda9239c Quick frontend: use of asyncGetParamA when pluging profile diff -r dd4caab17008 -r f6f94e21c642 frontends/src/quick_frontend/quick_app.py --- a/frontends/src/quick_frontend/quick_app.py Tue Nov 01 20:39:22 2011 +0100 +++ b/frontends/src/quick_frontend/quick_app.py Tue Nov 01 22:52:36 2011 +0100 @@ -111,6 +111,9 @@ self.options.profile = self.options.profile.decode('utf-8') return args + def _getParamError(self): + error(_("Can't get profile parameter")) + def plug_profile(self, profile_key='@DEFAULT@'): """Tell application which profile must be used""" if self.single_profile and self.profiles: @@ -128,9 +131,20 @@ self.profile = profile ###now we get the essential params### - self.profiles[profile]['whoami']=JID(self.bridge.getParamA("JabberID","Connection", profile_key=profile)) - autoconnect = self.bridge.getParamA("autoconnect","Connection", profile_key=profile) == "true" - self.profiles[profile]['watched']=self.bridge.getParamA("Watched", "Misc", profile_key=profile).split() #TODO: put this in a plugin + self.bridge.asyncGetParamA("JabberID","Connection", profile_key=profile, + callback=lambda _jid: self.plug_profile_2(_jid, profile), errback=self._getParamError) + + def plug_profile_2(self, _jid, profile): + self.profiles[profile]['whoami'] = JID(_jid) + self.bridge.asyncGetParamA("autoconnect","Connection", profile_key=profile, + callback=lambda value: self.plug_profile_3(value=="true", profile), errback=self._getParamError) + + def plug_profile_3(self, autoconnect, profile): + self.bridge.asyncGetParamA("Watched", "Misc", profile_key=profile, + callback=lambda watched: self.plug_profile_4(watched, autoconnect, profile), errback=self._getParamError) + + def plug_profile_4(self, watched, autoconnect, profile): + self.profiles[profile]['watched'] = watched.split() #TODO: put this in a plugin ## misc ## self.profiles[profile]['onlineContact'] = set() #FIXME: temporary @@ -166,9 +180,9 @@ for subject_args in self.bridge.getRoomsSubjectss(profile): self.roomNewSubject(*subject_args, profile=profile) - if autoconnect and not self.bridge.isConnected(profile_key): + if autoconnect and not self.bridge.isConnected(profile): #Does the user want autoconnection ? - self.bridge.connect(profile_key) + self.bridge.connect(profile) def unplug_profile(self, profile): @@ -509,9 +523,9 @@ """Must be called when the frontend is terminating""" #TODO: mange multi-profile here try: - autodisconnect = self.bridge.getParamA("autodisconnect","Connection", profile_key=self.profile) == "true" - if autodisconnect and self.bridge.isConnected(self.profile): - #Does the user want autodisconnection ? - self.bridge.disconnect(self.profile) + if self.bridge.isConnected(self.profile): + if self.bridge.getParamA("autodisconnect","Connection", profile_key=self.profile) == "true": + #The user wants autodisconnection + self.bridge.disconnect(self.profile) except: pass