From 352b385b121e447c11db80ec0d9c6b541342a084 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 16 Apr 2018 05:16:23 -0400 Subject: [PATCH] [locale] Make the selector configurable via the config file --- src/modules/locale/LocaleViewStep.cpp | 7 ++++--- src/modules/locale/LocaleViewStep.h | 6 ++++-- src/modules/locale/locale.conf | 13 ++++++++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/modules/locale/LocaleViewStep.cpp b/src/modules/locale/LocaleViewStep.cpp index 73121581c..4a6eb229a 100644 --- a/src/modules/locale/LocaleViewStep.cpp +++ b/src/modules/locale/LocaleViewStep.cpp @@ -124,16 +124,16 @@ LocaleViewStep::fetchGeoIpTimezone() if ( m_geoipStyle.isEmpty() || m_geoipStyle == "legacy" ) { actualUrl.append( "/json/" ); - handler = new GeoIPJSON; + handler = new GeoIPJSON( m_geoipSelector ); } else if ( m_geoipStyle == "json" ) { - handler = new GeoIPJSON; + handler = new GeoIPJSON( m_geoipSelector ); } #if defined(HAVE_XML) else if ( m_geoipStyle == "xml" ) { - handler = new GeoIPXML; + handler = new GeoIPXML( m_geoipSelector ); } #endif else @@ -295,4 +295,5 @@ LocaleViewStep::setConfigurationMap( const QVariantMap& configurationMap ) // Optional m_geoipUrl = CalamaresUtils::getString( configurationMap, "geoipUrl" ); m_geoipStyle = CalamaresUtils::getString( configurationMap, "geoipStyle" ); + m_geoipSelector = CalamaresUtils::getString( configurationMap, "geoipSelector" ); } diff --git a/src/modules/locale/LocaleViewStep.h b/src/modules/locale/LocaleViewStep.h index 003978d6a..b02f6adbd 100644 --- a/src/modules/locale/LocaleViewStep.h +++ b/src/modules/locale/LocaleViewStep.h @@ -75,8 +75,10 @@ private: QPair< QString, QString > m_startingTimezone; QString m_localeGenPath; - QString m_geoipUrl; - QString m_geoipStyle; + + QString m_geoipUrl; // The URL, depening on style might be modified on lookup + QString m_geoipStyle; // String selecting which kind of geoip data to expect + QString m_geoipSelector; // String selecting data from the geoip lookup QList< Calamares::job_ptr > m_jobs; }; diff --git a/src/modules/locale/locale.conf b/src/modules/locale/locale.conf index 327b53784..643ccd7c1 100644 --- a/src/modules/locale/locale.conf +++ b/src/modules/locale/locale.conf @@ -37,7 +37,9 @@ zone: "New_York" # the URL may be modified before use. The request should return # valid data in a suitable format, depending on geoipStyle; # generally this includes a string value with the timezone -# in / format. +# in / format. For services that return data which +# does not follow the conventions of "suitable data" described +# below, *geoIPSelector* may be used to pick different data. # # Note that this example URL works, but the service is shutting # down in June 2018. @@ -68,3 +70,12 @@ zone: "New_York" # shutting down in June 2018. There are other providers with the same # format. XML format is provided for Ubiquity. #geoipStyle: "legacy" + +# GeoIP selector. Leave commented out for the default selector +# (which depends on the style: JSON uses "time_zone" and XML +# uses TimeZone, for the FreeGeoIP-alike and the Ubiquity-alike +# respectively). If the service configured via *geoipUrl* uses +# a different attribute name (e.g. "timezone") in JSON or a +# different element tag (e.g. "") in XML, set this +# string to the name or tag to be used. +#geoipSelector: ""