|
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 // This file defines the class for the Network Based Location |
|
15 // protocol state machine. |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent |
|
22 @test |
|
23 */ |
|
24 |
|
25 #ifndef __CNETLOCSTATEMACHINE_H__ |
|
26 #define __CNETLOCSTATEMACHINE_H__ |
|
27 |
|
28 #include "cstatemachinebase.h" |
|
29 |
|
30 |
|
31 /** Network Based Location protocol state machine. |
|
32 This class manages the Network Based Location protocol procedure and is employed |
|
33 when the protocol module is required to handle interactions for retrieving a |
|
34 reference location (e.g. cell-based) from the network. |
|
35 |
|
36 The class implements the pure virtual methods defined by CStateMachineBase. |
|
37 @see CStateMachineBase |
|
38 |
|
39 The class also implements a timer observer interface defined by MLbsCallbackTimerObserver |
|
40 @see MLbsCallbackTimerObserver |
|
41 */ |
|
42 NONSHARABLE_CLASS(CNetLocStateMachine) : public CStateMachineBase, public MLbsCallbackTimerObserver |
|
43 { |
|
44 public: |
|
45 |
|
46 /** Network Based Location specific states |
|
47 These are specific to Network Based Location and identify the current |
|
48 state within the Network Based Location protocol procedure. |
|
49 */ |
|
50 enum TNetLocState |
|
51 { |
|
52 /** Not valid */ |
|
53 EStateNull, |
|
54 /** LBS Cient Network Based Loc request has been received */ |
|
55 EStateClientReqRecvd, |
|
56 /** Network Network Based Loc session has started */ |
|
57 EStateNetSessStarted, |
|
58 /** Measurement control data received from the network */ |
|
59 EStateMeasureDataRecvd, |
|
60 /** Network reference location sent to LBS */ |
|
61 EStateNetBasedLocSent, |
|
62 /** Network location request sent to LBS */ |
|
63 EStateLocReqByNet, |
|
64 /** Location response received from LBS */ |
|
65 EStateLocRespRecvd, |
|
66 /** Location response sent to network */ |
|
67 EStateLocSentToNet, |
|
68 /** Network NETLOC session about to close */ |
|
69 EStateNetSessToClose, |
|
70 /** LBS client Network Based Loc session about to close */ |
|
71 EStateClientSessToClose, |
|
72 /** Network and LBS sessions closed */ |
|
73 EStateSessionsClosed, |
|
74 /** Protocol procedure is to be cancelled */ |
|
75 EStateCancelling |
|
76 }; |
|
77 |
|
78 /** Request identifiers used when a request is queued. |
|
79 */ |
|
80 enum TNetLocQueue |
|
81 { |
|
82 /** Location response received from LBS */ |
|
83 EQueueLocResponse = 1000, |
|
84 /** Measurement control received from network */ |
|
85 EQueueMeasurementControl = 2000, |
|
86 /** Network result received from network */ |
|
87 EQueueNetworkResult = 3000, |
|
88 }; |
|
89 |
|
90 public: |
|
91 |
|
92 static CNetLocStateMachine* NewL(MStateMachineObserver& aObserver); |
|
93 virtual ~CNetLocStateMachine(); |
|
94 |
|
95 CNetLocStateMachine::TNetLocState CurrentState(); |
|
96 |
|
97 void StartNetLocReqTimer(); |
|
98 void StartLocRespTimer(); |
|
99 |
|
100 void NetLocReq(const TLbsNetSessionId& aSessionId); |
|
101 void QueueNetLocReq(const TLbsNetSessionId& aSessionId); |
|
102 |
|
103 // CStateMachineBase derived methods |
|
104 |
|
105 void MeasurementControlInd(const TPositionInfoBase& aPosInfo, |
|
106 const TLbsNetPosRequestQuality& aQuality, |
|
107 const TLbsNetPosRequestMethod& aPosMethod); |
|
108 void MeasurementControlErrorInd(TInt aReason); |
|
109 void NetworkErrorInd(); |
|
110 |
|
111 // CStateMachineBase pure virtual methods |
|
112 void StartQueuedMachine(); |
|
113 void PreStateTransition(); |
|
114 void StateTransition(); |
|
115 void PostStateTransition(); |
|
116 void CancelProcedure(); |
|
117 void DoQueuedRequest(TInt aRequest); |
|
118 |
|
119 void LocationResp(TInt aReason, const TPositionInfoBase& aPosInfo); |
|
120 void MeasurementControlTimeout(); |
|
121 |
|
122 // MLbsCallbackTimerObserver methods |
|
123 |
|
124 void OnTimerEventL(TInt aTimerId); |
|
125 TInt OnTimerError(TInt aTimerId, TInt aError); |
|
126 |
|
127 protected: |
|
128 |
|
129 CNetLocStateMachine(MStateMachineObserver& aObserver); |
|
130 |
|
131 private: |
|
132 |
|
133 void ConstructL(); |
|
134 void InitialiseProcedure(); |
|
135 void CompleteProcedure(); |
|
136 |
|
137 protected: |
|
138 |
|
139 /** Current NETLOC state |
|
140 */ |
|
141 TNetLocState iCurrentState; |
|
142 |
|
143 /** Timer for NETLOC requests issued to network. |
|
144 */ |
|
145 CLbsCallbackTimer* iNetLocReqIssuedTimer; |
|
146 |
|
147 /** Timer for Location response expected by network |
|
148 */ |
|
149 CLbsCallbackTimer* iLocRespTimer; |
|
150 |
|
151 }; |
|
152 |
|
153 #endif // __CNETLOCSTATEMACHINE_H__ |
|
154 |