diff options
author | Manuel Schneider | 2014-05-20 13:38:28 +0200 |
---|---|---|
committer | Manuel Schneider | 2014-05-20 13:38:28 +0200 |
commit | 6b3b3b1b4dff54c24a1291fb2787e6e86600ae12 (patch) | |
tree | c791662404877c18cc692f3d36b276490fa399f3 /src/server | |
parent | Changed Layout of helpWindow. Set Icon + Text into QFormLayout. (diff) | |
download | pvs2-6b3b3b1b4dff54c24a1291fb2787e6e86600ae12.tar.gz pvs2-6b3b3b1b4dff54c24a1291fb2787e6e86600ae12.tar.xz pvs2-6b3b3b1b4dff54c24a1291fb2787e6e86600ae12.zip |
Reduce codebase
* Drop Prepare MainWindow::prepareForProjection
* Drop redundant code in prepareForProjection (now unicast)
* Adjust comments
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/mainwindow/mainwindow.cpp | 110 | ||||
-rw-r--r-- | src/server/mainwindow/mainwindow.h | 1 | ||||
-rw-r--r-- | src/server/net/client.h | 6 |
3 files changed, 16 insertions, 101 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 60295a3..05cefe5 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -439,6 +439,10 @@ bool MainWindow::isValidClient(Client* client) */ void MainWindow::broadcast(Client *from) { + for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) + if ((*it)->client() != NULL && !(**it).isTutor()) + (*it)->client()->setProjectionSource(false); + // Projection source is never allowed to be an active VNC viewer if (from->isActiveVncClient()) { @@ -536,95 +540,22 @@ void MainWindow::unicast(Client *from, Client *to) */ void MainWindow::unicastExlusive(Client *from, Client *to) { - -} - -/***************************************************************************//** - * Handle VNC settings for a projection from "from" to "to". - * Check if projection source is active vnc client. - * Check if projection is One --> Many or One --> One. - * @param from - * @param to - */ -void MainWindow::prepareForProjection(Client * const from, Client * const to) -{ // Projection source is never allowed to be an active VNC viewer if (from->isActiveVncClient()) - { - qDebug("From is active client, stopping..."); from->stopVncClient(); - } - from->setDesiredProjectionSource(0); - - if (to == NULL) - { - // One to many - qDebug("One to many requested..."); - from->setProjectionSource(true); - - // Set desired projection source on all clients - for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) - { - Client *c = (**it).client(); - if (c == NULL || c->id() == from->id()) - continue; // Self or offline - c->setDesiredProjectionSource(from->id()); - } - - if (from->isActiveVncServer()) - { - // From is already active, if there is at least one active client, assume it is not - // shutting down, so we can directly tell the new client to connect to it - qDebug("Source is already running a VNC server...."); - for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) - { - Client *c = (**it).client(); - if (c == NULL || c->id() == from->id()) - continue; // Self or offline - if (c->currentProjectionSource() != from->id()) - continue; // Other client - // Yep :-) - qDebug("Reusing because of active client"); - this->onVncServerStateChange(from); - return; - } - qDebug("But no active client found...."); - } - // Could not take shortcut, (re)start VNC server on source - qDebug("Starting VNC server on source machine"); - from->startVncServer(); - return; - } - - // One to one is desired, figure out what to do with current client - to->setProjectionSource(false); + // Projection destination is never allowed to be an active VNC server if (to->isActiveVncServer()) - { - if (to->currentProjectionSource() == from->id()) - return; // Nothing to do to->stopVncServer(); - } + + from->setDesiredProjectionSource(0); + to->setProjectionSource(false); to->setDesiredProjectionSource(from->id()); - if (from->isActiveVncServer()) - { - // From is already active, if there is at least one active client, assume it is not - // shutting down, so we can directly tell the new client to connect to it - for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) - { - Client *c = (**it).client(); - if (c == NULL || c->id() == from->id()) - continue; - if (c->currentProjectionSource() != from->id()) - continue; - // Yep :-) - this->onVncServerStateChange(from); - return; - } - } - // Could not take shortcut, (re)start VNC server on source - from->startVncServer(); + if (from->isActiveVncServer()) // From is already active + this->onVncServerStateChange(from); + else // Could not take shortcut, (re)start VNC server on source + from->startVncServer(); } /***************************************************************************//** @@ -639,14 +570,9 @@ void MainWindow::onButtonHelp() * Handle projection from tutor to all. * Get the client who is tutor and set the projectionSource of all * clients, except the tutor ones, to false. - * Call prepareForProjection(from, to). */ void MainWindow::onButtonTutorToAll() { - for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) - if ((*it)->client() != NULL && !(**it).isTutor()) - (*it)->client()->setProjectionSource(false); - if (_tutorFrame == NULL) QMessageBox::critical(this, tr("Projection"), sStrTutorNdef); else if (_tutorFrame->client() == NULL) @@ -659,14 +585,9 @@ void MainWindow::onButtonTutorToAll() * Button projection from one student to all the others. * First get which client is projectionSource and set this one as from. * Set projection source for all clients,except the selected one, to false. - * Then call prepareForProjection(from, Null). */ void MainWindow::onButtonStudentToAll() { - for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) - if ((*it)->client() != NULL && !(*it)->selected()) - (*it)->client()->setProjectionSource(false); - if (_selectedFrame == NULL) QMessageBox::critical(this, tr("Projection"), sStrSourceNdef); if (_selectedFrame->client() == NULL) @@ -678,7 +599,6 @@ void MainWindow::onButtonStudentToAll() /***************************************************************************//** * Handle the projection from Tutor to specific student. * Set the client who is tutor as from and the selected client as to. - * Call prepareForProjection(from, to). */ void MainWindow::onButtonTutorToStudent() { @@ -699,7 +619,6 @@ void MainWindow::onButtonTutorToStudent() /***************************************************************************//** * Handle projection from one student to tutor. * Get the client to project from and get client, who is tutor, as to. - * Call prepareForProjection(from, to). */ void MainWindow::onButtonStudentToTutor() { @@ -787,10 +706,9 @@ void MainWindow::onButtonLock(bool checked) // Check if client is Tutor or the manager is also running on this machine. bool isManagerMachine = false; - foreach (const QHostAddress &address, QNetworkInterface::allAddresses()) { + foreach (const QHostAddress &address, QNetworkInterface::allAddresses()) if (address != QHostAddress(QHostAddress::LocalHost) && c != NULL && c->ip() == address.toString()) - isManagerMachine = true; - } + isManagerMachine = true; if (c == NULL || (**it).isTutor() || isManagerMachine) continue; // Don't lock the tutor or the manager running machine. diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index d6b0265..8340ff3 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -66,7 +66,6 @@ private: ConnectionFrame* createFrame(); bool loadPosition(QSettings& settings, const QString& id, int& x, int& y); void savePosition(ConnectionFrame *cf); - void prepareForProjection(Client * const from, Client * const to); bool isValidClient(Client* client); void broadcast(Client *from); void unicast(Client *from, Client *to); diff --git a/src/server/net/client.h b/src/server/net/client.h index 7bcdc2d..a6d9001 100644 --- a/src/server/net/client.h +++ b/src/server/net/client.h @@ -44,10 +44,8 @@ private: // situation in the GUI in a meaningful way would be hard. int _desiredProjectionSource; - // This boolean tells whether this client is currently the VNC broadcast - // source. This version only allows "one to all others" setups - bool _isProjectionSource; + bool _isProjectionSource; // Tells whether this client is currently the VNC broadcast source. int _currentProjectionSource; QString _vncRwPass, _vncRoPass; @@ -59,7 +57,7 @@ private: // Flag indicating that the client is displaying a remote screen via VNC bool _activeVncClient; - // Flag indicating that the hab been set as a tutor + // Flag indicating that the client has been set as a tutor bool _isTutor; void handleMsg(); |