core: better handling of profile_key and don't write the param file anymore
- new error ProfileNotSetError and some methods use the default @NONE@ instead of @DEFAULT@ - do not output the .sat/param file anymore, it is not needed and created confusion - plugin XEP-0054: remove an error message at startup
This commit is contained in:
parent
f9bd9dd9b2
commit
4c30dcf240
4 changed files with 24 additions and 13 deletions
|
|
@ -28,9 +28,9 @@ class QuickChatList(dict):
|
|||
dict.__init__(self)
|
||||
self.host = host
|
||||
|
||||
def __getitem__(self,to_jid):
|
||||
target=JID(to_jid)
|
||||
if not self.has_key(target.short):
|
||||
def __getitem__(self, to_jid):
|
||||
target = JID(to_jid)
|
||||
if not target.short in self:
|
||||
#we have to create the chat win
|
||||
self[target.short] = self.createChat(target)
|
||||
return dict.__getitem__(self, target.short)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,13 @@ class ProfileNotInCacheError(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class ProfileNotSetError(Exception):
|
||||
"""
|
||||
This error raises when no profile has been set (value @NONE@ is found, but it should have been replaced)
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class NotConnectedProfileError(Exception):
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -195,6 +195,8 @@ class Params(object):
|
|||
info(_('No profile exist yet'))
|
||||
return ""
|
||||
return default # FIXME: temporary, must use real default value, and fallback to first one if it doesn't exists
|
||||
elif profile_key == '@NONE@':
|
||||
raise exceptions.ProfileNotSetError
|
||||
if not self.storage.hasProfile(profile_key):
|
||||
info(_('Trying to access an unknown profile'))
|
||||
return ""
|
||||
|
|
@ -275,11 +277,11 @@ class Params(object):
|
|||
return "true" if result else "false"
|
||||
return result
|
||||
|
||||
def getStringParamA(self, name, category, attr="value", profile_key="@DEFAULT@"):
|
||||
def getStringParamA(self, name, category, attr="value", profile_key="@NONE@"):
|
||||
""" Same as getParamA but for bridge: convert non string value to string """
|
||||
return self.__type_to_string(self.getParamA(name, category, attr, profile_key))
|
||||
|
||||
def getParamA(self, name, category, attr="value", profile_key="@DEFAULT@"):
|
||||
def getParamA(self, name, category, attr="value", profile_key="@NONE@"):
|
||||
"""Helper method to get a specific attribute
|
||||
@param name: name of the parameter
|
||||
@param category: category of the parameter
|
||||
|
|
@ -312,12 +314,12 @@ class Params(object):
|
|||
value = self.__getParam(profile, category, name)
|
||||
return self.__getAttr(node[1], attr, value)
|
||||
|
||||
def asyncGetStringParamA(self, name, category, attr="value", profile_key="@DEFAULT@"):
|
||||
def asyncGetStringParamA(self, name, category, attr="value", profile_key="@NONE@"):
|
||||
d = self.asyncGetParamA(name, category, attr, profile_key)
|
||||
d.addCallback(self.__type_to_string)
|
||||
return d
|
||||
|
||||
def asyncGetParamA(self, name, category, attr="value", profile_key="@DEFAULT@"):
|
||||
def asyncGetParamA(self, name, category, attr="value", profile_key="@NONE@"):
|
||||
"""Helper method to get a specific attribute
|
||||
@param name: name of the parameter
|
||||
@param category: category of the parameter
|
||||
|
|
@ -678,7 +680,8 @@ class Memory(object):
|
|||
param_file_xml = os.path.expanduser(self.getConfig('', 'local_dir') +
|
||||
self.host.get_const('savefile_param_xml'))
|
||||
|
||||
self.params.save_xml(param_file_xml)
|
||||
# TODO: check if this method is still needed
|
||||
#self.params.save_xml(param_file_xml)
|
||||
debug(_("params saved"))
|
||||
|
||||
def getProfilesList(self):
|
||||
|
|
@ -894,16 +897,16 @@ class Memory(object):
|
|||
|
||||
return self.subscriptions[profile]
|
||||
|
||||
def getStringParamA(self, name, category, attr="value", profile_key='@DEFAULT@'):
|
||||
def getStringParamA(self, name, category, attr="value", profile_key='@NONE@'):
|
||||
return self.params.getStringParamA(name, category, attr, profile_key)
|
||||
|
||||
def getParamA(self, name, category, attr="value", profile_key='@DEFAULT@'):
|
||||
def getParamA(self, name, category, attr="value", profile_key='@NONE@'):
|
||||
return self.params.getParamA(name, category, attr, profile_key)
|
||||
|
||||
def asyncGetParamA(self, name, category, attr="value", profile_key='@DEFAULT@'):
|
||||
def asyncGetParamA(self, name, category, attr="value", profile_key='@NONE@'):
|
||||
return self.params.asyncGetParamA(name, category, attr, profile_key)
|
||||
|
||||
def asyncGetStringParamA(self, name, category, attr="value", profile_key='@DEFAULT@'):
|
||||
def asyncGetStringParamA(self, name, category, attr="value", profile_key='@NONE@'):
|
||||
return self.params.asyncGetStringParamA(name, category, attr, profile_key)
|
||||
|
||||
def getParamsUI(self, security_limit, profile_key):
|
||||
|
|
|
|||
|
|
@ -199,7 +199,8 @@ class XEP_0054(object):
|
|||
|
||||
def vcard_err(self, failure, profile):
|
||||
"""Called when something is wrong with registration"""
|
||||
error(_("Can't find VCard of %s") % failure.value.stanza['from'])
|
||||
if failure.value.stanza.hasAttribute("from"):
|
||||
error(_("Can't find VCard of %s") % failure.value.stanza['from'])
|
||||
self.host.bridge.actionResult("SUPPRESS", failure.value.stanza['id'], {}, profile) # FIXME: maybe an error message would be better
|
||||
|
||||
def getCard(self, target_s, profile_key='@DEFAULT@'):
|
||||
|
|
|
|||
Loading…
Reference in a new issue