summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2017-12-01 17:12:52 +0100
committerSimon Rettberg2017-12-01 17:12:52 +0100
commitedb818aa42c9bb2e9c5ae437a16aa5f168c0c1a7 (patch)
treed5b2cd33e79a49f4a90ea608abf8cb789dd1091c
parent[client] Use polling when checking whether to hide the bar (diff)
downloadpvs2-edb818aa42c9bb2e9c5ae437a16aa5f168c0c1a7.tar.gz
pvs2-edb818aa42c9bb2e9c5ae437a16aa5f168c0c1a7.tar.xz
pvs2-edb818aa42c9bb2e9c5ae437a16aa5f168c0c1a7.zip
Fix connection problems qith Qt5 (again)
-rw-r--r--src/client/net/serverconnection.cpp24
-rw-r--r--src/client/net/serverdiscovery.cpp4
-rw-r--r--src/server/net/discoverylistener.cpp2
3 files changed, 12 insertions, 18 deletions
diff --git a/src/client/net/serverconnection.cpp b/src/client/net/serverconnection.cpp
index d79c7c3..b2a6b0d 100644
--- a/src/client/net/serverconnection.cpp
+++ b/src/client/net/serverconnection.cpp
@@ -1,8 +1,7 @@
#include "serverconnection.h"
#include <QtCore>
#include <QPixmap>
-#include <QApplication>
-#include <QDesktopWidget>
+#include <QGuiApplication>
#include <QHostInfo>
#include <unistd.h>
#include <cstdlib>
@@ -190,9 +189,8 @@ void ServerConnection::handleMsg()
int x = _fromServer.getFieldString(_X).toInt();
int y = _fromServer.getFieldString(_Y).toInt();
- // Get rect of primary screen
- const QDesktopWidget primary;
- const QRect primaryRect = primary.screenGeometry();
+ QRect primaryRect = QGuiApplication::primaryScreen()->geometry();
+ qDebug() << primaryRect;
// Limit requested size so it won't easily leak sensitive information
if (x < 32) {
x = 32;
@@ -206,16 +204,10 @@ void ServerConnection::handleMsg()
}
QPixmap desktop(
- QPixmap::grabWindow(
- QApplication::desktop()->winId(),
- primaryRect.x(),
- primaryRect.y(),
- primaryRect.width(),
- primaryRect.height()
- ).scaled(
- x, y,
- Qt::KeepAspectRatio,
- Qt::SmoothTransformation));
+ QGuiApplication::primaryScreen()->grabWindow(0,
+ primaryRect.x(), primaryRect.y(), primaryRect.width(), primaryRect.height()
+ ).scaled(x, y, Qt::KeepAspectRatio, Qt::SmoothTransformation
+ ));
QByteArray bytes;
QBuffer jpgBuffer(&bytes);
jpgBuffer.open(QIODevice::WriteOnly);
@@ -365,6 +357,7 @@ 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()));
@@ -375,6 +368,7 @@ void ServerConnection::sslErrors(const QList<QSslError> & errors)
if (err.error() == QSslError::CertificateNotYetValid || err.error() == QSslError::CertificateExpired)
continue;
// Some other SSL error - do not ignore
+ qDebug() << "FATAL!";
_socket->ignoreSslErrors(QList<QSslError>());
return;
}
diff --git a/src/client/net/serverdiscovery.cpp b/src/client/net/serverdiscovery.cpp
index 5ca0eba..33ddbf5 100644
--- a/src/client/net/serverdiscovery.cpp
+++ b/src/client/net/serverdiscovery.cpp
@@ -21,8 +21,8 @@ ServerDiscovery::ServerDiscovery(QObject *parent)
/* Try to get a UDP port for server discovery */
int tries = 10;
while (tries-- != 0) {
- const quint16 port = (quint16)(qrand() % 10000 + 10000);
- if (_discoverySocket.bind(QHostAddress::Any, port))
+ quint16 port = (quint16)(16384 + qrand() % 32768);
+ if (_discoverySocket.bind(QHostAddress::AnyIPv4, port))
break;
if (tries == 0)
qFatal("Could not bind to any UDP port for server discovery.");
diff --git a/src/server/net/discoverylistener.cpp b/src/server/net/discoverylistener.cpp
index 95ad5e4..a13800b 100644
--- a/src/server/net/discoverylistener.cpp
+++ b/src/server/net/discoverylistener.cpp
@@ -32,7 +32,7 @@
DiscoveryListener::DiscoveryListener() :
_socket(this), _counterResetPos(0)
{
- if (!_socket.bind(SERVICE_DISCOVERY_PORT))
+ if (!_socket.bind(QHostAddress::AnyIPv4, SERVICE_DISCOVERY_PORT))
qFatal("Could not bind to service discovery port %d", (int)SERVICE_DISCOVERY_PORT);
connect(&_socket, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
for (int i = 0; i < SD_PACKET_TABLE_SIZE; ++i)