summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
authorManuel Schneider2014-05-20 13:38:28 +0200
committerManuel Schneider2014-05-20 13:38:28 +0200
commit6b3b3b1b4dff54c24a1291fb2787e6e86600ae12 (patch)
treec791662404877c18cc692f3d36b276490fa399f3 /src/server/mainwindow/mainwindow.cpp
parentChanged Layout of helpWindow. Set Icon + Text into QFormLayout. (diff)
downloadpvs2-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/mainwindow/mainwindow.cpp')
-rw-r--r--src/server/mainwindow/mainwindow.cpp110
1 files changed, 14 insertions, 96 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.