From a7f5105baba838dfeb0492530bead41abc69b226 Mon Sep 17 00:00:00 2001 From: Christian Klinger Date: Mon, 30 May 2016 12:28:21 +0200 Subject: 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. --- src/client/main.cpp | 47 ++++++++++++++++++++++++++++++++--------------- 1 file 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(); } -- cgit v1.2.3-55-g7522