summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2012-01-19 15:49:13 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-09 06:02:00 +0100
commitd24206cf6d87966b32c8a1186c9fa682d66b8ee9 (patch)
treee860f08099c77f7a5b06f89a2931f6b0932f6208
parent4f158d2920736553cc214a5ef4690e8e89a79324 (diff)
downloadqtlocation-d24206cf6d87966b32c8a1186c9fa682d66b8ee9.tar.gz
Add support for the new Nokia REST API to nokia plugin.
Support is added in such a way that both the v1 and v2 REST APIs are supported by the plugin. By default the v1 API is used. The application developer can explicitly select v2 by setting the places.api_version plugin parameter to 2. At some point the default will change to v2 and support for v1 and places.api_version may be dropped entirely. The new REST API is documented at http://api.places.lbs.maps.nokia.com/places/static/doc/index.html Change-Id: I643d10202ab387346fa4658f096a6ddbb5e80e34 Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
-rw-r--r--doc/src/plugins/nokia.qdoc8
-rw-r--r--examples/declarative/places/content/places/CategoryDelegate.qml27
-rw-r--r--examples/declarative/places/content/places/SearchResultView.qml20
-rw-r--r--examples/declarative/places/places.qml23
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplace.cpp18
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp36
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h2
-rw-r--r--src/location/places/qplacecontentreply.h4
-rw-r--r--src/plugins/geoservices/nokia/nokia.pro3
-rw-r--r--src/plugins/geoservices/nokia/places/places.pri61
-rw-r--r--src/plugins/geoservices/nokia/placesv1/placesv1.pri61
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacecategoriesreplyimplv1.cpp (renamed from src/plugins/geoservices/nokia/places/qplacecategoriesreplyimpl.cpp)16
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacecategoriesreplyimplv1.h (renamed from src/plugins/geoservices/nokia/places/qplacecategoriesreplyimpl.h)6
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacecategoriesrepository.cpp (renamed from src/plugins/geoservices/nokia/places/qplacecategoriesrepository.cpp)2
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacecategoriesrepository.h (renamed from src/plugins/geoservices/nokia/places/qplacecategoriesrepository.h)4
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacecontentreplyimplv1.cpp (renamed from src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.cpp)16
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacecontentreplyimplv1.h (renamed from src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.h)6
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacedetailsreplyimplv1.cpp (renamed from src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.cpp)16
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacedetailsreplyimplv1.h (renamed from src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.h)6
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacejsoncategoriesparser.cpp (renamed from src/plugins/geoservices/nokia/places/qplacejsoncategoriesparser.cpp)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacejsoncategoriesparser.h (renamed from src/plugins/geoservices/nokia/places/qplacejsoncategoriesparser.h)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacejsondetailsparser.cpp (renamed from src/plugins/geoservices/nokia/places/qplacejsondetailsparser.cpp)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacejsondetailsparser.h (renamed from src/plugins/geoservices/nokia/places/qplacejsondetailsparser.h)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacejsonmediaparser.cpp (renamed from src/plugins/geoservices/nokia/places/qplacejsonmediaparser.cpp)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacejsonmediaparser.h (renamed from src/plugins/geoservices/nokia/places/qplacejsonmediaparser.h)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacejsonparser.cpp (renamed from src/plugins/geoservices/nokia/places/qplacejsonparser.cpp)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacejsonparser_p.h (renamed from src/plugins/geoservices/nokia/places/qplacejsonparser_p.h)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacejsonrecommendationparser.cpp (renamed from src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.cpp)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacejsonrecommendationparser.h (renamed from src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.h)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacejsonreviewparser.cpp (renamed from src/plugins/geoservices/nokia/places/qplacejsonreviewparser.cpp)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacejsonreviewparser.h (renamed from src/plugins/geoservices/nokia/places/qplacejsonreviewparser.h)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacejsonsearchparser.cpp (renamed from src/plugins/geoservices/nokia/places/qplacejsonsearchparser.cpp)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacejsonsearchparser.h (renamed from src/plugins/geoservices/nokia/places/qplacejsonsearchparser.h)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacejsontextpredictionparser.cpp (renamed from src/plugins/geoservices/nokia/places/qplacejsontextpredictionparser.cpp)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacejsontextpredictionparser.h (renamed from src/plugins/geoservices/nokia/places/qplacejsontextpredictionparser.h)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplaceratingreplyimpl.cpp (renamed from src/plugins/geoservices/nokia/places/qplaceratingreplyimpl.cpp)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplaceratingreplyimpl.h (renamed from src/plugins/geoservices/nokia/places/qplaceratingreplyimpl.h)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacerecommendationreplyimplv1.cpp (renamed from src/plugins/geoservices/nokia/places/qplacerecommendationreplyimpl.cpp)12
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacerecommendationreplyimplv1.h (renamed from src/plugins/geoservices/nokia/places/qplacerecommendationreplyimpl.h)6
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacerestmanager.cpp (renamed from src/plugins/geoservices/nokia/places/qplacerestmanager.cpp)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacerestmanager.h (renamed from src/plugins/geoservices/nokia/places/qplacerestmanager.h)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacerestreply.cpp (renamed from src/plugins/geoservices/nokia/places/qplacerestreply.cpp)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacerestreply.h (renamed from src/plugins/geoservices/nokia/places/qplacerestreply.h)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacesearchreplyimplv1.cpp (renamed from src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.cpp)16
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacesearchreplyimplv1.h (renamed from src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.h)6
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacesuppliersrepository.cpp (renamed from src/plugins/geoservices/nokia/places/qplacesuppliersrepository.cpp)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacesuppliersrepository.h (renamed from src/plugins/geoservices/nokia/places/qplacesuppliersrepository.h)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacetextpredictionreplyimpl.cpp (renamed from src/plugins/geoservices/nokia/places/qplacetextpredictionreplyimpl.cpp)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/qplacetextpredictionreplyimpl.h (renamed from src/plugins/geoservices/nokia/places/qplacetextpredictionreplyimpl.h)0
-rw-r--r--src/plugins/geoservices/nokia/placesv1/unsupportedreplies.h (renamed from src/plugins/geoservices/nokia/places/unsupportedreplies.h)11
-rw-r--r--src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.cpp219
-rw-r--r--src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.h73
-rw-r--r--src/plugins/geoservices/nokia/placesv2/placesv2.pri23
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacecategoriesreplyimpl.cpp67
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacecategoriesreplyimpl.h65
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp127
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.h82
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp345
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.h80
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplaceidreplyimpl.cpp68
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplaceidreplyimpl.h65
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacerecommendationreplyimpl.cpp175
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacerecommendationreplyimpl.h80
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.cpp190
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.h78
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp129
-rw-r--r--src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.h78
-rw-r--r--src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp12
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.cpp (renamed from src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp)88
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.h (renamed from src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h)13
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp624
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.h145
-rw-r--r--src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp2
-rw-r--r--tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp2
-rw-r--r--tests/auto/qplacemanager_nokia/tst_qplacemanager_nokia.cpp2
75 files changed, 3018 insertions, 200 deletions
diff --git a/doc/src/plugins/nokia.qdoc b/doc/src/plugins/nokia.qdoc
index 5765e420..8ddad1d0 100644
--- a/doc/src/plugins/nokia.qdoc
+++ b/doc/src/plugins/nokia.qdoc
@@ -99,11 +99,9 @@ The following table lists optional parameters that can be passed to the Nokia pl
\o places.host
\o Search service URL used by search manager.
\row
- \o places.referer
- \o Referer for the places token used for authentication by search manager.
-\row
- \o places.token
- \o Client token for the service used for authentication by search manager.
+ \o places.api_version
+ \o Version of the REST API used by the places manager. Currently versions 1 and 2 are
+ supported. The default is version 1.
\endtable
\section1 Parameter Usage Example
diff --git a/examples/declarative/places/content/places/CategoryDelegate.qml b/examples/declarative/places/content/places/CategoryDelegate.qml
index f7921567..a5e1036e 100644
--- a/examples/declarative/places/content/places/CategoryDelegate.qml
+++ b/examples/declarative/places/content/places/CategoryDelegate.qml
@@ -53,20 +53,37 @@ Item {
width: parent.width
height: childrenRect.height
- //! [CategoryModel delegate text]
- Text {
+ Item {
anchors.left: parent.left
anchors.right: arrow.left
- text: category.name
- elide: Text.ElideRight
+ height: Math.max(icon.height, name.height)
+
+ Image {
+ id: icon
+
+ anchors.left: parent.left
+ source: category.icon.url()
+ }
+
+ //! [CategoryModel delegate text]
+ Text {
+ id: name
+
+ anchors.left: icon.right
+ anchors.verticalCenter: icon.verticalCenter
+ anchors.right: parent.right
+
+ text: category.name
+ elide: Text.ElideRight
+ }
+ //! [CategoryModel delegate text]
MouseArea {
anchors.fill: parent
onClicked: root.clicked()
}
}
- //! [CategoryModel delegate text]
//! [CategoryModel delegate icon]
IconButton {
diff --git a/examples/declarative/places/content/places/SearchResultView.qml b/examples/declarative/places/content/places/SearchResultView.qml
index a60b8349..859f773b 100644
--- a/examples/declarative/places/content/places/SearchResultView.qml
+++ b/examples/declarative/places/content/places/SearchResultView.qml
@@ -96,6 +96,26 @@ Item {
onDisplayPlaceDetails: showPlaceDetails(data)
onSearchFor: placeSearchModel.searchForText(query);
}
+
+ footer: Item {
+ anchors.left: parent.left
+ anchors.right: parent.right
+ height: childrenRect.height
+
+ Button {
+ text: qsTr("Previous")
+ onClicked: placeSearchModel.previousPage()
+
+ anchors.left: parent.left
+ }
+
+ Button {
+ text: qsTr("Next")
+ onClicked: placeSearchModel.nextPage()
+
+ anchors.right: parent.right
+ }
+ }
}
//! [PlaceSearchModel place list]
diff --git a/examples/declarative/places/places.qml b/examples/declarative/places/places.qml
index e609c775..a75aa9aa 100644
--- a/examples/declarative/places/places.qml
+++ b/examples/declarative/places/places.qml
@@ -384,12 +384,30 @@ Item {
function searchForCategory(category) {
searchTerm = "";
categories = category;
+ limit = -1;
+ offset = 0;
execute();
}
function searchForText(text) {
searchTerm = text;
categories = null;
+ limit = -1;
+ offset = 0;
+ execute();
+ }
+
+ function previousPage() {
+ if (limit === -1)
+ limit = count;
+ offset = Math.max(0, offset - limit);
+ execute();
+ }
+
+ function nextPage() {
+ if (limit === -1)
+ limit = count;
+ offset += limit;
execute();
}
@@ -430,7 +448,10 @@ Item {
id: placesPlugin
parameters: pluginParametersFromMap(pluginParameters)
- onNameChanged: createMap(placesPlugin);
+ onNameChanged: {
+ createMap(placesPlugin);
+ categoryModel.update();
+ }
}
Item {
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplace.cpp b/src/imports/location/declarativeplaces/qdeclarativeplace.cpp
index fbd60e7b..4ee61ebd 100644
--- a/src/imports/location/declarativeplaces/qdeclarativeplace.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativeplace.cpp
@@ -367,13 +367,17 @@ void QDeclarativePlace::setPlace(const QPlace &src)
emit primaryWebsiteChanged();
}
- if (previous.placeId() != m_src.placeId()) {
- if (m_reviewModel)
- m_reviewModel->clear();
- if (m_imageModel)
- m_imageModel->clear();
- if (m_editorialModel)
- m_editorialModel->clear();
+ if (m_reviewModel) {
+ m_reviewModel->initializeCollection(m_src.totalContentCount(QPlaceContent::ReviewType),
+ m_src.content(QPlaceContent::ReviewType));
+ }
+ if (m_imageModel) {
+ m_imageModel->initializeCollection(m_src.totalContentCount(QPlaceContent::ImageType),
+ m_src.content(QPlaceContent::ImageType));
+ }
+ if (m_editorialModel) {
+ m_editorialModel->initializeCollection(m_src.totalContentCount(QPlaceContent::EditorialType),
+ m_src.content(QPlaceContent::EditorialType));
}
synchronizeExtendedAttributes();
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
index 47dd3f04..6f23ad37 100644
--- a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.cpp
@@ -158,6 +158,39 @@ void QDeclarativePlaceContentModel::clearData()
m_reply = 0;
}
+void QDeclarativePlaceContentModel::initializeCollection(int totalCount, const QPlaceContent::Collection &collection)
+{
+ beginResetModel();
+
+ clearData();
+
+ if (m_contentCount != totalCount) {
+ m_contentCount = totalCount;
+ emit totalCountChanged();
+ }
+
+ QMapIterator<int, QPlaceContent> i(collection);
+ while (i.hasNext()) {
+ i.next();
+
+ const QPlaceContent &content = i.value();
+ if (content.type() != m_type)
+ continue;
+
+ m_content.insert(i.key(), content);
+ if (!m_suppliers.contains(content.supplier().supplierId())) {
+ m_suppliers.insert(content.supplier().supplierId(),
+ new QDeclarativeSupplier(content.supplier(), m_place->plugin(), this));
+ }
+ if (!m_users.contains(content.user().userId())) {
+ m_users.insert(content.user().userId(),
+ new QDeclarativePlaceUser(content.user(), this));
+ }
+ }
+
+ endResetModel();
+}
+
int QDeclarativePlaceContentModel::rowCount(const QModelIndex &parent) const
{
if (parent.isValid())
@@ -259,6 +292,9 @@ void QDeclarativePlaceContentModel::componentComplete()
void QDeclarativePlaceContentModel::fetchFinished()
{
+ if (!m_reply)
+ return;
+
QPlaceContentReply *reply = m_reply;
m_reply = 0;
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h
index 2440f876..3499e178 100644
--- a/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h
+++ b/src/imports/location/declarativeplaces/qdeclarativeplacecontentmodel.h
@@ -80,6 +80,8 @@ public:
void clear();
void clearData();
+ void initializeCollection(int totalCount, const QPlaceContent::Collection &collection);
+
// from QAbstractListModel
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
diff --git a/src/location/places/qplacecontentreply.h b/src/location/places/qplacecontentreply.h
index 69d38793..4ce7bf4f 100644
--- a/src/location/places/qplacecontentreply.h
+++ b/src/location/places/qplacecontentreply.h
@@ -50,12 +50,11 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-
-
class QPlaceContentReplyPrivate;
class Q_LOCATION_EXPORT QPlaceContentReply : public QPlaceReply
{
Q_OBJECT
+
public:
explicit QPlaceContentReply(QObject *parent = 0);
virtual ~QPlaceContentReply();
@@ -73,7 +72,6 @@ protected:
void setTotalCount(int total);
void setRequest(const QPlaceContentRequest &request);
-\
private:
Q_DISABLE_COPY(QPlaceContentReply)
Q_DECLARE_PRIVATE(QPlaceContentReply)
diff --git a/src/plugins/geoservices/nokia/nokia.pro b/src/plugins/geoservices/nokia/nokia.pro
index e043d839..43884b2e 100644
--- a/src/plugins/geoservices/nokia/nokia.pro
+++ b/src/plugins/geoservices/nokia/nokia.pro
@@ -37,7 +37,8 @@ SOURCES += \
qgeoroutingmanagerengine_nokia.cpp \
qgeoserviceproviderplugin_nokia.cpp
-include(places/places.pri)
+include(placesv1/placesv1.pri)
+include(placesv2/placesv2.pri)
RESOURCES += resource.qrc
diff --git a/src/plugins/geoservices/nokia/places/places.pri b/src/plugins/geoservices/nokia/places/places.pri
deleted file mode 100644
index b5021d08..00000000
--- a/src/plugins/geoservices/nokia/places/places.pri
+++ /dev/null
@@ -1,61 +0,0 @@
-QT *= location network declarative
-
-HEADERS += \
-#data classes
-#parsers
- places/qplacejsonparser_p.h \
- places/qplacejsoncategoriesparser.h \
- places/qplacejsondetailsparser.h \
- places/qplacejsonmediaparser.h \
- places/qplacejsonrecommendationparser.h \
- places/qplacejsonreviewparser.h \
- places/qplacejsonsearchparser.h \
- places/qplacejsontextpredictionparser.h \
-#query classes
-#reply classes
- places/qplacecategoriesreplyimpl.h \
- places/qplacecontentreplyimpl.h \
- places/qplacedetailsreplyimpl.h \
- places/qplaceratingreplyimpl.h \
- places/qplacerecommendationreplyimpl.h \
- places/qplacesearchreplyimpl.h \
- places/qplacetextpredictionreplyimpl.h \
-#manager and engine
- qplacemanagerengine_nokia.h \
- places/qplacecategoriesrepository.h \
- places/qplacerestreply.h \
- places/qplacerestmanager.h \
- places/qplacesuppliersrepository.h \
-#misc
- places/unsupportedreplies.h
-
-SOURCES += \
-#data classes
-#parsers
- places/qplacejsonparser.cpp \
- places/qplacejsoncategoriesparser.cpp \
- places/qplacejsondetailsparser.cpp \
- places/qplacejsonmediaparser.cpp \
- places/qplacejsonrecommendationparser.cpp \
- places/qplacejsonreviewparser.cpp \
- places/qplacejsonsearchparser.cpp \
- places/qplacejsontextpredictionparser.cpp \
-#query classes
-#reply classes
- places/qplacecategoriesreplyimpl.cpp \
- places/qplacedetailsreplyimpl.cpp \
- places/qplacecontentreplyimpl.cpp \
- places/qplaceratingreplyimpl.cpp \
- places/qplacerecommendationreplyimpl.cpp \
- places/qplacesearchreplyimpl.cpp \
- places/qplacetextpredictionreplyimpl.cpp \
-#manager and engine
- qplacemanagerengine_nokia.cpp \
- places/qplacecategoriesrepository.cpp \
- places/qplacerestreply.cpp \
- places/qplacerestmanager.cpp \
- places/qplacesuppliersrepository.cpp
-
-
-
-
diff --git a/src/plugins/geoservices/nokia/placesv1/placesv1.pri b/src/plugins/geoservices/nokia/placesv1/placesv1.pri
new file mode 100644
index 00000000..8908456f
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv1/placesv1.pri
@@ -0,0 +1,61 @@
+QT *= location network declarative
+
+HEADERS += \
+#data classes
+#parsers
+ placesv1/qplacejsonparser_p.h \
+ placesv1/qplacejsoncategoriesparser.h \
+ placesv1/qplacejsondetailsparser.h \
+ placesv1/qplacejsonmediaparser.h \
+ placesv1/qplacejsonrecommendationparser.h \
+ placesv1/qplacejsonreviewparser.h \
+ placesv1/qplacejsonsearchparser.h \
+ placesv1/qplacejsontextpredictionparser.h \
+#query classes
+#reply classes
+ placesv1/qplaceratingreplyimpl.h \
+ placesv1/qplacetextpredictionreplyimpl.h \
+#manager and engine
+ qplacemanagerengine_nokiav1.h \
+ placesv1/qplacecategoriesrepository.h \
+ placesv1/qplacerestreply.h \
+ placesv1/qplacerestmanager.h \
+ placesv1/qplacesuppliersrepository.h \
+#misc
+ placesv1/unsupportedreplies.h \
+ placesv1/qplacecategoriesreplyimplv1.h \
+ placesv1/qplacecontentreplyimplv1.h \
+ placesv1/qplacedetailsreplyimplv1.h \
+ placesv1/qplacerecommendationreplyimplv1.h \
+ placesv1/qplacesearchreplyimplv1.h
+
+SOURCES += \
+#data classes
+#parsers
+ placesv1/qplacejsonparser.cpp \
+ placesv1/qplacejsoncategoriesparser.cpp \
+ placesv1/qplacejsondetailsparser.cpp \
+ placesv1/qplacejsonmediaparser.cpp \
+ placesv1/qplacejsonrecommendationparser.cpp \
+ placesv1/qplacejsonreviewparser.cpp \
+ placesv1/qplacejsonsearchparser.cpp \
+ placesv1/qplacejsontextpredictionparser.cpp \
+#query classes
+#reply classes
+ placesv1/qplaceratingreplyimpl.cpp \
+ placesv1/qplacetextpredictionreplyimpl.cpp \
+#manager and engine
+ qplacemanagerengine_nokiav1.cpp \
+ placesv1/qplacecategoriesrepository.cpp \
+ placesv1/qplacerestreply.cpp \
+ placesv1/qplacerestmanager.cpp \
+ placesv1/qplacesuppliersrepository.cpp \
+ placesv1/qplacecategoriesreplyimplv1.cpp \
+ placesv1/qplacecontentreplyimplv1.cpp \
+ placesv1/qplacedetailsreplyimplv1.cpp \
+ placesv1/qplacerecommendationreplyimplv1.cpp \
+ placesv1/qplacesearchreplyimplv1.cpp
+
+
+
+
diff --git a/src/plugins/geoservices/nokia/places/qplacecategoriesreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv1/qplacecategoriesreplyimplv1.cpp
index b1a656f7..7c02bd70 100644
--- a/src/plugins/geoservices/nokia/places/qplacecategoriesreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacecategoriesreplyimplv1.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include "qplacecategoriesreplyimpl.h"
+#include "qplacecategoriesreplyimplv1.h"
#if defined(QT_PLACES_LOGGING)
#include <QDebug>
@@ -48,7 +48,7 @@
/*!
Constructor.
*/
-QPlaceCategoriesReplyImpl::QPlaceCategoriesReplyImpl(QPlaceRestReply *reply, QObject *parent) :
+QPlaceCategoriesReplyImplV1::QPlaceCategoriesReplyImplV1(QPlaceRestReply *reply, QObject *parent) :
QPlaceReply(parent),
restReply(reply)
{
@@ -68,16 +68,16 @@ QPlaceCategoriesReplyImpl::QPlaceCategoriesReplyImpl(QPlaceRestReply *reply, QOb
/*!
Destructor.
*/
-QPlaceCategoriesReplyImpl::~QPlaceCategoriesReplyImpl()
+QPlaceCategoriesReplyImplV1::~QPlaceCategoriesReplyImplV1()
{
}
-QPlaceCategoryTree QPlaceCategoriesReplyImpl::categories() const
+QPlaceCategoryTree QPlaceCategoriesReplyImplV1::categories() const
{
return m_categoryTree;
}
-QList<QPlaceCategory> QPlaceCategoriesReplyImpl::categoriesFlat() const
+QList<QPlaceCategory> QPlaceCategoriesReplyImplV1::categoriesFlat() const
{
QList<QPlaceCategory> categories;
foreach (const PlaceCategoryNode node, m_categoryTree.values())
@@ -85,14 +85,14 @@ QList<QPlaceCategory> QPlaceCategoriesReplyImpl::categoriesFlat() const
return categories;
}
-void QPlaceCategoriesReplyImpl::abort()
+void QPlaceCategoriesReplyImplV1::abort()
{
if (restReply) {
restReply->cancelProcessing();
}
}
-void QPlaceCategoriesReplyImpl::restError(QPlaceRestReply::Error errorId)
+void QPlaceCategoriesReplyImplV1::restError(QPlaceRestReply::Error errorId)
{
if (errorId == QPlaceRestReply::Canceled) {
this->setError(CancelError, "RequestCanceled");
@@ -106,7 +106,7 @@ void QPlaceCategoriesReplyImpl::restError(QPlaceRestReply::Error errorId)
emit processingFinished(this);
}
-void QPlaceCategoriesReplyImpl::resultReady(const QPlaceJSonParser::Error &errorId,
+void QPlaceCategoriesReplyImplV1::resultReady(const QPlaceJSonParser::Error &errorId,
const QString &errorMessage)
{
if (errorId == QPlaceJSonParser::NoError) {
diff --git a/src/plugins/geoservices/nokia/places/qplacecategoriesreplyimpl.h b/src/plugins/geoservices/nokia/placesv1/qplacecategoriesreplyimplv1.h
index 4b9543b8..6e6b5679 100644
--- a/src/plugins/geoservices/nokia/places/qplacecategoriesreplyimpl.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacecategoriesreplyimplv1.h
@@ -49,12 +49,12 @@
#include "qplacerestreply.h"
#include "qplacejsoncategoriesparser.h"
-class QPlaceCategoriesReplyImpl : public QPlaceReply
+class QPlaceCategoriesReplyImplV1 : public QPlaceReply
{
Q_OBJECT
public:
- explicit QPlaceCategoriesReplyImpl(QPlaceRestReply *reply, QObject *parent = 0);
- ~QPlaceCategoriesReplyImpl();
+ explicit QPlaceCategoriesReplyImplV1(QPlaceRestReply *reply, QObject *parent = 0);
+ ~QPlaceCategoriesReplyImplV1();
QPlaceCategoryTree categories() const;
QList<QPlaceCategory> categoriesFlat() const;
diff --git a/src/plugins/geoservices/nokia/places/qplacecategoriesrepository.cpp b/src/plugins/geoservices/nokia/placesv1/qplacecategoriesrepository.cpp
index 3b68a9a9..60a3142f 100644
--- a/src/plugins/geoservices/nokia/places/qplacecategoriesrepository.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacecategoriesrepository.cpp
@@ -83,7 +83,7 @@ QPlaceReply *QPlaceCategoriesRepository::initializeCategories()
QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendCategoriesTreeRequest();
if (restReply) {
- m_categoriesReply = new QPlaceCategoriesReplyImpl(restReply);
+ m_categoriesReply = new QPlaceCategoriesReplyImplV1(restReply);
connect(m_categoriesReply.data(), SIGNAL(finished()),
this, SLOT(replyFinished()));
}
diff --git a/src/plugins/geoservices/nokia/places/qplacecategoriesrepository.h b/src/plugins/geoservices/nokia/placesv1/qplacecategoriesrepository.h
index c84977c4..004bd095 100644
--- a/src/plugins/geoservices/nokia/places/qplacecategoriesrepository.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacecategoriesrepository.h
@@ -56,7 +56,7 @@
#include <qplacecategory.h>
#include <qplacereply.h>
#include "qplacejsoncategoriesparser.h"
-#include "qplacecategoriesreplyimpl.h"
+#include "qplacecategoriesreplyimplv1.h"
QT_BEGIN_HEADER
@@ -90,7 +90,7 @@ private:
QPlaceCategoryTree m_categoryTree;
static QPlaceCategoriesRepository *repositoryInstance;
- QWeakPointer<QPlaceCategoriesReplyImpl> m_categoriesReply;
+ QWeakPointer<QPlaceCategoriesReplyImplV1> m_categoriesReply;
};
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv1/qplacecontentreplyimplv1.cpp
index 553196e8..2bd6a095 100644
--- a/src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacecontentreplyimplv1.cpp
@@ -46,7 +46,7 @@
**
****************************************************************************/
-#include "qplacecontentreplyimpl.h"
+#include "qplacecontentreplyimplv1.h"
#if defined(QT_PLACES_LOGGING)
#include <QDebug>
@@ -57,7 +57,7 @@ QT_USE_NAMESPACE
/*!
Constructor.
*/
-QPlaceContentReplyImpl::QPlaceContentReplyImpl(const QPlaceContentRequest &request, QPlaceRestReply *reply,
+QPlaceContentReplyImplV1::QPlaceContentReplyImplV1(const QPlaceContentRequest &request, QPlaceRestReply *reply,
QPlaceManager *manager, QObject *parent)
: QPlaceContentReply(parent), restReply(reply), startNumber(0)
@@ -86,22 +86,22 @@ QPlaceContentReplyImpl::QPlaceContentReplyImpl(const QPlaceContentRequest &reque
/*!
Destructor.
*/
-QPlaceContentReplyImpl::~QPlaceContentReplyImpl()
+QPlaceContentReplyImplV1::~QPlaceContentReplyImplV1()
{
}
-void QPlaceContentReplyImpl::abort()
+void QPlaceContentReplyImplV1::abort()
{
if (restReply)
restReply->cancelProcessing();
}
-void QPlaceContentReplyImpl::setStartNumber(int number)
+void QPlaceContentReplyImplV1::setStartNumber(int number)
{
startNumber = number;
}
-void QPlaceContentReplyImpl::restError(QPlaceReply::Error errorId, const QString &errorString)
+void QPlaceContentReplyImplV1::restError(QPlaceReply::Error errorId, const QString &errorString)
{
setError(errorId, errorString);
@@ -112,7 +112,7 @@ void QPlaceContentReplyImpl::restError(QPlaceReply::Error errorId, const QString
emit processingFinished(this);
}
-void QPlaceContentReplyImpl::restError(QPlaceRestReply::Error errorId)
+void QPlaceContentReplyImplV1::restError(QPlaceRestReply::Error errorId)
{
if (errorId == QPlaceRestReply::Canceled) {
this->setError(CancelError, "RequestCanceled");
@@ -126,7 +126,7 @@ void QPlaceContentReplyImpl::restError(QPlaceRestReply::Error errorId)
emit processingFinished(this);
}
-void QPlaceContentReplyImpl::resultReady(const QPlaceJSonParser::Error &errorId,
+void QPlaceContentReplyImplV1::resultReady(const QPlaceJSonParser::Error &errorId,
const QString &errorMessage)
{
if (errorId == QPlaceJSonParser::NoError) {
diff --git a/src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.h b/src/plugins/geoservices/nokia/placesv1/qplacecontentreplyimplv1.h
index 8b19fcc3..beee7ee2 100644
--- a/src/plugins/geoservices/nokia/places/qplacecontentreplyimpl.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacecontentreplyimplv1.h
@@ -60,13 +60,13 @@
QT_BEGIN_NAMESPACE
-class QPlaceContentReplyImpl : public QPlaceContentReply
+class QPlaceContentReplyImplV1 : public QPlaceContentReply
{
Q_OBJECT
public:
- QPlaceContentReplyImpl(const QPlaceContentRequest &request, QPlaceRestReply *reply,
+ QPlaceContentReplyImplV1(const QPlaceContentRequest &request, QPlaceRestReply *reply,
QPlaceManager *manager, QObject *parent = 0);
- ~QPlaceContentReplyImpl();
+ ~QPlaceContentReplyImplV1();
void abort();
void setStartNumber(int number);
diff --git a/src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv1/qplacedetailsreplyimplv1.cpp
index 870487a4..4eafce60 100644
--- a/src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacedetailsreplyimplv1.cpp
@@ -46,18 +46,18 @@
**
****************************************************************************/
-#include "qplacedetailsreplyimpl.h"
+#include "qplacedetailsreplyimplv1.h"
#if defined(QT_PLACES_LOGGING)
#include <QDebug>
#endif
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
/*!
Constructor.
*/
-QPlaceDetailsReplyImpl::QPlaceDetailsReplyImpl(QPlaceRestReply *reply, QPlaceManager *manager, QObject *parent) :
+QPlaceDetailsReplyImplV1::QPlaceDetailsReplyImplV1(QPlaceRestReply *reply, QPlaceManager *manager, QObject *parent) :
QPlaceDetailsReply(parent),
restReply(reply)
{
@@ -76,17 +76,17 @@ QPlaceDetailsReplyImpl::QPlaceDetailsReplyImpl(QPlaceRestReply *reply, QPlaceMan
/*!
Destructor.
*/
-QPlaceDetailsReplyImpl::~QPlaceDetailsReplyImpl()
+QPlaceDetailsReplyImplV1::~QPlaceDetailsReplyImplV1()
{
}
-void QPlaceDetailsReplyImpl::abort()
+void QPlaceDetailsReplyImplV1::abort()
{
if (restReply)
restReply->cancelProcessing();
}
-void QPlaceDetailsReplyImpl::restError(QPlaceRestReply::Error errorId)
+void QPlaceDetailsReplyImplV1::restError(QPlaceRestReply::Error errorId)
{
if (errorId == QPlaceRestReply::Canceled) {
this->setError(CancelError, "RequestCanceled");
@@ -100,7 +100,7 @@ void QPlaceDetailsReplyImpl::restError(QPlaceRestReply::Error errorId)
emit processingFinished(this);
}
-void QPlaceDetailsReplyImpl::resultReady(const QPlaceJSonParser::Error &errorId,
+void QPlaceDetailsReplyImplV1::resultReady(const QPlaceJSonParser::Error &errorId,
const QString &errorMessage)
{
if (errorId == QPlaceJSonParser::NoError) {
@@ -120,3 +120,5 @@ void QPlaceDetailsReplyImpl::resultReady(const QPlaceJSonParser::Error &errorId,
restReply->deleteLater();
restReply = NULL;
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.h b/src/plugins/geoservices/nokia/placesv1/qplacedetailsreplyimplv1.h
index 529be150..bad52df7 100644
--- a/src/plugins/geoservices/nokia/places/qplacedetailsreplyimpl.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacedetailsreplyimplv1.h
@@ -59,12 +59,12 @@
QT_BEGIN_NAMESPACE
-class QPlaceDetailsReplyImpl : public QPlaceDetailsReply
+class QPlaceDetailsReplyImplV1 : public QPlaceDetailsReply
{
Q_OBJECT
public:
- QPlaceDetailsReplyImpl(QPlaceRestReply *reply, QPlaceManager *manager, QObject *parent = 0);
- ~QPlaceDetailsReplyImpl();
+ QPlaceDetailsReplyImplV1(QPlaceRestReply *reply, QPlaceManager *manager, QObject *parent = 0);
+ ~QPlaceDetailsReplyImplV1();
void abort();
Q_SIGNALS:
diff --git a/src/plugins/geoservices/nokia/places/qplacejsoncategoriesparser.cpp b/src/plugins/geoservices/nokia/placesv1/qplacejsoncategoriesparser.cpp
index c0a40d9e..c0a40d9e 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsoncategoriesparser.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacejsoncategoriesparser.cpp
diff --git a/src/plugins/geoservices/nokia/places/qplacejsoncategoriesparser.h b/src/plugins/geoservices/nokia/placesv1/qplacejsoncategoriesparser.h
index f4fb500a..f4fb500a 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsoncategoriesparser.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacejsoncategoriesparser.h
diff --git a/src/plugins/geoservices/nokia/places/qplacejsondetailsparser.cpp b/src/plugins/geoservices/nokia/placesv1/qplacejsondetailsparser.cpp
index 2701c59e..2701c59e 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsondetailsparser.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacejsondetailsparser.cpp
diff --git a/src/plugins/geoservices/nokia/places/qplacejsondetailsparser.h b/src/plugins/geoservices/nokia/placesv1/qplacejsondetailsparser.h
index 8992ce47..8992ce47 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsondetailsparser.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacejsondetailsparser.h
diff --git a/src/plugins/geoservices/nokia/places/qplacejsonmediaparser.cpp b/src/plugins/geoservices/nokia/placesv1/qplacejsonmediaparser.cpp
index 52bde7ee..52bde7ee 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsonmediaparser.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacejsonmediaparser.cpp
diff --git a/src/plugins/geoservices/nokia/places/qplacejsonmediaparser.h b/src/plugins/geoservices/nokia/placesv1/qplacejsonmediaparser.h
index 5501fc90..5501fc90 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsonmediaparser.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacejsonmediaparser.h
diff --git a/src/plugins/geoservices/nokia/places/qplacejsonparser.cpp b/src/plugins/geoservices/nokia/placesv1/qplacejsonparser.cpp
index e222498a..e222498a 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsonparser.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacejsonparser.cpp
diff --git a/src/plugins/geoservices/nokia/places/qplacejsonparser_p.h b/src/plugins/geoservices/nokia/placesv1/qplacejsonparser_p.h
index 83544006..83544006 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsonparser_p.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacejsonparser_p.h
diff --git a/src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.cpp b/src/plugins/geoservices/nokia/placesv1/qplacejsonrecommendationparser.cpp
index fa3e2157..fa3e2157 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacejsonrecommendationparser.cpp
diff --git a/src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.h b/src/plugins/geoservices/nokia/placesv1/qplacejsonrecommendationparser.h
index 5ff02518..5ff02518 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsonrecommendationparser.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacejsonrecommendationparser.h
diff --git a/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.cpp b/src/plugins/geoservices/nokia/placesv1/qplacejsonreviewparser.cpp
index a7c11845..a7c11845 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacejsonreviewparser.cpp
diff --git a/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.h b/src/plugins/geoservices/nokia/placesv1/qplacejsonreviewparser.h
index da8b7dc2..da8b7dc2 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsonreviewparser.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacejsonreviewparser.h
diff --git a/src/plugins/geoservices/nokia/places/qplacejsonsearchparser.cpp b/src/plugins/geoservices/nokia/placesv1/qplacejsonsearchparser.cpp
index 9e4f095a..9e4f095a 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsonsearchparser.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacejsonsearchparser.cpp
diff --git a/src/plugins/geoservices/nokia/places/qplacejsonsearchparser.h b/src/plugins/geoservices/nokia/placesv1/qplacejsonsearchparser.h
index fb673315..fb673315 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsonsearchparser.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacejsonsearchparser.h
diff --git a/src/plugins/geoservices/nokia/places/qplacejsontextpredictionparser.cpp b/src/plugins/geoservices/nokia/placesv1/qplacejsontextpredictionparser.cpp
index d1fc6dd2..d1fc6dd2 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsontextpredictionparser.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacejsontextpredictionparser.cpp
diff --git a/src/plugins/geoservices/nokia/places/qplacejsontextpredictionparser.h b/src/plugins/geoservices/nokia/placesv1/qplacejsontextpredictionparser.h
index 7969752e..7969752e 100644
--- a/src/plugins/geoservices/nokia/places/qplacejsontextpredictionparser.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacejsontextpredictionparser.h
diff --git a/src/plugins/geoservices/nokia/places/qplaceratingreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv1/qplaceratingreplyimpl.cpp
index afc80232..afc80232 100644
--- a/src/plugins/geoservices/nokia/places/qplaceratingreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplaceratingreplyimpl.cpp
diff --git a/src/plugins/geoservices/nokia/places/qplaceratingreplyimpl.h b/src/plugins/geoservices/nokia/placesv1/qplaceratingreplyimpl.h
index 28dac274..28dac274 100644
--- a/src/plugins/geoservices/nokia/places/qplaceratingreplyimpl.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplaceratingreplyimpl.h
diff --git a/src/plugins/geoservices/nokia/places/qplacerecommendationreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv1/qplacerecommendationreplyimplv1.cpp
index 2a6cb936..ebb66a08 100644
--- a/src/plugins/geoservices/nokia/places/qplacerecommendationreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacerecommendationreplyimplv1.cpp
@@ -46,7 +46,7 @@
**
****************************************************************************/
-#include "qplacerecommendationreplyimpl.h"
+#include "qplacerecommendationreplyimplv1.h"
#if defined(QT_PLACES_LOGGING)
#include <QDebug>
@@ -57,7 +57,7 @@ QT_USE_NAMESPACE
/*!
Constructor.
*/
-QPlaceRecommendationReplyImpl::QPlaceRecommendationReplyImpl(QPlaceRestReply *reply, QPlaceManager * manager, QObject *parent) :
+QPlaceRecommendationReplyImplV1::QPlaceRecommendationReplyImplV1(QPlaceRestReply *reply, QPlaceManager * manager, QObject *parent) :
QPlaceSearchReply(parent),
restReply(reply)
{
@@ -77,17 +77,17 @@ QPlaceRecommendationReplyImpl::QPlaceRecommendationReplyImpl(QPlaceRestReply *re
/*!
Destructor.
*/
-QPlaceRecommendationReplyImpl::~QPlaceRecommendationReplyImpl()
+QPlaceRecommendationReplyImplV1::~QPlaceRecommendationReplyImplV1()
{
}
-void QPlaceRecommendationReplyImpl::abort()
+void QPlaceRecommendationReplyImplV1::abort()
{
if (restReply)
restReply->cancelProcessing();
}
-void QPlaceRecommendationReplyImpl::restError(QPlaceRestReply::Error errorId)
+void QPlaceRecommendationReplyImplV1::restError(QPlaceRestReply::Error errorId)
{
if (errorId == QPlaceRestReply::Canceled) {
this->setError(CancelError, "RequestCanceled");
@@ -101,7 +101,7 @@ void QPlaceRecommendationReplyImpl::restError(QPlaceRestReply::Error errorId)
emit processingFinished(this);
}
-void QPlaceRecommendationReplyImpl::resultReady(const QPlaceJSonRecommendationParser::Error &errorId,
+void QPlaceRecommendationReplyImplV1::resultReady(const QPlaceJSonRecommendationParser::Error &errorId,
const QString &errorMessage)
{
if (errorId == QPlaceJSonParser::NoError) {
diff --git a/src/plugins/geoservices/nokia/places/qplacerecommendationreplyimpl.h b/src/plugins/geoservices/nokia/placesv1/qplacerecommendationreplyimplv1.h
index 3ece4b02..9dc37563 100644
--- a/src/plugins/geoservices/nokia/places/qplacerecommendationreplyimpl.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacerecommendationreplyimplv1.h
@@ -58,12 +58,12 @@
QT_BEGIN_NAMESPACE
-class QPlaceRecommendationReplyImpl : public QPlaceSearchReply
+class QPlaceRecommendationReplyImplV1 : public QPlaceSearchReply
{
Q_OBJECT
public:
- QPlaceRecommendationReplyImpl(QPlaceRestReply *reply, QPlaceManager *manager, QObject *parent = 0);
- ~QPlaceRecommendationReplyImpl();
+ QPlaceRecommendationReplyImplV1(QPlaceRestReply *reply, QPlaceManager *manager, QObject *parent = 0);
+ ~QPlaceRecommendationReplyImplV1();
void abort();
Q_SIGNALS:
diff --git a/src/plugins/geoservices/nokia/places/qplacerestmanager.cpp b/src/plugins/geoservices/nokia/placesv1/qplacerestmanager.cpp
index 116a969f..116a969f 100644
--- a/src/plugins/geoservices/nokia/places/qplacerestmanager.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacerestmanager.cpp
diff --git a/src/plugins/geoservices/nokia/places/qplacerestmanager.h b/src/plugins/geoservices/nokia/placesv1/qplacerestmanager.h
index ddc9a8f3..ddc9a8f3 100644
--- a/src/plugins/geoservices/nokia/places/qplacerestmanager.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacerestmanager.h
diff --git a/src/plugins/geoservices/nokia/places/qplacerestreply.cpp b/src/plugins/geoservices/nokia/placesv1/qplacerestreply.cpp
index 535952ea..535952ea 100644
--- a/src/plugins/geoservices/nokia/places/qplacerestreply.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacerestreply.cpp
diff --git a/src/plugins/geoservices/nokia/places/qplacerestreply.h b/src/plugins/geoservices/nokia/placesv1/qplacerestreply.h
index 291adca5..291adca5 100644
--- a/src/plugins/geoservices/nokia/places/qplacerestreply.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacerestreply.h
diff --git a/src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv1/qplacesearchreplyimplv1.cpp
index 3b085d8e..179dac5c 100644
--- a/src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacesearchreplyimplv1.cpp
@@ -46,7 +46,7 @@
**
****************************************************************************/
-#include "qplacesearchreplyimpl.h"
+#include "qplacesearchreplyimplv1.h"
#if defined(QT_PLACES_LOGGING)
#include <QDebug>
@@ -57,7 +57,7 @@ QT_USE_NAMESPACE
/*!
Constructor.
*/
-QPlaceSearchReplyImpl::QPlaceSearchReplyImpl(QPlaceRestReply *reply, QObject *parent) :
+QPlaceSearchReplyImplV1::QPlaceSearchReplyImplV1(QPlaceRestReply *reply, QObject *parent) :
QPlaceSearchReply(parent),
restReply(reply)
{
@@ -77,17 +77,17 @@ QPlaceSearchReplyImpl::QPlaceSearchReplyImpl(QPlaceRestReply *reply, QObject *pa
/*!
Destructor.
*/
-QPlaceSearchReplyImpl::~QPlaceSearchReplyImpl()
+QPlaceSearchReplyImplV1::~QPlaceSearchReplyImplV1()
{
}
-void QPlaceSearchReplyImpl::abort()
+void QPlaceSearchReplyImplV1::abort()
{
if (restReply)
restReply->cancelProcessing();
}
-void QPlaceSearchReplyImpl::setError(QPlaceReply::Error errorId, const QString &errorString)
+void QPlaceSearchReplyImplV1::setError(QPlaceReply::Error errorId, const QString &errorString)
{
QPlaceReply::setError(errorId, errorString);
emit error(this->error(), this->errorString());
@@ -97,7 +97,7 @@ void QPlaceSearchReplyImpl::setError(QPlaceReply::Error errorId, const QString &
emit processingFinished(this);
}
-void QPlaceSearchReplyImpl::restError(QPlaceRestReply::Error errorId)
+void QPlaceSearchReplyImplV1::restError(QPlaceRestReply::Error errorId)
{
if (errorId == QPlaceRestReply::Canceled) {
this->setError(CancelError, "RequestCanceled");
@@ -111,7 +111,7 @@ void QPlaceSearchReplyImpl::restError(QPlaceRestReply::Error errorId)
emit processingFinished(this);
}
-void QPlaceSearchReplyImpl::resultReady(const QPlaceJSonParser::Error &errorId,
+void QPlaceSearchReplyImplV1::resultReady(const QPlaceJSonParser::Error &errorId,
const QString &errorMessage)
{
if (errorId == QPlaceJSonParser::NoError) {
@@ -130,7 +130,7 @@ void QPlaceSearchReplyImpl::resultReady(const QPlaceJSonParser::Error &errorId,
restReply = NULL;
}
-QList<QPlaceSearchResult> QPlaceSearchReplyImpl::filterSecondSearchCenter(const QList<QPlaceSearchResult> &list)
+QList<QPlaceSearchResult> QPlaceSearchReplyImplV1::filterSecondSearchCenter(const QList<QPlaceSearchResult> &list)
{
QList<QPlaceSearchResult> newList;
foreach (QPlaceSearchResult res, list) {
diff --git a/src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.h b/src/plugins/geoservices/nokia/placesv1/qplacesearchreplyimplv1.h
index 2a91c335..be991298 100644
--- a/src/plugins/geoservices/nokia/places/qplacesearchreplyimpl.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacesearchreplyimplv1.h
@@ -58,12 +58,12 @@
QT_BEGIN_NAMESPACE
-class QPlaceSearchReplyImpl : public QPlaceSearchReply
+class QPlaceSearchReplyImplV1 : public QPlaceSearchReply
{
Q_OBJECT
public:
- explicit QPlaceSearchReplyImpl(QPlaceRestReply *reply, QObject *parent = 0);
- ~QPlaceSearchReplyImpl();
+ explicit QPlaceSearchReplyImplV1(QPlaceRestReply *reply, QObject *parent = 0);
+ ~QPlaceSearchReplyImplV1();
void abort();
Q_SIGNALS:
diff --git a/src/plugins/geoservices/nokia/places/qplacesuppliersrepository.cpp b/src/plugins/geoservices/nokia/placesv1/qplacesuppliersrepository.cpp
index 87264020..87264020 100644
--- a/src/plugins/geoservices/nokia/places/qplacesuppliersrepository.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacesuppliersrepository.cpp
diff --git a/src/plugins/geoservices/nokia/places/qplacesuppliersrepository.h b/src/plugins/geoservices/nokia/placesv1/qplacesuppliersrepository.h
index 699f6be8..699f6be8 100644
--- a/src/plugins/geoservices/nokia/places/qplacesuppliersrepository.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacesuppliersrepository.h
diff --git a/src/plugins/geoservices/nokia/places/qplacetextpredictionreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv1/qplacetextpredictionreplyimpl.cpp
index b02a8bad..b02a8bad 100644
--- a/src/plugins/geoservices/nokia/places/qplacetextpredictionreplyimpl.cpp
+++ b/src/plugins/geoservices/nokia/placesv1/qplacetextpredictionreplyimpl.cpp
diff --git a/src/plugins/geoservices/nokia/places/qplacetextpredictionreplyimpl.h b/src/plugins/geoservices/nokia/placesv1/qplacetextpredictionreplyimpl.h
index edf834e1..edf834e1 100644
--- a/src/plugins/geoservices/nokia/places/qplacetextpredictionreplyimpl.h
+++ b/src/plugins/geoservices/nokia/placesv1/qplacetextpredictionreplyimpl.h
diff --git a/src/plugins/geoservices/nokia/places/unsupportedreplies.h b/src/plugins/geoservices/nokia/placesv1/unsupportedreplies.h
index a6ae0b0c..71480c67 100644
--- a/src/plugins/geoservices/nokia/places/unsupportedreplies.h
+++ b/src/plugins/geoservices/nokia/placesv1/unsupportedreplies.h
@@ -42,16 +42,17 @@
#ifndef UNSUPPORTED_REPLIES_H
#define UNSUPPORTED_REPLIES_H
+#include "../qplacemanagerengine_nokiav1.h"
+
#include <QtLocation/QPlaceIdReply>
-#include "../qplacemanagerengine_nokia.h"
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class IdReply : public QPlaceIdReply
{
Q_OBJECT
public:
- IdReply(QPlaceIdReply::OperationType type, QPlaceManagerEngineNokia *engine)
+ IdReply(QPlaceIdReply::OperationType type, QPlaceManagerEngineNokiaV1 *engine)
: QPlaceIdReply(type, engine), m_engine(engine)
{}
virtual ~IdReply() {}
@@ -77,8 +78,10 @@ public:
}
private:
- QPlaceManagerEngineNokia *m_engine;
+ QPlaceManagerEngineNokiaV1 *m_engine;
};
+QT_END_NAMESPACE
+
#endif
diff --git a/src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.cpp b/src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.cpp
new file mode 100644
index 00000000..a201bb73
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.cpp
@@ -0,0 +1,219 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include "jsonparserhelpers.h"
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDateTime>
+#include <QtCore/QJsonObject>
+#include <QtCore/QJsonArray>
+#include <QtCore/QVariantMap>
+#include <QtLocation/QGeoCoordinate>
+#include <QtLocation/QPlaceImage>
+#include <QtLocation/QPlaceReview>
+#include <QtLocation/QPlaceEditorial>
+#include <QtLocation/QPlaceUser>
+#include <QtLocation/QPlaceContactDetail>
+#include <QtLocation/QPlaceCategory>
+
+QT_BEGIN_NAMESPACE
+
+QGeoCoordinate parseCoordinate(const QJsonArray &coordinateArray)
+{
+ return QGeoCoordinate(coordinateArray.at(0).toDouble(), coordinateArray.at(1).toDouble());
+}
+
+QPlaceSupplier parseSupplier(const QJsonObject &supplierObject)
+{
+ QPlaceSupplier supplier;
+ supplier.setName(supplierObject.value(QLatin1String("title")).toString());
+ supplier.setUrl(supplierObject.value(QLatin1String("href")).toString());
+
+ QVariantMap parameters;
+ parameters.insert(QPlaceIcon::SingleUrl,
+ QUrl(supplierObject.value(QLatin1String("icon")).toString()));
+ QPlaceIcon icon;
+ icon.setParameters(parameters);
+ supplier.setIcon(icon);
+
+ return supplier;
+}
+
+QPlaceCategory parseCategory(const QJsonObject &categoryObject)
+{
+ QPlaceCategory category;
+
+ category.setName(categoryObject.value(QLatin1String("title")).toString());
+
+ const QUrl href(categoryObject.value(QLatin1String("href")).toString());
+ category.setCategoryId(href.path().mid(34));
+
+ QVariantMap parameters;
+ parameters.insert(QPlaceIcon::SingleUrl,
+ QUrl(categoryObject.value(QLatin1String("icon")).toString()));
+ QPlaceIcon icon;
+ icon.setParameters(parameters);
+ category.setIcon(icon);
+
+ return category;
+}
+
+QList<QPlaceCategory> parseCategories(const QJsonArray &categoryArray)
+{
+ QList<QPlaceCategory> categoryList;
+ for (int i = 0; i < categoryArray.count(); ++i)
+ categoryList.append(parseCategory(categoryArray.at(i).toObject()));
+
+ return categoryList;
+}
+
+QList<QPlaceContactDetail> parseContactDetails(const QJsonArray &contacts)
+{
+ QList<QPlaceContactDetail> contactDetails;
+
+ for (int i = 0; i < contacts.count(); ++i) {
+ QJsonObject contact = contacts.at(i).toObject();
+
+ QPlaceContactDetail detail;
+ detail.setLabel(contact.value(QLatin1String("label")).toString());
+ detail.setValue(contact.value(QLatin1String("value")).toString());
+
+ contactDetails.append(detail);
+ }
+
+ return contactDetails;
+}
+
+QPlaceImage parseImage(const QJsonObject &imageObject)
+{
+ QPlaceImage image;
+
+ image.setAttribution(imageObject.value(QLatin1String("attribution")).toString());
+ image.setUrl(imageObject.value(QLatin1String("src")).toString());
+ image.setSupplier(parseSupplier(imageObject.value(QLatin1String("supplier")).toObject()));
+
+ return image;
+}
+
+QPlaceReview parseReview(const QJsonObject &reviewObject)
+{
+ QPlaceReview review;
+
+ review.setDateTime(QDateTime::fromString(reviewObject.value(QLatin1String("date")).toString()));
+
+ if (reviewObject.contains(QLatin1String("title")))
+ review.setTitle(reviewObject.value(QLatin1String("title")).toString());
+
+ if (reviewObject.contains(QLatin1String("rating")))
+ review.setRating(reviewObject.value(QLatin1String("rating")).toDouble());
+
+ review.setText(reviewObject.value(QLatin1String("description")).toString());
+
+ QJsonObject userObject = reviewObject.value(QLatin1String("user")).toObject();
+
+ QPlaceUser user;
+ user.setUserId(userObject.value(QLatin1String("id")).toString());
+ user.setName(userObject.value(QLatin1String("title")).toString());
+ review.setUser(user);
+
+ review.setAttribution(reviewObject.value(QLatin1String("attribution")).toString());
+
+ review.setLanguage(reviewObject.value(QLatin1String("language")).toString());
+
+ review.setSupplier(parseSupplier(reviewObject.value(QLatin1String("supplier")).toObject()));
+
+ //if (reviewObject.contains(QLatin1String("via"))) {
+ // QJsonObject viaObject = reviewObject.value(QLatin1String("via")).toObject();
+ //}
+
+ return review;
+}
+
+QPlaceEditorial parseEditorial(const QJsonObject &editorialObject)
+{
+ QPlaceEditorial editorial;
+
+ editorial.setAttribution(editorialObject.value(QLatin1String("attribution")).toString());
+
+ //if (editorialObject.contains(QLatin1String("via"))) {
+ // QJsonObject viaObject = editorialObject.value(QLatin1String("via")).toObject();
+ //}
+
+ editorial.setSupplier(parseSupplier(editorialObject.value(QLatin1String("supplier")).toObject()));
+ editorial.setLanguage(editorialObject.value(QLatin1String("language")).toString());
+ editorial.setText(editorialObject.value(QLatin1String("description")).toString());
+
+ return editorial;
+}
+
+void parseCollection(QPlaceContent::Type type, const QJsonObject &object,
+ QPlaceContent::Collection *collection, int *totalCount)
+{
+ if (totalCount)
+ *totalCount = object.value(QLatin1String("available")).toDouble();
+
+ int offset = 0;
+ if (object.contains(QLatin1String("offset")))
+ offset = object.value(QLatin1String("offset")).toDouble();
+
+ if (collection) {
+ QJsonArray items = object.value(QLatin1String("items")).toArray();
+ for (int i = 0; i < items.count(); ++i) {
+ QJsonObject itemObject = items.at(i).toObject();
+
+ switch (type) {
+ case QPlaceContent::ImageType:
+ collection->insert(offset + i, parseImage(itemObject));
+ break;
+ case QPlaceContent::ReviewType:
+ collection->insert(offset + i, parseReview(itemObject));
+ break;
+ case QPlaceContent::EditorialType:
+ collection->insert(offset + i, parseEditorial(itemObject));
+ break;
+ case QPlaceContent::NoType:
+ break;
+ }
+ }
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.h b/src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.h
new file mode 100644
index 00000000..7efb3f36
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv2/jsonparserhelpers.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#ifndef JSONPARSERHELPERS_H
+#define JSONPARSERHELPERS_H
+
+#include <QtLocation/QPlaceContent>
+
+QT_BEGIN_NAMESPACE
+
+class QJsonArray;
+class QJsonObject;
+class QGeoCoordinate;
+class QPlaceContactDetail;
+class QPlaceImage;
+class QPlaceReview;
+class QPlaceEditorial;
+class QPlaceCategory;
+
+QGeoCoordinate parseCoordinate(const QJsonArray &coordinateArray);
+QPlaceSupplier parseSupplier(const QJsonObject &supplierObject);
+QPlaceCategory parseCategory(const QJsonObject &categoryObject);
+QList<QPlaceCategory> parseCategories(const QJsonArray &categoryArray);
+QList<QPlaceContactDetail> parseContactDetails(const QJsonArray &contacts);
+
+QPlaceImage parseImage(const QJsonObject &imageObject);
+QPlaceReview parseReview(const QJsonObject &reviewObject);
+QPlaceEditorial parseEditorial(const QJsonObject &editorialObject);
+
+void parseCollection(QPlaceContent::Type type, const QJsonObject &object,
+ QPlaceContent::Collection *collection, int *totalCount);
+
+QT_END_NAMESPACE
+
+#endif // JSONPARSERHELPERS_H
diff --git a/src/plugins/geoservices/nokia/placesv2/placesv2.pri b/src/plugins/geoservices/nokia/placesv2/placesv2.pri
new file mode 100644
index 00000000..43835f65
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv2/placesv2.pri
@@ -0,0 +1,23 @@
+QT *= location network
+
+HEADERS += \
+ qplacemanagerengine_nokiav2.h \
+ placesv2/qplacecategoriesreplyimpl.h \
+ placesv2/qplacecontentreplyimpl.h \
+ placesv2/qplacedetailsreplyimpl.h \
+ placesv2/qplaceidreplyimpl.h \
+ placesv2/qplacerecommendationreplyimpl.h \
+ placesv2/qplacesearchreplyimpl.h \
+ placesv2/qplacesearchsuggestionreplyimpl.h \
+ placesv2/jsonparserhelpers.h
+
+SOURCES += \
+ qplacemanagerengine_nokiav2.cpp \
+ placesv2/qplacecategoriesreplyimpl.cpp \
+ placesv2/qplacecontentreplyimpl.cpp \
+ placesv2/qplacedetailsreplyimpl.cpp \
+ placesv2/qplaceidreplyimpl.cpp \
+ placesv2/qplacerecommendationreplyimpl.cpp \
+ placesv2/qplacesearchreplyimpl.cpp \
+ placesv2/qplacesearchsuggestionreplyimpl.cpp \
+ placesv2/jsonparserhelpers.cpp
diff --git a/src/plugins/geoservices/nokia/placesv2/qplacecategoriesreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacecategoriesreplyimpl.cpp
new file mode 100644
index 00000000..810ce771
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv2/qplacecategoriesreplyimpl.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include "qplacecategoriesreplyimpl.h"
+
+QT_BEGIN_NAMESPACE
+
+QPlaceCategoriesReplyImpl::QPlaceCategoriesReplyImpl(QObject *parent)
+: QPlaceReply(parent)
+{
+}
+
+QPlaceCategoriesReplyImpl::~QPlaceCategoriesReplyImpl()
+{
+}
+
+void QPlaceCategoriesReplyImpl::emitFinished()
+{
+ setFinished(true);
+ emit finished();
+}
+
+void QPlaceCategoriesReplyImpl::setError(QPlaceReply::Error error_, const QString &errorString)
+{
+ QPlaceReply::setError(error_, errorString);
+ emit error(error_, errorString);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/placesv2/qplacecategoriesreplyimpl.h b/src/plugins/geoservices/nokia/placesv2/qplacecategoriesreplyimpl.h
new file mode 100644
index 00000000..587d884e
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv2/qplacecategoriesreplyimpl.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#ifndef QPLACECATEGORIESREPLYIMPL_H
+#define QPLACECATEGORIESREPLYIMPL_H
+
+#include <QtLocation/QPlaceReply>
+
+QT_BEGIN_NAMESPACE
+
+class QPlaceCategoriesReplyImpl : public QPlaceReply
+{
+ Q_OBJECT
+
+public:
+ explicit QPlaceCategoriesReplyImpl(QObject *parent = 0);
+ ~QPlaceCategoriesReplyImpl();
+
+ void emitFinished();
+
+private slots:
+ void setError(QPlaceReply::Error error_, const QString &errorString);
+};
+
+QT_END_NAMESPACE
+
+#endif // QPLACECATEGORIESREPLYIMPL_H
diff --git a/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp
new file mode 100644
index 00000000..f6dda4bd
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.cpp
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** 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 "qplacecontentreplyimpl.h"
+#include "jsonparserhelpers.h"
+
+#include <QtCore/QJsonDocument>
+#include <QtCore/QJsonObject>
+
+QT_BEGIN_NAMESPACE
+
+QPlaceContentReplyImpl::QPlaceContentReplyImpl(const QPlaceContentRequest &request,
+ QNetworkReply *reply, QObject *parent)
+: QPlaceContentReply(parent), m_reply(reply)
+
+{
+ setRequest(request);
+
+ if (!m_reply)
+ return;
+
+ m_reply->setParent(this);
+ connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished()));
+ connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)),
+ this, SLOT(replyError(QNetworkReply::NetworkError)));
+}
+
+QPlaceContentReplyImpl::~QPlaceContentReplyImpl()
+{
+}
+
+void QPlaceContentReplyImpl::abort()
+{
+ if (m_reply)
+ m_reply->abort();
+}
+
+void QPlaceContentReplyImpl::setError(QPlaceReply::Error error_, const QString &errorString)
+{
+ QPlaceContentReply::setError(error_, errorString);
+ emit error(error_, errorString);
+ setFinished(true);
+ emit finished();
+}
+
+void QPlaceContentReplyImpl::replyFinished()
+{
+ QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll());
+ if (!document.isObject()) {
+ setError(ParseError, tr("Error parsing response."));
+ return;
+ }
+
+ QJsonObject object = document.object();
+
+ QPlaceContent::Collection collection;
+ int totalCount;
+
+ parseCollection(request().contentType(), object, &collection, &totalCount);
+
+ setTotalCount(totalCount);
+ setContent(collection);
+
+ m_reply->deleteLater();
+ m_reply = 0;
+
+ setFinished(true);
+ emit finished();
+}
+
+void QPlaceContentReplyImpl::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/qplacecontentreplyimpl.h b/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.h
new file mode 100644
index 00000000..3347d1de
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv2/qplacecontentreplyimpl.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** 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 QPLACECONTENTREPLYIMPL_H
+#define QPLACECONTENTREPLYIMPL_H
+
+#include <QtNetwork/QNetworkReply>
+#include <QtLocation/QPlaceContentReply>
+
+QT_BEGIN_NAMESPACE
+
+class QPlaceManager;
+
+class QPlaceContentReplyImpl : public QPlaceContentReply
+{
+ Q_OBJECT
+
+public:
+ QPlaceContentReplyImpl(const QPlaceContentRequest &request, QNetworkReply *reply,
+ QObject *parent = 0);
+ ~QPlaceContentReplyImpl();
+
+ void abort();
+
+private slots:
+ void setError(QPlaceReply::Error error_, const QString &errorString);
+ void replyFinished();
+ void replyError(QNetworkReply::NetworkError error);
+
+private:
+ QPlaceManager *m_manager;
+ QNetworkReply *m_reply;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp
new file mode 100644
index 00000000..fe3068e3
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.cpp
@@ -0,0 +1,345 @@
+/****************************************************************************
+**
+** 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 "qplacedetailsreplyimpl.h"
+#include "jsonparserhelpers.h"
+
+#include <QtCore/QJsonDocument>
+#include <QtCore/QJsonObject>
+#include <QtCore/QJsonArray>
+#include <QtNetwork/QNetworkReply>
+#include <QtLocation/QPlaceManager>
+#include <QtLocation/QPlaceSupplier>
+#include <QtLocation/QPlaceImage>
+#include <QtLocation/QPlaceEditorial>
+#include <QtLocation/QPlaceReview>
+#include <QtLocation/QPlaceUser>
+
+QT_BEGIN_NAMESPACE
+
+// These countries format the street address as: {house number} {street name}
+// All other countries format it as: {street name} {house number}
+static const char COUNTRY_TABLE_string[] =
+ "CAN\0"
+ "NZL\0"
+ "GBR\0"
+ "AUS\0"
+ "LKA\0"
+ "USA\0"
+ "SGP\0"
+ "FRA\0"
+ "BHS\0"
+ "CHN\0"
+ "IND\0"
+ "IRL\0"
+ "ARE\0"
+ "\0";
+
+static const int COUNTRY_TABLE_indices[] = {
+ 0, 4, 8, 12, 16, 20, 24, 28,
+ 32, 36, 40, 44, 48, -1
+};
+
+static bool countryTableContains(const QString &countryCode)
+{
+ for (int i = 0; COUNTRY_TABLE_indices[i] != -1; ++i) {
+ if (countryCode == QLatin1String(COUNTRY_TABLE_string + COUNTRY_TABLE_indices[i]))
+ return true;
+ }
+
+ return false;
+}
+
+QPlaceDetailsReplyImpl::QPlaceDetailsReplyImpl(QNetworkReply *reply, QObject *parent)
+: QPlaceDetailsReply(parent), m_reply(reply)
+{
+ if (!m_reply)
+ return;
+
+ m_reply->setParent(this);
+ connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished()));
+ connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)),
+ this, SLOT(replyError(QNetworkReply::NetworkError)));
+}
+
+QPlaceDetailsReplyImpl::~QPlaceDetailsReplyImpl()
+{
+}
+
+void QPlaceDetailsReplyImpl::abort()
+{
+ if (m_reply)
+ m_reply->abort();
+}
+
+void QPlaceDetailsReplyImpl::setError(QPlaceReply::Error error_, const QString &errorString)
+{
+ QPlaceReply::setError(error_, errorString);
+ emit error(error_, errorString);
+ setFinished(true);
+ emit finished();
+}
+
+void QPlaceDetailsReplyImpl::replyFinished()
+{
+ QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll());
+ if (!document.isObject()) {
+ setError(ParseError, tr("Error parsing response."));
+ return;
+ }
+
+ QJsonObject object = document.object();
+
+ QPlace place;
+
+ place.setPlaceId(object.value(QLatin1String("placeId")).toString());
+
+ //const QString refId = object.value(QLatin1String("refId")).toString();
+ //const QUrl view = object.value(QLatin1String("view")).toString();
+
+ place.setName(object.value(QLatin1String("name")).toString());
+
+ //if (object.contains(QLatin1String("distance")))
+ // double distance = object.value(QLatin1String("distance")).toDouble();
+
+ //if (object.contains(QLatin1String("alternativeNames"))) {
+ // QJsonArray alternativeNames = object.value(QLatin1String("alternativeNames")).toArray();
+ //}
+
+ QGeoLocation location;
+
+ QJsonObject locationObject = object.value(QLatin1String("location")).toObject();
+
+ //if (locationObject.contains(QLatin1String("locationId")))
+ // const QString locationId = locationObject.value(QLatin1String("locationId")).toString();
+
+ QJsonArray position = locationObject.value(QLatin1String("position")).toArray();
+ location.setCoordinate(QGeoCoordinate(position.at(0).toDouble(), position.at(1).toDouble()));
+
+ QGeoAddress address;
+
+ QJsonObject addressObject = locationObject.value(QLatin1String("address")).toObject();
+
+ address.setFormattedAddress(addressObject.value(QLatin1String("text")).toString());
+
+ address.setCountry(addressObject.value(QLatin1String("country")).toString());
+ address.setCountryCode(addressObject.value(QLatin1String("countryCode")).toString());
+
+ QString house;
+ QString street;
+
+ if (addressObject.contains(QLatin1String("house")))
+ house = addressObject.value(QLatin1String("house")).toString();
+ if (addressObject.contains(QLatin1String("street")))
+ street = addressObject.value(QLatin1String("street")).toString();
+
+ if (countryTableContains(address.countryCode())) {
+ if (!house.isEmpty() && !street.startsWith(house))
+ street = house + QLatin1Char(' ') + street;
+ } else {
+ if (!house.isEmpty() && !street.endsWith(house))
+ street += QLatin1Char(' ') + house;
+ }
+
+ address.setStreet(street);
+
+ if (addressObject.contains(QLatin1String("city")))
+ address.setCity(addressObject.value(QLatin1String("city")).toString());
+ if (addressObject.contains(QLatin1String("district")))
+ address.setDistrict(addressObject.value(QLatin1String("district")).toString());
+ if (addressObject.contains(QLatin1String("state")))
+ address.setState(addressObject.value(QLatin1String("state")).toString());
+ if (addressObject.contains(QLatin1String("county")))
+ address.setCounty(addressObject.value(QLatin1String("county")).toString());
+ if (addressObject.contains(QLatin1String("postalCode")))
+ address.setPostalCode(addressObject.value(QLatin1String("postalCode")).toString());
+
+ location.setAddress(address);
+
+ if (locationObject.contains(QLatin1String("bbox"))) {
+ QJsonArray bbox = locationObject.value(QLatin1String("bbox")).toArray();
+ QGeoBoundingBox box(QGeoCoordinate(bbox.at(3).toDouble(), bbox.at(0).toDouble()),
+ QGeoCoordinate(bbox.at(1).toDouble(), bbox.at(2).toDouble()));
+ location.setBoundingBox(box);
+ }
+
+ place.setLocation(location);
+
+ place.setCategories(parseCategories(object.value(QLatin1String("categories")).toArray()));
+
+ QVariantMap parameters;
+ parameters.insert(QPlaceIcon::SingleUrl, QUrl(object.value(QLatin1String("icon")).toString()));
+ QPlaceIcon icon;
+ icon.setParameters(parameters);
+ place.setIcon(icon);
+
+ if (object.contains(QLatin1String("contacts"))) {
+ QJsonObject contactsObject = object.value(QLatin1String("contacts")).toObject();
+
+ if (contactsObject.contains(QLatin1String("phone"))) {
+ place.setContactDetails(QPlaceContactDetail::Phone,
+ parseContactDetails(contactsObject.value(QLatin1String("phone")).toArray()));
+ }
+ if (contactsObject.contains(QLatin1String("fax"))) {
+ place.setContactDetails(QPlaceContactDetail::Fax,
+ parseContactDetails(contactsObject.value(QLatin1String("fax")).toArray()));
+ }
+ if (contactsObject.contains(QLatin1String("website"))) {
+ place.setContactDetails(QPlaceContactDetail::Website,
+ parseContactDetails(contactsObject.value(QLatin1String("website")).toArray()));
+ }
+ if (contactsObject.contains(QLatin1String("email"))) {
+ place.setContactDetails(QPlaceContactDetail::Email,
+ parseContactDetails(contactsObject.value(QLatin1String("email")).toArray()));
+ }
+ }
+
+ //if (object.contains(QLatin1String("verifiedByOwner")))
+ // bool verifiedByOwner = object.value(QLatin1String("verifiedByOwner")).toBool();
+
+ if (object.contains(QLatin1String("attribution")))
+ place.setAttribution(object.value(QLatin1String("attribution")).toString());
+
+ if (object.contains(QLatin1String("supplier")))
+ place.setSupplier(parseSupplier(object.value(QLatin1String("supplier")).toObject()));
+
+ if (object.contains(QLatin1String("ratings"))) {
+ QJsonObject ratingsObject = object.value(QLatin1String("ratings")).toObject();
+
+ QPlaceRatings ratings;
+ ratings.setAverage(ratingsObject.value(QLatin1String("average")).toDouble());
+ ratings.setCount(ratingsObject.value(QLatin1String("count")).toString().toInt());
+ ratings.setMaximum(5.0);
+
+ place.setRatings(ratings);
+ }
+
+ if (object.contains(QLatin1String("extended"))) {
+ QJsonObject extendedObject = object.value(QLatin1String("extended")).toObject();
+
+ foreach (const QString &key, extendedObject.keys()) {
+ QJsonObject attributeObject = extendedObject.value(key).toObject();
+
+ QPlaceAttribute attribute;
+
+ attribute.setLabel(attributeObject.value(QLatin1String("label")).toString());
+ attribute.setText(attributeObject.value(QLatin1String("text")).toString());
+
+ if (key == QLatin1String("payment"))
+ place.setExtendedAttribute(QPlaceAttribute::Payment, attribute);
+ else if (key == QLatin1String("openingHours"))
+ place.setExtendedAttribute(QPlaceAttribute::OpeningHours, attribute);
+ else
+ place.setExtendedAttribute(key, attribute);
+ }
+ }
+
+ if (object.contains(QLatin1String("media"))) {
+ QJsonObject mediaObject = object.value(QLatin1String("media")).toObject();
+
+ if (mediaObject.contains(QLatin1String("images"))) {
+ QPlaceContent::Collection collection;
+ int totalCount = 0;
+
+ parseCollection(QPlaceContent::ImageType,
+ mediaObject.value(QLatin1String("images")).toObject(),
+ &collection, &totalCount);
+
+ place.setTotalContentCount(QPlaceContent::ImageType, totalCount);
+ place.setContent(QPlaceContent::ImageType, collection);
+ }
+ if (mediaObject.contains(QLatin1String("editorials"))) {
+ QPlaceContent::Collection collection;
+ int totalCount = 0;
+
+ parseCollection(QPlaceContent::EditorialType,
+ mediaObject.value(QLatin1String("editorials")).toObject(),
+ &collection, &totalCount);
+
+ place.setTotalContentCount(QPlaceContent::EditorialType, totalCount);
+ place.setContent(QPlaceContent::EditorialType, collection);
+ }
+ if (mediaObject.contains(QLatin1String("reviews"))) {
+ QPlaceContent::Collection collection;
+ int totalCount = 0;
+
+ parseCollection(QPlaceContent::ReviewType,
+ mediaObject.value(QLatin1String("reviews")).toObject(),
+ &collection, &totalCount);
+
+ place.setTotalContentCount(QPlaceContent::ReviewType, totalCount);
+ place.setContent(QPlaceContent::ReviewType, collection);
+ }
+ }
+
+ //if (object.contains(QLatin1String("related"))) {
+ // QJsonObject relatedObject = object.value(QLatin1String("related")).toObject();
+ //}
+
+ place.setDetailsFetched(true);
+ setPlace(place);
+
+ m_reply->deleteLater();
+ m_reply = 0;
+
+ setFinished(true);
+ emit finished();
+}
+
+void QPlaceDetailsReplyImpl::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/qplacedetailsreplyimpl.h b/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.h
new file mode 100644
index 00000000..0e1a5767
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv2/qplacedetailsreplyimpl.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** 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 QPLACEDETAILSREPLYIMPL_H
+#define QPLACEDETAILSREPLYIMPL_H
+
+#include <QtNetwork/QNetworkReply>
+#include <QtLocation/QPlaceDetailsReply>
+
+QT_BEGIN_NAMESPACE
+
+class QPlaceManager;
+
+class QPlaceDetailsReplyImpl : public QPlaceDetailsReply
+{
+ Q_OBJECT
+
+public:
+ QPlaceDetailsReplyImpl(QNetworkReply *reply, QObject *parent = 0);
+ ~QPlaceDetailsReplyImpl();
+
+ void abort();
+
+private slots:
+ void setError(QPlaceReply::Error error_, const QString &errorString);
+ void replyFinished();
+ void replyError(QNetworkReply::NetworkError error);
+
+private:
+ QNetworkReply *m_reply;
+};
+
+QT_END_NAMESPACE
+
+#endif // QPLACEDETAILSREPLYIMPL_H
diff --git a/src/plugins/geoservices/nokia/placesv2/qplaceidreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplaceidreplyimpl.cpp
new file mode 100644
index 00000000..e375038d
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv2/qplaceidreplyimpl.cpp
@@ -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$
+**
+****************************************************************************/
+
+#include "qplaceidreplyimpl.h"
+
+QT_BEGIN_NAMESPACE
+
+QPlaceIdReplyImpl::QPlaceIdReplyImpl(QPlaceIdReply::OperationType type, QObject *parent)
+: QPlaceIdReply(type, parent)
+{
+}
+
+QPlaceIdReplyImpl::~QPlaceIdReplyImpl()
+{
+}
+
+void QPlaceIdReplyImpl::setId(const QString &id)
+{
+ QPlaceIdReply::setId(id);
+}
+
+void QPlaceIdReplyImpl::setError(QPlaceReply::Error error_, const QString &errorString)
+{
+ QPlaceIdReply::setError(error_, errorString);
+ emit error(error_, errorString);
+ setFinished(true);
+ emit finished();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/placesv2/qplaceidreplyimpl.h b/src/plugins/geoservices/nokia/placesv2/qplaceidreplyimpl.h
new file mode 100644
index 00000000..d52dc92c
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv2/qplaceidreplyimpl.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#ifndef UNSUPPORTED_REPLIES_H
+#define UNSUPPORTED_REPLIES_H
+
+#include <QtLocation/QPlaceIdReply>
+
+QT_BEGIN_NAMESPACE
+
+class QPlaceIdReplyImpl : public QPlaceIdReply
+{
+ Q_OBJECT
+
+public:
+ QPlaceIdReplyImpl(QPlaceIdReply::OperationType type, QObject *parent = 0);
+ ~QPlaceIdReplyImpl();
+
+ void setId(const QString &id);
+
+private slots:
+ void setError(QPlaceReply::Error error_, const QString &errorString);
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/geoservices/nokia/placesv2/qplacerecommendationreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacerecommendationreplyimpl.cpp
new file mode 100644
index 00000000..2d09375d
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv2/qplacerecommendationreplyimpl.cpp
@@ -0,0 +1,175 @@
+/****************************************************************************
+**
+** 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 "qplacerecommendationreplyimpl.h"
+#include "jsonparserhelpers.h"
+
+#include <QtCore/QJsonDocument>
+#include <QtCore/QJsonObject>
+#include <QtCore/QJsonArray>
+#include <QtLocation/QPlaceIcon>
+
+QT_BEGIN_NAMESPACE
+
+QPlaceRecommendationReplyImpl::QPlaceRecommendationReplyImpl(QNetworkReply *reply, QObject *parent)
+: QPlaceSearchReply(parent), m_reply(reply)
+{
+ if (!m_reply)
+ return;
+
+ m_reply->setParent(this);
+ connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished()));
+ connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)),
+ this, SLOT(replyError(QNetworkReply::NetworkError)));
+}
+
+QPlaceRecommendationReplyImpl::~QPlaceRecommendationReplyImpl()
+{
+}
+
+void QPlaceRecommendationReplyImpl::abort()
+{
+ if (m_reply)
+ m_reply->abort();
+}
+
+void QPlaceRecommendationReplyImpl::setError(QPlaceReply::Error error_, const QString &errorString)
+{
+ QPlaceReply::setError(error_, errorString);
+ emit error(error_, errorString);
+ setFinished(true);
+ emit finished();
+}
+
+void QPlaceRecommendationReplyImpl::replyFinished()
+{
+ QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll());
+ if (!document.isObject()) {
+ setError(ParseError, tr("Error parsing response."));
+ emit error(error(), errorString());
+ return;
+ }
+
+ QJsonObject object = document.object();
+
+ //const QUrl next = object.value(QLatin1String("next")).toString();
+
+ QJsonArray items = object.value(QLatin1String("items")).toArray();
+
+ QList<QPlaceSearchResult> results;
+ for (int i = 0; i < items.count(); ++i) {
+ QJsonObject item = items.at(i).toObject();
+
+ QPlaceSearchResult result;
+
+ result.setType(QPlaceSearchResult::PlaceResult);
+
+ result.setDistance(item.value(QLatin1String("distance")).toDouble());
+
+ QPlace place;
+
+ QGeoLocation location;
+
+ location.setCoordinate(parseCoordinate(item.value(QLatin1String("position")).toArray()));
+
+ const QString vicinity = item.value(QLatin1String("vicinity")).toString();
+ QGeoAddress address;
+ address.setFormattedAddress(vicinity);
+ location.setAddress(address);
+
+ place.setLocation(location);
+
+ QPlaceRatings ratings;
+ ratings.setAverage(item.value(QLatin1String("averageRating")).toDouble());
+ ratings.setMaximum(5.0);
+ place.setRatings(ratings);
+
+ place.setName(item.value(QLatin1String("title")).toString());
+
+ QVariantMap parameters;
+ parameters.insert(QPlaceIcon::SingleUrl,
+ QUrl(item.value(QLatin1String("icon")).toString()));
+ QPlaceIcon icon;
+ icon.setParameters(parameters);
+ place.setIcon(icon);
+
+ place.setCategories(parseCategories(item.value(QLatin1String("categories")).toArray()));
+
+ //QJsonArray having = item.value(QLatin1String("having")).toArray();
+
+ QUrl href = item.value(QLatin1String("href")).toString();
+ place.setPlaceId(href.path().mid(18, 41));
+
+ //const QString refId = item.value(QLatin1String("refId")).toString();
+
+ result.setPlace(place);
+
+ results.append(result);
+ }
+
+ setResults(results);
+
+ m_reply->deleteLater();
+ m_reply = 0;
+
+ setFinished(true);
+ emit finished();
+}
+
+void QPlaceRecommendationReplyImpl::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/qplacerecommendationreplyimpl.h b/src/plugins/geoservices/nokia/placesv2/qplacerecommendationreplyimpl.h
new file mode 100644
index 00000000..2582043c
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv2/qplacerecommendationreplyimpl.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** 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 QPLACERECOMMENDATIONREPLYIMPL_H
+#define QPLACERECOMMENDATIONREPLYIMPL_H
+
+#include <QtNetwork/QNetworkReply>
+#include <QtLocation/QPlaceSearchReply>
+
+QT_BEGIN_NAMESPACE
+
+class QPlaceManager;
+
+class QPlaceRecommendationReplyImpl : public QPlaceSearchReply
+{
+ Q_OBJECT
+
+public:
+ QPlaceRecommendationReplyImpl(QNetworkReply *reply, QObject *parent = 0);
+ ~QPlaceRecommendationReplyImpl();
+
+ void abort();
+
+private slots:
+ void setError(QPlaceReply::Error error_, const QString &errorString);
+ void replyFinished();
+ void replyError(QNetworkReply::NetworkError error);
+
+private:
+ QNetworkReply *m_reply;
+};
+
+QT_END_NAMESPACE
+
+#endif // QPLACERECOMMENDATIONREPLYIMPL_H
diff --git a/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.cpp
new file mode 100644
index 00000000..ea8d1075
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.cpp
@@ -0,0 +1,190 @@
+/****************************************************************************
+**
+** 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 "qplacesearchreplyimpl.h"
+#include "jsonparserhelpers.h"
+
+#include <QtCore/QJsonDocument>
+#include <QtCore/QJsonObject>
+#include <QtCore/QJsonArray>
+#include <QtLocation/QPlaceIcon>
+
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+QPlaceSearchReplyImpl::QPlaceSearchReplyImpl(QNetworkReply *reply, QObject *parent)
+: QPlaceSearchReply(parent), m_reply(reply)
+{
+ if (!m_reply)
+ return;
+
+ m_reply->setParent(this);
+ connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished()));
+ connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)),
+ this, SLOT(replyError(QNetworkReply::NetworkError)));
+}
+
+QPlaceSearchReplyImpl::~QPlaceSearchReplyImpl()
+{
+}
+
+void QPlaceSearchReplyImpl::abort()
+{
+ if (m_reply)
+ m_reply->abort();
+}
+
+void QPlaceSearchReplyImpl::setError(QPlaceReply::Error error_, const QString &errorString)
+{
+ QPlaceReply::setError(error_, errorString);
+ emit error(error_, errorString);
+ setFinished(true);
+ emit finished();
+}
+
+void QPlaceSearchReplyImpl::replyFinished()
+{
+ QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll());
+ if (!document.isObject()) {
+ setError(ParseError, tr("Error parsing response."));
+ emit error(error(), errorString());
+ return;
+ }
+
+ QJsonObject object = document.object();
+
+ //QJsonObject searchObject = object.value(QLatin1String("search")).toObject();
+
+ QJsonObject resultsObject = object.value(QLatin1String("results")).toObject();
+ QJsonArray items = resultsObject.value(QLatin1String("items")).toArray();
+
+ QList<QPlaceSearchResult> results;
+ for (int i = 0; i < items.count(); ++i) {
+ QJsonObject item = items.at(i).toObject();
+
+ QPlaceSearchResult result;
+
+ result.setType(QPlaceSearchResult::PlaceResult);
+
+ if (item.contains(QLatin1String("distance")))
+ result.setDistance(item.value(QLatin1String("distance")).toDouble());
+
+ QPlace place;
+
+ QGeoLocation location;
+
+ location.setCoordinate(parseCoordinate(item.value(QLatin1String("position")).toArray()));
+
+ const QString vicinity = item.value(QLatin1String("vicinity")).toString();
+ QGeoAddress address;
+ address.setFormattedAddress(vicinity);
+ location.setAddress(address);
+
+ if (item.contains(QLatin1String("bbox"))) {
+ QJsonArray bbox = item.value(QLatin1String("bbox")).toArray();
+ QGeoBoundingBox box(QGeoCoordinate(bbox.at(3).toDouble(), bbox.at(0).toDouble()),
+ QGeoCoordinate(bbox.at(1).toDouble(), bbox.at(2).toDouble()));
+ location.setBoundingBox(box);
+ }
+
+ place.setLocation(location);
+
+ QPlaceRatings ratings;
+ ratings.setAverage(item.value(QLatin1String("averageRating")).toDouble());
+ ratings.setMaximum(5.0);
+ place.setRatings(ratings);
+
+ place.setName(item.value(QLatin1String("title")).toString());
+
+ QVariantMap parameters;
+ parameters.insert(QPlaceIcon::SingleUrl,
+ QUrl(item.value(QLatin1String("icon")).toString()));
+ QPlaceIcon icon;
+ icon.setParameters(parameters);
+ place.setIcon(icon);
+
+ place.setCategory(parseCategory(item.value(QLatin1String("category")).toObject()));
+
+ //QJsonArray having = item.value(QLatin1String("having")).toArray();
+
+ //bool sponsored = item.value(QLatin1String("sponsored")).toBool();
+
+ QUrl href = item.value(QLatin1String("href")).toString();
+ //QUrl type = item.value(QLatin1String("type")).toString();
+
+ place.setPlaceId(href.path().mid(18, 41));
+
+ //const QString refId = item.value(QLatin1String("refId")).toString();
+
+ result.setPlace(place);
+
+ results.append(result);
+ }
+
+ setResults(results);
+
+ m_reply->deleteLater();
+ m_reply = 0;
+
+ setFinished(true);
+ emit finished();
+}
+
+void QPlaceSearchReplyImpl::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/qplacesearchreplyimpl.h b/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.h
new file mode 100644
index 00000000..8d9b2e40
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv2/qplacesearchreplyimpl.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** 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 QPLACESEARCHREPLYIMPL_H
+#define QPLACESEARCHREPLYIMPL_H
+
+#include <QtNetwork/QNetworkReply>
+#include <QtLocation/QPlaceSearchReply>
+
+QT_BEGIN_NAMESPACE
+
+class QPlaceSearchReplyImpl : public QPlaceSearchReply
+{
+ Q_OBJECT
+
+public:
+ explicit QPlaceSearchReplyImpl(QNetworkReply *reply, QObject *parent = 0);
+ ~QPlaceSearchReplyImpl();
+
+ void abort();
+
+private slots:
+ void setError(QPlaceReply::Error error_, const QString &errorString);
+ void replyFinished();
+ void replyError(QNetworkReply::NetworkError error);
+
+private:
+ QNetworkReply *m_reply;
+};
+
+QT_END_NAMESPACE
+
+#endif // QPLACESEARCHREPLYIMPL_H
diff --git a/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp b/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp
new file mode 100644
index 00000000..bd5e86e1
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.cpp
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** 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 "qplacesearchsuggestionreplyimpl.h"
+
+#include <QtCore/QJsonDocument>
+#include <QtCore/QJsonObject>
+#include <QtCore/QJsonArray>
+
+QT_BEGIN_NAMESPACE
+
+QPlaceSearchSuggestionReplyImpl::QPlaceSearchSuggestionReplyImpl(QNetworkReply *reply,
+ QObject *parent)
+: QPlaceSearchSuggestionReply(parent), m_reply(reply)
+{
+ if (!m_reply)
+ return;
+
+ 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()
+{
+}
+
+void QPlaceSearchSuggestionReplyImpl::abort()
+{
+ if (m_reply)
+ m_reply->abort();
+}
+
+void QPlaceSearchSuggestionReplyImpl::setError(QPlaceReply::Error error_,
+ const QString &errorString)
+{
+ QPlaceReply::setError(error_, errorString);
+ emit error(error_, errorString);
+ setFinished(true);
+ emit finished();
+}
+
+void QPlaceSearchSuggestionReplyImpl::replyFinished()
+{
+ QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll());
+ if (!document.isObject()) {
+ setError(ParseError, tr("Error parsing response."));
+ emit error(error(), errorString());
+ return;
+ }
+
+ QJsonObject object = document.object();
+
+ QJsonArray suggestions = object.value(QLatin1String("suggestions")).toArray();
+
+ QStringList s;
+ for (int i = 0; i < suggestions.count(); ++i) {
+ QJsonValue v = suggestions.at(i);
+ if (v.isString())
+ s.append(v.toString());
+ }
+
+ setSuggestions(s);
+
+ m_reply->deleteLater();
+ m_reply = 0;
+
+ setFinished(true);
+ 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
new file mode 100644
index 00000000..2cbbbef3
--- /dev/null
+++ b/src/plugins/geoservices/nokia/placesv2/qplacesearchsuggestionreplyimpl.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** 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 QPLACESEARCHSUGGESTIONREPLYIMPL_H
+#define QPLACESEARCHSUGGESTIONREPLYIMPL_H
+
+#include <QtNetwork/QNetworkReply>
+#include <QtLocation/QPlaceSearchSuggestionReply>
+
+QT_BEGIN_NAMESPACE
+
+class QPlaceSearchSuggestionReplyImpl : public QPlaceSearchSuggestionReply
+{
+ Q_OBJECT
+
+public:
+ explicit QPlaceSearchSuggestionReplyImpl(QNetworkReply *reply, QObject *parent = 0);
+ ~QPlaceSearchSuggestionReplyImpl();
+
+ void abort();
+
+private slots:
+ void setError(QPlaceReply::Error error_, const QString &errorString);
+ void replyFinished();
+ void replyError(QNetworkReply::NetworkError error);
+
+private:
+ QNetworkReply *m_reply;
+};
+
+QT_END_NAMESPACE
+
+#endif // QPLACESEARCHSUGGESTIONREPLYIMPL_H
diff --git a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp
index 6f89e3d5..da0f45a8 100644
--- a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp
@@ -51,7 +51,8 @@
#include "qgeocodingmanagerengine_nokia.h"
#include "qgeoroutingmanagerengine_nokia.h"
#include "qgeomappingmanagerengine_nokia.h"
-#include "qplacemanagerengine_nokia.h"
+#include "qplacemanagerengine_nokiav1.h"
+#include "qplacemanagerengine_nokiav2.h"
#include <QtPlugin>
#include <QNetworkProxy>
@@ -102,7 +103,14 @@ QPlaceManagerEngine *QGeoServiceProviderFactoryNokia::createPlaceManagerEngine(c
QGeoServiceProvider::Error *error,
QString *errorString) const
{
- return new QPlaceManagerEngineNokia(parameters, error, errorString);
+ switch (parameters.value(QLatin1String("places.api_version"), 1).toUInt()) {
+ case 1:
+ return new QPlaceManagerEngineNokiaV1(parameters, error, errorString);
+ case 2:
+ return new QPlaceManagerEngineNokiaV2(parameters, error, errorString);
+ }
+
+ return 0;
}
const QString QGeoServiceProviderFactoryNokia::defaultToken("152022572f0e44e07489c35cd46fa246");
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.cpp
index c75e31f6..d5022f81 100644
--- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.cpp
@@ -46,24 +46,24 @@
**
****************************************************************************/
-#include "qplacemanagerengine_nokia.h"
+#include "qplacemanagerengine_nokiav1.h"
#include <QtLocation/QPlaceContentRequest>
-#include "places/qplacecategoriesrepository.h"
-#include "places/qplacecontentreplyimpl.h"
-#include "places/qplacetextpredictionreplyimpl.h"
-#include "places/qplacesearchreplyimpl.h"
-#include "places/qplacerecommendationreplyimpl.h"
-#include "places/qplacedetailsreplyimpl.h"
-#include "places/qplaceratingreplyimpl.h"
-#include "places/qplacerestmanager.h"
-#include "places/qplacerestreply.h"
-#include "places/unsupportedreplies.h"
+#include "placesv1/qplacecategoriesrepository.h"
+#include "placesv1/qplacecontentreplyimplv1.h"
+#include "placesv1/qplacetextpredictionreplyimpl.h"
+#include "placesv1/qplacesearchreplyimplv1.h"
+#include "placesv1/qplacerecommendationreplyimplv1.h"
+#include "placesv1/qplacedetailsreplyimplv1.h"
+#include "placesv1/qplaceratingreplyimpl.h"
+#include "placesv1/qplacerestmanager.h"
+#include "placesv1/qplacerestreply.h"
+#include "placesv1/unsupportedreplies.h"
QT_USE_NAMESPACE
-QPlaceManagerEngineNokia::QPlaceManagerEngineNokia(const QMap<QString, QVariant> &parameters,
+QPlaceManagerEngineNokiaV1::QPlaceManagerEngineNokiaV1(const QMap<QString, QVariant> &parameters,
QGeoServiceProvider::Error *error,
QString *errorString)
: QPlaceManagerEngine(parameters)
@@ -91,16 +91,16 @@ QPlaceManagerEngineNokia::QPlaceManagerEngineNokia(const QMap<QString, QVariant>
errorString->clear();
}
-QPlaceManagerEngineNokia::~QPlaceManagerEngineNokia()
+QPlaceManagerEngineNokiaV1::~QPlaceManagerEngineNokiaV1()
{
}
-QPlaceDetailsReply *QPlaceManagerEngineNokia::getPlaceDetails(const QString &placeId)
+QPlaceDetailsReply *QPlaceManagerEngineNokiaV1::getPlaceDetails(const QString &placeId)
{
- QPlaceDetailsReplyImpl *reply = NULL;
+ QPlaceDetailsReplyImplV1 *reply = 0;
QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendPlaceRequest(placeId);
if (restReply) {
- reply = new QPlaceDetailsReplyImpl(restReply, manager(), this);
+ reply = new QPlaceDetailsReplyImplV1(restReply, manager(), this);
connect(reply, SIGNAL(processingError(QPlaceReply*,QPlaceReply::Error,QString)),
this, SLOT(processingError(QPlaceReply*,QPlaceReply::Error,QString)));
connect(reply, SIGNAL(processingFinished(QPlaceReply*)),
@@ -109,14 +109,14 @@ QPlaceDetailsReply *QPlaceManagerEngineNokia::getPlaceDetails(const QString &pla
return reply;
}
-QPlaceContentReply *QPlaceManagerEngineNokia::getPlaceContent(const QString &placeId, const QPlaceContentRequest &request)
+QPlaceContentReply *QPlaceManagerEngineNokiaV1::getPlaceContent(const QString &placeId, const QPlaceContentRequest &request)
{
- QPlaceContentReplyImpl *reply;
+ QPlaceContentReplyImplV1 *reply;
switch (request.contentType()) {
case QPlaceContent::ImageType: {
QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendPlaceImagesRequest(placeId,
request);
- reply = new QPlaceContentReplyImpl(request, restReply, manager(), this);
+ reply = new QPlaceContentReplyImplV1(request, restReply, manager(), this);
if (!restReply)
QMetaObject::invokeMethod(reply, "restError", Qt::QueuedConnection,
@@ -127,7 +127,7 @@ QPlaceContentReply *QPlaceManagerEngineNokia::getPlaceContent(const QString &pla
case QPlaceContent::ReviewType: {
QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendPlaceReviewRequest(placeId,
request);
- reply = new QPlaceContentReplyImpl(request, restReply, manager(), this);
+ reply = new QPlaceContentReplyImplV1(request, restReply, manager(), this);
if (!restReply)
QMetaObject::invokeMethod(reply, "restError", Qt::QueuedConnection,
@@ -139,7 +139,7 @@ QPlaceContentReply *QPlaceManagerEngineNokia::getPlaceContent(const QString &pla
QPlaceRestReply *restReply =
QPlaceRestManager::instance()->sendPlaceRequest(placeId);
- reply = new QPlaceContentReplyImpl(request, restReply, manager(), this);
+ reply = new QPlaceContentReplyImplV1(request, restReply, manager(), this);
if (!restReply) {
QMetaObject::invokeMethod(reply, "restError", Qt::QueuedConnection,
@@ -150,7 +150,7 @@ QPlaceContentReply *QPlaceManagerEngineNokia::getPlaceContent(const QString &pla
break;
}
default: {
- reply = new QPlaceContentReplyImpl(request, 0, manager(), this);
+ reply = new QPlaceContentReplyImplV1(request, 0, manager(), this);
QMetaObject::invokeMethod(reply, "restError", Qt::QueuedConnection,
Q_ARG(QPlaceReply::Error, QPlaceReply::UnsupportedError),
Q_ARG(QString, QString("Retrieval of given content type not supported")));
@@ -166,10 +166,10 @@ QPlaceContentReply *QPlaceManagerEngineNokia::getPlaceContent(const QString &pla
return reply;
}
-QPlaceSearchReply *QPlaceManagerEngineNokia::search(const QPlaceSearchRequest &query)
+QPlaceSearchReply *QPlaceManagerEngineNokiaV1::search(const QPlaceSearchRequest &query)
{
//TODO: handling of scope
- QPlaceSearchReplyImpl *reply = NULL;
+ QPlaceSearchReplyImplV1 *reply = 0;
QPlaceSearchRequest newQuery = query;
// search by category
if (newQuery.categories().count()) {
@@ -182,14 +182,14 @@ QPlaceSearchReply *QPlaceManagerEngineNokia::search(const QPlaceSearchRequest &q
QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendSearchRequest(newQuery);
if (restReply) {
- reply = new QPlaceSearchReplyImpl(restReply, this);
+ reply = new QPlaceSearchReplyImplV1(restReply, this);
connect(reply, SIGNAL(processingError(QPlaceReply*,QPlaceReply::Error,QString)),
this, SLOT(processingError(QPlaceReply*,QPlaceReply::Error,QString)));
connect(reply, SIGNAL(processingFinished(QPlaceReply*)),
this, SLOT(processingFinished(QPlaceReply*)));
}
} else {
- reply = new QPlaceSearchReplyImpl(0,this);
+ reply = new QPlaceSearchReplyImplV1(0, this);
QMetaObject::invokeMethod(reply,
"setError",
Qt::QueuedConnection,
@@ -200,14 +200,14 @@ QPlaceSearchReply *QPlaceManagerEngineNokia::search(const QPlaceSearchRequest &q
return reply;
}
-QPlaceSearchReply *QPlaceManagerEngineNokia::recommendations(const QString &placeId, const QPlaceSearchRequest &query)
+QPlaceSearchReply *QPlaceManagerEngineNokiaV1::recommendations(const QString &placeId, const QPlaceSearchRequest &query)
{
- QPlaceRecommendationReplyImpl *reply = NULL;
+ QPlaceRecommendationReplyImplV1 *reply = 0;
QPlaceSearchRequest newQuery = query;
newQuery.setSearchTerm(placeId);
QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendRecommendationRequest(newQuery, QString());
if (restReply) {
- reply = new QPlaceRecommendationReplyImpl(restReply, manager(), this);
+ reply = new QPlaceRecommendationReplyImplV1(restReply, manager(), this);
connect(reply, SIGNAL(processingError(QPlaceReply*,QPlaceReply::Error,QString)),
this, SLOT(processingError(QPlaceReply*,QPlaceReply::Error,QString)));
connect(reply, SIGNAL(processingFinished(QPlaceReply*)),
@@ -216,7 +216,7 @@ QPlaceSearchReply *QPlaceManagerEngineNokia::recommendations(const QString &plac
return reply;
}
-QPlaceSearchSuggestionReply *QPlaceManagerEngineNokia::searchSuggestions(const QPlaceSearchRequest &query)
+QPlaceSearchSuggestionReply *QPlaceManagerEngineNokiaV1::searchSuggestions(const QPlaceSearchRequest &query)
{
QPlaceTextPredictionReplyImpl *reply = NULL;
QPlaceRestReply *restReply = QPlaceRestManager::instance()->sendSuggestionRequest(query);
@@ -230,7 +230,7 @@ QPlaceSearchSuggestionReply *QPlaceManagerEngineNokia::searchSuggestions(const Q
return reply;
}
-QPlaceIdReply *QPlaceManagerEngineNokia::savePlace(const QPlace &place)
+QPlaceIdReply *QPlaceManagerEngineNokiaV1::savePlace(const QPlace &place)
{
IdReply *reply = new IdReply(QPlaceIdReply::SavePlace, this);
reply->setId(place.placeId());
@@ -238,7 +238,7 @@ QPlaceIdReply *QPlaceManagerEngineNokia::savePlace(const QPlace &place)
return reply;
}
-QPlaceIdReply *QPlaceManagerEngineNokia::removePlace(const QString &placeId)
+QPlaceIdReply *QPlaceManagerEngineNokiaV1::removePlace(const QString &placeId)
{
IdReply *reply = new IdReply(QPlaceIdReply::RemovePlace, this);
reply->setId(placeId);
@@ -246,7 +246,7 @@ QPlaceIdReply *QPlaceManagerEngineNokia::removePlace(const QString &placeId)
return reply;
}
-QPlaceIdReply *QPlaceManagerEngineNokia::saveCategory(const QPlaceCategory &category, const QString &parentId)
+QPlaceIdReply *QPlaceManagerEngineNokiaV1::saveCategory(const QPlaceCategory &category, const QString &parentId)
{
Q_UNUSED(parentId)
@@ -256,7 +256,7 @@ QPlaceIdReply *QPlaceManagerEngineNokia::saveCategory(const QPlaceCategory &cate
return reply;
}
-QPlaceIdReply *QPlaceManagerEngineNokia::removeCategory(const QString &categoryId)
+QPlaceIdReply *QPlaceManagerEngineNokiaV1::removeCategory(const QString &categoryId)
{
IdReply *reply = new IdReply(QPlaceIdReply::RemoveCategory, this);
reply->setId(categoryId);
@@ -264,7 +264,7 @@ QPlaceIdReply *QPlaceManagerEngineNokia::removeCategory(const QString &categoryI
return reply;
}
-QPlaceReply *QPlaceManagerEngineNokia::initializeCategories()
+QPlaceReply *QPlaceManagerEngineNokiaV1::initializeCategories()
{
QPlaceReply *reply = QPlaceCategoriesRepository::instance()->initializeCategories();
if (reply) {
@@ -277,25 +277,25 @@ QPlaceReply *QPlaceManagerEngineNokia::initializeCategories()
return reply;
}
-QString QPlaceManagerEngineNokia::parentCategoryId(const QString &categoryId) const
+QString QPlaceManagerEngineNokiaV1::parentCategoryId(const QString &categoryId) const
{
QPlaceCategoryTree tree = QPlaceCategoriesRepository::instance()->categories();
return tree.value(categoryId).parentId;
}
-QStringList QPlaceManagerEngineNokia::childCategoryIds(const QString &categoryId) const
+QStringList QPlaceManagerEngineNokiaV1::childCategoryIds(const QString &categoryId) const
{
QPlaceCategoryTree tree = QPlaceCategoriesRepository::instance()->categories();
return tree.value(categoryId).childIds;
}
-QPlaceCategory QPlaceManagerEngineNokia::category(const QString &categoryId) const
+QPlaceCategory QPlaceManagerEngineNokiaV1::category(const QString &categoryId) const
{
QPlaceCategoryTree tree = QPlaceCategoriesRepository::instance()->categories();
return tree.value(categoryId).category;
}
-QList<QPlaceCategory> QPlaceManagerEngineNokia::childCategories(const QString &parentId) const
+QList<QPlaceCategory> QPlaceManagerEngineNokiaV1::childCategories(const QString &parentId) const
{
QList<QPlaceCategory> results;
QPlaceCategoryTree tree = QPlaceCategoriesRepository::instance()->categories();
@@ -305,18 +305,18 @@ QList<QPlaceCategory> QPlaceManagerEngineNokia::childCategories(const QString &p
return results;
}
-QList<QLocale> QPlaceManagerEngineNokia::locales() const
+QList<QLocale> QPlaceManagerEngineNokiaV1::locales() const
{
return QPlaceRestManager::instance()->locales();
}
-void QPlaceManagerEngineNokia::setLocales(const QList<QLocale> &locales)
+void QPlaceManagerEngineNokiaV1::setLocales(const QList<QLocale> &locales)
{
QPlaceRestManager::instance()->setLocales(locales);
}
-QPlaceManager::ManagerFeatures QPlaceManagerEngineNokia::supportedFeatures() const
+QPlaceManager::ManagerFeatures QPlaceManagerEngineNokiaV1::supportedFeatures() const
{
return QPlaceManager::RecommendationsFeature
| QPlaceManager::SearchSuggestionsFeature
@@ -324,14 +324,14 @@ QPlaceManager::ManagerFeatures QPlaceManagerEngineNokia::supportedFeatures() con
| QPlaceManager::LocaleFeature;
}
-void QPlaceManagerEngineNokia::processingError(QPlaceReply *reply,
+void QPlaceManagerEngineNokiaV1::processingError(QPlaceReply *reply,
const QPlaceReply::Error &errorId,
const QString &errorMessage)
{
emit error(reply, errorId, errorMessage);
}
-void QPlaceManagerEngineNokia::processingFinished(QPlaceReply *reply)
+void QPlaceManagerEngineNokiaV1::processingFinished(QPlaceReply *reply)
{
emit finished(reply);
}
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.h
index 66498703..08bc30cb 100644
--- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokia.h
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.h
@@ -46,25 +46,26 @@
**
****************************************************************************/
-#ifndef QPLACEMANAGERENGINE_NOKIA_H
-#define QPLACEMANAGERENGINE_NOKIA_H
+#ifndef QPLACEMANAGERENGINE_NOKIAV1_H
+#define QPLACEMANAGERENGINE_NOKIAV1_H
#include <qplacecontent.h>
#include <qplacemanagerengine.h>
#include <qgeoserviceprovider.h>
QT_BEGIN_NAMESPACE
+
class QPlaceContentReply;
-class QPlaceManagerEngineNokia : public QPlaceManagerEngine
+class QPlaceManagerEngineNokiaV1 : public QPlaceManagerEngine
{
Q_OBJECT
public:
- QPlaceManagerEngineNokia(const QMap<QString, QVariant> &parameters,
+ QPlaceManagerEngineNokiaV1(const QMap<QString, QVariant> &parameters,
QGeoServiceProvider::Error *error,
QString *errorString);
- ~QPlaceManagerEngineNokia();
+ ~QPlaceManagerEngineNokiaV1();
QPlaceDetailsReply *getPlaceDetails(const QString &placeId);
@@ -99,4 +100,4 @@ private slots:
QT_END_NAMESPACE
-#endif // QPLACEMANAGERENGINEIMPL_H
+#endif // QPLACEMANAGERENGINE_NOKIAV1_H
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp
new file mode 100644
index 00000000..8bfaf51c
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp
@@ -0,0 +1,624 @@
+/****************************************************************************
+**
+** 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 "qplacemanagerengine_nokiav2.h"
+
+#include "placesv2/qplacecategoriesreplyimpl.h"
+#include "placesv2/qplacecontentreplyimpl.h"
+#include "placesv2/qplacesearchsuggestionreplyimpl.h"
+#include "placesv2/qplacesearchreplyimpl.h"
+#include "placesv2/qplacerecommendationreplyimpl.h"
+#include "placesv2/qplacedetailsreplyimpl.h"
+#include "placesv2/qplaceidreplyimpl.h"
+
+#include <QtCore/QJsonDocument>
+#include <QtCore/QJsonObject>
+#include <QtNetwork/QNetworkProxy>
+#ifdef USE_CHINA_NETWORK_REGISTRATION
+#include <QtSystemInfo/QNetworkInfo>
+#endif
+#include <QtLocation/QPlaceContentRequest>
+#include <QtLocation/QGeoBoundingCircle>
+
+QT_BEGIN_NAMESPACE
+
+static const char FIXED_CATEGORIES_string[] =
+ "eat-drink\0"
+ "going-out\0"
+ "sights-museums\0"
+ "transport\0"
+ "accommodation\0"
+ "shopping\0"
+ "leisure-outdoor\0"
+ "administrative-areas-buildings\0"
+ "natural-geographical\0"
+ "\0";
+
+static const int FIXED_CATEGORIES_indices[] = {
+ 0, 10, 20, 35, 45, 59, 68, 84,
+ 115, -1
+};
+
+static const char * const placesServerInternational = "http://api.places.lbs.maps.nokia.com/places";
+static const char * const placesServerChina = "http://api.places.lbs.maps.nokia.com.cn/places";
+
+QPlaceManagerEngineNokiaV2::QPlaceManagerEngineNokiaV2(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString)
+: QPlaceManagerEngine(parameters), m_manager(new QNetworkAccessManager(this))
+{
+ m_locales.append(QLocale());
+
+ if (parameters.contains(QLatin1String("places.proxy"))) {
+ const QUrl proxy(parameters.value("places.proxy").toString());
+ if (proxy.isValid()) {
+ m_manager->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, proxy.host(),
+ proxy.port(8080), proxy.userName(),
+ proxy.password()));
+ }
+ }
+
+ // Unless specified in the plugin parameters set the international places server to the builtin
+ // one. This is the server used when not in China.
+ m_host = parameters.value(QLatin1String("places.host"),
+ QLatin1String(placesServerInternational)).toString();
+
+ m_appId = parameters.value(QLatin1String("places.appid")).toString();
+ m_appCode = parameters.value(QLatin1String("places.appcode")).toString();
+
+#ifdef USE_CHINA_NETWORK_REGISTRATION
+ m_networkInfo = new QNetworkInfo(this);
+ connect(m_networkInfo, SIGNAL(currentMobileCountryCodeChanged(int,QString)),
+ this, SLOT(currentMobileCountryCodeChanged(int,QString)));
+ currentMobileCountryCodeChanged(0, m_networkInfo->currentMobileCountryCode(0));
+#else
+ m_placesServer = m_host;
+#endif
+
+ if (error)
+ *error = QGeoServiceProvider::NoError;
+
+ if (errorString)
+ errorString->clear();
+}
+
+QPlaceManagerEngineNokiaV2::~QPlaceManagerEngineNokiaV2()
+{
+}
+
+QPlaceDetailsReply *QPlaceManagerEngineNokiaV2::getPlaceDetails(const QString &placeId)
+{
+ QUrl requestUrl(m_placesServer + QLatin1String("/v1/places/") + placeId);
+
+ QList<QPair<QString, QString> > queryItems;
+
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("tf"), QLatin1String("plain")));
+ //queryItems.append(qMakePair<QString, QString>(QLatin1String("size"), QString::number(5)));
+ //queryItems.append(qMakePair<QString, QString>(QLatin1String("image_dimensions"), QLatin1String("w64-h64,w100")));
+
+ requestUrl.setQueryItems(queryItems);
+
+ QNetworkReply *networkReply = sendRequest(requestUrl);
+
+ QPlaceDetailsReplyImpl *reply = new QPlaceDetailsReplyImpl(networkReply, this);
+ connect(reply, SIGNAL(finished()), this, SLOT(replyFinished()));
+ connect(reply, SIGNAL(error(QPlaceReply::Error,QString)),
+ this, SLOT(replyError(QPlaceReply::Error,QString)));
+
+ return reply;
+}
+
+QPlaceContentReply *QPlaceManagerEngineNokiaV2::getPlaceContent(const QString &placeId,
+ const QPlaceContentRequest &request)
+{
+ QUrl requestUrl(m_placesServer + QLatin1String("/v1/places/") + placeId + QLatin1String("/media/"));
+
+ QNetworkReply *networkReply = 0;
+
+ QList<QPair<QString, QString> > queryItems;
+
+ switch (request.contentType()) {
+ case QPlaceContent::ImageType:
+ requestUrl.setPath(requestUrl.path() + QLatin1String("images"));
+
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("tf"), QLatin1String("plain")));
+
+ if (request.limit() > 0) {
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("size"),
+ QString::number(request.limit())));
+ }
+ if (request.offset() > -1) {
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("offset"),
+ QString::number(request.offset())));
+ }
+
+ //queryItems.append(qMakePair<QString, QString>(QLatin1String("image_dimensions"), QLatin1String("w64-h64,w100")));
+
+ requestUrl.setQueryItems(queryItems);
+
+ networkReply = sendRequest(requestUrl);
+ break;
+ case QPlaceContent::ReviewType:
+ requestUrl.setPath(requestUrl.path() + QLatin1String("reviews"));
+
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("tf"), QLatin1String("plain")));
+
+ if (request.limit() > 0) {
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("size"),
+ QString::number(request.limit())));
+ }
+ if (request.offset() > -1) {
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("offset"),
+ QString::number(request.offset())));
+ }
+
+ requestUrl.setQueryItems(queryItems);
+
+ networkReply = sendRequest(requestUrl);
+ break;
+ case QPlaceContent::EditorialType:
+ requestUrl.setPath(requestUrl.path() + QLatin1String("editorials"));
+
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("tf"), QLatin1String("plain")));
+
+ if (request.limit() > 0) {
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("size"),
+ QString::number(request.limit())));
+ }
+ if (request.offset() > -1) {
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("offset"),
+ QString::number(request.offset())));
+ }
+
+ requestUrl.setQueryItems(queryItems);
+
+ networkReply = sendRequest(requestUrl);
+ break;
+ case QPlaceContent::NoType:
+ ;
+ }
+
+ QPlaceContentReply *reply = new QPlaceContentReplyImpl(request, networkReply, this);
+ connect(reply, SIGNAL(finished()), this, SLOT(replyFinished()));
+ connect(reply, SIGNAL(error(QPlaceReply::Error,QString)),
+ this, SLOT(replyError(QPlaceReply::Error,QString)));
+
+ if (!networkReply) {
+ QMetaObject::invokeMethod(reply, "setError", Qt::QueuedConnection,
+ Q_ARG(QPlaceReply::Error, QPlaceReply::UnsupportedError),
+ Q_ARG(QString, QString("Retrieval of given content type not supported.")));
+ }
+
+ return reply;
+}
+
+static QString boundingAreaToLatLong(QGeoBoundingArea *area)
+{
+ QGeoCoordinate center;
+ switch (area->type()) {
+ case QGeoBoundingArea::BoxType:
+ center = static_cast<QGeoBoundingBox *>(area)->center();
+ break;
+ case QGeoBoundingArea::CircleType:
+ center = static_cast<QGeoBoundingCircle *>(area)->center();
+ break;
+ }
+
+ return QString::number(center.latitude()) + QLatin1Char(',') +
+ QString::number(center.longitude());
+}
+
+QPlaceSearchReply *QPlaceManagerEngineNokiaV2::search(const QPlaceSearchRequest &query)
+{
+ bool unsupported = false;
+
+ unsupported |= query.visibilityScope() != QtLocation::UnspecifiedVisibility &&
+ query.visibilityScope() != QtLocation::PublicVisibility;
+
+ unsupported |= !query.searchTerm().isEmpty() && query.offset() > 0;
+
+ if (!unsupported && !query.searchTerm().isEmpty() && query.categories().isEmpty()) {
+ // search term query
+ QUrl requestUrl(m_placesServer + QLatin1String("/v1/discover/search"));
+
+ QList<QPair<QString, QString> > queryItems;
+
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("q"), query.searchTerm()));
+
+ if (query.searchArea()) {
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("at"),
+ boundingAreaToLatLong(query.searchArea())));
+ }
+
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("tf"), QLatin1String("plain")));
+
+ if (query.limit() > 0) {
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("size"),
+ QString::number(query.limit())));
+ }
+
+ requestUrl.setQueryItems(queryItems);
+
+ QNetworkReply *networkReply = sendRequest(requestUrl);
+
+ QPlaceSearchReplyImpl *reply = new QPlaceSearchReplyImpl(networkReply, this);
+ connect(reply, SIGNAL(finished()), this, SLOT(replyFinished()));
+ connect(reply, SIGNAL(error(QPlaceReply::Error,QString)),
+ this, SLOT(replyError(QPlaceReply::Error,QString)));
+
+ return reply;
+ } else if (!unsupported && query.searchTerm().isEmpty() && !query.categories().isEmpty()) {
+ // category search
+ // The request URL should be "/v1/discover/explore" but that returns both places and
+ // clusters of places. We don't support clusters so we use the undocumented
+ // "/v1/discover/explore/places" instead which only returns places.
+ QUrl requestUrl(m_placesServer + QLatin1String("/v1/discover/explore/places"));
+
+ QList<QPair<QString, QString> > queryItems;
+
+ QStringList ids;
+ foreach (const QPlaceCategory &category, query.categories())
+ ids.append(category.categoryId());
+
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("cat"),
+ ids.join(QLatin1String(","))));
+
+ if (query.searchArea()) {
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("at"),
+ boundingAreaToLatLong(query.searchArea())));
+ }
+
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("tf"), QLatin1String("plain")));
+
+ if (query.limit() > 0) {
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("size"),
+ QString::number(query.limit())));
+ }
+ if (query.offset() > -1) {
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("offset"),
+ QString::number(query.offset())));
+ }
+
+ requestUrl.setQueryItems(queryItems);
+
+ QNetworkReply *networkReply = sendRequest(requestUrl);
+
+ QPlaceSearchReplyImpl *reply = new QPlaceSearchReplyImpl(networkReply, this);
+ connect(reply, SIGNAL(finished()), this, SLOT(replyFinished()));
+ connect(reply, SIGNAL(error(QPlaceReply::Error,QString)),
+ this, SLOT(replyError(QPlaceReply::Error,QString)));
+
+ return reply;
+ }
+
+ QPlaceSearchReplyImpl *reply = new QPlaceSearchReplyImpl(0, this);
+ QMetaObject::invokeMethod(reply, "setError", Qt::QueuedConnection,
+ Q_ARG(QPlaceReply::Error, QPlaceReply::BadArgumentError),
+ Q_ARG(QString, "Unsupported search request options specified."));
+
+ return reply;
+}
+
+QPlaceSearchReply *QPlaceManagerEngineNokiaV2::recommendations(const QString &placeId, const QPlaceSearchRequest &query)
+{
+ QUrl requestUrl(m_placesServer + QLatin1String("/v1/places/") + placeId + QLatin1String("/related/recommended"));
+
+ QList<QPair<QString, QString> > queryItems;
+
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("tf"), QLatin1String("plain")));
+
+ if (query.limit() > 0) {
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("size"),
+ QString::number(query.limit())));
+ }
+ if (query.offset() > -1) {
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("offset"),
+ QString::number(query.offset())));
+ }
+
+ requestUrl.setQueryItems(queryItems);
+
+ QNetworkReply *networkReply = sendRequest(requestUrl);
+
+ QPlaceRecommendationReplyImpl *reply = new QPlaceRecommendationReplyImpl(networkReply, this);
+ connect(reply, SIGNAL(finished()), this, SLOT(replyFinished()));
+ connect(reply, SIGNAL(error(QPlaceReply::Error,QString)),
+ this, SLOT(replyError(QPlaceReply::Error,QString)));
+
+ return reply;
+}
+
+QPlaceSearchSuggestionReply *QPlaceManagerEngineNokiaV2::searchSuggestions(const QPlaceSearchRequest &query)
+{
+ QUrl requestUrl(m_placesServer + QLatin1String("/v1/suggest"));
+
+ QList<QPair<QString, QString> > queryItems;
+
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("q"), query.searchTerm()));
+
+ if (query.searchArea()) {
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("at"),
+ boundingAreaToLatLong(query.searchArea())));
+ }
+
+ requestUrl.setQueryItems(queryItems);
+
+ QNetworkReply *networkReply = sendRequest(requestUrl);
+
+ QPlaceSearchSuggestionReplyImpl *reply = new QPlaceSearchSuggestionReplyImpl(networkReply, this);
+ connect(reply, SIGNAL(finished()), this, SLOT(replyFinished()));
+ connect(reply, SIGNAL(error(QPlaceReply::Error,QString)),
+ this, SLOT(replyError(QPlaceReply::Error,QString)));
+
+ return reply;
+}
+
+QPlaceIdReply *QPlaceManagerEngineNokiaV2::savePlace(const QPlace &place)
+{
+ QPlaceIdReplyImpl *reply = new QPlaceIdReplyImpl(QPlaceIdReply::SavePlace, this);
+ 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.")));
+ return reply;
+}
+
+QPlaceIdReply *QPlaceManagerEngineNokiaV2::removePlace(const QString &placeId)
+{
+ QPlaceIdReplyImpl *reply = new QPlaceIdReplyImpl(QPlaceIdReply::RemovePlace, this);
+ reply->setId(placeId);
+ QMetaObject::invokeMethod(reply, "setError", Qt::QueuedConnection,
+ Q_ARG(QPlaceReply::Error, QPlaceReply::UnsupportedError),
+ Q_ARG(QString, tr("Removing places is not supported.")));
+ return reply;
+}
+
+QPlaceIdReply *QPlaceManagerEngineNokiaV2::saveCategory(const QPlaceCategory &category, const QString &parentId)
+{
+ Q_UNUSED(parentId)
+
+ QPlaceIdReplyImpl *reply = new QPlaceIdReplyImpl(QPlaceIdReply::SaveCategory, this);
+ 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.")));
+ return reply;
+}
+
+QPlaceIdReply *QPlaceManagerEngineNokiaV2::removeCategory(const QString &categoryId)
+{
+ QPlaceIdReplyImpl *reply = new QPlaceIdReplyImpl(QPlaceIdReply::RemoveCategory, this);
+ reply->setId(categoryId);
+ QMetaObject::invokeMethod(reply, "setError", Qt::QueuedConnection,
+ Q_ARG(QPlaceReply::Error, QPlaceReply::UnsupportedError),
+ Q_ARG(QString, tr("Removing categories is not supported.")));
+ return reply;
+}
+
+QPlaceReply *QPlaceManagerEngineNokiaV2::initializeCategories()
+{
+ if (m_categoryReply)
+ return m_categoryReply.data();
+
+ for (int i = 0; FIXED_CATEGORIES_indices[i] != -1; ++i) {
+ const QString id = QString::fromLatin1(FIXED_CATEGORIES_string +
+ FIXED_CATEGORIES_indices[i]);
+
+ QUrl requestUrl(m_placesServer + QLatin1String("/v1/categories/places/") + id);
+ QNetworkReply *networkReply = sendRequest(requestUrl);
+ connect(networkReply, SIGNAL(finished()), this, SLOT(categoryReplyFinished()));
+ connect(networkReply, SIGNAL(error(QNetworkReply::NetworkError)),
+ this, SLOT(categoryReplyError()));
+
+ m_categoryRequests.insert(id, networkReply);
+ }
+
+ QPlaceCategoriesReplyImpl *reply = new QPlaceCategoriesReplyImpl(this);
+ connect(reply, SIGNAL(finished()), this, SLOT(replyFinished()));
+ connect(reply, SIGNAL(error(QPlaceReply::Error,QString)),
+ this, SLOT(replyError(QPlaceReply::Error,QString)));
+
+ m_categoryReply = reply;
+ return reply;
+}
+
+QString QPlaceManagerEngineNokiaV2::parentCategoryId(const QString &categoryId) const
+{
+ return m_categoryTree.value(categoryId).parentId;
+}
+
+QStringList QPlaceManagerEngineNokiaV2::childCategoryIds(const QString &categoryId) const
+{
+ return m_categoryTree.value(categoryId).childIds;
+}
+
+QPlaceCategory QPlaceManagerEngineNokiaV2::category(const QString &categoryId) const
+{
+ return m_categoryTree.value(categoryId).category;
+}
+
+QList<QPlaceCategory> QPlaceManagerEngineNokiaV2::childCategories(const QString &parentId) const
+{
+ QList<QPlaceCategory> results;
+ foreach (const QString &childId, m_categoryTree.value(parentId).childIds)
+ results.append(m_categoryTree.value(childId).category);
+ return results;
+}
+
+QList<QLocale> QPlaceManagerEngineNokiaV2::locales() const
+{
+ return m_locales;
+}
+
+void QPlaceManagerEngineNokiaV2::setLocales(const QList<QLocale> &locales)
+{
+ m_locales = locales;
+}
+
+QPlaceManager::ManagerFeatures QPlaceManagerEngineNokiaV2::supportedFeatures() const
+{
+ return QPlaceManager::RecommendationsFeature |
+ QPlaceManager::SearchSuggestionsFeature |
+ QPlaceManager::LocaleFeature;
+}
+
+void QPlaceManagerEngineNokiaV2::replyFinished()
+{
+ QPlaceReply *reply = qobject_cast<QPlaceReply *>(sender());
+ if (reply)
+ emit finished(reply);
+}
+
+void QPlaceManagerEngineNokiaV2::replyError(QPlaceReply::Error error_, const QString &errorString)
+{
+ QPlaceReply *reply = qobject_cast<QPlaceReply *>(sender());
+ if (reply)
+ emit error(reply, error_, errorString);
+}
+
+void QPlaceManagerEngineNokiaV2::categoryReplyFinished()
+{
+ QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
+ if (!reply)
+ return;
+
+ if (reply->error() == QNetworkReply::NoError) {
+ QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
+ if (!document.isObject()) {
+ if (m_categoryReply) {
+ QMetaObject::invokeMethod(m_categoryReply.data(), "setError", Qt::QueuedConnection,
+ Q_ARG(QPlaceReply::Error, QPlaceReply::ParseError),
+ Q_ARG(QString, tr("Error parsing response.")));
+ }
+ return;
+ }
+
+ QJsonObject category = document.object();
+
+ PlaceCategoryNode node;
+ node.category.setCategoryId(category.value(QLatin1String("categoryId")).toString());
+ node.category.setName(category.value(QLatin1String("name")).toString());
+
+ QVariantMap parameters;
+ parameters.insert(QPlaceIcon::SingleUrl,
+ QUrl(category.value(QLatin1String("icon")).toString()));
+ QPlaceIcon icon;
+ icon.setParameters(parameters);
+ node.category.setIcon(icon);
+
+ m_categoryTree.insert(node.category.categoryId(), node);
+
+ m_categoryTree[QString()].childIds.append(node.category.categoryId());
+ }
+
+ m_categoryRequests.remove(m_categoryRequests.key(reply));
+ reply->deleteLater();
+
+ if (m_categoryRequests.isEmpty() && m_categoryReply)
+ m_categoryReply.data()->emitFinished();
+}
+
+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.")));
+ }
+}
+
+#ifdef USE_CHINA_NETWORK_REGISTRATION
+void QPlaceManagerEngineNokiaV2::currentMobileCountryCodeChanged(int interface, const QString &mcc)
+{
+ Q_UNUSED(interface)
+
+ if (mcc == QLatin1String("460") || mcc == QLatin1String("461") ||
+ mcc == QLatin1String("454") || mcc == QLatin1String("455")) {
+ m_placesServer = QLatin1String(placesServerChina);
+ } else {
+ m_placesServer = m_host;
+ }
+}
+#endif
+
+QNetworkReply *QPlaceManagerEngineNokiaV2::sendRequest(const QUrl &url)
+{
+ QList<QPair<QString, QString> > queryItems = url.queryItems();
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("app_id"), m_appId));
+ queryItems.append(qMakePair<QString, QString>(QLatin1String("app_code"), m_appCode));
+
+ QUrl requestUrl = url;
+ requestUrl.setQueryItems(queryItems);
+
+ QNetworkRequest request;
+ request.setUrl(requestUrl);
+
+ request.setRawHeader("Accept", "application/json");
+ request.setRawHeader("Accept-Language", createLanguageString());
+
+ return m_manager->get(request);
+}
+
+QByteArray QPlaceManagerEngineNokiaV2::createLanguageString() const
+{
+ QByteArray language;
+
+ QList<QLocale> locales = m_locales;
+ if (locales.isEmpty())
+ locales << QLocale();
+
+ foreach (const QLocale &loc, locales) {
+ language.append(loc.name().replace(2, 1, QLatin1Char('-')).toAscii());
+ language.append(", ");
+ }
+ language.chop(2);
+
+ return language;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.h b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.h
new file mode 100644
index 00000000..a9afbb9a
--- /dev/null
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.h
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** 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 QPLACEMANAGERENGINE_NOKIAV2_H
+#define QPLACEMANAGERENGINE_NOKIAV2_H
+
+#include <QtCore/QWeakPointer>
+#include <QtNetwork/QNetworkReply>
+#include <QtLocation/QPlaceManagerEngine>
+#include <QtLocation/QGeoServiceProvider>
+
+QT_BEGIN_NAMESPACE
+
+class QPlaceContentReply;
+class QNetworkReply;
+class QNetworkAccessManager;
+class QPlaceCategoriesReplyImpl;
+class QNetworkInfo;
+
+struct PlaceCategoryNode
+{
+ QString parentId;
+ QStringList childIds;
+ QPlaceCategory category;
+};
+
+typedef QMap<QString, PlaceCategoryNode> QPlaceCategoryTree;
+
+class QPlaceManagerEngineNokiaV2 : public QPlaceManagerEngine
+{
+ Q_OBJECT
+
+public:
+ QPlaceManagerEngineNokiaV2(const QMap<QString, QVariant> &parameters,
+ QGeoServiceProvider::Error *error,
+ QString *errorString);
+ ~QPlaceManagerEngineNokiaV2();
+
+ QPlaceDetailsReply *getPlaceDetails(const QString &placeId);
+
+ QPlaceContentReply *getPlaceContent(const QString &placeId, const QPlaceContentRequest &request);
+
+ QPlaceSearchReply *search(const QPlaceSearchRequest &query);
+
+ QPlaceSearchReply *recommendations(const QString &placeId, const QPlaceSearchRequest &query);
+ QPlaceSearchSuggestionReply *searchSuggestions(const QPlaceSearchRequest &query);
+
+ QPlaceIdReply *savePlace(const QPlace &place);
+ QPlaceIdReply *removePlace(const QString &placeId);
+
+ QPlaceIdReply *saveCategory(const QPlaceCategory &category, const QString &parentId);
+ QPlaceIdReply *removeCategory(const QString &categoryId);
+
+ QPlaceReply *initializeCategories();
+ QString parentCategoryId(const QString &categoryId) const;
+ QStringList childCategoryIds(const QString &categoryId) const;
+ QPlaceCategory category(const QString &categoryId) const;
+ QList<QPlaceCategory> childCategories(const QString &parentId) const;
+
+ QList<QLocale> locales() const;
+ void setLocales(const QList<QLocale> &locales);
+
+ QPlaceManager::ManagerFeatures supportedFeatures() const;
+
+private:
+ QNetworkReply *sendRequest(const QUrl &url);
+ QByteArray createLanguageString() const;
+
+private slots:
+ void replyFinished();
+ void replyError(QPlaceReply::Error error_, const QString &errorString);
+ void categoryReplyFinished();
+ void categoryReplyError();
+#ifdef USE_CHINA_NETWORK_REGISTRATION
+ void currentMobileCountryCodeChanged(int interface, const QString &mcc);
+#endif
+
+private:
+ QNetworkAccessManager *m_manager;
+#ifdef USE_CHINA_NETWORK_REGISTRATION
+ QNetworkInfo *m_networkInfo;
+#endif
+
+ QList<QLocale> m_locales;
+
+ QPlaceCategoryTree m_categoryTree;
+
+ QWeakPointer<QPlaceCategoriesReplyImpl> m_categoryReply;
+ QHash<QString, QNetworkReply *> m_categoryRequests;
+
+ QString m_appId;
+ QString m_appCode;
+ QString m_host;
+
+ QString m_placesServer;
+};
+
+QT_END_NAMESPACE
+
+#endif // QPLACEMANAGERENGINE_NOKIAV2_H
diff --git a/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp b/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp
index 330b4437..e8be80a9 100644
--- a/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp
+++ b/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp
@@ -64,8 +64,6 @@ QPlaceManagerEngineJsonDb::QPlaceManagerEngineJsonDb(const QMap<QString, QVarian
QString *errorString)
: QPlaceManagerEngine(parameters)
{
- qRegisterMetaType<QPlaceReply::Error>();
- qRegisterMetaType<QPlaceReply *>();
qRegisterMetaType<QPlaceCategory>();
m_db = new JsonDbClient(this);
diff --git a/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp b/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp
index 2c22c349..f1452b7a 100644
--- a/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp
+++ b/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp
@@ -256,8 +256,6 @@ tst_QPlaceManagerJsonDb::tst_QPlaceManagerJsonDb()
void tst_QPlaceManagerJsonDb::initTestCase()
{
- qRegisterMetaType<QPlaceReply::Error>();
- qRegisterMetaType<QPlaceReply *>();
qRegisterMetaType<QPlaceIdReply *>();
QStringList providers = QGeoServiceProvider::availableServiceProviders();
diff --git a/tests/auto/qplacemanager_nokia/tst_qplacemanager_nokia.cpp b/tests/auto/qplacemanager_nokia/tst_qplacemanager_nokia.cpp
index 87f6fb50..554e9e93 100644
--- a/tests/auto/qplacemanager_nokia/tst_qplacemanager_nokia.cpp
+++ b/tests/auto/qplacemanager_nokia/tst_qplacemanager_nokia.cpp
@@ -87,8 +87,6 @@ tst_QPlaceManagerNokia::tst_QPlaceManagerNokia()
void tst_QPlaceManagerNokia::initTestCase()
{
- qRegisterMetaType<QPlaceReply::Error>();
- qRegisterMetaType<QPlaceReply *>();
qRegisterMetaType<QPlaceIdReply *>();
QStringList providers = QGeoServiceProvider::availableServiceProviders();