From 7878fe9db26439acd1163b2f487cfdb3415f59ac Mon Sep 17 00:00:00 2001 From: Manuel Schneider Date: Thu, 22 May 2014 15:45:23 +0200 Subject: First approach for an exclusive unicast. T.b.c. --- src/server/mainwindow/mainwindow.cpp | 68 ++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 26 deletions(-) (limited to 'src/server/mainwindow/mainwindow.cpp') 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::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::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::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::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::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; } } -- cgit v1.2.3-55-g7522