diff options
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/mainwindow/mainwindow.cpp | 41 | ||||
| -rw-r--r-- | src/server/mainwindow/mainwindow.h | 1 | ||||
| -rw-r--r-- | src/server/net/client.cpp | 5 | ||||
| -rw-r--r-- | src/server/net/discoverylistener.cpp | 54 |
4 files changed, 67 insertions, 34 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 590d5ab..21cde86 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -364,6 +364,20 @@ void MainWindow::mouseReleaseEvent(QMouseEvent* e) } } +/***************************************************************************//** + * @brief reset + */ +void MainWindow::reset() +{ + // Unlock all clients + for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) + if ((*it)->client() != NULL) + (*it)->client()->lockScreen(false); + + // Stop server (Clients get stopped on ACK) + if (_streamingSource != NULL) + _streamingSource->stopVncServer(); +} /* * Slots @@ -529,6 +543,8 @@ void MainWindow::onButtonHelp() */ void MainWindow::onButtonTutorToAll() { + ui->action_Lock->setChecked(false); + if (_tutorFrame == NULL) QMessageBox::critical(this, tr("Projection"), sStrTutorNdef); else if (_tutorFrame->client() == NULL) @@ -544,6 +560,8 @@ void MainWindow::onButtonTutorToAll() */ void MainWindow::onButtonStudentToAll() { + ui->action_Lock->setChecked(false); + if (_selectedFrame == NULL) QMessageBox::critical(this, tr("Projection"), sStrSourceNdef); if (_selectedFrame->client() == NULL) @@ -558,6 +576,8 @@ void MainWindow::onButtonStudentToAll() */ void MainWindow::onButtonTutorToStudent() { + ui->action_Lock->setChecked(false); + if (_selectedFrame == NULL) QMessageBox::critical(this, tr("Projection"), sStrDestNdef); else if (_tutorFrame == NULL) @@ -578,6 +598,8 @@ void MainWindow::onButtonTutorToStudent() */ void MainWindow::onButtonStudentToTutor() { + ui->action_Lock->setChecked(false); + if (_selectedFrame == NULL) QMessageBox::critical(this, tr("Projection"), sStrSourceNdef); else if (_tutorFrame == NULL) @@ -598,6 +620,8 @@ void MainWindow::onButtonStudentToTutor() */ void MainWindow::onButtonStudentToTutorExclusive() { + ui->action_Lock->setChecked(false); + if (_selectedFrame == NULL) QMessageBox::critical(this, tr("Projection"), sStrSourceNdef); else if (_tutorFrame == NULL) @@ -609,7 +633,7 @@ void MainWindow::onButtonStudentToTutorExclusive() else if (_tutorFrame->client() == NULL) QMessageBox::critical(this, tr("Projection"), sStrTutorOffline); else - changeProjection(_tutorFrame->client(), Mode::LockedMulticast, _selectedFrame->client()); + changeProjection(_selectedFrame->client(), Mode::LockedMulticast, _tutorFrame->client()); } @@ -620,14 +644,8 @@ void MainWindow::onButtonStudentToTutorExclusive() */ void MainWindow::onButtonStopProjection() { - // Unlock all clients - for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) - if ((*it)->client() != NULL) - (*it)->client()->lockScreen(false); - - // Stop server (Clients get stopped on ACK) - if (_streamingSource != NULL) - _streamingSource->startVncServer(); + ui->action_Lock->setChecked(false); + reset(); } /***************************************************************************//** @@ -638,6 +656,9 @@ void MainWindow::onButtonStopProjection() */ void MainWindow::onButtonLock(bool checked) { + // Stop all projections + reset(); + for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) { // Check if client is Tutor or the manager is also running on this machine. @@ -662,6 +683,8 @@ void MainWindow::onButtonExit() */ void MainWindow::onButtonSetAsTutor() { + ui->action_Lock->setChecked(false); + // If no frame is selected, warning. if (_selectedFrame == NULL) { diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index 3866db5..0d0d650 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -79,6 +79,7 @@ private: 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); void changeEvent(QEvent *e); diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp index abd739d..135157c 100644 --- a/src/server/net/client.cpp +++ b/src/server/net/client.cpp @@ -46,8 +46,8 @@ Client::Client(QSslSocket* socket) : _socket(socket) msgChlng.setField(_CHALLENGE, _challenge); msgChlng.writeMessage(_socket); // give client 3 seconds to complete handshake - _timerIdAuthTimeout = startTimer(3000); - _timerPingTimeout = startTimer(600000); // for debugging purposes 10min + _timerIdAuthTimeout = startTimer(600000);// TODO undo, for debugging purposes 10min + _timerPingTimeout = startTimer(600000); // TODO undo, for debugging purposes 10min _pingTimeout = QDateTime::currentMSecsSinceEpoch() + PING_TIMEOUT_MS; } @@ -169,7 +169,6 @@ void Client::handleMsg() if (_vncPort <= 0) { qDebug() << "Starting VNC server on client" << _name << " (" << _socket->peerAddress().toString()+_vncPort << ") failed."; - // TODO: Show message on manager } else { diff --git a/src/server/net/discoverylistener.cpp b/src/server/net/discoverylistener.cpp index b308a09..f3d7d39 100644 --- a/src/server/net/discoverylistener.cpp +++ b/src/server/net/discoverylistener.cpp @@ -25,6 +25,33 @@ // +++ static ++++ hash ip address +++ + +/***************************************************************************//** + * @brief DiscoveryListener::DiscoveryListener + */ +DiscoveryListener::DiscoveryListener() : + _socket(this), _counterResetPos(0) +{ + if (!_socket.bind(SERVICE_DISCOVERY_PORT)) + qFatal("Could not bind to service discovery port %d", (int)SERVICE_DISCOVERY_PORT); + connect(&_socket, SIGNAL(readyRead()), this, SLOT(onReadyRead())); + for (int i = 0; i < SD_PACKET_TABLE_SIZE; ++i) + _packetCounter[i] = 0; + startTimer((SPAM_MODERATE_AT_ONCE * SPAM_MODERATE_INTERVAL) / SD_PACKET_TABLE_SIZE + 1); +} + +/***************************************************************************//** + * @brief DiscoveryListener::~DiscoveryListener + */ +DiscoveryListener::~DiscoveryListener() +{ +} + +/***************************************************************************//** + * @brief hash + * @param host + * @return + */ static quint16 hash(const QHostAddress& host) { static quint16 seed1 = 0, seed2 = 0; @@ -70,30 +97,13 @@ static quint16 hash(const QHostAddress& host) return result; } -// +++++++++++++++++++++++++++++++++++ - -DiscoveryListener::DiscoveryListener() : - _socket(this), _counterResetPos(0) -{ - if (!_socket.bind(SERVICE_DISCOVERY_PORT)) - qFatal("Could not bind to service discovery port %d", (int)SERVICE_DISCOVERY_PORT); - connect(&_socket, SIGNAL(readyRead()), this, SLOT(onReadyRead())); - for (int i = 0; i < SD_PACKET_TABLE_SIZE; ++i) - _packetCounter[i] = 0; - startTimer((SPAM_MODERATE_AT_ONCE * SPAM_MODERATE_INTERVAL) / SD_PACKET_TABLE_SIZE + 1); -} - -DiscoveryListener::~DiscoveryListener() -{ - // TODO Auto-generated destructor stub -} - /* * Overrides */ -/** - * Decrease packet counters per source IP in our "spam protection" table. +/***************************************************************************//** + * @brief Decrease packet counters per source IP in our "spam protection" table. + * @param event */ void DiscoveryListener::timerEvent(QTimerEvent* event) { @@ -112,8 +122,8 @@ void DiscoveryListener::timerEvent(QTimerEvent* event) * Slots */ -/** - * Incoming UDP packet on service discovery port - handle. +/***************************************************************************//** + * @brief Incoming UDP packet on service discovery port - handle. */ void DiscoveryListener::onReadyRead() { |
