[welcome] Load potentially a list of URLs to check
This commit is contained in:
parent
2f3062f4c2
commit
1452b74740
@ -215,6 +215,57 @@ GeneralRequirements::checkRequirements()
|
||||
return checkEntries;
|
||||
}
|
||||
|
||||
/** @brief Loads the check-internel URLs
|
||||
*
|
||||
* There may be zero or one or more URLs specified; returns
|
||||
* @c true if the configuration is incomplete or damaged in some way.
|
||||
*/
|
||||
static bool
|
||||
getCheckInternetUrls( const QVariantMap& configurationMap )
|
||||
{
|
||||
const QString exampleUrl = QStringLiteral( "http://example.com" );
|
||||
|
||||
bool incomplete = false;
|
||||
QStringList checkInternetSetting = CalamaresUtils::getStringList( configurationMap, "internetCheckUrl" );
|
||||
if ( !checkInternetSetting.isEmpty() )
|
||||
{
|
||||
QVector< QUrl > urls;
|
||||
for ( const auto& urlString : qAsConst( checkInternetSetting ) )
|
||||
{
|
||||
QUrl url( urlString.trimmed() );
|
||||
if ( url.isValid() )
|
||||
{
|
||||
urls.append( url );
|
||||
}
|
||||
else
|
||||
{
|
||||
cWarning() << "GeneralRequirements entry 'internetCheckUrl' in welcome.conf contains invalid"
|
||||
<< urlString;
|
||||
}
|
||||
}
|
||||
|
||||
if ( urls.empty() )
|
||||
{
|
||||
cWarning() << "GeneralRequirements entry 'internetCheckUrl' contains no valid URLs,"
|
||||
<< "reverting to default (http://example.com).";
|
||||
CalamaresUtils::Network::Manager::instance().setCheckHasInternetUrl( QUrl( exampleUrl ) );
|
||||
incomplete = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
CalamaresUtils::Network::Manager::instance().setCheckHasInternetUrl( urls );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cWarning() << "GeneralRequirements entry 'internetCheckUrl' is undefined in welcome.conf,"
|
||||
"reverting to default (http://example.com).";
|
||||
CalamaresUtils::Network::Manager::instance().setCheckHasInternetUrl( QUrl( exampleUrl ) );
|
||||
incomplete = true;
|
||||
}
|
||||
return incomplete;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GeneralRequirements::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
@ -302,30 +353,7 @@ GeneralRequirements::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
incompleteConfiguration = true;
|
||||
}
|
||||
|
||||
QUrl checkInternetUrl;
|
||||
QString checkInternetSetting = CalamaresUtils::getString( configurationMap, "internetCheckUrl" );
|
||||
if ( !checkInternetSetting.isEmpty() )
|
||||
{
|
||||
checkInternetUrl = QUrl( checkInternetSetting.trimmed() );
|
||||
if ( !checkInternetUrl.isValid() )
|
||||
{
|
||||
cWarning() << "GeneralRequirements entry 'internetCheckUrl' is invalid in welcome.conf"
|
||||
<< checkInternetSetting << "reverting to default (http://example.com).";
|
||||
checkInternetUrl = QUrl( "http://example.com" );
|
||||
incompleteConfiguration = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cWarning() << "GeneralRequirements entry 'internetCheckUrl' is undefined in welcome.conf,"
|
||||
"reverting to default (http://example.com).";
|
||||
checkInternetUrl = "http://example.com";
|
||||
incompleteConfiguration = true;
|
||||
}
|
||||
if ( checkInternetUrl.isValid() )
|
||||
{
|
||||
CalamaresUtils::Network::Manager::instance().setCheckHasInternetUrl( checkInternetUrl );
|
||||
}
|
||||
incompleteConfiguration |= getCheckInternetUrls( configurationMap );
|
||||
|
||||
if ( incompleteConfiguration )
|
||||
{
|
||||
|
@ -43,6 +43,21 @@ requirements:
|
||||
#
|
||||
# The URL is only used if "internet" is in the *check* list below.
|
||||
internetCheckUrl: http://example.com
|
||||
#
|
||||
# This may be a single URL, or a list or URLs, in which case the
|
||||
# URLs will be checked one-by-one; if any of them returns data,
|
||||
# internet is assumed to be OK. This can be used to check via
|
||||
# a number of places, where some domains may be down or blocked.
|
||||
#
|
||||
# To use a list of URLs, just use YAML list syntax (e.g.
|
||||
#
|
||||
# internetCheckUrl:
|
||||
# - http://www.kde.org
|
||||
# - http://www.freebsd.org
|
||||
#
|
||||
# or short-form
|
||||
#
|
||||
# internetCheckUrl: [ http://www.kde.org, http://www.freebsd.org ]
|
||||
|
||||
# List conditions to check. Each listed condition will be
|
||||
# probed in some way, and yields true or false according to
|
||||
|
Loading…
Reference in New Issue
Block a user