summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Klinger2016-05-30 12:28:21 +0200
committerChristian Klinger2016-05-30 12:28:21 +0200
commita7f5105baba838dfeb0492530bead41abc69b226 (patch)
tree48d625f3593098ef61fd956f70f4233dd626dead
parentAdded examMode to server (this also changes the style of the toolbar) (diff)
downloadpvs2-a7f5105baba838dfeb0492530bead41abc69b226.tar.gz
pvs2-a7f5105baba838dfeb0492530bead41abc69b226.tar.xz
pvs2-a7f5105baba838dfeb0492530bead41abc69b226.zip
Added "--exam-mode" option.
This might break things because the old way to specify a session is not valid anymore. Please use "--session=1234" to specify session.
-rw-r--r--src/client/main.cpp47
1 files changed, 32 insertions, 15 deletions
diff --git a/src/client/main.cpp b/src/client/main.cpp
index 9b1fa81..602eee7 100644
--- a/src/client/main.cpp
+++ b/src/client/main.cpp
@@ -4,16 +4,30 @@
int main(int argc, char** argv)
{
- if (argc > 2) {
- std::cerr << "Usage: " << argv[0] << " [sessionId] | --auto" << std::endl;
- exit(EXIT_FAILURE);
- }
+ bool option_auto = false;
+ bool option_session = false;
+ bool option_exam_mode = false;
+ QString sessionName;
QApplication app(argc, argv);
app.setOrganizationName("openslx");
app.setOrganizationDomain("openslx.org");
app.setApplicationName("pvsclient");
+ for (QString a : app.arguments()) {
+ if (a == "--exam-mode") {
+ option_exam_mode = true;
+ } else if (a == "--auto") {
+ option_auto = true;
+ } else if (a.startsWith("--session=")) {
+ option_session= true;
+ sessionName= a.replace("--session=", "");
+
+ } else if (!a.endsWith("pvsclient")) {
+ qDebug() << "ignoring unknown argument: \"" << a << "\"";
+ }
+ }
+
qsrand((uint)QDateTime::currentMSecsSinceEpoch());
@@ -47,16 +61,19 @@ int main(int argc, char** argv)
translator.load(":pvsclient");
app.installTranslator(&translator);
- if (argc == 2) {
- if (argv[1] == std::string("--auto")) {
- qDebug() << "Calling Toolbar(true)";
- new Toolbar(true); // auto connect client without session ID.
- } else {
- new Toolbar(QByteArray(argv[1])); // connect client with given session ID.
- }
- } else {
- new Toolbar(); // create normal client.
- }
-
+ Toolbar* toolbar;
+ if (option_auto) {
+ qDebug() << "Calling Toolbar(true) (autoConnect)";
+ toolbar = new Toolbar(true); // auto connect client without session ID.
+ } else if (option_session) {
+ qDebug() << "Session ID";
+ toolbar = new Toolbar(sessionName.toUtf8()); // connect client with given session ID.
+ } else {
+ qDebug() << "just client mode";
+ toolbar = new Toolbar(); // create normal client.
+ }
+ if (option_exam_mode) {
+ toolbar->setVisible(false);
+ }
return app.exec();
}