This commit is contained in:
doitux
2007-05-05 20:11:49 +00:00
parent e72c25203b
commit 7b6be9d750
2 changed files with 13 additions and 6 deletions
+9 -3
View File
@@ -112,14 +112,20 @@ ConfigFile::ConfigFile(bool configFirstStart)
if (configFirstStart) { if (configFirstStart) {
//Prüfen ob Configfile existiert --> sonst anlegen //Prüfen ob Configfile existiert --> sonst anlegen
TiXmlDocument doc(configFileName); TiXmlDocument doc(configFileName);
if(!doc.LoadFile()){ createDefaultConfig(); } if(!doc.LoadFile()){
CONFIGSTATE = INEXISTENT;
updateConfig(CONFIGSTATE);
}
else { else {
//Prüfen ob die Revision stimmt ansonsten löschen und neue anlegen //Prüfen ob die Revision stimmt ansonsten löschen und neue anlegen
int temp = 0; int temp = 0;
TiXmlHandle docHandle( &doc ); TiXmlHandle docHandle( &doc );
TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( "ConfigRevision" ).ToElement(); TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( "ConfigRevision" ).ToElement();
if ( conf ) { conf->QueryIntAttribute("value", &temp ); } if ( conf ) { conf->QueryIntAttribute("value", &temp ); }
if (temp < configRev) { /*löschen()*/ createDefaultConfig() ;} if (temp < configRev) { /*löschen()*/
CONFIGSTATE = OLD;
updateConfig(CONFIGSTATE) ;
}
} }
} }
} }
@@ -129,7 +135,7 @@ ConfigFile::~ConfigFile()
{ {
} }
void ConfigFile::createDefaultConfig() { void ConfigFile::updateConfig(CONFIGSTATE) {
QtToolsInterface *myQtToolsInterface = new QtToolsWrapper; QtToolsInterface *myQtToolsInterface = new QtToolsWrapper;
+4 -3
View File
@@ -23,15 +23,15 @@
#include "tinyxml.h" #include "tinyxml.h"
#include <string> #include <string>
enum CONFIGSTATE { Inexistens, Old };
class ConfigFile{ class ConfigFile{
public: public:
ConfigFile(bool configFirstStart =0); ConfigFile(bool configFirstStart =0);
~ConfigFile(); ~ConfigFile();
void createDefaultConfig(); void updateConfig(CONFIGSTATE);
std::string readConfigString(std::string varName); std::string readConfigString(std::string varName);
void writeConfigString(std::string varName, std::string varCont); void writeConfigString(std::string varName, std::string varCont);
@@ -45,6 +45,7 @@ private:
std::string logDir; std::string logDir;
std::string dataDir; std::string dataDir;
int configRev; int configRev;
}; };