summaryrefslogtreecommitdiffstats
path: root/src/server/util
diff options
context:
space:
mode:
authorChristian Klinger2016-09-26 11:45:35 +0200
committerChristian Klinger2016-09-26 11:45:35 +0200
commitf9d165687aac7423c86554b7e73ade99f9e1f3ea (patch)
tree27a8d541e2c510a09292d7240fb64f38f11218fc /src/server/util
parentremoved USER_SETTINGS etc. (diff)
downloadpvs2-f9d165687aac7423c86554b7e73ade99f9e1f3ea.tar.gz
pvs2-f9d165687aac7423c86554b7e73ade99f9e1f3ea.tar.xz
pvs2-f9d165687aac7423c86554b7e73ade99f9e1f3ea.zip
added the --config=FILE parameter and got rid of the SETTINGS macro.
Diffstat (limited to 'src/server/util')
-rw-r--r--src/server/util/global.cpp15
-rw-r--r--src/server/util/global.h8
-rw-r--r--src/server/util/util.h4
3 files changed, 23 insertions, 4 deletions
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<QSettings> Global::getSettings() {
+ QSharedPointer<QSettings> set;
+ if (_iniPath == "") {
+ /* default location (system scope) */
+ set = QSharedPointer<QSettings>(new QSettings(QSettings::IniFormat, QSettings::SystemScope, "openslx/pvs2", "pvs2"));
+ } else {
+ /* use _iniPath to find ini file */
+ set = QSharedPointer<QSettings>(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 <QByteArray>
#include <QMap>
#include <QPair>
+#include <QSettings>
#include <QPoint>
#include <QSize>
#include <QList>
+#include <QSharedPointer>
struct Room {
Room(QMap<QString, QPoint> 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<QSettings> 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
{