diff options
-rw-r--r-- | src/server/mainwindow/mainwindow.cpp | 15 | ||||
-rw-r--r-- | src/server/net/client.cpp | 16 |
2 files changed, 26 insertions, 5 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index e3b7952..7543004 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -398,6 +398,15 @@ void MainWindow::prepareForProjection(Client * const from, Client * const to) 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 @@ -407,9 +416,9 @@ void MainWindow::prepareForProjection(Client * const from, Client * const to) { Client *c = (**it).client(); if (c == NULL || c->id() == from->id()) - continue; + continue; // Self or offline if (c->currentProjectionSource() != from->id()) - continue; + continue; // Other client // Yep :-) qDebug("Reusing because of active client"); this->onVncServerStateChange(from); @@ -793,8 +802,10 @@ void MainWindow::onClientAuthenticated(Client* client) msg.setField("HOST", c->ip()); msg.setField("PORT", QString::number(c->vncPort())); msg.setField("ROPASS", c->vncRoPass()); + msg.setField("CLIENTID", QString::number(c->id())); msg.setField("CAPTION", c->name() + " @ " + c->host()); client->sendMessage(msg); + client->setDesiredProjectionSource(c->id()); break; } } diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp index 3adeeaa..f3cbc0d 100644 --- a/src/server/net/client.cpp +++ b/src/server/net/client.cpp @@ -195,11 +195,16 @@ void Client::handleMsg() qDebug() << "Starting VNC server on client" << _name << " (" << _ip << ") failed."; // TODO: Show message on manager } + else + { + qDebug() << "Client " << _name << " stopped its VNC server"; + } } else { _vncRoPass = _fromClient.getFieldString("ROPASS"); _vncRwPass = _fromClient.getFieldString("RWPASS"); + qDebug() << "Client " << _name << " started its VNC server"; } _vncPort = port; emit vncServerStateChange(this); @@ -210,14 +215,19 @@ void Client::handleMsg() _activeVncClient = (_fromClient.getFieldString("ENABLED").toInt() != 0); const int other = (int)_fromClient.getFieldString("CLIENTID").toInt(); - if (!_activeVncClient && other == 0) - _desiredProjectionSource = 0; + int last = (_currentProjectionSource != 0 ? _currentProjectionSource : _desiredProjectionSource); - int last = _currentProjectionSource; if (!_activeVncClient) + { _currentProjectionSource = 0; + _desiredProjectionSource = 0; + qDebug() << "Client " << _name << " stopped its VNC client (watched " << last << ")"; + } else + { _currentProjectionSource = other; + qDebug() << "Client " << _name << " started its VNC client (watching " << other << ")"; + } emit vncClientStateChange(this, last); } |