[libcalamares] Put GeoIP in namespace
- Use consistent include-guard style - Put things in namespace CalamaresUtils
This commit is contained in:
parent
ce909f00cc
commit
73a5e7dd62
@ -20,6 +20,9 @@
|
|||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
|
namespace CalamaresUtils
|
||||||
|
{
|
||||||
|
|
||||||
GeoIP::GeoIP(const QString& e)
|
GeoIP::GeoIP(const QString& e)
|
||||||
: m_element( e )
|
: m_element( e )
|
||||||
{
|
{
|
||||||
@ -47,3 +50,5 @@ GeoIP::splitTZString( const QString& tz )
|
|||||||
|
|
||||||
return qMakePair( QString(), QString() );
|
return qMakePair( QString(), QString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
*
|
*
|
||||||
* Copyright 2018, Adriaan de Groot <groot@kde.org>
|
* Copyright 2018-2019, Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -16,8 +16,8 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef GEOIP_H
|
#ifndef GEOIP_GEOIP_H
|
||||||
#define GEOIP_H
|
#define GEOIP_GEOIP_H
|
||||||
|
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
class QByteArray;
|
class QByteArray;
|
||||||
|
|
||||||
|
namespace CalamaresUtils
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* @brief Interface for GeoIP retrievers.
|
* @brief Interface for GeoIP retrievers.
|
||||||
*
|
*
|
||||||
@ -67,4 +69,5 @@ protected:
|
|||||||
QString m_element; // string for selecting from data
|
QString m_element; // string for selecting from data
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
#endif
|
#endif
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
|
||||||
|
namespace CalamaresUtils
|
||||||
|
{
|
||||||
|
|
||||||
GeoIPJSON::GeoIPJSON(const QString& attribute)
|
GeoIPJSON::GeoIPJSON(const QString& attribute)
|
||||||
: GeoIP( attribute.isEmpty() ? QStringLiteral( "time_zone" ) : attribute )
|
: GeoIP( attribute.isEmpty() ? QStringLiteral( "time_zone" ) : attribute )
|
||||||
{
|
{
|
||||||
@ -72,3 +75,5 @@ GeoIPJSON::processReply( const QByteArray& data )
|
|||||||
|
|
||||||
return qMakePair( QString(), QString() );
|
return qMakePair( QString(), QString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
*
|
*
|
||||||
* Copyright 2018, Adriaan de Groot <groot@kde.org>
|
* Copyright 2018-2019, Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -16,11 +16,13 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef GEOIPJSON_H
|
#ifndef GEOIP_GEOIPJSON_H
|
||||||
#define GEOIPJSON_H
|
#define GEOIP_GEOIPJSON_H
|
||||||
|
|
||||||
#include "GeoIP.h"
|
#include "GeoIP.h"
|
||||||
|
|
||||||
|
namespace CalamaresUtils
|
||||||
|
{
|
||||||
/** @brief GeoIP lookup for services that return JSON.
|
/** @brief GeoIP lookup for services that return JSON.
|
||||||
*
|
*
|
||||||
* This is the original implementation of GeoIP lookup,
|
* This is the original implementation of GeoIP lookup,
|
||||||
@ -41,4 +43,5 @@ public:
|
|||||||
virtual RegionZonePair processReply( const QByteArray& );
|
virtual RegionZonePair processReply( const QByteArray& );
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,6 +31,10 @@
|
|||||||
|
|
||||||
QTEST_GUILESS_MAIN( GeoIPTests )
|
QTEST_GUILESS_MAIN( GeoIPTests )
|
||||||
|
|
||||||
|
using CalamaresUtils::GeoIP;
|
||||||
|
using CalamaresUtils::GeoIPJSON;
|
||||||
|
using CalamaresUtils::GeoIPXML;
|
||||||
|
|
||||||
GeoIPTests::GeoIPTests()
|
GeoIPTests::GeoIPTests()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QtXml/QDomDocument>
|
#include <QtXml/QDomDocument>
|
||||||
|
|
||||||
|
namespace CalamaresUtils
|
||||||
|
{
|
||||||
|
|
||||||
GeoIPXML::GeoIPXML( const QString& element )
|
GeoIPXML::GeoIPXML( const QString& element )
|
||||||
: GeoIP( element.isEmpty() ? QStringLiteral( "TimeZone" ) : element )
|
: GeoIP( element.isEmpty() ? QStringLiteral( "TimeZone" ) : element )
|
||||||
{
|
{
|
||||||
@ -58,3 +61,5 @@ GeoIPXML::processReply( const QByteArray& data )
|
|||||||
|
|
||||||
return qMakePair( QString(), QString() );
|
return qMakePair( QString(), QString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
*
|
*
|
||||||
* Copyright 2018, Adriaan de Groot <groot@kde.org>
|
* Copyright 2018-2019, Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -16,11 +16,13 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef GEOIPXML_H
|
#ifndef GEOIP_GEOIPXML_H
|
||||||
#define GEOIPXML_H
|
#define GEOIP_GEOIPXML_H
|
||||||
|
|
||||||
#include "GeoIP.h"
|
#include "GeoIP.h"
|
||||||
|
|
||||||
|
namespace CalamaresUtils
|
||||||
|
{
|
||||||
/** @brief GeoIP lookup with XML data
|
/** @brief GeoIP lookup with XML data
|
||||||
*
|
*
|
||||||
* The data is assumed to be in XML format with a
|
* The data is assumed to be in XML format with a
|
||||||
@ -41,4 +43,5 @@ public:
|
|||||||
virtual RegionZonePair processReply( const QByteArray& );
|
virtual RegionZonePair processReply( const QByteArray& );
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,6 +28,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
|
using CalamaresUtils::GeoIP;
|
||||||
|
using CalamaresUtils::GeoIPJSON;
|
||||||
|
using CalamaresUtils::GeoIPXML;
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
@ -117,6 +117,12 @@ LocaleViewStep::setUpPage()
|
|||||||
void
|
void
|
||||||
LocaleViewStep::fetchGeoIpTimezone()
|
LocaleViewStep::fetchGeoIpTimezone()
|
||||||
{
|
{
|
||||||
|
using CalamaresUtils::GeoIP;
|
||||||
|
using CalamaresUtils::GeoIPJSON;
|
||||||
|
#if defined(QT_XML_LIB)
|
||||||
|
using CalamaresUtils::GeoIPXML;
|
||||||
|
#endif
|
||||||
|
|
||||||
QString actualUrl( m_geoipUrl );
|
QString actualUrl( m_geoipUrl );
|
||||||
GeoIP *handler = nullptr;
|
GeoIP *handler = nullptr;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user