diff options
author | Jean Gressmann <jean.gressmann@nokia.com> | 2012-04-18 20:37:09 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-20 05:57:41 +0200 |
commit | 729fa78e7b16830fd3128786b994c66d8dbfe157 (patch) | |
tree | 03b58e0e279177d4d197ef65cfdf5ec7ba7959de /src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp | |
parent | 50897540e9eb7d285ede714ce4f8482cae4b104d (diff) | |
download | qtlocation-729fa78e7b16830fd3128786b994c66d8dbfe157.tar.gz |
QtLocation/Nokia plugin: Print usage terms fixup
Instead of only printing the usage terms when using the tile
mapping service the terms are now printed regardless of the
service used from Nokia's location plugin.
Note that the usage terms are only printed at most once per
plugin initialization.
Change-Id: I665ed97552c811e0f5e2b06a7ff1d522f823601a
Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp')
-rw-r--r-- | src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp index 9037bd5a..b23f313c 100644 --- a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp +++ b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp @@ -59,7 +59,9 @@ QT_BEGIN_NAMESPACE -QGeoServiceProviderFactoryNokia::QGeoServiceProviderFactoryNokia() {} +QGeoServiceProviderFactoryNokia::QGeoServiceProviderFactoryNokia() + : m_informedAboutUsageTerms(false) +{} QGeoServiceProviderFactoryNokia::~QGeoServiceProviderFactoryNokia() {} @@ -67,6 +69,8 @@ QGeocodingManagerEngine* QGeoServiceProviderFactoryNokia::createGeocodingManager QGeoServiceProvider::Error *error, QString *errorString) const { + informOnceAboutUsageTermsIfNecessary(parameters); + return new QGeocodingManagerEngineNokia(parameters, error, errorString); } @@ -74,6 +78,8 @@ QGeoMappingManagerEngine* QGeoServiceProviderFactoryNokia::createMappingManagerE QGeoServiceProvider::Error *error, QString *errorString) const { + informOnceAboutUsageTermsIfNecessary(parameters); + return new QGeoTiledMappingManagerEngineNokia(parameters, error, errorString); } @@ -81,6 +87,8 @@ QGeoRoutingManagerEngine* QGeoServiceProviderFactoryNokia::createRoutingManagerE QGeoServiceProvider::Error *error, QString *errorString) const { + informOnceAboutUsageTermsIfNecessary(parameters); + return new QGeoRoutingManagerEngineNokia(parameters, error, errorString); } @@ -88,6 +96,8 @@ QPlaceManagerEngine *QGeoServiceProviderFactoryNokia::createPlaceManagerEngine(c QGeoServiceProvider::Error *error, QString *errorString) const { + informOnceAboutUsageTermsIfNecessary(parameters); + switch (parameters.value(QLatin1String("places.api_version"), 2).toUInt()) { case 1: return new QPlaceManagerEngineNokiaV1(parameters, error, errorString); @@ -98,6 +108,42 @@ QPlaceManagerEngine *QGeoServiceProviderFactoryNokia::createPlaceManagerEngine(c return 0; } +void QGeoServiceProviderFactoryNokia::informOnceAboutUsageTermsIfNecessary( + const QMap<QString, QVariant> ¶meters) const +{ + if (m_informedAboutUsageTerms) + return; + + const QString appId = parameters.value(QLatin1String("app_id")).toString(); + const QString token = parameters.value(QLatin1String("token")).toString(); + + if (!isValidParameter(appId) || !isValidParameter(token)) { + m_informedAboutUsageTerms = true; + qWarning() << "****************************************************************************"; + qWarning() << "* Qt Location requires usage of app_id and token parameters obtained from: *"; + qWarning() << "* https://api.developer.nokia.com/ *"; + qWarning() << "****************************************************************************"; + } +} + +bool QGeoServiceProviderFactoryNokia::isValidParameter(const QString ¶m) +{ + if (param.isEmpty()) + return false; + + if (param.length() > 512) + return false; + + foreach (QChar c, param) { + if (!c.isLetterOrNumber() && c.toAscii() != '%' && c.toAscii() != '-' && + c.toAscii() != '+' && c.toAscii() != '_') { + return false; + } + } + + return true; +} + const QString QGeoServiceProviderFactoryNokia::defaultToken("152022572f0e44e07489c35cd46fa246"); const QString QGeoServiceProviderFactoryNokia::defaultReferer("qtlocationapi"); |