--- a/qtmobility/plugins/sensors/maemo6/maemo6proximitysensor.cpp Fri Jun 11 14:26:25 2010 +0300
+++ b/qtmobility/plugins/sensors/maemo6/maemo6proximitysensor.cpp Wed Jun 23 19:08:38 2010 +0300
@@ -41,40 +41,32 @@
#include "maemo6proximitysensor.h"
-const char *maemo6proximitysensor::id("maemo6.proximity");
+char const * const maemo6proximitysensor::id("maemo6.proximity");
bool maemo6proximitysensor::m_initDone = false;
maemo6proximitysensor::maemo6proximitysensor(QSensor *sensor)
: maemo6sensorbase(sensor)
{
- setReading<QProximityReading>(&m_reading);
-
- if (!m_initDone) {
- initSensor<ProximitySensorChannelInterface>("proximitysensor");
+ const QString sensorName = "proximitysensor";
+ initSensor<ProximitySensorChannelInterface>(sensorName, m_initDone);
- if (m_sensorInterface)
- QObject::connect(static_cast<ProximitySensorChannelInterface*>(m_sensorInterface), SIGNAL(dataAvailable(const Unsigned&)), this, SLOT(slotDataAvailable(const Unsigned&)));
- else
- qWarning() << "Unable to initialize proximity sensor.";
-
- // metadata
- addDataRate(2, 2); // 2Hz
- sensor->setDataRate(2);
- addOutputRange(0, 1, 1); // close definition in meters - may be used as metadata even the sensor gives true/false values
- setDescription(QLatin1String("Measures if a living object is in proximity or not"));
-
- m_initDone = true;
+ if (m_sensorInterface){
+ if (!(QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const Unsigned&)),
+ this, SLOT(slotDataAvailable(const Unsigned&)))))
+ qWarning() << "Unable to connect "<< sensorName;
}
+ else
+ qWarning() << "Unable to initialize "<<sensorName;
+ setReading<QProximityReading>(&m_reading);
+ // metadata
+ addDataRate(2, 2); // 2 Hz
+ addOutputRange(0, 1, 1); // close definition in meters - may be used as metadata even the sensor gives true/false values
+ setDescription(QLatin1String("Measures if a living object is in proximity or not"));
}
void maemo6proximitysensor::slotDataAvailable(const Unsigned& data)
{
- bool close;
- if (data.x())
- close = true;
- else
- close = false;
- m_reading.setClose(close);
+ m_reading.setClose(data.x()? true: false);
m_reading.setTimestamp(data.UnsignedData().timestamp_);
newReadingAvailable();
}