Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb41029' into 'master'
Fix location satelliteinfo

See merge request mer-core/qtlocation!14
  • Loading branch information
rainemak committed Apr 10, 2018
2 parents 1114406 + 0f3262c commit e420927
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
12 changes: 12 additions & 0 deletions src/plugins/position/geoclue/geocluetypes.cpp
Expand Up @@ -64,6 +64,18 @@ const QDBusArgument &operator>>(const QDBusArgument &arg, Accuracy &accuracy)
return dbus_argument_helper(arg, accuracy);
}

QDBusArgument &operator<<(QDBusArgument &arg, const QGeoSatelliteInfo &si)
{
arg.beginStructure();
arg << si.satelliteIdentifier();
arg << (qint32)si.attribute(QGeoSatelliteInfo::Elevation);
arg << (qint32)si.attribute(QGeoSatelliteInfo::Azimuth);
arg << si.signalStrength();
arg.endStructure();

return arg;
}

const QDBusArgument &operator>>(const QDBusArgument &argument, QGeoSatelliteInfo &si)
{
qint32 a;
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/position/geoclue/geocluetypes.h
Expand Up @@ -79,6 +79,8 @@ class Accuracy
};

Q_DECLARE_METATYPE(Accuracy)
Q_DECLARE_METATYPE(QList<int>)
Q_DECLARE_METATYPE(QGeoSatelliteInfo)
Q_DECLARE_METATYPE(QList<QGeoSatelliteInfo>)


Expand All @@ -89,6 +91,7 @@ Q_DECLARE_TYPEINFO(Accuracy, Q_MOVABLE_TYPE);
QDBusArgument &operator<<(QDBusArgument &arg, const Accuracy &accuracy);
const QDBusArgument &operator>>(const QDBusArgument &arg, Accuracy &accuracy);

QDBusArgument &operator<<(QDBusArgument &arg, const QGeoSatelliteInfo &si);
const QDBusArgument &operator>>(const QDBusArgument &arg, QGeoSatelliteInfo &si);
const QDBusArgument &operator>>(const QDBusArgument &arg, QList<QGeoSatelliteInfo> &sis);

Expand Down
Expand Up @@ -8,7 +8,7 @@
<arg name="satelliteVisible" type="i" direction="out" />
<arg name="usedPrn" type="ai" direction="out" />
<arg name="satInfo" type="a(iiii)" direction="out" />
<annotation name="org.qtproject.QtDBus.QtTypeName.Out3" value="QList&lt;qint32&gt;"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out3" value="QList&lt;int&gt;"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out4" value="QList&lt;QGeoSatelliteInfo&gt;"/>
</method>
<method name="GetLastSatellite">
Expand All @@ -17,16 +17,16 @@
<arg name="satelliteVisible" type="i" direction="out" />
<arg name="usedPrn" type="ai" direction="out" />
<arg name="satInfo" type="a(iiii)" direction="out" />
<annotation name="org.qtproject.QtDBus.QtTypeName.Out3" value="QList&lt;qint32&gt;"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out3" value="QList&lt;int&gt;"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out4" value="QList&lt;QGeoSatelliteInfo&gt;"/>
</method>
<signal name="SatelliteChanged">
<arg name="timestamp" type="i" />
<arg name="satelliteUsed" type="i" />
<arg name="satelliteVisible" type="i" />
<arg name="usedPrn" type="ai" />
<arg name="satInfo" type="a(iiii)" />'
<annotation name="org.qtproject.QtDBus.QtTypeName.In3" value="QList&lt;qint32&gt;"/>
<arg name="satInfo" type="a(iiii)" />
<annotation name="org.qtproject.QtDBus.QtTypeName.In3" value="QList&lt;int&gt;"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In4" value="QList&lt;QGeoSatelliteInfo&gt;"/>
</signal>
</interface>
Expand Down
Expand Up @@ -48,14 +48,15 @@

#define MINIMUM_UPDATE_INTERVAL 1000

Q_DECLARE_METATYPE(QList<int>)

QT_BEGIN_NAMESPACE

QGeoSatelliteInfoSourceGeoclueMaster::QGeoSatelliteInfoSourceGeoclueMaster(QObject *parent)
: QGeoSatelliteInfoSource(parent), m_master(new QGeoclueMaster(this)), m_provider(0), m_sat(0),
m_error(NoError), m_satellitesChangedConnected(false), m_running(false)
{
qDBusRegisterMetaType<QGeoSatelliteInfo>();
qDBusRegisterMetaType<QList<QGeoSatelliteInfo> >();

connect(m_master, SIGNAL(positionProviderChanged(QString,QString,QString,QString)),
this, SLOT(positionProviderChanged(QString,QString,QString,QString)));
m_requestTimer.setSingleShot(true);
Expand All @@ -74,10 +75,7 @@ int QGeoSatelliteInfoSourceGeoclueMaster::minimumUpdateInterval() const

void QGeoSatelliteInfoSourceGeoclueMaster::setUpdateInterval(int msec)
{
if (msec < 0 || (msec > 0 && msec < MINIMUM_UPDATE_INTERVAL))
msec = MINIMUM_UPDATE_INTERVAL;

QGeoSatelliteInfoSource::setUpdateInterval(msec);
QGeoSatelliteInfoSource::setUpdateInterval(qMax(MINIMUM_UPDATE_INTERVAL, msec));
}

QGeoSatelliteInfoSource::Error QGeoSatelliteInfoSourceGeoclueMaster::error() const
Expand All @@ -96,7 +94,7 @@ void QGeoSatelliteInfoSourceGeoclueMaster::startUpdates()
if (!m_master->hasMasterClient())
configureSatelliteSource();

m_requestTimer.start(updateInterval());
m_requestTimer.start(qMax(updateInterval(), minimumUpdateInterval()));
}

