From 6ba8d9fd7dc9ad27bb94d7a80313102fbe9672ad Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 24 Oct 2023 02:00:15 +0200 Subject: [PATCH] modules: adapt to changes in network manager --- src/modules/locale/Config.cpp | 2 +- src/modules/netinstall/LoaderQueue.cpp | 2 +- src/modules/tracking/TrackingJobs.cpp | 8 ++++---- src/modules/welcome/Tests.cpp | 12 ++++++------ src/modules/welcome/checker/GeneralRequirements.cpp | 8 ++++---- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/modules/locale/Config.cpp b/src/modules/locale/Config.cpp index d8489eccd..226bdfc85 100644 --- a/src/modules/locale/Config.cpp +++ b/src/modules/locale/Config.cpp @@ -547,7 +547,7 @@ Config::startGeoIP() { if ( m_geoip && m_geoip->isValid() ) { - auto& network = Calamares::Network::Manager::instance(); + Calamares::Network::Manager network; if ( network.hasInternet() || network.synchronousPing( m_geoip->url() ) ) { using Watcher = QFutureWatcher< Calamares::GeoIP::RegionZonePair >; diff --git a/src/modules/netinstall/LoaderQueue.cpp b/src/modules/netinstall/LoaderQueue.cpp index d10e45f81..07ce0edf4 100644 --- a/src/modules/netinstall/LoaderQueue.cpp +++ b/src/modules/netinstall/LoaderQueue.cpp @@ -128,7 +128,7 @@ LoaderQueue::fetch( const QUrl& url ) using namespace Calamares::Network; cDebug() << "NetInstall loading groups from" << url; - QNetworkReply* reply = Manager::instance().asynchronousGet( + QNetworkReply* reply = Manager().asynchronousGet( url, RequestOptions( RequestOptions::FakeUserAgent | RequestOptions::FollowRedirect, std::chrono::seconds( 30 ) ) ); diff --git a/src/modules/tracking/TrackingJobs.cpp b/src/modules/tracking/TrackingJobs.cpp index 5bd19de8d..c8e3cfc63 100644 --- a/src/modules/tracking/TrackingJobs.cpp +++ b/src/modules/tracking/TrackingJobs.cpp @@ -113,10 +113,10 @@ TrackingInstallJob::exec() using Calamares::Network::RequestOptions; using Calamares::Network::RequestStatus; - auto result = Manager::instance().synchronousPing( - QUrl( m_url ), - RequestOptions( RequestOptions::FollowRedirect | RequestOptions::FakeUserAgent, - RequestOptions::milliseconds( 5000 ) ) ); + auto result + = Manager().synchronousPing( QUrl( m_url ), + RequestOptions( RequestOptions::FollowRedirect | RequestOptions::FakeUserAgent, + RequestOptions::milliseconds( 5000 ) ) ); if ( result.status == RequestStatus::Timeout ) { cWarning() << "install-tracking request timed out."; diff --git a/src/modules/welcome/Tests.cpp b/src/modules/welcome/Tests.cpp index c68178b37..a33991c08 100644 --- a/src/modules/welcome/Tests.cpp +++ b/src/modules/welcome/Tests.cpp @@ -72,7 +72,7 @@ WelcomeTests::testOneUrl() QVERIFY( map.contains( "requirements" ) ); c.setConfigurationMap( map ); - QCOMPARE( Calamares::Network::Manager::instance().getCheckInternetUrls().count(), 1 ); + QCOMPARE( Calamares::Network::Manager::getCheckInternetUrls().count(), 1 ); } void @@ -107,17 +107,17 @@ WelcomeTests::testUrls() const auto map = Calamares::YAML::load( fi, &ok ); QVERIFY( ok ); - Calamares::Network::Manager::instance().setCheckHasInternetUrl( QVector< QUrl > {} ); - QCOMPARE( Calamares::Network::Manager::instance().getCheckInternetUrls().count(), 0 ); + Calamares::Network::Manager::setCheckHasInternetUrl( QVector< QUrl > {} ); + QCOMPARE( Calamares::Network::Manager::getCheckInternetUrls().count(), 0 ); c.setConfigurationMap( map ); - QCOMPARE( Calamares::Network::Manager::instance().getCheckInternetUrls().count(), result ); + QCOMPARE( Calamares::Network::Manager::getCheckInternetUrls().count(), result ); } void WelcomeTests::testBadConfigDoesNotResetUrls() { - auto& nam = Calamares::Network::Manager::instance(); - Calamares::Network::Manager::instance().setCheckHasInternetUrl( QVector< QUrl > {} ); + Calamares::Network::Manager nam; + Calamares::Network::Manager::setCheckHasInternetUrl( QVector< QUrl > {} ); QCOMPARE( nam.getCheckInternetUrls().count(), 0 ); nam.setCheckHasInternetUrl( QVector< QUrl > { QUrl( "http://example.com" ), QUrl( "https://www.kde.org" ) } ); QCOMPARE( nam.getCheckInternetUrls().count(), 2 ); diff --git a/src/modules/welcome/checker/GeneralRequirements.cpp b/src/modules/welcome/checker/GeneralRequirements.cpp index df594f1e0..a58f3df83 100644 --- a/src/modules/welcome/checker/GeneralRequirements.cpp +++ b/src/modules/welcome/checker/GeneralRequirements.cpp @@ -306,12 +306,12 @@ getCheckInternetUrls( const QVariantMap& configurationMap ) { cWarning() << "GeneralRequirements entry 'internetCheckUrl' contains no valid URLs, " << "reverting to default (" << exampleUrl << ")."; - Calamares::Network::Manager::instance().setCheckHasInternetUrl( QUrl( exampleUrl ) ); + Calamares::Network::Manager::setCheckHasInternetUrl( QUrl( exampleUrl ) ); incomplete = true; } else { - Calamares::Network::Manager::instance().setCheckHasInternetUrl( urls ); + Calamares::Network::Manager::setCheckHasInternetUrl( urls ); } } else @@ -319,7 +319,7 @@ getCheckInternetUrls( const QVariantMap& configurationMap ) cWarning() << "GeneralRequirements entry 'internetCheckUrl' is undefined in welcome.conf, " "reverting to default (" << exampleUrl << ")."; - Calamares::Network::Manager::instance().setCheckHasInternetUrl( QUrl( exampleUrl ) ); + Calamares::Network::Manager::setCheckHasInternetUrl( QUrl( exampleUrl ) ); incomplete = true; } return incomplete; @@ -504,7 +504,7 @@ GeneralRequirements::checkHasPower() bool GeneralRequirements::checkHasInternet() { - auto& nam = Calamares::Network::Manager::instance(); + Calamares::Network::Manager nam; bool hasInternet = nam.checkHasInternet(); Calamares::JobQueue::instance()->globalStorage()->insert( "hasInternet", hasInternet ); return hasInternet;