Quick frontend: use of asyncGetParamA when pluging profile
This commit is contained in:
parent
554299aa91
commit
f1089aa515
1 changed files with 23 additions and 9 deletions
|
|
@ -111,6 +111,9 @@ class QuickApp():
|
|||
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 @@ class QuickApp():
|
|||
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 @@ class QuickApp():
|
|||
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 @@ class QuickApp():
|
|||
"""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
|
||||
|
|
|
|||
Loading…
Reference in a new issue