|
1 // Copyright (c) 2008-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 // This file provides the implementation of the base class for |
|
15 // protocol state machines used in the SUPL Protocol Module. |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalTechnology |
|
22 @deprecated |
|
23 */ |
|
24 |
|
25 #include <in_sock.h> |
|
26 #include "suplfsmsessionbase.h" |
|
27 #include "suplstatehandlerbase.h" |
|
28 #include <lbs/lbsnetclasstypes.h> |
|
29 #include "supldevloggermacros.h" |
|
30 #include "suplend.h" |
|
31 #include <lbs/lbsextendedsatellite.h> |
|
32 |
|
33 |
|
34 const TLbsHostCreatorId KUidLbsHostSettingsCreator = {0x10285A9D}; |
|
35 |
|
36 //----------------------------------------------------------------------------- |
|
37 // State Machine Base Class |
|
38 //----------------------------------------------------------------------------- |
|
39 |
|
40 /** Standard constructor. |
|
41 @param aObserver A reference to the state machine observer. |
|
42 */ |
|
43 CSuplFsmSessionBase::CSuplFsmSessionBase(MSuplFsmSessionObserver& aObserver) |
|
44 : CActive(EPriorityLow), iObserver(aObserver), iProtocolState(EStateReady) |
|
45 { |
|
46 SUPLLOG(ELogP1, "CSuplFsmSessionBase::CSuplFsmSessionBase() Begin\n"); |
|
47 ResetSessionId(); |
|
48 iDefSettingsId.Null(); |
|
49 SUPLLOG(ELogP1, "CSuplFsmSessionBase::CSuplFsmSessionBase() End\n"); |
|
50 } |
|
51 |
|
52 |
|
53 /** Standard destructor. |
|
54 */ |
|
55 CSuplFsmSessionBase::~CSuplFsmSessionBase() |
|
56 { |
|
57 SUPLLOG(ELogP1, "CSuplFsmSessionBase::~CSuplFsmSessionBase() Begin\n"); |
|
58 |
|
59 if(iDefSettingsId!=TUid::Uid(KNullUidValue) && iSlpSettingsStore) |
|
60 { |
|
61 iSlpSettingsStore->DeleteHostSettings(iDefSettingsId); |
|
62 } |
|
63 |
|
64 Cancel(); |
|
65 delete iEventStore; |
|
66 delete iStateHandler; |
|
67 delete iPositioningProtocol; |
|
68 iAssistanceDataBuilderSet.Close(); |
|
69 delete iSlpSettingsStore; |
|
70 delete iMessageSessionId; |
|
71 delete iTelNumber; |
|
72 delete iSuplProtTimer; |
|
73 SUPLLOG(ELogP1, "CSuplFsmSessionBase::~CSuplFsmSessionBase() End\n"); |
|
74 } |
|
75 |
|
76 |
|
77 /** Retrieve reference to state machine observer. |
|
78 @return MSuplFsmSessionObserver A reference to the observer. |
|
79 */ |
|
80 MSuplFsmSessionObserver& CSuplFsmSessionBase::Observer() |
|
81 { |
|
82 SUPLLOG(ELogP1, "CSuplFsmSessionBase::Observer() Begin\n"); |
|
83 SUPLLOG(ELogP1, "CSuplFsmSessionBase::Observer() End\n"); |
|
84 return iObserver; |
|
85 } |
|
86 |
|
87 /** Set session ID |
|
88 @param aSessionId Identifier to be used by the state machine whenever |
|
89 the session ID is to be used. |
|
90 */ |
|
91 void CSuplFsmSessionBase::SetSessionId(const TLbsNetSessionId& aSessionId) |
|
92 { |
|
93 SUPLLOG(ELogP1, "CSuplFsmSessionBase::SessionId() Begin\n"); |
|
94 iSessionId = aSessionId; |
|
95 SUPLLOG(ELogP1, "CSuplFsmSessionBase::SessionId() End\n"); |
|
96 } |
|
97 |
|
98 /** Reset session ID |
|
99 */ |
|
100 void CSuplFsmSessionBase::ResetSessionId() |
|
101 { |
|
102 SUPLLOG(ELogP1, "CSuplFsmSessionBase::ResetSessionId() Begin\n"); |
|
103 iSessionId.SetSessionOwner(TUid::Uid(0)); |
|
104 iSessionId.SetSessionNum(0); |
|
105 SUPLLOG(ELogP1, "CSuplFsmSessionBase::ResetSessionId() End\n"); |
|
106 } |
|
107 |
|
108 /** Get session ID |
|
109 @return const TLbsNetSessionId& The session ID currently used by the state machine. |
|
110 */ |
|
111 const TLbsNetSessionId& CSuplFsmSessionBase::SessionId() const |
|
112 { |
|
113 SUPLLOG(ELogP1, "CSuplFsmSessionBase::SessionId() Begin\n"); |
|
114 SUPLLOG(ELogP1, "CSuplFsmSessionBase::SessionId() End\n"); |
|
115 return iSessionId; |
|
116 } |
|
117 |
|
118 /** Obtain the session Id to be set in a call back to LBS |
|
119 */ |
|
120 const TLbsNetSessionId& CSuplFsmSessionBase::LbsSessionId() const |
|
121 { |
|
122 // This base class just returns iSessionId |
|
123 SUPLLOG(ELogP1, "CSuplFsmSessionBase::LbsSessionId() Begin\n"); |
|
124 SUPLLOG(ELogP1, "CSuplFsmSessionBase::LbsSessionId() End\n"); |
|
125 return iSessionId; |
|
126 } |
|
127 |
|
128 CSuplPositioningProtocolFsm* CSuplFsmSessionBase::PositioningFsm() |
|
129 { |
|
130 SUPLLOG(ELogP1, "CSuplFsmSessionBase::PositioningFsm() Begin\n"); |
|
131 SUPLLOG(ELogP1, "CSuplFsmSessionBase::PositioningFsm() End\n"); |
|
132 return iPositioningProtocol; |
|
133 } |
|
134 |
|
135 /** Retrieve current general protocol state. |
|
136 @return CSuplFsmSessionBase::TMachineState The current general |
|
137 protocol state for this state machine. |
|
138 |
|
139 @see CSuplFsmSessionBase::TMachineState |
|
140 */ |
|
141 CSuplFsmSessionBase::TMachineState CSuplFsmSessionBase::State() const |
|
142 { |
|
143 SUPLLOG(ELogP1, "CSuplFsmSessionBase::State() Begin\n"); |
|
144 SUPLLOG(ELogP1, "CSuplFsmSessionBase::State() End\n"); |
|
145 return iProtocolState; |
|
146 } |
|
147 |
|
148 /** Location request type. |
|
149 This is called by state handlers to determine what type of location |
|
150 request is to be specified to LBS. This is usually fixed for a given |
|
151 state machine. |
|
152 @return MLbsNetworkProtocolObserver::TLbsNetProtocolService request type. |
|
153 */ |
|
154 MLbsNetworkProtocolObserver::TLbsNetProtocolService CSuplFsmSessionBase::LocReqType() const |
|
155 { |
|
156 SUPLLOG(ELogP1, "CSuplFsmSessionBase::LocReqType() Begin\n"); |
|
157 SUPLLOG(ELogP1, "CSuplFsmSessionBase::LocReqType() End\n"); |
|
158 return iLocReqType; |
|
159 } |
|
160 |
|
161 |
|
162 /** Initialise internal state machine attributes. |
|
163 This is used when a new protocol procedure commences. |
|
164 */ |
|
165 void CSuplFsmSessionBase::InitialiseMachineBase() |
|
166 { |
|
167 SUPLLOG(ELogP1, "CSuplFsmSessionBase::InitialiseMachineBase() Begin\n"); |
|
168 iTransitionState = ETransitionNull; |
|
169 iProtocolState = EStateActive; |
|
170 iIsCancelPending = EFalse; |
|
171 iSessionConnected = EFalse; |
|
172 iCancelNoLongerAllowed = EFalse; |
|
173 |
|
174 ResetSessionId(); |
|
175 |
|
176 // Clear store from any events that may remain |
|
177 // from previous session |
|
178 iEventStore->ClearStore(); |
|
179 SUPLLOG(ELogP1, "CSuplFsmSessionBase::InitialiseMachineBase() End\n"); |
|
180 } |
|
181 |
|
182 /** Complete state machine attributes. |
|
183 This is used when a protocol procedure completes. |
|
184 */ |
|
185 void CSuplFsmSessionBase::CompleteMachineBase() |
|
186 { |
|
187 SUPLLOG(ELogP1, "CSuplFsmSessionBase::CompleteMachineBase() Begin\n"); |
|
188 iProtocolState = EStateReady; |
|
189 |
|
190 // close connection |
|
191 iObserver.ConnectionManager().Disconnect(iSessionId.SessionNum()); |
|
192 iSessionConnected = EFalse; |
|
193 |
|
194 // clear event store |
|
195 iEventStore->ClearStore(); |
|
196 |
|
197 iSessionIdReplaced = EFalse; |
|
198 |
|
199 // Inform Protocol Manager that procedure is complete |
|
200 iObserver.ProcedureCompleteInd(LocReqType()); |
|
201 SUPLLOG(ELogP1, "CSuplFsmSessionBase::CompleteMachineBase() End\n"); |
|
202 } |
|
203 |
|
204 /** Enter new state. |
|
205 This asks the state handler to perform the actions required when |
|
206 entering a new state. |
|
207 */ |
|
208 TBool CSuplFsmSessionBase::NextStateEntryActionsL() |
|
209 { |
|
210 SUPLLOG(ELogP1, "CSuplFsmSessionBase::NextStateEntryActionsL() Begin\n"); |
|
211 ASSERT(iStateHandler); |
|
212 |
|
213 // Perform entry actions for the new state |
|
214 SUPLLOG(ELogP1, "CSuplFsmSessionBase::NextStateEntryActionsL() End\n"); |
|
215 return iStateHandler->EntryActionsL(); |
|
216 } |
|
217 |
|
218 /** Perform a transition. |
|
219 This initiates a transition following either an external trigger |
|
220 or a decision by the state machine that it must move on to the |
|
221 next state (self-transition). |
|
222 |
|
223 If the transition has been due to an external event, the state machine |
|
224 may yet decide to remain in the current state; @see SelectNextState() |
|
225 */ |
|
226 void CSuplFsmSessionBase::PerformTransition() |
|
227 { |
|
228 SUPLLOG(ELogP1, "CSuplFsmSessionBase::PerformTransition() Begin\n"); |
|
229 if (!IsActive()) |
|
230 { |
|
231 iTransitionState = ETransitionEnter; |
|
232 DoTransitionStage(); |
|
233 } |
|
234 SUPLLOG(ELogP1, "CSuplFsmSessionBase::PerformTransition() End\n"); |
|
235 } |
|
236 |
|
237 /** Do one stage of the state transition. |
|
238 This employs a self-completion mechanism to perform one stage of |
|
239 a state transition. The state machine object is set active and then its |
|
240 own status is completed, which results in its RunL being called. |
|
241 */ |
|
242 void CSuplFsmSessionBase::DoTransitionStage() |
|
243 { |
|
244 SUPLLOG(ELogP1, "CSuplFsmSessionBase::DoTransitionStage() Begin\n"); |
|
245 TRequestStatus* localStatus = &iStatus; |
|
246 iStatus = KRequestPending; |
|
247 SetActive(); |
|
248 User::RequestComplete(localStatus, KErrNone); |
|
249 SUPLLOG(ELogP1, "CSuplFsmSessionBase::DoTransitionStage() End\n"); |
|
250 } |
|
251 |
|
252 /** Returns ETrue if at least one of the positioning methods in a SUPL message |
|
253 is within LBS' capabilities. |
|
254 |
|
255 @param aPosMethod Positioning methods received in a SUPL message. A maximum of two positioning methods are expected. |
|
256 @param aLbsCapabilities Positioning methods supported by LBS. |
|
257 @param aSelected method. If the method returns ETrue, this variable will contain the network preferred |
|
258 positioning method if supported by LBS, otherwise, the network alternative positioning. |
|
259 method. This variable is not modified when the return value is EFalse. |
|
260 @return ETrue if at least one method in aPosMethods is supported by LBS |
|
261 */ |
|
262 TBool CSuplFsmSessionBase::PosMethodSupported(const TLbsNetPosRequestMethod& aPosMethods, TLbsNetPosMethod& aSelectedMethod, const TLbsNetPosCapabilities& aLbsCapabilities) |
|
263 { |
|
264 SUPLLOG(ELogP1, "CSuplFsmSessionBase::PosMethodSupported() Begin\n"); |
|
265 TInt index; |
|
266 TBool methodSupported = EFalse; |
|
267 TLbsNetPosMethod capPosMethod; |
|
268 TInt alternativeMethod = KErrNone; |
|
269 TLbsNetPosMethod netPrefMethod; |
|
270 TLbsNetPosMethod netAltMethod; |
|
271 |
|
272 // There must be a method preferred by the SUPL server |
|
273 if (KErrNone != aPosMethods.GetPosMethod(0, netPrefMethod)) |
|
274 return methodSupported; |
|
275 // There may be an alternative method from the SUPL server |
|
276 alternativeMethod = aPosMethods.GetPosMethod(1, netAltMethod); |
|
277 |
|
278 // Loop through all of LBS-supported positioning methods |
|
279 for (index = 0; index < aLbsCapabilities.NumPosMethods(); index++) |
|
280 { |
|
281 aLbsCapabilities.GetPosMethod(index,capPosMethod); |
|
282 if (netPrefMethod.PosMeans() == capPosMethod.PosMeans() && |
|
283 netPrefMethod.PosMode() == capPosMethod.PosMode()) |
|
284 { |
|
285 // If the preferred network method is supported |
|
286 // just return it. |
|
287 aSelectedMethod = netPrefMethod; |
|
288 methodSupported = ETrue; |
|
289 break; |
|
290 } |
|
291 else if ((KErrNone != alternativeMethod) && |
|
292 (netAltMethod.PosMeans() == capPosMethod.PosMeans()) && |
|
293 (netAltMethod.PosMode() == capPosMethod.PosMode())) |
|
294 { |
|
295 aSelectedMethod = netPrefMethod; |
|
296 methodSupported = ETrue; |
|
297 } |
|
298 } |
|
299 |
|
300 SUPLLOG(ELogP1, "CSuplFsmSessionBase::PosMethodSupported() End\n"); |
|
301 return methodSupported; |
|
302 } |
|
303 |
|
304 |
|
305 /** Indicates if state machine is to be cancelled |
|
306 @return TBool ETrue if machine is to be cancelled |
|
307 */ |
|
308 TBool CSuplFsmSessionBase::IsCancelPending() const |
|
309 { |
|
310 SUPLLOG2(ELogP1, "CSuplFsmSessionBase::IsCancelPending() = %d\n", iIsCancelPending); |
|
311 return iIsCancelPending; |
|
312 } |
|
313 |
|
314 /** Set the status of the connection (connected or not) |
|
315 @param aSessionConnected ETrue means the connection is up |
|
316 */ |
|
317 void CSuplFsmSessionBase::SetSessionConnected(TBool aSessionConnected) |
|
318 { |
|
319 SUPLLOG(ELogP1, "CSuplFsmSessionBase::SetSessionConnected() Begin\n"); |
|
320 iSessionConnected = aSessionConnected; |
|
321 SUPLLOG(ELogP1, "CSuplFsmSessionBase::SetSessionConnected() End\n"); |
|
322 } |
|
323 |
|
324 /** Return the connection status |
|
325 */ |
|
326 TBool CSuplFsmSessionBase::IsSessionConnected() |
|
327 { |
|
328 SUPLLOG(ELogP1, "CSuplFsmSessionBase::IsSessionConnected() Begin\n"); |
|
329 SUPLLOG(ELogP1, "CSuplFsmSessionBase::IsSessionConnected() End\n"); |
|
330 return iSessionConnected; |
|
331 } |
|
332 |
|
333 /** Cancel state machine |
|
334 @param aCancelSource The source that decided to cancel. |
|
335 */ |
|
336 void CSuplFsmSessionBase::CancelMachine(const TCancelSource& aCancelSource, const TCancelReason& aReason) |
|
337 { |
|
338 SUPLLOG(ELogP1, "CSuplFsmSessionBase::CancelMachine() Begin\n"); |
|
339 TBool forcedCancel = EFalse; |
|
340 if ((aCancelSource == CSuplFsmSessionBase::ECancelClosing)) |
|
341 { |
|
342 // Cancel requested from RunError. |
|
343 // Set the machine as disconnected so there is no attempt to |
|
344 // send a SUPL END. This is to prevent the execution |
|
345 // of leaving methods by the state machine from this point onwards. |
|
346 // |
|
347 iSessionConnected = EFalse; |
|
348 |
|
349 forcedCancel = ETrue; |
|
350 } |
|
351 |
|
352 // Always cancel if the cancel is forced. |
|
353 // Otherwise, only cancel if no cancel is in progress |
|
354 // and no cancel has already been requested |
|
355 // (only the first cancel source is considered) |
|
356 // and if cancel is allowed. |
|
357 if (forcedCancel || |
|
358 ((EStateCancelling != iProtocolState) && !iIsCancelPending && !iCancelNoLongerAllowed)) |
|
359 { |
|
360 iIsCancelPending = ETrue; |
|
361 |
|
362 // Cancel the active procedure |
|
363 CancelProcedure(); |
|
364 |
|
365 StoreCancelInfo(aCancelSource,aReason); |
|
366 |
|
367 // Perform state transition |
|
368 PerformTransition(); |
|
369 } |
|
370 SUPLLOG(ELogP1, "CSuplFsmSessionBase::CancelMachine() End\n"); |
|
371 } |
|
372 |
|
373 /** Sets state machine attributes to represent cancelling |
|
374 */ |
|
375 void CSuplFsmSessionBase::SetMachineAsCancelling() |
|
376 { |
|
377 SUPLLOG(ELogP1, "CSuplFsmSessionBase::SetMachineAsCancelling() Begin\n"); |
|
378 iIsCancelPending = EFalse; |
|
379 iProtocolState = EStateCancelling; |
|
380 SUPLLOG(ELogP1, "CSuplFsmSessionBase::SetMachineAsCancelling() End\n"); |
|
381 } |
|
382 |
|
383 /** Sets state machine to not-cancellable |
|
384 Derived state machines call this method after entering |
|
385 some of the last states of the procedure when it no longer |
|
386 make sense to accept cancel requests |
|
387 */ |
|
388 void CSuplFsmSessionBase::SetMachineAsNotCancellable() |
|
389 { |
|
390 SUPLLOG(ELogP1, "CSuplFsmSessionBase::SetMachineAsNotCancellable() Begin\n"); |
|
391 iCancelNoLongerAllowed = ETrue; |
|
392 SUPLLOG(ELogP1, "CSuplFsmSessionBase::SetMachineAsNotCancellable() End\n"); |
|
393 } |
|
394 |
|
395 |
|
396 /** Check for a stored events. |
|
397 Determine if there is an event stored and, if so, trigger |
|
398 a transition to see if the event needs handling from |
|
399 current state. |
|
400 */ |
|
401 void CSuplFsmSessionBase::CheckForStoredEvents() |
|
402 { |
|
403 SUPLLOG(ELogP1, "CSuplFsmSessionBase::CheckForStoredEvents() Begin\n"); |
|
404 ASSERT(!IsActive()); // method only called when the AO is inactive |
|
405 |
|
406 // Check for a pending event when the machine is active |
|
407 if ((iProtocolState == EStateActive) && (!iEventStore->IsStoreEmpty())) |
|
408 { |
|
409 PerformTransition(); |
|
410 } |
|
411 SUPLLOG(ELogP1, "CSuplFsmSessionBase::CheckForStoredEvents() End\n"); |
|
412 } |
|
413 |
|
414 /** Active object completion handler |
|
415 */ |
|
416 void CSuplFsmSessionBase::RunL() |
|
417 { |
|
418 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RunL() Begin\n"); |
|
419 SUPLLOG3(ELogP1, " iStatus=%d, iTransitionState=&d\n", iStatus.Int(), iTransitionState); |
|
420 |
|
421 TBool stateChanged = EFalse; |
|
422 TBool redoEntryActions = EFalse; |
|
423 TBool entryActionsConducted = EFalse; |
|
424 // Check we have completed ok |
|
425 if (KErrNone == iStatus.Int()) |
|
426 { |
|
427 // Which stage of the transition is this? |
|
428 switch (iTransitionState) |
|
429 { |
|
430 |
|
431 // About to enter a state |
|
432 case ETransitionEnter: |
|
433 |
|
434 // Reset transition state value |
|
435 iTransitionState = ETransitionNull; |
|
436 |
|
437 // Perform state machine transition. |
|
438 stateChanged = SelectNextState(redoEntryActions); |
|
439 |
|
440 // Execute next state entry actions only if a |
|
441 // cancel has not been requested from |
|
442 // SelectNextState() due to unexpected message. |
|
443 if (!iIsCancelPending) |
|
444 { |
|
445 if (stateChanged || redoEntryActions) |
|
446 { |
|
447 entryActionsConducted = NextStateEntryActionsL(); |
|
448 } |
|
449 } |
|
450 |
|
451 // Perform state machine post-transition actions |
|
452 // Note: this will initiate a transition out of states |
|
453 // that perform self-transition. |
|
454 PostTransition(); |
|
455 |
|
456 // When the state machine is not active (it is waiting |
|
457 // for an external trigger) check if there are |
|
458 // any stored events to be handled that may provoke |
|
459 // a transition. |
|
460 if (!IsActive()) |
|
461 { |
|
462 // If the last transition neither changed state |
|
463 // nor was conductive to any actions then it can |
|
464 // be assumed that there are no pending events that |
|
465 // can be handled from the current state (a transition |
|
466 // can only be triggered by a new event) |
|
467 if (stateChanged || entryActionsConducted) |
|
468 { |
|
469 CheckForStoredEvents(); |
|
470 } |
|
471 } |
|
472 break; |
|
473 |
|
474 // Not changing state just performing asynchronous activities |
|
475 // or waiting for new events |
|
476 case ETransitionNull: |
|
477 default: |
|
478 // Empty intentionally |
|
479 break; |
|
480 }; |
|
481 } |
|
482 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RunL() End\n"); |
|
483 } |
|
484 |
|
485 /** Active object completion handler |
|
486 */ |
|
487 void CSuplFsmSessionBase::RunError() |
|
488 { |
|
489 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RunError() Begin\n"); |
|
490 CancelMachine(ECancelClosing,EReasonNone); |
|
491 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RunError() End\n"); |
|
492 } |
|
493 |
|
494 |
|
495 /** Active object cancellation handler |
|
496 */ |
|
497 void CSuplFsmSessionBase::DoCancel() |
|
498 { |
|
499 SUPLLOG(ELogP1, "CSuplFsmSessionBase::DoCancel() Begin\n"); |
|
500 iStatus = KErrCancel; |
|
501 SUPLLOG(ELogP1, "CSuplFsmSessionBase::DoCancel() End\n"); |
|
502 } |
|
503 |
|
504 /** Retrieve Stored Message Session Id |
|
505 @return Pointer to the stored message session ID object |
|
506 */ |
|
507 CSuplSessionId* CSuplFsmSessionBase::MessageSessionId() |
|
508 { |
|
509 SUPLLOG(ELogP1, "CSuplFsmSessionBase::MessageSessionId() Begin\n"); |
|
510 SUPLLOG(ELogP1, "CSuplFsmSessionBase::MessageSessionId() End\n"); |
|
511 return iMessageSessionId; |
|
512 } |
|
513 |
|
514 /** Store Message Session Id |
|
515 @return Pointer to the stored message session ID object |
|
516 */ |
|
517 void CSuplFsmSessionBase::SetMessageSessionId(CSuplSessionId* aMessageSessionId) |
|
518 { |
|
519 SUPLLOG(ELogP1, "CSuplFsmSessionBase::SetMessageSessionId() Begin\n"); |
|
520 |
|
521 // Delete old session Id, take ownership of the new one |
|
522 if (iMessageSessionId != NULL) |
|
523 { |
|
524 delete iMessageSessionId; |
|
525 } |
|
526 |
|
527 |
|
528 iMessageSessionId = aMessageSessionId; |
|
529 SUPLLOG(ELogP1, "CSuplFsmSessionBase::SetMessageSessionId() End\n"); |
|
530 } |
|
531 |
|
532 /** Store assistance data mask from an assistance data request |
|
533 @param aFilter Requested assistance data types |
|
534 */ |
|
535 void CSuplFsmSessionBase::StoreAssistanceDataRequest(const TLbsAssistanceDataGroup& aFilter) |
|
536 { |
|
537 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StoreAssistanceDataRequest() Begin\n"); |
|
538 iEventStore->StoreEvent(aFilter); |
|
539 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StoreAssistanceDataRequest() End\n"); |
|
540 } |
|
541 |
|
542 /** Store location request positioning method |
|
543 @param aOptions Location request options |
|
544 @return KErrNone or KErrNoMemory |
|
545 */ |
|
546 TInt CSuplFsmSessionBase::StoreLocationRequest(const TLbsNetPosRequestOptionsBase& aOptions) |
|
547 { |
|
548 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StoreLocationRequest() Begin\n"); |
|
549 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StoreLocationRequest() End\n"); |
|
550 return iEventStore->StoreEvent(aOptions); |
|
551 } |
|
552 |
|
553 /** Store a SUPL message in the event store |
|
554 @param aSuplMessage a pointer to the SUPL message being stored (ownership transferred) |
|
555 */ |
|
556 void CSuplFsmSessionBase::StoreSuplMessage(const CSuplMessageBase* aSuplMessage) |
|
557 { |
|
558 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StoreSuplMessage() Begin\n"); |
|
559 iEventStore->StoreEvent(aSuplMessage); |
|
560 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StoreSuplMessage() End\n"); |
|
561 } |
|
562 |
|
563 /** Store a Positioning Protocol payload in the event store |
|
564 @param aPositioningPayload a pointer to the payload being stored (ownership transferred) |
|
565 */ |
|
566 void CSuplFsmSessionBase::StorePosPayload(const CSuplPosPayload* aPositioningPayload) |
|
567 { |
|
568 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StorePosPayload() Begin\n"); |
|
569 iEventStore->StoreEvent(aPositioningPayload); |
|
570 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StorePosPayload() End\n"); |
|
571 } |
|
572 |
|
573 /** Store reason for cancelling the procedure and source of the cancel |
|
574 @param aSource the originator of the cancel |
|
575 @param aReason the reason for cancelling the procedure |
|
576 */ |
|
577 void CSuplFsmSessionBase::StoreCancelInfo(const CSuplFsmSessionBase::TCancelSource& aSource, |
|
578 const CSuplFsmSessionBase::TCancelReason& aReason) |
|
579 { |
|
580 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StoreCancelInfo() Begin\n"); |
|
581 iEventStore->StoreEvent(aSource,aReason); |
|
582 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StoreCancelInfo() End\n"); |
|
583 } |
|
584 |
|
585 void CSuplFsmSessionBase::StoreNetInfo(const RMobilePhone::TMobilePhoneNetworkInfoV1& aNetworkInfo, |
|
586 const RMobilePhone::TMobilePhoneLocationAreaV1& aLocationArea) |
|
587 { |
|
588 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StoreNetInfo() Begin\n"); |
|
589 //We store only information for two modes supported - GSM & WCDMA |
|
590 if(aNetworkInfo.iMode==RMobilePhone::ENetworkModeGsm || aNetworkInfo.iMode==RMobilePhone::ENetworkModeWcdma) |
|
591 { |
|
592 iEventStore->StoreEvent(aNetworkInfo, aLocationArea); |
|
593 } |
|
594 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StoreNetInfo() End\n"); |
|
595 } |
|
596 void CSuplFsmSessionBase::StoreMccMnc(TUint aMcc, TUint aMnc) |
|
597 { |
|
598 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StoreMccMnc() Begin\n"); |
|
599 iMcc = aMcc; |
|
600 iMnc = aMnc; |
|
601 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StoreMccMnc() End\n"); |
|
602 } |
|
603 |
|
604 void CSuplFsmSessionBase::StoreMsisdn(const TDesC& aTelNumber) |
|
605 { |
|
606 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StoreMsisdn() Begin\n"); |
|
607 delete iTelNumber; |
|
608 iTelNumber = HBufC::New(aTelNumber.Length()); |
|
609 if(iTelNumber) |
|
610 { |
|
611 (*iTelNumber) = aTelNumber; |
|
612 } |
|
613 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StoreMsisdn() End\n"); |
|
614 } |
|
615 |
|
616 void CSuplFsmSessionBase::StoreCellInfo(const RMobilePhone::TMobilePhoneCellInfoV9& aCellInfo) |
|
617 { |
|
618 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StoreCellInfo() Begin\n"); |
|
619 iEventStore->StoreEvent(aCellInfo); |
|
620 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StoreCellInfo() End\n"); |
|
621 } |
|
622 |
|
623 void CSuplFsmSessionBase::StorePositioningEnded(TBool aPositioningEnded) |
|
624 { |
|
625 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StorePositioningEnded() Begin\n"); |
|
626 iEventStore->SetPositioningEnded(aPositioningEnded); |
|
627 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StorePositioningEnded() End\n"); |
|
628 } |
|
629 |
|
630 |
|
631 |
|
632 /** Retrieve from event store options associated to a location request from LBS. |
|
633 @param aOptions upon return, contains the options of a previous location request. |
|
634 When the method is from a Cell-Based state machine, aOptions must be of type |
|
635 TLbsNetPosRequestOptions. When called from an AGPS state machine, aOptions |
|
636 must be of type TLbsNetPosRequestOptionsAssistance. |
|
637 */ |
|
638 TBool CSuplFsmSessionBase::RetrieveLocationRequestOptions(TLbsNetPosRequestOptions& aOptions) |
|
639 { |
|
640 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveLocationRequestOptions() Begin\n"); |
|
641 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveLocationRequestOptions() End\n"); |
|
642 return iEventStore->GetLocationRequestOptions(aOptions); |
|
643 } |
|
644 |
|
645 /** Retrieve an assistance data request mask from the event store |
|
646 @return EFalse if no assistance data request mask is stored |
|
647 @param aPositioningPayload a pointer to the payload being stored (ownership transferred) |
|
648 */ |
|
649 TBool CSuplFsmSessionBase::RetrieveAssistanceDataRequest(TLbsAssistanceDataGroup& aAssitDataMask) |
|
650 { |
|
651 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveAssistanceDataRequest() Begin\n"); |
|
652 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveAssistanceDataRequest() End\n"); |
|
653 return iEventStore->GetAssistanceDataRequest(aAssitDataMask); |
|
654 } |
|
655 |
|
656 /** Retrieve the oldest stored SUPL message from the event store |
|
657 Ownership of the message is transferred to the caller. |
|
658 */ |
|
659 const CSuplMessageBase* CSuplFsmSessionBase::RetrieveSuplMessage() |
|
660 { |
|
661 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveSuplMessage() Begin\n"); |
|
662 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveSuplMessage() End\n"); |
|
663 return iEventStore->SuplMessage(); |
|
664 } |
|
665 |
|
666 /** Retrieve the oldest stored Positioning payload from the event store |
|
667 Ownership of the payload object is transferred to the caller. |
|
668 */ |
|
669 const CSuplPosPayload* CSuplFsmSessionBase::RetrievePosPayload() |
|
670 { |
|
671 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrievePosPayload() Begin\n"); |
|
672 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrievePosPayload() End\n"); |
|
673 return iEventStore->PosPayload(); |
|
674 } |
|
675 |
|
676 void CSuplFsmSessionBase::RetrieveCancelInfo(CSuplFsmSessionBase::TCancelSource& aSource, |
|
677 CSuplFsmSessionBase::TCancelReason& aReason) |
|
678 { |
|
679 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveCancelInfo() Begin\n"); |
|
680 iEventStore->GetCancelInfo(aSource,aReason); |
|
681 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveCancelInfo() End\n"); |
|
682 } |
|
683 |
|
684 const TInetAddr& CSuplFsmSessionBase::RetrieveLocalIpAddress() |
|
685 { |
|
686 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveLocalIpAddress() Begin\n"); |
|
687 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveLocalIpAddress() End\n"); |
|
688 return iEventStore->Address(); |
|
689 } |
|
690 |
|
691 |
|
692 void CSuplFsmSessionBase::RetrieveStoredNetworkInfo(RMobilePhone::TMobilePhoneNetworkInfoV1& aNetworkInfo, |
|
693 RMobilePhone::TMobilePhoneLocationAreaV1& aLocationArea) |
|
694 { |
|
695 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveStoredNetworkInfo() Begin\n"); |
|
696 iEventStore->GetNetworkInfo(aNetworkInfo, aLocationArea); |
|
697 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveStoredNetworkInfo() End\n"); |
|
698 } |
|
699 |
|
700 TBool CSuplFsmSessionBase::RetrieveStoredCellInfo(RMobilePhone::TMobilePhoneCellInfoV9& aCellInfo) |
|
701 { |
|
702 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveStoredCellInfo() Begin\n"); |
|
703 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveStoredCellInfo() End\n"); |
|
704 return iEventStore->GetCellInfo(aCellInfo); |
|
705 } |
|
706 |
|
707 void CSuplFsmSessionBase::RetrievePrivacyAdvice(TLbsNetPosRequestPrivacy& aPrivacy) |
|
708 { |
|
709 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrievePrivacyAdvice() Begin\n"); |
|
710 iEventStore->GetPrivacyAdvice(aPrivacy); |
|
711 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrievePrivacyAdvice() End\n"); |
|
712 } |
|
713 |
|
714 void CSuplFsmSessionBase::RetrieveRequestorInfo(TLbsExternalRequestInfo& aRequestor) |
|
715 { |
|
716 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveRequestorInfo() Begin\n"); |
|
717 iEventStore->GetRequestorInfo(aRequestor); |
|
718 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveRequestorInfo() End\n"); |
|
719 } |
|
720 |
|
721 void CSuplFsmSessionBase::RetrieveInitPosMethod(TLbsNetPosRequestMethod& aPosMethod) |
|
722 { |
|
723 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveInitPosMethod() Begin\n"); |
|
724 iEventStore->GetInitPosMethod(aPosMethod); |
|
725 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveInitPosMethod() End\n"); |
|
726 } |
|
727 |
|
728 void CSuplFsmSessionBase::RetrieveInitQuality(TLbsNetPosRequestQuality& aQuality) |
|
729 { |
|
730 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveInitQuality() Begin\n"); |
|
731 iEventStore->GetInitQuality(aQuality); |
|
732 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveInitQuality() End\n"); |
|
733 } |
|
734 |
|
735 void CSuplFsmSessionBase::RetrieveVer(TDes8& ver) |
|
736 { |
|
737 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveVer() Begin\n"); |
|
738 iEventStore->GetVer(ver); |
|
739 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrieveVer() End\n"); |
|
740 } |
|
741 |
|
742 TBool CSuplFsmSessionBase::RetrievePositioningSessionEnded() |
|
743 { |
|
744 SUPLLOG(ELogP1, "CSuplFsmSessionBase::PositioningSessionEnded() Begin\n"); |
|
745 SUPLLOG(ELogP1, "CSuplFsmSessionBase::PositioningSessionEnded() End\n"); |
|
746 return iEventStore->PositioningEnded(); |
|
747 } |
|
748 |
|
749 TBool CSuplFsmSessionBase::IsPositionStored() |
|
750 { |
|
751 SUPLLOG(ELogP1, "CSuplFsmSessionBase::IsPositionStored() Begin\n"); |
|
752 SUPLLOG(ELogP1, "CSuplFsmSessionBase::IsPositionStored() End\n"); |
|
753 return iEventStore->IsPositionStored(); |
|
754 } |
|
755 |
|
756 /** Returns pointer to the stored position information |
|
757 */ |
|
758 TPositionInfoBase* CSuplFsmSessionBase::RetrievePositionL() |
|
759 { |
|
760 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrievePositionL() Begin\n"); |
|
761 SUPLLOG(ELogP1, "CSuplFsmSessionBase::RetrievePositionL() End\n"); |
|
762 return iEventStore->PositionL(); |
|
763 } |
|
764 |
|
765 /** Retrieve from event store whether an unexpected SUPL END was received or not |
|
766 */ |
|
767 TBool CSuplFsmSessionBase::IsUnexpectedSuplEndStored() |
|
768 { |
|
769 SUPLLOG(ELogP1, "CSuplFsmSessionBase::IsUnexpectedSuplEndStored() Begin\n"); |
|
770 SUPLLOG(ELogP1, "CSuplFsmSessionBase::IsUnexpectedSuplEndStored() End\n"); |
|
771 return iEventStore->UnexpectedSuplEndStored(); |
|
772 } |
|
773 |
|
774 TBool CSuplFsmSessionBase::IsAssistanceDataRequestStored() |
|
775 { |
|
776 SUPLLOG(ELogP1, "CSuplFsmSessionBase::IsAssistanceDataRequestStored() Begin\n"); |
|
777 SUPLLOG(ELogP1, "CSuplFsmSessionBase::IsAssistanceDataRequestStored() End\n"); |
|
778 return iEventStore->IsAssistanceDataReqStored(); |
|
779 } |
|
780 |
|
781 TBool CSuplFsmSessionBase::IsNetworkInfoAvailable() |
|
782 { |
|
783 SUPLLOG(ELogP1, "CSuplFsmSessionBase::IsNetworkInfoAvailable() Begin\n"); |
|
784 SUPLLOG(ELogP1, "CSuplFsmSessionBase::IsNetworkInfoAvailable() End\n"); |
|
785 return iEventStore->IsNetworkInfoAvailable(); |
|
786 } |
|
787 |
|
788 TBool CSuplFsmSessionBase::PosSessionConducted() |
|
789 { |
|
790 SUPLLOG(ELogP1, "CSuplFsmSessionBase::PosSessionConducted() Begin\n"); |
|
791 SUPLLOG(ELogP1, "CSuplFsmSessionBase::PosSessionConducted() End\n"); |
|
792 return iEventStore->PosSessionConducted(); |
|
793 } |
|
794 |
|
795 TInt CSuplFsmSessionBase::GenerateHostId(TLbsHostSettingsId& aHostId) |
|
796 { |
|
797 SUPLLOG(ELogP1, "CSuplFsmSessionBase::GenerateHostId() Begin\n"); |
|
798 TRAPD(err, GenerateHostIdL(aHostId)); |
|
799 SUPLLOG(ELogP1, "CSuplFsmSessionBase::GenerateHostId() End\n"); |
|
800 return err; |
|
801 } |
|
802 |
|
803 void CSuplFsmSessionBase::GenerateHostIdL(TLbsHostSettingsId& aHostId) |
|
804 { |
|
805 SUPLLOG(ELogP1, "CSuplFsmSessionBase::GenerateHostIdL() Begin\n"); |
|
806 //Set the UID to zero first of all |
|
807 aHostId.Null(); |
|
808 |
|
809 //Generating the address |
|
810 _LIT8(KHslpAddresFormat, "h-slp.mnc%03d.mcc%03d.pub.3gppnetwork.org"); |
|
811 TLbsHostNameAddress hslpAddress; |
|
812 |
|
813 hslpAddress.Format(KHslpAddresFormat, iMnc, iMcc); |
|
814 |
|
815 //Creating a new record |
|
816 CLbsHostSettingsStore* settingsStore = CLbsHostSettingsStore::NewL(KLbsHostSettingsSuplStoreId); |
|
817 CleanupStack::PushL(settingsStore); |
|
818 |
|
819 TLbsHostSettingsSupl settings; |
|
820 _LIT8(KDefSuplServer, "defSuplServer"); |
|
821 settings.SetName(KDefSuplServer); |
|
822 _LIT8(KDefaultConfig, "defaultConfig"); |
|
823 settings.SetProviderId(KDefaultConfig); |
|
824 |
|
825 settings.SetHostNameAddress(hslpAddress); |
|
826 settings.SetPortId(KLbsSuplUseDefaultPortId); |
|
827 //To tell the Connection Manager to use the default connection |
|
828 settings.SetConnectionPoint(0, TLbsHostSettingsSupl::ELbsConnectionTypeInvalid); |
|
829 |
|
830 settings.SetAuthModesMOLR(TLbsHostSettingsSupl::EAuthAcaTls); |
|
831 settings.SetAuthModesMTLR(TLbsHostSettingsSupl::EAuthAcaTls); |
|
832 |
|
833 TInt err= settingsStore->CreateHostSettings(settings, KUidLbsHostSettingsCreator, iDefSettingsId); |
|
834 if(err!=KErrNone) |
|
835 { |
|
836 iDefSettingsId.Null(); |
|
837 User::Leave(err); |
|
838 } |
|
839 aHostId = iDefSettingsId; |
|
840 |
|
841 CleanupStack::PopAndDestroy(settingsStore); |
|
842 SUPLLOG(ELogP1, "CSuplFsmSessionBase::GenerateHostIdL() End\n"); |
|
843 } |
|
844 |
|
845 |
|
846 //----------------------------------------------------------------------------- |
|
847 // State Machine Event Store Class Methods |
|
848 //----------------------------------------------------------------------------- |
|
849 |
|
850 /** Static constructor |
|
851 @param aMaxEntries Maximum requests to be held in the intenal queues. |
|
852 @return A new instance of the CStateQueue class. |
|
853 */ |
|
854 CSuplFsmEventStore* CSuplFsmEventStore::NewL(TInt aMaxEntries) |
|
855 { |
|
856 SUPLLOG(ELogP1, "CSuplFsmEventStore::NewL() Begin\n"); |
|
857 CSuplFsmEventStore* self = new (ELeave) CSuplFsmEventStore(aMaxEntries); |
|
858 SUPLLOG(ELogP1, "CSuplFsmEventStore::NewL() End\n"); |
|
859 return self; |
|
860 } |
|
861 |
|
862 /** Default private constructor |
|
863 @param aMaxEntries Maximum requests to be held in the queue. |
|
864 */ |
|
865 CSuplFsmEventStore::CSuplFsmEventStore(TInt aMaxEntries) |
|
866 : iLocRequestOptions (NULL), |
|
867 iCancelSource(CSuplFsmSessionBase::ECancelNone), |
|
868 iCancelReason(CSuplFsmSessionBase::EReasonNone), |
|
869 iMessageQueue(aMaxEntries), |
|
870 iPayloadQueue(aMaxEntries), |
|
871 iMaxEntries(aMaxEntries) |
|
872 { |
|
873 SUPLLOG(ELogP1, "CSuplFsmEventStore::CSuplFsmEventStore() Begin\n"); |
|
874 SUPLLOG(ELogP1, "CSuplFsmEventStore::CSuplFsmEventStore() End\n"); |
|
875 } |
|
876 |
|
877 |
|
878 /** Destructor |
|
879 */ |
|
880 CSuplFsmEventStore::~CSuplFsmEventStore() |
|
881 { |
|
882 SUPLLOG(ELogP1, "CSuplFsmEventStore::~CSuplFsmEventStore() Begin\n"); |
|
883 // Delete stored messages |
|
884 iMessageQueue.ResetAndDestroy(); |
|
885 iPayloadQueue.ResetAndDestroy(); |
|
886 delete iLocRequestOptions; |
|
887 iLocRequestOptions = NULL; |
|
888 delete iPosition; |
|
889 iPosition = NULL; |
|
890 SUPLLOG(ELogP1, "CSuplFsmEventStore::~CSuplFsmEventStore() End\n"); |
|
891 } |
|
892 |
|
893 /** Clear all the events from the store |
|
894 */ |
|
895 void CSuplFsmEventStore::ClearStore() |
|
896 { |
|
897 SUPLLOG(ELogP1, "CSuplFsmEventStore::ClearStore() Begin\n"); |
|
898 if (iMessageQueue.Count() > 0) |
|
899 { |
|
900 iMessageQueue.ResetAndDestroy(); |
|
901 } |
|
902 if (iPayloadQueue.Count() > 0) |
|
903 { |
|
904 iPayloadQueue.ResetAndDestroy(); |
|
905 } |
|
906 |
|
907 iAssistanceDataStored = EFalse; |
|
908 |
|
909 if (iLocationRequestStored) |
|
910 { |
|
911 delete iLocRequestOptions; |
|
912 iLocRequestOptions = NULL; |
|
913 iLocationRequestStored = EFalse; |
|
914 } |
|
915 |
|
916 iUnexpectedSuplEndReceived = EFalse; |
|
917 if (iPositionStored) |
|
918 { |
|
919 iPositionStored = EFalse; |
|
920 delete iPosition; |
|
921 iPosition = NULL; |
|
922 } |
|
923 |
|
924 iPositioningEnded = EFalse; |
|
925 iPosSessionConducted = EFalse; |
|
926 iCancelSource = CSuplFsmSessionBase::ECancelNone; |
|
927 iPrivacyRespStored = EFalse; |
|
928 iPositionStored = EFalse; |
|
929 iPositioningEnded = EFalse; |
|
930 iPosSessionConducted = EFalse; |
|
931 |
|
932 SUPLLOG(ELogP1, "CSuplFsmEventStore::ClearStore() End\n"); |
|
933 } |
|
934 |
|
935 /** Return true if there is any event in the store |
|
936 */ |
|
937 TBool CSuplFsmEventStore::IsStoreEmpty() |
|
938 { |
|
939 SUPLLOG(ELogP1, "CSuplFsmEventStore::IsStoreEmpty() Begin\n"); |
|
940 TBool empty = ETrue; |
|
941 |
|
942 if (iAssistanceDataStored || |
|
943 iMessageQueue.Count() > 0 || |
|
944 iPayloadQueue.Count() > 0) |
|
945 { |
|
946 empty = EFalse; |
|
947 } |
|
948 SUPLLOG(ELogP1, "CSuplFsmEventStore::IsStoreEmpty() End\n"); |
|
949 return empty; |
|
950 } |
|
951 |
|
952 |
|
953 /** Return true if there are any SUPL message in the store. If |
|
954 there are any, return a pointer to the oldest stored message |
|
955 in aSuplMessage but keep the message in the store (ownership |
|
956 is not transferred). |
|
957 @param aSuplMessage Reference to the oldest stored message. |
|
958 */ |
|
959 TBool CSuplFsmEventStore::IsSuplMessageStored(const CSuplMessageBase*& aSuplMessage) |
|
960 { |
|
961 SUPLLOG(ELogP1, "CSuplFsmEventStore::IsSuplMessageStored() Begin\n"); |
|
962 TBool ret = EFalse; |
|
963 if (iMessageQueue.Count() > 0) |
|
964 { |
|
965 aSuplMessage = (iMessageQueue[iMessageQueue.Count() - 1]); |
|
966 ret = ETrue; |
|
967 } |
|
968 SUPLLOG(ELogP1, "CSuplFsmEventStore::IsSuplMessageStored() End\n"); |
|
969 return ret; |
|
970 } |
|
971 |
|
972 /** Return true if assistance data request is stored |
|
973 */ |
|
974 TBool CSuplFsmEventStore::IsAssistanceDataReqStored() |
|
975 { |
|
976 SUPLLOG(ELogP1, "CSuplFsmEventStore::IsAssistanceDataReqStored() Begin\n"); |
|
977 SUPLLOG(ELogP1, "CSuplFsmEventStore::IsAssistanceDataReqStored() End\n"); |
|
978 return iAssistanceDataStored; |
|
979 } |
|
980 |
|
981 /** Return true if network data is stored |
|
982 */ |
|
983 TBool CSuplFsmEventStore::IsNetworkInfoAvailable() |
|
984 { |
|
985 SUPLLOG(ELogP1, "CSuplFsmEventStore::IsNetworkInfoAvailable() Begin\n"); |
|
986 SUPLLOG(ELogP1, "CSuplFsmEventStore::IsNetworkInfoAvailable() End\n"); |
|
987 return iNetworkDataStored; |
|
988 } |
|
989 |
|
990 TBool CSuplFsmEventStore::IsPositionStored() |
|
991 { |
|
992 SUPLLOG(ELogP1, "CSuplFsmEventStore::IsPositionStored() Begin\n"); |
|
993 SUPLLOG(ELogP1, "CSuplFsmEventStore::IsPositionStored() End\n"); |
|
994 return iPositionStored; |
|
995 } |
|
996 |
|
997 /** Returns ETrue if assistance data request is stored. In such case |
|
998 return the requested assistance data mask. |
|
999 @return TBool ETrue if the assistance data mask of a previous request is stored |
|
1000 @param aAssistDataMask variable that after the call will hold the stored assistance data mask |
|
1001 */ |
|
1002 TBool CSuplFsmEventStore::GetAssistanceDataRequest(TLbsAssistanceDataGroup& aAssistDataMask) |
|
1003 { |
|
1004 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetAssistanceDataRequest() Begin\n"); |
|
1005 TBool requested = EFalse; |
|
1006 if (iAssistanceDataStored) |
|
1007 { |
|
1008 aAssistDataMask = iAssistanceDataMask; |
|
1009 iAssistanceDataStored = EFalse; |
|
1010 requested = ETrue; |
|
1011 } |
|
1012 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetAssistanceDataRequest() End\n"); |
|
1013 return requested; |
|
1014 } |
|
1015 |
|
1016 /** Returns ETrue if the parameters of a location request are stored. In such case |
|
1017 return the parameters of request. |
|
1018 @return TBool ETrue if the paramaters of a previous location request are stored. |
|
1019 @param aOptions variable that after the call will hold the stored parameters of the previous location request. |
|
1020 */ |
|
1021 TBool CSuplFsmEventStore::GetLocationRequestOptions(TLbsNetPosRequestOptionsBase& aOptions) |
|
1022 { |
|
1023 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetLocationRequestOptions() Begin\n"); |
|
1024 TBool ret = EFalse; |
|
1025 if (iLocationRequestStored) |
|
1026 { |
|
1027 if (aOptions.ClassType() == iLocRequestOptions->ClassType()) |
|
1028 { |
|
1029 Mem::Copy(&aOptions, iLocRequestOptions, iLocRequestOptions->ClassSize()); |
|
1030 ret = ETrue; |
|
1031 } |
|
1032 } |
|
1033 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetLocationRequestOptions() End\n"); |
|
1034 return ret; |
|
1035 } |
|
1036 |
|
1037 /** Returns a pointer to the oldest stored SUPL message |
|
1038 or NULL if no message was avaible. |
|
1039 Ownership of the message is transferred. |
|
1040 */ |
|
1041 const CSuplMessageBase* CSuplFsmEventStore::SuplMessage() |
|
1042 { |
|
1043 SUPLLOG(ELogP1, "CSuplFsmEventStore::SuplMessage() Begin\n"); |
|
1044 const CSuplMessageBase* msgPtr = NULL; |
|
1045 |
|
1046 // Pop last message off the array (FIFO) |
|
1047 if (iMessageQueue.Count() > 0) |
|
1048 { |
|
1049 msgPtr = iMessageQueue[iMessageQueue.Count() - 1]; |
|
1050 iMessageQueue.Remove(iMessageQueue.Count() - 1); |
|
1051 } |
|
1052 SUPLLOG(ELogP1, "CSuplFsmEventStore::SuplMessage() End\n"); |
|
1053 return msgPtr; |
|
1054 } |
|
1055 |
|
1056 |
|
1057 const TInetAddr& CSuplFsmEventStore::Address() |
|
1058 { |
|
1059 SUPLLOG(ELogP1, "CSuplFsmEventStore::Address() Begin\n"); |
|
1060 SUPLLOG(ELogP1, "CSuplFsmEventStore::Address() End\n"); |
|
1061 return iAddress; |
|
1062 } |
|
1063 |
|
1064 /** Returns a pointer to the oldest stored Positioning Payload |
|
1065 or NULL if no message was avaible. |
|
1066 |
|
1067 Ownership of the message is transferred. |
|
1068 */ |
|
1069 const CSuplPosPayload* CSuplFsmEventStore::PosPayload() |
|
1070 { |
|
1071 SUPLLOG(ELogP1, "CSuplFsmEventStore::PosPayload() Begin\n"); |
|
1072 const CSuplPosPayload* payloadPtr = NULL; |
|
1073 |
|
1074 // Pop last payload off the array (FIFO) |
|
1075 if (iPayloadQueue.Count() > 0) |
|
1076 { |
|
1077 payloadPtr = iPayloadQueue[iPayloadQueue.Count() - 1]; |
|
1078 iPayloadQueue.Remove(iPayloadQueue.Count() - 1); |
|
1079 } |
|
1080 SUPLLOG(ELogP1, "CSuplFsmEventStore::PosPayload() End\n"); |
|
1081 return payloadPtr; |
|
1082 } |
|
1083 |
|
1084 /** Returns the stored source and reason of a previous cancel |
|
1085 */ |
|
1086 void CSuplFsmEventStore::GetCancelInfo(CSuplFsmSessionBase::TCancelSource& aSource,CSuplFsmSessionBase::TCancelReason& aReason) |
|
1087 { |
|
1088 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetCancelInfo() Begin\n"); |
|
1089 aSource = iCancelSource; |
|
1090 aReason = iCancelReason; |
|
1091 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetCancelInfo() End\n"); |
|
1092 } |
|
1093 |
|
1094 /** Returns the stored current network parameters |
|
1095 */ |
|
1096 void CSuplFsmEventStore::GetNetworkInfo(RMobilePhone::TMobilePhoneNetworkInfoV1& aNetworkInfo, |
|
1097 RMobilePhone::TMobilePhoneLocationAreaV1& aLocationArea) |
|
1098 { |
|
1099 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetNetworkInfo() Begin\n"); |
|
1100 aNetworkInfo = iNetworkInfo; |
|
1101 aLocationArea = iLocationArea; |
|
1102 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetNetworkInfo() End\n"); |
|
1103 } |
|
1104 |
|
1105 /** Returns the stored cell info with timing advance |
|
1106 network parameters |
|
1107 */ |
|
1108 TBool CSuplFsmEventStore::GetCellInfo(RMobilePhone::TMobilePhoneCellInfoV9& aCellInfo) |
|
1109 { |
|
1110 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetCellInfo() Begin\n"); |
|
1111 if (iCellInfoStored) |
|
1112 aCellInfo = iCellInfo; |
|
1113 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetCellInfo() End\n"); |
|
1114 return iCellInfoStored; |
|
1115 } |
|
1116 |
|
1117 /** Returns privacy advice that was received in a SUPL INIT |
|
1118 "notification" field |
|
1119 */ |
|
1120 void CSuplFsmEventStore::GetPrivacyAdvice(TLbsNetPosRequestPrivacy& aPrivacy) |
|
1121 { |
|
1122 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetPrivacyAdvice() Begin\n"); |
|
1123 aPrivacy = iPrivacyInfo; |
|
1124 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetPrivacyAdvice() End\n"); |
|
1125 } |
|
1126 |
|
1127 /** Returns requestor info that was received in a SUPL INIT |
|
1128 "notification" field |
|
1129 */ |
|
1130 void CSuplFsmEventStore::GetRequestorInfo(TLbsExternalRequestInfo& aRequestor) |
|
1131 { |
|
1132 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetRequestorInfo() Begin\n"); |
|
1133 aRequestor = iRequestorInfo; |
|
1134 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetRequestorInfo() End\n"); |
|
1135 } |
|
1136 |
|
1137 /** Returns tentative positioning methods that were received in a SUPL INIT |
|
1138 */ |
|
1139 void CSuplFsmEventStore::GetInitPosMethod(TLbsNetPosRequestMethod& aPosMethod) |
|
1140 { |
|
1141 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetInitPosMethod() Begin\n"); |
|
1142 aPosMethod = iInitPosMethod; |
|
1143 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetInitPosMethod() End\n"); |
|
1144 } |
|
1145 |
|
1146 /** Returns quality of position that was received in a SUPL INIT |
|
1147 */ |
|
1148 void CSuplFsmEventStore::GetInitQuality(TLbsNetPosRequestQuality& aQuality) |
|
1149 { |
|
1150 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetInitQuality() Begin\n"); |
|
1151 aQuality = iInitQuality; |
|
1152 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetInitQuality() End\n"); |
|
1153 } |
|
1154 |
|
1155 /** Returns the stored HMAC of the received SUPL INIT |
|
1156 */ |
|
1157 void CSuplFsmEventStore::GetVer(TDes8& aVer) |
|
1158 { |
|
1159 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetVer() Begin\n"); |
|
1160 aVer.Copy(iVer); |
|
1161 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetVer() End\n"); |
|
1162 } |
|
1163 |
|
1164 TBool CSuplFsmEventStore::GetPrivacyResp(CLbsNetworkProtocolBase::TLbsPrivacyResponse& aResponse) |
|
1165 { |
|
1166 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetPrivacyResp() Begin\n"); |
|
1167 TBool ret = ETrue; |
|
1168 |
|
1169 if (iPrivacyRespStored) |
|
1170 { |
|
1171 aResponse = iPrivacyResp; |
|
1172 } |
|
1173 else |
|
1174 { |
|
1175 ret = EFalse; |
|
1176 } |
|
1177 |
|
1178 SUPLLOG(ELogP1, "CSuplFsmEventStore::GetPrivacyResp() End\n"); |
|
1179 return ret; |
|
1180 } |
|
1181 |
|
1182 /** Returns pointer to the stored position information |
|
1183 */ |
|
1184 TPositionInfoBase* CSuplFsmEventStore::PositionL() |
|
1185 { |
|
1186 SUPLLOG(ELogP1, "CSuplFsmEventStore::PositionL() Begin\n"); |
|
1187 SUPLLOG(ELogP1, "CSuplFsmEventStore::PositionL() End\n"); |
|
1188 return iPosition; |
|
1189 } |
|
1190 |
|
1191 /** Store an assistance data request mask |
|
1192 */ |
|
1193 void CSuplFsmEventStore::StoreEvent(const TLbsAssistanceDataGroup& aAssistDataMask) |
|
1194 { |
|
1195 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() Begin\n"); |
|
1196 iAssistanceDataStored = ETrue; |
|
1197 iAssistanceDataMask = aAssistDataMask; |
|
1198 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() End\n"); |
|
1199 } |
|
1200 |
|
1201 /** Store a SUPL Message |
|
1202 */ |
|
1203 TInt CSuplFsmEventStore::StoreEvent(const CSuplMessageBase* aSuplMessage) |
|
1204 { |
|
1205 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() Begin\n"); |
|
1206 //TInt err = KErrOverflow; |
|
1207 TInt err = iMessageQueue.Insert(aSuplMessage,0); |
|
1208 |
|
1209 //if (iMaxEntries > iMessageQueue.Count()) |
|
1210 // { |
|
1211 // TRAP(err, iMessageQueue.InsertL(aSuplMessage,0)); |
|
1212 // } |
|
1213 |
|
1214 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() End\n"); |
|
1215 return err; |
|
1216 } |
|
1217 |
|
1218 /** Store a positioning protocol payload |
|
1219 */ |
|
1220 TInt CSuplFsmEventStore::StoreEvent(const CSuplPosPayload* aPosPayload) |
|
1221 { |
|
1222 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() Begin\n"); |
|
1223 //TInt err = KErrOverflow; |
|
1224 TInt err = iPayloadQueue.Insert(aPosPayload,0); |
|
1225 //if (iMaxEntries > iPayloadQueue.Count()) |
|
1226 // { |
|
1227 // TRAP(err, iPayloadQueue.InsertL(aPosPayload,0)); |
|
1228 // } |
|
1229 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() End\n"); |
|
1230 return err; |
|
1231 } |
|
1232 |
|
1233 /** Store options of a location request received from LBS |
|
1234 */ |
|
1235 TInt CSuplFsmEventStore::StoreEvent(const TLbsNetPosRequestOptionsBase& aOptions) |
|
1236 { |
|
1237 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() Begin\n"); |
|
1238 |
|
1239 if (iLocationRequestStored) |
|
1240 { |
|
1241 delete iLocRequestOptions; |
|
1242 iLocationRequestStored = EFalse; |
|
1243 } |
|
1244 |
|
1245 switch (aOptions.ClassType()) |
|
1246 { |
|
1247 case ELbsNetPosRequestOptionsClass: //Expected from LBS in Cell Based MO-LRs |
|
1248 { |
|
1249 TLbsNetPosRequestOptions* optionsPtr = new TLbsNetPosRequestOptions(); |
|
1250 if (optionsPtr) |
|
1251 { |
|
1252 *optionsPtr = static_cast<const TLbsNetPosRequestOptions&>(aOptions); |
|
1253 iLocRequestOptions = optionsPtr; |
|
1254 iLocationRequestStored = ETrue; |
|
1255 } |
|
1256 } |
|
1257 break; |
|
1258 |
|
1259 case ELbsNetPosRequestOptionsAssistanceClass: //Expected from LBS in AGPS MO-LRs |
|
1260 { |
|
1261 TLbsNetPosRequestOptionsAssistance* optionsAssistPtr = new TLbsNetPosRequestOptionsAssistance(); |
|
1262 if (optionsAssistPtr) |
|
1263 { |
|
1264 *optionsAssistPtr = static_cast<const TLbsNetPosRequestOptionsAssistance&>(aOptions); |
|
1265 iLocRequestOptions = optionsAssistPtr; |
|
1266 iLocationRequestStored = ETrue; |
|
1267 } |
|
1268 } |
|
1269 break; |
|
1270 |
|
1271 default://Intentionally empty |
|
1272 break; |
|
1273 } |
|
1274 |
|
1275 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() End\n"); |
|
1276 if (iLocationRequestStored) |
|
1277 return KErrNone; |
|
1278 else |
|
1279 return KErrNoMemory; |
|
1280 } |
|
1281 |
|
1282 /** Store source and reason for cancelling the procedure |
|
1283 */ |
|
1284 void CSuplFsmEventStore::StoreEvent(const CSuplFsmSessionBase::TCancelSource& aSource, const CSuplFsmSessionBase::TCancelReason& aReason) |
|
1285 { |
|
1286 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() Begin\n"); |
|
1287 iCancelSource = aSource; |
|
1288 iCancelReason = aReason; |
|
1289 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() End\n"); |
|
1290 } |
|
1291 |
|
1292 |
|
1293 /** Store local IP address assigned to the connection |
|
1294 for this session. Needed for sending in the SetSessionID |
|
1295 */ |
|
1296 void CSuplFsmEventStore::StoreEvent(const TInetAddr& aAddress) |
|
1297 { |
|
1298 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() Begin\n"); |
|
1299 iAddress = aAddress; |
|
1300 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() End\n"); |
|
1301 } |
|
1302 |
|
1303 |
|
1304 /** Store a position provided by LBS |
|
1305 */ |
|
1306 void CSuplFsmEventStore::StoreEventL(const TPositionInfoBase& aPosInfo) |
|
1307 { |
|
1308 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEventL() Begin\n"); |
|
1309 // Delete old position if present |
|
1310 iPositionStored = EFalse; |
|
1311 if (iPosition) |
|
1312 { |
|
1313 delete iPosition; |
|
1314 iPosition = NULL; |
|
1315 } |
|
1316 if (aPosInfo.PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass|EPositionExtendedSatelliteInfoClass)) |
|
1317 { |
|
1318 TPositionExtendedSatelliteInfo* posPtr = new(ELeave)TPositionExtendedSatelliteInfo(); |
|
1319 if (posPtr) |
|
1320 { |
|
1321 *posPtr = static_cast<const TPositionExtendedSatelliteInfo&>(aPosInfo); |
|
1322 iPosition = posPtr; |
|
1323 iPositionStored = ETrue; |
|
1324 } |
|
1325 } |
|
1326 else if (aPosInfo.PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass|EPositionSatelliteInfoClass)) |
|
1327 { |
|
1328 TPositionSatelliteInfo* posPtr = new(ELeave)TPositionSatelliteInfo(); |
|
1329 if (posPtr) |
|
1330 { |
|
1331 *posPtr = static_cast<const TPositionSatelliteInfo&>(aPosInfo); |
|
1332 iPosition = posPtr; |
|
1333 iPositionStored = ETrue; |
|
1334 } |
|
1335 } |
|
1336 else if (aPosInfo.PositionClassType() == (EPositionInfoClass|EPositionCourseInfoClass)) |
|
1337 { |
|
1338 TPositionCourseInfo* posPtr = new(ELeave)TPositionCourseInfo(); |
|
1339 if (posPtr) |
|
1340 { |
|
1341 *posPtr = static_cast<const TPositionCourseInfo&>(aPosInfo); |
|
1342 iPosition = posPtr; |
|
1343 iPositionStored = ETrue; |
|
1344 } |
|
1345 } |
|
1346 else if (aPosInfo.PositionClassType() == (EPositionInfoClass)) |
|
1347 { |
|
1348 TPositionInfo* posPtr = new(ELeave)TPositionInfo(); |
|
1349 if (posPtr) |
|
1350 { |
|
1351 *posPtr = static_cast<const TPositionInfo&>(aPosInfo); |
|
1352 iPosition = posPtr; |
|
1353 iPositionStored = ETrue; |
|
1354 } |
|
1355 } |
|
1356 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEventL() End\n"); |
|
1357 } |
|
1358 |
|
1359 /** Store the fact that a SUPL END has ended the session unexpectedly |
|
1360 */ |
|
1361 void CSuplFsmEventStore::SetUnexpectedSuplEnd() |
|
1362 { |
|
1363 SUPLLOG(ELogP1, "CSuplFsmEventStore::SetUnexpectedSuplEnd() Begin\n"); |
|
1364 iUnexpectedSuplEndReceived = ETrue; |
|
1365 SUPLLOG(ELogP1, "CSuplFsmEventStore::SetUnexpectedSuplEnd() End\n"); |
|
1366 } |
|
1367 |
|
1368 /** Check if a SUPL END has ended the session unexpectedly |
|
1369 */ |
|
1370 TBool CSuplFsmEventStore::UnexpectedSuplEndStored() |
|
1371 { |
|
1372 SUPLLOG(ELogP1, "CSuplFsmEventStore::UnexpectedSuplEndStored() Begin\n"); |
|
1373 SUPLLOG(ELogP1, "CSuplFsmEventStore::UnexpectedSuplEndStored() End\n"); |
|
1374 return iUnexpectedSuplEndReceived; |
|
1375 } |
|
1376 |
|
1377 /** Store the fact that a positioning session occurred |
|
1378 */ |
|
1379 void CSuplFsmEventStore::SetPosSessionConducted() |
|
1380 { |
|
1381 SUPLLOG(ELogP1, "CSuplFsmEventStore::SetPosSessionConducted() Begin\n"); |
|
1382 iPosSessionConducted = ETrue; |
|
1383 SUPLLOG(ELogP1, "CSuplFsmEventStore::SetPosSessionConducted() End\n"); |
|
1384 } |
|
1385 |
|
1386 /** Check if a SUPL END has ended the session unexpectedly |
|
1387 */ |
|
1388 TBool CSuplFsmEventStore::PosSessionConducted() |
|
1389 { |
|
1390 SUPLLOG(ELogP1, "CSuplFsmEventStore::PosSessionConducted() Begin\n"); |
|
1391 SUPLLOG(ELogP1, "CSuplFsmEventStore::PosSessionConducted() End\n"); |
|
1392 return iPosSessionConducted; |
|
1393 } |
|
1394 |
|
1395 |
|
1396 void CSuplFsmEventStore::StoreEvent(const RMobilePhone::TMobilePhoneNetworkInfoV1& aNetworkInfo, |
|
1397 const RMobilePhone::TMobilePhoneLocationAreaV1& aLocationArea) |
|
1398 { |
|
1399 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() Begin\n"); |
|
1400 iNetworkDataStored = ETrue; |
|
1401 iNetworkInfo = aNetworkInfo; |
|
1402 iLocationArea = aLocationArea; |
|
1403 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() End\n"); |
|
1404 } |
|
1405 |
|
1406 void CSuplFsmEventStore::StoreEvent(const RMobilePhone::TMobilePhoneSubscriberId& aImsi) |
|
1407 { |
|
1408 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() Begin\n"); |
|
1409 iImsiStored = ETrue; |
|
1410 iImsi = aImsi; |
|
1411 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() End\n"); |
|
1412 } |
|
1413 |
|
1414 void CSuplFsmEventStore::StoreEvent(const RMobilePhone::TMobilePhoneCellInfoV9& aCellInfo) |
|
1415 { |
|
1416 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() Begin\n"); |
|
1417 iCellInfoStored = ETrue; |
|
1418 iCellInfo = aCellInfo; |
|
1419 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() End\n"); |
|
1420 } |
|
1421 |
|
1422 void CSuplFsmEventStore::StoreEvent(const CLbsNetworkProtocolBase::TLbsPrivacyResponse& aResponse) |
|
1423 { |
|
1424 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() Begin\n"); |
|
1425 iPrivacyRespStored = ETrue; |
|
1426 iPrivacyResp = aResponse; |
|
1427 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreEvent() End\n"); |
|
1428 } |
|
1429 |
|
1430 |
|
1431 void CSuplFsmEventStore::StoreExternalLocationRequest(const TLbsNetPosRequestPrivacy& aPrivacy, |
|
1432 const TLbsExternalRequestInfo& aRequestor, |
|
1433 const TLbsNetPosRequestQuality& aQuality, |
|
1434 const TLbsNetPosRequestMethod& aPosMethod, |
|
1435 const TDesC8& aVer) |
|
1436 { |
|
1437 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreExternalLocationRequest() Begin\n"); |
|
1438 iPrivacyInfo = aPrivacy; |
|
1439 iRequestorInfo = aRequestor; |
|
1440 iInitQuality = aQuality; |
|
1441 iInitPosMethod = aPosMethod; |
|
1442 iVer.Copy(aVer); |
|
1443 SUPLLOG(ELogP1, "CSuplFsmEventStore::StoreExternalLocationRequest() End\n"); |
|
1444 } |
|
1445 |
|
1446 void CSuplFsmEventStore::SetPositioningEnded(const TBool& aPositioningEnded) |
|
1447 { |
|
1448 SUPLLOG(ELogP1, "CSuplFsmEventStore::SetPositioningEnded() Begin\n"); |
|
1449 iPositioningEnded = aPositioningEnded; |
|
1450 SUPLLOG(ELogP1, "CSuplFsmEventStore::SetPositioningEnded() End\n"); |
|
1451 } |
|
1452 |
|
1453 TBool CSuplFsmEventStore::PositioningEnded() |
|
1454 { |
|
1455 SUPLLOG(ELogP1, "CSuplFsmEventStore::PositioningEnded() Begin\n"); |
|
1456 SUPLLOG(ELogP1, "CSuplFsmEventStore::PositioningEnded() End\n"); |
|
1457 return iPositioningEnded; |
|
1458 } |
|
1459 |
|
1460 // ---------------- METHODS THAT ARE COMMON TO THE CONCRETE STATE MACHINES --------------------------- |
|
1461 |
|
1462 /** Start SUPL POS timer |
|
1463 The state handler calls this method when it sends a SUPL POS INIT. |
|
1464 A SUPL POS is expected before the timer expires. |
|
1465 */ |
|
1466 void CSuplFsmSessionBase::StartSuplPosTimer() |
|
1467 { |
|
1468 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StartSuplPosTimer() Begin\n"); |
|
1469 iSuplProtTimer->EventAfter(TTimeIntervalSeconds(KSuplPosTimerDurationInSecTimerDurationInSec), KSuplPosTimerEvent); |
|
1470 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StartSuplPosTimer() End\n"); |
|
1471 } |
|
1472 |
|
1473 /** Start SUPL END timer |
|
1474 The state handler calls this when it has sent the last SUPL POS. |
|
1475 A SUPL END is expected before the timer expires. |
|
1476 */ |
|
1477 void CSuplFsmSessionBase::StartSuplEndTimer() |
|
1478 { |
|
1479 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StartSuplEndTimer() Begin\n"); |
|
1480 iSuplProtTimer->EventAfter(TTimeIntervalSeconds(KSuplEndTimerDurationInSecTimerDurationInSec), KSuplEndTimerEvent); |
|
1481 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StartSuplEndTimer() End\n"); |
|
1482 } |
|
1483 |
|
1484 /** Start the connection timer |
|
1485 The state handler calls this when it has sent a connection request |
|
1486 to the Connection Manager and requires a result before the timer expires. |
|
1487 */ |
|
1488 void CSuplFsmSessionBase::StartConnectionTimer() |
|
1489 { |
|
1490 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StartConnectionTimer() Begin\n"); |
|
1491 iSuplProtTimer->EventAfter(TTimeIntervalSeconds(KSessionConnectedTimerDurationInSec), KSessionConnectedTimerEvent); |
|
1492 SUPLLOG(ELogP1, "CSuplFsmSessionBase::StartConnectionTimer() End\n"); |
|
1493 } |
|
1494 |
|
1495 void CSuplFsmSessionBase::SetSessionInProgress(TBool aSessionInProgress) |
|
1496 { |
|
1497 SUPLLOG(ELogP1, "CSuplFsmSessionBase::SetSessionInProgress() Begin\n"); |
|
1498 iSessionInProgress = aSessionInProgress; |
|
1499 SUPLLOG(ELogP1, "CSuplFsmSessionBase::SetSessionInProgress() End\n"); |
|
1500 } |
|
1501 |
|
1502 /** Timer callback error handler. |
|
1503 This is called if the timer expiry callback leaves. |
|
1504 @param aTimerId The timer event identifier. |
|
1505 @param aError Error value. |
|
1506 */ |
|
1507 TInt CSuplFsmSessionBase::OnTimerError(TInt /*aTimerId*/, TInt aError) |
|
1508 { |
|
1509 SUPLLOG(ELogP1, "CSuplFsmSessionBase::OnTimerEventL() Begin\n"); |
|
1510 SUPLLOG(ELogP1, "CSuplFsmSessionBase::OnTimerEventL() End\n"); |
|
1511 return aError; |
|
1512 } |
|
1513 |
|
1514 /** Retrieve current MO-Lr state |
|
1515 @return TMoLrState Current MO-LR state |
|
1516 */ |
|
1517 CSuplFsmSessionBase::TSuplProcedureState CSuplFsmSessionBase::CurrentState() |
|
1518 { |
|
1519 SUPLLOG(ELogP1, "CSuplFsmSessionBase::CurrentState() Begin\n"); |
|
1520 SUPLLOG(ELogP1, "CSuplFsmSessionBase::CurrentState() End\n"); |
|
1521 return iCurrentState; |
|
1522 } |
|
1523 |
|
1524 |
|
1525 //----------------------------- EVENTS FROM CONNECTION MANAGER (Network) ------------------------ |
|
1526 |
|
1527 /** Handle a SUPL message fromt the Connection Manager |
|
1528 @param aSuplMessage SUPL message received from network (ownership transferred to this state machine) |
|
1529 */ |
|
1530 void CSuplFsmSessionBase::MessageReceived(CSuplMessageBase* aSuplMessage) |
|
1531 { |
|
1532 SUPLLOG(ELogP1, "CSuplFsmSessionBase::MessageReceived() Begin\n"); |
|
1533 |
|
1534 iSuplProtTimer->Cancel(); |
|
1535 |
|
1536 StoreSuplMessage(aSuplMessage); |
|
1537 // A new SUPL message always prompts a transition if one is not |
|
1538 // already underway. |
|
1539 PerformTransition(); |
|
1540 SUPLLOG(ELogP1, "CSuplFsmSessionBase::MessageReceived() End\n"); |
|
1541 } |
|
1542 |
|
1543 /** Handle a connection notification from the Connection Manager |
|
1544 */ |
|
1545 void CSuplFsmSessionBase::Connected(const TInetAddr& aIpAddress) |
|
1546 { |
|
1547 SUPLLOG(ELogP1, "CSuplFsmSessionBase::Connected() Begin\n"); |
|
1548 // Kill the timer related to connection creation |
|
1549 iSuplProtTimer->Cancel(); |
|
1550 SetSessionConnected(ETrue); |
|
1551 |
|
1552 // Keep the IP address (may be used later in |
|
1553 // SET session ID of SUPL messages) |
|
1554 iEventStore->StoreEvent(aIpAddress); |
|
1555 |
|
1556 // This event only needs handling while in state EStateNetConnectionStarted |
|
1557 if (iCurrentState == EStateNetConnectionStarted) |
|
1558 { |
|
1559 PerformTransition(); |
|
1560 } |
|
1561 SUPLLOG(ELogP1, "CSuplFsmSessionBase::Connected() End\n"); |
|
1562 } |
|
1563 |
|
1564 /** Handle a connection error notification from the Connection Manager |
|
1565 |
|
1566 The errors notified by the connection manager are: connection unavailable, |
|
1567 insufficient security or error asn1 (encoding/decoding). The first two |
|
1568 imply that the connection is down. |
|
1569 |
|
1570 MSuplConnectionManagerObserver::TSuplConnectionError |
|
1571 */ |
|
1572 void CSuplFsmSessionBase::ConnectionError(const TSuplConnectionError& aError) |
|
1573 { |
|
1574 SUPLLOG(ELogP1, "CSuplFsmSessionBase::ConnectionError() Begin\n"); |
|
1575 TBool suplEndReceived = EFalse; |
|
1576 if (aError != MSuplConnectionManagerObserver::EDecodeMessageFailed) |
|
1577 SetSessionConnected(EFalse); |
|
1578 |
|
1579 // If this ConnectionError has happened after a SUPL END, it must |
|
1580 // be due to a normal disconnection initiated by the SUPL server and |
|
1581 // it can be safely ignored, which allows the handling of a position |
|
1582 // that may be present in the SUPL END. |
|
1583 const CSuplMessageBase* msg = NULL; |
|
1584 TBool messageAvailable = iEventStore->IsSuplMessageStored(msg); |
|
1585 if (messageAvailable) |
|
1586 { |
|
1587 CSuplMessageBase* message = const_cast<CSuplMessageBase*> (msg); |
|
1588 if (CSuplMessageBase::ESuplEnd == message->MessageType()) |
|
1589 { |
|
1590 suplEndReceived = ETrue; |
|
1591 } |
|
1592 } |
|
1593 |
|
1594 if (!suplEndReceived) |
|
1595 { |
|
1596 if (aError == MSuplConnectionManagerObserver::EDecodeMessageFailed) |
|
1597 { |
|
1598 CancelMachine(ECancelNetwork, EReasonParsingError); |
|
1599 } |
|
1600 else |
|
1601 { |
|
1602 CancelMachine(ECancelNetwork, EReasonDisconnected); |
|
1603 } |
|
1604 } |
|
1605 |
|
1606 SUPLLOG(ELogP1, "CSuplFsmSessionBase::ConnectionError() End\n"); |
|
1607 } |
|
1608 |
|
1609 //----------------------------- EVENTS FROM POSITIONING STATE MACHINE (RRLP) ------------------------ |
|
1610 |
|
1611 void CSuplFsmSessionBase::PositioningSessionEnded() |
|
1612 { |
|
1613 SUPLLOG(ELogP1, "CSuplFsmSessionBase::PositioningSessionEnded() Begin\n"); |
|
1614 iEventStore->SetPositioningEnded(ETrue); |
|
1615 SUPLLOG(ELogP1, "CSuplFsmSessionBase::PositioningSessionEnded() End\n"); |
|
1616 } |
|
1617 |
|
1618 //--------------------------------------------------------------------------------------------------------------------- |
|
1619 // -------------------------------- STATE CHANGE METHODS --------------------------------------------- |
|
1620 //--------------------------------------------------------------------------------------------------------------------- |
|
1621 |
|
1622 /** Decide next state from EStatePosInitSent |
|
1623 @return TBool ETrue if the state has changed |
|
1624 */ |
|
1625 TBool CSuplFsmSessionBase::DetermineStateFromPosInitSent() |
|
1626 { |
|
1627 SUPLLOG(ELogP1, "CSuplFsmSessionBase::DetermineStateFromPosInitSent() Begin\n"); |
|
1628 TBool stateChanged = ETrue; |
|
1629 |
|
1630 //Determine what SUPL Message was received. |
|
1631 // |
|
1632 const CSuplMessageBase* msg = NULL; |
|
1633 TBool messageAvailable = iEventStore->IsSuplMessageStored(msg); |
|
1634 |
|
1635 if (messageAvailable) |
|
1636 { |
|
1637 // Received message was stored as constant (read-only) but |
|
1638 // access to non-constant methods is needed |
|
1639 CSuplMessageBase* message = const_cast<CSuplMessageBase*> (msg); |
|
1640 if (CSuplMessageBase::ESuplEnd == message->MessageType()) |
|
1641 { |
|
1642 iSessionInProgress = EFalse; |
|
1643 CSuplEnd* suplEnd = static_cast <CSuplEnd*> (message); |
|
1644 |
|
1645 if (suplEnd->PositionPresent()) |
|
1646 { |
|
1647 iCurrentState = EStatePositionReceived; |
|
1648 SUPLLOG(ELogP1, "CSuplFsmSessionBase::DetermineStateFromPosInitSent() Next State: EStatePositionReceived\n"); |
|
1649 } |
|
1650 else |
|
1651 { |
|
1652 // Unexpected session termination. |
|
1653 // Remember this fact before switching state. |
|
1654 iEventStore->SetUnexpectedSuplEnd(); |
|
1655 iCurrentState = EStateLbsSessionEnded; |
|
1656 SUPLLOG(ELogP1, "CSuplFsmSessionBase::DetermineStateFromPosInitSent() Next State: EStateLbsSessionEnded\n"); |
|
1657 SetMachineAsNotCancellable(); |
|
1658 } |
|
1659 SetSessionInProgress(EFalse); |
|
1660 } |
|
1661 else if (CSuplMessageBase::ESuplPos == message->MessageType()) |
|
1662 { |
|
1663 iCurrentState = EStatePositioningInProgress; |
|
1664 SUPLLOG(ELogP1, "CSuplFsmSessionBase::DetermineStateFromPosInitSent() Next State: EStatePositioningInProgress\n"); |
|
1665 } |
|
1666 else |
|
1667 { |
|
1668 // Unexpected SUPL Message was received |
|
1669 // |
|
1670 CancelMachine(ECancelSuplProt,EReasonUnexpectedMessage); |
|
1671 } |
|
1672 } |
|
1673 else |
|
1674 { |
|
1675 stateChanged = EFalse; |
|
1676 } |
|
1677 SUPLLOG(ELogP1, "CSuplFsmSessionBase::DetermineStateFromPosInitSent() End\n"); |
|
1678 return stateChanged; |
|
1679 } |
|
1680 |
|
1681 /** Decide next state from EStatePositioningInProgress |
|
1682 @return TBool ETrue if the state has changed |
|
1683 @param aForceRedo, indicates that the states entry action must be re-performed when there has been no change in state |
|
1684 */ |
|
1685 TBool CSuplFsmSessionBase::DetermineStateFromPositioningInProgress(TBool& aForceRedo) |
|
1686 { |
|
1687 SUPLLOG(ELogP1, "CSuplFsmSessionBase::DetermineStateFromPositioningInProgress() Begin\n"); |
|
1688 TBool stateChanged = ETrue; |
|
1689 aForceRedo = ETrue; |
|
1690 |
|
1691 //Determine what SUPL Message was received. |
|
1692 // |
|
1693 const CSuplMessageBase* msg = NULL; |
|
1694 |
|
1695 TBool messageAvailable = iEventStore->IsSuplMessageStored(msg); |
|
1696 |
|
1697 if (messageAvailable) |
|
1698 { |
|
1699 CSuplMessageBase* message = const_cast <CSuplMessageBase*> (msg); |
|
1700 if (CSuplMessageBase::ESuplEnd == message->MessageType()) |
|
1701 { |
|
1702 iSessionInProgress = EFalse; |
|
1703 CSuplEnd *suplEnd = static_cast <CSuplEnd*> (message); |
|
1704 |
|
1705 if (suplEnd->PositionPresent()) |
|
1706 { |
|
1707 iCurrentState = EStatePositionReceived; |
|
1708 |
|
1709 // Remember that the position was received |
|
1710 // after a positioning session (Terminal Assisted). |
|
1711 iEventStore->SetPosSessionConducted(); |
|
1712 |
|
1713 SUPLLOG(ELogP1, "CSuplFsmSessionBase::DetermineStateFromPositioningInProgress() Next State: EStatePositionReceived\n"); |
|
1714 } |
|
1715 else |
|
1716 { |
|
1717 // A SUPL END is expected in this state |
|
1718 // but if the SUPL END contains a reason |
|
1719 // code, that is indicative of an error. |
|
1720 if(suplEnd->StatusCodePresent()) |
|
1721 { |
|
1722 iEventStore->SetUnexpectedSuplEnd(); |
|
1723 } |
|
1724 iCurrentState = EStatePosSessionEnded; |
|
1725 SUPLLOG(ELogP1, "CSuplFsmSessionBase::DetermineStateFromPositioningInProgress() Next State: EStatePosSessionEnded\n"); |
|
1726 SetMachineAsNotCancellable(); |
|
1727 } |
|
1728 SetSessionInProgress(EFalse); |
|
1729 } |
|
1730 else if (CSuplMessageBase::ESuplPos != message->MessageType()) |
|
1731 { |
|
1732 // Unexpected SUPL Message was received |
|
1733 // |
|
1734 CancelMachine(ECancelSuplProt,EReasonUnexpectedMessage); |
|
1735 } |
|
1736 } |
|
1737 else |
|
1738 { |
|
1739 stateChanged = EFalse; |
|
1740 } |
|
1741 SUPLLOG(ELogP1, "CSuplFsmSessionBase::DetermineStateFromPositioningInProgress() End\n"); |
|
1742 return stateChanged; |
|
1743 } |