36
|
1 |
// Copyright (c) 2005-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 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
#include <lbs/epos_privacy.h>
|
|
20 |
#include "EPos_PrivacyInternal.h"
|
|
21 |
|
|
22 |
#include "EPos_CPosPrivManager.h"
|
|
23 |
#include "EPos_CPosDialogCtrl.h"
|
|
24 |
#include "EPos_PosCommonPrivacyResources.h"
|
|
25 |
#include "EPos_PrivacyServerDebugPanic.h"
|
|
26 |
|
|
27 |
// ================= MEMBER FUNCTIONS =======================
|
|
28 |
|
|
29 |
// Two-phased constructor.
|
|
30 |
CPosPrivManager* CPosPrivManager::NewL()
|
|
31 |
{
|
|
32 |
CPosPrivManager* self = new (ELeave) CPosPrivManager();
|
|
33 |
CleanupStack::PushL(self);
|
|
34 |
self->ConstructL();
|
|
35 |
CleanupStack::Pop(self);
|
|
36 |
return self;
|
|
37 |
}
|
|
38 |
|
|
39 |
// Destructor
|
|
40 |
CPosPrivManager::~CPosPrivManager()
|
|
41 |
{
|
|
42 |
Cancel();
|
|
43 |
if (iRequestInfo)
|
|
44 |
{
|
|
45 |
delete iRequestInfo;
|
|
46 |
}
|
|
47 |
}
|
|
48 |
|
|
49 |
// C++ default constructor can NOT contain any code, that
|
|
50 |
// might leave.
|
|
51 |
//
|
|
52 |
CPosPrivManager::CPosPrivManager()
|
|
53 |
: CActive(CActive::EPriorityStandard),
|
|
54 |
iDlgCtrl(PosCommonPrivacyResources::DialogCtrl())
|
|
55 |
{
|
|
56 |
CActiveScheduler::Add(this);
|
|
57 |
iActivity = EPosInactive;
|
|
58 |
}
|
|
59 |
|
|
60 |
// EPOC default constructor can leave.
|
|
61 |
void CPosPrivManager::ConstructL()
|
|
62 |
{
|
|
63 |
iRequestInfo = new (ELeave) TLbsExternalRequestInfo2;
|
|
64 |
}
|
|
65 |
|
|
66 |
// ---------------------------------------------------------
|
|
67 |
// CPosPrivManager::VerifyL
|
|
68 |
//
|
|
69 |
// (other items were commented in a header).
|
|
70 |
// ---------------------------------------------------------
|
|
71 |
//
|
|
72 |
void CPosPrivManager::VerifyL(
|
|
73 |
TRequestStatus& aRequestStatus,
|
|
74 |
const TLbsExternalRequestInfo& aRequestInfo,
|
|
75 |
const TPosRequestData& aRequestData,
|
|
76 |
TInt aRequestId)
|
|
77 |
{
|
|
78 |
if (iActivity != EPosInactive)
|
|
79 |
{
|
|
80 |
TRequestStatus* status = &aRequestStatus;
|
|
81 |
User::RequestComplete(status, KErrOverflow);
|
|
82 |
return;
|
|
83 |
}
|
|
84 |
|
|
85 |
Mem::Copy(iRequestInfo,
|
|
86 |
&aRequestInfo,
|
|
87 |
aRequestInfo.ClassSize());
|
|
88 |
iRequestStatus = &aRequestStatus;
|
|
89 |
*iRequestStatus = KRequestPending;
|
|
90 |
iRequestData = aRequestData;
|
|
91 |
iRequestId = aRequestId;
|
|
92 |
iActivity = EPosResolvingForVerification;
|
|
93 |
|
|
94 |
ResolveL();
|
|
95 |
}
|
|
96 |
|
|
97 |
// ---------------------------------------------------------
|
|
98 |
// CPosPrivManager::CancelVerify
|
|
99 |
//
|
|
100 |
// (other items were commented in a header).
|
|
101 |
// ---------------------------------------------------------
|
|
102 |
//
|
|
103 |
void CPosPrivManager::CancelVerify()
|
|
104 |
{
|
|
105 |
if (IsVerifying())
|
|
106 |
{
|
|
107 |
User::RequestComplete(iRequestStatus, KErrCancel);
|
|
108 |
Cancel();
|
|
109 |
iActivity = EPosInactive;
|
|
110 |
}
|
|
111 |
}
|
|
112 |
|
|
113 |
// ---------------------------------------------------------
|
|
114 |
// CPosPrivManager::CancelVerifyL
|
|
115 |
//
|
|
116 |
// (other items were commented in a header).
|
|
117 |
// ---------------------------------------------------------
|
|
118 |
//
|
|
119 |
void CPosPrivManager::CancelVerifyL(
|
|
120 |
TPosVerifyCancelReason aCancelReason)
|
|
121 |
{
|
|
122 |
if (!IsVerifying() && iActivity != EPosInactive)
|
|
123 |
{ // Notification is running. Cancel is then not allowed.
|
|
124 |
User::Leave(KErrOverflow);
|
|
125 |
}
|
|
126 |
|
|
127 |
switch (iActivity)
|
|
128 |
{
|
|
129 |
case EPosVerifying:
|
|
130 |
{
|
|
131 |
//Cancel could occur on four places during the state EPosVerifying.
|
|
132 |
//1. The request is queued in CPosDlgCtrl
|
|
133 |
//2. The request is cancelled when the dialog is shown.
|
|
134 |
//3. The user has dismissed the dialog but CPosDlgCtrl::RunL has not
|
|
135 |
// yet been run by the AS.
|
|
136 |
//4. The user has dismissed the dialog, CPosDlgCtrl::RunL has been
|
|
137 |
// run, however, CPosPrivManager::RunL has not. In this case, it
|
|
138 |
// is not necessary to cancel CPosDialogCtrl since it has already
|
|
139 |
// completed the request.
|
|
140 |
//
|
|
141 |
//Case 3 and 4 are treated the same way, i.e. the
|
|
142 |
//user will be notified.
|
|
143 |
//
|
|
144 |
if (iRequestData.iTimeoutStrategy != EPosDecisionNotAvailable)
|
|
145 |
{
|
|
146 |
if (iStatus == KRequestPending)
|
|
147 |
{
|
|
148 |
TInt err;
|
|
149 |
TBool requestQueued;
|
|
150 |
iDlgCtrl->CancelLaunch(iStatus, err, iUserResponse,
|
|
151 |
requestQueued, aCancelReason);
|
|
152 |
|
|
153 |
if (requestQueued)
|
|
154 |
{
|
|
155 |
iActivity = EPosCancelBeforeDialog; //Case 1
|
|
156 |
}
|
|
157 |
else if (err == KErrArgument ||
|
|
158 |
err == KErrNotReady &&
|
|
159 |
iUserResponse != KRequestPending || //S60
|
|
160 |
err == KErrNone &&
|
|
161 |
iUserResponse != KRequestPending) //S90
|
|
162 |
{
|
|
163 |
iActivity = EPosCancelAfterDialog2; //Case 3
|
|
164 |
}
|
|
165 |
else
|
|
166 |
{
|
|
167 |
iActivity = EPosCancelDuringDialog; //Case 2
|
|
168 |
}
|
|
169 |
}
|
|
170 |
else
|
|
171 |
{
|
|
172 |
iActivity = EPosCancelAfterDialog1; //Case 4.
|
|
173 |
}
|
|
174 |
}
|
|
175 |
else
|
|
176 |
{
|
|
177 |
CancelVerify();
|
|
178 |
}
|
|
179 |
break;
|
|
180 |
}
|
|
181 |
case EPosInactive:
|
|
182 |
{
|
|
183 |
//A cancel request is received after user response,
|
|
184 |
//but client has not yet received the request.
|
|
185 |
if (iRequestData.iTimeoutStrategy != EPosDecisionNotAvailable)
|
|
186 |
{
|
|
187 |
TInt result = iLastVerificationResult == KErrNone ?
|
|
188 |
KErrNone : KErrAccessDenied;
|
|
189 |
TInt reqDecision = iRequestData.iTimeoutStrategy ==
|
|
190 |
EPosDecisionRejected ? KErrAccessDenied : KErrNone;
|
|
191 |
if (result != reqDecision)
|
|
192 |
{
|
|
193 |
NotifyPluginL();
|
|
194 |
}
|
|
195 |
}
|
|
196 |
break;
|
|
197 |
}
|
|
198 |
default: break;
|
|
199 |
}
|
|
200 |
}
|
|
201 |
|
|
202 |
// ---------------------------------------------------------
|
|
203 |
// CPosPrivManager::NotifyL
|
|
204 |
//
|
|
205 |
// (other items were commented in a header).
|
|
206 |
// ---------------------------------------------------------
|
|
207 |
//
|
|
208 |
void CPosPrivManager::NotifyL(
|
|
209 |
TRequestStatus& aRequestStatus,
|
|
210 |
const TLbsExternalRequestInfo& aRequestInfo,
|
|
211 |
const TPosRequestData& aRequestData,
|
|
212 |
TInt aRequestId)
|
|
213 |
{
|
|
214 |
if (iActivity != EPosInactive)
|
|
215 |
{
|
|
216 |
TRequestStatus* status = &aRequestStatus;
|
|
217 |
User::RequestComplete(status, KErrOverflow);
|
|
218 |
return;
|
|
219 |
}
|
|
220 |
|
|
221 |
iRequestStatus = &aRequestStatus;
|
|
222 |
*iRequestStatus = KRequestPending;
|
|
223 |
|
|
224 |
iRequestData = aRequestData;
|
|
225 |
iRequestId = aRequestId;
|
|
226 |
|
|
227 |
TLbsExternalRequestInfo2* reqInfo = new (ELeave) TLbsExternalRequestInfo2;
|
|
228 |
Mem::Copy(reqInfo,
|
|
229 |
&aRequestInfo,
|
|
230 |
aRequestInfo.ClassSize());
|
|
231 |
delete iRequestInfo;
|
|
232 |
iRequestInfo = reqInfo;
|
|
233 |
|
|
234 |
iActivity = EPosResolvingForNotification;
|
|
235 |
ResolveL();
|
|
236 |
}
|
|
237 |
|
|
238 |
// ---------------------------------------------------------
|
|
239 |
// CPosPrivManager::RunL
|
|
240 |
//
|
|
241 |
// (other items were commented in a header).
|
|
242 |
// ---------------------------------------------------------
|
|
243 |
//
|
|
244 |
void CPosPrivManager::RunL()
|
|
245 |
{
|
|
246 |
if (iStatus.Int() == KErrNoMemory)
|
|
247 |
{
|
|
248 |
User::Leave(KErrNoMemory);
|
|
249 |
}
|
|
250 |
|
|
251 |
if (iActivity == EPosResolvingForVerification)
|
|
252 |
{
|
|
253 |
// Resolving is done. Start verification
|
|
254 |
iActivity = EPosVerifying;
|
|
255 |
|
|
256 |
// Launch the verification dialog
|
|
257 |
iDlgCtrl->VerifyL(iStatus, *iRequestInfo, iRequestData);
|
|
258 |
SetActive();
|
|
259 |
}
|
|
260 |
else if (iActivity == EPosResolvingForNotification)
|
|
261 |
{
|
|
262 |
if (iRequestData.iNotificationReason == EPosVerificationTimeout)
|
|
263 |
// Notify verification timeout
|
|
264 |
{
|
|
265 |
NotifyPluginL();
|
|
266 |
}
|
|
267 |
else // Notify (without previous verification)
|
|
268 |
{
|
|
269 |
iDlgCtrl->NotifyL(*iRequestInfo, iRequestData);
|
|
270 |
iRequestInfo = NULL;
|
|
271 |
iRequestInfo = new (ELeave) TLbsExternalRequestInfo2;
|
|
272 |
}
|
|
273 |
|
|
274 |
// Notify message not completed until now, in order to prevent
|
|
275 |
// parallell notifications
|
|
276 |
User::RequestComplete(iRequestStatus, KErrNone);
|
|
277 |
iActivity = EPosInactive;
|
|
278 |
}
|
|
279 |
else if (iActivity == EPosVerifying)
|
|
280 |
{
|
|
281 |
CompleteRequestL(iStatus.Int());
|
|
282 |
}
|
|
283 |
else
|
|
284 |
{
|
|
285 |
if (iActivity == EPosCancelBeforeDialog &&
|
|
286 |
iRequestData.iTimeoutStrategy == EPosDecisionAccepted)
|
|
287 |
{
|
|
288 |
iRequestData.iNotificationReason = EPosDecisionByRequestSource;
|
|
289 |
iDlgCtrl->NotifyL(*iRequestInfo, iRequestData);
|
|
290 |
iRequestInfo = NULL;
|
|
291 |
iRequestInfo = new (ELeave) TLbsExternalRequestInfo2;
|
|
292 |
}
|
|
293 |
else if (iActivity == EPosCancelAfterDialog1
|
|
294 |
|| iActivity == EPosCancelAfterDialog2)
|
|
295 |
{
|
|
296 |
TInt userResponse;
|
|
297 |
if (iActivity == EPosCancelAfterDialog1)
|
|
298 |
{
|
|
299 |
userResponse = iStatus.Int() == KErrNone ?
|
|
300 |
KErrNone : KErrAccessDenied;
|
|
301 |
}
|
|
302 |
else
|
|
303 |
{
|
|
304 |
userResponse = iUserResponse == KErrNone ?
|
|
305 |
KErrNone : KErrAccessDenied;
|
|
306 |
}
|
|
307 |
|
|
308 |
TInt timeoutStrategy = iRequestData.iTimeoutStrategy ==
|
|
309 |
EPosDecisionRejected ? KErrAccessDenied : KErrNone;
|
|
310 |
|
|
311 |
if (userResponse != timeoutStrategy)
|
|
312 |
{
|
|
313 |
NotifyPluginL();
|
|
314 |
}
|
|
315 |
}
|
|
316 |
User::RequestComplete(iRequestStatus, KErrCancel);
|
|
317 |
iActivity = EPosInactive;
|
|
318 |
}
|
|
319 |
}
|
|
320 |
|
|
321 |
// ---------------------------------------------------------
|
|
322 |
// CPosPrivManager::DoCancel
|
|
323 |
//
|
|
324 |
// (other items were commented in a header).
|
|
325 |
// ---------------------------------------------------------
|
|
326 |
//
|
|
327 |
void CPosPrivManager::DoCancel()
|
|
328 |
{
|
|
329 |
if (PosCommonPrivacyResources::Installed())
|
|
330 |
{
|
|
331 |
if (iActivity == EPosVerifying)
|
|
332 |
{
|
|
333 |
iDlgCtrl->CancelLaunch(iStatus);
|
|
334 |
}
|
|
335 |
}
|
|
336 |
}
|
|
337 |
|
|
338 |
// ---------------------------------------------------------
|
|
339 |
// CPosPrivManager::RunError
|
|
340 |
//
|
|
341 |
// (other items were commented in a header).
|
|
342 |
// ---------------------------------------------------------
|
|
343 |
//
|
|
344 |
TInt CPosPrivManager::RunError(TInt aError)
|
|
345 |
{
|
|
346 |
User::RequestComplete(iRequestStatus, aError);
|
|
347 |
iActivity = EPosInactive;
|
|
348 |
return KErrNone;
|
|
349 |
}
|
|
350 |
|
|
351 |
// ---------------------------------------------------------
|
|
352 |
// CPosPrivManager::ResolveL
|
|
353 |
//
|
|
354 |
// (other items were commented in a header).
|
|
355 |
// ---------------------------------------------------------
|
|
356 |
//
|
|
357 |
void CPosPrivManager::ResolveL()
|
|
358 |
{
|
|
359 |
// No resolving of requestors is implemented
|
|
360 |
iStatus = KErrNone;
|
|
361 |
RunL();
|
|
362 |
}
|
|
363 |
|
|
364 |
// ---------------------------------------------------------
|
|
365 |
// CPosPrivManager::CompleteRequestL
|
|
366 |
//
|
|
367 |
// (other items were commented in a header).
|
|
368 |
// ---------------------------------------------------------
|
|
369 |
//
|
|
370 |
void CPosPrivManager::CompleteRequestL(TInt aCompleteCode)
|
|
371 |
{
|
|
372 |
iLastVerificationResult = aCompleteCode;
|
|
373 |
|
|
374 |
TInt result = aCompleteCode ==
|
|
375 |
KErrNone ? KErrNone : KErrAccessDenied;
|
|
376 |
User::RequestComplete(iRequestStatus, result);
|
|
377 |
iActivity = EPosInactive;
|
|
378 |
}
|
|
379 |
|
|
380 |
// ---------------------------------------------------------
|
|
381 |
// CPosPrivManager::NotifyPluginL
|
|
382 |
//
|
|
383 |
// (other items were commented in a header).
|
|
384 |
// ---------------------------------------------------------
|
|
385 |
//
|
|
386 |
void CPosPrivManager::NotifyPluginL()
|
|
387 |
{
|
|
388 |
if (iRequestData.iRequestDecision == EPosDecisionNotAvailable)
|
|
389 |
{
|
|
390 |
iRequestData.iRequestDecision = iRequestData.iTimeoutStrategy;
|
|
391 |
}
|
|
392 |
|
|
393 |
iRequestData.iTimeoutStrategy = EPosDecisionNotAvailable;
|
|
394 |
iRequestData.iNotificationReason = EPosVerificationTimeout;
|
|
395 |
iRequestData.iCancelReason = EPosCancelReasonNotAvailable;
|
|
396 |
|
|
397 |
iDlgCtrl->NotifyL(*iRequestInfo, iRequestData);
|
|
398 |
iRequestInfo = NULL;
|
|
399 |
iRequestInfo = new (ELeave) TLbsExternalRequestInfo2;
|
|
400 |
}
|
|
401 |
|
|
402 |
// ---------------------------------------------------------
|
|
403 |
// CPosPrivManager::IsVerifying
|
|
404 |
//
|
|
405 |
// (other items were commented in a header).
|
|
406 |
// ---------------------------------------------------------
|
|
407 |
//
|
|
408 |
TBool CPosPrivManager::IsVerifying() const
|
|
409 |
{
|
|
410 |
switch (iActivity)
|
|
411 |
{
|
|
412 |
case EPosInactive:
|
|
413 |
case EPosResolvingForNotification:
|
|
414 |
return EFalse;
|
|
415 |
case EPosResolvingForVerification:
|
|
416 |
case EPosVerifying:
|
|
417 |
case EPosCancelBeforeDialog:
|
|
418 |
case EPosCancelDuringDialog:
|
|
419 |
case EPosCancelAfterDialog1:
|
|
420 |
case EPosCancelAfterDialog2:
|
|
421 |
return ETrue;
|
|
422 |
default:
|
|
423 |
//DebugPanic(EPosPrivSrvPanicUnknownActivity);
|
|
424 |
break;
|
|
425 |
}
|
|
426 |
return EFalse;
|
|
427 |
}
|
|
428 |
|
|
429 |
// End of File
|