|
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 that manages protocol aspects |
|
15 // of Test Protocol Module operation. |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent |
|
22 @test |
|
23 */ |
|
24 |
|
25 #ifndef __CPROTOCOLMANAGER_H__ |
|
26 #define __CPROTOCOLMANAGER_H__ |
|
27 |
|
28 #include <e32base.h> |
|
29 #include <lbs/lbsnetcommon.h> |
|
30 #include <lbs/lbsnetprotocolbase.h> |
|
31 #include "cconfigmanager.h" |
|
32 #include "cnetworkinterface.h" |
|
33 |
|
34 class CStateMachineBase; |
|
35 class CMoLrStateMachine; |
|
36 class CMtLrStateMachine; |
|
37 class CX3pStateMachine; |
|
38 class CNetLocStateMachine; |
|
39 class CAssistDataMgr; |
|
40 class MProtocolMgrObserver; |
|
41 |
|
42 /** State machine observer mixin definition. |
|
43 This defines an interface to be implemented by an observer of state machines. |
|
44 In this case it is only the Protocol Manager that implements this. |
|
45 */ |
|
46 class MStateMachineObserver |
|
47 { |
|
48 public: |
|
49 |
|
50 /** Gateway interface pointer. |
|
51 @return MProtocolMgrObserver* A pointer to the gateway interface |
|
52 */ |
|
53 virtual MProtocolMgrObserver* Gateway() = 0; |
|
54 |
|
55 /** Network interface pointer. |
|
56 @return CNetworkInterface* A pointer to the Network interface |
|
57 */ |
|
58 virtual CNetworkInterface* Network() = 0; |
|
59 |
|
60 /** Do outstanding actions relating to assistance data. |
|
61 */ |
|
62 virtual void DoAssistanceDataActions() = 0; |
|
63 |
|
64 /** State machine procedure complete notification. |
|
65 */ |
|
66 virtual void ProcedureCompleteInd() = 0; |
|
67 |
|
68 /** State machine measurement control timeout notification. |
|
69 */ |
|
70 virtual void MeasurementControlTimeout() = 0; |
|
71 |
|
72 /** State machine reports network error. |
|
73 */ |
|
74 virtual void NetworkErrorReported() = 0; |
|
75 |
|
76 /** State machine requests a new session. |
|
77 A new ID is assigned when this new session is created. This is called |
|
78 when the protocol module needs to initiate a new session. |
|
79 @return const TLbsNetSessionId& The new session ID. |
|
80 */ |
|
81 virtual const TLbsNetSessionId& NewSessionId() = 0; |
|
82 |
|
83 }; |
|
84 |
|
85 |
|
86 /** Protocol Manager class. |
|
87 This class manages protocol aspects of the protocol module operation. |
|
88 It employs various state machines to oversee individual protocol |
|
89 procedures and transfers requests, responses and indications to these |
|
90 state machines. |
|
91 @see CMoLrStateMachine |
|
92 @see CMtLrStateMachine |
|
93 @see CX3pStateMachine |
|
94 @see CNetLocStateMachine |
|
95 |
|
96 The protocol manager implements the MStateMachineObserver interface to |
|
97 receive messages from state machines. |
|
98 @see MStateMachineObserver |
|
99 |
|
100 The protocol manager is created by the Gateway Interface and uses the |
|
101 MProtocolMgrObserver interface to communicate with it. |
|
102 @see MProtocolMgrObserver |
|
103 |
|
104 The protocol manager implements the MNetworkObserver interface to receive |
|
105 requests and responses from the Network Interface. |
|
106 @see MNetworkObserver |
|
107 |
|
108 The class also owns a CAssistDataMgr assistance data manager object. |
|
109 This is used to oversee all assistance data requests and responses. |
|
110 @see CAssistDataMgr |
|
111 */ |
|
112 NONSHARABLE_CLASS(CProtocolManager) |
|
113 : public CBase, public MStateMachineObserver, public MNetworkObserver |
|
114 { |
|
115 public: |
|
116 |
|
117 static CProtocolManager* NewL(MProtocolMgrObserver& aGateway); |
|
118 ~CProtocolManager(); |
|
119 |
|
120 CConfigManager::TConflictResult ResolveConflict( |
|
121 CConfigManager::TConflictOp aNewOp, |
|
122 CConfigManager::TConflictPriority aNewPriority = CConfigManager::EPriorityNone); |
|
123 |
|
124 void AssistanceDataReq(TLbsAsistanceDataGroup aDataRequestMask); |
|
125 void LocationResp(const TLbsNetSessionId& aSessionId, TInt aReason, const TPositionInfoBase& aPosInfo); |
|
126 void PrivacyResp(const TLbsNetSessionId& aSessionId, const CLbsNetworkProtocolBase::TLbsPrivacyResponse& aResponse); |
|
127 void NetworkBasedLocationReq(const TLbsNetSessionId& aSessionId, const TLbsNetPosRequestOptionsBase& aOptions); |
|
128 void NetworkBasedLocationCompleteInd(const TLbsNetSessionId& aSessionId, TInt aReason); |
|
129 void SelfLocationReq(const TLbsNetSessionId& aSessionId, const TLbsNetPosRequestOptionsBase& aOptions); |
|
130 void SelfLocationCompleteInd(const TLbsNetSessionId& aSessionId, TInt aReason); |
|
131 void TransmitLocationReq(const TLbsNetSessionId& aSessionId, const TDesC& aDest, TInt aPriority); |
|
132 void TransmitLocationCompleteInd(const TLbsNetSessionId& aSessionId, TInt aReason); |
|
133 void SystemStatusInd(CLbsNetworkProtocolBase::TLbsSystemStatus aStatus); |
|
134 |
|
135 |
|
136 // MStateMachineObserver derived methods |
|
137 |
|
138 MProtocolMgrObserver* Gateway(); |
|
139 CNetworkInterface* Network(); |
|
140 void DoAssistanceDataActions(); |
|
141 void ProcedureCompleteInd(); |
|
142 void MeasurementControlTimeout(); |
|
143 void NetworkErrorReported(); |
|
144 |
|
145 const TLbsNetSessionId& NewSessionId(); |
|
146 |
|
147 // MNetworkObserver derived methods |
|
148 |
|
149 void MeasurementControlInd(const TPositionInfoBase& aPosInfo, |
|
150 const RLbsAssistanceDataBuilderSet& aData, const TLbsNetPosRequestQuality& aQuality, |
|
151 const TLbsNetPosRequestMethod& aPosMethod); |
|
152 void MeasurementControlErrorInd(TInt aReason); |
|
153 void MtLrReq(const TLbsExternalRequestInfo& aReqInfo, |
|
154 const TLbsNetPosRequestPrivacy& aPrivacy); |
|
155 void MtLrCancelInd(TInt aReason); |
|
156 void NetworkResultInd(TInt aResult, const TPositionInfoBase* aPosInfo); |
|
157 void NetworkErrorInd(TInt aReason); |
|
158 void GetCapabilities(TLbsNetPosCapabilities& aCapabilities); |
|
159 void ResetAssistanceData(TLbsAssistanceDataGroup aMask); |
|
160 |
|
161 private: |
|
162 |
|
163 CProtocolManager(MProtocolMgrObserver& aGateway); |
|
164 void ConstructL(); |
|
165 |
|
166 void GetActiveStateMachine(CStateMachineBase*& aActiveMachine) const; |
|
167 void GetCancellingStateMachine(CStateMachineBase*& aCancellingMachine) const; |
|
168 void GetQueuedStateMachine(CStateMachineBase*& aQueuedMachine) const; |
|
169 |
|
170 void StatusUpdate(CConfigManager::TConflictOp aNewOp, |
|
171 TBool aIsOperationStarting); |
|
172 |
|
173 private: |
|
174 |
|
175 /** Gateway interface reference. |
|
176 */ |
|
177 MProtocolMgrObserver& iGateway; |
|
178 |
|
179 /** Configuration manager object pointer. |
|
180 This object is created and owned by this class |
|
181 */ |
|
182 CConfigManager* iConfig; |
|
183 |
|
184 |
|
185 /** Current active operation. |
|
186 */ |
|
187 CConfigManager::TConflictOperation iCurrentOp; |
|
188 |
|
189 /** Network interface object pointer. |
|
190 This object is created and owned by this class |
|
191 */ |
|
192 CNetworkInterface* iNetwork; |
|
193 |
|
194 /** MO-LR state machine object pointer. |
|
195 This object is created and owned by this class |
|
196 */ |
|
197 CMoLrStateMachine* iMoLr; |
|
198 |
|
199 /** MT-LR state machine object pointer. |
|
200 This object is created and owned by this class |
|
201 */ |
|
202 CMtLrStateMachine* iMtLr; |
|
203 |
|
204 /** X3P state machine object pointer. |
|
205 This object is created and owned by this class |
|
206 */ |
|
207 CX3pStateMachine* iX3p; |
|
208 |
|
209 /** Network Based Location state machine object pointer. |
|
210 This object is created and owned by this class |
|
211 */ |
|
212 CNetLocStateMachine* iNetLoc; |
|
213 |
|
214 /** Assistance data manager. |
|
215 This object is created and owned by this class |
|
216 */ |
|
217 CAssistDataMgr* iAssistMgr; |
|
218 |
|
219 /** Internal session ID |
|
220 This uniquely identifies the latest client session which has been |
|
221 initiated by the protocol module. |
|
222 */ |
|
223 TLbsNetSessionId iInternalSessionId; |
|
224 |
|
225 /** System Status session ID |
|
226 This holds the latest status information reported by LBS and is |
|
227 used when performing conflict decisions. |
|
228 */ |
|
229 CLbsNetworkProtocolBase::TLbsSystemStatus iLbsStatus; |
|
230 |
|
231 /** Service status |
|
232 This holds the latest service status information known by the module. |
|
233 */ |
|
234 MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask iActiveServiceMask; |
|
235 }; |
|
236 |
|
237 |
|
238 /** Protocol Manager observer mixin definition. |
|
239 This interface is implemented to handle calls from the protocol manager |
|
240 and this is currently only implemented by the Gateway Interface. |
|
241 */ |
|
242 class MProtocolMgrObserver |
|
243 { |
|
244 public: |
|
245 |
|
246 /** Send privacy request to the gateway observer. |
|
247 @param aSessionId Unique session ID for this request |
|
248 @param aEmergency Indicates an emergency request when ETrue |
|
249 @param aPrivacy Privacy request information |
|
250 @param aRequestInfo External requestor information |
|
251 */ |
|
252 virtual void PrivacyReq(const TLbsNetSessionId& aSessionId, TBool aEmergency, |
|
253 const TLbsNetPosRequestPrivacy& aPrivacy, |
|
254 const TLbsExternalRequestInfo& aRequestInfo) = 0; |
|
255 |
|
256 /** Send network-based location to the gateway observer. |
|
257 @param aSessionId Unique session ID |
|
258 @param aReferenceLocation The reference location position |
|
259 */ |
|
260 virtual void NetworkLocationInd(const TLbsNetSessionId& aSessionId, |
|
261 const TPositionInfoBase& aPosInfo) = 0; |
|
262 |
|
263 /** Send assistance data to the network observer. |
|
264 @param aGroupMask This identifies the data group relevant for this indication. |
|
265 @param aData Assistance data set |
|
266 @param aReason An error value for the assistance data |
|
267 */ |
|
268 virtual void AssistanceDataInd(const TLbsAsistanceDataGroup& aGroupMask, |
|
269 const RLbsAssistanceDataBuilderSet& aData, TInt aReason) = 0; |
|
270 |
|
271 /** Send location request to the gateway observer. |
|
272 @param aSessionId Unique session ID for this request |
|
273 @param aEmergency Indicates an emergency request when ETrue |
|
274 @param aType Identifies the type of request originator |
|
275 @param aQuality The required location quality value. |
|
276 @param aMethod The method to employ to obtain location |
|
277 */ |
|
278 virtual void LocationReq(const TLbsNetSessionId& aSessionId, TBool aEmergency, |
|
279 const MLbsNetworkProtocolObserver::TLbsNetProtocolService& aType, |
|
280 const TLbsNetPosRequestQuality& aQuality, |
|
281 const TLbsNetPosRequestMethod& aPosMethod) = 0; |
|
282 |
|
283 /** Send session complete indication to the gateway observer. |
|
284 @param aSessionId Unique session ID |
|
285 @param aReason An error or reason value for the session closing |
|
286 */ |
|
287 virtual void SessionCompleteInd(const TLbsNetSessionId& aSessionId, TInt aReason) = 0; |
|
288 |
|
289 /** Request to get LBS capabilities from the gateway observer. |
|
290 @param aCapabilities Object to hold capabilities returned by LBS |
|
291 */ |
|
292 virtual void GetCapabilities(TLbsNetPosCapabilities& aCapabilities) = 0; |
|
293 |
|
294 /** Send Status Update to the gateway observer. |
|
295 @param aActiveServiceMask The active services are represented by this mask. |
|
296 */ |
|
297 virtual void StatusUpdate(MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask aActiveServiceMask) = 0; |
|
298 |
|
299 /** Send a request to reset assistance data |
|
300 @param aMask The mask representing what assistance data to reset |
|
301 */ |
|
302 virtual void ResetAssistanceData(TLbsAssistanceDataGroup aMask, const RLbsAssistanceDataBuilderSet& aData) = 0; |
|
303 |
|
304 }; |
|
305 |
|
306 #endif // __CPROTOCOLMANAGER_H__ |