|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // CPrivacyAndLocationHandler.h |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 @released |
|
22 */ |
|
23 |
|
24 #ifndef PRIVACYANDLOCATIONHANDLER_H |
|
25 #define PRIVACYANDLOCATIONHANDLER_H |
|
26 |
|
27 #include <e32property.h> |
|
28 #include "nrhpanic.h" |
|
29 #include "ngmessageswitch.h" |
|
30 #include "agpsinterfacehandler.h" |
|
31 |
|
32 // Forward declarations |
|
33 class TPrivLocCommonParams; |
|
34 class CLbsPrivLocStateBase; |
|
35 class CLbsPrivLocFsm; |
|
36 |
|
37 // Panic Category |
|
38 _LIT(KPrivLocFault,"Lbs-Nrh PrivLoc"); |
|
39 |
|
40 /** |
|
41 * |
|
42 * Creates each of the states and sets the curent state to be idle. |
|
43 * Passes on any event to the current state, and handles requests |
|
44 * from states to change the current state. |
|
45 */ |
|
46 class CPrivacyAndLocationHandler : public CBase, |
|
47 public MNGMessageSwitchObserver, |
|
48 public MPrivacyHandlerObserver, |
|
49 public MAgpsInterfaceHandlerObserver |
|
50 { |
|
51 public: |
|
52 static CPrivacyAndLocationHandler* NewL(CNGMessageSwitch& aMessageSwitch, |
|
53 CLbsAdmin& aLbsAdmin, |
|
54 RLbsNetworkRegistrationStatus& aNetRegStatus); |
|
55 ~CPrivacyAndLocationHandler(); |
|
56 |
|
57 protected: |
|
58 void ConstructL(CLbsAdmin* aLbsAdmin); |
|
59 CPrivacyAndLocationHandler(CNGMessageSwitch& aMessageSwitch, RLbsNetworkRegistrationStatus& aNetRegStatus); |
|
60 |
|
61 void ReadProtocolModuleAdminSetting(); |
|
62 |
|
63 CLbsPrivLocFsm* LookupFsm(const TLbsNetSessionIdInt& aSessionId); |
|
64 CLbsPrivLocFsm* GetNewFsm(const TLbsNetSessionIdInt& aSessionId, |
|
65 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
66 TBool aEmergency); |
|
67 |
|
68 protected: // From MNGMessageSwitchObserver. Delegated to current state |
|
69 void OnMTLRRequest(const TLbsNetSessionIdInt& aSessionId, |
|
70 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
71 TBool aIsEmergency, |
|
72 const TLbsExternalRequestInfo& aExternalRequestInfo, |
|
73 const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy); |
|
74 |
|
75 void OnSessionComplete(const TLbsNetSessionIdInt& aSessionId, TInt aReason); |
|
76 |
|
77 void OnNetLocRequest(const TLbsNetSessionIdInt& aSessionId, |
|
78 const TLbsNetPosRequestMethodInt& aPosRequestMethod, |
|
79 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
80 TBool aIsEmergency, |
|
81 const TLbsNetPosRequestQualityInt& aQuality); |
|
82 |
|
83 void OnNetLocResponse(const TLbsNetSessionIdInt&, |
|
84 const TLbsNetPosRequestQualityInt&){} |
|
85 |
|
86 void OnNetLocReferenceUpdate(const TLbsNetSessionIdInt& aSessionId, |
|
87 const TPositionInfoBase& aPosInfo); |
|
88 |
|
89 void OnNetLocFinalUpdate(const TLbsNetSessionIdInt& aSessionId, |
|
90 const TPositionInfoBase& aPosInfo); |
|
91 |
|
92 public: // From MPrivacyHandlerObserver |
|
93 void SetServerObserver(MLbsSessionObserver* aNrhPrivacyServer); |
|
94 void OnRespondNetworkLocationRequest(const TLbsNetSessionIdInt& aRequestId, |
|
95 TLbsNetworkEnumInt::TLbsPrivacyResponseInt aRequestResult, |
|
96 TInt aResponseReason); |
|
97 void OnCancelNetworkLocationRequest(const TLbsNetSessionIdInt& aRequestId); |
|
98 |
|
99 public: |
|
100 void OnAgpsPositionUpdate( |
|
101 TInt aReason, |
|
102 const TPositionExtendedSatelliteInfo& aPosInfo, |
|
103 const TTime& aTimeStamp); |
|
104 |
|
105 void OnAgpsMeasurementUpdate( |
|
106 TInt aReason, |
|
107 const TPositionGpsMeasurementInfo& aPosInfo, |
|
108 const TTime& aTimeStamp); |
|
109 |
|
110 public: |
|
111 CAgpsInterfaceHandler* AgpsHandler(); |
|
112 MX3pStatusHandler& X3pStatusHandler(); |
|
113 |
|
114 private: // Allow access for friend classes (the states, the NRH, and the FSMs) |
|
115 friend class CLbsPrivLocStateBase; |
|
116 friend class CLbsNetworkRequestHandler; |
|
117 friend class CLbsPrivLocFsm; |
|
118 CPrivacyHandler* PrivacyHandler(); |
|
119 CLbsAdmin* LbsAdmin(); |
|
120 CNGMessageSwitch* MessageSwitch(); |
|
121 TPositionModuleInfoExtended::TDeviceGpsModeCapabilities DeviceGpsModeCaps(); |
|
122 CLbsAdmin::TLbsBehaviourMode BehaviourMode(); |
|
123 RLbsNetworkRegistrationStatus& NetworkRegistrationStatus(); |
|
124 |
|
125 private: |
|
126 static TBool IsSessionIdEqual( |
|
127 const TLbsNetSessionIdInt* aSessionId, |
|
128 const CLbsPrivLocFsm& aFsm); |
|
129 static TBool IsSessionTypeEqual( |
|
130 const TLbsNetworkEnumInt::TLbsNetProtocolServiceInt* aSessionType, |
|
131 const CLbsPrivLocFsm& aFsm); |
|
132 TBool IsSpecialFeatureIntermediateFutileUpdateOn(); |
|
133 private: |
|
134 CPrivacyHandler* iPrivacyHandler; |
|
135 CLbsAdmin* iLbsAdmin; |
|
136 RLbsNetworkRegistrationStatus& iNetRegStatus; |
|
137 CNGMessageSwitch* iMessageSwitch; |
|
138 |
|
139 CAgpsInterfaceHandler* iAgpsInterface; |
|
140 |
|
141 |
|
142 TUid iProtocolModuleUid; |
|
143 |
|
144 // state machine used for progessing a emergency (MTLR or NI) - so as to avoid OOM |
|
145 CLbsPrivLocFsm* iEmergencyFsm; |
|
146 |
|
147 // Array of state machines used for progressing sessions of all types (MTLR,MOLR and NI, including emergencies) |
|
148 RPointerArray<CLbsPrivLocFsm> iFsmArray; |
|
149 |
|
150 CLbsAdmin::TLbsBehaviourMode iLbsBehaviourMode; |
|
151 TPositionModuleInfoExtended::TDeviceGpsModeCapabilities iDeviceGpsModeCaps; |
|
152 |
|
153 // Is the intermediate futile update feature switched on? |
|
154 TBool iSpecialFeatureIntermediateFutileUpdate; |
|
155 |
|
156 // this is the maximum number of non-emergency sessions allowed |
|
157 // at any one time |
|
158 TUint iMaxNumSessions; |
|
159 |
|
160 // this is the current number of active non-emergency sessions |
|
161 TUint iNumActiveSessions; |
|
162 |
|
163 CLbsPrivLocFsm* iMolRFsm; |
|
164 CLbsPrivLocFsm* iX3pFsm; |
|
165 }; |
|
166 |
|
167 |
|
168 //------------------------------------------------------------------------------ |
|
169 // |
|
170 // Transport classes used to pass data across state changes |
|
171 // |
|
172 //------------------------------------------------------------------------------ |
|
173 /** |
|
174 * TPrivLocCommonParams defines the base class for the data passed between |
|
175 * states |
|
176 */ |
|
177 class TPrivLocCommonParams |
|
178 { |
|
179 protected: |
|
180 enum TType |
|
181 { |
|
182 ECommon, |
|
183 EPrivacyResponse, |
|
184 ELocationRequest, |
|
185 ELocationUpdate |
|
186 }; |
|
187 |
|
188 public: |
|
189 TPrivLocCommonParams(); |
|
190 TPrivLocCommonParams(TLbsNetSessionIdInt aSessionId); |
|
191 |
|
192 public: |
|
193 static const TPrivLocCommonParams& Cast(const TPrivLocCommonParams& aParamsBase) |
|
194 { |
|
195 if(aParamsBase.Type() != ECommon) |
|
196 { |
|
197 __ASSERT_DEBUG(EFalse, Panic(ENrhPanicBadParamType)); |
|
198 } |
|
199 return static_cast<const TPrivLocCommonParams&>(aParamsBase); |
|
200 } |
|
201 |
|
202 public: |
|
203 virtual TType Type() const |
|
204 { |
|
205 return(ECommon); |
|
206 }; |
|
207 |
|
208 public: |
|
209 TLbsNetSessionIdInt iSessionId; |
|
210 }; |
|
211 |
|
212 /* |
|
213 * TPrivLocWaitPrivResponseParams contains the data required on entry |
|
214 * to state EStateWaitPrivacyResponse |
|
215 */ |
|
216 class TPrivLocWaitPrivResponseParams : public TPrivLocCommonParams |
|
217 { |
|
218 public: |
|
219 TPrivLocWaitPrivResponseParams(); |
|
220 TPrivLocWaitPrivResponseParams(const TLbsNetSessionIdInt& aSessionId, |
|
221 const TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
222 const TLbsExternalRequestInfo& aExternalRequestInfo, |
|
223 const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy, |
|
224 TBool aIsEmergency); |
|
225 |
|
226 static const TPrivLocWaitPrivResponseParams& Cast(const TPrivLocCommonParams& aParamsBase) |
|
227 { |
|
228 if(aParamsBase.Type() != EPrivacyResponse) |
|
229 { |
|
230 __ASSERT_DEBUG(EFalse, Panic(ENrhPanicBadParamType)); |
|
231 |
|
232 } |
|
233 return static_cast<const TPrivLocWaitPrivResponseParams&>(aParamsBase); |
|
234 } |
|
235 public: // From TPrivLocCommonParams. |
|
236 TType Type() const |
|
237 { |
|
238 return EPrivacyResponse; |
|
239 } |
|
240 |
|
241 public: |
|
242 TLbsExternalRequestInfo2 iExternalRequestInfo; |
|
243 TLbsNetPosRequestPrivacyInt iNetPosRequestPrivacy; |
|
244 TBool iIsEmergency; |
|
245 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt iSessionType; |
|
246 }; |
|
247 |
|
248 class TPrivLocWaitLocationRequestParams : public TPrivLocCommonParams |
|
249 { |
|
250 public: |
|
251 TPrivLocWaitLocationRequestParams(); |
|
252 TPrivLocWaitLocationRequestParams(const TLbsNetSessionIdInt& aSessionId, |
|
253 TBool aIsEmergency, |
|
254 TBool aReqCancelled, |
|
255 TInt aPreviousStateExitInfo = KErrNone); |
|
256 |
|
257 static const TPrivLocWaitLocationRequestParams& Cast(const TPrivLocCommonParams& aParamsBase) |
|
258 { |
|
259 if(aParamsBase.Type() != ELocationRequest) |
|
260 { |
|
261 __ASSERT_DEBUG(EFalse, Panic(ENrhPanicBadParamType)); |
|
262 |
|
263 } |
|
264 return static_cast<const TPrivLocWaitLocationRequestParams&>(aParamsBase); |
|
265 } |
|
266 public: // From TPrivLocCommonParams. |
|
267 TType Type() const |
|
268 { |
|
269 return ELocationRequest; |
|
270 } |
|
271 |
|
272 public: |
|
273 TBool iIsEmergency; |
|
274 TBool iReqCancelled; |
|
275 TInt iPreviousStateExitInfo; // e. g. KPositionQualityLoss |
|
276 }; |
|
277 |
|
278 class TPrivLocWaitLocationUpdateParams : public TPrivLocCommonParams |
|
279 { |
|
280 public: |
|
281 TPrivLocWaitLocationUpdateParams(); |
|
282 TPrivLocWaitLocationUpdateParams(const TLbsNetSessionIdInt& aSessionId, |
|
283 const TLbsNetPosRequestMethodInt& aPosRequestMethod, |
|
284 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
285 TBool aIsEmergency, |
|
286 const TLbsNetPosRequestQualityInt& aQuality); |
|
287 |
|
288 static const TPrivLocWaitLocationUpdateParams& Cast(const TPrivLocCommonParams& aParamsBase) |
|
289 { |
|
290 if(aParamsBase.Type() != ELocationUpdate) |
|
291 { |
|
292 __ASSERT_DEBUG(EFalse, Panic(ENrhPanicBadParamType)); |
|
293 |
|
294 } |
|
295 return static_cast<const TPrivLocWaitLocationUpdateParams&>(aParamsBase); |
|
296 } |
|
297 public: // From TPrivLocCommonParams. |
|
298 TType Type() const |
|
299 { |
|
300 return ELocationUpdate; |
|
301 } |
|
302 |
|
303 public: |
|
304 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt iSessionType; |
|
305 TBool iIsEmergency; |
|
306 TLbsNetPosRequestQualityInt iQuality; |
|
307 TLbsNetPosRequestMethodInt iPosRequestMethod; |
|
308 }; |
|
309 |
|
310 //------------------------------------------------------------------------------ |
|
311 // |
|
312 // End transport classes |
|
313 // |
|
314 //------------------------------------------------------------------------------ |
|
315 |
|
316 |
|
317 class TPrivLocStateExitData |
|
318 { |
|
319 public: |
|
320 enum TPrivLocStateExitReason |
|
321 { |
|
322 EExitReasonNone, |
|
323 // Normal exit from Idle state when MTLR session is started |
|
324 EExitPrivacyRequestReceived, |
|
325 // normal exit from wait for location request or Idle (for non-MTLR) |
|
326 EExitLocReqReceived, |
|
327 // exit from wait for location update when position reeceived |
|
328 EExitLocFixReceived, |
|
329 // exit from wait for location update when measurement data received |
|
330 EExitLocMeasurementResultsReceived, |
|
331 // normal exit from wait for privacy response |
|
332 EExitPrivacyResponseReceived, |
|
333 // session could be completed, cancelled or overridden by a new one |
|
334 EExitSessionComplete, |
|
335 // Privacy Controller cancelled a session |
|
336 EExitCancelledByPrivacyController, |
|
337 // Can't action a position update request |
|
338 EExitBadQualityProfile, |
|
339 // Update not received |
|
340 EExitTimedOut, |
|
341 // The location request was 'bad', for various reasons. |
|
342 EExitBadLocationRequest |
|
343 }; |
|
344 public: |
|
345 TPrivLocStateExitData(){} |
|
346 TPrivLocStateExitData(TPrivLocStateExitReason aExitReason, TInt aExitInfo) |
|
347 { |
|
348 SetExitData(aExitReason, aExitInfo); |
|
349 } |
|
350 public: |
|
351 void SetExitData(TPrivLocStateExitReason aExitReason, TInt aExitInfo) |
|
352 { |
|
353 iExitReason = aExitReason; |
|
354 iExitInfo = aExitInfo; |
|
355 } |
|
356 public: |
|
357 TPrivLocStateExitReason iExitReason; |
|
358 TInt iExitInfo; // e.g. KErrCancel |
|
359 }; |
|
360 |
|
361 |
|
362 /** |
|
363 * |
|
364 * Base class for states, not intended for instantiation. |
|
365 * Defines functions common to all states |
|
366 */ |
|
367 class CLbsPrivLocStateBase : public CBase |
|
368 { |
|
369 |
|
370 public: |
|
371 virtual void OnEntry(const TPrivLocCommonParams&); |
|
372 virtual TBool OnExit(); |
|
373 |
|
374 public: |
|
375 virtual void OnMTLRRequest( |
|
376 const TLbsNetSessionIdInt&, |
|
377 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt, |
|
378 TBool, |
|
379 const TLbsExternalRequestInfo&, |
|
380 const TLbsNetPosRequestPrivacyInt&) {} |
|
381 |
|
382 virtual void OnSessionComplete( |
|
383 const TLbsNetSessionIdInt&, |
|
384 TInt ); |
|
385 |
|
386 virtual void OnNetLocRequest( |
|
387 const TLbsNetSessionIdInt&, |
|
388 const TLbsNetPosRequestMethodInt&, |
|
389 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt, |
|
390 TBool, |
|
391 const TLbsNetPosRequestQualityInt&) {} |
|
392 |
|
393 virtual void OnNetLocResponse( |
|
394 const TLbsNetSessionIdInt&, |
|
395 const TLbsNetPosRequestQualityInt&) {} |
|
396 |
|
397 virtual void OnRespondNetworkLocationRequest( |
|
398 const TLbsNetSessionIdInt&, |
|
399 TLbsNetworkEnumInt::TLbsPrivacyResponseInt, |
|
400 TInt /*aResponseReason*/) {} |
|
401 |
|
402 virtual void OnCancelNetworkLocationRequest( |
|
403 const TLbsNetSessionIdInt&); |
|
404 |
|
405 virtual void OnNetLocReferenceUpdate( |
|
406 const TLbsNetSessionIdInt& aSessionId, |
|
407 const TPositionInfoBase& aPosInfo); |
|
408 |
|
409 virtual void OnAgpsPositionUpdate( |
|
410 TInt /*aReason*/, |
|
411 const TPositionExtendedSatelliteInfo& /*aPosInfo*/, |
|
412 const TTime& /*aTimeStamp*/) {} |
|
413 |
|
414 virtual void OnAgpsMeasurementUpdate( |
|
415 TInt /*aReason*/, |
|
416 const TPositionGpsMeasurementInfo& /*aPosInfo*/, |
|
417 const TTime& /*aTimeStamp*/) {} |
|
418 |
|
419 public: |
|
420 virtual void OnTimerEventL(TInt aTimerId); |
|
421 |
|
422 protected: |
|
423 CLbsPrivLocStateBase(CLbsPrivLocFsm* aFsm); |
|
424 |
|
425 protected: |
|
426 void HandleLocRequest(const TLbsNetSessionIdInt& aSessionId, |
|
427 const TLbsNetPosRequestMethodInt& aPosRequestMethod, |
|
428 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
429 TBool aIsEmergency, |
|
430 const TLbsNetPosRequestQualityInt& aQuality); |
|
431 void HandleSessionCancel(const TLbsNetSessionIdInt& aSessionId,TInt aReason); |
|
432 void ReadNetworkInducedAdminSetting(CLbsAdmin::TExternalLocateService& aExternalLocateService); |
|
433 CPrivacyHandler* PrivacyHandler(); |
|
434 CNGMessageSwitch* MessageSwitch(); |
|
435 CLbsAdmin* LbsAdmin(); |
|
436 CAgpsInterfaceHandler* AgpsInterface(); |
|
437 RLbsNetworkRegistrationStatus& LbsNetworkRegistrationStatus(); |
|
438 TPositionModuleInfoExtended::TDeviceGpsModeCapabilities DeviceGpsModeCaps(); |
|
439 CLbsAdmin::TLbsBehaviourMode BehaviourMode(); |
|
440 |
|
441 |
|
442 protected: |
|
443 CLbsPrivLocFsm* iFsm; |
|
444 }; |
|
445 |
|
446 /** |
|
447 * Idle state. |
|
448 * Handles all events originating from the Network Gateway, but |
|
449 * does nothing with any apart from MTLR (i.e. privacy) Request |
|
450 * and Location Request |
|
451 * Exits to states: |
|
452 * EStateWaitPrivacyResponse |
|
453 */ |
|
454 class CLbsPrivLocIdleState : public CLbsPrivLocStateBase |
|
455 |
|
456 { |
|
457 public: |
|
458 static CLbsPrivLocIdleState* NewL(CLbsPrivLocFsm* aFsm); |
|
459 |
|
460 public: |
|
461 void OnEntry(const TPrivLocCommonParams& aStateParams); |
|
462 TBool OnExit(); |
|
463 |
|
464 void OnMTLRRequest(const TLbsNetSessionIdInt& aSessionId, |
|
465 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
466 TBool aIsEmergency, |
|
467 const TLbsExternalRequestInfo& aExternalRequestInfo, |
|
468 const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy); |
|
469 |
|
470 void OnNetLocRequest(const TLbsNetSessionIdInt& aSessionId, |
|
471 const TLbsNetPosRequestMethodInt& aPosRequestMethod, |
|
472 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
473 TBool aIsEmergency, |
|
474 const TLbsNetPosRequestQualityInt& aQuality); |
|
475 |
|
476 void OnNetLocReferenceUpdate( |
|
477 const TLbsNetSessionIdInt& aSessionId, |
|
478 const TPositionInfoBase& aPosInfo); |
|
479 |
|
480 |
|
481 protected: |
|
482 CLbsPrivLocIdleState(CLbsPrivLocFsm* aFsm); |
|
483 }; |
|
484 |
|
485 /** |
|
486 * Wait for Privacy Response state. |
|
487 * Expects an accept/reject response from the privacy handler which |
|
488 * it passes on to the network gateway. |
|
489 * Also handles all events originating from the Network Gateway, which may |
|
490 * teminate the current session. |
|
491 * Exits to states: |
|
492 */ |
|
493 class CLbsPrivLocWaitPrivRespState : public CLbsPrivLocStateBase |
|
494 { |
|
495 public: |
|
496 static CLbsPrivLocWaitPrivRespState* NewL(CLbsPrivLocFsm* aFsm); |
|
497 |
|
498 public: |
|
499 void OnEntry(const TPrivLocCommonParams& aStateParams); |
|
500 TBool OnExit(); |
|
501 |
|
502 void OnMTLRRequest(const TLbsNetSessionIdInt& aSessionId, |
|
503 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
504 TBool aIsEmergency, |
|
505 const TLbsExternalRequestInfo& aExternalRequestInfo, |
|
506 const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy); |
|
507 |
|
508 void OnNetLocRequest(const TLbsNetSessionIdInt& aSessionId, |
|
509 const TLbsNetPosRequestMethodInt& aPosRequestMethod, |
|
510 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
511 TBool aIsEmergency, |
|
512 const TLbsNetPosRequestQualityInt& aQuality); |
|
513 |
|
514 void OnRespondNetworkLocationRequest(const TLbsNetSessionIdInt& aRequestId, |
|
515 TLbsNetworkEnumInt::TLbsPrivacyResponseInt aRequestResult, |
|
516 TInt aResponseReason); |
|
517 |
|
518 void OnNetLocReferenceUpdate( |
|
519 const TLbsNetSessionIdInt& aSessionId, |
|
520 const TPositionInfoBase& aPosInfo); |
|
521 |
|
522 protected: |
|
523 CLbsPrivLocWaitPrivRespState(CLbsPrivLocFsm* aFsm); |
|
524 }; |
|
525 |
|
526 |
|
527 /** |
|
528 * Wait for Location Request state. |
|
529 * Following a response from the privacy handler to accept a request, expects |
|
530 * a request for a position update. |
|
531 * Also handles all other events originating from the Network Gateway, |
|
532 * which may terminate the current session. |
|
533 * Exits to states: |
|
534 */ |
|
535 class CLbsPrivLocWaitLocReqState : public CLbsPrivLocStateBase |
|
536 { |
|
537 public: |
|
538 static CLbsPrivLocWaitLocReqState* NewL(CLbsPrivLocFsm* aFsm); |
|
539 |
|
540 protected: |
|
541 CLbsPrivLocWaitLocReqState(CLbsPrivLocFsm* aFsm); |
|
542 |
|
543 public: |
|
544 void OnEntry(const TPrivLocCommonParams& aStateParams); |
|
545 TBool OnExit(); |
|
546 |
|
547 void OnMTLRRequest(const TLbsNetSessionIdInt& aSessionId, |
|
548 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
549 TBool aIsEmergency, |
|
550 const TLbsExternalRequestInfo& aExternalRequestInfo, |
|
551 const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy); |
|
552 |
|
553 void OnNetLocRequest(const TLbsNetSessionIdInt& aSessionId, |
|
554 const TLbsNetPosRequestMethodInt& aPosRequestMethod, |
|
555 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
556 TBool aIsEmergency, |
|
557 const TLbsNetPosRequestQualityInt& aQuality); |
|
558 |
|
559 void OnCancelNetworkLocationRequest(const TLbsNetSessionIdInt& aSessionId); |
|
560 |
|
561 void OnSessionComplete(const TLbsNetSessionIdInt&, TInt ); |
|
562 |
|
563 void OnNetLocReferenceUpdate( |
|
564 const TLbsNetSessionIdInt& aSessionId, |
|
565 const TPositionInfoBase& aPosInfo); |
|
566 }; |
|
567 |
|
568 /** |
|
569 * Wait for location update state. |
|
570 * Handles all events originating from the Network Gwateway, and also |
|
571 * the update response timer and location updates received from the AGPS manager |
|
572 * Exits to states: |
|
573 */ |
|
574 class CLbsPrivLocWaitLocUpdateState : public CLbsPrivLocStateBase |
|
575 { |
|
576 public: |
|
577 static CLbsPrivLocWaitLocUpdateState* NewL(CLbsPrivLocFsm* aFsm); |
|
578 ~CLbsPrivLocWaitLocUpdateState(); |
|
579 |
|
580 protected: |
|
581 CLbsPrivLocWaitLocUpdateState(CLbsPrivLocFsm* aFsm); |
|
582 void ConstructL(); |
|
583 |
|
584 protected: // From MLbsPrivLocStateTransition |
|
585 void OnEntry(const TPrivLocCommonParams& aStateParams); // Need to request the update and start the timer |
|
586 TBool OnExit(); // Cancel any outstanding request and its timer |
|
587 |
|
588 public: |
|
589 void OnMTLRRequest(const TLbsNetSessionIdInt& aSessionId, |
|
590 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
591 TBool aIsEmergency, |
|
592 const TLbsExternalRequestInfo& aExternalRequestInfo, |
|
593 const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy); |
|
594 |
|
595 void OnNetLocRequest(const TLbsNetSessionIdInt& aSessionId, |
|
596 const TLbsNetPosRequestMethodInt& aPosRequestMethod, |
|
597 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
598 TBool aIsEmergency, |
|
599 const TLbsNetPosRequestQualityInt& aQuality); |
|
600 |
|
601 void OnTimerEventL(TInt aTimerId); |
|
602 |
|
603 void OnAgpsPositionUpdate( |
|
604 TInt aReason, |
|
605 const TPositionExtendedSatelliteInfo& aPosInfo, |
|
606 const TTime& aTimeStamp); |
|
607 |
|
608 void OnAgpsMeasurementUpdate( |
|
609 TInt aReason, |
|
610 const TPositionGpsMeasurementInfo& aPosInfo, |
|
611 const TTime& aTimeStamp); |
|
612 |
|
613 void OnNetLocReferenceUpdate( |
|
614 const TLbsNetSessionIdInt& aSessionId, |
|
615 const TPositionInfoBase& aPosInfo); |
|
616 |
|
617 private: |
|
618 void SetExitState(); |
|
619 TBool ReceivedFixIsAccurate(); |
|
620 }; |
|
621 |
|
622 |
|
623 /** |
|
624 * State machine |
|
625 */ |
|
626 class CLbsPrivLocFsm : public CBase, |
|
627 public MNGMessageSwitchObserver, |
|
628 public MPrivacyHandlerObserver, |
|
629 public MLbsCallbackTimerObserver, |
|
630 public MAgpsInterfaceHandlerObserver |
|
631 { |
|
632 public: |
|
633 |
|
634 enum TLocPrivacyHandlerState |
|
635 { |
|
636 EStateIdle, |
|
637 EStateWaitPrivacyResponse, |
|
638 EStateWaitLocationRequest, |
|
639 EStateWaitLocationUpdate, |
|
640 ETotalStates, |
|
641 ENoState = ETotalStates |
|
642 }; |
|
643 |
|
644 static CLbsPrivLocFsm* NewL(CPrivacyAndLocationHandler& aPrivLocHandler, |
|
645 const TLbsNetSessionIdInt& aSessionId); |
|
646 ~CLbsPrivLocFsm(); |
|
647 |
|
648 const TLbsNetSessionIdInt& SessionId() const; |
|
649 |
|
650 TBool IsSpecialFeatureIntermediateFutileUpdateOn(); |
|
651 |
|
652 public: // From MLbsFsmObserver |
|
653 void ChangeState(TLocPrivacyHandlerState aNewStateId, |
|
654 const TPrivLocCommonParams& aStateParams); |
|
655 void ChangeState(TLocPrivacyHandlerState aNewStateId, |
|
656 const TLbsNetSessionIdInt& aSessionId); |
|
657 |
|
658 protected: |
|
659 void ConstructL(); |
|
660 CLbsPrivLocFsm(CPrivacyAndLocationHandler& aPrivLocHandler, |
|
661 const TLbsNetSessionIdInt& aSessionId); |
|
662 |
|
663 public: // From MNGMessageSwitchObserver. Delegated to current state |
|
664 void OnMTLRRequest(const TLbsNetSessionIdInt& aSessionId, |
|
665 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
666 TBool aIsEmergency, |
|
667 const TLbsExternalRequestInfo& aExternalRequestInfo, |
|
668 const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy); |
|
669 |
|
670 void OnSessionComplete(const TLbsNetSessionIdInt& aSessionId, TInt aReason); |
|
671 |
|
672 void OnNetLocRequest(const TLbsNetSessionIdInt& aSessionId, |
|
673 const TLbsNetPosRequestMethodInt& aPosRequestMethod, |
|
674 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
675 TBool aIsEmergency, |
|
676 const TLbsNetPosRequestQualityInt& aQuality); |
|
677 void OnNetLocResponse(const TLbsNetSessionIdInt&, |
|
678 const TLbsNetPosRequestQualityInt&){} |
|
679 |
|
680 void OnNetLocReferenceUpdate(const TLbsNetSessionIdInt& aSessionId, |
|
681 const TPositionInfoBase& aPosInfo); |
|
682 |
|
683 void OnNetLocFinalUpdate(const TLbsNetSessionIdInt& aSessionId, |
|
684 const TPositionInfoBase& aPosInfo); |
|
685 |
|
686 public: // From MPrivacyHandlerObserver |
|
687 void SetServerObserver(MLbsSessionObserver* aNrhPrivacyServer); |
|
688 void OnRespondNetworkLocationRequest(const TLbsNetSessionIdInt& aRequestId, |
|
689 TLbsNetworkEnumInt::TLbsPrivacyResponseInt aRequestResult, |
|
690 TInt aResponseReason); |
|
691 void OnCancelNetworkLocationRequest(const TLbsNetSessionIdInt& aRequestId); |
|
692 |
|
693 public: // from MAgpsInterfaceHandlerObserver |
|
694 void OnAgpsPositionUpdate( |
|
695 TInt aReason, |
|
696 const TPositionExtendedSatelliteInfo& aPosInfo, |
|
697 const TTime& aTimeStamp); |
|
698 |
|
699 void OnAgpsMeasurementUpdate( |
|
700 TInt aReason, |
|
701 const TPositionGpsMeasurementInfo& aPosInfo, |
|
702 const TTime& aTimeStamp); |
|
703 |
|
704 protected: // From MLbsCallbackTimerObserver |
|
705 /** Called when the timer expires */ |
|
706 void OnTimerEventL(TInt aTimerId); |
|
707 /** Called if OnTimerEventL leaves */ |
|
708 TInt OnTimerError(TInt aTimerId, TInt aError); |
|
709 |
|
710 public: |
|
711 // These accessor functions can be used as |
|
712 // both getters and setters. |
|
713 |
|
714 TBool& IsEmergency() |
|
715 { return iIsEmergency; } |
|
716 |
|
717 TBool& TapMode() |
|
718 { return iTapMode; } |
|
719 |
|
720 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt& SessionType() |
|
721 { return iSessionType; } |
|
722 |
|
723 TPrivLocStateExitData& ExitData() { return iExitData; } |
|
724 |
|
725 TBool& RefPosProcessed() |
|
726 { return iRefPosProcessed; } |
|
727 |
|
728 TLbsNetSessionIdInt& NetSessionId() |
|
729 { return iSessionId; } |
|
730 |
|
731 TLbsNetPosRequestQualityInt& NetRequestQuality() |
|
732 { return iNetRequestQuality; } |
|
733 |
|
734 TBool& LocReqReceived() |
|
735 { return iLocReqReceived; } |
|
736 |
|
737 TLbsNetworkEnumInt::TLbsPrivacyResponseInt& PrivacyResponse() |
|
738 { return iPrivacyResponse; } |
|
739 |
|
740 TInt& PrivacyResponseReason() |
|
741 { return iPrivacyResponseReason; } |
|
742 |
|
743 TLbsNetPosRequestMethodInt& PosRequestMethod() |
|
744 { return iPosRequestMethod; } |
|
745 |
|
746 TBool& PrivacyRequestCancelled() |
|
747 { return iReqCancelled; } |
|
748 |
|
749 TLbsNetPosRequestQualityInt& GpsRequestQuality() |
|
750 { return iGpsRequestQuality; } |
|
751 |
|
752 TBool& LocationFixReceived() |
|
753 { return iLocationFixReceived; } |
|
754 |
|
755 TTime& ActualTime() |
|
756 { return iActualTime; } |
|
757 |
|
758 TPositionExtendedSatelliteInfo& GpsPosition() |
|
759 { return iPosInfo; } |
|
760 |
|
761 TBool& MeasurementInfoReceived() |
|
762 { return iMeasurementInfoReceived; } |
|
763 |
|
764 TInt& MeasurementInfoError() |
|
765 { return iMeasurementInfoErr; } |
|
766 |
|
767 TPositionGpsMeasurementInfo& GpsMeasurementInfo() |
|
768 { return iMeasurementResults; } |
|
769 |
|
770 TInt& PreviousStateExitInfo() |
|
771 { return iPreviousStateExitInfo; } |
|
772 |
|
773 CLbsCallbackTimer& LocationUpdateTimer() |
|
774 { return *iLocationUpdateTimer; } |
|
775 |
|
776 TLbsNetSessionIdInt& LastLocReqSessionId() |
|
777 { return iLastLocReqSessionId; } |
|
778 |
|
779 TBool& WasPrivacyResponseReceivedStateExited() |
|
780 { return iWasPrivacyResponseReceivedStateExited; } |
|
781 |
|
782 private: // Allow access for friend classes (the states and the NRH) |
|
783 friend class CLbsPrivLocStateBase; |
|
784 friend class CLbsNetworkRequestHandler; |
|
785 friend class CPrivacyAndLocationHandler; |
|
786 friend class CLbsPrivLocWaitLocUpdateState; |
|
787 CPrivacyAndLocationHandler& PrivLocHandler(); |
|
788 |
|
789 private: |
|
790 |
|
791 // The privacy and location handler |
|
792 CPrivacyAndLocationHandler& iPrivLocHandler; |
|
793 |
|
794 // The current Session ID being used by this FSM |
|
795 TLbsNetSessionIdInt iSessionId; |
|
796 |
|
797 // Is the current request an emergency request? |
|
798 TBool iIsEmergency; |
|
799 |
|
800 // Is the current session porcessing a Tap request? |
|
801 TBool iTapMode; |
|
802 |
|
803 // Service type of the current request. |
|
804 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt iSessionType; |
|
805 |
|
806 // Exit data from the current state. |
|
807 TPrivLocStateExitData iExitData; |
|
808 |
|
809 // Has a reference position been processed -by provacy framework? |
|
810 TBool iRefPosProcessed; |
|
811 |
|
812 // Quality/accuracy requirements for the location request. |
|
813 TLbsNetPosRequestQualityInt iNetRequestQuality; |
|
814 |
|
815 // Record if a location request has arrived while waiting for privacy response. |
|
816 TBool iLocReqReceived; |
|
817 |
|
818 // Response from a privacy request. |
|
819 TLbsNetworkEnumInt::TLbsPrivacyResponseInt iPrivacyResponse; |
|
820 |
|
821 // Reason for the privacy request response. |
|
822 TInt iPrivacyResponseReason; |
|
823 |
|
824 // The location method requested by the network. |
|
825 TLbsNetPosRequestMethodInt iPosRequestMethod; |
|
826 |
|
827 // Was the privacy request cancelled by the user? |
|
828 TBool iReqCancelled; |
|
829 |
|
830 // Request quality sent to agps manager. |
|
831 TLbsNetPosRequestQualityInt iGpsRequestQuality; |
|
832 |
|
833 // GPS position update has arrived? |
|
834 TBool iLocationFixReceived; |
|
835 |
|
836 // GPS position update timestamp. |
|
837 TTime iActualTime; |
|
838 |
|
839 // GPS position update. |
|
840 TPositionExtendedSatelliteInfo iPosInfo; |
|
841 |
|
842 // GPS measurement info update arrived? |
|
843 TBool iMeasurementInfoReceived; |
|
844 |
|
845 // GPS measurement info error code. |
|
846 TInt iMeasurementInfoErr; |
|
847 |
|
848 // GPS measurement info update data. |
|
849 TPositionGpsMeasurementInfo iMeasurementResults; |
|
850 |
|
851 // Exit info code from the previous state ?!? |
|
852 TInt iPreviousStateExitInfo; |
|
853 |
|
854 // MaxFixTime timeout timer for location requests to agps manager. |
|
855 CLbsCallbackTimer* iLocationUpdateTimer; |
|
856 |
|
857 // Record the sessionId of the last/current location request. |
|
858 TLbsNetSessionIdInt iLastLocReqSessionId; |
|
859 |
|
860 // Has a privacy request been rejected? |
|
861 TBool iWasPrivacyResponseReceivedStateExited; |
|
862 |
|
863 private: |
|
864 // the states |
|
865 CLbsPrivLocStateBase* iCurrentState; |
|
866 TFixedArray<CLbsPrivLocStateBase*, ETotalStates> iStates; |
|
867 }; |
|
868 |
|
869 |
|
870 |
|
871 #endif //PRIVACYANDLOCATIONHANDLER_H |