[welcome] Only do GeoIP query if it's useful

- If badly-configured, then type is none; this is warned about
   in the constructor of Handler()
 - Only run the query if it's a useful type.
This commit is contained in:
Adriaan de Groot 2019-06-18 12:34:52 +02:00
parent 68dc1f5e31
commit 0f66a89236

View File

@ -128,16 +128,24 @@ WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap )
CalamaresUtils::getString( geoip, "style" ),
CalamaresUtils::getString( geoip, "url" ),
CalamaresUtils::getString( geoip, "selector" ) );
auto* future = new FWString();
connect( future, &FWString::finished, [view=this, f=future, h=handler]()
if ( handler->type() != CalamaresUtils::GeoIP::Handler::Type::None )
{
QString countryResult = f->future().result();
cDebug() << "GeoIP result for welcome=" << countryResult;
view->setCountry( countryResult, h );
f->deleteLater();
delete h;
} );
future->setFuture( handler->queryRaw() );
auto* future = new FWString();
connect( future, &FWString::finished, [view=this, f=future, h=handler]()
{
QString countryResult = f->future().result();
cDebug() << "GeoIP result for welcome=" << countryResult;
view->setCountry( countryResult, h );
f->deleteLater();
delete h;
} );
future->setFuture( handler->queryRaw() );
}
else
{
// Would not produce useful country code anyway.
delete handler;
}
}