summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Gressmann <jean.gressmann@nokia.com>2012-04-18 20:37:09 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-20 05:57:41 +0200
commit729fa78e7b16830fd3128786b994c66d8dbfe157 (patch)
tree03b58e0e279177d4d197ef65cfdf5ec7ba7959de
parent50897540e9eb7d285ede714ce4f8482cae4b104d (diff)
downloadqtlocation-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>
-rw-r--r--src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp48
-rw-r--r--src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h7
-rw-r--r--src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp23
-rw-r--r--src/plugins/geoservices/nokia/qgeotilefetcher_nokia.h1
4 files changed, 54 insertions, 25 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> &parameters) 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 &param)
+{
+ 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");
diff --git a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h
index 52acea36..a0ce069d 100644
--- a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h
+++ b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h
@@ -80,6 +80,13 @@ public:
static const QString defaultToken;
static const QString defaultReferer;
+
+private:
+ void informOnceAboutUsageTermsIfNecessary(const QMap<QString, QVariant> &parameters) const;
+ static bool isValidParameter(const QString &param);
+
+private:
+ mutable bool m_informedAboutUsageTerms;
};
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
index 777548ea..5df43dce 100644
--- a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
@@ -128,11 +128,6 @@ bool QGeoTileFetcherNokia::init()
currentMobileCountryCodeChanged(0, m_networkInfo.currentMobileCountryCode(0));
#endif
- if (!isValidParameter(m_applicationId) || !isValidParameter(m_token)) {
- qWarning() << "Qt Location requires usage of app_id and token parameters obtained from:";
- qWarning() << "https://api.developer.nokia.com/";
- }
-
// Temporary testing aid for setting China maptile server
QFile file("/.enable_china_maptile_server");
if (file.exists()) {
@@ -300,24 +295,6 @@ void QGeoTileFetcherNokia::currentMobileCountryCodeChanged(int interface, const
}
#endif
-bool QGeoTileFetcherNokia::isValidParameter(const QString &param)
-{
- 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;
-}
-
void QGeoTileFetcherNokia::copyrightsFetched()
{
QMetaObject::invokeMethod(m_engineNokia,
diff --git a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.h b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.h
index e5a5ac08..34ba4176 100644
--- a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.h
+++ b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.h
@@ -109,7 +109,6 @@ private:
static QString mapIdToStr(int mapId);
void setHost(const QString& host);
- bool isValidParameter(const QString& param);
QGeoTiledMappingManagerEngineNokia *m_engineNokia;
QNetworkAccessManager *m_networkManager;