|
|
|
@ -25,12 +25,14 @@
|
|
|
|
|
#include "partman_devices.h"
|
|
|
|
|
|
|
|
|
|
#include "modulesystem/Requirement.h"
|
|
|
|
|
#include "network/Manager.h"
|
|
|
|
|
#include "widgets/WaitingWidget.h"
|
|
|
|
|
#include "utils/CalamaresUtilsGui.h"
|
|
|
|
|
#include "utils/Logger.h"
|
|
|
|
|
#include "utils/Retranslator.h"
|
|
|
|
|
#include "utils/CalamaresUtilsSystem.h"
|
|
|
|
|
#include "utils/Units.h"
|
|
|
|
|
#include "utils/Variant.h"
|
|
|
|
|
#include "Settings.h"
|
|
|
|
|
|
|
|
|
|
#include "JobQueue.h"
|
|
|
|
@ -245,16 +247,16 @@ GeneralRequirements::setConfigurationMap( const QVariantMap& configurationMap )
|
|
|
|
|
incompleteConfiguration = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( configurationMap.contains( "internetCheckUrl" ) &&
|
|
|
|
|
configurationMap.value( "internetCheckUrl" ).type() == QVariant::String )
|
|
|
|
|
QUrl checkInternetUrl;
|
|
|
|
|
QString checkInternetSetting = CalamaresUtils::getString( configurationMap, "internetCheckUrl" );
|
|
|
|
|
if ( !checkInternetSetting.isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
m_checkHasInternetUrl = configurationMap.value( "internetCheckUrl" ).toString().trimmed();
|
|
|
|
|
if ( m_checkHasInternetUrl.isEmpty() ||
|
|
|
|
|
!QUrl( m_checkHasInternetUrl ).isValid() )
|
|
|
|
|
checkInternetUrl = QUrl( checkInternetSetting.trimmed() );
|
|
|
|
|
if ( !checkInternetUrl.isValid() )
|
|
|
|
|
{
|
|
|
|
|
cWarning() << "GeneralRequirements entry 'internetCheckUrl' is invalid in welcome.conf" << m_checkHasInternetUrl
|
|
|
|
|
cWarning() << "GeneralRequirements entry 'internetCheckUrl' is invalid in welcome.conf" << checkInternetSetting
|
|
|
|
|
<< "reverting to default (http://example.com).";
|
|
|
|
|
m_checkHasInternetUrl = "http://example.com";
|
|
|
|
|
checkInternetUrl = QUrl( "http://example.com" );
|
|
|
|
|
incompleteConfiguration = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -262,10 +264,13 @@ GeneralRequirements::setConfigurationMap( const QVariantMap& configurationMap )
|
|
|
|
|
{
|
|
|
|
|
cWarning() << "GeneralRequirements entry 'internetCheckUrl' is undefined in welcome.conf,"
|
|
|
|
|
"reverting to default (http://example.com).";
|
|
|
|
|
|
|
|
|
|
m_checkHasInternetUrl = "http://example.com";
|
|
|
|
|
checkInternetUrl = "http://example.com";
|
|
|
|
|
incompleteConfiguration = true;
|
|
|
|
|
}
|
|
|
|
|
if ( checkInternetUrl.isValid() )
|
|
|
|
|
{
|
|
|
|
|
CalamaresUtils::Network::Manager::instance().setCheckHasInternetUrl( checkInternetUrl );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( incompleteConfiguration )
|
|
|
|
|
{
|
|
|
|
@ -357,22 +362,8 @@ GeneralRequirements::checkHasPower()
|
|
|
|
|
bool
|
|
|
|
|
GeneralRequirements::checkHasInternet()
|
|
|
|
|
{
|
|
|
|
|
// default to true in the QNetworkAccessManager::UnknownAccessibility case
|
|
|
|
|
QNetworkAccessManager qnam;
|
|
|
|
|
bool hasInternet = qnam.networkAccessible() == QNetworkAccessManager::Accessible;
|
|
|
|
|
|
|
|
|
|
if ( !hasInternet && qnam.networkAccessible() == QNetworkAccessManager::UnknownAccessibility )
|
|
|
|
|
{
|
|
|
|
|
QNetworkRequest req = QNetworkRequest( QUrl( m_checkHasInternetUrl ) );
|
|
|
|
|
QNetworkReply* reply = qnam.get( req );
|
|
|
|
|
QEventLoop loop;
|
|
|
|
|
connect( reply, &QNetworkReply::finished,
|
|
|
|
|
&loop, &QEventLoop::quit );
|
|
|
|
|
loop.exec();
|
|
|
|
|
if( reply->bytesAvailable() )
|
|
|
|
|
hasInternet = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto& nam = CalamaresUtils::Network::Manager::instance();
|
|
|
|
|
bool hasInternet = nam.checkHasInternet();
|
|
|
|
|
Calamares::JobQueue::instance()->globalStorage()->insert( "hasInternet", hasInternet );
|
|
|
|
|
return hasInternet;
|
|
|
|
|
}
|
|
|
|
|