|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 /** |
|
18 @file |
|
19 @internalComponent |
|
20 @released |
|
21 */ |
|
22 #ifndef __PRIVACYHANDLER_H__ |
|
23 #define __PRIVACYHANDLER_H__ |
|
24 |
|
25 #include <lbs/lbsloccommon.h> // For TLbsExternalRequestInfo |
|
26 #include <lbs/lbsprivacycontroller.h> // For MLbsSessionObserver |
|
27 #include "privacyhandlerobserver.h" |
|
28 #include "lbsprivacynotifier.h" |
|
29 #include "lbstimer.h" |
|
30 #include "lbsprivacycontrollerdata.h" |
|
31 #include "lbsnetregstatusint.h" |
|
32 #include <lbs/lbsadmin.h> |
|
33 |
|
34 class CLbsPrivacyNotifier; |
|
35 class CPrivacyRequest; |
|
36 class CLbsAdmin; |
|
37 |
|
38 class MLbsSessionObserver |
|
39 { |
|
40 public: |
|
41 |
|
42 virtual void ProcessNetworkLocationRequest(TLbsNetSessionIdInt aRequestId, |
|
43 const TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
44 const TLbsExternalRequestInfo& aRequestInfo, |
|
45 const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy, |
|
46 TBool aIsEmergency) = 0; |
|
47 |
|
48 virtual void ProcessNetworkPositionUpdate(TLbsNetSessionIdInt aRequestId, |
|
49 const TPositionInfo& aPosInfo) = 0; |
|
50 virtual void ProcessRequestComplete(TLbsNetSessionIdInt aRequestId, |
|
51 TInt aReason) = 0; |
|
52 }; |
|
53 |
|
54 /** Abstract base class for all privacy request handlers. |
|
55 |
|
56 Each privacy request handler for a specific API/interface |
|
57 must derive from this class and implement the pure virtual |
|
58 functions. |
|
59 */ |
|
60 class CPrivacyHandler : public CActive, |
|
61 public MLbsSessionObserver, |
|
62 public MPrivacyHandlerObserver |
|
63 { |
|
64 protected: |
|
65 enum TRequiredPrivacyAction |
|
66 { |
|
67 ERequiredPrivacyActionNone, |
|
68 ERequiredPrivacyActionNotify, |
|
69 ERequiredPrivacyActionVerify |
|
70 }; |
|
71 |
|
72 public: |
|
73 static CPrivacyHandler* CreateL(MPrivacyHandlerObserver* aObserver, |
|
74 CLbsAdmin& aLbsAdmin, |
|
75 RLbsNetworkRegistrationStatus& aNetRegStatus); |
|
76 |
|
77 protected: |
|
78 CPrivacyHandler(CLbsAdmin& aLbsAdmin, |
|
79 RLbsNetworkRegistrationStatus& aNetRegStatus); |
|
80 |
|
81 protected: |
|
82 // From CActive |
|
83 virtual void RunL() = 0; |
|
84 virtual void DoCancel() = 0; |
|
85 |
|
86 virtual void GetPrivacyTimeoutAction( |
|
87 TLbsNetworkEnumInt::TLbsPrivacyResponseInt& aResponse, |
|
88 const TLbsNetPosRequestPrivacyInt& aRequestPrivacy); |
|
89 |
|
90 void GetExternalLocateAdminSetting(const TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
91 CLbsAdmin::TExternalLocateService& aExternalLocateService); |
|
92 |
|
93 |
|
94 protected: |
|
95 CLbsAdmin& iLbsAdmin; |
|
96 RLbsNetworkRegistrationStatus& iNetRegStatus; |
|
97 MPrivacyHandlerObserver* iObserver; |
|
98 |
|
99 private: |
|
100 virtual void RegisterObserver(MPrivacyHandlerObserver* aObserver) = 0; |
|
101 |
|
102 }; |
|
103 |
|
104 /////////////////////////////////////////////////////////////////////////////// |
|
105 // CPrivacyRequest |
|
106 /////////////////////////////////////////////////////////////////////////////// |
|
107 |
|
108 /* Class that holds the data for a single privacy request. |
|
109 */ |
|
110 class CPrivacyRequest : public CBase |
|
111 { |
|
112 public: |
|
113 /* Privacy request states. |
|
114 |
|
115 The state is needed to keep track of what has happened to this |
|
116 request so far. For example, it can be used to guard against |
|
117 multiple responses from the privacy controller application |
|
118 (or privacy notifier or Q&N Notifier). |
|
119 */ |
|
120 enum TPrivReqState |
|
121 { |
|
122 /* 'Undefined' state. */ |
|
123 EPrivReqStateUnknown = 0, |
|
124 /* Privacy request sent to user; waiting for response. */ |
|
125 EPrivReqStateWaitPrivacyResponse, |
|
126 /* Privacy response received and sent into NRH. */ |
|
127 EPrivReqStateResponseSent, |
|
128 /* Privacy request complete message received from NRH. */ |
|
129 EPrivReqStateCompleted |
|
130 }; |
|
131 |
|
132 public: |
|
133 static CPrivacyRequest* NewL(); |
|
134 ~CPrivacyRequest(); |
|
135 |
|
136 public: |
|
137 TPrivReqState State() const; |
|
138 void SetState(TPrivReqState aState); |
|
139 |
|
140 const TLbsNetSessionIdInt& SessionId() const; |
|
141 void SetSessionId(const TLbsNetSessionIdInt& aSessionId); |
|
142 |
|
143 const TLbsNetworkEnumInt::TLbsNetProtocolServiceInt& SessionType() const; |
|
144 void SetSessionType(const TLbsNetworkEnumInt::TLbsNetProtocolServiceInt& aSessionType); |
|
145 |
|
146 const TLbsExternalRequestInfo& RequestInfo() const; |
|
147 void SetRequestInfo(const TLbsExternalRequestInfo& aRequestInfo); |
|
148 |
|
149 const TLbsNetPosRequestPrivacyInt& RequestPrivacy() const; |
|
150 void SetRequestPrivacy(const TLbsNetPosRequestPrivacyInt& aRequestPrivacy); |
|
151 |
|
152 TBool IsEmergency() const; |
|
153 void SetIsEmergency(TBool aIsEmergency); |
|
154 |
|
155 TTime StartTime() const; |
|
156 void SetStartTime(); |
|
157 |
|
158 public: |
|
159 static TBool IsSessionIdEqual( |
|
160 const TLbsNetSessionIdInt* aSessionId, |
|
161 const CPrivacyRequest& aItem); |
|
162 |
|
163 protected: |
|
164 CPrivacyRequest(); |
|
165 CPrivacyRequest(const CPrivacyRequest&); |
|
166 |
|
167 void ConstructL(); |
|
168 |
|
169 private: |
|
170 TPrivReqState iState; |
|
171 TLbsNetSessionIdInt iSessionId; |
|
172 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt iSessionType; |
|
173 TBool iIsEmergency; |
|
174 TTime iStartTime; |
|
175 TLbsNetPosRequestPrivacyInt iRequestPrivacy; |
|
176 TLbsExternalRequestInfo2 iRequestInfo; |
|
177 }; |
|
178 |
|
179 /////////////////////////////////////////////////////////////////////////////// |
|
180 // CPrivacyNotifierHandler |
|
181 /////////////////////////////////////////////////////////////////////////////// |
|
182 class CPrivacyNotifierHandler : public CPrivacyHandler, |
|
183 public MLbsPrivacyNotifierObserver, |
|
184 public MLbsCallbackTimerObserver |
|
185 { |
|
186 |
|
187 public: |
|
188 static CPrivacyNotifierHandler* NewL(CLbsAdmin& aLbsAdmin, |
|
189 RLbsNetworkRegistrationStatus& aNetRegStatus); |
|
190 ~CPrivacyNotifierHandler(); |
|
191 |
|
192 public: // From MLbsSessionObserver |
|
193 |
|
194 void ProcessNetworkLocationRequest(TLbsNetSessionIdInt aRequestId, |
|
195 const TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
196 const TLbsExternalRequestInfo& aRequestInfo, |
|
197 const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy, |
|
198 TBool aIsEmergency); |
|
199 |
|
200 void ProcessNetworkPositionUpdate(TLbsNetSessionIdInt aRequestId, |
|
201 const TPositionInfo& aPosInfo); |
|
202 void ProcessRequestComplete(TLbsNetSessionIdInt aRequestId, |
|
203 TInt aReason); |
|
204 |
|
205 public: // From MLbsPrivacyNotifierObserver |
|
206 void OnNotificationDialogResponse(TInt aErr, |
|
207 const TLbsPrivacyNotifierResponse& aResponse); |
|
208 |
|
209 public: // From MLbsCallbackTimerObserver |
|
210 void OnTimerEventL(TInt aTimerId); |
|
211 TInt OnTimerError(TInt aTimerId, TInt aError); |
|
212 |
|
213 public: // From MPrivacyHandlerObserver |
|
214 void SetServerObserver(MLbsSessionObserver* aNrhPrivacyServer); |
|
215 void OnRespondNetworkLocationRequest(const TLbsNetSessionIdInt& aRequestId, |
|
216 TLbsNetworkEnumInt::TLbsPrivacyResponseInt aRequestResult, |
|
217 TInt aReason); |
|
218 void OnCancelNetworkLocationRequest(const TLbsNetSessionIdInt& aRequestId); |
|
219 |
|
220 protected: // From CActive |
|
221 void RunL(); |
|
222 void DoCancel(); |
|
223 |
|
224 protected: |
|
225 CPrivacyNotifierHandler(CLbsAdmin& aLbsAdmin, |
|
226 RLbsNetworkRegistrationStatus& aNetRegStatus); |
|
227 void RegisterObserver(MPrivacyHandlerObserver* aObserver); |
|
228 void ConstructL(); |
|
229 |
|
230 private: |
|
231 TBool IsPrivacyRequestActive(); |
|
232 void SendNextPrivacyRequest(); |
|
233 void SendPrivacyResponse(); |
|
234 void WaitForPrivacyResponse(); |
|
235 |
|
236 TInt BufferPrivacyRequest( |
|
237 const TLbsNetSessionIdInt& aSessionId, |
|
238 const TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
239 const TLbsExternalRequestInfo& aRequestInfo, |
|
240 const TLbsNetPosRequestPrivacyInt& aRequestPrivacy, |
|
241 TBool aIsEmergency); |
|
242 |
|
243 void RemovePrivacyRequestFromBuffer( |
|
244 const TLbsNetSessionIdInt& aSessionId); |
|
245 |
|
246 void GetRequiredNotificationAction( |
|
247 TBool aIsEmergency, |
|
248 CLbsAdmin::TExternalLocateService aExternalLocate, |
|
249 TRequiredPrivacyAction& aPrivacyAction, |
|
250 TBool& aTimeoutRequired, |
|
251 TLbsNetworkEnumInt::TLbsPrivacyResponseInt& aResponse, |
|
252 TLbsNetPosRequestPrivacyInt& aPrivacy); |
|
253 |
|
254 private: |
|
255 CLbsCallbackTimer* iPrivacyResponseTimer; |
|
256 TRequiredPrivacyAction iNotifierAction; |
|
257 CLbsPrivacyNotifier* iNotifier; |
|
258 RPointerArray<CPrivacyRequest> iRequestBuffer; |
|
259 TBool iPrivacyResponseOutstanding; |
|
260 }; |
|
261 |
|
262 /////////////////////////////////////////////////////////////////////////////// |
|
263 // CPrivacyControllerHandler |
|
264 /////////////////////////////////////////////////////////////////////////////// |
|
265 class CPrivacyControllerHandler : public CPrivacyHandler, |
|
266 public MLbsCallbackTimerObserver |
|
267 { |
|
268 public: |
|
269 static CPrivacyControllerHandler* NewL(CLbsAdmin& aLbsAdmin, |
|
270 RLbsNetworkRegistrationStatus& aNetRegStatus); |
|
271 ~CPrivacyControllerHandler(); |
|
272 |
|
273 public: // From MLbsSessionObserver |
|
274 |
|
275 void ProcessNetworkLocationRequest(TLbsNetSessionIdInt aRequestId, |
|
276 const TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
277 const TLbsExternalRequestInfo& aRequestInfo, |
|
278 const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy, |
|
279 TBool aIsEmergency); |
|
280 |
|
281 void ProcessNetworkPositionUpdate(TLbsNetSessionIdInt aRequestId, |
|
282 const TPositionInfo& aPosInfo); |
|
283 void ProcessRequestComplete(TLbsNetSessionIdInt aRequestId, |
|
284 TInt aReason); |
|
285 |
|
286 public: // From MPrivacyHandlerObserver |
|
287 void SetServerObserver(MLbsSessionObserver* aNrhPrivacyServer); |
|
288 void OnRespondNetworkLocationRequest(const TLbsNetSessionIdInt& aRequestId, |
|
289 TLbsNetworkEnumInt::TLbsPrivacyResponseInt aRequestResult, |
|
290 TInt aResponseReason); |
|
291 void OnCancelNetworkLocationRequest(const TLbsNetSessionIdInt& aRequestId); |
|
292 public: // From MLbsCallbackTimerObserver |
|
293 void OnTimerEventL(TInt aTimerId); |
|
294 TInt OnTimerError(TInt aTimerId, TInt aError); |
|
295 |
|
296 protected: |
|
297 CPrivacyControllerHandler(CLbsAdmin& aLbsAdmin, |
|
298 RLbsNetworkRegistrationStatus& aNetRegStatus); |
|
299 void ConstructL(); |
|
300 |
|
301 // From CActive |
|
302 void RunL(); |
|
303 void DoCancel(); |
|
304 |
|
305 void GetPrivacyTimeoutAction( |
|
306 TLbsNetworkEnumInt::TLbsPrivacyResponseInt& aResponse, |
|
307 const TLbsNetPosRequestPrivacyInt& aRequestPrivacy); |
|
308 |
|
309 protected: |
|
310 void RegisterObserver(MPrivacyHandlerObserver* aObserver); |
|
311 |
|
312 private: |
|
313 void StartResponseTimer(); |
|
314 void CancelResponseTimer(); |
|
315 |
|
316 private: |
|
317 static TBool IsSessionIdMatch(const CPrivacyRequest& aReq1, const CPrivacyRequest& aReq2); |
|
318 CPrivacyRequest* FindPrivacyRequest( |
|
319 const TLbsNetSessionIdInt& aSessionId, |
|
320 TBool aRemoveRequest); |
|
321 |
|
322 private: |
|
323 MLbsSessionObserver* iNrhServer; |
|
324 CLbsCallbackTimer* iPrivacyResponseTimer; |
|
325 RPointerArray<CPrivacyRequest> iRequestBuffer; |
|
326 CPrivacyRequest* iEmergencyPrivReq; |
|
327 TBool iSessionActive; |
|
328 TBool iRefPosReported; |
|
329 TBool iIsEmergency; |
|
330 CLbsAdmin::TLbsBehaviourMode iLbsBehaviourMode; |
|
331 TBool iAlwaysVerify; |
|
332 |
|
333 }; |
|
334 |
|
335 |
|
336 #endif // __PRIVACYHANDLER_H__ |