diff options
-rw-r--r-- | src/server/connectionframe/connectionframe.cpp | 2 | ||||
-rw-r--r-- | src/server/mainwindow/mainwindow.cpp | 18 | ||||
-rw-r--r-- | src/server/net/client.cpp | 17 | ||||
-rw-r--r-- | src/server/net/client.h | 10 |
4 files changed, 20 insertions, 27 deletions
diff --git a/src/server/connectionframe/connectionframe.cpp b/src/server/connectionframe/connectionframe.cpp index 75d24a4..b772231 100644 --- a/src/server/connectionframe/connectionframe.cpp +++ b/src/server/connectionframe/connectionframe.cpp @@ -146,7 +146,7 @@ void ConnectionFrame::assignClient(Client* client) connect( client, SIGNAL(vncClientStateChange(Client*, int)), this, SLOT(onVncClientStateChange(Client*, int)) ); _client = client; - _computerId = client->computerId(); + _computerId = client->ip(); _lblHostName->setText(client->ip()); _lblHostName->setToolTip(client->host()); _lblUserName->setText(client->name()); diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 8ca00a0..608b8cf 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -251,7 +251,7 @@ void MainWindow::savePosition(ConnectionFrame *cf) QPoint pos(cf->pos().x() / _tileWidth, cf->pos().y() / _tileHeight); USER_SETTINGS(settings); settings.beginGroup("client_position"); - settings.setValue(client->computerId(), pos); + settings.setValue(client->ip(), pos); settings.endGroup(); } @@ -742,7 +742,7 @@ void MainWindow::onClientAuthenticated(Client* client) ConnectionFrame *existing = NULL; for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) { - if ((*it)->computerId() == client->computerId()) + if ((*it)->computerId() == client->ip()) existing = *it; if ((*it)->isTutor()) { @@ -757,7 +757,7 @@ void MainWindow::onClientAuthenticated(Client* client) for (int i = 0; i < _tutorList.size(); i++) { // Check if client is possible tutor - if (client->computerId() == _tutorList[i]) + if (client->ip() == _tutorList[i]) { isTutor = true; break; @@ -777,11 +777,11 @@ void MainWindow::onClientAuthenticated(Client* client) int x, y; bool ok; USER_SETTINGS(usr); - ok = loadPosition(usr, client->computerId(), x, y); + ok = loadPosition(usr, client->ip(), x, y); if (!ok) { SYSTEM_SETTINGS(sys); - ok = loadPosition(sys, client->computerId(), x, y); + ok = loadPosition(sys, client->ip(), x, y); } if (x >= _tilesX || y >= _tilesY) ok = false; @@ -804,7 +804,7 @@ void MainWindow::onClientAuthenticated(Client* client) cf->setTutor(isTutor); // Assign client instance cf->assignClient(client); - // ################ + // If clients are currently locked, tell this new client if (ui->action_Lock->isChecked()) client->lockScreen(true); @@ -815,7 +815,7 @@ void MainWindow::onClientAuthenticated(Client* client) Client *c = (**it).client(); if (c != NULL && c != client && c->isActiveVncServer() && c->isProjectionSource()) { - c->startVncClient(c->ip(), c->vncPort(), c->vncRoPass(), c->id(), c->name() + " @ " + c->host()); + c->startVncClient(c); client->setDesiredProjectionSource(c->id()); break; } @@ -832,7 +832,7 @@ void MainWindow::onVncServerStateChange(Client* client) { if (!isValidClient(client)) // Check here because this slot is connected queued return; - if (client->vncPort() > 0) + if (client->isActiveVncServer()) { // VNC Server started on some client - start projection on all clients interested in that client's screen for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it) @@ -844,7 +844,7 @@ void MainWindow::onVncServerStateChange(Client* client) continue; // Already watching this client if (c->desiredProjectionSource() != client->id() && !client->isProjectionSource()) continue; // Not interested - c->startVncClient(client->ip(), client->vncPort(), client->vncRoPass(), client->id(), client->name() + " @ " + client->host()); + c->startVncClient(client); } } else diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp index 9422e81..9bee319 100644 --- a/src/server/net/client.cpp +++ b/src/server/net/client.cpp @@ -298,7 +298,6 @@ void Client::handleMsg() /******************************************************************************/ void Client::startVncServer() { - _vncPort = 0; NetworkMessage msg; msg.setField(_ID, _VNCSERVER); msg.setField(_ENABLE, __TRUE); @@ -315,25 +314,23 @@ void Client::stopVncServer() } /******************************************************************************/ -void Client::stopVncClient() +void Client::startVncClient(const Client * const to) { - _activeVncClient = false; NetworkMessage msg; msg.setField(_ID, _VNCCLIENT); + msg.setField("HOST", to->_host); + msg.setField("PORT", QString::number(to->_vncPort)); + msg.setField("ROPASS", to->_vncRoPass); + msg.setField("CLIENTID", QString::number(to->_id)); + msg.setField("CAPTION", to->_name + " @ " + to->_host); sendMessage(msg); } /******************************************************************************/ -void Client::startVncClient(QString host, int port, QString pass, int id, QString caption) +void Client::stopVncClient() { - _activeVncClient = false; NetworkMessage msg; msg.setField(_ID, _VNCCLIENT); - msg.setField("HOST", host); - msg.setField("PORT", QString::number(port)); - msg.setField("ROPASS", pass); - msg.setField("CLIENTID", QString::number(id)); - msg.setField("CAPTION", caption); sendMessage(msg); } diff --git a/src/server/net/client.h b/src/server/net/client.h index e0bdfe8..bbd7ed0 100644 --- a/src/server/net/client.h +++ b/src/server/net/client.h @@ -31,12 +31,7 @@ public: const inline QString& host() const { return _host; } const inline QString& ip() const { return _ip; } // The computer ID (used eg. for saving the frame positions) is currently the IP, but this is an extra method for easier modification later on - const inline QString& computerId() const { return _ip; } const inline int id() const { return _id; } - - inline const QString& vncRwPass() const { return _vncRwPass; } - inline const QString& vncRoPass() const { return _vncRoPass; } - inline const int vncPort() const { return _vncPort; } inline const bool isActiveVncClient() const { return _activeVncClient; } inline const bool isActiveVncServer() const { return _vncPort > 0; } inline const int desiredProjectionSource() const { return _desiredProjectionSource; } @@ -44,12 +39,13 @@ public: inline const bool isProjectionSource() const { return _isProjectionSource; } inline void setProjectionSource(bool enable) { _isProjectionSource = enable; } inline const int currentProjectionSource() const { return _currentProjectionSource; } + void setTutor(bool enable); + //Send message stuff void startVncServer(); void stopVncServer(); - void startVncClient(QString host, int port, QString pass, int id, QString caption); + void startVncClient(Client const * const to ); void stopVncClient(); void lockScreen(bool); - void setTutor(bool enable); private: static int _clientIdCounter; |