|
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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @InternalComponent |
|
19 @released |
|
20 */ |
|
21 |
|
22 #ifndef NGMESSAGESWITCH_H |
|
23 #define NGMESSAGESWITCH_H |
|
24 |
|
25 #include <lbs/lbsprivacycontroller.h> |
|
26 #include <lbs/lbsextendedsatellite.h> |
|
27 #include "lbscommoninternaldatatypes.h" |
|
28 #include "privacyhandlerobserver.h" |
|
29 #include "privacyhandler.h" |
|
30 #include "lbsnetinternalapi.h" |
|
31 #include "lbsnrhngmsgs.h" |
|
32 |
|
33 |
|
34 |
|
35 class CNGMessageSendBufferBase; |
|
36 |
|
37 /** |
|
38 * |
|
39 * Class which defines the observer interface for CNGMessageSwitch. |
|
40 * Objects which want to be informed of incoming messages should |
|
41 * inherit and implement this interface and register themselves by |
|
42 * calling CNGMessageSwitch::RegisterObserver(); |
|
43 * |
|
44 */ |
|
45 class MNGMessageSwitchObserver |
|
46 { |
|
47 public: |
|
48 /** Called when a privacy request arrives from the network. |
|
49 |
|
50 Note: a privacy request is often the start of an MT-LR, hence the function name. |
|
51 */ |
|
52 virtual void OnMTLRRequest(const TLbsNetSessionIdInt& aSessionId, |
|
53 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
54 TBool aIsEmergency, |
|
55 const TLbsExternalRequestInfo& aExternalRequestInfo, |
|
56 const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy) = 0; |
|
57 |
|
58 /** Called when a session complete arrives from the network. |
|
59 */ |
|
60 virtual void OnSessionComplete(const TLbsNetSessionIdInt& aSessionId, TInt aReason) = 0; |
|
61 |
|
62 /** Called when a location request arrives from the network. |
|
63 */ |
|
64 virtual void OnNetLocRequest(const TLbsNetSessionIdInt& aSessionId, |
|
65 const TLbsNetPosRequestMethodInt& aNetPosMethod, |
|
66 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
67 TBool aIsEmergency, |
|
68 const TLbsNetPosRequestQualityInt& aQuality) = 0; |
|
69 |
|
70 /** Called when a location response is sent to the network. |
|
71 |
|
72 This is only needed for the X3P handler, so that it knows what quality |
|
73 parameters were used when the location request was sent to the A-GPS manager. |
|
74 */ |
|
75 virtual void OnNetLocResponse(const TLbsNetSessionIdInt& aSessionId, |
|
76 const TLbsNetPosRequestQualityInt& aQuality) = 0; |
|
77 |
|
78 /** Called when a reference location arrives from the network. |
|
79 */ |
|
80 virtual void OnNetLocReferenceUpdate(const TLbsNetSessionIdInt& aSessionId, |
|
81 const TPositionInfoBase& aPosInfo) = 0; |
|
82 |
|
83 /** Called when a final location arrives from the network. |
|
84 */ |
|
85 virtual void OnNetLocFinalUpdate(const TLbsNetSessionIdInt& aSessionId, |
|
86 const TPositionInfoBase& aPosInfo) = 0; |
|
87 }; |
|
88 |
|
89 /** |
|
90 * |
|
91 * Class which implements the interface between the Network Gateway and the |
|
92 * Network Request Handler |
|
93 */ |
|
94 class CNGMessageSwitch : public CBase, |
|
95 public MLbsNetChannelObserver |
|
96 { |
|
97 public: |
|
98 static CNGMessageSwitch* NewL(CLbsAdmin& aAdmin); |
|
99 ~CNGMessageSwitch(); |
|
100 |
|
101 public: |
|
102 /* |
|
103 * Called by an observer to register itself with the |
|
104 * message switch. |
|
105 */ |
|
106 TInt RegisterObserver(MNGMessageSwitchObserver* aPrvLocObserver); |
|
107 |
|
108 /** |
|
109 * Called by the Privacy and Location Request Handler to send the |
|
110 * result of an MTLR to the Network |
|
111 */ |
|
112 void SendMTLRResponse(const TLbsNetSessionIdInt& aSessionId, |
|
113 TLbsNetworkEnumInt::TLbsPrivacyResponseInt aResult, |
|
114 TInt aReason, |
|
115 TBool aEmergency); |
|
116 /** |
|
117 * Called by the Privacy and Location Request Handler to send the |
|
118 * result of a location measurement request to the Network |
|
119 */ |
|
120 void SendNetLocResponse(const TLbsNetSessionIdInt& aSessionId, |
|
121 TInt aCompletionCode, |
|
122 const TLbsNetPosRequestQualityInt& aRequestQuality, |
|
123 const TPositionInfoBase& aPosInfo, |
|
124 const TTime& aTimeStamp, |
|
125 TBool aEmergency); |
|
126 /** |
|
127 * Called by the X3P Request Handler to send |
|
128 * an X3P request to the Message Gateway Protocol Handler |
|
129 */ |
|
130 void SendX3pRequest(const TLbsNetSessionIdInt& aSessionId, |
|
131 const TDesC& aDestId, |
|
132 TUint aTransmitPriority, |
|
133 const TLbsNetPosRequestOptionsTechnologyInt& aOptions); |
|
134 /** |
|
135 * Called by the X3P Request Handler to cancel |
|
136 * an X3P request to the Message Gateway Protocol Handler |
|
137 */ |
|
138 void SendX3pCancel(const TLbsNetSessionIdInt& aSessionId, |
|
139 TInt aReason); |
|
140 |
|
141 /** |
|
142 * Called by the Privacy and Location Request Handler to cancel |
|
143 * an External Location request |
|
144 */ |
|
145 void SendExternalLocateCancel(const TLbsNetSessionIdInt& aSessionId, |
|
146 TInt aReason); |
|
147 |
|
148 TInt GetNetworkReferencePosition(const TLbsNetSessionIdInt& aSessionId, |
|
149 TPositionInfoBase& aPosInfo); |
|
150 |
|
151 TInt GetNetworkFinalPosition(const TLbsNetSessionIdInt& aSessionId, |
|
152 TPositionInfoBase& aPosInfo); |
|
153 |
|
154 public: // From MLbsNetChannelObserver |
|
155 void ProcessNetChannelMessage(RLbsNetChannel::TLbsNetChannelId aChannelId, |
|
156 const TLbsNetInternalMsgBase& aMessage); |
|
157 |
|
158 |
|
159 protected: |
|
160 void ConstructL(); |
|
161 |
|
162 private: |
|
163 CNGMessageSwitch(CLbsAdmin& aLbsAdmin); |
|
164 |
|
165 private: |
|
166 |
|
167 class TNetPosItem |
|
168 { |
|
169 public: |
|
170 TLbsNetSessionIdInt iSessionId; |
|
171 TPositionInfo iPosInfo; |
|
172 |
|
173 }; |
|
174 |
|
175 class TNetFNPPosItem |
|
176 { |
|
177 public: |
|
178 TLbsNetSessionIdInt iSessionId; |
|
179 TPositionExtendedSatelliteInfo iPosInfo; |
|
180 |
|
181 }; |
|
182 |
|
183 static TBool IsSessionIdEqual(const TLbsNetSessionIdInt* aSessionId, |
|
184 const TNetPosItem& aItem); |
|
185 static TBool IsFNPSessionIdEqual(const TLbsNetSessionIdInt* aSessionId, |
|
186 const TNetFNPPosItem& aItem); |
|
187 |
|
188 void RemoveBufferedNetworkPositions(const TLbsNetSessionIdInt& aSessionId); |
|
189 |
|
190 private: |
|
191 RPointerArray<MNGMessageSwitchObserver> iObservers; |
|
192 RLbsNetChannel iNetworkGateway; |
|
193 CNGMessageSendBufferBase* iNetworkGatewaySendBuffer; |
|
194 CLbsAdmin& iAdmin; |
|
195 |
|
196 RArray<TNetPosItem> iRefPosBuffer; |
|
197 RPointerArray<TNetFNPPosItem> iFNPPosBuffer; |
|
198 |
|
199 }; |
|
200 |
|
201 /** Abstract base class for buffer for sending messages to the Network Gateway. |
|
202 */ |
|
203 class CNGMessageSendBufferBase : public CActive |
|
204 { |
|
205 public: |
|
206 ~CNGMessageSendBufferBase(); |
|
207 |
|
208 virtual void SendNetLocResponseToNetwork( |
|
209 const TLbsNetSessionIdInt& aSessionId, |
|
210 TInt aCompletionCode, |
|
211 const TPositionInfoBase& aPosInfo, |
|
212 const TTime& aTimeStamp, |
|
213 TBool aEmergency) = 0; |
|
214 |
|
215 virtual void SendMtlrResponseToNetwork( |
|
216 const TLbsNetSessionIdInt& aSessionId, |
|
217 TLbsNetworkEnumInt::TLbsPrivacyResponseInt aResult, |
|
218 TInt aReason, |
|
219 TBool aEmergency) = 0; |
|
220 |
|
221 virtual void SendX3pRequestToNetwork( |
|
222 const TLbsNetSessionIdInt& aSessionId, |
|
223 const TDesC& aDestId, |
|
224 TUint aTransmitPriority, |
|
225 const TLbsNetPosRequestOptionsTechnologyInt& aOptions) = 0; |
|
226 |
|
227 virtual void SendX3pCancelToNetwork( |
|
228 const TLbsNetSessionIdInt& aSessionId, |
|
229 TInt aReason) = 0; |
|
230 |
|
231 virtual void SendExternalLocateCancelToNetwork( |
|
232 const TLbsNetSessionIdInt& aSessionId, |
|
233 TInt aReason) = 0; |
|
234 |
|
235 protected: |
|
236 CNGMessageSendBufferBase(RLbsNetChannel& aGatewayChannel, CLbsAdmin& aAdmin); |
|
237 |
|
238 void RunL(); |
|
239 void DoCancel(); |
|
240 |
|
241 void SendMessageToNetwork(const TLbsNetInternalMsgBase& aMessage); |
|
242 |
|
243 virtual void BufferData(TLbsNetInternalMsgBase* aData) = 0; |
|
244 |
|
245 protected: |
|
246 CLbsAdmin& iAdmin; |
|
247 |
|
248 private: |
|
249 RLbsNetChannel& iNetGatewayChannel; |
|
250 }; |
|
251 |
|
252 |
|
253 |
|
254 /** The NRH uses this buffer used to send messages to network gateway. |
|
255 |
|
256 This buffer has a special, non-dynamic allocation that guarantees that the messages |
|
257 can be sent. This avoiding Emergencies failing due to |
|
258 OOM situations. For non-emergencies messages the |
|
259 memory is allocated off the heap to buffer messages. |
|
260 When this fails due to OOM then the result is that the messages are not sent. |
|
261 */ |
|
262 class CNGMessageSendBuffer : public CNGMessageSendBufferBase |
|
263 { |
|
264 public: |
|
265 static CNGMessageSendBuffer* NewL(RLbsNetChannel& aGatewayChannel, CLbsAdmin& aAdmin); |
|
266 ~CNGMessageSendBuffer(); |
|
267 |
|
268 void SendNetLocResponseToNetwork(const TLbsNetSessionIdInt& aSessionId, |
|
269 TInt aCompletionCode, |
|
270 const TPositionInfoBase& aPosInfo, |
|
271 const TTime& aTimeStamp, |
|
272 TBool aEmergency); |
|
273 void SendMtlrResponseToNetwork(const TLbsNetSessionIdInt& aSessionId, |
|
274 TLbsNetworkEnumInt::TLbsPrivacyResponseInt aResult, |
|
275 TInt aReason, |
|
276 TBool aEmergency); |
|
277 void SendX3pRequestToNetwork(const TLbsNetSessionIdInt& aSessionId, |
|
278 const TDesC& aDestId, |
|
279 TUint aTransmitPriority, |
|
280 const TLbsNetPosRequestOptionsTechnologyInt& aOptions); |
|
281 void SendX3pCancelToNetwork(const TLbsNetSessionIdInt& aSessionId, |
|
282 TInt aReason); |
|
283 void SendExternalLocateCancelToNetwork(const TLbsNetSessionIdInt& aSessionId, |
|
284 TInt aReason); |
|
285 private: |
|
286 CNGMessageSendBuffer(RLbsNetChannel& aGatewayChannel, CLbsAdmin& aAdmin); |
|
287 |
|
288 void RunL(); |
|
289 TInt RunError(TInt aError); |
|
290 |
|
291 void BufferData(TLbsNetInternalMsgBase* aData); |
|
292 void BufferEmergencyData(TLbsNetInternalMsgBase* aData); // two spaces are pre-allocated in this array |
|
293 |
|
294 |
|
295 private: |
|
296 RPointerArray<TLbsNetInternalMsgBase> iBuffer; |
|
297 RPointerArray<TLbsNetInternalMsgBase> iEmergencyBuffer; |
|
298 |
|
299 TLbsNetMtLrReponseMsg iEmergencyPrivacyResponseData; |
|
300 TLbsNetLocationResponseMsg iEmergencyLocationResponseData; |
|
301 |
|
302 }; |
|
303 |
|
304 #endif // NGMESSAGESWITCH_H |
|
305 |