diff options
author | Aaron McCarthy <aaron.mccarthy@jollamobile.com> | 2014-08-12 11:56:14 +1000 |
---|---|---|
committer | Alex Blasche <alexander.blasche@digia.com> | 2014-08-13 13:21:22 +0200 |
commit | 7d9173ddb973025adf414b2e0333c4389d431a56 (patch) | |
tree | 975a5b5e545efdff40d96b5f277680bb46938142 | |
parent | 17447ee1cf457498bb08dff9f0be46b8db32c098 (diff) | |
download | qtlocation-7d9173ddb973025adf414b2e0333c4389d431a56.tar.gz |
Report error when failing to connect to Geoclue.
[ChangeLog][QtPositioning][QGeoPositionInfoSource] Report errors when
failing to connect to Geoclue.
Task-number: QTBUG-40425
Change-Id: If3fa0929b724aa70a1fed01b5951f5bc9bd5adad
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r-- | src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp | 31 | ||||
-rw-r--r-- | src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster_p.h | 3 |
2 files changed, 26 insertions, 8 deletions
diff --git a/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp b/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp index 0b4c1414..8e6e1b61 100644 --- a/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp +++ b/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster.cpp @@ -115,7 +115,7 @@ QGeoPositionInfoSourceGeoclueMaster::QGeoPositionInfoSourceGeoclueMaster(QObject : QGeoPositionInfoSource(parent), QGeoclueMaster(this), m_pos(0), m_vel(0), m_lastVelocityIsFresh(false), m_regularUpdateTimedOut(false), m_lastVelocity(qQNaN()), m_lastDirection(qQNaN()), m_lastClimb(qQNaN()), m_lastPositionFromSatellite(false), - m_methods(AllPositioningMethods), m_running(false) + m_methods(AllPositioningMethods), m_running(false), m_error(NoError) { #ifndef QT_NO_DATASTREAM // Load the last known location @@ -497,25 +497,42 @@ void QGeoPositionInfoSourceGeoclueMaster::positionProviderChanged(const QByteArr } } -bool QGeoPositionInfoSourceGeoclueMaster::configurePositionSource() +void QGeoPositionInfoSourceGeoclueMaster::configurePositionSource() { + GeoclueAccuracyLevel accuracy; + GeoclueResourceFlags resourceFlags; + switch (preferredPositioningMethods()) { case SatellitePositioningMethods: - return createMasterClient(GEOCLUE_ACCURACY_LEVEL_DETAILED, GEOCLUE_RESOURCE_GPS); + accuracy = GEOCLUE_ACCURACY_LEVEL_DETAILED; + resourceFlags = GEOCLUE_RESOURCE_GPS; + break; case NonSatellitePositioningMethods: - return createMasterClient(GEOCLUE_ACCURACY_LEVEL_NONE, GeoclueResourceFlags(GEOCLUE_RESOURCE_CELL | GEOCLUE_RESOURCE_NETWORK)); + accuracy = GEOCLUE_ACCURACY_LEVEL_NONE; + resourceFlags = GeoclueResourceFlags(GEOCLUE_RESOURCE_CELL | GEOCLUE_RESOURCE_NETWORK); + break; case AllPositioningMethods: - return createMasterClient(GEOCLUE_ACCURACY_LEVEL_NONE, GEOCLUE_RESOURCE_ALL); + accuracy = GEOCLUE_ACCURACY_LEVEL_NONE; + resourceFlags = GEOCLUE_RESOURCE_ALL; + break; default: qWarning("GeoPositionInfoSourceGeoClueMaster unknown preferred method."); + m_error = UnknownSourceError; + emit QGeoPositionInfoSource::error(m_error); + return; } - return false; + if (createMasterClient(accuracy, resourceFlags)) { + m_error = NoError; + } else { + m_error = UnknownSourceError; + emit QGeoPositionInfoSource::error(m_error); + } } QGeoPositionInfoSource::Error QGeoPositionInfoSourceGeoclueMaster::error() const { - return NoError; + return m_error; } #include "moc_qgeopositioninfosource_geocluemaster_p.cpp" diff --git a/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster_p.h b/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster_p.h index 3f88334a..193c9765 100644 --- a/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster_p.h +++ b/src/plugins/position/geoclue/qgeopositioninfosource_geocluemaster_p.h @@ -101,7 +101,7 @@ private slots: void positionProviderChanged(const QByteArray &service, const QByteArray &path); private: - bool configurePositionSource(); + void configurePositionSource(); void cleanupPositionSource(); void setOptions(); @@ -118,6 +118,7 @@ private: QGeoPositionInfo m_lastPosition; PositioningMethods m_methods; bool m_running; + QGeoPositionInfoSource::Error m_error; }; QT_END_NAMESPACE |