Fixed parameters loading/saving
- removed unused "parent" argument in importParams - changed "ext" for "tld" in wix jid example
This commit is contained in:
parent
e3a3c1e975
commit
989f660a53
3 changed files with 20 additions and 13 deletions
|
|
@ -404,7 +404,7 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
debug("Add contact request")
|
||||
dlg = wx.TextEntryDialog(
|
||||
self, 'Please enter new contact JID',
|
||||
'Adding a contact', 'name@server.ext')
|
||||
'Adding a contact', 'name@server.tld')
|
||||
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
jid=JID(dlg.GetValue())
|
||||
|
|
|
|||
|
|
@ -470,7 +470,7 @@ class XEP_0065(XMPPHandler):
|
|||
self.client_factory = Socks5ClientFactory()
|
||||
|
||||
#parameters
|
||||
host.memory.importParams(self, XEP_0065.params)
|
||||
host.memory.importParams(XEP_0065.params)
|
||||
host.memory.setDefault("IP", "File Transfert", self.getExternalIP)
|
||||
|
||||
port = int(self.host.memory.getParamA("Port", "File Transfert"))
|
||||
|
|
|
|||
|
|
@ -53,11 +53,19 @@ class Param():
|
|||
|
||||
def load_default_params(self):
|
||||
self.dom = minidom.parseString(Param.default_xml.encode('utf-8'))
|
||||
|
||||
def load(self, file):
|
||||
"""Load parameters from file"""
|
||||
self.dom = minidom.parse(file)
|
||||
|
||||
def save(self, file):
|
||||
"""Save parameters to xml file"""
|
||||
with open(file, 'wb') as xml_file:
|
||||
self.dom.writexml(xml_file)
|
||||
|
||||
def __init__(self, host):
|
||||
debug("Parameters init")
|
||||
self.host = host
|
||||
self.load_default_params()
|
||||
host.registerGeneralCB("registerNewAccount", host.registerNewAccountCB)
|
||||
|
||||
def __get_unique_node(self, parent, tag, name):
|
||||
|
|
@ -74,9 +82,8 @@ class Param():
|
|||
#the node is new
|
||||
return None
|
||||
|
||||
def importParams(self, parent, xml):
|
||||
def importParams(self, xml):
|
||||
"""import xml in parameters, do nothing if the param already exist
|
||||
@param parent: parent class (usefull for callbacks)
|
||||
@param xml: parameters in xml form"""
|
||||
src_dom = minidom.parseString(xml.encode('utf-8'))
|
||||
|
||||
|
|
@ -184,12 +191,10 @@ class Memory:
|
|||
def load(self):
|
||||
"""Load parameters and all memory things from file/db"""
|
||||
|
||||
#first parameters
|
||||
#parameters
|
||||
if os.path.exists(const_SAVEFILE_PARAM):
|
||||
try:
|
||||
#gof: FIXME FIXME FIXME: sauver l'xml et non plus le pickle !!!!!!!
|
||||
with open(const_SAVEFILE_PARAM, 'r') as params_pickle:
|
||||
self.params=pickle.load(params_pickle)
|
||||
self.params.load(const_SAVEFILE_PARAM)
|
||||
debug("params loaded")
|
||||
except:
|
||||
error ("Can't load params !")
|
||||
|
|
@ -210,10 +215,12 @@ class Memory:
|
|||
|
||||
def save(self):
|
||||
"""Save parameters and all memory things to file/db"""
|
||||
with open(const_SAVEFILE_PARAM, 'w') as params_pickle:
|
||||
pickle.dump(self.params, params_pickle)
|
||||
#TODO: need to encrypt files (at least passwords !) and set permissions
|
||||
self.params.save(const_SAVEFILE_PARAM)
|
||||
debug("params saved")
|
||||
with open(const_SAVEFILE_HISTORY, 'w') as history_pickle:
|
||||
pickle.dump(self.history, history_pickle)
|
||||
debug("history saved")
|
||||
|
||||
def addToHistory(self, me_jid, from_jid, to_jid, type, message):
|
||||
me_short=me_jid.userhost()
|
||||
|
|
@ -287,8 +294,8 @@ class Memory:
|
|||
def setParam(self, name, value, category):
|
||||
return self.params.setParam(name, value, category)
|
||||
|
||||
def importParams(self, parent, xml):
|
||||
return self.params.importParams(parent, xml)
|
||||
def importParams(self, xml):
|
||||
return self.params.importParams(xml)
|
||||
|
||||
def setDefault(self, name, category, callback, errback=None):
|
||||
return self.params.setDefault(name, category, callback, errback)
|
||||
|
|
|
|||
Loading…
Reference in a new issue