diff options
Diffstat (limited to 'src/server/mainwindow')
-rw-r--r-- | src/server/mainwindow/mainwindow.cpp | 74 | ||||
-rw-r--r-- | src/server/mainwindow/mainwindow.h | 2 |
2 files changed, 45 insertions, 31 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index a6c90c0..6ac7422 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -57,7 +57,7 @@ MainWindow::MainWindow(QString ipListUrl, QWidget* parent) : _tutorFrame = NULL; _selectedFrame = NULL; _mode = Mode::Multicast; - _streamingSource = NULL; + _streamingSource = 0; _sessionNameWindow = new SessionNameWindow(this); _helpWindow = new HelpWindow(this); @@ -266,10 +266,14 @@ void MainWindow::tellClientCurrentSituation(Client* client) if (_mode == Mode::Broadcast){ // _watchers.insert(client->id(), client); client->setWatcher(true); - client->startVncClient(_streamingSource); + Client* c = getClientFromId(_streamingSource); + if (c != NULL) { + client->startVncClient(c); + } } else if (_mode == Mode::LockedMulticast) client->lockScreen(true); + } /***************************************************************************//** @@ -384,8 +388,8 @@ void MainWindow::reset() (*it)->client()->lockScreen(false); // Stop server (Clients get stopped on ACK) - if (_streamingSource != NULL) - _streamingSource->stopVncServer(); + if (getClientFromId(_streamingSource) != NULL) + getClientFromId(_streamingSource)->stopVncServer(); } /* @@ -489,7 +493,7 @@ void MainWindow::changeProjection(Client *from, Mode mode, Client *to) // Set all clients as watchers for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) { - if ((*it)->client() != NULL && (*it)->client() != _streamingSource) + if ((*it)->client() != NULL && (*it)->client() != getClientFromId(_streamingSource)) { // _watchers.insert((*it)->client()->id(), (*it)->client()); (*it)->client()->setWatcher(true); @@ -528,17 +532,20 @@ void MainWindow::changeProjection(Client *from, Mode mode, Client *to) _mode = mode; // if there is a server running which is not "from" stop it. - if (_streamingSource != NULL && _streamingSource != from) - _streamingSource->stopVncServer(); + if (getClientFromId(_streamingSource) != NULL && getClientFromId(_streamingSource) != from) + getClientFromId(_streamingSource)->stopVncServer(); // Set new streaming source - _streamingSource = from; + _streamingSource = from->id(); // If streaming source is already active avoid a restart - if (_streamingSource->isActiveVncServer()) - this->onVncServerStateChange(_streamingSource); - else // Could not take shortcut, (re)start VNC server on source - _streamingSource->startVncServer(); + Client* c = getClientFromId(_streamingSource); + if (c != NULL) { + if (c->isActiveVncServer()) + this->onVncServerStateChange(c); + else // Could not take shortcut, (re)start VNC server on source + c->startVncServer(); + } } /***************************************************************************//** @@ -882,7 +889,7 @@ void MainWindow::onClientAuthenticated(Client* client) */ void MainWindow::onVncServerStateChange(Client* client) { - if (client == _streamingSource) + if (client == getClientFromId(_streamingSource)) EnableButtons(); if (client->isActiveVncServer()) @@ -910,7 +917,7 @@ void MainWindow::onVncServerStateChange(Client* client) if ( (*it)->client() != NULL) { // if (_watchers.contains((*it)->client()->id())) - if (getClientFromId((*it)->client()->id())->isWatcher()) + if ((*it)->client()->isWatcher()) { // Unlock destination and connect VNCclient (*it)->client()->lockScreen(false); @@ -957,25 +964,32 @@ void MainWindow::onVncServerStateChange(Client* client) */ void MainWindow::onVncClientStateChange(Client* client) { - // VNC Client stopped -> remove from watchers - if (!client->isActiveVncClient()){ - // _watchers.remove(client->id()); - getClientFromId(client->id())->setWatcher(false); - - // If noboody is watching the multicast stop VNC server - // if (_watchers.isEmpty() && _mode != Mode::Broadcast) - // _streamingSource->stopVncServer(); - bool noWatchers = true; - for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) - { - if ((*it)->client() != NULL) + if (client != NULL) + { + // VNC Client stopped -> remove from watchers + if (!client->isActiveVncClient()){ + // _watchers.remove(client->id()); + getClientFromId(client->id())->setWatcher(false); + + // If noboody is watching the multicast stop VNC server + // if (_watchers.isEmpty() && _mode != Mode::Broadcast) + // _streamingSource->stopVncServer(); + bool noWatchers = true; + for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) { - if ((*it)->client()->isWatcher()) - noWatchers = false; + if ((*it)->client() != NULL) + { + if ((*it)->client()->isWatcher()) + noWatchers = false; + } + } + if (noWatchers && _mode != Mode::Broadcast) + { + Client* c = getClientFromId(_streamingSource); + if (c != NULL) + c->stopVncServer(); } } - if (noWatchers && _mode != Mode::Broadcast) - _streamingSource->stopVncServer(); } } diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index fffa49a..64accd9 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -54,7 +54,7 @@ private: Multicast, LockedMulticast } _mode; - Client * _streamingSource; + int _streamingSource; QMap<int, Client*> _watchers; QList<ConnectionFrame*> _clientFrames; |