diff options
Diffstat (limited to 'src/server/net')
-rw-r--r-- | src/server/net/client.cpp | 21 | ||||
-rw-r--r-- | src/server/net/client.h | 6 |
2 files changed, 21 insertions, 6 deletions
diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp index 59211b7..7224339 100644 --- a/src/server/net/client.cpp +++ b/src/server/net/client.cpp @@ -91,6 +91,17 @@ void Client::sendMessage(NetworkMessage& message) } /******************************************************************************/ +void Client::removeAttentionInternal() +{ + NetworkMessage msg; + _wantsAttention = false; + msg.setField(_ID, _ATTENTION); + msg.setField(_ENABLE, __FALSE); + sendMessage(msg); + emit stateChanged(); +} + +/******************************************************************************/ void Client::requestThumb(const int width, const int height) { if (_socket->state() != QAbstractSocket::ConnectedState) { @@ -113,9 +124,8 @@ void Client::onDataArrival() return; } - bool ret; while (_socket->bytesAvailable() > 0) { - ret = _fromClient.readMessage(_socket); // let the message read data from socket + int ret = _fromClient.readMessage(_socket); // let the message read data from socket if (ret == NM_READ_FAILED) { // error parsing msg, disconnect client! this->disconnect(); return; @@ -175,7 +185,6 @@ void Client::handleMsg() const int projectionSource = (int)_fromClient.getFieldString("CLIENTID").toInt(); if (_fromClient.getFieldString("ENABLED").toInt() != 0) { qDebug() << "Client " << _name << " started its VNC client (watching " << projectionSource << ")"; - _projectionSource = projectionSource; _isActiveVncClient = true; emit vncClientStateChange(this); } else { @@ -184,6 +193,9 @@ void Client::handleMsg() emit vncClientStateChange(this); } emit stateChanged(); + } else if (id == _ATTENTION) { + _wantsAttention = _fromClient.getFieldString(_ENABLE) == __TRUE; + emit stateChanged(); } return; } @@ -301,7 +313,6 @@ bool Client::isManagerMachine() { foreach (const QHostAddress & address, QNetworkInterface::allAddresses()) if (address != QHostAddress(QHostAddress::LocalHost) - && this != NULL && this->ip() == address.toString()) return true; return false; @@ -314,7 +325,7 @@ void Client::lockScreen(bool lock) _locked = lock; NetworkMessage msg; msg.setField(_ID, _LOCK); - msg.setField(_ENABLE, lock ? __TRUE : __FALSE); + msg.setField(_ENABLE, _BOOL(lock)); sendMessage(msg); } emit stateChanged(); diff --git a/src/server/net/client.h b/src/server/net/client.h index e7c9c5c..81f5346 100644 --- a/src/server/net/client.h +++ b/src/server/net/client.h @@ -41,6 +41,8 @@ public: inline const int desiredProjectionSource() { return _desiredSource; } inline const int projectionSource() const { return _projectionSource; } inline const int isExamMode() const { return _isExamMode; } + inline const bool wantsAttention() const { return _wantsAttention; } + inline const void removeAttention() { if (!_wantsAttention) return; removeAttentionInternal(); } // Setters inline void setTutor(bool enable) { _isTutor = enable; } @@ -73,7 +75,8 @@ private: 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 _isExamMode; + bool _wantsAttention; // Flag telling whether the client activated the "i want attention" button QByteArray _rawRemoteScreen; @@ -83,6 +86,7 @@ private: void handleMsg(); void sendMessage(NetworkMessage& message); + void removeAttentionInternal(); protected: void timerEvent(QTimerEvent* event); |