[libcalamares] Allow "fixed" as a GeoIP lookup type
This commit is contained in:
parent
672f506e72
commit
ac2a9c569e
@ -23,6 +23,7 @@ set( libSources
|
|||||||
|
|
||||||
# GeoIP services
|
# GeoIP services
|
||||||
geoip/Interface.cpp
|
geoip/Interface.cpp
|
||||||
|
geoip/GeoIPFixed.cpp
|
||||||
geoip/GeoIPJSON.cpp
|
geoip/GeoIPJSON.cpp
|
||||||
geoip/Handler.cpp
|
geoip/Handler.cpp
|
||||||
|
|
||||||
|
@ -18,11 +18,13 @@
|
|||||||
|
|
||||||
#include "Handler.h"
|
#include "Handler.h"
|
||||||
|
|
||||||
|
#include "GeoIPFixed.h"
|
||||||
#include "GeoIPJSON.h"
|
#include "GeoIPJSON.h"
|
||||||
#if defined( QT_XML_LIB )
|
#if defined( QT_XML_LIB )
|
||||||
#include "GeoIPXML.h"
|
#include "GeoIPXML.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "Settings.h"
|
||||||
#include "network/Manager.h"
|
#include "network/Manager.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/NamedEnum.h"
|
#include "utils/NamedEnum.h"
|
||||||
@ -40,7 +42,8 @@ handlerTypes()
|
|||||||
static const NamedEnumTable<Type> names{
|
static const NamedEnumTable<Type> names{
|
||||||
{ QStringLiteral( "none" ), Type::None },
|
{ QStringLiteral( "none" ), Type::None },
|
||||||
{ QStringLiteral( "json" ), Type::JSON },
|
{ QStringLiteral( "json" ), Type::JSON },
|
||||||
{ QStringLiteral( "xml" ), Type::XML }
|
{ QStringLiteral( "xml" ), Type::XML },
|
||||||
|
{ QStringLiteral( "fixed" ), Type::Fixed }
|
||||||
};
|
};
|
||||||
// *INDENT-ON*
|
// *INDENT-ON*
|
||||||
// clang-format on
|
// clang-format on
|
||||||
@ -73,6 +76,10 @@ Handler::Handler( const QString& implementation, const QString& url, const QStri
|
|||||||
{
|
{
|
||||||
cWarning() << "GeoIP style *none* does not do anything.";
|
cWarning() << "GeoIP style *none* does not do anything.";
|
||||||
}
|
}
|
||||||
|
else if ( m_type == Type::Fixed && Calamares::Settings::instance() && !Calamares::Settings::instance()->debugMode() )
|
||||||
|
{
|
||||||
|
cWarning() << "GeoIP style *fixed* is not recommended for production.";
|
||||||
|
}
|
||||||
#if !defined( QT_XML_LIB )
|
#if !defined( QT_XML_LIB )
|
||||||
else if ( m_type == Type::XML )
|
else if ( m_type == Type::XML )
|
||||||
{
|
{
|
||||||
@ -99,6 +106,8 @@ create_interface( Handler::Type t, const QString& selector )
|
|||||||
#else
|
#else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
case Handler::Type::Fixed:
|
||||||
|
return std::make_unique< GeoIPFixed >( selector );
|
||||||
}
|
}
|
||||||
NOTREACHED return nullptr;
|
NOTREACHED return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -43,9 +43,10 @@ class DLLEXPORT Handler
|
|||||||
public:
|
public:
|
||||||
enum class Type
|
enum class Type
|
||||||
{
|
{
|
||||||
None,
|
None, // No lookup, returns empty string
|
||||||
JSON,
|
JSON, // JSON-formatted data, returns extracted field
|
||||||
XML
|
XML, // XML-formatted data, returns extracted field
|
||||||
|
Fixed // Returns selector string verbatim
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @brief An unconfigured handler; this always returns errors. */
|
/** @brief An unconfigured handler; this always returns errors. */
|
||||||
|
@ -98,7 +98,7 @@ public:
|
|||||||
virtual QString rawReply( const QByteArray& ) = 0;
|
virtual QString rawReply( const QByteArray& ) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Interface( const QString& e = QString() );
|
Interface( const QString& element = QString() );
|
||||||
|
|
||||||
QString m_element; // string for selecting from data
|
QString m_element; // string for selecting from data
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user