diff options
author | abcd <amos.choy@nokia.com> | 2012-06-26 17:48:14 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-05 06:26:13 +0200 |
commit | b259be3e53f534cc4355f1fe7957f361c08b9890 (patch) | |
tree | 634941ac8ed3431e42bea7e61c46a7fcf38f4cee /src/plugins/geoservices/nokia | |
parent | 3e49bbe8a67f2b5524f7ac8aa2bf99a2ba2ec5ce (diff) | |
download | qtlocation-b259be3e53f534cc4355f1fe7957f361c08b9890.tar.gz |
Refactor error handling in nokia plugin for search suggestions
Change-Id: I022ccad6a1d53ec0f3da14e1ef8fe0e2b27e0687
Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'src/plugins/geoservices/nokia')
5 files changed, 15 insertions, 17 deletions
diff --git a/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.cpp index 116f8f9f..8bcfd6a2 100644 --- a/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.cpp +++ b/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.cpp @@ -101,10 +101,10 @@ void QPlaceSearchReplyImpl::replyFinished() if (m_reply->error() != QNetworkReply::NoError) { switch (m_reply->error()) { case QNetworkReply::OperationCanceledError: - setError(CancelError, "Request canceled."); + setError(CancelError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, CANCEL_ERROR)); break; default: - setError(CommunicationError, "Network error."); + setError(CommunicationError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, NETWORK_ERROR)); } return; } @@ -112,7 +112,6 @@ void QPlaceSearchReplyImpl::replyFinished() QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll()); if (!document.isObject()) { 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 37820e3a..a25a0332 100644 --- a/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp +++ b/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp @@ -65,8 +65,6 @@ QPlaceSearchSuggestionReplyImpl::QPlaceSearchSuggestionReplyImpl(QNetworkReply * m_reply->setParent(this); connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished())); - connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), - this, SLOT(replyError(QNetworkReply::NetworkError))); } QPlaceSearchSuggestionReplyImpl::~QPlaceSearchSuggestionReplyImpl() @@ -90,6 +88,17 @@ void QPlaceSearchSuggestionReplyImpl::setError(QPlaceReply::Error error_, void QPlaceSearchSuggestionReplyImpl::replyFinished() { + if (m_reply->error() != QNetworkReply::NoError) { + switch (m_reply->error()) { + case QNetworkReply::OperationCanceledError: + setError(CancelError, "Request canceled."); + break; + default: + setError(CommunicationError, "Network error."); + } + return; + } + QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll()); if (!document.isObject()) { setError(ParseError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, PARSE_ERROR)); @@ -117,15 +126,4 @@ void QPlaceSearchSuggestionReplyImpl::replyFinished() emit finished(); } -void QPlaceSearchSuggestionReplyImpl::replyError(QNetworkReply::NetworkError error) -{ - switch (error) { - case QNetworkReply::OperationCanceledError: - setError(CancelError, "Request canceled."); - break; - default: - setError(CommunicationError, "Network error."); - } -} - QT_END_NAMESPACE diff --git a/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.h b/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.h index fdbb2212..c7fb3b21 100644 --- a/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.h +++ b/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.h @@ -67,7 +67,6 @@ public: private slots: void setError(QPlaceReply::Error error_, const QString &errorString); void replyFinished(); - void replyError(QNetworkReply::NetworkError error); private: QNetworkReply *m_reply; diff --git a/src/plugins/geoservices/nokia/qgeoerror_messages.cpp b/src/plugins/geoservices/nokia/qgeoerror_messages.cpp index 2bb1e1b8..a1d3409a 100644 --- a/src/plugins/geoservices/nokia/qgeoerror_messages.cpp +++ b/src/plugins/geoservices/nokia/qgeoerror_messages.cpp @@ -58,5 +58,6 @@ const char SAVING_CATEGORY_NOT_SUPPORTED[] = QT_TRANSLATE_NOOP("QtLocationQML", 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."); +const char CANCEL_ERROR[] = QT_TRANSLATE_NOOP("QtLocationQML", "Request was canceled."); QT_END_NAMESPACE diff --git a/src/plugins/geoservices/nokia/qgeoerror_messages.h b/src/plugins/geoservices/nokia/qgeoerror_messages.h index 08d54e2c..a9ef3caa 100644 --- a/src/plugins/geoservices/nokia/qgeoerror_messages.h +++ b/src/plugins/geoservices/nokia/qgeoerror_messages.h @@ -62,6 +62,7 @@ extern const char SAVING_CATEGORY_NOT_SUPPORTED[]; extern const char REMOVING_CATEGORY_NOT_SUPPORTED[]; extern const char PARSE_ERROR[]; extern const char NETWORK_ERROR[]; +extern const char CANCEL_ERROR[]; QT_END_NAMESPACE |