diff options
author | Vladimir Bezkorovainyi <vladimir.bezkorovainyi@nokia.com> | 2012-05-30 18:13:28 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-31 17:57:34 +0200 |
commit | 1c356029e308283c4c305dda855a094cf16e19ef (patch) | |
tree | 028cc1e9aef5f0dcb0a2966b065b854428df44b1 /src/plugins/geoservices | |
parent | f72688998639d168444eec32f0b5ec04320369bb (diff) | |
download | qtlocation-1c356029e308283c4c305dda855a094cf16e19ef.tar.gz |
Move hard-codded messages into separate file and declare constants for them.
Change-Id: I35a2a5ca9d4c4dc20e291051666bb88f4264ab33
Reviewed-by: Jean Gressmann <jean.gressmann@nokia.com>
Diffstat (limited to 'src/plugins/geoservices')
10 files changed, 163 insertions, 17 deletions
diff --git a/src/plugins/geoservices/nokia/nokia.pro b/src/plugins/geoservices/nokia/nokia.pro index 892d3392..d5bfe5da 100644 --- a/src/plugins/geoservices/nokia/nokia.pro +++ b/src/plugins/geoservices/nokia/nokia.pro @@ -30,7 +30,8 @@ HEADERS += \ qgeonetworkaccessmanager.h \ qgeointrinsicnetworkaccessmanager.h \ qgeouriprovider.h \ - uri_constants.h + uri_constants.h \ + qgeoerror_messages.h SOURCES += \ @@ -47,7 +48,8 @@ SOURCES += \ qgeoserviceproviderplugin_nokia.cpp \ qgeointrinsicnetworkaccessmanager.cpp \ qgeouriprovider.cpp \ - uri_constants.cpp + uri_constants.cpp \ + qgeoerror_messages.cpp include(placesv1/placesv1.pri) include(placesv2/placesv2.pri) diff --git a/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp index 2266ae56..1617d438 100644 --- a/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp +++ b/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp @@ -49,7 +49,9 @@ #include "jsonparserhelpers.h" #include "qplacecontentreplyimpl.h" #include "../qplacemanagerengine_nokiav2.h" +#include "../qgeoerror_messages.h" +#include <QCoreApplication> #include <QtCore/QJsonDocument> #include <QtCore/QJsonObject> @@ -94,7 +96,7 @@ void QPlaceContentReplyImpl::replyFinished() { QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll()); if (!document.isObject()) { - setError(ParseError, tr("Error parsing response.")); + setError(ParseError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, PARSE_ERROR)); return; } diff --git a/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp index 0f76b891..3fe94aee 100644 --- a/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp +++ b/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp @@ -49,7 +49,9 @@ #include "qplacedetailsreplyimpl.h" #include "jsonparserhelpers.h" #include "../qplacemanagerengine_nokiav2.h" +#include "../qgeoerror_messages.h" +#include <QCoreApplication> #include <QtCore/QJsonDocument> #include <QtCore/QJsonObject> #include <QtCore/QJsonArray> @@ -133,7 +135,7 @@ void QPlaceDetailsReplyImpl::replyFinished() { QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll()); if (!document.isObject()) { - setError(ParseError, tr("Error parsing response.")); + setError(ParseError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, PARSE_ERROR)); return; } diff --git a/src/plugins/geoservices/nokia/placesv2/qplacerecommendationreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacerecommendationreplyimpl.cpp index 3f24f937..cfbb6da9 100644 --- a/src/plugins/geoservices/nokia/placesv2/qplacerecommendationreplyimpl.cpp +++ b/src/plugins/geoservices/nokia/placesv2/qplacerecommendationreplyimpl.cpp @@ -49,7 +49,9 @@ #include "qplacerecommendationreplyimpl.h" #include "jsonparserhelpers.h" #include "../qplacemanagerengine_nokiav2.h" +#include "../qgeoerror_messages.h" +#include <QCoreApplication> #include <QtCore/QJsonDocument> #include <QtCore/QJsonObject> #include <QtCore/QJsonArray> @@ -94,7 +96,7 @@ void QPlaceRecommendationReplyImpl::replyFinished() { QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll()); if (!document.isObject()) { - setError(ParseError, tr("Error parsing response.")); + setError(ParseError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, PARSE_ERROR)); emit error(error(), errorString()); return; } diff --git a/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.cpp index 3c29cdc1..b4d6c2e5 100644 --- a/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.cpp +++ b/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.cpp @@ -49,7 +49,9 @@ #include "qplacesearchreplyimpl.h" #include "jsonparserhelpers.h" #include "../qplacemanagerengine_nokiav2.h" +#include "../qgeoerror_messages.h" +#include <QCoreApplication> #include <QtCore/QJsonDocument> #include <QtCore/QJsonObject> #include <QtCore/QJsonArray> @@ -95,7 +97,7 @@ void QPlaceSearchReplyImpl::replyFinished() { QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll()); if (!document.isObject()) { - setError(ParseError, tr("Error parsing response.")); + setError(ParseError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, PARSE_ERROR)); emit error(error(), errorString()); return; } diff --git a/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp index ce4cd3b2..37820e3a 100644 --- a/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp +++ b/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp @@ -47,7 +47,9 @@ ****************************************************************************/ #include "qplacesearchsuggestionreplyimpl.h" +#include "../qgeoerror_messages.h" +#include <QCoreApplication> #include <QtCore/QJsonDocument> #include <QtCore/QJsonObject> #include <QtCore/QJsonArray> @@ -90,7 +92,7 @@ void QPlaceSearchSuggestionReplyImpl::replyFinished() { QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll()); if (!document.isObject()) { - setError(ParseError, tr("Error parsing response.")); + setError(ParseError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, PARSE_ERROR)); emit error(error(), errorString()); return; } diff --git a/src/plugins/geoservices/nokia/qgeoerror_messages.cpp b/src/plugins/geoservices/nokia/qgeoerror_messages.cpp new file mode 100644 index 00000000..2bb1e1b8 --- /dev/null +++ b/src/plugins/geoservices/nokia/qgeoerror_messages.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +** This file is part of the Ovi services plugin for the Maps and +** Navigation API. The use of these services, whether by use of the +** plugin or by other means, is governed by the terms and conditions +** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in +** this package, located in the directory containing the Ovi services +** plugin source code. +** +****************************************************************************/ + +#include "qgeoerror_messages.h" + +QT_BEGIN_NAMESPACE + +const char NOKIA_PLUGIN_CONTEXT_NAME[] = "QtLocationQML"; +const char MISSED_CREDENTIALS[] = QT_TRANSLATE_NOOP("QtLocationQML", "Qt Location requires app_id and token parameters.\nPlease register at https://api.developer.nokia.com/ to get your personal application credentials."); +const char SAVING_PLACE_NOT_SUPPORTED[] = QT_TRANSLATE_NOOP("QtLocationQML", "Saving places is not supported."); +const char REMOVING_PLACE_NOT_SUPPORTED[] = QT_TRANSLATE_NOOP("QtLocationQML", "Removing places is not supported."); +const char SAVING_CATEGORY_NOT_SUPPORTED[] = QT_TRANSLATE_NOOP("QtLocationQML", "Saving categories is not supported."); +const char REMOVING_CATEGORY_NOT_SUPPORTED[] = QT_TRANSLATE_NOOP("QtLocationQML", "Removing categories is not supported."); +const char PARSE_ERROR[] = QT_TRANSLATE_NOOP("QtLocationQML", "Error parsing response."); +const char NETWORK_ERROR[] = QT_TRANSLATE_NOOP("QtLocationQML", "Network error."); + +QT_END_NAMESPACE diff --git a/src/plugins/geoservices/nokia/qgeoerror_messages.h b/src/plugins/geoservices/nokia/qgeoerror_messages.h new file mode 100644 index 00000000..08d54e2c --- /dev/null +++ b/src/plugins/geoservices/nokia/qgeoerror_messages.h @@ -0,0 +1,68 @@ + +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +** This file is part of the Ovi services plugin for the Maps and +** Navigation API. The use of these services, whether by use of the +** plugin or by other means, is governed by the terms and conditions +** described by the file OVI_SERVICES_TERMS_AND_CONDITIONS.txt in +** this package, located in the directory containing the Ovi services +** plugin source code. +** +****************************************************************************/ + +#ifndef QGEOERROR_MESSAGES_H +#define QGEOERROR_MESSAGES_H + +#include <qglobal.h> + +QT_BEGIN_NAMESPACE + +extern const char NOKIA_PLUGIN_CONTEXT_NAME[]; +extern const char MISSED_CREDENTIALS[]; +extern const char SAVING_PLACE_NOT_SUPPORTED[]; +extern const char REMOVING_PLACE_NOT_SUPPORTED[]; +extern const char SAVING_CATEGORY_NOT_SUPPORTED[]; +extern const char REMOVING_CATEGORY_NOT_SUPPORTED[]; +extern const char PARSE_ERROR[]; +extern const char NETWORK_ERROR[]; + +QT_END_NAMESPACE + +#endif // QGEOERROR_MESSAGES_H diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.cpp index f55db408..3b72e572 100644 --- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.cpp +++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.cpp @@ -47,7 +47,9 @@ ****************************************************************************/ #include "qplacemanagerengine_nokiav1.h" +#include "qgeoerror_messages.h" +#include <QCoreApplication> #include <QtLocation/QPlaceContentRequest> #include "placesv1/qplacecategoriesrepository.h" @@ -219,7 +221,7 @@ QPlaceIdReply *QPlaceManagerEngineNokiaV1::savePlace(const QPlace &place) { IdReply *reply = new IdReply(QPlaceIdReply::SavePlace, this); reply->setId(place.placeId()); - reply->triggerDone(QPlaceReply::UnsupportedError, tr("Saving places is not supported")); + reply->triggerDone(QPlaceReply::UnsupportedError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, SAVING_PLACE_NOT_SUPPORTED)); return reply; } @@ -227,7 +229,7 @@ QPlaceIdReply *QPlaceManagerEngineNokiaV1::removePlace(const QString &placeId) { IdReply *reply = new IdReply(QPlaceIdReply::RemovePlace, this); reply->setId(placeId); - reply->triggerDone(QPlaceReply::UnsupportedError, tr("Removing places is not supported")); + reply->triggerDone(QPlaceReply::UnsupportedError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, REMOVING_PLACE_NOT_SUPPORTED)); return reply; } @@ -237,7 +239,7 @@ QPlaceIdReply *QPlaceManagerEngineNokiaV1::saveCategory(const QPlaceCategory &ca IdReply *reply = new IdReply(QPlaceIdReply::SaveCategory, this); reply->setId(category.categoryId()); - reply->triggerDone(QPlaceReply::UnsupportedError, tr("Saving categories is not supported")); + reply->triggerDone(QPlaceReply::UnsupportedError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, SAVING_CATEGORY_NOT_SUPPORTED)); return reply; } @@ -245,7 +247,7 @@ QPlaceIdReply *QPlaceManagerEngineNokiaV1::removeCategory(const QString &categor { IdReply *reply = new IdReply(QPlaceIdReply::RemoveCategory, this); reply->setId(categoryId); - reply->triggerDone(QPlaceReply::UnsupportedError, tr("Removing categories is not supported")); + reply->triggerDone(QPlaceReply::UnsupportedError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, REMOVING_CATEGORY_NOT_SUPPORTED)); return reply; } diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp index c833df10..5cbc431a 100644 --- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp +++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp @@ -58,7 +58,9 @@ #include "qgeonetworkaccessmanager.h" #include "qgeouriprovider.h" #include "uri_constants.h" +#include "qgeoerror_messages.h" +#include <QCoreApplication> #include <QtCore/QFile> #include <QtCore/QJsonArray> #include <QtCore/QJsonDocument> @@ -527,7 +529,7 @@ QPlaceIdReply *QPlaceManagerEngineNokiaV2::savePlace(const QPlace &place) reply->setId(place.placeId()); QMetaObject::invokeMethod(reply, "setError", Qt::QueuedConnection, Q_ARG(QPlaceReply::Error, QPlaceReply::UnsupportedError), - Q_ARG(QString, tr("Saving places is not supported."))); + Q_ARG(QString, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, SAVING_PLACE_NOT_SUPPORTED))); connect(reply, SIGNAL(finished()), this, SLOT(replyFinished())); connect(reply, SIGNAL(error(QPlaceReply::Error,QString)), this, SLOT(replyError(QPlaceReply::Error,QString))); @@ -540,7 +542,7 @@ QPlaceIdReply *QPlaceManagerEngineNokiaV2::removePlace(const QString &placeId) reply->setId(placeId); QMetaObject::invokeMethod(reply, "setError", Qt::QueuedConnection, Q_ARG(QPlaceReply::Error, QPlaceReply::UnsupportedError), - Q_ARG(QString, tr("Removing places is not supported."))); + Q_ARG(QString, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, REMOVING_PLACE_NOT_SUPPORTED))); connect(reply, SIGNAL(finished()), this, SLOT(replyFinished())); connect(reply, SIGNAL(error(QPlaceReply::Error,QString)), this, SLOT(replyError(QPlaceReply::Error,QString))); @@ -555,7 +557,7 @@ QPlaceIdReply *QPlaceManagerEngineNokiaV2::saveCategory(const QPlaceCategory &ca reply->setId(category.categoryId()); QMetaObject::invokeMethod(reply, "setError", Qt::QueuedConnection, Q_ARG(QPlaceReply::Error, QPlaceReply::UnsupportedError), - Q_ARG(QString, tr("Saving categories is not supported."))); + Q_ARG(QString, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, SAVING_CATEGORY_NOT_SUPPORTED))); connect(reply, SIGNAL(finished()), this, SLOT(replyFinished())); connect(reply, SIGNAL(error(QPlaceReply::Error,QString)), this, SLOT(replyError(QPlaceReply::Error,QString))); @@ -568,7 +570,7 @@ QPlaceIdReply *QPlaceManagerEngineNokiaV2::removeCategory(const QString &categor reply->setId(categoryId); QMetaObject::invokeMethod(reply, "setError", Qt::QueuedConnection, Q_ARG(QPlaceReply::Error, QPlaceReply::UnsupportedError), - Q_ARG(QString, tr("Removing categories is not supported."))); + Q_ARG(QString, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, REMOVING_CATEGORY_NOT_SUPPORTED))); connect(reply, SIGNAL(finished()), this, SLOT(replyFinished())); connect(reply, SIGNAL(error(QPlaceReply::Error,QString)), this, SLOT(replyError(QPlaceReply::Error,QString))); @@ -747,7 +749,7 @@ void QPlaceManagerEngineNokiaV2::categoryReplyFinished() if (m_categoryReply) { QMetaObject::invokeMethod(m_categoryReply.data(), "setError", Qt::QueuedConnection, Q_ARG(QPlaceReply::Error, QPlaceReply::ParseError), - Q_ARG(QString, tr("Error parsing response."))); + Q_ARG(QString, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, PARSE_ERROR))); } return; } @@ -779,7 +781,7 @@ void QPlaceManagerEngineNokiaV2::categoryReplyError() if (m_categoryReply) { QMetaObject::invokeMethod(m_categoryReply.data(), "setError", Qt::QueuedConnection, Q_ARG(QPlaceReply::Error, QPlaceReply::CommunicationError), - Q_ARG(QString, tr("Network error."))); + Q_ARG(QString, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, NETWORK_ERROR))); } } |