summaryrefslogtreecommitdiffstats
path: root/src/util
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
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')
-rwxr-xr-xsrc/util/consoleLogger.cpp6
-rw-r--r--src/util/pvsSettingsManager.cpp185
-rw-r--r--src/util/pvsSettingsManager.h50
3 files changed, 1 insertions, 240 deletions
diff --git a/src/util/consoleLogger.cpp b/src/util/consoleLogger.cpp
index ae29989..5d07dbe 100755
--- a/src/util/consoleLogger.cpp
+++ b/src/util/consoleLogger.cpp
@@ -233,14 +233,10 @@ void ConsoleLogger::_prepareLog()
fullpath.append(_logName);
_logFile.open(fullpath.toUtf8().data(), std::ofstream::out | std::ofstream::app);
if (_logFile.good())
- {
_logFileGood = true;
- writeTerminal(QString("LogPath/Name changed to: ").append(fullpath));
- }
else
- {
printf("ERROR: Logfile ( %s ) not accessible/found. Logs will not be available.\n", _logPath.toUtf8().data());
- }
+
_logFile.close();
}
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;
-}
-
-
-
diff --git a/src/util/pvsSettingsManager.h b/src/util/pvsSettingsManager.h
deleted file mode 100644
index 78607eb..0000000
--- a/src/util/pvsSettingsManager.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/// documentation test 1
-/// line 2
-/// line 3
-#ifndef _PVSSETTINGSMANGER_H_
-#define _PVSSETTINGSMANGER_H_
-
-#include <list>
-#include <map>
-#include <src/util/util.h>
-#include <src/util/consoleLogger.h>
-#include <QSettings>
-
-
-/// documentation test 1.1
-/// line 2.1
-/// line 3.1
-
-typedef std::pair<QString, QString> SettingsEntry; ///< first = option name, second = option value
-typedef std::list<SettingsEntry> SettingsList; ///< obvious
-typedef std::list<SettingsEntry>::iterator SettingsIter;
-
-
-class PVSSettingsManager;
-/// documentation test 1.2
-/// line 2.2
-/// line 3.2
-class PVSSettingsManager
-{
-public:
- static PVSSettingsManager* getManager();
- void setConfigFile(QString path);
- bool hasEntry(QString name);
- QString getEntryString(QString name);
- void writeEntry(QString name, QString value);
- void setConfigs();
- void reWriteConfigs(QString set, QString val);
- void readConfigs(QString sett, QString vall);
-private:
- static PVSSettingsManager* myself;
- PVSSettingsManager();
- void _parseFile(QString path);
- SettingsEntry _parseLine(QString line);
- QString _path;
- SettingsList settingsList;
- QSettings _configs;
-
-};
-
-
-#endif