void QGeoSatelliteInfoSourceGeoclueMaster::stopUpdates()
Expand All @@ -105,8 +103,8 @@ void QGeoSatelliteInfoSourceGeoclueMaster::stopUpdates()
return;

if (m_sat) {
disconnect(m_sat, SIGNAL(SatelliteChanged(qint32,qint32,qint32,QList<qint32>,QList<QGeoSatelliteInfo>)),
this, SLOT(satelliteChanged(qint32,qint32,qint32,QList<qint32>,QList<QGeoSatelliteInfo>)));
disconnect(m_sat, SIGNAL(SatelliteChanged(int,int,int,QList<int>,QList<QGeoSatelliteInfo>)),
this, SLOT(satelliteChanged(int,int,int,QList<int>,QList<QGeoSatelliteInfo>)));
}

m_running = false;
Expand Down Expand Up @@ -134,7 +132,7 @@ void QGeoSatelliteInfoSourceGeoclueMaster::requestUpdate(int timeout)
m_requestTimer.start(qMax(timeout, minimumUpdateInterval()));

if (m_sat) {
QDBusPendingReply<qint32, qint32, qint32, QList<qint32>, QList<QGeoSatelliteInfo> > reply =
QDBusPendingReply<int, int, int, QList<int>, QList<QGeoSatelliteInfo> > reply =
m_sat->GetSatellite();
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
Expand All @@ -147,6 +145,7 @@ void QGeoSatelliteInfoSourceGeoclueMaster::updateSatelliteInfo(int timestamp, in
const QList<int> &usedPrn,
const QList<QGeoSatelliteInfo> &satInfos)
{
m_requestTimer.stop();
Q_UNUSED(timestamp)

QList<QGeoSatelliteInfo> inUse;
Expand All @@ -172,8 +171,6 @@ void QGeoSatelliteInfoSourceGeoclueMaster::updateSatelliteInfo(int timestamp, in

m_inUse = inUse;
emit satellitesInUseUpdated(m_inUse);

m_requestTimer.start(updateInterval());
}

void QGeoSatelliteInfoSourceGeoclueMaster::requestUpdateTimeout()
Expand All @@ -195,13 +192,12 @@ void QGeoSatelliteInfoSourceGeoclueMaster::requestUpdateTimeout()

void QGeoSatelliteInfoSourceGeoclueMaster::getSatelliteFinished(QDBusPendingCallWatcher *watcher)
{
QDBusPendingReply<qint32, qint32, qint32, QList<qint32>, QList<QGeoSatelliteInfo> > reply = *watcher;
QDBusPendingReply<int, int, int, QList<int>, QList<QGeoSatelliteInfo> > reply = *watcher;
watcher->deleteLater();

if (reply.isError())
return;

m_requestTimer.stop();
updateSatelliteInfo(reply.argumentAt<0>(), reply.argumentAt<1>(), reply.argumentAt<2>(),
reply.argumentAt<3>(), reply.argumentAt<4>());
}
Expand Down Expand Up @@ -261,8 +257,8 @@ void QGeoSatelliteInfoSourceGeoclueMaster::positionProviderChanged(const QString
m_sat = new OrgFreedesktopGeoclueSatelliteInterface(providerService, providerPath, QDBusConnection::sessionBus());

if (m_running) {
connect(m_sat, SIGNAL(SatelliteChanged(qint32,qint32,qint32,QList<qint32>,QList<QGeoSatelliteInfo>)),
this, SLOT(satelliteChanged(qint32,qint32,qint32,QList<qint32>,QList<QGeoSatelliteInfo>)));
connect(m_sat, SIGNAL(SatelliteChanged(int,int,int,QList<int>,QList<QGeoSatelliteInfo>)),
this, SLOT(satelliteChanged(int,int,int,QList<int>,QList<QGeoSatelliteInfo>)));
}
}

Expand Down Expand Up @@ -305,6 +301,8 @@ void QGeoSatelliteInfoSourceGeoclueMaster::cleanupSatelliteSource()
m_provider = 0;
delete m_sat;
m_sat = 0;

m_requestTimer.stop();
}

QT_END_NAMESPACE

0 comments on commit e420927

Please sign in to comment.