From f9d165687aac7423c86554b7e73ade99f9e1f3ea Mon Sep 17 00:00:00 2001 From: Christian Klinger Date: Mon, 26 Sep 2016 11:45:35 +0200 Subject: added the --config=FILE parameter and got rid of the SETTINGS macro. --- src/server/util/global.cpp | 15 +++++++++++++++ src/server/util/global.h | 8 ++++++++ src/server/util/util.h | 4 ---- 3 files changed, 23 insertions(+), 4 deletions(-) (limited to 'src/server/util') diff --git a/src/server/util/global.cpp b/src/server/util/global.cpp index bdb462f..990eee1 100644 --- a/src/server/util/global.cpp +++ b/src/server/util/global.cpp @@ -49,3 +49,18 @@ const Room* Global::getCurrentRoom() { } bool Global::manager_only = false; bool Global::_isExam = false; + +QString Global::_iniPath = ""; + +QSharedPointer Global::getSettings() { + QSharedPointer set; + if (_iniPath == "") { + /* default location (system scope) */ + set = QSharedPointer(new QSettings(QSettings::IniFormat, QSettings::SystemScope, "openslx/pvs2", "pvs2")); + } else { + /* use _iniPath to find ini file */ + set = QSharedPointer(new QSettings(Global::_iniPath, QSettings::IniFormat)); + } + set->setIniCodec("UTF-8"); + return set; +} diff --git a/src/server/util/global.h b/src/server/util/global.h index 08ec00a..6ab1c42 100644 --- a/src/server/util/global.h +++ b/src/server/util/global.h @@ -12,9 +12,11 @@ #include #include #include +#include #include #include #include +#include struct Room { Room(QMap cPos, QSize grid, QSize client, QString image, QString tutor) : @@ -41,6 +43,7 @@ private: static QString _currentRoom; static bool _isExam; + static QString _iniPath; public: static const QString& sessionName() { return Global::_sessionName; } @@ -55,11 +58,16 @@ public: return _rooms; } + static void setIniPath(QString s) {_iniPath = s;}; + static QString getIniPath() { return _iniPath; }; + static QSharedPointer getSettings(); + static bool isExam() { return _isExam; } static void setExam(bool b) { _isExam = b; } static void setCurrentRoom(QString room); static const QString& getCurrentRoomName() { return _currentRoom; } + /* returns a pointer to the current room or a pointer to the constant "defaultRoom". * (NEVER returns NULL or undefined) */ static const Room* getCurrentRoom(); diff --git a/src/server/util/util.h b/src/server/util/util.h index dfb70b4..e7a918b 100644 --- a/src/server/util/util.h +++ b/src/server/util/util.h @@ -8,10 +8,6 @@ #define CERTSTORAGE ".config/openslx/pvs2/" -#define SETTINGS(name) \ - QSettings name (QSettings::IniFormat, QSettings::SystemScope, "openslx/pvs2", "pvs2"); \ - name.setIniCodec("UTF-8"); - namespace Util { -- cgit v1.2.3-55-g7522