|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 // QT Mobility Sensor API headers |
|
42 #include <qsensorplugin.h> |
|
43 #include <qsensorbackend.h> |
|
44 #include <qsensormanager.h> |
|
45 |
|
46 // Internal Headers |
|
47 #include "proximitysensorsym.h" |
|
48 #include "ambientlightsensorsym.h" |
|
49 #include "magnetometersensorsym.h" |
|
50 #include "compasssym.h" |
|
51 #include "orientationsym.h" |
|
52 #include "accelerometersym.h" |
|
53 |
|
54 // QT Utility headers |
|
55 #include <QDebug> |
|
56 |
|
57 class SensorPluginSym : public QObject, public QSensorPluginInterface, public QSensorBackendFactory |
|
58 { |
|
59 Q_OBJECT |
|
60 Q_INTERFACES(QtMobility::QSensorPluginInterface) |
|
61 public: |
|
62 void registerSensors() |
|
63 { |
|
64 qDebug() << "Loaded the symbian sensor plugins"; |
|
65 QSensorManager::registerBackend(QProximitySensor::type, CProximitySensorSym::id, this); |
|
66 QSensorManager::registerBackend(QAmbientLightSensor::type, CAmbientLightSensorSym::id, this); |
|
67 QSensorManager::registerBackend(QMagnetometer::type, CMagnetometerSensorSym::id, this); |
|
68 QSensorManager::registerBackend(QCompass::type, CCompassSym::id, this); |
|
69 QSensorManager::registerBackend(QOrientationSensor::type, COrientationSensorSym::id, this); |
|
70 QSensorManager::registerBackend(QAccelerometer::type, CAccelerometerSensorSym::id, this); |
|
71 } |
|
72 |
|
73 QSensorBackend *createBackend(QSensor *sensor) |
|
74 { |
|
75 if (sensor->identifier() == CProximitySensorSym::id) |
|
76 { |
|
77 CProximitySensorSym *self = NULL; |
|
78 TRAPD(err,self = CProximitySensorSym::NewL(sensor)); |
|
79 return self; |
|
80 } |
|
81 if (sensor->identifier() == CAmbientLightSensorSym::id) |
|
82 { |
|
83 CAmbientLightSensorSym *self = NULL; |
|
84 TRAPD(err,self = CAmbientLightSensorSym::NewL(sensor)); |
|
85 return self; |
|
86 } |
|
87 if (sensor->identifier() == CMagnetometerSensorSym::id) |
|
88 { |
|
89 CMagnetometerSensorSym *self = NULL; |
|
90 TRAPD(err,self = CMagnetometerSensorSym::NewL(sensor)); |
|
91 return self; |
|
92 } |
|
93 if (sensor->identifier() == CCompassSym::id) |
|
94 { |
|
95 CCompassSym *self = NULL; |
|
96 TRAPD(err,self = CCompassSym::NewL(sensor)); |
|
97 return self; |
|
98 } |
|
99 if (sensor->identifier() == COrientationSensorSym::id) |
|
100 { |
|
101 COrientationSensorSym *self = NULL; |
|
102 TRAPD(err,self = COrientationSensorSym::NewL(sensor)); |
|
103 return self; |
|
104 } |
|
105 if (sensor->identifier() == CAccelerometerSensorSym::id) |
|
106 { |
|
107 CAccelerometerSensorSym *self = NULL; |
|
108 TRAPD(err,self = CAccelerometerSensorSym::NewL(sensor)); |
|
109 return self; |
|
110 } |
|
111 return 0; |
|
112 } |
|
113 }; |
|
114 |
|
115 Q_EXPORT_PLUGIN2(libsensors_sym, SensorPluginSym); |
|
116 |
|
117 #include "main.moc" |
|
118 |