diff options
Diffstat (limited to 'src/client/net/serverconnection.cpp')
-rw-r--r-- | src/client/net/serverconnection.cpp | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/src/client/net/serverconnection.cpp b/src/client/net/serverconnection.cpp index ca19c76..e500528 100644 --- a/src/client/net/serverconnection.cpp +++ b/src/client/net/serverconnection.cpp @@ -1,21 +1,20 @@ #include "serverconnection.h" -#include <QtCore> -#include <QPixmap> -#include <QGuiApplication> -#include <QHostInfo> -#include <unistd.h> -#include <cstdlib> -#include <sys/types.h> -#include <pwd.h> -//#define verbose #include "../vnc/vncserver.h" - #include "../../shared/util.h" #include "../../shared/settings.h" #include "../util/platform/blankscreen.h" #include "../clientapp/clientapp.h" +#include <QPixmap> +#include <QGuiApplication> +#include <QHostInfo> +#include <QScreen> +// For getting logged-in username +#include <sys/types.h> +#include <pwd.h> +#include <unistd.h> + #define CHALLENGE_LEN 20 ServerConnection::ServerConnection(const QString& host, const quint16 port, const QByteArray& sessionName, const QByteArray& certHash, bool autoConnect) : @@ -23,16 +22,13 @@ ServerConnection::ServerConnection(const QString& host, const quint16 port, cons { _socket = new QSslSocket(); _blank = new BlankScreen(); - connect(_socket, SIGNAL(encrypted()), this, SLOT(sock_connected())); - connect(_socket, SIGNAL(readyRead()), this, SLOT(sock_dataArrival())); - connect(_socket, SIGNAL(disconnected()), this, SLOT(sock_closed())); - connect(_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(sock_error(QAbstractSocket::SocketError))); - connect(_socket, - SIGNAL(sslErrors(const QList<QSslError> &)), - this, - SLOT(sslErrors(const QList<QSslError> &)) + connect(_socket, &QSslSocket::encrypted, this, &ServerConnection::sock_connected); + connect(_socket, &QSslSocket::readyRead, this, &ServerConnection::sock_dataArrival); + connect(_socket, &QSslSocket::disconnected, this, &ServerConnection::sock_closed); + connect(_socket, &QSslSocket::errorOccurred, this, &ServerConnection::sock_error); + connect(_socket, QOverload<const QList<QSslError> &>::of(&QSslSocket::sslErrors), + this, &ServerConnection::sslErrors ); - connect(_socket, &QSslSocket::peerVerifyError, [=](const QSslError &error) { qDebug() << "PVE:" << error.errorString(); }); qDebug("Connecting to %s on port %d", host.toUtf8().data(), int(port)); _socket->ignoreSslErrors(); _socket->connectToHostEncrypted(host, port); @@ -40,7 +36,7 @@ ServerConnection::ServerConnection(const QString& host, const quint16 port, cons _lastData = QDateTime::currentMSecsSinceEpoch() + PING_TIMEOUT_MS; _timerConnectionCheck = startTimer(5000); // Connect the vnc start/stop signal to this class, so we can tell the server about successful vnc server startup - connect(VncServer::instance(), SIGNAL(started(int, QString&, QString&)), this, SLOT(onVncServerStartStop(int, QString&, QString&))); + connect(VncServer::instance(), &VncServer::started, this, &ServerConnection::onVncServerStartStop); } ServerConnection::~ServerConnection() @@ -112,7 +108,7 @@ void ServerConnection::handleMsg() emit stateChange(ConnectWindow::AwaitingChallengeResponse); _myChallenge.resize(CHALLENGE_LEN); for (int i = 0; i < CHALLENGE_LEN; ++i) { - _myChallenge[i] = char(qrand() & 0xff); + _myChallenge[i] = char(slxrand() & 0xff); } QByteArray serverChallenge(_fromServer.getFieldBytes(_CHALLENGE)); _toServer.reset(); @@ -320,7 +316,7 @@ void ServerConnection::timerEvent(QTimerEvent *event) * server was succesfully started, or was terminated (either planned or * crashed). */ -void ServerConnection::onVncServerStartStop(int port, QString& ropass, QString& rwpass) +void ServerConnection::onVncServerStartStop(int port, const QString &ropass, const QString &rwpass) { _toServer.reset(); _toServer.setField(_ID, _VNCSERVER); @@ -357,9 +353,8 @@ void ServerConnection::onVncViewerStartStop(const bool started, const int client void ServerConnection::sslErrors(const QList<QSslError> & errors) { _socket->ignoreSslErrors(); - for (QList<QSslError>::const_iterator it = errors.begin(); it != errors.end(); it++) { - const QSslError &err = *it; - qDebug("Connect SSL: %s", qPrintable(err.errorString())); + for (const auto &err : errors) { + qDebug("Connect SSL: %s", qPrintable(err.errorString())); if (err.error() == QSslError::HostNameMismatch) continue; // We don't pay attention to hostnames for validation if (err.error() == QSslError::SelfSignedCertificate) |