From 43a9ed4776d6036b71de487a0a4b22a395ba457b Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Mon, 2 Jun 2014 15:24:10 +0200 Subject: Put Check if manager is running on machine into method. If student2tutor_exclusive is running, the manager running machine is not locked now. --- src/server/mainwindow/mainwindow.cpp | 30 ++++++++++++++++++++---------- src/server/mainwindow/mainwindow.h | 1 + 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 7279869..590d5ab 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -276,6 +276,21 @@ void MainWindow::tellClientCurrentSituation(Client* client) client->lockScreen(true); } +/***************************************************************************//** + * Checks if client and manager runs on same machine. + * @param client + * @return Return true, if pvsmanager is running on client. + */ +bool MainWindow::isManagerMachine(Client* client) +{ + foreach (const QHostAddress &address, QNetworkInterface::allAddresses()) + if (address != QHostAddress(QHostAddress::LocalHost) + && client != NULL + && client->ip() == address.toString()) + return true; + return false; +} + /* * Overridden methods */ @@ -626,15 +641,9 @@ void MainWindow::onButtonLock(bool checked) for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) { // Check if client is Tutor or the manager is also running on this machine. - bool isManagerMachine = false; - foreach (const QHostAddress &address, QNetworkInterface::allAddresses()) - if (address != QHostAddress(QHostAddress::LocalHost) - && (*it)->client() != NULL - && (*it)->client()->ip() == address.toString()) - isManagerMachine = true; - - if ((*it)->client() == NULL || isManagerMachine) - continue; // Don't lock the tutor or the manager running machine. + bool isManager = isManagerMachine((*it)->client()); + if ((*it)->client() == NULL || isManager) + continue; (*it)->client()->lockScreen(checked); } } @@ -874,7 +883,8 @@ void MainWindow::onVncServerStateChange(Client* client) else { // Lock others and stop their clients - (*it)->client()->lockScreen(_mode == Mode::LockedMulticast); + bool isManager = isManagerMachine((*it)->client()); + (*it)->client()->lockScreen(_mode == Mode::LockedMulticast && isManager != true); (*it)->client()->stopVncClient(); } } diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index 25eb9aa..3866db5 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -78,6 +78,7 @@ private: bool isValidClient(Client* client); void changeProjection(Client *from, Mode mode = Mode::Broadcast, Client *to = NULL); void tellClientCurrentSituation(Client* client); + bool isManagerMachine(Client* client); void closeEvent(QCloseEvent *e); void changeEvent(QEvent *e); -- cgit v1.2.3-55-g7522 From 266f172e2c5eac02a0e1e480cadb5ba1a5098cb4 Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Mon, 2 Jun 2014 18:18:14 +0200 Subject: Removed some unnecessary qDebug comments. --- src/server/mainwindow/mainwindow.cpp | 4 +--- src/server/mainwindow/mainwindow.h | 1 - src/server/net/listenserver.cpp | 1 - src/server/net/sslserver.cpp | 1 - 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 21cde86..c1e39f3 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -101,6 +101,7 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : connect(ui->action_Lock, SIGNAL(toggled(bool)), this, SLOT(onButtonLock(bool))); connect(ui->action_Help, SIGNAL(triggered()), this, SLOT(onButtonHelp())); + /* Stuff for the button lock */ _buttonLockTimer = new QTimer(this); _buttonLockTimer->setSingleShot(true); @@ -718,7 +719,6 @@ void MainWindow::onButtonSetAsTutor() */ void MainWindow::onClientConnected(Client* client) { - qDebug("ListenServer told MainWindow about new connection"); connect(client, SIGNAL(authenticating(Client*, ClientLogin*)), this, SLOT(onClientAuthenticating(Client*, ClientLogin*))); connect(client, SIGNAL(authenticated(Client*)), this, SLOT(onClientAuthenticated(Client*))); } @@ -735,7 +735,6 @@ void MainWindow::onClientConnected(Client* client) */ void MainWindow::onClientAuthenticating(Client* client, ClientLogin* request) { - qDebug("onClientAuthenticating - Slot was called."); disconnect(client, SIGNAL(authenticating(Client*, ClientLogin*)), this, SLOT(onClientAuthenticating(Client*, ClientLogin*))); if (!request->accept) // Another receiver of that signal already rejected the client, so nothing to do return; @@ -783,7 +782,6 @@ void MainWindow::onClientAuthenticating(Client* client, ClientLogin* request) */ void MainWindow::onClientAuthenticated(Client* client) { - qDebug("Entering onClientAuthenticated - Slot."); disconnect(client, SIGNAL(authenticated(Client*)), this, SLOT(onClientAuthenticated(Client*))); connect(client, SIGNAL(vncServerStateChange(Client*)), this, SLOT(onVncServerStateChange(Client*)), Qt::QueuedConnection); connect(client, SIGNAL(vncClientStateChange(Client*)), this, SLOT(onVncClientStateChange(Client*)), Qt::QueuedConnection); diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index 0d0d650..a15c12f 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -86,7 +86,6 @@ private: void resizeEvent(QResizeEvent *e); void mouseReleaseEvent(QMouseEvent* e); - protected slots: void onTutorListDownloaded(QByteArray& tutorList); void onSessionNameClick(); diff --git a/src/server/net/listenserver.cpp b/src/server/net/listenserver.cpp index 859ee33..8eb3750 100644 --- a/src/server/net/listenserver.cpp +++ b/src/server/net/listenserver.cpp @@ -32,7 +32,6 @@ ListenServer::~ListenServer() */ void ListenServer::newClientConnection() { - qDebug("Listenserver::newClientConnection()."); QSslSocket* sock; while ((sock = (QSslSocket*)_server.nextPendingConnection()) != NULL) { diff --git a/src/server/net/sslserver.cpp b/src/server/net/sslserver.cpp index 65a40b4..4ea3991 100644 --- a/src/server/net/sslserver.cpp +++ b/src/server/net/sslserver.cpp @@ -36,7 +36,6 @@ SslServer::~SslServer() */ void SslServer::incomingConnection(int socketDescriptor) { - qDebug("SslServer:incomingConnection."); QSslSocket *serverSocket = new QSslSocket(NULL); connect(serverSocket, SIGNAL(sslErrors(const QList &)), this, SLOT(sslErrors(const QList &))); QSslKey key; -- cgit v1.2.3-55-g7522