summaryrefslogtreecommitdiffstats
path: root/src/server/net
diff options
context:
space:
mode:
authorChristian Klinger2016-09-27 15:38:39 +0200
committerChristian Klinger2016-09-27 15:38:39 +0200
commit1f6493e319016f8c375b62f2109ee57f5cea828d (patch)
treeac1635d23eaaf7090f6cc21767536ddcc9c76dae /src/server/net
parentclients in exam-mode no longer send a screenshot. Also some refactoring. (diff)
downloadpvs2-1f6493e319016f8c375b62f2109ee57f5cea828d.tar.gz
pvs2-1f6493e319016f8c375b62f2109ee57f5cea828d.tar.xz
pvs2-1f6493e319016f8c375b62f2109ee57f5cea828d.zip
Implemented 'majority vote' to determine the toolbar options.
clients in exam-mode are also displayed differently.
Diffstat (limited to 'src/server/net')
-rw-r--r--src/server/net/client.cpp20
-rw-r--r--src/server/net/client.h5
2 files changed, 17 insertions, 8 deletions
diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp
index 5086ea1..84c45a9 100644
--- a/src/server/net/client.cpp
+++ b/src/server/net/client.cpp
@@ -150,7 +150,6 @@ void Client::handleMsg()
qDebug("Received message with empty ID field. ignored.");
return;
}
- //qDebug() << "Received message " << id;
if (_authed == 2)
{
@@ -159,13 +158,16 @@ void Client::handleMsg()
{
QPixmap pixmap;
const QByteArray& rawImage = _fromClient.getFieldBytes("IMG");
- if (!pixmap.loadFromData(rawImage))
- {
- qDebug("Could not decode thumbnail image from client.");
- return;
+ /* size 0 means the client is in exam-mode and therefore doesn't send any thumbnail */
+ if (rawImage.size() > 0) {
+ if (!pixmap.loadFromData(rawImage))
+ {
+ qDebug("Could not decode thumbnail image from client.");
+ return;
+ }
+ _rawRemoteScreen = QByteArray(rawImage);
+ emit thumbUpdated(this, pixmap, rawImage);
}
- _rawRemoteScreen = QByteArray(rawImage);
- emit thumbUpdated(this, pixmap, rawImage);
}
else if (id == _VNCSERVER)
{
@@ -225,8 +227,10 @@ void Client::handleMsg()
request.accept = true;
request.host = _fromClient.getFieldString("HOST");
request.name = _fromClient.getFieldString("NAME");
+ request.examMode = _fromClient.getFieldString(_EXAMMODE) == __TRUE;
request.ip = _socket->peerAddress().toString();
- qDebug() << "Login request by " << request.name;
+
+ qDebug() << "Login request by " << request.name << (request.examMode ? "(in exam mode)" : "");
// emit event, see if request is accepted
emit authenticating(this, &request);
if (!request.accept)
diff --git a/src/server/net/client.h b/src/server/net/client.h
index d2097ad..872d0e1 100644
--- a/src/server/net/client.h
+++ b/src/server/net/client.h
@@ -18,6 +18,7 @@ struct ClientLogin
QString name;
QString host;
QString ip;
+ bool examMode;
};
@@ -40,10 +41,12 @@ public:
inline const bool isLocked() const { return _locked; }
inline const int desiredProjectionSource(){ return _desiredSource; }
inline const int projectionSource() const { return _projectionSource; }
+ inline const int isExamMode() const { return _isExamMode; }
// Setters
inline void setTutor(bool enable){ _isTutor = enable; }
inline void setDesiredProjectionSource(int id){_desiredSource = id;}
+ inline void setExamMode(bool mode) { _isExamMode = mode; }
//Send message stuff
void startVncServer();
@@ -71,8 +74,10 @@ 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;
QByteArray _rawRemoteScreen;
+
static int _clientIdCounter;
bool isManagerMachine();