From 1d771836abd9b0ef4bffbfe7f09a6f8ff2cc85db Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Tue, 17 Jun 2014 12:31:06 +0200 Subject: Moved method isManagerMachine() from MainWindow to Client. isManagerMachine() is now called just once directly in lockScreen(). --- src/server/mainwindow/mainwindow.cpp | 22 ++-------------------- src/server/mainwindow/mainwindow.h | 1 - src/server/net/client.cpp | 17 ++++++++++++++++- src/server/net/client.h | 2 ++ 4 files changed, 20 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 4af9fe1..5063df6 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -273,21 +273,6 @@ void MainWindow::tellClientCurrentSituation(Client* client) } -/***************************************************************************//** - * 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; -} - /***************************************************************************//** * Returns connected client which belongs to given id. * Iterating over ConnectionFrames and comparing id to given id. @@ -719,9 +704,7 @@ 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 isManager = isManagerMachine((*it)->client()); - if ((*it)->client() == NULL || isManager) + if ((*it)->client() == NULL) continue; (*it)->client()->lockScreen(checked); } @@ -972,8 +955,7 @@ void MainWindow::onVncServerStateChange(Client* client) else { // Lock others and stop their clients - bool isManager = isManagerMachine((*it)->client()); - (*it)->client()->lockScreen(_mode == Mode::LockedMulticast && isManager != true); + (*it)->client()->lockScreen(_mode == Mode::LockedMulticast); (*it)->client()->stopVncClient(); } } diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index dbef1b1..851dc84 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -76,7 +76,6 @@ private: void savePosition(ConnectionFrame *cf); void changeProjection(Client *from, Mode mode = Mode::Broadcast, Client *to = NULL); void tellClientCurrentSituation(Client* client); - bool isManagerMachine(Client* client); void reset(); void closeEvent(QCloseEvent *e); diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp index 135157c..584b254 100644 --- a/src/server/net/client.cpp +++ b/src/server/net/client.cpp @@ -11,6 +11,7 @@ #include "../../shared/util.h" #include #include +#include #define CHALLENGE_LEN 20 @@ -310,10 +311,24 @@ void Client::stopVncClient() } } +/***************************************************************************//** + * Checks if client and manager runs on same machine. + * @return Return true, if pvsmanager is running on client. + */ +bool Client::isManagerMachine() +{ + foreach (const QHostAddress &address, QNetworkInterface::allAddresses()) + if (address != QHostAddress(QHostAddress::LocalHost) + && this != NULL + && this->ip() == address.toString()) + return true; + return false; +} + /******************************************************************************/ void Client::lockScreen(bool lock) { - if (!_isTutor && _locked != lock){ + if (!_isTutor && _locked != lock && !isManagerMachine()){ _locked = lock; NetworkMessage msg; msg.setField(_ID, _LOCK); diff --git a/src/server/net/client.h b/src/server/net/client.h index 1031838..6872959 100644 --- a/src/server/net/client.h +++ b/src/server/net/client.h @@ -71,6 +71,8 @@ private: static int _clientIdCounter; + bool isManagerMachine(); + void handleMsg(); void sendMessage(NetworkMessage& message); -- cgit v1.2.3-55-g7522