diff --git a/src/libcalamares/geoip/Handler.cpp b/src/libcalamares/geoip/Handler.cpp index ce500489b..3ee41eaa5 100644 --- a/src/libcalamares/geoip/Handler.cpp +++ b/src/libcalamares/geoip/Handler.cpp @@ -25,6 +25,7 @@ #include "utils/Logger.h" #include "utils/NamedEnum.h" +#include "utils/Variant.h" #include #include @@ -73,6 +74,22 @@ Handler::Handler( const QString& implementation, const QString& url, const QStri } } +static QString +getMapAlternates( const QVariantMap& config, const QString& key1, const QString& key2 ) +{ + QString r = CalamaresUtils::getString( config, key1 ); + if ( r.isEmpty() ) + r = CalamaresUtils::getString( config, key2 ); + return r; +} + +Handler::Handler( const QVariantMap& config ) + : Handler( getMapAlternates( config, QStringLiteral( "style" ), QStringLiteral( "geoipStyle" ) ), + getMapAlternates( config, QStringLiteral( "url" ), QStringLiteral( "geoipUrl" ) ), + getMapAlternates( config, QStringLiteral( "selector" ), QStringLiteral( "geoipSelector" ) ) ) +{ +} + Handler::~Handler() { } diff --git a/src/libcalamares/geoip/Handler.h b/src/libcalamares/geoip/Handler.h index a07b62c7b..8285682dd 100644 --- a/src/libcalamares/geoip/Handler.h +++ b/src/libcalamares/geoip/Handler.h @@ -64,9 +64,6 @@ public: * - implementation from "style" or "geoipStyle" (if the first does not exist) * - url from "url" or "geoipUrl" (if the first does not exist) * - selector from "selector" or "geoipSelector" (if the first does not exist) - * Unlike the 3-QString Handler constructor, this also understands implementations - * "legacy" and blank, which are interpreted as "JSON", except that the url is extended - * by "/json/" before fetching. */ Handler( const QVariantMap& config );