From 2cd4461b57fed9275badb351c52dffd2dcb7b34f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 16 Apr 2018 04:32:49 -0400 Subject: [PATCH] [locale] Rename JSON handler - The handler for JSON data should be called that, not named specially after the original provider it was implemented for. - Make filename and classname consistent, GeoIPJSON. --- src/modules/locale/CMakeLists.txt | 2 +- .../locale/{GeoIPFreeGeoIP.cpp => GeoIPJSON.cpp} | 4 ++-- src/modules/locale/{GeoIPFreeGeoIP.h => GeoIPJSON.h} | 11 +++++------ src/modules/locale/GeoIPTests.cpp | 6 +++--- src/modules/locale/LocaleViewStep.cpp | 6 +++--- src/modules/locale/test_geoip.cpp | 4 ++-- 6 files changed, 16 insertions(+), 17 deletions(-) rename src/modules/locale/{GeoIPFreeGeoIP.cpp => GeoIPJSON.cpp} (95%) rename src/modules/locale/{GeoIPFreeGeoIP.h => GeoIPJSON.h} (83%) diff --git a/src/modules/locale/CMakeLists.txt b/src/modules/locale/CMakeLists.txt index 3c0cc3712..384135d4c 100644 --- a/src/modules/locale/CMakeLists.txt +++ b/src/modules/locale/CMakeLists.txt @@ -6,7 +6,7 @@ endif() include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ) -set( geoip_src GeoIP.cpp GeoIPFreeGeoIP.cpp ) +set( geoip_src GeoIP.cpp GeoIPJSON.cpp ) set( geoip_libs ) find_package(Qt5 COMPONENTS Xml) diff --git a/src/modules/locale/GeoIPFreeGeoIP.cpp b/src/modules/locale/GeoIPJSON.cpp similarity index 95% rename from src/modules/locale/GeoIPFreeGeoIP.cpp rename to src/modules/locale/GeoIPJSON.cpp index 9ef534a5d..78f6c67a7 100644 --- a/src/modules/locale/GeoIPFreeGeoIP.cpp +++ b/src/modules/locale/GeoIPJSON.cpp @@ -17,7 +17,7 @@ * along with Calamares. If not, see . */ -#include "GeoIPFreeGeoIP.h" +#include "GeoIPJSON.h" #include "utils/Logger.h" #include "utils/YamlUtils.h" @@ -27,7 +27,7 @@ #include GeoIP::RegionZonePair -FreeGeoIP::processReply( const QByteArray& data ) +GeoIPJSON::processReply( const QByteArray& data ) { try { diff --git a/src/modules/locale/GeoIPFreeGeoIP.h b/src/modules/locale/GeoIPJSON.h similarity index 83% rename from src/modules/locale/GeoIPFreeGeoIP.h rename to src/modules/locale/GeoIPJSON.h index e8986db3f..26a0560f6 100644 --- a/src/modules/locale/GeoIPFreeGeoIP.h +++ b/src/modules/locale/GeoIPJSON.h @@ -16,20 +16,19 @@ * along with Calamares. If not, see . */ -#ifndef GEOIPFREEGEOIP_H -#define GEOIPFREEGEOIP_H +#ifndef GEOIPJSON_H +#define GEOIPJSON_H #include "GeoIP.h" -/** @brief GeoIP lookup via freegeoip.com +/** @brief GeoIP lookup for services that return JSON. * * This is the original implementation of GeoIP lookup, - * using the FreeGeoIP service, or similar which returns - * data in the same format. + * (e.g. using the FreeGeoIP.net service), or similar. * * The data is assumed to be in JSON format with a time_zone attribute. */ -struct FreeGeoIP : public GeoIP +struct GeoIPJSON : public GeoIP { virtual RegionZonePair processReply( const QByteArray& ); } ; diff --git a/src/modules/locale/GeoIPTests.cpp b/src/modules/locale/GeoIPTests.cpp index 2c59aa729..4f946b8b7 100644 --- a/src/modules/locale/GeoIPTests.cpp +++ b/src/modules/locale/GeoIPTests.cpp @@ -18,7 +18,7 @@ #include "GeoIPTests.h" -#include "GeoIPFreeGeoIP.h" +#include "GeoIPJSON.h" #ifdef HAVE_XML #include "GeoIPXML.h" #endif @@ -46,7 +46,7 @@ GeoIPTests::testJSON() static const char data[] = "{\"time_zone\":\"Europe/Amsterdam\"}"; - FreeGeoIP handler; + GeoIPJSON handler; auto tz = handler.processReply( data ); QCOMPARE( tz.first, QLatin1String( "Europe" ) ); @@ -65,7 +65,7 @@ GeoIPTests::testJSONbad() { static const char data[] = "time_zone: 1"; - FreeGeoIP handler; + GeoIPJSON handler; auto tz = handler.processReply( data ); tz = handler.processReply( data ); diff --git a/src/modules/locale/LocaleViewStep.cpp b/src/modules/locale/LocaleViewStep.cpp index 7cafd8793..243ad436c 100644 --- a/src/modules/locale/LocaleViewStep.cpp +++ b/src/modules/locale/LocaleViewStep.cpp @@ -20,7 +20,7 @@ #include "LocaleViewStep.h" #include "GeoIP.h" -#include "GeoIPFreeGeoIP.h" +#include "GeoIPJSON.h" #ifdef HAVE_XML #include "GeoIPXML.h" #endif @@ -124,11 +124,11 @@ LocaleViewStep::fetchGeoIpTimezone() if ( m_geoipStyle.isEmpty() || m_geoipStyle == "legacy" ) { actualUrl.append( "/json/" ); - handler = new FreeGeoIP; + handler = new GeoIPJSON; } else if ( m_geoipStyle == "json" ) { - handler = new FreeGeoIP; + handler = new GeoIPJSON; } #if defined(HAVE_XML) else if ( m_geoipStyle == "xml" ) diff --git a/src/modules/locale/test_geoip.cpp b/src/modules/locale/test_geoip.cpp index 5797ad9ff..70c205b40 100644 --- a/src/modules/locale/test_geoip.cpp +++ b/src/modules/locale/test_geoip.cpp @@ -22,7 +22,7 @@ #include -#include "GeoIPFreeGeoIP.h" +#include "GeoIPJSON.h" #ifdef HAVE_XML #include "GeoIPXML.h" #endif @@ -39,7 +39,7 @@ int main(int argc, char** argv) GeoIP* handler = nullptr; if ( QLatin1String( "json" ) == argv[1] ) - handler = new FreeGeoIP; + handler = new GeoIPJSON; #ifdef HAVE_XML else if ( QLatin1String( "xml" ) == argv[1] ) handler = new XMLGeoIP;