From e9b4cb4721b7c7f02728e22f92f5ad7a94828521 Mon Sep 17 00:00:00 2001 From: sr Date: Tue, 5 Feb 2013 19:48:39 +0100 Subject: [SERVER] Go back from ClientId to int, so queued signal/slot connections work --- src/server/connectionframe/connectionframe.cpp | 4 ++-- src/server/connectionframe/connectionframe.h | 5 ++--- src/server/mainwindow/mainwindow.cpp | 4 ++-- src/server/mainwindow/mainwindow.h | 2 +- src/server/net/client.cpp | 6 +++--- src/server/net/client.h | 20 +++++++++----------- 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/server/connectionframe/connectionframe.cpp b/src/server/connectionframe/connectionframe.cpp index a05af95..df93525 100644 --- a/src/server/connectionframe/connectionframe.cpp +++ b/src/server/connectionframe/connectionframe.cpp @@ -100,7 +100,7 @@ void ConnectionFrame::assignClient(Client* client) connect(client, SIGNAL(disconnected()), this, SLOT(onClientDisconnected())); connect(client, SIGNAL(thumbUpdated(Client*, const QPixmap&)), this, SLOT(onThumbUpdated(Client*, const QPixmap&))); connect(client, SIGNAL(vncServerStateChange(Client*)), this, SLOT(onVncServerStateChange(Client*))); - connect(client, SIGNAL(vncClientStateChange(Client*, ClientId)), this, SLOT(onVncClientStateChange(Client*, ClientId))); + connect(client, SIGNAL(vncClientStateChange(Client*, int)), this, SLOT(onVncClientStateChange(Client*, int))); _client = client; _computerId = client->computerId(); _lblHostName->setText(client->ip()); @@ -280,7 +280,7 @@ void ConnectionFrame::onVncServerStateChange(Client* client) this->updateColor(); } -void ConnectionFrame::onVncClientStateChange(Client* client, ClientId lastSource) +void ConnectionFrame::onVncClientStateChange(Client* client, int lastSource) { this->updateColor(); } diff --git a/src/server/connectionframe/connectionframe.h b/src/server/connectionframe/connectionframe.h index ac1a0a8..a4d9ede 100644 --- a/src/server/connectionframe/connectionframe.h +++ b/src/server/connectionframe/connectionframe.h @@ -1,8 +1,7 @@ #ifndef _CONNECTIONFRAME_H_ #define _CONNECTIONFRAME_H_ #include - -class Client; +#include "../net/client.h" class ConnectionFrame : public QGroupBox { @@ -71,7 +70,7 @@ private slots: void onClientDisconnected(); void onThumbUpdated(Client* client, const QPixmap& thumb); void onVncServerStateChange(Client* client); - void onVncClientStateChange(Client* client, ClientId lastSource); + void onVncClientStateChange(Client* client, int lastSource); }; #endif diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index ceb445a..12c7921 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -634,7 +634,7 @@ void MainWindow::onClientAuthenticated(Client* client) { disconnect(client, SIGNAL(authenticated(Client*)), this, SLOT(onClientAuthenticated(Client*))); connect(client, SIGNAL(vncServerStateChange(Client*)), this, SLOT(onVncServerStateChange(Client*)), Qt::QueuedConnection); - connect(client, SIGNAL(vncClientStateChange(Client*, ClientId)), this, SLOT(onVncClientStateChange(Client*, ClientId)), Qt::QueuedConnection); + connect(client, SIGNAL(vncClientStateChange(Client*, int)), this, SLOT(onVncClientStateChange(Client*, int)), Qt::QueuedConnection); bool hasActiveTutor = false; ConnectionFrame *deadTutor = NULL; bool anyClient = false; @@ -778,7 +778,7 @@ void MainWindow::onVncServerStateChange(Client* client) } } -void MainWindow::onVncClientStateChange(Client* client, ClientId lastProjectionSource) +void MainWindow::onVncClientStateChange(Client* client, int lastProjectionSource) { if (!isValidClient(client)) // Check here because this slot is connected queued return; diff --git a/src/server/mainwindow/mainwindow.h b/src/server/mainwindow/mainwindow.h index 076da3f..0cc6abc 100644 --- a/src/server/mainwindow/mainwindow.h +++ b/src/server/mainwindow/mainwindow.h @@ -72,7 +72,7 @@ protected slots: void onClientAuthenticating(Client* client, ClientLogin* request); void onClientAuthenticated(Client* client); void onVncServerStateChange(Client* client); - void onVncClientStateChange(Client* client, ClientId lastProjectionSource); + void onVncClientStateChange(Client* client, int lastProjectionSource); }; diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp index 26c1dd2..d6002a6 100644 --- a/src/server/net/client.cpp +++ b/src/server/net/client.cpp @@ -16,7 +16,7 @@ #define CHALLENGE_LEN 20 -ClientId Client::_clientIdCounter = 0; +int Client::_clientIdCounter = 0; Client::Client(QSslSocket* socket) : _socket(socket), _authed(0), _timerDelete(0), _desiredProjectionSource(0), _isProjectionSource(false), @@ -198,12 +198,12 @@ void Client::handleMsg() { // Client tells us that it started or stopped displaying a remote screen via VNC _activeVncClient = (_fromClient.getFieldString("ENABLED").toInt() != 0); - const ClientId other = (ClientId)_fromClient.getFieldString("CLIENTID").toInt(); + const int other = (int)_fromClient.getFieldString("CLIENTID").toInt(); if (!_activeVncClient && other == 0) _desiredProjectionSource = 0; - ClientId last = _currentProjectionSource; + int last = _currentProjectionSource; if (!_activeVncClient) _currentProjectionSource = 0; else diff --git a/src/server/net/client.h b/src/server/net/client.h index 08cac71..ce17c18 100644 --- a/src/server/net/client.h +++ b/src/server/net/client.h @@ -16,14 +16,12 @@ struct ClientLogin QString ip; }; -typedef int ClientId; - class Client : public QObject { Q_OBJECT private: - static ClientId _clientIdCounter; + static int _clientIdCounter; QSslSocket *_socket; int _authed; // 0 = challenge sent, awaiting reply 1 = challenge ok, client challenge replied, awaiting login, 2 = ESTABLISHED @@ -35,18 +33,18 @@ private: NetworkMessage _toClient, _fromClient; int _timerIdAuthTimeout, _timerDelete; - ClientId _id; // this client's unique id + int _id; // this client's unique id // If this client should be projected to from another client, the other client's id is set here. 0 otherwise. // This is not currently used and it is questionable if this makes sense, as it might just be confusing if // several groups students watch different other students. // Also, visualizing such a situation in the GUI in a meaningful way would be hard. - ClientId _desiredProjectionSource; + int _desiredProjectionSource; // This boolean tells whether this client is currently the VNC broadcast source. This // version only allows "one to all others" setups bool _isProjectionSource; - ClientId _currentProjectionSource; + int _currentProjectionSource; QString _vncRwPass, _vncRoPass; int _vncPort; @@ -71,18 +69,18 @@ public: 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 ClientId id() const { return _id; } + 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 ClientId desiredProjectionSource() const { return _desiredProjectionSource; } - inline void setDesiredProjectionSource(ClientId source) { _desiredProjectionSource = source; } + inline const int desiredProjectionSource() const { return _desiredProjectionSource; } + inline void setDesiredProjectionSource(int source) { _desiredProjectionSource = source; } inline const bool isProjectionSource() const { return _isProjectionSource; } inline void setProjectionSource(bool enable) { _isProjectionSource = enable; } - inline const ClientId currentProjectionSource() const { return _currentProjectionSource; } + inline const int currentProjectionSource() const { return _currentProjectionSource; } void startVncServer(); void stopVncServer(); void stopVncClient(); @@ -93,7 +91,7 @@ signals: void authenticated(Client* client); void thumbUpdated(Client* client, const QPixmap& thumb); void vncServerStateChange(Client* client); - void vncClientStateChange(Client* client, ClientId lastProjectionSource); + void vncClientStateChange(Client* client, int lastProjectionSource); void disconnected(); private slots: -- cgit v1.2.3-55-g7522