From d9effb4ba7bab54cd63b2518cbc3ef0a624cb2bc Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 3 Jun 2020 14:34:45 +0200 Subject: [PATCH] [libcalamares] Add GeoIPFixed to the test-tool for GeoIP lookup - Allow format "fixed" - Allow specifying the selector in the test-tool --- src/libcalamares/geoip/test_geoip.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/libcalamares/geoip/test_geoip.cpp b/src/libcalamares/geoip/test_geoip.cpp index 32c6f4e24..0587dda02 100644 --- a/src/libcalamares/geoip/test_geoip.cpp +++ b/src/libcalamares/geoip/test_geoip.cpp @@ -22,6 +22,7 @@ #include +#include "GeoIPFixed.h" #include "GeoIPJSON.h" #ifdef QT_XML_LIB #include "GeoIPXML.h" @@ -33,27 +34,34 @@ using namespace CalamaresUtils::GeoIP; int main( int argc, char** argv ) { - if ( argc != 2 ) + if ( ( argc != 2 ) && ( argc != 3 ) ) { - cerr << "Usage: curl url | test_geoip \n"; + cerr << "Usage: curl url | test_geoip [selector]\n"; return 1; } + QString format( argv[ 1 ] ); + QString selector = argc == 3 ? QString( argv[ 2 ] ) : QString(); + Interface* handler = nullptr; - if ( QStringLiteral( "json" ) == argv[ 1 ] ) + if ( QStringLiteral( "json" ) == format ) { - handler = new GeoIPJSON; + handler = new GeoIPJSON( selector ); } #ifdef QT_XML_LIB - else if ( QStringLiteral( "xml" ) == argv[ 1 ] ) + else if ( QStringLiteral( "xml" ) == format ) { - handler = new GeoIPXML; + handler = new GeoIPXML( selector ); } #endif + else if ( QStringLiteral( "fixed" ) == format ) + { + handler = new GeoIPFixed( selector ); + } if ( !handler ) { - cerr << "Unknown format '" << argv[ 1 ] << "'\n"; + cerr << "Unknown format '" << format.toLatin1().constData() << "'\n"; return 1; }