[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.
This commit is contained in:
parent
ec113e3df3
commit
2cd4461b57
@ -6,7 +6,7 @@ endif()
|
|||||||
|
|
||||||
include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui )
|
include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui )
|
||||||
|
|
||||||
set( geoip_src GeoIP.cpp GeoIPFreeGeoIP.cpp )
|
set( geoip_src GeoIP.cpp GeoIPJSON.cpp )
|
||||||
set( geoip_libs )
|
set( geoip_libs )
|
||||||
|
|
||||||
find_package(Qt5 COMPONENTS Xml)
|
find_package(Qt5 COMPONENTS Xml)
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "GeoIPFreeGeoIP.h"
|
#include "GeoIPJSON.h"
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/YamlUtils.h"
|
#include "utils/YamlUtils.h"
|
||||||
@ -27,7 +27,7 @@
|
|||||||
#include <yaml-cpp/yaml.h>
|
#include <yaml-cpp/yaml.h>
|
||||||
|
|
||||||
GeoIP::RegionZonePair
|
GeoIP::RegionZonePair
|
||||||
FreeGeoIP::processReply( const QByteArray& data )
|
GeoIPJSON::processReply( const QByteArray& data )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
@ -16,20 +16,19 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef GEOIPFREEGEOIP_H
|
#ifndef GEOIPJSON_H
|
||||||
#define GEOIPFREEGEOIP_H
|
#define GEOIPJSON_H
|
||||||
|
|
||||||
#include "GeoIP.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,
|
* This is the original implementation of GeoIP lookup,
|
||||||
* using the FreeGeoIP service, or similar which returns
|
* (e.g. using the FreeGeoIP.net service), or similar.
|
||||||
* data in the same format.
|
|
||||||
*
|
*
|
||||||
* The data is assumed to be in JSON format with a time_zone attribute.
|
* 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& );
|
virtual RegionZonePair processReply( const QByteArray& );
|
||||||
} ;
|
} ;
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include "GeoIPTests.h"
|
#include "GeoIPTests.h"
|
||||||
|
|
||||||
#include "GeoIPFreeGeoIP.h"
|
#include "GeoIPJSON.h"
|
||||||
#ifdef HAVE_XML
|
#ifdef HAVE_XML
|
||||||
#include "GeoIPXML.h"
|
#include "GeoIPXML.h"
|
||||||
#endif
|
#endif
|
||||||
@ -46,7 +46,7 @@ GeoIPTests::testJSON()
|
|||||||
static const char data[] =
|
static const char data[] =
|
||||||
"{\"time_zone\":\"Europe/Amsterdam\"}";
|
"{\"time_zone\":\"Europe/Amsterdam\"}";
|
||||||
|
|
||||||
FreeGeoIP handler;
|
GeoIPJSON handler;
|
||||||
auto tz = handler.processReply( data );
|
auto tz = handler.processReply( data );
|
||||||
|
|
||||||
QCOMPARE( tz.first, QLatin1String( "Europe" ) );
|
QCOMPARE( tz.first, QLatin1String( "Europe" ) );
|
||||||
@ -65,7 +65,7 @@ GeoIPTests::testJSONbad()
|
|||||||
{
|
{
|
||||||
static const char data[] = "time_zone: 1";
|
static const char data[] = "time_zone: 1";
|
||||||
|
|
||||||
FreeGeoIP handler;
|
GeoIPJSON handler;
|
||||||
auto tz = handler.processReply( data );
|
auto tz = handler.processReply( data );
|
||||||
|
|
||||||
tz = handler.processReply( data );
|
tz = handler.processReply( data );
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "LocaleViewStep.h"
|
#include "LocaleViewStep.h"
|
||||||
|
|
||||||
#include "GeoIP.h"
|
#include "GeoIP.h"
|
||||||
#include "GeoIPFreeGeoIP.h"
|
#include "GeoIPJSON.h"
|
||||||
#ifdef HAVE_XML
|
#ifdef HAVE_XML
|
||||||
#include "GeoIPXML.h"
|
#include "GeoIPXML.h"
|
||||||
#endif
|
#endif
|
||||||
@ -124,11 +124,11 @@ LocaleViewStep::fetchGeoIpTimezone()
|
|||||||
if ( m_geoipStyle.isEmpty() || m_geoipStyle == "legacy" )
|
if ( m_geoipStyle.isEmpty() || m_geoipStyle == "legacy" )
|
||||||
{
|
{
|
||||||
actualUrl.append( "/json/" );
|
actualUrl.append( "/json/" );
|
||||||
handler = new FreeGeoIP;
|
handler = new GeoIPJSON;
|
||||||
}
|
}
|
||||||
else if ( m_geoipStyle == "json" )
|
else if ( m_geoipStyle == "json" )
|
||||||
{
|
{
|
||||||
handler = new FreeGeoIP;
|
handler = new GeoIPJSON;
|
||||||
}
|
}
|
||||||
#if defined(HAVE_XML)
|
#if defined(HAVE_XML)
|
||||||
else if ( m_geoipStyle == "xml" )
|
else if ( m_geoipStyle == "xml" )
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "GeoIPFreeGeoIP.h"
|
#include "GeoIPJSON.h"
|
||||||
#ifdef HAVE_XML
|
#ifdef HAVE_XML
|
||||||
#include "GeoIPXML.h"
|
#include "GeoIPXML.h"
|
||||||
#endif
|
#endif
|
||||||
@ -39,7 +39,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
GeoIP* handler = nullptr;
|
GeoIP* handler = nullptr;
|
||||||
if ( QLatin1String( "json" ) == argv[1] )
|
if ( QLatin1String( "json" ) == argv[1] )
|
||||||
handler = new FreeGeoIP;
|
handler = new GeoIPJSON;
|
||||||
#ifdef HAVE_XML
|
#ifdef HAVE_XML
|
||||||
else if ( QLatin1String( "xml" ) == argv[1] )
|
else if ( QLatin1String( "xml" ) == argv[1] )
|
||||||
handler = new XMLGeoIP;
|
handler = new XMLGeoIP;
|
||||||
|
Loading…
Reference in New Issue
Block a user