[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.
main
Adriaan de Groot 7 years ago
parent ec113e3df3
commit 2cd4461b57

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

@ -17,7 +17,7 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GeoIPFreeGeoIP.h"
#include "GeoIPJSON.h"
#include "utils/Logger.h"
#include "utils/YamlUtils.h"
@ -27,7 +27,7 @@
#include <yaml-cpp/yaml.h>
GeoIP::RegionZonePair
FreeGeoIP::processReply( const QByteArray& data )
GeoIPJSON::processReply( const QByteArray& data )
{
try
{

@ -16,20 +16,19 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#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& );
} ;

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

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

@ -22,7 +22,7 @@
#include <iostream>
#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;

Loading…
Cancel
Save