summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gui/server_normal/mainwindow.ui4
-rw-r--r--src/server/mainwindow/mainwindow.cpp203
-rw-r--r--src/server/mainwindow/mainwindow.h4
-rw-r--r--src/server/net/client.h6
4 files changed, 34 insertions, 183 deletions
diff --git a/gui/server_normal/mainwindow.ui b/gui/server_normal/mainwindow.ui
index 9bf32aa..6d29c97 100644
--- a/gui/server_normal/mainwindow.ui
+++ b/gui/server_normal/mainwindow.ui
@@ -67,8 +67,8 @@
</property>
<property name="iconSize">
<size>
- <width>64</width>
- <height>64</height>
+ <width>48</width>
+ <height>48</height>
</size>
</property>
<attribute name="toolBarArea">
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index e6f7d9d..83a424e 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -442,190 +442,58 @@ void MainWindow::broadcast(Client *from)
{
// Projection source is never allowed to be an active VNC viewer
if (from->isActiveVncClient())
- {
- qDebug("From is active client, stopping...");
from->stopVncClient();
+
+ // Tell all clients to listen to server
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it){
+ if ((*it)->client() != NULL)
+ (*it)->client()->setProjectionSource(false);
}
- from->setDesiredProjectionSource(0);
- qDebug("Broadcast requested...");
+ from->setDesiredProjectionSource(0);
from->setProjectionSource(true);
- // Set desired projection source on all clients
+ // Set desired projection source on all clients, if not "from" or oflline
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 ((*it)->client() != NULL && (*it)->client()->id() != from->id())
+ (*it)->client()->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;
+ if (from->isActiveVncServer()) // From is already active
+ this->onVncServerStateChange(from);
+ else // Could not take shortcut, (re)start VNC server on source
+ from->startVncServer();
}
+
/***************************************************************************//**
- * @brief unicast
+ * @brief MainWindow::unicast
* @param from
* @param to
+ * @param blockOthers
*/
-void MainWindow::unicast(Client *from, Client *to)
+void MainWindow::unicast(Client *from, Client *to, bool blockOthers)
{
// 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);
-
- to->setProjectionSource(false);
- if (to->isActiveVncServer()) // TODO aint this not alway the
- {
- if (to->currentProjectionSource() == from->id()) // TODO SHALL to->VNCSERVER NOT BE CLOSED?
- return; // Nothing to do
+ // Projection destination is never allowed to be an active VNC server
+ if (to->isActiveVncServer())
to->stopVncServer();
- }
- 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();
-}
-/***************************************************************************//**
- * @brief unicastExlusive
- * @param from
- * @param 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);
+ to->setProjectionSource(false);
+ to->setDesiredProjectionSource(from->id());
- 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");
+ if (from->isActiveVncServer()) // From is already active
+ this->onVncServerStateChange(from);
+ else // Could not take shortcut, (re)start VNC server on source
from->startVncServer();
- return;
- }
-
- // One to one is desired, figure out what to do with current client
- to->setProjectionSource(false);
- if (to->isActiveVncServer())
- {
- if (to->currentProjectionSource() == from->id())
- return; // Nothing to do
- to->stopVncServer();
+ if (blockOthers){
+ // TODO: REDESIGN TO FIT THE REQUIREMENTS
}
- 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();
}
/***************************************************************************//**
@@ -640,14 +508,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)
@@ -660,14 +523,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)
@@ -679,7 +537,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()
{
@@ -700,7 +557,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()
{
@@ -735,7 +591,7 @@ void MainWindow::onButtonStudentToTutorExclusive()
else if (_tutorFrame->client() == NULL)
QMessageBox::critical(this, tr("Projection"), sStrTutorOffline);
else
- unicastExlusive(_tutorFrame->client(), _selectedFrame->client());
+ unicast(_tutorFrame->client(), _selectedFrame->client(), true);
}
@@ -788,10 +644,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..4f40a67 100644
--- a/src/server/mainwindow/mainwindow.h
+++ b/src/server/mainwindow/mainwindow.h
@@ -66,11 +66,9 @@ 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);
- void unicastExlusive(Client *from, Client *to);
+ void unicast(Client *from, Client *to, bool blockOthers = false);
void closeEvent(QCloseEvent *e);
void changeEvent(QEvent *e);
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();