|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 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 |
|
42 #ifndef SENSORBACKENDSYM_H |
|
43 #define SENSORBACKENDSYM_H |
|
44 |
|
45 // QT Mobility Sensor API headers |
|
46 #include <qsensorbackend.h> |
|
47 |
|
48 // Standard Symbian Headers |
|
49 #include <e32std.h> |
|
50 #include <e32cmn.h> |
|
51 |
|
52 // Sensor client headers |
|
53 // Common Sensor Headers |
|
54 #include <sensrvchannel.h> |
|
55 #include <sensrvchannelinfo.h> |
|
56 #include <sensrvtypes.h> |
|
57 #include <sensrvchannelfinder.h> |
|
58 #include <sensrvdatalistener.h> |
|
59 #include <sensrvpropertylistener.h> |
|
60 |
|
61 // Internal Headers |
|
62 #include "sensorbackenddatasym.h" |
|
63 |
|
64 QTM_USE_NAMESPACE |
|
65 |
|
66 class CSensorBackendSym : public CBase, public QSensorBackend, public MSensrvDataListener, public MSensrvPropertyListener |
|
67 { |
|
68 public: |
|
69 // From QSensorBackend |
|
70 |
|
71 /** |
|
72 * start is used to start listening to the sensor |
|
73 */ |
|
74 virtual void start(); |
|
75 |
|
76 /* |
|
77 * stop is used to stop listening to the sensor |
|
78 */ |
|
79 virtual void stop(); |
|
80 |
|
81 /* |
|
82 * Backend Destructor |
|
83 */ |
|
84 ~CSensorBackendSym(); |
|
85 |
|
86 // From MSensrvDataListener |
|
87 |
|
88 /* |
|
89 * DataReceived is called by the Sensor Server when ever data is available in the |
|
90 * sensor buffer |
|
91 */ |
|
92 void DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt aDataLost); |
|
93 |
|
94 /** |
|
95 * DataError is called to indicate an error, fatal errors are unrecoverable |
|
96 */ |
|
97 void DataError(CSensrvChannel &aChannel, TSensrvErrorSeverity aError); |
|
98 |
|
99 /* |
|
100 * GetDataListenerInterfaceL is used to get a pointer to the sensor server backend |
|
101 * It is not required for QT Mobility Sensors API |
|
102 */ |
|
103 void GetDataListenerInterfaceL(TUid aInterfaceUid, TAny *&aInterface); |
|
104 |
|
105 // From MSensrvProeprtyListener |
|
106 |
|
107 /** |
|
108 * Notification about the changed value of a property. |
|
109 */ |
|
110 void PropertyChanged (CSensrvChannel &aChannel, const TSensrvProperty &aChangedProperty); |
|
111 |
|
112 /** |
|
113 * Property listening failed. |
|
114 */ |
|
115 void PropertyError (CSensrvChannel &aChannel, TSensrvErrorSeverity aError); |
|
116 |
|
117 /** |
|
118 * Set a listener for the indication, if the setting of the property succeeded. |
|
119 */ |
|
120 void SetPropertySuccessIndicationChanged (TSetPropertySuccessIndicator aIndication); |
|
121 |
|
122 /* |
|
123 * Returns a pointer to a specified interface extension - to allow future extension of this class without breaking binary compatibility. |
|
124 */ |
|
125 void GetPropertyListenerInterfaceL (TUid aInterfaceUid, TAny *&aInterface); |
|
126 |
|
127 /* |
|
128 * To enable/disable data/property listening |
|
129 */ |
|
130 void SetListening(TBool aDataListening, TBool aPropertyListening); |
|
131 |
|
132 protected: |
|
133 |
|
134 /* |
|
135 * Default C++ constructor |
|
136 */ |
|
137 CSensorBackendSym(QSensor *sensor); |
|
138 |
|
139 /** |
|
140 * Deriving class implements this if it requires property change notification |
|
141 */ |
|
142 virtual void HandlePropertyChange(CSensrvChannel &aChannel, const TSensrvProperty &aChangedProperty); |
|
143 |
|
144 /* |
|
145 * RecvData is used to retrieve the sensor reading from sensor server |
|
146 * It is implemented the the sensor concrete class and handles sensor specific |
|
147 * reading data and provides conversion and utility code |
|
148 */ |
|
149 virtual void RecvData(CSensrvChannel &aChannel) = 0; |
|
150 |
|
151 /* |
|
152 * InitializeL is used to create and init the sensor server objects |
|
153 */ |
|
154 void InitializeL(); |
|
155 |
|
156 /* |
|
157 * SetProperty is used to set property to the channel |
|
158 */ |
|
159 TInt SetProperty(TSensrvPropertyId aPropertyId, TSensrvPropertyType aPropertyType, TSensrvArrayIndex aArrayIndex, TReal aValue); |
|
160 |
|
161 /* |
|
162 * SetMeasurementRange is used to check measurement range type and set the measurement range |
|
163 */ |
|
164 TInt SetMeasurementRange(); |
|
165 |
|
166 /* |
|
167 * SetDataRate is used to calculate appropriate data rate for given interval and set that interval to the channel |
|
168 */ |
|
169 TInt SetDataRate(); |
|
170 |
|
171 /* |
|
172 * SetProperties is used to set properties on the channel before start data listening |
|
173 */ |
|
174 void SetProperties(); |
|
175 |
|
176 /* |
|
177 * GetPropertiesL used to get the properties from sensor server and sets as metadata for Qt. |
|
178 */ |
|
179 void GetPropertiesL(); |
|
180 |
|
181 /* |
|
182 * GetDescription used to get description of sensor from symbian and set |
|
183 * as description in Qt |
|
184 */ |
|
185 void GetDescription(); |
|
186 |
|
187 /* |
|
188 * GetDataRate used to get available datarates from symbian and set |
|
189 * as availableDataRates in Qt |
|
190 */ |
|
191 void GetDataRate(); |
|
192 |
|
193 /* |
|
194 * GetMeasurementrangeAndAccuracy used to get measurement ranges and accuracy from |
|
195 * symbian and set as outputRanges in Qt |
|
196 */ |
|
197 virtual void GetMeasurementrangeAndAccuracy(); |
|
198 |
|
199 /* |
|
200 * Close is used to release all the sensor server objects |
|
201 * May change when error handling is supported by mobility apis |
|
202 */ |
|
203 TInt Close(); |
|
204 |
|
205 /* |
|
206 * FindSensorL is used to find if a specific sensor is available on the |
|
207 * device, if FindSensorL leaves then the sensor is not supported |
|
208 */ |
|
209 void FindSensorL(); |
|
210 |
|
211 /* |
|
212 * OpenSensorChannelL is used to open the channel for sensor as indicated by |
|
213 * iPrivateData.iChannelInfo |
|
214 */ |
|
215 void OpenSensorChannelL(); |
|
216 |
|
217 /* |
|
218 * CloseSensorChannel is used to close the sensor channel and release the |
|
219 * resources |
|
220 */ |
|
221 void CloseSensorChannelL(); |
|
222 |
|
223 /* |
|
224 * Used to start listening to the sensor |
|
225 */ |
|
226 void StartListeningL(); |
|
227 |
|
228 /* |
|
229 * Used to stop listening to the sensor |
|
230 */ |
|
231 void StopListeningL(); |
|
232 |
|
233 private: |
|
234 TSensrvPropertyType propertyType(TSensrvPropertyId, TInt&); |
|
235 |
|
236 protected: |
|
237 TSensorBackendDataSym iBackendData; |
|
238 }; |
|
239 |
|
240 #endif //SENSORBACKENDSYM_H |
|
241 |