|
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 QGEOPOSITIONINFOSOURCES60_H |
|
43 #define QGEOPOSITIONINFOSOURCES60_H |
|
44 |
|
45 // INCLUDES |
|
46 #include <e32std.h> |
|
47 #include <e32base.h> |
|
48 #include <lbs.h> |
|
49 #include "qgeopositioninfosource.h" |
|
50 #include "qmlbackendao_s60_p.h" |
|
51 #include "notificationcallback_s60_p.h" |
|
52 |
|
53 #define MAX_SIZE 5 |
|
54 |
|
55 QTM_BEGIN_NAMESPACE |
|
56 |
|
57 // CLASS DECLARATION |
|
58 //forward declaration |
|
59 class CQMLBackendAO; |
|
60 |
|
61 class CPosMethodInfo |
|
62 { |
|
63 public: |
|
64 // A unique id for the positioning module |
|
65 TPositionModuleId mUid; |
|
66 |
|
67 // Positioning Module (satellite/ non-satellite) |
|
68 QGeoPositionInfoSource::PositioningMethod mPosMethod; |
|
69 |
|
70 // |
|
71 int mStatus; |
|
72 |
|
73 // time to first and next fix from the location server |
|
74 TTimeIntervalMicroSeconds mTimeToFirstFix; |
|
75 TTimeIntervalMicroSeconds mTimeToNextFix; |
|
76 |
|
77 // Accuracy |
|
78 double mHorizontalAccuracy; |
|
79 |
|
80 // Flags whether the positioning technology is currently available or not. |
|
81 bool mIsAvailable; |
|
82 }; |
|
83 |
|
84 |
|
85 /** |
|
86 * CQGeoPositionInfoSourceS60 |
|
87 * |
|
88 */ |
|
89 class CQGeoPositionInfoSourceS60 : public INotificationCallback, |
|
90 public QGeoPositionInfoSource |
|
91 |
|
92 { |
|
93 public: |
|
94 // Constructors and destructor |
|
95 /** |
|
96 * Destructor. |
|
97 */ |
|
98 ~CQGeoPositionInfoSourceS60(); |
|
99 |
|
100 /** |
|
101 * Two-phased constructor. |
|
102 */ |
|
103 static CQGeoPositionInfoSourceS60* NewL(QObject* aParent); |
|
104 |
|
105 /** |
|
106 * Two-phased constructor. |
|
107 */ |
|
108 static CQGeoPositionInfoSourceS60* NewLC(QObject* aParent); |
|
109 |
|
110 /** |
|
111 * returns the last known position |
|
112 */ |
|
113 QGeoPositionInfo lastKnownPosition(bool aFromSatellitePositioningMethodsOnly = false) const; |
|
114 |
|
115 /** |
|
116 * returns the minimum update interval |
|
117 */ |
|
118 int minimumUpdateInterval() const; |
|
119 |
|
120 /** |
|
121 * Sets the preferred PositioningMethod, if available |
|
122 * otherwise sets the default poistioning mmethod |
|
123 */ |
|
124 void setPreferredPositioningMethods(PositioningMethods aMethods); |
|
125 |
|
126 /** |
|
127 * Sets the interval for the regular position notifications |
|
128 */ |
|
129 void setUpdateInterval(int aMilliSec); |
|
130 |
|
131 /** |
|
132 * Returns the supported Positioning Methods |
|
133 */ |
|
134 PositioningMethods supportedPositioningMethods() const { |
|
135 return mSupportedMethods; |
|
136 } |
|
137 |
|
138 /** |
|
139 * Notification methods from active object. |
|
140 * Notifies device status, position value, and status |
|
141 */ |
|
142 void updateDeviceStatus(void) ; |
|
143 |
|
144 /** |
|
145 * Update the position info |
|
146 */ |
|
147 void updatePosition(HPositionGenericInfo* aPosInfo, int aError); |
|
148 |
|
149 |
|
150 /** |
|
151 * Gets the handle of the PositionServer |
|
152 */ |
|
153 RPositionServer& getPositionServer(); |
|
154 |
|
155 /* |
|
156 * checks whether the object is valid |
|
157 */ |
|
158 inline TBool isValid() { |
|
159 if (mDevStatusUpdateAO && mRegUpdateAO) |
|
160 return TRUE; |
|
161 else |
|
162 return FALSE; |
|
163 } |
|
164 |
|
165 inline TPositionModuleId getCurrentPositonModuleID() { |
|
166 return mCurrentModuleId; |
|
167 } |
|
168 |
|
169 inline TPositionModuleId getRequestUpdateModuleID() { |
|
170 return mReqModuleId; |
|
171 } |
|
172 |
|
173 public slots : |
|
174 // for request update |
|
175 void requestUpdate(int timeout = 5000); |
|
176 |
|
177 // starts the regular updates |
|
178 virtual void startUpdates(); |
|
179 |
|
180 // stops the regular updates |
|
181 virtual void stopUpdates(); |
|
182 |
|
183 |
|
184 private: |
|
185 |
|
186 /** |
|
187 * Constructor for performing 1st stage construction |
|
188 */ |
|
189 CQGeoPositionInfoSourceS60(QObject* aParent = 0); |
|
190 |
|
191 /** |
|
192 * EPOC default constructor for performing 2nd stage construction |
|
193 */ |
|
194 void ConstructL(); |
|
195 |
|
196 void updateStatus(TPositionModuleInfo aModInfo, TInt aStatus); |
|
197 |
|
198 void updateAvailableTypes(void); |
|
199 |
|
200 //get the index of the module in the List array |
|
201 TInt checkModule(TPositionModuleId aId) const; |
|
202 |
|
203 //get the index of the position module based on the preferred methods |
|
204 TInt getIndexPositionModule(TUint8 aBits, PositioningMethods aPosMethods = AllPositioningMethods) const; |
|
205 |
|
206 //get the more accuarte method with time to first fix < than timeout |
|
207 TInt getMoreAccurateMethod(TInt aTimeout, TUint8 aBits); |
|
208 |
|
209 void TPositionInfo2QGeoPositionInfo(HPositionGenericInfo *mPosInfo, |
|
210 QGeoPositionInfo& posUpdate); |
|
211 |
|
212 protected: |
|
213 void connectNotify(const char *aSignal); |
|
214 |
|
215 void disconnectNotify(const char *aSignal); |
|
216 |
|
217 private: |
|
218 /** |
|
219 * current module ID |
|
220 */ |
|
221 TPositionModuleId mCurrentModuleId; |
|
222 |
|
223 /** |
|
224 *prvmoduleID |
|
225 */ |
|
226 TPositionModuleId mReqModuleId; |
|
227 |
|
228 /** |
|
229 * Active object for device status updates |
|
230 */ |
|
231 CQMLBackendAO * mDevStatusUpdateAO; |
|
232 |
|
233 /** |
|
234 * Active object for requestUpdate |
|
235 */ |
|
236 CQMLBackendAO * mReqUpdateAO; |
|
237 |
|
238 /** |
|
239 * Active object for regular updates. |
|
240 */ |
|
241 CQMLBackendAO * mRegUpdateAO; |
|
242 |
|
243 /** |
|
244 * Positioner server |
|
245 */ |
|
246 RPositionServer mPositionServer; |
|
247 |
|
248 /** |
|
249 * list of supported position methods |
|
250 */ |
|
251 CPosMethodInfo mList[MAX_SIZE]; |
|
252 |
|
253 PositioningMethods mSupportedMethods; |
|
254 |
|
255 PositioningMethod mCurrentMethod; |
|
256 |
|
257 /** |
|
258 * maintaiss the size of thr CPosMethodInfo array |
|
259 */ |
|
260 int mListSize; |
|
261 |
|
262 /* |
|
263 * query for the status |
|
264 */ |
|
265 TPositionModuleStatusEvent mStatusEvent; |
|
266 |
|
267 /* |
|
268 * maintain the startUpdates status |
|
269 */ |
|
270 TBool mStartUpdates; |
|
271 |
|
272 TBool mRegularUpdateTimedOut; |
|
273 |
|
274 /* |
|
275 * flags for the modules |
|
276 */ |
|
277 TUint8 mModuleFlags; |
|
278 }; |
|
279 |
|
280 QTM_END_NAMESPACE |
|
281 |
|
282 #endif // CQGEOPOSITIONINFOSOURCES60_H |