summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
authorSimon Rettberg2016-10-19 23:56:34 +0200
committerSimon Rettberg2016-10-19 23:56:34 +0200
commit6534027c5ce5579c4293aa346cadf0850aa02157 (patch)
treef9974a9dbed4ca33a4e167e05cde1dc7915b31a4 /src/server
parent[client] Update translations (diff)
downloadpvs2-6534027c5ce5579c4293aa346cadf0850aa02157.tar.gz
pvs2-6534027c5ce5579c4293aa346cadf0850aa02157.tar.xz
pvs2-6534027c5ce5579c4293aa346cadf0850aa02157.zip
Implement "Attention" feature (virtual hand-raising)
Diffstat (limited to 'src/server')
-rw-r--r--src/server/connectionframe/connectionframe.cpp16
-rw-r--r--src/server/connectionframe/connectionframe.h5
-rw-r--r--src/server/mainwindow/mainwindow.cpp10
-rw-r--r--src/server/net/client.cpp21
-rw-r--r--src/server/net/client.h6
5 files changed, 42 insertions, 16 deletions
diff --git a/src/server/connectionframe/connectionframe.cpp b/src/server/connectionframe/connectionframe.cpp
index a7427c6..4228441 100644
--- a/src/server/connectionframe/connectionframe.cpp
+++ b/src/server/connectionframe/connectionframe.cpp
@@ -28,13 +28,21 @@ static QString style_tutor(
"QLabel{ background-color: #FFF; border-radius: 2px; color: black;} \
QGroupBox { background-color: #70C670; margin: 2px; border-radius: 4px}"
);
+static QString style_attention(
+ "QLabel{ background-color: #FFF; border-radius: 2px; color: black;} \
+ QGroupBox { background-color: #C88; margin: 2px; border-radius: 4px}"
+);
static QString style_selectedStudent(
"QLabel{ background-color: #FFF; border-radius: 2px; color: black; } \
QGroupBox { background-color: #ccebff; margin: 0px; border-radius: 4px; border: 4px solid #6C8CF0;}"
);
static QString style_selectedTutor(
"QLabel{ background-color: #FFF; border-radius: 2px; color: black;} \
- QGroupBox { background-color: #99ff99; margin: 0px; border-radius: 4px; border: 4px solid #6C8CF0;}"
+ QGroupBox { background-color: #9f9; margin: 0px; border-radius: 4px; border: 4px solid #6C8CF0;}"
+);
+static QString style_selectedAttention(
+ "QLabel{ background-color: #FFF; border-radius: 2px; color: black;} \
+ QGroupBox { background-color: #E99; margin: 0px; border-radius: 4px; border: 4px solid #6C8CF0;}"
);
static QString style_exam (
"QLabel{ background-color: #919191; color: black; } \
@@ -45,7 +53,7 @@ static QString style_exam_selected (
QGroupBox { background-color: #cc743a; margin: 1px; border-radius: 4px}"
);
static QString style_disconnected(
- "QLabel{ background-color: #919191; color: black; } \
+ "QLabel{ background-color: #919191; border-radius: 2px; color: black; } \
QGroupBox { background-color: #7F7F7F; margin: 1px; border-radius: 4px}"
);
@@ -355,6 +363,10 @@ void ConnectionFrame::updateAppearance()
this->setStyleSheet(style_selectedTutor);
} else if (_isTutor) {
this->setStyleSheet(style_tutor);
+ } else if (_isSelected && _client->wantsAttention()) {
+ this->setStyleSheet(style_selectedAttention);
+ } else if (_client->wantsAttention()) {
+ this->setStyleSheet(style_attention);
} else if (_client->isExamMode()) {
if (_isSelected) {
this->setStyleSheet(style_exam_selected);
diff --git a/src/server/connectionframe/connectionframe.h b/src/server/connectionframe/connectionframe.h
index 4f4decb..56cde9c 100644
--- a/src/server/connectionframe/connectionframe.h
+++ b/src/server/connectionframe/connectionframe.h
@@ -45,11 +45,6 @@ private:
void showDefaultThumb();
QLabel* addIcon(const QIcon* icon);
- // Static stylesheets
- static const QString studentLblStyle, studentBgStyle;
- static const QString tutorLblStyle, tutorBgStyle;
- static const QString selectedBgStyle;
-
public:
ConnectionFrame(QWidget* parent, int width, int height);
virtual ~ConnectionFrame();
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index b54a190..ded64b9 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -689,8 +689,10 @@ void MainWindow::reset()
// Unlock all clients
for (QList<ConnectionFrame*>::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- if ((*it)->client() != NULL)
+ if ((*it)->client() != NULL) {
(*it)->client()->lockScreen(false);
+ (*it)->client()->removeAttention();
+ }
// Stop server (Clients get stopped on ACK)
if (getClientFromId(_streamingSource) != NULL)
@@ -791,10 +793,12 @@ void MainWindow::startVncServerIfNecessary(int from)
// If streaming source is already active avoid a restart
if (ns != NULL) {
- if (ns->isActiveVncServer())
+ if (ns->isActiveVncServer()) {
this->onVncServerStateChange(ns);
- else // Could not take shortcut, (re)start VNC server on source
+ } else { // Could not take shortcut, (re)start VNC server on source
ns->startVncServer();
+ }
+ ns->removeAttention();
}
}
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);