|
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 provides the implementation of the class for |
|
15 // the MO-LR protocol state handler |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalTechnology |
|
22 @released |
|
23 */ |
|
24 |
|
25 #include "cmolrstatemachine.h" |
|
26 #include "cmolrstatehandler.h" |
|
27 |
|
28 |
|
29 /** Static constructor. |
|
30 @param aMachine A reference to the parent state machine. |
|
31 @return A new instance of the CMoLrStateHandler class |
|
32 */ |
|
33 CMoLrStateHandler* CMoLrStateHandler::NewL(CStateMachineBase& aMachine) |
|
34 { |
|
35 CMoLrStateHandler* self = new (ELeave) CMoLrStateHandler(aMachine); |
|
36 CleanupStack::PushL(self); |
|
37 self->ConstructL(); |
|
38 CleanupStack::Pop(self); |
|
39 return self; |
|
40 } |
|
41 |
|
42 |
|
43 /** Standard constructor. |
|
44 @param aMachine A reference to the parent state machine. |
|
45 */ |
|
46 CMoLrStateHandler::CMoLrStateHandler(CStateMachineBase& aMachine) |
|
47 : CStateHandlerBase(aMachine) |
|
48 { |
|
49 } |
|
50 |
|
51 |
|
52 /** Standard destructor. |
|
53 */ |
|
54 CMoLrStateHandler::~CMoLrStateHandler() |
|
55 { |
|
56 } |
|
57 |
|
58 |
|
59 /** Private second-stage constructor. |
|
60 */ |
|
61 void CMoLrStateHandler::ConstructL() |
|
62 { |
|
63 } |
|
64 |
|
65 |
|
66 /** Initialise state attributes |
|
67 */ |
|
68 void CMoLrStateHandler::Initialise() |
|
69 { |
|
70 } |
|
71 |
|
72 |
|
73 /** Perform entry actions. |
|
74 This is called from the state machine to perform any actions |
|
75 associated with entering the current state. |
|
76 */ |
|
77 void CMoLrStateHandler::EntryActions() |
|
78 { |
|
79 CNetworkInterface::TNetworkError netError = CNetworkInterface::ENone; |
|
80 |
|
81 // Retrieve current state and act accordingly |
|
82 CMoLrStateMachine& molrMachine = reinterpret_cast <CMoLrStateMachine&> (iMachine); |
|
83 switch(molrMachine.CurrentState()) |
|
84 { |
|
85 |
|
86 case CMoLrStateMachine::EStateNull: |
|
87 break; |
|
88 |
|
89 case CMoLrStateMachine::EStateClientReqRecvd: |
|
90 // No action required |
|
91 break; |
|
92 |
|
93 case CMoLrStateMachine::EStateNetSessStarted: |
|
94 // Forward MO-LR request to network |
|
95 netError = molrMachine.Observer().Network()->MoLrReq(KNullDesC()); |
|
96 // If this succeeded then start a timer for the anticipated response |
|
97 if (CNetworkInterface::ENone == netError) |
|
98 { |
|
99 molrMachine.StartMoLrReqTimer(); |
|
100 } |
|
101 break; |
|
102 |
|
103 case CMoLrStateMachine::EStateMeasureDataRecvd: |
|
104 // No action required |
|
105 break; |
|
106 |
|
107 case CMoLrStateMachine::EStateNetBasedLocSent: |
|
108 // Send network location to gateway |
|
109 molrMachine.Observer().Gateway()->NetworkLocationInd( |
|
110 molrMachine.SessionId(), |
|
111 molrMachine.ReferenceLoc()); |
|
112 break; |
|
113 |
|
114 case CMoLrStateMachine::EStateLocReqByNet: |
|
115 // Send location request to gateway |
|
116 molrMachine.Observer().Gateway()->LocationReq( |
|
117 molrMachine.SessionId(), |
|
118 EFalse, // this is NOT emergency related |
|
119 molrMachine.LocReqType(), |
|
120 molrMachine.LocReqQuality(), |
|
121 molrMachine.PosMethod()); |
|
122 // Start a timer for the anticipated response |
|
123 molrMachine.StartLocRespTimer(); |
|
124 break; |
|
125 |
|
126 case CMoLrStateMachine::EStateLocRespRecvd: |
|
127 // No action required |
|
128 break; |
|
129 |
|
130 case CMoLrStateMachine::EStateLocSentToNet: |
|
131 // Forward location response to network - but not if an error was reported |
|
132 if (KErrNone == molrMachine.LocRespReason()) |
|
133 { |
|
134 netError = molrMachine.Observer().Network()->LocationResp(molrMachine.LocRespPosition()); |
|
135 // If this succeeded then start a timer for the anticipated network result |
|
136 if (CNetworkInterface::ENone == netError) |
|
137 { |
|
138 molrMachine.StartFacResultTimer(); |
|
139 } |
|
140 } |
|
141 break; |
|
142 |
|
143 case CMoLrStateMachine::EStateNetSessToClose: |
|
144 // If we had received a location request, but an error was reported then |
|
145 // forward this location error to the network |
|
146 if (molrMachine.IsLocReqReceived() && (KErrNone != molrMachine.LocRespReason())) |
|
147 { |
|
148 netError = molrMachine.Observer().Network()->LocationResp(molrMachine.LocRespReason()); |
|
149 } |
|
150 break; |
|
151 |
|
152 case CMoLrStateMachine::EStateNetResultSent: |
|
153 // Send network result location to gateway |
|
154 molrMachine.Observer().Gateway()->NetworkLocationInd( |
|
155 molrMachine.SessionId(), |
|
156 molrMachine.NetResultLoc()); |
|
157 break; |
|
158 |
|
159 case CMoLrStateMachine::EStateClientSessToClose: |
|
160 // No action required |
|
161 break; |
|
162 |
|
163 case CMoLrStateMachine::EStateSessionsClosed: |
|
164 // No action required |
|
165 break; |
|
166 |
|
167 case CMoLrStateMachine::EStateCancelling: |
|
168 // No action required |
|
169 break; |
|
170 |
|
171 default: |
|
172 User::Panic(KProtocolModulePanic, EProtocolModuleMoLrState); |
|
173 break; |
|
174 } |
|
175 |
|
176 // Handle any network-related error |
|
177 if (CNetworkInterface::ENone != netError) |
|
178 { |
|
179 molrMachine.Observer().NetworkErrorReported(); |
|
180 } |
|
181 |
|
182 } |
|
183 |
|
184 |
|
185 /** Perform exit actions. |
|
186 This is called from the state machine to perform any actions |
|
187 associated with exiting from the current state. |
|
188 */ |
|
189 void CMoLrStateHandler::ExitActions() |
|
190 { |
|
191 CNetworkInterface::TNetworkError netError = CNetworkInterface::ENone; |
|
192 |
|
193 // Retrieve current state and act accordingly |
|
194 CMoLrStateMachine& molrMachine = reinterpret_cast <CMoLrStateMachine&> (iMachine); |
|
195 switch(molrMachine.CurrentState()) |
|
196 { |
|
197 |
|
198 case CMoLrStateMachine::EStateNull: |
|
199 // no action required |
|
200 break; |
|
201 |
|
202 case CMoLrStateMachine::EStateClientReqRecvd: |
|
203 // no action required |
|
204 break; |
|
205 |
|
206 case CMoLrStateMachine::EStateNetSessStarted: |
|
207 // no action required |
|
208 break; |
|
209 |
|
210 case CMoLrStateMachine::EStateMeasureDataRecvd: |
|
211 // no action required |
|
212 break; |
|
213 |
|
214 case CMoLrStateMachine::EStateNetBasedLocSent: |
|
215 // no action required |
|
216 break; |
|
217 |
|
218 case CMoLrStateMachine::EStateLocReqByNet: |
|
219 // no action required |
|
220 break; |
|
221 |
|
222 case CMoLrStateMachine::EStateLocRespRecvd: |
|
223 // no action required |
|
224 break; |
|
225 |
|
226 case CMoLrStateMachine::EStateLocSentToNet: |
|
227 // no action required |
|
228 break; |
|
229 |
|
230 case CMoLrStateMachine::EStateNetSessToClose: |
|
231 // Forward session completion to network if network is okay |
|
232 if (!molrMachine.IsNetworkConnectionError()) |
|
233 { |
|
234 netError = molrMachine.Observer().Network()->MoLrCompleteInd(molrMachine.NetworkCloseReason()); |
|
235 } |
|
236 break; |
|
237 |
|
238 case CMoLrStateMachine::EStateNetResultSent: |
|
239 // no action required |
|
240 break; |
|
241 |
|
242 case CMoLrStateMachine::EStateClientSessToClose: |
|
243 molrMachine.Observer().Gateway()->SessionCompleteInd( |
|
244 molrMachine.SessionId(),molrMachine.ClientCloseReason()); |
|
245 break; |
|
246 |
|
247 case CMoLrStateMachine::EStateSessionsClosed: |
|
248 // no action required |
|
249 break; |
|
250 |
|
251 case CMoLrStateMachine::EStateCancelling: |
|
252 // no action required |
|
253 break; |
|
254 |
|
255 default: |
|
256 User::Panic(KProtocolModulePanic, EProtocolModuleMoLrState); |
|
257 break; |
|
258 } |
|
259 |
|
260 // Handle any network-related error |
|
261 if (CNetworkInterface::ENone != netError) |
|
262 { |
|
263 molrMachine.Observer().NetworkErrorReported(); |
|
264 } |
|
265 |
|
266 } |
|
267 |
|
268 |