modules: adapt to changes in network manager

This commit is contained in:
Adriaan de Groot 2023-10-24 02:00:15 +02:00
parent 8ebba4fcff
commit 6ba8d9fd7d
5 changed files with 16 additions and 16 deletions

View File

@ -547,7 +547,7 @@ Config::startGeoIP()
{ {
if ( m_geoip && m_geoip->isValid() ) if ( m_geoip && m_geoip->isValid() )
{ {
auto& network = Calamares::Network::Manager::instance(); Calamares::Network::Manager network;
if ( network.hasInternet() || network.synchronousPing( m_geoip->url() ) ) if ( network.hasInternet() || network.synchronousPing( m_geoip->url() ) )
{ {
using Watcher = QFutureWatcher< Calamares::GeoIP::RegionZonePair >; using Watcher = QFutureWatcher< Calamares::GeoIP::RegionZonePair >;

View File

@ -128,7 +128,7 @@ LoaderQueue::fetch( const QUrl& url )
using namespace Calamares::Network; using namespace Calamares::Network;
cDebug() << "NetInstall loading groups from" << url; cDebug() << "NetInstall loading groups from" << url;
QNetworkReply* reply = Manager::instance().asynchronousGet( QNetworkReply* reply = Manager().asynchronousGet(
url, url,
RequestOptions( RequestOptions::FakeUserAgent | RequestOptions::FollowRedirect, std::chrono::seconds( 30 ) ) ); RequestOptions( RequestOptions::FakeUserAgent | RequestOptions::FollowRedirect, std::chrono::seconds( 30 ) ) );

View File

@ -113,10 +113,10 @@ TrackingInstallJob::exec()
using Calamares::Network::RequestOptions; using Calamares::Network::RequestOptions;
using Calamares::Network::RequestStatus; using Calamares::Network::RequestStatus;
auto result = Manager::instance().synchronousPing( auto result
QUrl( m_url ), = Manager().synchronousPing( QUrl( m_url ),
RequestOptions( RequestOptions::FollowRedirect | RequestOptions::FakeUserAgent, RequestOptions( RequestOptions::FollowRedirect | RequestOptions::FakeUserAgent,
RequestOptions::milliseconds( 5000 ) ) ); RequestOptions::milliseconds( 5000 ) ) );
if ( result.status == RequestStatus::Timeout ) if ( result.status == RequestStatus::Timeout )
{ {
cWarning() << "install-tracking request timed out."; cWarning() << "install-tracking request timed out.";

View File

@ -72,7 +72,7 @@ WelcomeTests::testOneUrl()
QVERIFY( map.contains( "requirements" ) ); QVERIFY( map.contains( "requirements" ) );
c.setConfigurationMap( map ); c.setConfigurationMap( map );
QCOMPARE( Calamares::Network::Manager::instance().getCheckInternetUrls().count(), 1 ); QCOMPARE( Calamares::Network::Manager::getCheckInternetUrls().count(), 1 );
} }
void void
@ -107,17 +107,17 @@ WelcomeTests::testUrls()
const auto map = Calamares::YAML::load( fi, &ok ); const auto map = Calamares::YAML::load( fi, &ok );
QVERIFY( ok ); QVERIFY( ok );
Calamares::Network::Manager::instance().setCheckHasInternetUrl( QVector< QUrl > {} ); Calamares::Network::Manager::setCheckHasInternetUrl( QVector< QUrl > {} );
QCOMPARE( Calamares::Network::Manager::instance().getCheckInternetUrls().count(), 0 ); QCOMPARE( Calamares::Network::Manager::getCheckInternetUrls().count(), 0 );
c.setConfigurationMap( map ); c.setConfigurationMap( map );
QCOMPARE( Calamares::Network::Manager::instance().getCheckInternetUrls().count(), result ); QCOMPARE( Calamares::Network::Manager::getCheckInternetUrls().count(), result );
} }
void void
WelcomeTests::testBadConfigDoesNotResetUrls() WelcomeTests::testBadConfigDoesNotResetUrls()
{ {
auto& nam = Calamares::Network::Manager::instance(); Calamares::Network::Manager nam;
Calamares::Network::Manager::instance().setCheckHasInternetUrl( QVector< QUrl > {} ); Calamares::Network::Manager::setCheckHasInternetUrl( QVector< QUrl > {} );
QCOMPARE( nam.getCheckInternetUrls().count(), 0 ); QCOMPARE( nam.getCheckInternetUrls().count(), 0 );
nam.setCheckHasInternetUrl( QVector< QUrl > { QUrl( "http://example.com" ), QUrl( "https://www.kde.org" ) } ); nam.setCheckHasInternetUrl( QVector< QUrl > { QUrl( "http://example.com" ), QUrl( "https://www.kde.org" ) } );
QCOMPARE( nam.getCheckInternetUrls().count(), 2 ); QCOMPARE( nam.getCheckInternetUrls().count(), 2 );

View File

@ -306,12 +306,12 @@ getCheckInternetUrls( const QVariantMap& configurationMap )
{ {
cWarning() << "GeneralRequirements entry 'internetCheckUrl' contains no valid URLs, " cWarning() << "GeneralRequirements entry 'internetCheckUrl' contains no valid URLs, "
<< "reverting to default (" << exampleUrl << ")."; << "reverting to default (" << exampleUrl << ").";
Calamares::Network::Manager::instance().setCheckHasInternetUrl( QUrl( exampleUrl ) ); Calamares::Network::Manager::setCheckHasInternetUrl( QUrl( exampleUrl ) );
incomplete = true; incomplete = true;
} }
else else
{ {
Calamares::Network::Manager::instance().setCheckHasInternetUrl( urls ); Calamares::Network::Manager::setCheckHasInternetUrl( urls );
} }
} }
else else
@ -319,7 +319,7 @@ getCheckInternetUrls( const QVariantMap& configurationMap )
cWarning() << "GeneralRequirements entry 'internetCheckUrl' is undefined in welcome.conf, " cWarning() << "GeneralRequirements entry 'internetCheckUrl' is undefined in welcome.conf, "
"reverting to default (" "reverting to default ("
<< exampleUrl << ")."; << exampleUrl << ").";
Calamares::Network::Manager::instance().setCheckHasInternetUrl( QUrl( exampleUrl ) ); Calamares::Network::Manager::setCheckHasInternetUrl( QUrl( exampleUrl ) );
incomplete = true; incomplete = true;
} }
return incomplete; return incomplete;
@ -504,7 +504,7 @@ GeneralRequirements::checkHasPower()
bool bool
GeneralRequirements::checkHasInternet() GeneralRequirements::checkHasInternet()
{ {
auto& nam = Calamares::Network::Manager::instance(); Calamares::Network::Manager nam;
bool hasInternet = nam.checkHasInternet(); bool hasInternet = nam.checkHasInternet();
Calamares::JobQueue::instance()->globalStorage()->insert( "hasInternet", hasInternet ); Calamares::JobQueue::instance()->globalStorage()->insert( "hasInternet", hasInternet );
return hasInternet; return hasInternet;