Merge pull request #1502 from asif-mahmud/calamares

[libcalamares] Internet accessibility checking done by synchronous ping method
This commit is contained in:
Adriaan de Groot 2020-08-27 13:24:50 +02:00 committed by GitHub
commit c3903b6e88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -149,18 +149,23 @@ Manager::hasInternet()
bool bool
Manager::checkHasInternet() Manager::checkHasInternet()
{ {
bool hasInternet = d->nam()->networkAccessible() == QNetworkAccessManager::Accessible;
if ( !hasInternet && ( d->nam()->networkAccessible() == QNetworkAccessManager::UnknownAccessibility ) ) d->m_hasInternet = synchronousPing( d->m_hasInternetUrl );
// For earlier Qt versions (< 5.15.0), set the accessibility flag to
// NotAccessible if synchronous ping has failed, so that any module
// using Qt's networkAccessible method to determine whether or not
// internet connection is actually avaialable won't get confused over
// virtualization technologies.
#if ( QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 ) )
if ( !d->m_hasInternet )
{ {
hasInternet = synchronousPing( d->m_hasInternetUrl ); d->nam()->setNetworkAccessible( QNetworkAccessManager::NotAccessible );
} }
if ( hasInternet != d->m_hasInternet ) #endif
{
d->m_hasInternet = hasInternet; emit hasInternetChanged( d->m_hasInternet );
emit hasInternetChanged( hasInternet ); return d->m_hasInternet;
}
return hasInternet;
} }
void void