mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 19:05:46 -05:00
[libcalamares] Allow "fixed" as a GeoIP lookup type
This commit is contained in:
parent
672f506e72
commit
ac2a9c569e
4 changed files with 16 additions and 5 deletions
|
@ -23,6 +23,7 @@ set( libSources
|
|||
|
||||
# GeoIP services
|
||||
geoip/Interface.cpp
|
||||
geoip/GeoIPFixed.cpp
|
||||
geoip/GeoIPJSON.cpp
|
||||
geoip/Handler.cpp
|
||||
|
||||
|
|
|
@ -18,11 +18,13 @@
|
|||
|
||||
#include "Handler.h"
|
||||
|
||||
#include "GeoIPFixed.h"
|
||||
#include "GeoIPJSON.h"
|
||||
#if defined( QT_XML_LIB )
|
||||
#include "GeoIPXML.h"
|
||||
#endif
|
||||
|
||||
#include "Settings.h"
|
||||
#include "network/Manager.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/NamedEnum.h"
|
||||
|
@ -40,7 +42,8 @@ handlerTypes()
|
|||
static const NamedEnumTable<Type> names{
|
||||
{ QStringLiteral( "none" ), Type::None },
|
||||
{ QStringLiteral( "json" ), Type::JSON },
|
||||
{ QStringLiteral( "xml" ), Type::XML }
|
||||
{ QStringLiteral( "xml" ), Type::XML },
|
||||
{ QStringLiteral( "fixed" ), Type::Fixed }
|
||||
};
|
||||
// *INDENT-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.";
|
||||
}
|
||||
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 )
|
||||
else if ( m_type == Type::XML )
|
||||
{
|
||||
|
@ -99,6 +106,8 @@ create_interface( Handler::Type t, const QString& selector )
|
|||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
case Handler::Type::Fixed:
|
||||
return std::make_unique< GeoIPFixed >( selector );
|
||||
}
|
||||
NOTREACHED return nullptr;
|
||||
}
|
||||
|
|
|
@ -43,9 +43,10 @@ class DLLEXPORT Handler
|
|||
public:
|
||||
enum class Type
|
||||
{
|
||||
None,
|
||||
JSON,
|
||||
XML
|
||||
None, // No lookup, returns empty string
|
||||
JSON, // JSON-formatted data, returns extracted field
|
||||
XML, // XML-formatted data, returns extracted field
|
||||
Fixed // Returns selector string verbatim
|
||||
};
|
||||
|
||||
/** @brief An unconfigured handler; this always returns errors. */
|
||||
|
|
|
@ -98,7 +98,7 @@ public:
|
|||
virtual QString rawReply( const QByteArray& ) = 0;
|
||||
|
||||
protected:
|
||||
Interface( const QString& e = QString() );
|
||||
Interface( const QString& element = QString() );
|
||||
|
||||
QString m_element; // string for selecting from data
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue