From 1e77797ab3ffaf617bfc1150129196a8153dda4c Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Tue, 3 Jun 2014 16:30:02 +0200 Subject: Removed _watchers List. Set flag in client.h _isWatcher with getter and setter, and controlling the watchers over this value. --- src/server/mainwindow/mainwindow.cpp | 63 +++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 11 deletions(-) (limited to 'src/server/mainwindow/mainwindow.cpp') diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index d0487d4..58da462 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -270,7 +270,8 @@ void MainWindow::tellClientCurrentSituation(Client* client) client->lockScreen(true); if (_mode == Mode::Broadcast){ - _watchers.insert(client->id(), client); + // _watchers.insert(client->id(), client); + client->setWatcher(true); client->startVncClient(_streamingSource); } else if (_mode == Mode::LockedMulticast) @@ -491,21 +492,40 @@ void MainWindow::changeProjection(Client *from, Mode mode, Client *to) { // Set all clients as watchers for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) + { if ((*it)->client() != NULL && (*it)->client() != _streamingSource) - _watchers.insert((*it)->client()->id(), (*it)->client()); + { + // _watchers.insert((*it)->client()->id(), (*it)->client()); + (*it)->client()->setWatcher(true); + } + } } else // mode != Mode::Broadcast { // If this is the first call in this mode clear the watchers if ((mode == Mode::LockedMulticast && _mode != Mode::LockedMulticast) || (mode == Mode::Multicast && _mode != Mode::Multicast)) - _watchers.clear(); + { + // _watchers.clear(); + for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) + { + if ((*it)->client() != NULL) + (*it)->client()->setWatcher(false); + } + } // If "to" already watches "from" stop it - if (_watchers.contains(to->id())) - _watchers.remove(to->id()); + // if (_watchers.contains(to->id())) + if (getClientFromId(to->id())->isWatcher()) + { + // _watchers.remove(to->id()); + getClientFromId(to->id())->setWatcher(false); + } else // list "to" as watcher - _watchers.insert(to->id(), to); + { + // _watchers.insert(to->id(), to); + getClientFromId(to->id())->setWatcher(true); + } } // Set the mode @@ -890,7 +910,8 @@ void MainWindow::onVncServerStateChange(Client* client) // Ignore offline clients if ( (*it)->client() != NULL) { - if (_watchers.contains((*it)->client()->id())) + // if (_watchers.contains((*it)->client()->id())) + if (getClientFromId((*it)->client()->id())->isWatcher()) { // Unlock destination and connect VNCclient (*it)->client()->lockScreen(false); @@ -915,8 +936,16 @@ void MainWindow::onVncServerStateChange(Client* client) else { // VNC server stopped on some client or failed to start - reset local pending projection information - foreach (Client *c, _watchers) { - c->stopVncClient(); + // foreach (Client *c, _watchers) { + // c->stopVncClient(); + // } + for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) + { + if ((*it)->client() != NULL) + { + if ((*it)->client()->isWatcher()) + (*it)->client()->stopVncClient(); + } } } } @@ -931,10 +960,22 @@ void MainWindow::onVncClientStateChange(Client* client) { // VNC Client stopped -> remove from watchers if (!client->isActiveVncClient()){ - _watchers.remove(client->id()); + // _watchers.remove(client->id()); + getClientFromId(client->id())->setWatcher(false); // If noboody is watching the multicast stop VNC server - if (_watchers.isEmpty() && _mode != Mode::Broadcast) + // if (_watchers.isEmpty() && _mode != Mode::Broadcast) + // _streamingSource->stopVncServer(); + bool noWatchers = true; + for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) + { + if ((*it)->client() != NULL) + { + if ((*it)->client()->isWatcher()) + noWatchers = false; + } + } + if (noWatchers && _mode != Mode::Broadcast) _streamingSource->stopVncServer(); } } -- cgit v1.2.3-55-g7522