From 846c9135bf20a9653e13e6075900a695ff09b500 Mon Sep 17 00:00:00 2001 From: doitux Date: Wed, 16 May 2007 08:55:49 +0000 Subject: [PATCH] --nowriteaccess first steps --- src/config/configfile.cpp | 244 +++++++++++------- src/config/configfile.h | 6 +- .../joinnetworkgamedialogimpl.cpp | 7 + src/pokerth.cpp | 3 +- 4 files changed, 158 insertions(+), 102 deletions(-) diff --git a/src/config/configfile.cpp b/src/config/configfile.cpp index fe32fbf5..ddf871dd 100644 --- a/src/config/configfile.cpp +++ b/src/config/configfile.cpp @@ -31,77 +31,96 @@ class QtToolsWrapper; -ConfigFile::ConfigFile(bool configFirstStart) +ConfigFile::ConfigFile(int argc, char **argv) : noWriteAccess(0) { - // !!!! Revisionsnummer der Configdefaults !!!!! - configRev = 18; + int i; - // Pfad und Dateinamen setzen -#ifdef _WIN32 - const char *appDataPath = getenv("AppData"); - if (appDataPath && appDataPath[0] != 0) { - configFileName = appDataPath; + for (i=0; i sonst anlegen TiXmlDocument doc(configFileName); if(!doc.LoadFile()){ @@ -177,9 +197,10 @@ ConfigFile::ConfigFile(bool configFirstStart) updateConfig(myConfigState) ; } } + + + fillBuffer(); } - - fillBuffer(); } @@ -392,56 +413,81 @@ int ConfigFile::readConfigInt(string varName) void ConfigFile::writeConfigInt(string varName, int varCont) { - - TiXmlDocument doc(configFileName); - if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << configFileName << "\n"; } - TiXmlHandle docHandle( &doc ); - - TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( varName ).ToElement(); - if ( conf ) { - conf->SetAttribute("value", varCont ); - if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; } - } else { - //Wenn nicht gefunden eines neues Anlegen - TiXmlElement* config = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).ToElement(); - - if ( config ) { - - TiXmlElement * confElement1 = new TiXmlElement( varName ); - config->LinkEndChild( confElement1 ); - confElement1->SetAttribute("value", varCont); - + if(!noWriteAccess) { + //writeaccess + TiXmlDocument doc(configFileName); + if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << configFileName << "\n"; } + TiXmlHandle docHandle( &doc ); + + TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( varName ).ToElement(); + if ( conf ) { + conf->SetAttribute("value", varCont ); if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; } + } else { + //Wenn nicht gefunden eines neues Anlegen + TiXmlElement* config = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).ToElement(); + + if ( config ) { + + TiXmlElement * confElement1 = new TiXmlElement( varName ); + config->LinkEndChild( confElement1 ); + confElement1->SetAttribute("value", varCont); + + if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; } + } + } + if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; } + + fillBuffer(); + } + else { + //no writeaccess + size_t i; + string tempString; + ostringstream intToString; + + for (i=0; iSetAttribute("value", varCont ); - } else { - //Wenn nicht gefunden eines neues Anlegen - TiXmlElement* config = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).ToElement(); - if ( config ) { - TiXmlElement * confElement1 = new TiXmlElement( varName ); - config->LinkEndChild( confElement1 ); - confElement1->SetAttribute("value", varCont); - if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; } + if(!noWriteAccess) { + //writeaccess + TiXmlDocument doc(configFileName); + if(!doc.LoadFile()) { cout << "Could Not Load Config-File!!! " << configFileName << "\n"; } + TiXmlHandle docHandle( &doc ); + + TiXmlElement* conf = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( varName ).ToElement(); + if ( conf ) { + conf->SetAttribute("value", varCont ); + } else { + //Wenn nicht gefunden eines neues Anlegen + TiXmlElement* config = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).ToElement(); + if ( config ) { + TiXmlElement * confElement1 = new TiXmlElement( varName ); + config->LinkEndChild( confElement1 ); + confElement1->SetAttribute("value", varCont); + if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; } + } + } + if(!doc.SaveFile()) { cout << "Could Not Save Config-File!!! " << configFileName << "\n"; } + + fillBuffer(); + } + else { + //no writeaccess + size_t i; + for (i=0; ireadConfigInt("CLA_NoWriteAccess")) { + + pushButton_save->setDisabled(TRUE); + pushButton_delete->setDisabled(TRUE); + treeWidget->setDisabled(TRUE); + } + connect( pushButton_connect, SIGNAL( clicked() ), this, SLOT( startClient() ) ); connect( pushButton_save, SIGNAL( clicked() ), this, SLOT( saveServerProfile() ) ); connect( pushButton_delete, SIGNAL( clicked() ), this, SLOT( deleteServerProfile() ) ); diff --git a/src/pokerth.cpp b/src/pokerth.cpp index 565c3def..533dacda 100755 --- a/src/pokerth.cpp +++ b/src/pokerth.cpp @@ -64,8 +64,7 @@ class GuiWrapper; int main( int argc, char **argv ) { //create defaultconfig - bool configFirstStart = 1; - ConfigFile *myConfig = new ConfigFile(configFirstStart); + ConfigFile *myConfig = new ConfigFile(argc, argv); //ENABLE_LEAK_CHECK();