[locale] Refactor geoip handling
- Configuration **must** be a complete URL. The implementation no longer appends /json to the URL.
This commit is contained in:
parent
c0d5a153d4
commit
d5623af8ef
@ -21,9 +21,3 @@
|
||||
GeoIP::~GeoIP()
|
||||
{
|
||||
}
|
||||
|
||||
QUrl
|
||||
GeoIP::fullUrl(const QString& configUrl)
|
||||
{
|
||||
return QUrl::fromUserInput( configUrl );
|
||||
}
|
||||
|
@ -36,16 +36,6 @@ struct GeoIP
|
||||
{
|
||||
using RegionZonePair = QPair<QString, QString>;
|
||||
|
||||
/** @brief Convert configured URL to a complete URL.
|
||||
*
|
||||
* 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 );
|
||||
|
||||
/** @brief Handle a (successful) request by interpreting the data.
|
||||
*
|
||||
* Should return a ( <zone>, <region> ) pair, e.g.
|
||||
|
@ -26,15 +26,6 @@
|
||||
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
QUrl
|
||||
FreeGeoIP::fullUrl( const QString& configUrl )
|
||||
{
|
||||
// FIXME: derpy way to append "/json" to the user-specified config URL
|
||||
QString requestUrl = QString( "%1/json" )
|
||||
.arg( QUrl::fromUserInput( configUrl ).toString() );
|
||||
return QUrl( requestUrl );
|
||||
}
|
||||
|
||||
GeoIP::RegionZonePair
|
||||
FreeGeoIP::processReply( QNetworkReply* reply )
|
||||
{
|
||||
|
@ -21,9 +21,16 @@
|
||||
|
||||
#include "GeoIP.h"
|
||||
|
||||
/** @brief GeoIP lookup via freegeoip.com
|
||||
*
|
||||
* This is the original implementation of GeoIP lookup,
|
||||
* using the FreeGeoIP service, or similar which returns
|
||||
* data in the same format.
|
||||
*
|
||||
* The data is assumed to be in JSON format with a time_zone attribute.
|
||||
*/
|
||||
struct FreeGeoIP : public GeoIP
|
||||
{
|
||||
virtual QUrl fullUrl( const QString& configUrl );
|
||||
virtual RegionZonePair processReply( QNetworkReply* );
|
||||
} ;
|
||||
|
||||
|
@ -133,7 +133,7 @@ LocaleViewStep::fetchGeoIpTimezone()
|
||||
} );
|
||||
|
||||
QNetworkRequest request;
|
||||
request.setUrl( handler->fullUrl( m_geoipUrl ) );
|
||||
request.setUrl( QUrl::fromUserInput( m_geoipUrl ) );
|
||||
request.setAttribute( QNetworkRequest::FollowRedirectsAttribute, true );
|
||||
manager->get( request );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user