diff options
author | Martin Zielinski <martin.zielinski@nokia.com> | 2012-01-27 10:01:15 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-01 07:46:49 +0100 |
commit | 013def8ddcd3a2c2a8c253baf1071607bd3d3a55 (patch) | |
tree | 55510bd0ffcd4656dac33636ec43533751a4ae5e /src | |
parent | 82f57c1d4b428f1cb29dc8745d5e14f06084307a (diff) | |
download | qtlocation-013def8ddcd3a2c2a8c253baf1071607bd3d3a55.tar.gz |
Remove use of deprecated VariantStream API
Also removes the dependency on mt-client, as this is the last
usage of it in the code.
Removes config.tests as they are testing for Qt modules or
Qt Addon modules which can be tested for in the .pro files with
!isEmpty(QT.foo.name).
Change-Id: I2a621d73ef76de51154ad9ce80fb2c84881ae3de
Reviewed-by: Alex Wilson <alex.wilson@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/location/location.pro | 9 | ||||
-rw-r--r-- | src/location/qgeopositioninfosource_npe_backend.cpp | 71 | ||||
-rw-r--r-- | src/location/qgeopositioninfosource_npe_backend_p.h | 9 | ||||
-rw-r--r-- | src/location/qgeosatelliteinfosource_npe_backend.cpp | 50 | ||||
-rw-r--r-- | src/location/qgeosatelliteinfosource_npe_backend_p.h | 8 | ||||
-rw-r--r-- | src/plugins/geoservices/geoservices.pro | 4 |
6 files changed, 81 insertions, 70 deletions
diff --git a/src/location/location.pro b/src/location/location.pro index 33673aad..b35b07a8 100644 --- a/src/location/location.pro +++ b/src/location/location.pro @@ -87,18 +87,13 @@ meego { } } -contains(config_test_jsondb, yes):contains(config_test_mtclient, yes):!simulator { +!isEmpty(QT.jsondb.name):!isEmpty(QT.jsonstream.name):!simulator { DEFINES += NPE_BACKEND - QT += jsondb-private + QT += jsondb-private jsonstream SOURCES += qgeopositioninfosource_npe_backend.cpp\ qgeosatelliteinfosource_npe_backend.cpp PRIVATE_HEADERS += qgeopositioninfosource_npe_backend_p.h\ qgeosatelliteinfosource_npe_backend_p.h - - unix{ - CONFIG += link_pkgconfig - PKGCONFIG += mt-client - } } HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS diff --git a/src/location/qgeopositioninfosource_npe_backend.cpp b/src/location/qgeopositioninfosource_npe_backend.cpp index 8c8d972d..782f2d39 100644 --- a/src/location/qgeopositioninfosource_npe_backend.cpp +++ b/src/location/qgeopositioninfosource_npe_backend.cpp @@ -42,6 +42,9 @@ #include "qgeopositioninfosource_npe_backend_p.h" #include <sys/stat.h> +#include <QtAddOnJsonStream/jsonstream.h> + +QT_USE_NAMESPACE_JSONSTREAM // API for socket communication towards locationd const QString kstartUpdates = QLatin1String("startUpdates"); @@ -92,9 +95,9 @@ bool QGeoPositionInfoSourceNpeBackend::init() if (mSocket) { connect(mSocket, SIGNAL(connected()), this, SLOT(onSocketConnected())); connect(mSocket, SIGNAL(disconnected()), this, SLOT(onSocketDisconnected())); - mStream = new VariantStream(mSocket); + mStream = new JsonStream(mSocket); if (mStream) { - connect(mStream, SIGNAL(receive(const QVariantMap&)), this, SLOT(onStreamReceived(const QVariantMap&)), Qt::QueuedConnection); + connect(mStream, SIGNAL(messageReceived(const QVariantMap&)), this, SLOT(onStreamReceived(const QVariantMap&)), Qt::QueuedConnection); } mSocket->connectToServer((QLatin1String)klocationdSocketName); return(mSocket->waitForConnected(500)); // wait up to 0.5 seconds to get connected, otherwise return false @@ -108,11 +111,11 @@ QGeoPositionInfo QGeoPositionInfoSourceNpeBackend::lastKnownPosition(bool fromSa { QEventLoop loop; // loop to wait for response from locationd (asynchronous socket connection) connect( this, SIGNAL(lastKnownPositionReceived()), &loop, SLOT(quit())); - QVariantMap action; - QVariantMap object; - action.insert(JsonDbString::kActionStr, kgetLastKnownPosition); - object.insert(ksatelliteOnly, fromSatellitePositioningMethodsOnly); - action.insert(JsonDbString::kDataStr, object); + QJsonObject action; + QJsonObject object; + action[JsonDbString::kActionStr] = kgetLastKnownPosition; + object[ksatelliteOnly] = fromSatellitePositioningMethodsOnly; + action[JsonDbString::kDataStr] = object; mStream->send(action); loop.exec(); // wait for signal lastKnownPositionReceived()sent by slot onStreamReceived return(lastPosition); @@ -123,8 +126,8 @@ QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceNpeBackend::sup { QEventLoop loop; // loop to wait for response from locationd (asynchronous socket connection) connect( this, SIGNAL(supportedPositioningMethodsReceived()), &loop, SLOT(quit())); - QVariantMap action; - action.insert(JsonDbString::kActionStr, kgetSupportedMethods); + QJsonObject action; + action[JsonDbString::kActionStr] = kgetSupportedMethods; mStream->send(action); loop.exec(); // wait for supportedPositioningMethodsReceived() signal sent by slot onStreamReceived switch (supportedMethods){ @@ -140,21 +143,21 @@ QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceNpeBackend::sup void QGeoPositionInfoSourceNpeBackend::setUpdateInterval(int msec) { - QVariantMap action; QEventLoop loop; // loop to wait for response from locationd (asynchronous socket connection) connect( this, SIGNAL(minimumUpdateIntervalReceived()), &loop, SLOT(quit())); - action.insert(JsonDbString::kActionStr, kgetMinimumUpdateInterval); + QJsonObject action; + action[JsonDbString::kActionStr] = kgetMinimumUpdateInterval; mStream->send(action); loop.exec(); // wait for minimumUpdateIntervalReceived() signal sent by slot onStreamReceived if (msec < minInterval && msec != 0) msec = minInterval; QGeoPositionInfoSource::setUpdateInterval(msec); if (!requestTimer->isActive()) { - QVariantMap actionUpdate; - QVariantMap object; - actionUpdate.insert(JsonDbString::kActionStr, ksetUpdateInterval); - object.insert(kinterval, msec); - actionUpdate.insert(JsonDbString::kDataStr, object); + QJsonObject actionUpdate; + QJsonObject object; + actionUpdate[JsonDbString::kActionStr] = ksetUpdateInterval; + object[kinterval] = msec; + actionUpdate[JsonDbString::kDataStr] = object; mStream->send(actionUpdate); } } @@ -163,21 +166,21 @@ void QGeoPositionInfoSourceNpeBackend::setUpdateInterval(int msec) void QGeoPositionInfoSourceNpeBackend::setPreferredPositioningMethods(PositioningMethods sources) { QGeoPositionInfoSource::setPreferredPositioningMethods(sources); - QVariantMap action; - QVariantMap object; - action.insert(JsonDbString::kActionStr, ksetPreferredMethod); - object.insert(kmethod, (uint)sources); - action.insert(JsonDbString::kDataStr, object); + QJsonObject action; + QJsonObject object; + action[JsonDbString::kActionStr] = ksetPreferredMethod; + object[kmethod] = int(sources); + action[JsonDbString::kDataStr] = object; mStream->send(action); } int QGeoPositionInfoSourceNpeBackend::minimumUpdateInterval() const { - QVariantMap action; + QJsonObject action; QEventLoop loop; // loop to wait for response from locationd (asynchronous socket connection) connect( this, SIGNAL(minimumUpdateIntervalReceived()), &loop, SLOT(quit())); - action.insert(JsonDbString::kActionStr, kgetMinimumUpdateInterval); + action[JsonDbString::kActionStr] = kgetMinimumUpdateInterval; mStream->send(action); loop.exec(); // wait for minimumUpdateIntervalReceived() signal sent by slot onStreamReceived return(minInterval); @@ -188,8 +191,8 @@ void QGeoPositionInfoSourceNpeBackend::startUpdates() { if (!locationOngoing) { locationOngoing = true; - QVariantMap action; - action.insert(JsonDbString::kActionStr, kstartUpdates); + QJsonObject action; + action[JsonDbString::kActionStr] = kstartUpdates; mStream->send(action); } } @@ -199,8 +202,8 @@ void QGeoPositionInfoSourceNpeBackend::stopUpdates() { if ( locationOngoing && !requestTimer->isActive() ) { locationOngoing = false; - QVariantMap action; - action.insert(JsonDbString::kActionStr, kstopUpdates); + QJsonObject action; + action[JsonDbString::kActionStr] = kstopUpdates; mStream->send(action); } } @@ -222,18 +225,18 @@ void QGeoPositionInfoSourceNpeBackend::requestUpdate(int timeout) // get position as fast as possible in case of ongoing satellite based session if ( locationOngoing ) { if ( QGeoPositionInfoSource::updateInterval() != minimumInterval) { - QVariantMap actionUpdate; - QVariantMap object; - actionUpdate.insert(JsonDbString::kActionStr, ksetUpdateInterval); - object.insert(kinterval, minimumInterval); - actionUpdate.insert(JsonDbString::kDataStr, object); + QJsonObject actionUpdate; + QJsonObject object; + actionUpdate[JsonDbString::kActionStr] = ksetUpdateInterval; + object[kinterval] = minimumInterval; + actionUpdate[JsonDbString::kDataStr] = object; mStream->send(actionUpdate); } } // request the update only if no tracking session is active if ( !locationOngoing) { - QVariantMap action; - action.insert(JsonDbString::kActionStr, krequestUpdate); + QJsonObject action; + action[JsonDbString::kActionStr] = krequestUpdate; mStream->send(action); } requestTimer->start(timeout); diff --git a/src/location/qgeopositioninfosource_npe_backend_p.h b/src/location/qgeopositioninfosource_npe_backend_p.h index 55f2967f..62d5b89f 100644 --- a/src/location/qgeopositioninfosource_npe_backend_p.h +++ b/src/location/qgeopositioninfosource_npe_backend_p.h @@ -54,12 +54,17 @@ // #include <qgeopositioninfosource.h> -#include <mt-client/variantstream.h> #include <private/jsondb-strings_p.h> #include <qlocalsocket.h> #include <qeventloop.h> #include <qtimer.h> +#include <QtAddOnJsonStream/jsonstream-global.h> + +QT_BEGIN_NAMESPACE_JSONSTREAM +class JsonStream; +QT_END_NAMESPACE_JSONSTREAM + Q_USE_JSONDB_NAMESPACE class QGeoPositionInfoSourceNpeBackend : public QGeoPositionInfoSource @@ -82,7 +87,7 @@ public Q_SLOTS: private: QLocalSocket* mSocket; - VariantStream* mStream; + QtAddOn::JsonStream::JsonStream* mStream; int minInterval; uint supportedMethods; QGeoPositionInfo lastPosition; diff --git a/src/location/qgeosatelliteinfosource_npe_backend.cpp b/src/location/qgeosatelliteinfosource_npe_backend.cpp index 1d989bcc..8e343315 100644 --- a/src/location/qgeosatelliteinfosource_npe_backend.cpp +++ b/src/location/qgeosatelliteinfosource_npe_backend.cpp @@ -41,6 +41,12 @@ #include "qgeosatelliteinfosource_npe_backend_p.h" #include <sys/stat.h> + +#include <QtCore/QJsonObject> +#include <QtAddOnJsonStream/jsonstream.h> + +QT_USE_NAMESPACE_JSONSTREAM + // #include <mtlocationd/locationd-strings.h> // API for socket communication towards locationd @@ -87,9 +93,9 @@ bool QGeoSatelliteInfoSourceNpeBackend::init() if (mSocket) { connect(mSocket, SIGNAL(connected()), this, SLOT(onSocketConnected())); connect(mSocket, SIGNAL(disconnected()), this, SLOT(onSocketDisconnected())); - mStream = new VariantStream(mSocket); + mStream = new JsonStream(mSocket); if (mStream) { - connect(mStream, SIGNAL(receive(const QVariantMap&)), this, SLOT(onStreamReceived(const QVariantMap&)), Qt::QueuedConnection); + connect(mStream, SIGNAL(messageReceived(const QVariantMap&)), this, SLOT(onStreamReceived(const QVariantMap&)), Qt::QueuedConnection); } mSocket->connectToServer((QLatin1String)"/var/run/locationd/locationd.socket"); return(mSocket->waitForConnected(500)); // wait up to 0.5 seconds to get connected, otherwise return false @@ -101,21 +107,21 @@ bool QGeoSatelliteInfoSourceNpeBackend::init() void QGeoSatelliteInfoSourceNpeBackend::setUpdateInterval(int msec) { - QVariantMap action; QEventLoop loop; // loop to wait for response from locationd (asynchronous socket connection) connect( this, SIGNAL(minimumUpdateIntervalReceived()), &loop, SLOT(quit())); - action.insert(JsonDbString::kActionStr, kgetMinimumUpdateInterval); + QJsonObject action; + action[JsonDbString::kActionStr] = kgetMinimumUpdateInterval; mStream->send(action); loop.exec(); // wait for minimumUpdateIntervalReceived() signal sent by slot onStreamReceived if (msec < minInterval && msec != 0) msec = minInterval; QGeoSatelliteInfoSource::setUpdateInterval(msec); if (!requestTimer->isActive()) { - QVariantMap actionUpdate; - QVariantMap object; - actionUpdate.insert(JsonDbString::kActionStr, ksetUpdateInterval); - object.insert(kinterval, msec); - actionUpdate.insert(JsonDbString::kDataStr, object); + QJsonObject actionUpdate; + QJsonObject object; + actionUpdate[JsonDbString::kActionStr] = ksetUpdateInterval; + object[kinterval] = msec; + actionUpdate[JsonDbString::kDataStr] = object; mStream->send(actionUpdate); } } @@ -123,10 +129,10 @@ void QGeoSatelliteInfoSourceNpeBackend::setUpdateInterval(int msec) int QGeoSatelliteInfoSourceNpeBackend::minimumUpdateInterval() const { - QVariantMap action; QEventLoop loop; // loop to wait for response from locationd (asynchronous socket connection) connect( this, SIGNAL(minimumUpdateIntervalReceived()), &loop, SLOT(quit())); - action.insert(JsonDbString::kActionStr, kgetMinimumUpdateInterval); + QJsonObject action; + action[JsonDbString::kActionStr] = kgetMinimumUpdateInterval; mStream->send(action); loop.exec(); // wait for minimumUpdateIntervalReceived() signal sent by slot onStreamReceived return(minInterval); @@ -137,8 +143,8 @@ void QGeoSatelliteInfoSourceNpeBackend::startUpdates() { if (!satOngoing) { satOngoing = true; - QVariantMap action; - action.insert(JsonDbString::kActionStr, ksatelliteStartUpdates); + QJsonObject action; + action[JsonDbString::kActionStr] = ksatelliteStartUpdates; mStream->send(action); } } @@ -148,8 +154,8 @@ void QGeoSatelliteInfoSourceNpeBackend::stopUpdates() { if (satOngoing && !requestTimer->isActive()) { satOngoing = false; - QVariantMap action; - action.insert(JsonDbString::kActionStr, ksatelliteStopUpdates); + QJsonObject action; + action[JsonDbString::kActionStr] = ksatelliteStopUpdates; mStream->send(action); } } @@ -170,18 +176,18 @@ void QGeoSatelliteInfoSourceNpeBackend::requestUpdate(int timeout) // get satellite update as fast as possible in case of ongoing tracking session if ( satOngoing ) { if ( QGeoSatelliteInfoSource::updateInterval() != minimumInterval) { - QVariantMap actionUpdate; - QVariantMap object; - actionUpdate.insert(JsonDbString::kActionStr, ksetUpdateInterval); - object.insert(kinterval, minimumInterval); - actionUpdate.insert(JsonDbString::kDataStr, object); + QJsonObject actionUpdate; + QJsonObject object; + actionUpdate[JsonDbString::kActionStr] = ksetUpdateInterval; + object[kinterval] = minimumInterval; + actionUpdate[JsonDbString::kDataStr] = object; mStream->send(actionUpdate); } } // request the update only if no tracking session is active if ( !satOngoing) { - QVariantMap action; - action.insert(JsonDbString::kActionStr, ksatelliteRequestUpdate); + QJsonObject action; + action[JsonDbString::kActionStr] = ksatelliteRequestUpdate; mStream->send(action); } requestTimer->start(timeout); diff --git a/src/location/qgeosatelliteinfosource_npe_backend_p.h b/src/location/qgeosatelliteinfosource_npe_backend_p.h index 9b9f8b51..fc2f6012 100644 --- a/src/location/qgeosatelliteinfosource_npe_backend_p.h +++ b/src/location/qgeosatelliteinfosource_npe_backend_p.h @@ -55,12 +55,16 @@ #include "qgeosatelliteinfosource.h" #include "qgeosatelliteinfo.h" -#include <mt-client/variantstream.h> #include <private/jsondb-strings_p.h> #include <qlocalsocket.h> #include <qeventloop.h> #include <qtimer.h> +#include <QtAddOnJsonStream/jsonstream-global.h> + +QT_BEGIN_NAMESPACE_JSONSTREAM +class JsonStream; +QT_END_NAMESPACE_JSONSTREAM Q_USE_JSONDB_NAMESPACE @@ -92,7 +96,7 @@ private Q_SLOTS: private: QLocalSocket* mSocket; - VariantStream* mStream; + QtAddOn::JsonStream::JsonStream* mStream; bool satOngoing; QTimer* requestTimer; int minInterval; diff --git a/src/plugins/geoservices/geoservices.pro b/src/plugins/geoservices/geoservices.pro index a27213d1..abf4c44e 100644 --- a/src/plugins/geoservices/geoservices.pro +++ b/src/plugins/geoservices/geoservices.pro @@ -2,6 +2,4 @@ TEMPLATE = subdirs SUBDIRS = nokia -contains(config_test_jsondb, yes) { - SUBDIRS += nokia_places_jsondb -} +!isEmpty(QT.jsondb.name):SUBDIRS += nokia_places_jsondb |