summaryrefslogtreecommitdiffstats
path: root/src/util/pvsSettingsManager.cpp
diff options
context:
space:
mode:
authorJohann Latocha2010-08-30 17:21:30 +0200
committerJohann Latocha2010-08-30 17:21:30 +0200
commitc1d871390c75e46bf2cbc71b38796b5c33e67c77 (patch)
treeed76b5490fe8357b810803c095a00e99a4f171ec /src/util/pvsSettingsManager.cpp
parentPVS output errors fixed (diff)
downloadpvs-c1d871390c75e46bf2cbc71b38796b5c33e67c77.tar.gz
pvs-c1d871390c75e46bf2cbc71b38796b5c33e67c77.tar.xz
pvs-c1d871390c75e46bf2cbc71b38796b5c33e67c77.zip
Defect #644 and cleanout some old code
Diffstat (limited to 'src/util/pvsSettingsManager.cpp')
-rw-r--r--src/util/pvsSettingsManager.cpp185
1 files changed, 0 insertions, 185 deletions
diff --git a/src/util/pvsSettingsManager.cpp b/src/util/pvsSettingsManager.cpp
deleted file mode 100644
index a6a742b..0000000
--- a/src/util/pvsSettingsManager.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-#include "pvsSettingsManager.h"
-#include "TextFile.h"
-
-PVSSettingsManager* PVSSettingsManager::getManager()
-{
- if (myself)
- return myself;
- else
- return myself = new PVSSettingsManager;
-}
-
-void PVSSettingsManager::setConfigFile(QString path)
-{
- if (path.size() && fileExists(path))
- {
- _path = path;
- _parseFile(_path);
-
- }
- else
- ConsoleLog writeError(QString("Can't open config file \"").append(QString(path).append("\"")));
-}
-
-bool PVSSettingsManager::hasEntry(QString name)
-{
- for (SettingsIter it = settingsList.begin(); it != settingsList.end(); it++)
- {
- if ((*it).first.compare(name) == 0)
- {
- return true;
- }
- }
- return false;
-}
-
-QString PVSSettingsManager::getEntryString(QString name)
-{
- for (SettingsIter it = settingsList.begin(); it != settingsList.end(); it++)
- {
- if ((*it).first.compare(name) == 0)
- {
- return (*it).second;
- }
- }
- return QString();
-}
-
-void PVSSettingsManager::writeEntry(QString name, QString value)
-{
- if (name.size() && value.size())
- return;
- bool unique = true;
- for (SettingsIter it = settingsList.begin(); it != settingsList.end(); it++)
- {
- if ((*it).first.compare(name) == 0)
- {
- unique = false;
- (*it).second = value;
- break;
- }
- }
- if (unique)
- {
- SettingsEntry tmp(name, value);
- settingsList.push_back(tmp);
- }
-}
-
-
-PVSSettingsManager* PVSSettingsManager::myself = NULL;
-
-PVSSettingsManager::PVSSettingsManager()
-{
-
-}
-
-void PVSSettingsManager::setConfigs()
-{
- //default settings
- _configs.setValue("Chat/chatstate", "on");
- _configs.setValue("Chat/chatmode", "bossmode");
- _configs.setValue("Room/roomId", "0");
- _configs.setValue("VNC/permit", "off");
- _configs.setValue("VNC/quality", "high");
- _configs.sync();
-}
-void PVSSettingsManager::reWriteConfigs(QString set, QString val)
-{
- _configs.setValue(set, val);
- _configs.sync();
-}
-
-void PVSSettingsManager::readConfigs(QString sett, QString vall)
-{
- //TODO: read the config file..
- _configs.value("Chat/chatstate").toBool();
- _configs.value("Chat/chatmode").toString();
- _configs.value("Room/room").toInt();
- _configs.value("VNC/permit").toBool();
- _configs.value("VNC/quality").toString();
-}
-
-void PVSSettingsManager::_parseFile(QString path)
-{
- QString line;
- TextFile file(path);
-
- SettingsList tmpList;
-
- if (file.good())
- {
- while (!file.eof())
- {
- line = file.readLine();
- if (!(line.length() <=1)) // ignore blank
- {
- if (!(line[0] == '#' || line[0] == '/' || line[0] == '[')) // ignore comments and section headers
- {
- SettingsEntry tmp = _parseLine(line);
- if (tmp.first.size() && tmp.second.size())
- {
- bool unique = true;
- for (SettingsIter it = tmpList.begin(); it != tmpList.end(); it++)
- {
- if ((*it).first.compare(tmp.first) == 0)
- {
- unique = false;
- break;
- }
- }
- if (unique)
- tmpList.push_back(tmp);
- }
- }
- }
- }
- }
- else
- {
- ConsoleLog writeError(QString("No configfile \"").append(QString(path).append("\" found or file corrupt.")));
- }
-
- if (tmpList.size())
- settingsList = tmpList;
-}
-#ifdef verbose
-ConsoleLog writeLine(QString("Dumping Config Content of ").append(QString(path).append(" : ")));
-for (SettingsIter it = settingsList.begin(); it != settingsList.end(); it++)
-{
- ConsoleLog writeLine(QString("Option: ").append(QString((*it).first).append(QString(" | Value: ").append((*it).second))));
-}
-ConsoleLog writeLine(QString("End of ").append(QString(path).append(".")));
-#endif
-
-SettingsEntry PVSSettingsManager::_parseLine(QString line)
-{
- QString name;
- QString value;
-
- name = lineSplitter(line, "=\n\t", true);
- value = lineSplitter(line, "=\n\t", false);
-
- if (!(name.size() && value.size()))
- return SettingsEntry("","");
-
-
- // remove whitespaces in front of option name
- for (int i = 0; i < name.size(); i++)
- {
- if (name[i] == '\t' || name[i] == ' ')
- {
- name.remove(i, 1);
- i--;
- }
- else
- break;
- }
- // whitespaces after the value are trimmed by the lineSplitter
-
- SettingsEntry tmp(name, value);
- return tmp;
-}
-
-
-