From 7913223f2c35bf69af68d28d2f11dde158c94e73 Mon Sep 17 00:00:00 2001 From: Christian Klinger Date: Thu, 19 May 2016 18:17:52 +0200 Subject: added --manager-only (and removed the ipList-feature) --- src/server/main.cpp | 22 ++++++++++++++-------- src/server/mainwindow/mainwindow.cpp | 34 ++++++++++++++-------------------- src/server/mainwindow/mainwindow.h | 5 +---- src/server/util/global.cpp | 1 + src/server/util/global.h | 3 +++ 5 files changed, 33 insertions(+), 32 deletions(-) (limited to 'src/server') diff --git a/src/server/main.cpp b/src/server/main.cpp index 8729af5..71657d8 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -2,21 +2,27 @@ #include #include "mainwindow/mainwindow.h" #include "util/util.h" +#include "util/global.h" #include "../shared/settings.h" int main(int argc, char** argv) { - QString ipListUrl; - if (argc != 2) - { - ipListUrl = ""; - } else { - ipListUrl = argv[1]; - } QApplication app(argc, argv); + app.setOrganizationName("openslx"); app.setOrganizationDomain("openslx.org"); app.setApplicationName("pvsmgr"); + + qDebug() << "args are " << app.arguments() << ""; + for (QString a : app.arguments()) { + if (a == "--manager-only") { + Global::manager_only = true; + break; + } else if (!a.endsWith("pvsmgr")) { + qDebug() << "ignoring unknown argument: \"" << a << "\""; + } + } + QStringList supportedStyles = QStyleFactory::keys(); for (QString style : PREFERRED_STYLES) { if (supportedStyles.contains(style)) { @@ -57,6 +63,6 @@ int main(int argc, char** argv) translator.load(":pvsmgr"); app.installTranslator(&translator); - MainWindow pvsmgr(ipListUrl); + MainWindow pvsmgr; return app.exec(); } diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 6d8d02f..c7d8a9e 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -38,6 +38,7 @@ #include "ui_mainwindow.h" #include "ui_reloadroom.h" +#include #include #define sStrTutorNdef MainWindow::tr("No tutor defined.") @@ -51,15 +52,18 @@ #define sStrNoDestAv MainWindow::tr("No projection destination available.") using std::vector; +using std::cout; +using std::endl; /***************************************************************************//** * Initialize MainWindow and ListenServer. * @param ipListUrl * @param parent */ -MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : +MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow), _tbIconSize(24), _tbArea(Qt::LeftToolBarArea) { + qDebug() << "MainWindow(parent)"; _mode = Mode::Multicast; _streamingSource = 0; @@ -95,12 +99,6 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : ui->action_Exit->setStatusTip(tr("Exit")); ui->action_Lock->setStatusTip(tr("Lock or Unlock all Clients")); - // Initialize FileDownloader. - if (!ipListUrl.isEmpty()) - { - _fileDownloader.connectSlot(this, SLOT(onTutorListDownloaded(QByteArray&))); - _fileDownloader.downloadFile(QUrl(ipListUrl)); - } // Close button in tool bar connect(ui->action_Exit, SIGNAL(triggered()), this, SLOT(onButtonExit())); @@ -371,6 +369,7 @@ QSize minimalGridSize(const QMap& clientPositions, QSize& clien */ void MainWindow::tryToUseRoomTemplate() { + qDebug() << "tryToUseRoomTemplate()"; QMap roomsList; SYSTEM_SETTINGS(conf); @@ -433,9 +432,16 @@ void MainWindow::tryToUseRoomTemplate() roomsList.insert(roomName, r); } Global::setRooms(roomsList); - if (myRoom != "") { + if (myRoom == "") { + /* so apparently this is not a manager of a room */ + if (Global::manager_only) { + cout << "exiting because of the argument --manager-only was set and this computer is not a manager" << endl; + exit(0); + } + } else { switchRoomTo(myRoom); } + } /***************************************************************************//** @@ -650,18 +656,6 @@ void MainWindow::reset() * Slots */ -/***************************************************************************//** - * Extract information from downloaded tutorList. - * Split downloaded file by new line and store IPs in _tutorList. - * @param tutorList - */ -void MainWindow::onTutorListDownloaded(QByteArray& tutorList) -{ - QString data = QString::fromUtf8(tutorList.constData(), tutorList.size()); - _tutorList = data.split(QRegExp("[\r\n]"),QString::SkipEmptyParts); - qDebug() << _tutorList; -} - /***************************************************************************//** * Place Frame to from user specified position. diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index 7d3910d..ab3befd 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -4,7 +4,6 @@ #include #include #include "../net/client.h" -#include "../net/filedownloader.h" class SessionNameWindow; class ConnectionFrame; @@ -27,7 +26,7 @@ class MainWindow : public QMainWindow public: - MainWindow(QString ipListUrl, QWidget *parent = 0); + MainWindow(QWidget *parent = 0); ~MainWindow(); private: @@ -70,7 +69,6 @@ private: QList _clientFrames; ListenServer *_listenServer; DiscoveryListener *_discoveryListener; - FileDownloader _fileDownloader; QStringList _tutorList; void placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferred = QPoint(0,0)); @@ -100,7 +98,6 @@ private: void switchRoomTo(QString); protected slots: - void onTutorListDownloaded(QByteArray& tutorList); void onSessionNameClick(); void onSessionNameUpdate(); diff --git a/src/server/util/global.cpp b/src/server/util/global.cpp index 8bb89d0..41f6389 100644 --- a/src/server/util/global.cpp +++ b/src/server/util/global.cpp @@ -50,3 +50,4 @@ const Room* Global::getCurrentRoom() { return defaultRoom; } } +bool Global::manager_only = false; diff --git a/src/server/util/global.h b/src/server/util/global.h index f9dc327..59bed27 100644 --- a/src/server/util/global.h +++ b/src/server/util/global.h @@ -44,6 +44,8 @@ public: static void setSessionName(const QString& name); static void setSessionName(); + static bool manager_only; + static void setRooms(const QMap & roomList); static const QMap & getRooms() { return _rooms; @@ -57,4 +59,5 @@ public: static const Room* getCurrentRoom(); }; + #endif /* GLOBAL_H_ */ -- cgit v1.2.3-55-g7522