[locale] Make the selector configurable via the config file

This commit is contained in:
Adriaan de Groot 2018-04-16 05:16:23 -04:00
parent b1b59b27b2
commit 352b385b12
3 changed files with 20 additions and 6 deletions

View File

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

View File

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

View File

@ -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 <region>/<zone> format.
# in <region>/<zone> 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. "<Time_Zone>") in XML, set this
# string to the name or tag to be used.
#geoipSelector: ""