Remove use of QNetworkConfiguration in Qt6

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2022-11-21 17:54:54 +01:00 committed by Matthieu Gallien
parent 79a150baf4
commit 29b0d2b8ad
3 changed files with 13 additions and 8 deletions

View file

@ -67,6 +67,7 @@
#include <QUrlQuery>
#include <QVersionNumber>
#include <QRandomGenerator>
#include <QHttp2Configuration>
class QSocket;
@ -429,7 +430,7 @@ Application::Application(int &argc, char **argv)
QTimer::singleShot(0, this, &Application::slotCheckConnection);
// Can't use onlineStateChanged because it is always true on modern systems because of many interfaces
connect(&_networkConfigurationManager, &QNetworkConfigurationManager::configurationChanged,
connect(QNetworkInformation::instance(), &QNetworkInformation::reachabilityChanged,
this, &Application::slotSystemOnlineConfigurationChanged);
#if defined(BUILD_UPDATER)
@ -647,9 +648,10 @@ void Application::slotCleanup()
// FIXME: This is not ideal yet since a ConnectionValidator might already be running and is in
// progress of timing out in some seconds.
// Maybe we need 2 validators, one triggered by timer, one by network configuration changes?
void Application::slotSystemOnlineConfigurationChanged(QNetworkConfiguration cnf)
void Application::slotSystemOnlineConfigurationChanged()
{
if (cnf.state() & QNetworkConfiguration::Active) {
if (QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Site ||
QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Online) {
const auto list = AccountManager::instance()->accounts();
for (const auto &accountState : list) {
accountState->systemOnlineConfigurationChanged();

View file

@ -20,7 +20,7 @@
#include <QQueue>
#include <QTimer>
#include <QElapsedTimer>
#include <QNetworkConfigurationManager>
#include <QNetworkInformation>
#include "qtsingleapplication.h"
@ -110,7 +110,7 @@ protected slots:
void slotCleanup();
void slotAccountStateAdded(OCC::AccountState *accountState);
void slotAccountStateRemoved(OCC::AccountState *accountState);
void slotSystemOnlineConfigurationChanged(QNetworkConfiguration);
void slotSystemOnlineConfigurationChanged();
void slotGuiIsShowingSettings();
private:
@ -152,7 +152,6 @@ private:
ClientProxy _proxy;
QNetworkConfigurationManager _networkConfigurationManager;
QTimer _checkConnectionTimer;
QString _overrideServerUrl;

View file

@ -20,7 +20,11 @@
#include <QSslConfiguration>
#include <QNetworkCookie>
#include <QNetworkCookieJar>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QNetworkConfiguration>
#else
#include <QNetworkInformation>
#endif
#include <QUuid>
#include "cookiejar.h"
@ -42,8 +46,8 @@ AccessManager::AccessManager(QObject *parent)
setProxy(proxy);
#endif
#ifndef Q_OS_LINUX
// Attempt to workaround for https://github.com/owncloud/client/issues/3969
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && !defined(Q_OS_LINUX)
// Atempt to workaround for https://github.com/owncloud/client/issues/3969
setConfiguration(QNetworkConfiguration());
#endif
setCookieJar(new CookieJar);