summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
authorManuel Schneider2014-05-22 15:45:23 +0200
committerManuel Schneider2014-05-22 15:45:23 +0200
commit7878fe9db26439acd1163b2f487cfdb3415f59ac (patch)
treeab684395e0522179f6742c897ddfb2b8c51f2b00 /src/server/mainwindow/mainwindow.cpp
parentStop suggesting the user to be recorded: (diff)
downloadpvs2-7878fe9db26439acd1163b2f487cfdb3415f59ac.tar.gz
pvs2-7878fe9db26439acd1163b2f487cfdb3415f59ac.tar.xz
pvs2-7878fe9db26439acd1163b2f487cfdb3415f59ac.zip
First approach for an exclusive unicast. T.b.c.
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r--src/server/mainwindow/mainwindow.cpp68
1 files changed, 42 insertions, 26 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 5059516..1efc87a 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -439,28 +439,27 @@ bool MainWindow::isValidClient(Client* client)
*/
void MainWindow::broadcast(Client *from)
{
- // Projection source is never allowed to be an active VNC viewer
- if (from->isActiveVncClient())
- from->stopVncClient();
+ _state = State::Broadcast;
- // Tell all clients to listen to server
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it){
- if ((*it)->client() != NULL)
- (*it)->client()->setBroadcastSource(false);
- }
+ // if there is a server running which is not "from" stop it.
+ if (_streamingSource != NULL && _streamingSource != from)
+ _streamingSource->stopVncServer();
+ _streamingSource = from;
- from->setDesiredProjectionSource(0);
- from->setBroadcastSource(true);
+ // Server must not listen to itself
+ _streamingSource->setDesiredProjectionSource(0);
// Set desired projection source on all clients, if not "from" or oflline
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- if ((*it)->client() != NULL && (*it)->client()->id() != from->id())
- (*it)->client()->setDesiredProjectionSource(from->id());
+ if ((*it)->client() != NULL && (*it)->client() != _streamingSource)
+ (*it)->client()->setDesiredProjectionSource(_streamingSource->id());
- if (from->isActiveVncServer()) // From is already active
- this->onVncServerStateChange(from);
- else // Could not take shortcut, (re)start VNC server on source
- from->startVncServer();
+ if (_streamingSource->isActiveVncServer())
+ // From is already active
+ this->onVncServerStateChange(_streamingSource);
+ else
+ // Could not take shortcut, start VNC server on source
+ _streamingSource->startVncServer();
}
@@ -472,6 +471,13 @@ void MainWindow::broadcast(Client *from)
*/
void MainWindow::unicast(Client *from, Client *to, bool blockOthers)
{
+ _state = blockOthers ? State::ExclusiveUnicast : State::Unicast;
+
+ // if there is a server running which is not "from" stop it.
+ if (_streamingSource != NULL && _streamingSource != from)
+ _streamingSource->stopVncServer();
+ _streamingSource = from;
+
// Projection source is never allowed to be an active VNC viewer
if (from->isActiveVncClient())
from->stopVncClient();
@@ -484,6 +490,13 @@ void MainWindow::unicast(Client *from, Client *to, bool blockOthers)
to->setBroadcastSource(false);
to->setDesiredProjectionSource(from->id());
+ if (blockOthers) {
+ // Set lock others
+ for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
+ if ((*it)->client() != NULL && (*it)->client() != from && (*it)->client() != to)
+ (*it)->client()->lockScreen(true);
+ }
+
if (from->isActiveVncServer()) // From is already active
this->onVncServerStateChange(from);
else // Could not take shortcut, (re)start VNC server on source
@@ -601,6 +614,8 @@ void MainWindow::onButtonStudentToTutorExclusive()
*/
void MainWindow::onButtonStopProjection()
{
+ _state = State::Idle;
+
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
{
Client *c = (**it).client();
@@ -809,16 +824,17 @@ void MainWindow::onClientAuthenticated(Client* client)
if (ui->action_Lock->isChecked())
client->lockScreen(true);
- // Same for VNC projections
- for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- {
- Client *c = (**it).client();
- if (c != NULL && c != client && c->isActiveVncServer() && c->isBroadcastSource())
- {
- client->startVncClient(c);
- client->setDesiredProjectionSource(c->id());
- break;
- }
+ switch (_state) {
+ case State::Idle:break;
+ case State::Unicast:break;
+ case State::ExclusiveUnicast:
+ client->lockScreen(true);
+ break;
+ case State::Broadcast:
+ client->setDesiredProjectionSource(_streamingSource->id());
+ client->startVncClient(_streamingSource);
+ break;
+ default:break;
}
}