diff --git a/src/libcalamares/geoip/GeoIP.cpp b/src/libcalamares/geoip/GeoIP.cpp index 4c031f286..4f2f4ce62 100644 --- a/src/libcalamares/geoip/GeoIP.cpp +++ b/src/libcalamares/geoip/GeoIP.cpp @@ -20,6 +20,9 @@ #include "utils/Logger.h" +namespace CalamaresUtils +{ + GeoIP::GeoIP(const QString& e) : m_element( e ) { @@ -47,3 +50,5 @@ GeoIP::splitTZString( const QString& tz ) return qMakePair( QString(), QString() ); } + +} // namespace diff --git a/src/libcalamares/geoip/GeoIP.h b/src/libcalamares/geoip/GeoIP.h index 41abd2042..bb1f6a8aa 100644 --- a/src/libcalamares/geoip/GeoIP.h +++ b/src/libcalamares/geoip/GeoIP.h @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2018, Adriaan de Groot + * Copyright 2018-2019, 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 @@ -16,8 +16,8 @@ * along with Calamares. If not, see . */ -#ifndef GEOIP_H -#define GEOIP_H +#ifndef GEOIP_GEOIP_H +#define GEOIP_GEOIP_H #include #include @@ -25,6 +25,8 @@ class QByteArray; +namespace CalamaresUtils +{ /** * @brief Interface for GeoIP retrievers. * @@ -67,4 +69,5 @@ protected: QString m_element; // string for selecting from data } ; +} // namespace #endif diff --git a/src/libcalamares/geoip/GeoIPJSON.cpp b/src/libcalamares/geoip/GeoIPJSON.cpp index 8e5cc2e5c..0f33ca37f 100644 --- a/src/libcalamares/geoip/GeoIPJSON.cpp +++ b/src/libcalamares/geoip/GeoIPJSON.cpp @@ -25,6 +25,9 @@ #include +namespace CalamaresUtils +{ + GeoIPJSON::GeoIPJSON(const QString& attribute) : GeoIP( attribute.isEmpty() ? QStringLiteral( "time_zone" ) : attribute ) { @@ -72,3 +75,5 @@ GeoIPJSON::processReply( const QByteArray& data ) return qMakePair( QString(), QString() ); } + +} // namespace diff --git a/src/libcalamares/geoip/GeoIPJSON.h b/src/libcalamares/geoip/GeoIPJSON.h index 3c08f577b..10a38c48d 100644 --- a/src/libcalamares/geoip/GeoIPJSON.h +++ b/src/libcalamares/geoip/GeoIPJSON.h @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2018, Adriaan de Groot + * Copyright 2018-2019, 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 @@ -16,11 +16,13 @@ * along with Calamares. If not, see . */ -#ifndef GEOIPJSON_H -#define GEOIPJSON_H +#ifndef GEOIP_GEOIPJSON_H +#define GEOIP_GEOIPJSON_H #include "GeoIP.h" +namespace CalamaresUtils +{ /** @brief GeoIP lookup for services that return JSON. * * This is the original implementation of GeoIP lookup, @@ -41,4 +43,5 @@ public: virtual RegionZonePair processReply( const QByteArray& ); } ; +} // namespace #endif diff --git a/src/libcalamares/geoip/GeoIPTests.cpp b/src/libcalamares/geoip/GeoIPTests.cpp index 9a8070148..c84eb4713 100644 --- a/src/libcalamares/geoip/GeoIPTests.cpp +++ b/src/libcalamares/geoip/GeoIPTests.cpp @@ -31,6 +31,10 @@ QTEST_GUILESS_MAIN( GeoIPTests ) +using CalamaresUtils::GeoIP; +using CalamaresUtils::GeoIPJSON; +using CalamaresUtils::GeoIPXML; + GeoIPTests::GeoIPTests() { } diff --git a/src/libcalamares/geoip/GeoIPXML.cpp b/src/libcalamares/geoip/GeoIPXML.cpp index bd675c2ef..e32ff42a4 100644 --- a/src/libcalamares/geoip/GeoIPXML.cpp +++ b/src/libcalamares/geoip/GeoIPXML.cpp @@ -23,6 +23,9 @@ #include #include +namespace CalamaresUtils +{ + GeoIPXML::GeoIPXML( const QString& element ) : GeoIP( element.isEmpty() ? QStringLiteral( "TimeZone" ) : element ) { @@ -58,3 +61,5 @@ GeoIPXML::processReply( const QByteArray& data ) return qMakePair( QString(), QString() ); } + +} // namespace diff --git a/src/libcalamares/geoip/GeoIPXML.h b/src/libcalamares/geoip/GeoIPXML.h index bc3f23bec..15c4e1260 100644 --- a/src/libcalamares/geoip/GeoIPXML.h +++ b/src/libcalamares/geoip/GeoIPXML.h @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2018, Adriaan de Groot + * Copyright 2018-2019, 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 @@ -16,11 +16,13 @@ * along with Calamares. If not, see . */ -#ifndef GEOIPXML_H -#define GEOIPXML_H +#ifndef GEOIP_GEOIPXML_H +#define GEOIP_GEOIPXML_H #include "GeoIP.h" +namespace CalamaresUtils +{ /** @brief GeoIP lookup with XML data * * The data is assumed to be in XML format with a @@ -41,4 +43,5 @@ public: virtual RegionZonePair processReply( const QByteArray& ); } ; +} // namespace #endif diff --git a/src/libcalamares/geoip/test_geoip.cpp b/src/libcalamares/geoip/test_geoip.cpp index 8b8c2b0dc..b5e0234df 100644 --- a/src/libcalamares/geoip/test_geoip.cpp +++ b/src/libcalamares/geoip/test_geoip.cpp @@ -28,6 +28,9 @@ #endif using std::cerr; +using CalamaresUtils::GeoIP; +using CalamaresUtils::GeoIPJSON; +using CalamaresUtils::GeoIPXML; int main(int argc, char** argv) { diff --git a/src/modules/locale/LocaleViewStep.cpp b/src/modules/locale/LocaleViewStep.cpp index eb3d49960..a3ff5df91 100644 --- a/src/modules/locale/LocaleViewStep.cpp +++ b/src/modules/locale/LocaleViewStep.cpp @@ -117,6 +117,12 @@ LocaleViewStep::setUpPage() void LocaleViewStep::fetchGeoIpTimezone() { + using CalamaresUtils::GeoIP; + using CalamaresUtils::GeoIPJSON; +#if defined(QT_XML_LIB) + using CalamaresUtils::GeoIPXML; +#endif + QString actualUrl( m_geoipUrl ); GeoIP *handler = nullptr;