summaryrefslogtreecommitdiffstats
path: root/src/client
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/client
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/client')
-rw-r--r--src/client/informationdialog/informationdialog.cpp3
-rw-r--r--src/client/net/serverconnection.cpp29
-rw-r--r--src/client/net/serverconnection.h3
-rw-r--r--src/client/toolbar/toolbar.cpp46
-rw-r--r--src/client/toolbar/toolbar.h3
5 files changed, 63 insertions, 21 deletions
diff --git a/src/client/informationdialog/informationdialog.cpp b/src/client/informationdialog/informationdialog.cpp
index 6a8a6b7..275259b 100644
--- a/src/client/informationdialog/informationdialog.cpp
+++ b/src/client/informationdialog/informationdialog.cpp
@@ -31,9 +31,10 @@ void InformationDialog::initTable()
_tableLayout->addRow(new QLabel(tr("hostname")), new QLabel(QHostInfo::localHostName()));
/* ips */
for (QHostAddress a : QNetworkInterface::allAddresses()) {
+ if (a == QHostAddress::Null || a == QHostAddress::Broadcast || a == QHostAddress::LocalHost || a == QHostAddress::AnyIPv6)
+ continue;
QString ip = a.toString();
- if (ip == "::1" || ip == "127.0.0.1") { continue;}
QLabel* label = new QLabel(tr("IP") );
QLabel* value = new QLabel(ip);
diff --git a/src/client/net/serverconnection.cpp b/src/client/net/serverconnection.cpp
index 1275921..02c35fd 100644
--- a/src/client/net/serverconnection.cpp
+++ b/src/client/net/serverconnection.cpp
@@ -66,6 +66,14 @@ void ServerConnection::sendMessage(NetworkMessage& message)
}
}
+void ServerConnection::sendAttention(bool on)
+{
+ NetworkMessage msg;
+ msg.setField(_ID, _ATTENTION);
+ msg.setField(_ENABLE, _BOOL(on));
+ sendMessage(msg);
+}
+
/**
* Disconnect from current server.
* Do some cleanup also, like stopping any VNC server/client
@@ -177,18 +185,21 @@ void ServerConnection::handleMsg()
}
int x = _fromServer.getFieldString(_X).toInt();
int y = _fromServer.getFieldString(_Y).toInt();
- if (x < 32)
- x = 32;
- else if (x > 400)
- x = 400;
- if (y < 18)
- y = 18;
- else if (y > 300)
- y = 300;
// Get rect of primary screen
const QDesktopWidget primary;
const QRect primaryRect = primary.screenGeometry();
+ // Limit requested size so it won't easily leak sensitive information
+ if (x < 32) {
+ x = 32;
+ } else if (x > primaryRect.width() / 8) {
+ x = primaryRect.width() / 8;
+ }
+ if (y < 18) {
+ y = 18;
+ } else if (y > primaryRect.height() / 8) {
+ y = primaryRect.height() / 8;
+ }
QPixmap desktop(
QPixmap::grabWindow(
@@ -255,6 +266,8 @@ void ServerConnection::handleMsg()
_blank->lock(_fromServer.getFieldString("MESSAGE"));
else
_blank->unlock();
+ } else if (id == _ATTENTION) {
+ emit attentionChanged(_fromServer.getFieldString(_ENABLE) == __TRUE);
}
}
diff --git a/src/client/net/serverconnection.h b/src/client/net/serverconnection.h
index aa1d0b4..e299a04 100644
--- a/src/client/net/serverconnection.h
+++ b/src/client/net/serverconnection.h
@@ -43,6 +43,7 @@ public:
return _socket->peerAddress().toString();
}
void sendMessage(NetworkMessage& message);
+ void sendAttention(bool on);
protected:
void timerEvent(QTimerEvent *event);
@@ -63,7 +64,7 @@ signals:
void closeVnc();
void stateChange(ConnectWindow::ConnectionState state);
void disconnected();
-
+ void attentionChanged(bool state);
};
#endif
diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp
index 5fe34e4..10f9d22 100644
--- a/src/client/toolbar/toolbar.cpp
+++ b/src/client/toolbar/toolbar.cpp
@@ -92,8 +92,6 @@ void Toolbar::init()
/* Initialize the GUI */
_ui->setupUi(this);
- _onWorkspace2 = false;
-
/* Set window properties */
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint | Qt::FramelessWindowHint);
setAttribute(Qt::WA_AlwaysShowToolTips);
@@ -115,7 +113,7 @@ void Toolbar::init()
/* setup manager button */
_isManagerPc = isManagerPc();
if (_isManagerPc) {
- connect(_ui->btnManager, SIGNAL(clicked()), this, SLOT(onBtnManager()));
+ connect(_ui->btnManager, SIGNAL(toggled(bool)), this, SLOT(onBtnManager()));
} else {
setFixedWidth(width() - _ui->btnManager->width());
_ui->btnManager->setVisible(false);
@@ -130,6 +128,8 @@ void Toolbar::init()
_ui->btnLockDesktop->setVisible(false);
}
+ connect(_ui->btnAttention, SIGNAL(toggled(bool)), this, SLOT(onBtnAttention()));
+
/* Connect the signals from vnc server */
connect(VncServer::instance(), SIGNAL(started(int, QString&, QString&)), this, SLOT(onVncServerIsRunning(int)));
@@ -379,6 +379,8 @@ void Toolbar::onDisconnected()
this->_acnConnect->setEnabled(true);
this->_acnDisconnect->setEnabled(false);
+ onBtnAttention();
+ _hideTimer.start();
}
/***************************************************************************//**
@@ -392,7 +394,7 @@ void Toolbar::onConnected(ServerConnection* connection)
this->_acnConnect->setEnabled(false);
this->_acnDisconnect->setEnabled(true);
-
+ _ui->btnAttention->setChecked(false);
_ui->lblStatus->setStyleSheet("color:green");
_ui->lblStatus->setText(tr("Online"));
//
@@ -406,6 +408,7 @@ void Toolbar::onConnected(ServerConnection* connection)
connect(_connection, SIGNAL(openVnc(const QString&, int, const QString&, bool, bool, const QString&, const int, const QByteArray&)),
_vnc, SLOT(open(const QString&, int, const QString&, bool, bool, const QString&, const int, const QByteArray&)));
connect(_connection, SIGNAL(closeVnc()), _vnc, SLOT(close()));
+ connect(_connection, SIGNAL(attentionChanged(const bool)), this, SLOT(onServerAttentionChanged(const bool)));
connect(_vnc, SIGNAL(running(const bool, const int)), _connection, SLOT(onVncViewerStartStop(const bool, const int)));
}
@@ -418,6 +421,16 @@ void Toolbar::onDoDisconnect()
_connection->disconnectFromServer();
}
+void Toolbar::onServerAttentionChanged(const bool on)
+{
+ _ui->btnAttention->setChecked(on);
+ if (on) {
+ showBar();
+ } else {
+ hideBar();
+ }
+}
+
/***************************************************************************//**
* This slot hides the toolbar. Places the toolbar hidden behind the edge of the
* screen just showing 2 pixels.
@@ -425,7 +438,7 @@ void Toolbar::onDoDisconnect()
void Toolbar::hideBar()
{
// Don't hide window if any menu is open or VNC Server is running from this client.
- if (_menu->isVisible() || VncServer::instance()->isVncServerRunning())
+ if (_menu->isVisible() || _ui->btnAttention->isChecked() || VncServer::instance()->isVncServerRunning())
return;
const QDesktopWidget desktop;
const QRect primaryScreen = desktop.screenGeometry();
@@ -465,17 +478,30 @@ void Toolbar::showBar()
const QRect primaryScreen = desktop.screenGeometry();
move(x(), primaryScreen.top());
}
+
+void Toolbar::onBtnAttention()
+{
+ const bool on = _connection != NULL && _ui->btnAttention->isChecked();
+ if (on != _ui->btnAttention->isChecked()) {
+ _ui->btnAttention->setChecked(on);
+ return;
+ }
+ if (_connection != NULL) {
+ _connection->sendAttention(on);
+ }
+ _ui->btnAttention->setStyleSheet(on ? "color:red" : "");
+}
+
/** call script to switch to workspace of the manager */
void Toolbar::onBtnManager()
{
QProcess switchP;
- if (_onWorkspace2) {
- switchP.start("/bin/sh", QStringList() << "/opt/openslx/pvs2/switchBack.sh");
- } else {
+ const bool on = _ui->btnAttention->isChecked();
+ if (on) {
switchP.start("/bin/sh", QStringList() << "/opt/openslx/pvs2/switchToManager.sh");
+ } else {
+ switchP.start("/bin/sh", QStringList() << "/opt/openslx/pvs2/switchBack.sh");
}
- _ui->btnManager->setDown(_onWorkspace2);
- _onWorkspace2 = !_onWorkspace2;
switchP.waitForFinished();
}
diff --git a/src/client/toolbar/toolbar.h b/src/client/toolbar/toolbar.h
index eb05f5f..5fb4ea5 100644
--- a/src/client/toolbar/toolbar.h
+++ b/src/client/toolbar/toolbar.h
@@ -51,7 +51,6 @@ private:
ServerConnection *_connection;
QTimer _blinkTimer;
VncWindow *_vnc;
- bool _onWorkspace2;
bool _isManagerPc;
const QPixmap _cam32, _beWatchedEye;
@@ -69,9 +68,11 @@ private slots:
void onVncServerIsRunning(int port);
void onDisconnected();
void onConnected(ServerConnection* connection);
+ void onServerAttentionChanged(const bool on);
void onDoDisconnect();
void onBtnManager();
void onBtnLockDesktop();
+ void onBtnAttention();
void exit();
void cameraBlink();
void showBar();