summaryrefslogtreecommitdiffstats
path: root/src/server/main.cpp
blob: 0c09f91d7254e3996e4c57a3fe283840091c9311 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <iostream>
#include <stdlib.h>
#include "mainwindow/mainwindow.h"
#include "util/util.h"
#include "util/global.h"
#include "../shared/settings.h"

using std::cout;
using std::endl;

void usage() {
	cout << "USAGE pvsmgr [OPTIONS]" << endl;
	cout << "OPTIONS: " << endl;
	cout << "--manager-only" << endl;
	cout << "    pvsmgr terminates if this computer is not a manager of a room" << endl;
	cout << "--config=INIFILE" << endl;
	cout << "    read configuration from INIFILE instead of default path (/opt/openslx/pvs2/pvs2.ini) " << endl;
	cout << "--usage" << endl;
	cout << "    shows this message" << endl;
}


int main(int argc, char** argv)
{
	QApplication app(argc, argv);

	app.setOrganizationName("openslx");
	app.setOrganizationDomain("openslx.org");
	app.setApplicationName("pvsmgr");

	for (QString a : app.arguments()) {
		if (a == "--manager-only") {
			Global::manager_only = true;
			break;
		} else if (a.startsWith("--config=")) {
				Global::setIniPath(a.mid(9));
		} else if (a == "--usage" || a == "--help") {
			usage();
			exit(0);
		} else if (!a.endsWith("pvsmgr")) {
			qDebug() << "ignoring unknown argument: \"" << a << "\"";
		}
	}

	QStringList supportedStyles = QStyleFactory::keys();
	for (QString style : PREFERRED_STYLES) {
		if (supportedStyles.contains(style)) {
			qDebug() << "Setting style to: " << style;
			app.setStyle(style);
			break;
		}
	}
	qsrand((uint)QDateTime::currentMSecsSinceEpoch());


	// Set the global path of the settings
	QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, "/opt/");
	QSharedPointer<QSettings> sys = Global::getSettings();
	qDebug() << "System settings are in:" << sys->fileName();
	QFileInfo sysfi(sys->fileName());


	// use system locale as language to translate gui
	QTranslator translator;
	translator.load(":pvsmgr");
	app.installTranslator(&translator);

	MainWindow pvsmgr;
	return app.exec();
}