[libcalamares] Implement GeoIP Handler config from map

- read map entries with alternate keys
 - delegate to other constructor
main
Adriaan de Groot 6 years ago
parent d5fe86c394
commit fc76313ea6

@ -25,6 +25,7 @@
#include "utils/Logger.h"
#include "utils/NamedEnum.h"
#include "utils/Variant.h"
#include <QEventLoop>
#include <QNetworkRequest>
@ -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()
{
}

@ -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 );

Loading…
Cancel
Save