diff options
author | Simon Rettberg | 2022-10-30 20:34:23 +0100 |
---|---|---|
committer | Simon Rettberg | 2022-10-30 20:34:23 +0100 |
commit | 9f479b8f76238a03bce5d13aee14efd34e659c6e (patch) | |
tree | e320d32838202ac4604032da7a4bc3702cc304da /src/server/net/client.h | |
parent | Update translation files (diff) | |
download | pvs2-9f479b8f76238a03bce5d13aee14efd34e659c6e.tar.gz pvs2-9f479b8f76238a03bce5d13aee14efd34e659c6e.tar.xz pvs2-9f479b8f76238a03bce5d13aee14efd34e659c6e.zip |
Clean up and modernize code
- static "new-style" signal->slot connections
- Fix a lot of things Clang-Tidy complained about
- Move includes to .cpp files and use forward decls in .h
- Don't use <QtWidgets> and <QtCore>, but specific includes instead
Diffstat (limited to 'src/server/net/client.h')
-rw-r--r-- | src/server/net/client.h | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/src/server/net/client.h b/src/server/net/client.h index 3d5158b..3b95321 100644 --- a/src/server/net/client.h +++ b/src/server/net/client.h @@ -1,13 +1,13 @@ #ifndef CLIENT_H_ #define CLIENT_H_ -#include <QtCore> -#include <QHostAddress> -#include <QAbstractSocket> -#include <QTcpSocket> #include "../../shared/networkmessage.h" +#include <QByteArray> + //class QSslSocket; +class QTcpSocket; +class Client; #define NO_SOURCE 0 @@ -26,32 +26,32 @@ class Client : public QObject public: explicit Client(QTcpSocket* socket); - ~Client(); + ~Client() override; // Getters - inline bool isAuthed() const { return _authed == 2; } - inline const QString& name() const { return _name; } - inline const QString& host() const { return _host; } - inline const QString ip() const { return _socket->peerAddress().toString(); } - inline int id() const { return _id; } - inline bool isActiveVncClient() const { return _isActiveVncClient; } - inline bool isActiveVncServer() const { return _vncPort > 0; } - inline bool isLocked() const { return _locked; } - inline int desiredProjectionSource() const { return _desiredSource; } - inline int projectionSource() const { return _projectionSource; } - inline int isExamMode() const { return _isExamMode; } - inline bool wantsAttention() const { return _wantsAttention; } - inline void removeAttention() { if (!_wantsAttention) return; removeAttentionInternal(); } + bool isAuthed() const { return _authed == 2; } + const QString& name() const { return _name; } + const QString& host() const { return _host; } + QString ip() const; + int id() const { return _id; } + bool isActiveVncClient() const { return _isActiveVncClient; } + bool isActiveVncServer() const { return _vncPort > 0; } + bool isLocked() const { return _locked; } + int desiredProjectionSource() const { return _desiredSource; } + int projectionSource() const { return _projectionSource; } + int isExamMode() const { return _isExamMode; } + bool wantsAttention() const { return _wantsAttention; } + void removeAttention() { if (!_wantsAttention) return; removeAttentionInternal(); } // Setters - inline void setTutor(bool enable) { _isTutor = enable; } - inline void setDesiredProjectionSource(int id) {_desiredSource = id;} - inline void setExamMode(bool mode) { _isExamMode = mode; } + void setTutor(bool enable) { _isTutor = enable; } + void setDesiredProjectionSource(int id) { _desiredSource = id; } + void setExamMode(bool mode) { _isExamMode = mode; } //Send message stuff void startVncServer(); void stopVncServer(); - void startVncClient(Client const * const to ); + void startVncClient(const Client * to); void stopVncClient(); void lockScreen(bool); void requestThumb(const QSize& size); @@ -59,8 +59,8 @@ public: private: QTcpSocket * const _socket; - bool _locked; - int _authed; // 0 = challenge sent, awaiting reply 1 = challenge ok, client challenge replied, awaiting login, 2 = ESTABLISHED + bool _locked{}; + int _authed{}; // 0 = challenge sent, awaiting reply 1 = challenge ok, client challenge replied, awaiting login, 2 = ESTABLISHED QString _name; QString _host; QByteArray _challenge; @@ -69,26 +69,26 @@ private: int _timerIdAuthTimeout, _timerPingTimeout; int _id; // this client's unique id QString _vncRwPass, _vncRoPass; - int _vncPort; // VNCserver state. Greater 0 -> active on this port. Equals 0 -> no server. + int _vncPort{}; // VNCserver state. Greater 0 -> active on this port. Equals 0 -> no server. int _desiredSource; // The source the client shall be connected to - int _projectionSource; // The source the client was or is connected to (depends on _isActiveVncClient) - bool _isActiveVncClient; // VNCclient state. indicating that the client is displaying a remote screen via VNC - bool _isTutor; // Flag indicating that the client has been set as a tutor - bool _isExamMode; - bool _wantsAttention; // Flag telling whether the client activated the "i want attention" button + int _projectionSource{}; // The source the client was or is connected to (depends on _isActiveVncClient) + bool _isActiveVncClient{}; // VNCclient state. indicating that the client is displaying a remote screen via VNC + bool _isTutor{}; // Flag indicating that the client has been set as a tutor + bool _isExamMode{}; + bool _wantsAttention{}; // Flag telling whether the client activated the "i want attention" button QByteArray _rawRemoteScreen; static int _clientIdCounter; - bool isManagerMachine(); + bool isManagerMachine() const; void handleMsg(); void sendMessage(NetworkMessage& message); void removeAttentionInternal(); protected: - void timerEvent(QTimerEvent* event); + void timerEvent(QTimerEvent* event) override; signals: void authenticating(Client* client, ClientLogin* request); |