From c0d5a153d4499fc283fcc56b2664e1ef84db2bac Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 12 Apr 2018 09:54:22 -0400 Subject: [PATCH] [locale] Refactor GeoIP handler - Move GeoIP to its own cpp file - Provide a default implementation of the URL mangler --- src/modules/locale/CMakeLists.txt | 1 + src/modules/locale/GeoIP.cpp | 29 +++++++++++++++++++++++++++ src/modules/locale/GeoIP.h | 6 ++++-- src/modules/locale/LocaleViewStep.cpp | 6 ------ 4 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 src/modules/locale/GeoIP.cpp diff --git a/src/modules/locale/CMakeLists.txt b/src/modules/locale/CMakeLists.txt index f35a9b4bd..774868a28 100644 --- a/src/modules/locale/CMakeLists.txt +++ b/src/modules/locale/CMakeLists.txt @@ -4,6 +4,7 @@ calamares_add_plugin( locale TYPE viewmodule EXPORT_MACRO PLUGINDLLEXPORT_PRO SOURCES + GeoIP.cpp GeoIPFreeGeoIP.cpp LCLocaleDialog.cpp LocaleConfiguration.cpp diff --git a/src/modules/locale/GeoIP.cpp b/src/modules/locale/GeoIP.cpp new file mode 100644 index 000000000..d20d398c7 --- /dev/null +++ b/src/modules/locale/GeoIP.cpp @@ -0,0 +1,29 @@ +/* === This file is part of Calamares - === + * + * Copyright 2018, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#include "GeoIP.h" + +GeoIP::~GeoIP() +{ +} + +QUrl +GeoIP::fullUrl(const QString& configUrl) +{ + return QUrl::fromUserInput( configUrl ); +} diff --git a/src/modules/locale/GeoIP.h b/src/modules/locale/GeoIP.h index e9e0fadfd..6d4992781 100644 --- a/src/modules/locale/GeoIP.h +++ b/src/modules/locale/GeoIP.h @@ -41,8 +41,10 @@ struct GeoIP * Some GeoIP providers are configured with one URL, but actually * do retrieval with another (e.g. when using the original * implementation of FreeGeoIP, or when adding an API key). + * + * The default implementation uses the @p configUrl unchanged. */ - virtual QUrl fullUrl( const QString& configUrl ) = 0; + virtual QUrl fullUrl( const QString& configUrl ); /** @brief Handle a (successful) request by interpreting the data. * @@ -55,7 +57,7 @@ struct GeoIP */ virtual RegionZonePair processReply( QNetworkReply* ) = 0; - virtual ~GeoIP(); // Defined in LocaleViewStep + virtual ~GeoIP(); } ; #endif diff --git a/src/modules/locale/LocaleViewStep.cpp b/src/modules/locale/LocaleViewStep.cpp index d9f5d1338..bd9bef2fe 100644 --- a/src/modules/locale/LocaleViewStep.cpp +++ b/src/modules/locale/LocaleViewStep.cpp @@ -270,9 +270,3 @@ LocaleViewStep::setConfigurationMap( const QVariantMap& configurationMap ) m_geoipUrl = configurationMap.value( "geoipUrl" ).toString(); } } - - -// Defined here since the struct has nothing else in it -GeoIP::~GeoIP() -{ -}