|
|
@ -4013,7 +4013,7 @@ int CLuaIHMRyzom::setArkPowoOptions(CLuaState &ls)
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
int CLuaIHMRyzom::readUserChannels(CLuaState &ls)
|
|
|
|
int CLuaIHMRyzom::readUserChannels(CLuaState &ls)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string filename = CInterfaceManager::getInstance()->getSaveFileName("channels", "xml");
|
|
|
|
const std::string filename = CInterfaceManager::getInstance()->getSaveFileName("channels", "xml");
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CIFile fd;
|
|
|
|
CIFile fd;
|
|
|
@ -4024,37 +4024,43 @@ int CLuaIHMRyzom::readUserChannels(CLuaState &ls)
|
|
|
|
|
|
|
|
|
|
|
|
xmlKeepBlanksDefault(0);
|
|
|
|
xmlKeepBlanksDefault(0);
|
|
|
|
xmlNodePtr root = stream.getRootNode();
|
|
|
|
xmlNodePtr root = stream.getRootNode();
|
|
|
|
if (!root)
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
if (!root) return 0;
|
|
|
|
|
|
|
|
|
|
|
|
CXMLAutoPtr prop;
|
|
|
|
CXMLAutoPtr prop;
|
|
|
|
|
|
|
|
|
|
|
|
// table
|
|
|
|
|
|
|
|
ls.newTable();
|
|
|
|
ls.newTable();
|
|
|
|
CLuaObject output(ls);
|
|
|
|
CLuaObject output(ls);
|
|
|
|
|
|
|
|
|
|
|
|
uint nb = 0;
|
|
|
|
std::vector< string > tags;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// allowed tags
|
|
|
|
|
|
|
|
tags.push_back("id");
|
|
|
|
|
|
|
|
tags.push_back("name");
|
|
|
|
|
|
|
|
tags.push_back("rgba");
|
|
|
|
|
|
|
|
tags.push_back("passwd");
|
|
|
|
|
|
|
|
|
|
|
|
xmlNodePtr node = root->children;
|
|
|
|
xmlNodePtr node = root->children;
|
|
|
|
|
|
|
|
uint nb = 0;
|
|
|
|
while (node)
|
|
|
|
while (node)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
prop = xmlGetProp(node, (xmlChar*)"name");
|
|
|
|
ls.newTable();
|
|
|
|
if (!prop)
|
|
|
|
CLuaObject nodeTable(ls);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
std::string name = (const char*)prop;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prop = xmlGetProp(node, (xmlChar*)"passwd");
|
|
|
|
for (uint i = 0; i < tags.size(); i++)
|
|
|
|
if (!prop)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
prop = xmlGetProp(node, (xmlChar*)tags[i].c_str());
|
|
|
|
std::string pass = (const char*)prop;
|
|
|
|
if (!prop) return 0;
|
|
|
|
|
|
|
|
|
|
|
|
output.setValue(name.c_str(), pass.c_str());
|
|
|
|
nodeTable.setValue(tags[i].c_str(), (const char *)prop);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
output.setValue(toString("%i", nb).c_str(), nodeTable);
|
|
|
|
node = node->next;
|
|
|
|
node = node->next;
|
|
|
|
nb++;
|
|
|
|
nb++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
output.push();
|
|
|
|
// no exception
|
|
|
|
// no exception
|
|
|
|
fd.close();
|
|
|
|
fd.close();
|
|
|
|
|
|
|
|
|
|
|
|
// release lua table
|
|
|
|
|
|
|
|
output.push();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nlinfo("parse %s", filename.c_str());
|
|
|
|
nlinfo("parse %s", filename.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -4066,7 +4072,6 @@ int CLuaIHMRyzom::readUserChannels(CLuaState &ls)
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
int CLuaIHMRyzom::saveUserChannels(CLuaState &ls)
|
|
|
|
int CLuaIHMRyzom::saveUserChannels(CLuaState &ls)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const char *funcName = "saveUserChannels";
|
|
|
|
const char *funcName = "saveUserChannels";
|
|
|
@ -4084,7 +4089,7 @@ int CLuaIHMRyzom::saveUserChannels(CLuaState &ls)
|
|
|
|
CLuaObject params;
|
|
|
|
CLuaObject params;
|
|
|
|
params.pop(ls);
|
|
|
|
params.pop(ls);
|
|
|
|
|
|
|
|
|
|
|
|
std::string filename = CInterfaceManager::getInstance()->getSaveFileName("channels", "xml");
|
|
|
|
const std::string filename = CInterfaceManager::getInstance()->getSaveFileName("channels", "xml");
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
COFile fd;
|
|
|
|
COFile fd;
|
|
|
@ -4097,27 +4102,38 @@ int CLuaIHMRyzom::saveUserChannels(CLuaState &ls)
|
|
|
|
xmlNodePtr node = xmlNewDocNode(doc, NULL, (const xmlChar*)"interface_config", NULL);
|
|
|
|
xmlNodePtr node = xmlNewDocNode(doc, NULL, (const xmlChar*)"interface_config", NULL);
|
|
|
|
xmlDocSetRootElement(doc, node);
|
|
|
|
xmlDocSetRootElement(doc, node);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string key, value;
|
|
|
|
ENUM_LUA_TABLE(params, it)
|
|
|
|
ENUM_LUA_TABLE(params, it)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!it.nextKey().isString())
|
|
|
|
if (it.nextKey().type() == LUA_TSTRING)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
xmlNodePtr newNode = xmlNewChild(node, NULL, (const xmlChar*)"channels", NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (it.nextValue().type() == LUA_TTABLE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
xmlSetProp(newNode, (const xmlChar*)"id", (const xmlChar*)it.nextKey().toString().c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ENUM_LUA_TABLE(it.nextValue(), itt)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!itt.nextKey().isString())
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
if (!it.nextValue().isString())
|
|
|
|
if (!itt.nextValue().isString())
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
std::string name = it.nextKey().toString();
|
|
|
|
key = itt.nextKey().toString();
|
|
|
|
std::string pass = it.nextValue().toString();
|
|
|
|
value = itt.nextValue().toString();
|
|
|
|
|
|
|
|
|
|
|
|
xmlNodePtr newNode = xmlNewChild(node, NULL, (const xmlChar*)"channels", NULL);
|
|
|
|
xmlSetProp(newNode, (const xmlChar*)key.c_str(), (const xmlChar*)value.c_str());
|
|
|
|
xmlSetProp(newNode, (const xmlChar*)"name", (const xmlChar*)name.c_str());
|
|
|
|
}
|
|
|
|
xmlSetProp(newNode, (const xmlChar*)"passwd", (const xmlChar*)pass.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stream.flush();
|
|
|
|
stream.flush();
|
|
|
|
// no exception
|
|
|
|
|
|
|
|
fd.close();
|
|
|
|
fd.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nlinfo("save %s", filename.c_str());
|
|
|
|
nlinfo("save %s", filename.c_str());
|
|
|
|
if (verbose)
|
|
|
|
if (verbose)
|
|
|
|
CInterfaceManager::getInstance()->displaySystemInfo("Saving " + filename);
|
|
|
|
CInterfaceManager::getInstance()->displaySystemInfo("Save " + filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (const Exception &e)
|
|
|
|
catch (const Exception &e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|