Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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>

Upstream commit SHA1: 7d9173d
  • Loading branch information
Aaron McCarthy authored and rainemak committed Jan 15, 2018
1 parent 222e16f commit ae29aff
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
Expand Up @@ -116,7 +116,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
Expand Down Expand Up @@ -505,25 +505,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"
Expand Down
Expand Up @@ -102,7 +102,7 @@ private slots:
void positionProviderChanged(const QByteArray &service, const QByteArray &path);

private:
bool configurePositionSource();
void configurePositionSource();
void cleanupPositionSource();
void setOptions();

Expand All @@ -119,6 +119,7 @@ private slots:
QGeoPositionInfo m_lastPosition;
PositioningMethods m_methods;
bool m_running;
QGeoPositionInfoSource::Error m_error;
};

QT_END_NAMESPACE
Expand Down

0 comments on commit ae29aff

Please sign in to comment.