From 0923de46e6dfa4dc8485ead55a1ce1f3d0c27577 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 28 Oct 2016 19:46:28 +0200 Subject: [server] Show IP address in room layout right after loading it --- src/server/connectionframe/connectionframe.cpp | 24 +++++++++++++++++------- src/server/connectionframe/connectionframe.h | 3 ++- src/server/net/sslserver.cpp | 4 ++-- 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::iterator it(_pending.begin()); it != _pending.end(); it++) { + for (QList::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; -- cgit v1.2.3-55-g7522