summaryrefslogtreecommitdiff
path: root/src/plugins/sensors/simulator
diff options
context:
space:
mode:
authorAlex <qt-info@nokia.com>2011-06-09 18:31:09 +1000
committerAlex <qt-info@nokia.com>2011-06-10 15:34:08 +1000
commit164e4f5813d8beb30ce8e1555f49f84b785c0d51 (patch)
tree5ee0569d239e50695f6ae4c3357b506ea16b1abb /src/plugins/sensors/simulator
parentca4eb890b701035dfd472e0fb9aab23a9733a01d (diff)
downloadqtsensors-164e4f5813d8beb30ce8e1555f49f84b785c0d51.tar.gz
Add dummy, generic and simulator backend
The Simulator backend is not working/tested at this stage as the simulator library is not available for Qt5 at this stage. In addtion the sensor_explorer test app was added for simple sensor testing.
Diffstat (limited to 'src/plugins/sensors/simulator')
-rw-r--r--src/plugins/sensors/simulator/main.cpp102
-rw-r--r--src/plugins/sensors/simulator/qsensordata_simulator.cpp128
-rw-r--r--src/plugins/sensors/simulator/qsensordata_simulator_p.h116
-rw-r--r--src/plugins/sensors/simulator/simulator.pri19
-rw-r--r--src/plugins/sensors/simulator/simulator.pro19
-rw-r--r--src/plugins/sensors/simulator/simulatoraccelerometer.cpp74
-rw-r--r--src/plugins/sensors/simulator/simulatoraccelerometer.h61
-rw-r--r--src/plugins/sensors/simulator/simulatorambientlightsensor.cpp70
-rw-r--r--src/plugins/sensors/simulator/simulatorambientlightsensor.h61
-rw-r--r--src/plugins/sensors/simulator/simulatorcommon.cpp200
-rw-r--r--src/plugins/sensors/simulator/simulatorcommon.h104
-rw-r--r--src/plugins/sensors/simulator/simulatorcompass.cpp72
-rw-r--r--src/plugins/sensors/simulator/simulatorcompass.h61
-rw-r--r--src/plugins/sensors/simulator/simulatorlightsensor.cpp70
-rw-r--r--src/plugins/sensors/simulator/simulatorlightsensor.h61
-rw-r--r--src/plugins/sensors/simulator/simulatormagnetometer.cpp76
-rw-r--r--src/plugins/sensors/simulator/simulatormagnetometer.h61
-rw-r--r--src/plugins/sensors/simulator/simulatorproximitysensor.cpp70
-rw-r--r--src/plugins/sensors/simulator/simulatorproximitysensor.h61
19 files changed, 1486 insertions, 0 deletions
diff --git a/src/plugins/sensors/simulator/main.cpp b/src/plugins/sensors/simulator/main.cpp
new file mode 100644
index 0000000..be932ad
--- /dev/null
+++ b/src/plugins/sensors/simulator/main.cpp
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "simulatoraccelerometer.h"
+#include "simulatorambientlightsensor.h"
+#include "simulatorlightsensor.h"
+#include "simulatorcompass.h"
+#include "simulatorproximitysensor.h"
+#include "simulatormagnetometer.h"
+#include <qsensorplugin.h>
+#include <qsensorbackend.h>
+#include <qsensormanager.h>
+#include <QFile>
+#include <QDebug>
+
+class SimulatorSensorPlugin : public QObject, public QSensorPluginInterface, public QSensorBackendFactory
+{
+ Q_OBJECT
+ Q_INTERFACES(QSensorPluginInterface)
+public:
+ void registerSensors()
+ {
+ QSensorManager::registerBackend(QAccelerometer::type, SimulatorAccelerometer::id, this);
+ QSensorManager::registerBackend(QAmbientLightSensor::type, SimulatorAmbientLightSensor::id, this);
+ QSensorManager::registerBackend(QLightSensor::type, SimulatorLightSensor::id, this);
+ QSensorManager::registerBackend(QCompass::type, SimulatorCompass::id, this);
+ QSensorManager::registerBackend(QProximitySensor::type, SimulatorProximitySensor::id, this);
+ QSensorManager::registerBackend(QMagnetometer::type, SimulatorMagnetometer::id, this);
+ }
+
+ QSensorBackend *createBackend(QSensor *sensor)
+ {
+ if (sensor->identifier() == SimulatorAccelerometer::id) {
+ return new SimulatorAccelerometer(sensor);
+ }
+
+ if (sensor->identifier() == SimulatorAmbientLightSensor::id) {
+ return new SimulatorAmbientLightSensor(sensor);
+ }
+
+ if (sensor->identifier() == SimulatorLightSensor::id) {
+ return new SimulatorLightSensor(sensor);
+ }
+
+ if (sensor->identifier() == SimulatorProximitySensor::id) {
+ return new SimulatorProximitySensor(sensor);
+ }
+
+ if (sensor->identifier() == SimulatorCompass::id) {
+ return new SimulatorCompass(sensor);
+ }
+
+ if (sensor->identifier() == SimulatorMagnetometer::id) {
+ return new SimulatorMagnetometer(sensor);
+ }
+
+ return 0;
+ }
+};
+
+Q_EXPORT_PLUGIN2(libsensors_simulator, SimulatorSensorPlugin)
+
+#include "main.moc"
+
diff --git a/src/plugins/sensors/simulator/qsensordata_simulator.cpp b/src/plugins/sensors/simulator/qsensordata_simulator.cpp
new file mode 100644
index 0000000..205a333
--- /dev/null
+++ b/src/plugins/sensors/simulator/qsensordata_simulator.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsensordata_simulator_p.h"
+
+#include <QtCore/QDataStream>
+
+void qt_registerSensorTypes()
+{
+ qRegisterMetaTypeStreamOperators<QAmbientLightReadingData>("QtMobility::QAmbientLightReadingData");
+ qRegisterMetaTypeStreamOperators<QLightReadingData>("QtMobility::QLightReadingData");
+ qRegisterMetaTypeStreamOperators<QAccelerometerReadingData>("QtMobility::QAccelerometerReadingData");
+ qRegisterMetaTypeStreamOperators<QCompassReadingData>("QtMobility::QCompassReadingData");
+ qRegisterMetaTypeStreamOperators<QProximityReadingData>("QtMobility::QProximityReadingData");
+ qRegisterMetaTypeStreamOperators<QMagnetometerReadingData>("QtMobility::QMagnetometerReadingData");
+}
+
+QDataStream &operator<<(QDataStream &out, const QAmbientLightReadingData &s)
+{
+ out << static_cast<qint32>(s.lightLevel) << s.timestamp;
+ return out;
+}
+
+QDataStream &operator>>(QDataStream &in, QAmbientLightReadingData &s)
+{
+ qint32 lightLevel;
+ in >> lightLevel >> s.timestamp;
+ s.lightLevel = static_cast<QAmbientLightReading::LightLevel>(lightLevel);
+ return in;
+}
+
+QDataStream &operator<<(QDataStream &out, const QLightReadingData &s)
+{
+ out << s.lux << s.timestamp;
+ return out;
+}
+
+QDataStream &operator>>(QDataStream &in, QLightReadingData &s)
+{
+ in >> s.lux >> s.timestamp;
+ return in;
+}
+
+QDataStream &operator<<(QDataStream &out, const QAccelerometerReadingData &s)
+{
+ out << s.x << s.y << s.z << s.timestamp;
+ return out;
+}
+
+QDataStream &operator>>(QDataStream &in, QAccelerometerReadingData &s)
+{
+ in >> s.x >> s.y >> s.z >> s.timestamp;
+ return in;
+}
+
+QDataStream &operator<<(QDataStream &out, const QCompassReadingData &s)
+{
+ out << s.azimuth << s.calibrationLevel << s.timestamp;
+ return out;
+}
+
+QDataStream &operator>>(QDataStream &in, QCompassReadingData &s)
+{
+ in >> s.azimuth >> s.calibrationLevel >> s.timestamp;
+ return in;
+}
+
+QDataStream &operator<<(QDataStream &out, const QProximityReadingData &s)
+{
+ out << s.close << s.timestamp;
+ return out;
+}
+
+QDataStream &operator>>(QDataStream &in, QProximityReadingData &s)
+{
+ in >> s.close >> s.timestamp;
+ return in;
+}
+
+QDataStream &operator<<(QDataStream &out, const QMagnetometerReadingData &s)
+{
+ out << s.x << s.y << s.z << s.calibrationLevel << s.timestamp;
+ return out;
+}
+
+QDataStream &operator>>(QDataStream &in, QMagnetometerReadingData &s)
+{
+ in >> s.x >> s.y >> s.z >> s.calibrationLevel >> s.timestamp;
+ return in;
+}
diff --git a/src/plugins/sensors/simulator/qsensordata_simulator_p.h b/src/plugins/sensors/simulator/qsensordata_simulator_p.h
new file mode 100644
index 0000000..ca15ceb
--- /dev/null
+++ b/src/plugins/sensors/simulator/qsensordata_simulator_p.h
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSENSORDATA_SIMULATOR_P_H
+#define QSENSORDATA_SIMULATOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qambientlightsensor.h>
+#include <QtCore/QMetaType>
+#include <QtCore/QDateTime>
+
+QT_BEGIN_HEADER
+
+struct QAmbientLightReadingData
+{
+ QAmbientLightReading::LightLevel lightLevel;
+ QDateTime timestamp;
+};
+
+struct QLightReadingData
+{
+ double lux;
+ QDateTime timestamp;
+};
+
+struct QAccelerometerReadingData
+{
+ double x;
+ double y;
+ double z;
+ QDateTime timestamp;
+};
+
+struct QMagnetometerReadingData
+{
+ double x;
+ double y;
+ double z;
+ double calibrationLevel;
+ QDateTime timestamp;
+};
+
+struct QCompassReadingData
+{
+ double azimuth;
+ double calibrationLevel;
+ QDateTime timestamp;
+};
+
+struct QProximityReadingData
+{
+ bool close;
+ QDateTime timestamp;
+};
+
+void qt_registerSensorTypes();
+
+
+Q_DECLARE_METATYPE(QAmbientLightReadingData)
+Q_DECLARE_METATYPE(QLightReadingData)
+Q_DECLARE_METATYPE(QAccelerometerReadingData)
+Q_DECLARE_METATYPE(QMagnetometerReadingData)
+Q_DECLARE_METATYPE(QCompassReadingData)
+Q_DECLARE_METATYPE(QProximityReadingData)
+
+QT_END_HEADER
+
+#endif // QSENSORDATA_SIMULATOR_P_H
diff --git a/src/plugins/sensors/simulator/simulator.pri b/src/plugins/sensors/simulator/simulator.pri
new file mode 100644
index 0000000..bdce2b4
--- /dev/null
+++ b/src/plugins/sensors/simulator/simulator.pri
@@ -0,0 +1,19 @@
+HEADERS += simulatorcommon.h\
+ simulatoraccelerometer.h\
+ simulatorambientlightsensor.h\
+ simulatorlightsensor.h\
+ simulatorcompass.h\
+ simulatorproximitysensor.h\
+ simulatormagnetometer.h\
+ qsensordata_simulator_p.h
+
+SOURCES += simulatorcommon.cpp\
+ simulatoraccelerometer.cpp\
+ simulatorambientlightsensor.cpp\
+ simulatorlightsensor.cpp\
+ simulatorcompass.cpp\
+ simulatorproximitysensor.cpp\
+ simulatormagnetometer.cpp\
+ qsensordata_simulator.cpp\
+ main.cpp
+
diff --git a/src/plugins/sensors/simulator/simulator.pro b/src/plugins/sensors/simulator/simulator.pro
new file mode 100644
index 0000000..18f515b
--- /dev/null
+++ b/src/plugins/sensors/simulator/simulator.pro
@@ -0,0 +1,19 @@
+load(qt_module)
+
+include(simulator.pri)
+
+TARGET = qtsensors_simulator
+load(qt_plugin)
+
+DESTDIR = $$QT.sensors.plugins/sensors
+
+#TODO what is the simulator called in Qt 5?
+#qtAddLibrary(QtMobilitySimulator)
+
+symbian:TARGET.EPOCALLOWDLLDATA = 1
+
+QT=core gui network sensors
+
+target.path += $$[QT_INSTALL_PLUGINS]/sensors
+INSTALLS += target
+
diff --git a/src/plugins/sensors/simulator/simulatoraccelerometer.cpp b/src/plugins/sensors/simulator/simulatoraccelerometer.cpp
new file mode 100644
index 0000000..c1eb0f2
--- /dev/null
+++ b/src/plugins/sensors/simulator/simulatoraccelerometer.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "simulatoraccelerometer.h"
+#include <QDebug>
+#include <QtGlobal>
+
+const char *SimulatorAccelerometer::id("Simulator.Accelerometer");
+
+SimulatorAccelerometer::SimulatorAccelerometer(QSensor *sensor)
+ : SimulatorCommon(sensor)
+{
+ setReading<QAccelerometerReading>(&m_reading);
+}
+
+void SimulatorAccelerometer::poll()
+{
+ QtMobility::QAccelerometerReadingData data = get_qtAccelerometerData();
+ qtimestamp newTimestamp;
+ if (!data.timestamp.isValid())
+ newTimestamp = QDateTime::currentDateTime().toTime_t();
+ else
+ newTimestamp = data.timestamp.toTime_t();
+ if (m_reading.timestamp() != newTimestamp
+ || m_reading.x() != data.x
+ || m_reading.y() != data.y
+ || m_reading.z() != data.z) {
+ m_reading.setTimestamp(newTimestamp);
+ m_reading.setX(data.x);
+ m_reading.setY(data.y);
+ m_reading.setZ(data.z);
+
+ newReadingAvailable();
+ }
+}
+
diff --git a/src/plugins/sensors/simulator/simulatoraccelerometer.h b/src/plugins/sensors/simulator/simulatoraccelerometer.h
new file mode 100644
index 0000000..9c78508
--- /dev/null
+++ b/src/plugins/sensors/simulator/simulatoraccelerometer.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SIMULATORACCELEROMETER_H
+#define SIMULATORACCELEROMETER_H
+
+#include "simulatorcommon.h"
+#include <qaccelerometer.h>
+
+class SimulatorAccelerometer : public SimulatorCommon
+{
+public:
+ static const char *id;
+
+ SimulatorAccelerometer(QSensor *sensor);
+
+ void poll();
+private:
+ QAccelerometerReading m_reading;
+};
+
+#endif
+
diff --git a/src/plugins/sensors/simulator/simulatorambientlightsensor.cpp b/src/plugins/sensors/simulator/simulatorambientlightsensor.cpp
new file mode 100644
index 0000000..d23412d
--- /dev/null
+++ b/src/plugins/sensors/simulator/simulatorambientlightsensor.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "simulatorambientlightsensor.h"
+#include <QDebug>
+#include <QtGlobal>
+
+const char *SimulatorAmbientLightSensor::id("Simulator.AmbientLightSensor");
+
+SimulatorAmbientLightSensor::SimulatorAmbientLightSensor(QSensor *sensor)
+ : SimulatorCommon(sensor)
+{
+ setReading<QAmbientLightReading>(&m_reading);
+}
+
+void SimulatorAmbientLightSensor::poll()
+{
+ QAmbientLightReadingData data = get_qtAmbientLightData();
+ qtimestamp newTimestamp;
+ if (!data.timestamp.isValid())
+ newTimestamp = QDateTime::currentDateTime().toTime_t();
+ else
+ newTimestamp = data.timestamp.toTime_t();
+ if (m_reading.timestamp() != newTimestamp
+ || m_reading.lightLevel() != data.lightLevel) {
+ m_reading.setTimestamp(newTimestamp);
+ m_reading.setLightLevel(data.lightLevel);
+
+ newReadingAvailable();
+ }
+}
+
diff --git a/src/plugins/sensors/simulator/simulatorambientlightsensor.h b/src/plugins/sensors/simulator/simulatorambientlightsensor.h
new file mode 100644
index 0000000..441f3ed
--- /dev/null
+++ b/src/plugins/sensors/simulator/simulatorambientlightsensor.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SIMULATORAMBIENTLIGHTSENSOR_H
+#define SIMULATORAMBIENTLIGHTSENSOR_H
+
+#include "simulatorcommon.h"
+#include <qambientlightsensor.h>
+
+class SimulatorAmbientLightSensor : public SimulatorCommon
+{
+public:
+ static const char *id;
+
+ SimulatorAmbientLightSensor(QSensor *sensor);
+
+ void poll();
+private:
+ QAmbientLightReading m_reading;
+};
+
+#endif
+
diff --git a/src/plugins/sensors/simulator/simulatorcommon.cpp b/src/plugins/sensors/simulator/simulatorcommon.cpp
new file mode 100644
index 0000000..c7c46ed
--- /dev/null
+++ b/src/plugins/sensors/simulator/simulatorcommon.cpp
@@ -0,0 +1,200 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "simulatorcommon.h"
+#include "qsensordata_simulator_p.h"
+#include "mobilitysimulatorglobal.h"
+#include <mobilityconnection_p.h>
+
+#include <private/qsimulatordata_p.h>
+
+#include <QtNetwork/QLocalSocket>
+
+using namespace QtSimulatorPrivate;
+
+Q_GLOBAL_STATIC(QAmbientLightReadingData, qtAmbientLightData)
+Q_GLOBAL_STATIC(QLightReadingData, qtLightData)
+Q_GLOBAL_STATIC(QAccelerometerReadingData, qtAccelerometerData)
+Q_GLOBAL_STATIC(QMagnetometerReadingData, qtMagnetometerData)
+Q_GLOBAL_STATIC(QCompassReadingData, qtCompassData)
+Q_GLOBAL_STATIC(QProximityReadingData, qtProximityData)
+
+namespace Simulator
+{
+ SensorsConnection::SensorsConnection(MobilityConnection *mobilityCon)
+ : QObject(mobilityCon)
+ , mConnection(mobilityCon)
+ , mInitialDataReceived(false)
+ {
+ qt_registerSensorTypes();
+ mobilityCon->addMessageHandler(this);
+ }
+
+
+ void SensorsConnection::getInitialData()
+ {
+ RemoteMetacall<void>::call(mConnection->sendSocket(), NoSync, "setRequestsSensors");
+
+ while (!mInitialDataReceived) {
+ mConnection->receiveSocket()->waitForReadyRead(100);
+ mConnection->onReadyRead();
+ }
+ }
+
+ void SensorsConnection::initialSensorsDataSent()
+ {
+ mInitialDataReceived = true;
+ }
+
+ void SensorsConnection::setAmbientLightData(const QAmbientLightReadingData &data)
+ {
+ *qtAmbientLightData() = data;
+ }
+
+ void SensorsConnection::setLightData(const QLightReadingData &data)
+ {
+ *qtLightData() = data;
+ }
+
+ void SensorsConnection::setAccelerometerData(const QAccelerometerReadingData &data)
+ {
+ *qtAccelerometerData() = data;
+ }
+
+ void SensorsConnection::setMagnetometerData(const QMagnetometerReadingData &data)
+ {
+ *qtMagnetometerData() = data;
+ }
+
+ void SensorsConnection::setCompassData(const QCompassReadingData &data)
+ {
+ *qtCompassData() = data;
+ }
+
+ void SensorsConnection::setProximityData(const QProximityReadingData &data)
+ {
+ *qtProximityData() = data;
+ }
+} // namespace
+
+void ensureSimulatorConnection()
+{
+ using namespace Simulator;
+
+ static bool connected = false;
+ if (connected)
+ return;
+
+ connected = true;
+ MobilityConnection *connection = MobilityConnection::instance();
+ SensorsConnection *sensorsConnection = new SensorsConnection(connection);
+ sensorsConnection->getInitialData();
+}
+
+SimulatorCommon::SimulatorCommon(QSensor *sensor)
+ : QSensorBackend(sensor)
+ , m_timerid(0)
+{
+ addDataRate(1, 100);
+ sensor->setDataRate(20);
+ ensureSimulatorConnection();
+}
+
+void SimulatorCommon::start()
+{
+ if (m_timerid)
+ return;
+
+ int rate = sensor()->dataRate();
+ if (rate == 0)
+ rate = 20;
+ int interval = 1000 / rate;
+ if (interval < 0)
+ interval = 1000;
+
+ if (interval)
+ m_timerid = startTimer(interval);
+}
+
+void SimulatorCommon::stop()
+{
+ if (m_timerid) {
+ killTimer(m_timerid);
+ m_timerid = 0;
+ }
+}
+
+void SimulatorCommon::timerEvent(QTimerEvent * /*event*/)
+{
+ poll();
+}
+
+QAccelerometerReadingData get_qtAccelerometerData()
+{
+ return *qtAccelerometerData();
+}
+
+QMagnetometerReadingData get_qtMagnetometerData()
+{
+ return *qtMagnetometerData();
+}
+
+QAmbientLightReadingData get_qtAmbientLightData()
+{
+ return *qtAmbientLightData();
+}
+
+QLightReadingData get_qtLightData()
+{
+ return *qtLightData();
+}
+
+QCompassReadingData get_qtCompassData()
+{
+ return *qtCompassData();
+}
+
+QProximityReadingData get_qtProximityData()
+{
+ return *qtProximityData();
+}
+
+#include "moc_simulatorcommon.cpp"
diff --git a/src/plugins/sensors/simulator/simulatorcommon.h b/src/plugins/sensors/simulator/simulatorcommon.h
new file mode 100644
index 0000000..312a95d
--- /dev/null
+++ b/src/plugins/sensors/simulator/simulatorcommon.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SIMULATORCOMMON_H
+#define SIMULATORCOMMON_H
+
+#include <qsensorbackend.h>
+#include "qsensordata_simulator_p.h"
+
+QT_BEGIN_HEADER
+
+class QTimer;
+
+namespace Simulator
+{
+ class MobilityConnection;
+
+ class SensorsConnection : public QObject
+ {
+ Q_OBJECT
+ public:
+ SensorsConnection(MobilityConnection *mobilityCon);
+ virtual ~SensorsConnection() {}
+
+ void getInitialData();
+
+ private slots:
+ void setAmbientLightData(const QtMobility::QAmbientLightReadingData &);
+ void setLightData(const QtMobility::QLightReadingData &);
+ void setAccelerometerData(const QtMobility::QAccelerometerReadingData &);
+ void setMagnetometerData(const QtMobility::QMagnetometerReadingData &);
+ void setCompassData(const QtMobility::QCompassReadingData &);
+ void setProximityData(const QtMobility::QProximityReadingData &);
+ void initialSensorsDataSent();
+
+ private:
+ MobilityConnection *mConnection;
+ bool mInitialDataReceived;
+ };
+} // end namespace Simulator
+
+class SimulatorCommon : public QSensorBackend
+{
+public:
+ SimulatorCommon(QSensor *sensor);
+
+ void start();
+ void stop();
+ virtual void poll() = 0;
+ void timerEvent(QTimerEvent * /*event*/);
+
+private:
+ int m_timerid;
+};
+
+QAccelerometerReadingData get_qtAccelerometerData();
+QMagnetometerReadingData get_qtMagnetometerData();
+QAmbientLightReadingData get_qtAmbientLightData();
+QLightReadingData get_qtLightData();
+QCompassReadingData get_qtCompassData();
+QProximityReadingData get_qtProximityData();
+
+QT_END_HEADER
+
+#endif
+
diff --git a/src/plugins/sensors/simulator/simulatorcompass.cpp b/src/plugins/sensors/simulator/simulatorcompass.cpp
new file mode 100644
index 0000000..d6a2ccc
--- /dev/null
+++ b/src/plugins/sensors/simulator/simulatorcompass.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "simulatorcompass.h"
+#include <QDebug>
+#include <QtGlobal>
+
+const char *SimulatorCompass::id("Simulator.Compass");
+
+SimulatorCompass::SimulatorCompass(QSensor *sensor)
+ : SimulatorCommon(sensor)
+{
+ setReading<QCompassReading>(&m_reading);
+}
+
+void SimulatorCompass::poll()
+{
+ QtMobility::QCompassReadingData data = get_qtCompassData();
+ qtimestamp newTimestamp;
+ if (!data.timestamp.isValid())
+ newTimestamp = QDateTime::currentDateTime().toTime_t();
+ else
+ newTimestamp = data.timestamp.toTime_t();
+ if (m_reading.timestamp() != newTimestamp
+ || m_reading.azimuth() != data.azimuth
+ || m_reading.calibrationLevel() != data.calibrationLevel) {
+ m_reading.setTimestamp(newTimestamp);
+ m_reading.setAzimuth(data.azimuth);
+ m_reading.setCalibrationLevel(data.calibrationLevel);
+
+ newReadingAvailable();
+ }
+}
+
diff --git a/src/plugins/sensors/simulator/simulatorcompass.h b/src/plugins/sensors/simulator/simulatorcompass.h
new file mode 100644
index 0000000..4ad3a05
--- /dev/null
+++ b/src/plugins/sensors/simulator/simulatorcompass.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SIMULATORCOMPASS_H
+#define SIMULATORCOMPASS_H
+
+#include "simulatorcommon.h"
+#include <qcompass.h>
+
+class SimulatorCompass : public SimulatorCommon
+{
+public:
+ static const char *id;
+
+ SimulatorCompass(QSensor *sensor);
+
+ void poll();
+private:
+ QCompassReading m_reading;
+};
+
+#endif
+
diff --git a/src/plugins/sensors/simulator/simulatorlightsensor.cpp b/src/plugins/sensors/simulator/simulatorlightsensor.cpp
new file mode 100644
index 0000000..9cce94d
--- /dev/null
+++ b/src/plugins/sensors/simulator/simulatorlightsensor.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "simulatorlightsensor.h"
+#include <QDebug>
+#include <QtGlobal>
+
+const char *SimulatorLightSensor::id("Simulator.LightSensor");
+
+SimulatorLightSensor::SimulatorLightSensor(QSensor *sensor)
+ : SimulatorCommon(sensor)
+{
+ setReading<QLightReading>(&m_reading);
+}
+
+void SimulatorLightSensor::poll()
+{
+ QLightReadingData data = get_qtLightData();
+ qtimestamp newTimestamp;
+ if (!data.timestamp.isValid())
+ newTimestamp = QDateTime::currentDateTime().toTime_t();
+ else
+ newTimestamp = data.timestamp.toTime_t();
+ if (m_reading.timestamp() != newTimestamp
+ || m_reading.lux() != data.lux) {
+ m_reading.setTimestamp(newTimestamp);
+ m_reading.setLux(data.lux);
+
+ newReadingAvailable();
+ }
+}
+
diff --git a/src/plugins/sensors/simulator/simulatorlightsensor.h b/src/plugins/sensors/simulator/simulatorlightsensor.h
new file mode 100644
index 0000000..acd44c0
--- /dev/null
+++ b/src/plugins/sensors/simulator/simulatorlightsensor.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SIMULATORLIGHTSENSOR_H
+#define SIMULATORLIGHTSENSOR_H
+
+#include "simulatorcommon.h"
+#include <qlightsensor.h>
+
+class SimulatorLightSensor : public SimulatorCommon
+{
+public:
+ static const char *id;
+
+ SimulatorLightSensor(QSensor *sensor);
+
+ void poll();
+private:
+ QLightReading m_reading;
+};
+
+#endif
+
diff --git a/src/plugins/sensors/simulator/simulatormagnetometer.cpp b/src/plugins/sensors/simulator/simulatormagnetometer.cpp
new file mode 100644
index 0000000..ab0ba5d
--- /dev/null
+++ b/src/plugins/sensors/simulator/simulatormagnetometer.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "simulatormagnetometer.h"
+#include <QDebug>
+#include <QtGlobal>
+
+const char *SimulatorMagnetometer::id("Simulator.Magnetometer");
+
+SimulatorMagnetometer::SimulatorMagnetometer(QSensor *sensor)
+ : SimulatorCommon(sensor)
+{
+ setReading<QMagnetometerReading>(&m_reading);
+}
+
+void SimulatorMagnetometer::poll()
+{
+ QtMobility::QMagnetometerReadingData data = get_qtMagnetometerData();
+ qtimestamp newTimestamp;
+ if (!data.timestamp.isValid())
+ newTimestamp = QDateTime::currentDateTime().toTime_t();
+ else
+ newTimestamp = data.timestamp.toTime_t();
+ if (m_reading.timestamp() != newTimestamp
+ || m_reading.x() != data.x
+ || m_reading.y() != data.y
+ || m_reading.z() != data.z
+ || m_reading.calibrationLevel() != data.calibrationLevel) {
+ m_reading.setTimestamp(newTimestamp);
+ m_reading.setX(data.x);
+ m_reading.setY(data.y);
+ m_reading.setZ(data.z);
+ m_reading.setCalibrationLevel(data.calibrationLevel);
+
+ newReadingAvailable();
+ }
+}
+
diff --git a/src/plugins/sensors/simulator/simulatormagnetometer.h b/src/plugins/sensors/simulator/simulatormagnetometer.h
new file mode 100644
index 0000000..6cf7512
--- /dev/null
+++ b/src/plugins/sensors/simulator/simulatormagnetometer.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SIMULATORMAGNETOMETER_H
+#define SIMULATORMAGNETOMETER_H
+
+#include "simulatorcommon.h"
+#include <qmagnetometer.h>
+
+class SimulatorMagnetometer : public SimulatorCommon
+{
+public:
+ static const char *id;
+
+ SimulatorMagnetometer(QSensor *sensor);
+
+ void poll();
+private:
+ QMagnetometerReading m_reading;
+};
+
+#endif
+
diff --git a/src/plugins/sensors/simulator/simulatorproximitysensor.cpp b/src/plugins/sensors/simulator/simulatorproximitysensor.cpp
new file mode 100644
index 0000000..44b9926
--- /dev/null
+++ b/src/plugins/sensors/simulator/simulatorproximitysensor.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "simulatorproximitysensor.h"
+#include <QDebug>
+#include <QtGlobal>
+
+const char *SimulatorProximitySensor::id("Simulator.ProximitySensor");
+
+SimulatorProximitySensor::SimulatorProximitySensor(QSensor *sensor)
+ : SimulatorCommon(sensor)
+{
+ setReading<QProximityReading>(&m_reading);
+}
+
+void SimulatorProximitySensor::poll()
+{
+ QtMobility::QProximityReadingData data = get_qtProximityData();
+ qtimestamp newTimestamp;
+ if (!data.timestamp.isValid())
+ newTimestamp = QDateTime::currentDateTime().toTime_t();
+ else
+ newTimestamp = data.timestamp.toTime_t();
+ if (m_reading.timestamp() != newTimestamp
+ || m_reading.close() != data.close) {
+ m_reading.setTimestamp(newTimestamp);
+ m_reading.setClose(data.close);
+
+ newReadingAvailable();
+ }
+}
+
diff --git a/src/plugins/sensors/simulator/simulatorproximitysensor.h b/src/plugins/sensors/simulator/simulatorproximitysensor.h
new file mode 100644
index 0000000..5b2a177
--- /dev/null
+++ b/src/plugins/sensors/simulator/simulatorproximitysensor.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SIMULATORPROXIMITYSENSOR_H
+#define SIMULATORPROXIMITYSENSOR_H
+
+#include "simulatorcommon.h"
+#include <qproximitysensor.h>
+
+class SimulatorProximitySensor : public SimulatorCommon
+{
+public:
+ static const char *id;
+
+ SimulatorProximitySensor(QSensor *sensor);
+
+ void poll();
+private:
+ QProximityReading m_reading;
+};
+
+#endif
+