|
1 /* |
|
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CPOSREQUESTCONTROLLER_H |
|
21 #define CPOSREQUESTCONTROLLER_H |
|
22 |
|
23 #include "EPos_CPosDefaultPositioner.h" |
|
24 #include "epos_mposrequestorlistener.h" |
|
25 #include "epos_mpospsyfixstatelistener.h" |
|
26 #include "epos_mpospsylistlistener.h" |
|
27 |
|
28 class TPositionInfoBase; |
|
29 class CPositioner; |
|
30 class CPosPsyListHandler; |
|
31 class CPosPsyFixStateManager; |
|
32 class CPosConstManager; |
|
33 class CPosExternalGpsMonitor; |
|
34 class CPosRequestor; |
|
35 class MPosModuleSettingsManager; |
|
36 class MPosModuleStatusManager; |
|
37 class TPosModulesEvent; |
|
38 |
|
39 |
|
40 /** |
|
41 * The CPosRequestController is service provider implemented as an active object |
|
42 * that controls position requests to the positioners in priority order from |
|
43 * the location settings. Although it is an active object, Cancel should not be |
|
44 * called by users. Instead, CancelNotifyPositionUpdate() should be called to |
|
45 * cancel an out-standing position request. This class also listens to events |
|
46 * in Location Settings for changes in modules priorities or properties. |
|
47 */ |
|
48 class CPosRequestController : |
|
49 public CBase, |
|
50 public MPosRequestorListener, |
|
51 public MPosPsyFixStateListener, |
|
52 public MPosPsyListListener |
|
53 { |
|
54 public: // Constructors and destructor |
|
55 |
|
56 /** |
|
57 * Constructor. |
|
58 * @param aDefaultPositioner Pointer to default positioner to |
|
59 * @param aModulesSettings Pointer to modules settings |
|
60 */ |
|
61 static CPosRequestController* NewL( |
|
62 CPosDefaultPositioner& aDefaultPositioner, |
|
63 MPosModuleSettingsManager& aSettingsManager, |
|
64 MPosModuleStatusManager& aModuleStatusManager |
|
65 ); |
|
66 |
|
67 /** |
|
68 * Destructor. |
|
69 */ |
|
70 ~CPosRequestController(); |
|
71 |
|
72 public: // New functions |
|
73 |
|
74 /** |
|
75 * Analogous to CPositioner. |
|
76 * Requests position info asynchronously. |
|
77 * |
|
78 * @param aPosInfo A reference to a position info object. This object |
|
79 * must be in scope until the request has completed. |
|
80 * @param aStatus The request status |
|
81 * |
|
82 */ |
|
83 void NotifyPositionUpdate( |
|
84 TPositionInfoBase& aPosInfo, |
|
85 TRequestStatus& aStatus |
|
86 ); |
|
87 |
|
88 /** |
|
89 * Analogous to CPositioner. |
|
90 * Cancels position info request. Cancel() should not be used. |
|
91 * This class works as a service provider from user perspective. |
|
92 */ |
|
93 void CancelNotifyPositionUpdate(); |
|
94 |
|
95 /** |
|
96 * Analogous to CPositioner. |
|
97 * Cancels position info request with an error. Used by LocServer |
|
98 * to indicate to PSY that this is not a user cancel |
|
99 * This class works as a service provider from user perspective. |
|
100 */ |
|
101 void CancelNotifyPositionUpdate(TInt aCancelReason); |
|
102 |
|
103 /** |
|
104 * Analogous to CPositioner, but does not leave |
|
105 * Initiate a tracking session. |
|
106 * |
|
107 * @param aInterval Interval for position requests. |
|
108 */ |
|
109 void StartTracking( |
|
110 const TTimeIntervalMicroSeconds& aInterval |
|
111 ); |
|
112 |
|
113 /** |
|
114 * Stops tracking for all PSY:s that are in the list. |
|
115 */ |
|
116 void StopTracking(); |
|
117 |
|
118 protected: // Functions from base classes |
|
119 |
|
120 /** |
|
121 * From MPosRequestorListener. |
|
122 */ |
|
123 virtual void LocationRequestCompleted( |
|
124 TPositionModuleId aModuleId, |
|
125 TInt aErr, |
|
126 const TPositionInfoBase& aPosInfo, |
|
127 TBool aIsPosInfoUpToDate ); |
|
128 |
|
129 /** |
|
130 * From MPosPsyFixStateListener |
|
131 */ |
|
132 virtual void PsyFixStateChanged( |
|
133 TPositionModuleId aModuleId, |
|
134 CPosPsyFixStateManager::TPsyFixState aFixState ); |
|
135 |
|
136 /** |
|
137 * From MPosPsyListListener |
|
138 */ |
|
139 virtual void PsyListChanged( |
|
140 const TPosPsyListChangeEvent& aEvent ); |
|
141 |
|
142 |
|
143 private: |
|
144 |
|
145 /** |
|
146 * Start position update |
|
147 */ |
|
148 void StartPositionUpdateL(); |
|
149 |
|
150 /** |
|
151 * Iterates through available plugins looking for the next |
|
152 * to try |
|
153 */ |
|
154 void TryNextPositioner(); |
|
155 |
|
156 /** |
|
157 * Try to load and make location retquest to the specific |
|
158 * PSY. |
|
159 */ |
|
160 void TryPositionerL( TPositionModuleId aPsyId ); |
|
161 |
|
162 /** |
|
163 * Completes a request if not already completed. |
|
164 */ |
|
165 void CompleteRequest(TInt aCompleteCode); |
|
166 |
|
167 /** |
|
168 * Clear location request to all PSYs |
|
169 */ |
|
170 void ClearLocationRequests(); |
|
171 |
|
172 /** |
|
173 * Returns current requestor |
|
174 * This function returns NULL if the requestor is not found |
|
175 */ |
|
176 CPosRequestor* GetRequestor( |
|
177 TPositionModuleId aPsyId ); |
|
178 |
|
179 /** |
|
180 * Unload PSY |
|
181 */ |
|
182 void UnloadRequestor( TPositionModuleId aPsyId ); |
|
183 |
|
184 /** |
|
185 * Cancel location request from a requestor |
|
186 */ |
|
187 void CancelRequest( TInt aIndex, TInt aCancelReason); |
|
188 |
|
189 /** |
|
190 * Cancel location request by UID |
|
191 */ |
|
192 void CancelRequest( TPositionModuleId aPsyId ); |
|
193 |
|
194 /** |
|
195 * Returns the Module Id of the current positioner |
|
196 * @return the Module Id of currently used Positioner. KNullUid if none. |
|
197 */ |
|
198 TPositionModuleId CurrentPositionerId(); |
|
199 |
|
200 /** |
|
201 * Check if there is location request on going in |
|
202 * any loaded PSY. |
|
203 */ |
|
204 TBool IsLocationRequestOnGoing() const; |
|
205 |
|
206 /** |
|
207 * Check if there is location request on going in |
|
208 * any loaded Network based PSY. |
|
209 */ |
|
210 TBool IsLocationRequestOnGoingOnNetworkPsy() const; |
|
211 |
|
212 /** |
|
213 * Copy TPositionInfoBase class |
|
214 */ |
|
215 static TInt CopyPosInfoClass( |
|
216 const TPositionInfoBase& aSrc, |
|
217 TPositionInfoBase& aDst ); |
|
218 |
|
219 /** |
|
220 * Cleanup timer static callback function |
|
221 */ |
|
222 static TInt CleanupTimeoutCallback( TAny* aAny ); |
|
223 |
|
224 /** |
|
225 * Handle clenaup timer timeout |
|
226 */ |
|
227 void CleanupTimeout(); |
|
228 |
|
229 /** |
|
230 * C++ default constructor. |
|
231 */ |
|
232 CPosRequestController( |
|
233 CPosDefaultPositioner& aDefaultPositioner, |
|
234 MPosModuleStatusManager& aModuleStatusManager |
|
235 ); |
|
236 |
|
237 /** |
|
238 * EPOC constructor. |
|
239 */ |
|
240 void ConstructL( |
|
241 MPosModuleSettingsManager& aSettingsManager ); |
|
242 |
|
243 // By default, prohibit copy constructor |
|
244 CPosRequestController(const CPosRequestController&); |
|
245 // Prohibit assigment operator |
|
246 CPosRequestController& operator= (const CPosRequestController&); |
|
247 |
|
248 // Debug and trace helpers |
|
249 void Panic(TInt aPanic); |
|
250 |
|
251 private: // Data |
|
252 //Reference to default positioner |
|
253 CPosDefaultPositioner& iDefaultPositioner; |
|
254 |
|
255 //Reference to module status manager |
|
256 MPosModuleStatusManager& iModuleStatusManager; |
|
257 |
|
258 //Boolean value indicate PSY list is valid |
|
259 TBool iPsyListValid; |
|
260 |
|
261 //Psy list in priority list |
|
262 RArray< TPositionModuleId > iPsyList; |
|
263 |
|
264 //Positioner objects array |
|
265 RPointerArray< CPosRequestor > iRequestorArray; |
|
266 |
|
267 //Location request status |
|
268 TRequestStatus* iPosRequestStatus; |
|
269 |
|
270 //Position info base class for location request |
|
271 TPositionInfoBase* iPosInfo; |
|
272 |
|
273 //Pointer to PSY list handler |
|
274 CPosPsyListHandler* iPsyListHandler; |
|
275 |
|
276 //Pointer to PSY fix state manager |
|
277 CPosPsyFixStateManager* iPsyFixStateManager; |
|
278 |
|
279 //External GPS PSY monitor |
|
280 CPosExternalGpsMonitor* iExtGpsPsyMonitor; |
|
281 |
|
282 //Const manager |
|
283 CPosConstManager* iConstManager; |
|
284 |
|
285 //Error code returned from first PSY |
|
286 TInt iFirstResult; |
|
287 |
|
288 //Index of the current trying PSY in PSY list. If current |
|
289 //PSY can't give a fix, default proxy shall try next PSY |
|
290 //in the PSY array. |
|
291 TInt iCurrentPsy; |
|
292 |
|
293 //Cleanup timer |
|
294 CPeriodic* iCleanupTimer; |
|
295 |
|
296 }; |
|
297 |
|
298 #endif // CPOSREQUESTCONTROLLER_H |
|
299 |
|
300 // End of File |