core: importParams renamed to updateParams: it now updates the parameter instead of appending children if it find an existing one.
This commit is contained in:
parent
a96bbad148
commit
bd7f2d6e84
7 changed files with 15 additions and 10 deletions
|
|
@ -217,7 +217,7 @@ class Params(object):
|
|||
#the node is new
|
||||
return None
|
||||
|
||||
def importParams(self, xml):
|
||||
def updateParams(self, xml):
|
||||
"""import xml in parameters, do nothing if the param already exist
|
||||
@param xml: parameters in xml form"""
|
||||
src_dom = minidom.parseString(xml.encode('utf-8'))
|
||||
|
|
@ -230,7 +230,12 @@ class Params(object):
|
|||
if not node: # The node is new
|
||||
tgt_parent.appendChild(child)
|
||||
else:
|
||||
import_node(node, child)
|
||||
if child.nodeName == "param":
|
||||
# The child update an existing parameter, we replace the node
|
||||
tgt_parent.replaceChild(child, node)
|
||||
else:
|
||||
# the node already exists, we recurse 1 more level
|
||||
import_node(node, child)
|
||||
|
||||
import_node(self.dom.documentElement, src_dom.documentElement)
|
||||
|
||||
|
|
@ -932,8 +937,8 @@ class Memory(object):
|
|||
def setParam(self, name, value, category, security_limit=NO_SECURITY_LIMIT, profile_key='@NONE@'):
|
||||
return self.params.setParam(name, value, category, security_limit, profile_key)
|
||||
|
||||
def importParams(self, xml):
|
||||
return self.params.importParams(xml)
|
||||
def updateParams(self, xml):
|
||||
return self.params.updateParams(xml)
|
||||
|
||||
def setDefault(self, name, category, callback, errback=None):
|
||||
return self.params.setDefault(name, category, callback, errback)
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class CS_Plugin(object):
|
|||
info(_("Plugin CS initialization"))
|
||||
self.host = host
|
||||
#parameters
|
||||
host.memory.importParams(CS_Plugin.params)
|
||||
host.memory.updateParams(CS_Plugin.params)
|
||||
#menu
|
||||
host.importMenu(_("Plugin"), "CouchSurfing", self.menuSelected, help_string=_("Launch CoushSurfing management interface"))
|
||||
self.data = {} # TODO: delete cookies/data after a while
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class IMAP_server(object):
|
|||
self.host = host
|
||||
|
||||
#parameters
|
||||
host.memory.importParams(self.params)
|
||||
host.memory.updateParams(self.params)
|
||||
|
||||
port = int(self.host.memory.getParamA("IMAP Port", "Mail Server"))
|
||||
info(_("Launching IMAP server on port %d"), port)
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class SMTP_server(object):
|
|||
self.host = host
|
||||
|
||||
#parameters
|
||||
host.memory.importParams(self.params)
|
||||
host.memory.updateParams(self.params)
|
||||
|
||||
port = int(self.host.memory.getParamA("SMTP Port", "Mail Server"))
|
||||
info(_("Launching SMTP server on port %d"), port)
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class XmlLog(object):
|
|||
self.host = host
|
||||
|
||||
#parameters
|
||||
host.memory.importParams(self.params)
|
||||
host.memory.updateParams(self.params)
|
||||
|
||||
#bridge
|
||||
host.bridge.addSignal("xmlLog", ".plugin", signature='sss') # args: direction("IN" or "OUT"), xml_data, profile
|
||||
|
|
|
|||
|
|
@ -468,7 +468,7 @@ class XEP_0065(object):
|
|||
self.server_factory = Socks5ServerFactory(host, self.hash_sid_map, lambda sid, success, profile: self._killId(sid, success, profile=profile))
|
||||
|
||||
#parameters
|
||||
host.memory.importParams(XEP_0065.params)
|
||||
host.memory.updateParams(XEP_0065.params)
|
||||
host.memory.setDefault("IP", "File Transfer", self.getExternalIP)
|
||||
port = int(self.host.memory.getParamA("Port", "File Transfer"))
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class XEP_0085(object):
|
|||
self.host = host
|
||||
|
||||
# parameter value is retrieved before each use
|
||||
host.memory.importParams(self.params)
|
||||
host.memory.updateParams(self.params)
|
||||
|
||||
# triggers from core
|
||||
host.trigger.add("MessageReceived", self.messageReceivedTrigger)
|
||||
|
|
|
|||
Loading…
Reference in a new issue