summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2016-10-28 19:46:28 +0200
committerSimon Rettberg2016-10-28 19:46:28 +0200
commit0923de46e6dfa4dc8485ead55a1ce1f3d0c27577 (patch)
treed140c98efc01d4a88f10dd1fa8796682ae4b04be
parentFix compile warnings (diff)
downloadpvs2-0923de46e6dfa4dc8485ead55a1ce1f3d0c27577.tar.gz
pvs2-0923de46e6dfa4dc8485ead55a1ce1f3d0c27577.tar.xz
pvs2-0923de46e6dfa4dc8485ead55a1ce1f3d0c27577.zip
[server] Show IP address in room layout right after loading it
-rw-r--r--src/server/connectionframe/connectionframe.cpp24
-rw-r--r--src/server/connectionframe/connectionframe.h3
-rw-r--r--src/server/net/sslserver.cpp4
3 files changed, 21 insertions, 10 deletions
diff --git a/src/server/connectionframe/connectionframe.cpp b/src/server/connectionframe/connectionframe.cpp
index 4228441..90d72da 100644
--- a/src/server/connectionframe/connectionframe.cpp
+++ b/src/server/connectionframe/connectionframe.cpp
@@ -118,6 +118,7 @@ ConnectionFrame::ConnectionFrame(QWidget *parent, int width, int height) :
this->setLayout(_mainLayout);
this->setSize(width, height);
this->updateAppearance();
+ this->updateLabels();
}
ConnectionFrame::~ConnectionFrame()
@@ -170,10 +171,7 @@ void ConnectionFrame::assignClient(Client* client)
connect( client, SIGNAL(stateChanged()), this, SLOT(updateAppearance()));
_client = client;
_computerId = client->ip();
- _lblHostName->setText(client->ip());
- _lblHostName->setToolTip(client->host());
- _lblUserName->setText(client->name());
- _lblUserName->show();
+ updateLabels();
showDefaultThumb();
if (_timerId == 0)
_timerId = startTimer(1000 + qrand() % 150);
@@ -193,6 +191,19 @@ void ConnectionFrame::showDefaultThumb()
//_imgScreen->setPixmap(_remoteScreen);
}
+void ConnectionFrame::updateLabels()
+{
+ _lblHostName->setText(_computerId);
+ if (_client == NULL) {
+ _lblUserName->setText(QString());
+ _lblUserName->hide();
+ } else {
+ _lblHostName->setToolTip(_client->host());
+ _lblUserName->setText(_client->name());
+ _lblUserName->show();
+ }
+}
+
/**
* Handle mouse release event on frame.
* Check if frame was clicked or moved, if not moved enough, the event is handled as click.
@@ -395,10 +406,9 @@ void ConnectionFrame::onClientDisconnected()
_timerId = 0;
}
_client = NULL;
- _lblUserName->setText(QString());
- _lblUserName->hide();
showDefaultThumb();
- this->updateAppearance();
+ updateLabels();
+ updateAppearance();
}
/**
diff --git a/src/server/connectionframe/connectionframe.h b/src/server/connectionframe/connectionframe.h
index 56cde9c..9d86c70 100644
--- a/src/server/connectionframe/connectionframe.h
+++ b/src/server/connectionframe/connectionframe.h
@@ -62,7 +62,7 @@ public:
const inline QPoint& getCurrentPosition() const { return _currentPosition; }
const QString& computerId() const { return _computerId; }
- const inline void setComputerId(QString computerId) { _computerId = computerId; }
+ void setComputerId(QString computerId) { if (_client != NULL) return; _computerId = computerId; updateLabels(); }
Client* client() const { return _client; }
inline const bool isTutor() const { return _isTutor; }
@@ -87,6 +87,7 @@ private slots:
void onClientDisconnected();
void onThumbUpdated(Client* client, const QPixmap& thumb, const QByteArray& rawImage);
void updateAppearance();
+ void updateLabels();
};
#endif
diff --git a/src/server/net/sslserver.cpp b/src/server/net/sslserver.cpp
index 3d8f924..f75f174 100644
--- a/src/server/net/sslserver.cpp
+++ b/src/server/net/sslserver.cpp
@@ -73,9 +73,9 @@ void SslServer::timerEvent(QTimerEvent* event)
_pending.clear();
}
-bool SslServer::hasPendingConnections()
+bool SslServer::hasPendingConnections() const
{
- for (QList<QSslSocket*>::iterator it(_pending.begin()); it != _pending.end(); it++) {
+ for (QList<QSslSocket*>::const_iterator it(_pending.begin()); it != _pending.end(); it++) {
qDebug("State: %d - Encrypted: %d", (int)(*it)->state(), (*it)->isEncrypted());
if ((*it)->state() == QAbstractSocket::ConnectedState && (*it)->isEncrypted())
return true;