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 <s32mem.h>
|
|
20 |
#include <lbs/epos_privacy.h>
|
|
21 |
#include <lbs/epos_cposcontactrequestor.h>
|
|
22 |
#include <lbs/epos_cposservicerequestor.h>
|
|
23 |
#include <lbs/epos_rposrequestorstack.h>
|
|
24 |
#include <lbs/epos_privacynotifier.hrh>
|
|
25 |
#include "EPos_CPosDialogCtrl.h"
|
|
26 |
#include <lbs/lbslocclasstypes.h>
|
|
27 |
|
|
28 |
// CONSTANTS
|
|
29 |
#if defined(NRH_UNIT_TEST)
|
|
30 |
// For the NRH unit test, use a different Q&N notifier implementation UID.
|
|
31 |
// This is so that we can have both the unit test Q&N notifier and
|
|
32 |
// the integration test Q&N notifier (with the real implementation UID)
|
|
33 |
// in the same ROM.
|
|
34 |
const TUid KNotifierUid = { 0x10283744 };
|
|
35 |
#else
|
|
36 |
const TUid KNotifierUid = { KPosPrivacyNotifierImplUid };
|
|
37 |
#endif // NRH_UNIT_TEST
|
|
38 |
|
|
39 |
// The output descriptor for Notifier calls. Since we want to pass
|
|
40 |
// just a dummy null descriptor there is no need to create a HBufC
|
|
41 |
// each time.
|
|
42 |
TPtr8 nullPtr(reinterpret_cast<TUint8*>(NULL), 0);
|
|
43 |
|
|
44 |
|
|
45 |
// ================= MEMBER FUNCTIONS =======================
|
|
46 |
|
|
47 |
// C++ default constructor can NOT contain any code, that
|
|
48 |
// might leave.
|
|
49 |
//
|
|
50 |
CPosDialogCtrl::CPosDialogCtrl() : CActive(EPriorityNormal),
|
|
51 |
iRequestQueue(1) // Set granularity to 1
|
|
52 |
{
|
|
53 |
CActiveScheduler::Add(this);
|
|
54 |
}
|
|
55 |
|
|
56 |
// EPOC default constructor can leave.
|
|
57 |
void CPosDialogCtrl::ConstructL()
|
|
58 |
{
|
|
59 |
TInt err = iNotifier.Connect();
|
|
60 |
User::LeaveIfError(err);
|
|
61 |
}
|
|
62 |
|
|
63 |
// Two-phased constructor.
|
|
64 |
CPosDialogCtrl* CPosDialogCtrl::InstanceL()
|
|
65 |
{
|
|
66 |
CPosDialogCtrl* self = new (ELeave) CPosDialogCtrl;
|
|
67 |
CleanupStack::PushL(self);
|
|
68 |
self->ConstructL();
|
|
69 |
CleanupStack::Pop(self);
|
|
70 |
return self;
|
|
71 |
}
|
|
72 |
|
|
73 |
// Destructor
|
|
74 |
CPosDialogCtrl::~CPosDialogCtrl()
|
|
75 |
{
|
|
76 |
Cancel();
|
|
77 |
TInt count = iRequestQueue.Count();
|
|
78 |
for (TInt i = 0; i < count; i++)
|
|
79 |
{
|
|
80 |
DoCompleteRequest(0, KErrServerTerminated);
|
|
81 |
// Delete the pointer items
|
|
82 |
delete iRequestQueue[i].iRequestInfo;
|
|
83 |
}
|
|
84 |
|
|
85 |
iNotifier.Close();
|
|
86 |
iRequestQueue.Close();
|
|
87 |
}
|
|
88 |
|
|
89 |
// ---------------------------------------------------------
|
|
90 |
// CPosDialogCtrl::NotifyL
|
|
91 |
//
|
|
92 |
// (other items were commented in a header).
|
|
93 |
// ---------------------------------------------------------
|
|
94 |
//
|
|
95 |
void CPosDialogCtrl::NotifyL(
|
|
96 |
TLbsExternalRequestInfo& aRequestInfo,
|
|
97 |
const TPosRequestData& aRequestData)
|
|
98 |
{
|
|
99 |
TRequest request;
|
|
100 |
request.iType = TPosQNInputData::ENotification;
|
|
101 |
request.iRequestInfo = &aRequestInfo;
|
|
102 |
request.iStatus = NULL;
|
|
103 |
request.iRequestSource = aRequestData.iRequestSource;
|
|
104 |
request.iTimeoutStrategy = aRequestData.iTimeoutStrategy;
|
|
105 |
request.iRequestDecision = aRequestData.iRequestDecision;
|
|
106 |
request.iCancelReason = aRequestData.iCancelReason;
|
|
107 |
request.iNotificationReason = aRequestData.iNotificationReason;
|
|
108 |
|
|
109 |
ScheduleRequestL(request);
|
|
110 |
}
|
|
111 |
|
|
112 |
// ---------------------------------------------------------
|
|
113 |
// CPosDialogCtrl::VerifyL
|
|
114 |
//
|
|
115 |
// (other items were commented in a header).
|
|
116 |
// ---------------------------------------------------------
|
|
117 |
//
|
|
118 |
void CPosDialogCtrl::VerifyL(
|
|
119 |
TRequestStatus& aStatus,
|
|
120 |
TLbsExternalRequestInfo& aRequestInfo,
|
|
121 |
const TPosRequestData& aRequestData)
|
|
122 |
{
|
|
123 |
aStatus = KRequestPending;
|
|
124 |
|
|
125 |
TRequest request;
|
|
126 |
request.iType = TPosQNInputData::EQuery;
|
|
127 |
request.iRequestInfo = &aRequestInfo;
|
|
128 |
request.iStatus = &aStatus;
|
|
129 |
request.iRequestSource = aRequestData.iRequestSource;
|
|
130 |
request.iTimeoutStrategy = aRequestData.iTimeoutStrategy;
|
|
131 |
request.iRequestDecision = aRequestData.iRequestDecision;
|
|
132 |
request.iCancelReason = aRequestData.iCancelReason;
|
|
133 |
request.iNotificationReason = aRequestData.iNotificationReason;
|
|
134 |
|
|
135 |
GivePriorityToVerificationL(request);
|
|
136 |
}
|
|
137 |
|
|
138 |
// ---------------------------------------------------------
|
|
139 |
// CPosDialogCtrl::CancelLaunch
|
|
140 |
//
|
|
141 |
// (other items were commented in a header).
|
|
142 |
// ---------------------------------------------------------
|
|
143 |
//
|
|
144 |
void CPosDialogCtrl::CancelLaunch(TRequestStatus& aStatus)
|
|
145 |
{
|
|
146 |
TInt count = iRequestQueue.Count();
|
|
147 |
|
|
148 |
if (count > 0 && iRequestQueue[0].iStatus == &aStatus)
|
|
149 |
{
|
|
150 |
Cancel();
|
|
151 |
DoCompleteRequest(0, KErrCancel);
|
|
152 |
NextRequest();
|
|
153 |
}
|
|
154 |
else
|
|
155 |
{
|
|
156 |
for (TInt i = 1; i < count; ++i)
|
|
157 |
{
|
|
158 |
if (iRequestQueue[i].iStatus == &aStatus)
|
|
159 |
{
|
|
160 |
DoCompleteRequest(i, KErrCancel);
|
|
161 |
return;
|
|
162 |
}
|
|
163 |
}
|
|
164 |
}
|
|
165 |
}
|
|
166 |
|
|
167 |
// ---------------------------------------------------------
|
|
168 |
// CPosDialogCtrl::CancelLaunch
|
|
169 |
//
|
|
170 |
// (other items were commented in a header).
|
|
171 |
// ---------------------------------------------------------
|
|
172 |
//
|
|
173 |
void CPosDialogCtrl::CancelLaunch(
|
|
174 |
TRequestStatus& aStatus,
|
|
175 |
TInt& aErrorCode,
|
|
176 |
TInt& aResponse,
|
|
177 |
TBool& aRequestQueued,
|
|
178 |
TPosVerifyCancelReason aCancelReason)
|
|
179 |
{
|
|
180 |
TInt count = iRequestQueue.Count();
|
|
181 |
|
|
182 |
if (count > 0 && iRequestQueue[0].iStatus == &aStatus)
|
|
183 |
{
|
|
184 |
TPtr8 nullPtr(reinterpret_cast<TUint8*>(NULL), 0);
|
|
185 |
TPosQNInputData data;
|
|
186 |
data.iId = iRequestQueue[0].iId;
|
|
187 |
data.iCancelReason = aCancelReason;
|
|
188 |
|
|
189 |
TPckg<TPosQNInputData> dataPtr(data);
|
|
190 |
|
|
191 |
aErrorCode = iNotifier.UpdateNotifier(KNotifierUid, dataPtr, nullPtr);
|
|
192 |
if( KErrNone==aErrorCode /* && iRequestQueue[0].iTimeoutStrategy == EPosDecisionAccepted */)
|
|
193 |
{
|
|
194 |
// If there is an error, notifications will be triggered through PrivManager
|
|
195 |
TRAPD(err,CreateNotificationAndEnqueueL());
|
|
196 |
err = err; // To avoid compiler warning
|
|
197 |
}
|
|
198 |
aResponse = iStatus.Int();
|
|
199 |
aRequestQueued = EFalse;
|
|
200 |
}
|
|
201 |
else
|
|
202 |
{
|
|
203 |
aResponse = KErrNone;
|
|
204 |
aErrorCode = KErrNone;
|
|
205 |
aRequestQueued = ETrue;
|
|
206 |
}
|
|
207 |
CancelLaunch(aStatus);
|
|
208 |
}
|
|
209 |
|
|
210 |
// ---------------------------------------------------------
|
|
211 |
// CPosDialogCtrl::RunL
|
|
212 |
//
|
|
213 |
// (other items were commented in a header).
|
|
214 |
// ---------------------------------------------------------
|
|
215 |
//
|
|
216 |
void CPosDialogCtrl::RunL()
|
|
217 |
{
|
|
218 |
if (iRequestQueue.Count() > 0)
|
|
219 |
{
|
|
220 |
DoCompleteRequest(0, iStatus.Int());
|
|
221 |
NextRequest();
|
|
222 |
}
|
|
223 |
}
|
|
224 |
|
|
225 |
// ---------------------------------------------------------
|
|
226 |
// CPosDialogCtrl::DoCancel
|
|
227 |
//
|
|
228 |
// (other items were commented in a header).
|
|
229 |
// ---------------------------------------------------------
|
|
230 |
//
|
|
231 |
void CPosDialogCtrl::DoCancel()
|
|
232 |
{
|
|
233 |
if (iStatus == KRequestPending)
|
|
234 |
{
|
|
235 |
iNotifier.CancelNotifier(KNotifierUid);
|
|
236 |
}
|
|
237 |
}
|
|
238 |
|
|
239 |
// ---------------------------------------------------------
|
|
240 |
// CPosDialogCtrl::DialogActive
|
|
241 |
//
|
|
242 |
// (other items were commented in a header).
|
|
243 |
// ---------------------------------------------------------
|
|
244 |
//
|
|
245 |
TBool CPosDialogCtrl::DialogActive() const
|
|
246 |
{
|
|
247 |
return iRequestQueue.Count() > 0;
|
|
248 |
}
|
|
249 |
|
|
250 |
// ---------------------------------------------------------
|
|
251 |
// CPosDialogCtrl::NextRequest
|
|
252 |
//
|
|
253 |
// (other items were commented in a header).
|
|
254 |
// ---------------------------------------------------------
|
|
255 |
//
|
|
256 |
void CPosDialogCtrl::NextRequest()
|
|
257 |
{
|
|
258 |
while (iRequestQueue.Count() > 0)
|
|
259 |
{
|
|
260 |
TInt err = StartNotifierRequest();
|
|
261 |
if (err)
|
|
262 |
{
|
|
263 |
DoCompleteRequest(0, err);
|
|
264 |
}
|
|
265 |
else
|
|
266 |
{
|
|
267 |
return;
|
|
268 |
}
|
|
269 |
}
|
|
270 |
}
|
|
271 |
|
|
272 |
// ---------------------------------------------------------
|
|
273 |
// CPosDialogCtrl::DoCompleteRequest
|
|
274 |
//
|
|
275 |
// (other items were commented in a header).
|
|
276 |
// ---------------------------------------------------------
|
|
277 |
//
|
|
278 |
void CPosDialogCtrl::DoCompleteRequest(
|
|
279 |
TInt aIndex,
|
|
280 |
TInt aCompletionCode)
|
|
281 |
{
|
|
282 |
TRequestStatus* status = iRequestQueue[aIndex].iStatus;
|
|
283 |
User::RequestComplete(status, aCompletionCode);
|
|
284 |
iRequestQueue.Remove(aIndex);
|
|
285 |
iRequestQueue.Compress();
|
|
286 |
}
|
|
287 |
|
|
288 |
// ---------------------------------------------------------
|
|
289 |
// CPosDialogCtrl::ScheduleRequestL
|
|
290 |
//
|
|
291 |
// (other items were commented in a header).
|
|
292 |
// ---------------------------------------------------------
|
|
293 |
//
|
|
294 |
void CPosDialogCtrl::ScheduleRequestL(TRequest& aRequest)
|
|
295 |
{
|
|
296 |
// Start a new request.
|
|
297 |
aRequest.iId = ++iRequestId;
|
|
298 |
User::LeaveIfError(iRequestQueue.Append(aRequest));
|
|
299 |
|
|
300 |
if (iRequestQueue.Count() == 1)
|
|
301 |
{
|
|
302 |
TInt err = StartNotifierRequest();
|
|
303 |
|
|
304 |
if (err != KErrNone)
|
|
305 |
{
|
|
306 |
DoCompleteRequest(0, err);
|
|
307 |
}
|
|
308 |
}
|
|
309 |
}
|
|
310 |
|
|
311 |
// ---------------------------------------------------------
|
|
312 |
// CPosDialogCtrl::StartNotifierRequest
|
|
313 |
//
|
|
314 |
// (other items were commented in a header).
|
|
315 |
// ---------------------------------------------------------
|
|
316 |
//
|
|
317 |
TInt CPosDialogCtrl::StartNotifierRequest()
|
|
318 |
{
|
|
319 |
TRequest request = iRequestQueue[0];
|
|
320 |
|
|
321 |
// Convert the TLbsExternalRequestInfo into a CPosRequestorStack
|
|
322 |
RPosRequestorStack reqStack;
|
|
323 |
TRAPD(err, ExtractRequestorsL(*request.iRequestInfo, reqStack));
|
|
324 |
if (err != KErrNone)
|
|
325 |
{
|
|
326 |
return err;
|
|
327 |
}
|
|
328 |
TInt dataSize = CalcSize(reqStack);
|
|
329 |
|
|
330 |
HBufC8* reqStackBuf = HBufC8::New(dataSize);
|
|
331 |
if (!reqStackBuf)
|
|
332 |
{
|
|
333 |
reqStack.ResetAndDestroy();
|
|
334 |
return KErrNoMemory;
|
|
335 |
}
|
|
336 |
|
|
337 |
TPtr8 ptr = reqStackBuf->Des();
|
|
338 |
TRAP(err, CreateSerializedStackL(ptr, reqStack));
|
|
339 |
if (err == KErrNone)
|
|
340 |
{
|
|
341 |
TPosQNInputData data;
|
|
342 |
data.iId = request.iId;
|
|
343 |
data.iType = request.iType;
|
|
344 |
data.iDataSize = dataSize;
|
|
345 |
data.iDataPtr = NULL;
|
|
346 |
data.iRequestSource = request.iRequestSource;
|
|
347 |
data.iTimeoutStrategy = request.iTimeoutStrategy;
|
|
348 |
data.iRequestDecision = request.iRequestDecision;
|
|
349 |
data.iNotificationReason = request.iNotificationReason;
|
|
350 |
data.iCancelReason = request.iCancelReason;
|
|
351 |
|
|
352 |
TPckg<TPosQNInputData> dataPtr(data);
|
|
353 |
|
|
354 |
HBufC8* buffer = HBufC8::New(KPosQNInputDataClassSize +
|
|
355 |
reqStackBuf->Size());
|
|
356 |
if (!buffer)
|
|
357 |
{
|
|
358 |
delete reqStackBuf;
|
|
359 |
return KErrNoMemory;
|
|
360 |
}
|
|
361 |
|
|
362 |
buffer->Des().Append(dataPtr);
|
|
363 |
buffer->Des().Append(*reqStackBuf);
|
|
364 |
|
|
365 |
delete reqStackBuf;
|
|
366 |
reqStackBuf = NULL;
|
|
367 |
|
|
368 |
if (data.iType == TPosQNInputData::ENotification) // We dont expect a resonse from a notfication
|
|
369 |
{
|
|
370 |
iNotifier.StartNotifier(KNotifierUid, nullPtr, nullPtr);
|
|
371 |
|
|
372 |
// As we wont be getting a response remove from the notification list
|
|
373 |
delete iRequestQueue[0].iRequestInfo;
|
|
374 |
iRequestQueue.Remove(0);
|
|
375 |
iRequestQueue.Compress();
|
|
376 |
}
|
|
377 |
else
|
|
378 |
{
|
|
379 |
iNotifier.StartNotifierAndGetResponse(
|
|
380 |
iStatus, KNotifierUid, nullPtr, nullPtr);
|
|
381 |
SetActive();
|
|
382 |
}
|
|
383 |
|
|
384 |
err = iNotifier.UpdateNotifier(KNotifierUid, *buffer, nullPtr);
|
|
385 |
if (err != KErrNone)
|
|
386 |
{
|
|
387 |
Cancel();
|
|
388 |
}
|
|
389 |
delete buffer;
|
|
390 |
}
|
|
391 |
|
|
392 |
delete reqStackBuf;
|
|
393 |
reqStack.ResetAndDestroy();
|
|
394 |
return err;
|
|
395 |
}
|
|
396 |
|
|
397 |
// ---------------------------------------------------------
|
|
398 |
// CPosDialogCtrl::CreateSerializedStackL
|
|
399 |
//
|
|
400 |
// (other items were commented in a header).
|
|
401 |
// ---------------------------------------------------------
|
|
402 |
//
|
|
403 |
void CPosDialogCtrl::CreateSerializedStackL(
|
|
404 |
TDes8& aBuffer,
|
|
405 |
const RPosRequestorStack& aRequestStack)
|
|
406 |
{
|
|
407 |
RDesWriteStream writeStream(aBuffer);
|
|
408 |
CleanupClosePushL(writeStream);
|
|
409 |
aRequestStack.ExternalizeL(writeStream);
|
|
410 |
writeStream.CommitL();
|
|
411 |
CleanupStack::PopAndDestroy(1, &writeStream);
|
|
412 |
}
|
|
413 |
|
|
414 |
// ---------------------------------------------------------
|
|
415 |
// CPosDialogCtrl::CalcSize
|
|
416 |
//
|
|
417 |
// (other items were commented in a header).
|
|
418 |
// ---------------------------------------------------------
|
|
419 |
//
|
|
420 |
TInt CPosDialogCtrl::CalcSize(
|
|
421 |
const RPosRequestorStack& aRequestStack)
|
|
422 |
{
|
|
423 |
TInt size = sizeof(TInt); // One TInt for number of requestors.
|
|
424 |
const TInt numRequestors = aRequestStack.Count();
|
|
425 |
for (TInt i = 0; i < numRequestors; i++)
|
|
426 |
{
|
|
427 |
const CPosRequestor* requestor = aRequestStack[i];
|
|
428 |
|
|
429 |
// Add on the size of the requestor class, the
|
|
430 |
// descriptor it contains, and an extra TInt which
|
|
431 |
// is used to store the length of the descriptor.
|
|
432 |
size += sizeof(CPosRequestor);
|
|
433 |
size += sizeof(TInt);
|
|
434 |
size += requestor->RequestorIdString().Size();
|
|
435 |
}
|
|
436 |
|
|
437 |
return size;
|
|
438 |
}
|
|
439 |
|
|
440 |
/** Convert a TLbsExternalRequestInfo into a RPosRequestorStack.
|
|
441 |
*/
|
|
442 |
void CPosDialogCtrl::ExtractRequestorsL(
|
|
443 |
const TLbsExternalRequestInfo& aRequestInfo,
|
|
444 |
RPosRequestorStack& aRequestors)
|
|
445 |
{
|
|
446 |
// Convert the Client name into a CPosRequestor::ERequestorService requestor.
|
|
447 |
switch (aRequestInfo.ClassType())
|
|
448 |
{
|
|
449 |
case EExternalRequestInfoClass:
|
|
450 |
{
|
|
451 |
TBuf<KLbsMaxClientNameSize> buf;
|
|
452 |
aRequestInfo.GetClientName(buf);
|
|
453 |
AddRequestorL(CPosRequestor::ERequestorService,
|
|
454 |
aRequestInfo.ClientNameFormat(),
|
|
455 |
aRequestInfo.RequestType(),
|
|
456 |
aRequestInfo.NetworkType(),
|
|
457 |
buf,
|
|
458 |
aRequestors
|
|
459 |
);
|
|
460 |
break;
|
|
461 |
}
|
|
462 |
case (EExternalRequestInfoClass
|
|
463 |
| EExternalRequestInfoClass2):
|
|
464 |
{
|
|
465 |
const TLbsExternalRequestInfo2& info = static_cast<const TLbsExternalRequestInfo2&>(aRequestInfo);
|
|
466 |
TBuf<KLbsMaxClientNameSize2> buf;
|
|
467 |
info.GetClientName(buf);
|
|
468 |
AddRequestorL(CPosRequestor::ERequestorService,
|
|
469 |
aRequestInfo.ClientNameFormat(),
|
|
470 |
aRequestInfo.RequestType(),
|
|
471 |
aRequestInfo.NetworkType(),
|
|
472 |
buf,
|
|
473 |
aRequestors
|
|
474 |
);
|
|
475 |
break;
|
|
476 |
}
|
|
477 |
default:
|
|
478 |
{
|
|
479 |
// Unrecognised TLbsExternalRequestInfo class type, so ignore it.
|
|
480 |
break;
|
|
481 |
}
|
|
482 |
}
|
|
483 |
|
|
484 |
// Convert the Requestor name into a CPosRequestor::ERequestorContact requestor.
|
|
485 |
switch (aRequestInfo.ClassType())
|
|
486 |
{
|
|
487 |
case EExternalRequestInfoClass:
|
|
488 |
{
|
|
489 |
TBuf<KLbsMaxRequesterIdSize> buf;
|
|
490 |
aRequestInfo.GetRequesterId(buf);
|
|
491 |
AddRequestorL(CPosRequestor::ERequestorContact,
|
|
492 |
aRequestInfo.RequesterIdFormat(),
|
|
493 |
aRequestInfo.RequestType(),
|
|
494 |
aRequestInfo.NetworkType(),
|
|
495 |
buf,
|
|
496 |
aRequestors
|
|
497 |
);
|
|
498 |
break;
|
|
499 |
}
|
|
500 |
case (EExternalRequestInfoClass
|
|
501 |
| EExternalRequestInfoClass2):
|
|
502 |
{
|
|
503 |
const TLbsExternalRequestInfo2& info = static_cast<const TLbsExternalRequestInfo2&>(aRequestInfo);
|
|
504 |
TBuf<KLbsMaxRequesterIdSize2> buf;
|
|
505 |
info.GetRequesterId(buf);
|
|
506 |
AddRequestorL(CPosRequestor::ERequestorContact,
|
|
507 |
aRequestInfo.RequesterIdFormat(),
|
|
508 |
aRequestInfo.RequestType(),
|
|
509 |
aRequestInfo.NetworkType(),
|
|
510 |
buf,
|
|
511 |
aRequestors
|
|
512 |
);
|
|
513 |
break;
|
|
514 |
}
|
|
515 |
default:
|
|
516 |
{
|
|
517 |
// Unrecognised TLbsExternalRequestInfo class type, so ignore it.
|
|
518 |
break;
|
|
519 |
}
|
|
520 |
}
|
|
521 |
}
|
|
522 |
|
|
523 |
/**
|
|
524 |
*/
|
|
525 |
void CPosDialogCtrl::AddRequestorL(
|
|
526 |
CPosRequestor::TRequestorType aRequestorType,
|
|
527 |
TLbsExternalRequestInfo::TFormatIndicator aIdType,
|
|
528 |
CPosRequestor::TRequestType aRequestType,
|
|
529 |
CPosRequestor::TNetworkType aNetworkType,
|
|
530 |
const TDesC& aId,
|
|
531 |
RPosRequestorStack& aRequestors)
|
|
532 |
{
|
|
533 |
CPosRequestor::TRequestorIdFormat format = CPosRequestor::EIdFormatUnknown;
|
|
534 |
switch (aIdType)
|
|
535 |
{
|
|
536 |
case TLbsExternalRequestInfo::EFormatLogicalName :
|
|
537 |
format = CPosRequestor::EIdFormatGenericName;
|
|
538 |
break;
|
|
539 |
case TLbsExternalRequestInfo::EFormatMSISDN :
|
|
540 |
format = CPosRequestor::EIdFormatPhoneNumber;
|
|
541 |
break;
|
|
542 |
case TLbsExternalRequestInfo::EFormatEmailAddress :
|
|
543 |
format = CPosRequestor::EIdFormatEmail;
|
|
544 |
break;
|
|
545 |
case TLbsExternalRequestInfo::EFormatURL :
|
|
546 |
format = CPosRequestor::EIdFormatUrl;
|
|
547 |
break;
|
|
548 |
case TLbsExternalRequestInfo::EFormatSIPURL :
|
|
549 |
format = CPosRequestor::EIdFormatSIPUrl;
|
|
550 |
break;
|
|
551 |
case TLbsExternalRequestInfo::EFormatIMSPublicIdentity :
|
|
552 |
format = CPosRequestor::EIdFormatIMSPublicIdentity;
|
|
553 |
break;
|
|
554 |
case TLbsExternalRequestInfo::EFormatMIN:
|
|
555 |
format = CPosRequestor::EIdFormatMIN;
|
|
556 |
break;
|
|
557 |
case TLbsExternalRequestInfo::EFormatMDN:
|
|
558 |
format = CPosRequestor::EIdFormatMDN;
|
|
559 |
break;
|
|
560 |
}
|
|
561 |
|
|
562 |
// Only add the requestor to the stack if it is a recognised format.
|
|
563 |
if (format != CPosRequestor::EIdFormatUnknown)
|
|
564 |
{
|
|
565 |
CPosRequestor* requestor = NULL;
|
|
566 |
if (aRequestorType == CPosRequestor::ERequestorContact)
|
|
567 |
{
|
|
568 |
requestor = CPosContactRequestor::NewLC(format, aId);
|
|
569 |
}
|
|
570 |
else
|
|
571 |
{
|
|
572 |
requestor = CPosServiceRequestor::NewLC(format, aId);
|
|
573 |
}
|
|
574 |
|
|
575 |
requestor->SetRequestType(aRequestType);
|
|
576 |
requestor->SetNetworkType(aNetworkType);
|
|
577 |
User::LeaveIfError(aRequestors.Append(requestor));
|
|
578 |
CleanupStack::Pop(requestor);
|
|
579 |
}
|
|
580 |
}
|
|
581 |
|
|
582 |
|
|
583 |
// ---------------------------------------------------------
|
|
584 |
// CPosDialogCtrl::GivePriorityToVerificationL
|
|
585 |
//
|
|
586 |
// (other items were commented in a header).
|
|
587 |
// ---------------------------------------------------------
|
|
588 |
//
|
|
589 |
void CPosDialogCtrl::GivePriorityToVerificationL(TRequest& aRequest)
|
|
590 |
{
|
|
591 |
TBool notificationDeferred = EFalse;
|
|
592 |
|
|
593 |
if( iRequestQueue.Count() == 0 )
|
|
594 |
{
|
|
595 |
ScheduleRequestL(aRequest);
|
|
596 |
return;
|
|
597 |
}
|
|
598 |
if ( iRequestQueue[0].iType == TPosQNInputData::ENotification )
|
|
599 |
{
|
|
600 |
notificationDeferred=ETrue; // To indicate that notification is deferred,dont remove it from queue.
|
|
601 |
}
|
|
602 |
|
|
603 |
EnqueueRequestL(aRequest);
|
|
604 |
|
|
605 |
if(notificationDeferred)
|
|
606 |
{
|
|
607 |
Cancel();
|
|
608 |
DeferNotificationL();
|
|
609 |
}
|
|
610 |
}
|
|
611 |
// ---------------------------------------------------------
|
|
612 |
// CPosDialogCtrl::EnqueueRequestL
|
|
613 |
//
|
|
614 |
// (other items were commented in a header).
|
|
615 |
// ---------------------------------------------------------
|
|
616 |
//
|
|
617 |
void CPosDialogCtrl::EnqueueRequestL(TRequest& aRequest)
|
|
618 |
{
|
|
619 |
aRequest.iId = ++iRequestId;
|
|
620 |
|
|
621 |
for( TInt i = 1; i < iRequestQueue.Count(); i++ )
|
|
622 |
{
|
|
623 |
if ( iRequestQueue[i].iType == TPosQNInputData::ENotification )
|
|
624 |
{
|
|
625 |
User::LeaveIfError(iRequestQueue.Insert( aRequest,i ));
|
|
626 |
return;
|
|
627 |
}
|
|
628 |
}
|
|
629 |
|
|
630 |
User::LeaveIfError(iRequestQueue.Append(aRequest));
|
|
631 |
}
|
|
632 |
|
|
633 |
// ---------------------------------------------------------
|
|
634 |
// CPosDialogCtrl::DeferNotificationL
|
|
635 |
//
|
|
636 |
// (other items were commented in a header).
|
|
637 |
// ---------------------------------------------------------
|
|
638 |
//
|
|
639 |
void CPosDialogCtrl::DeferNotificationL()
|
|
640 |
{
|
|
641 |
if( KErrCancel == iStatus.Int() )
|
|
642 |
{
|
|
643 |
//Notification request has been cancelled..Defer it by adding
|
|
644 |
// after verification requests,remove it from first place & schedule next request.
|
|
645 |
TRequest request = iRequestQueue[0];
|
|
646 |
EnqueueRequestL(request);
|
|
647 |
}
|
|
648 |
iRequestQueue.Remove(0);
|
|
649 |
iRequestQueue.Compress();
|
|
650 |
NextRequest();
|
|
651 |
}
|
|
652 |
|
|
653 |
// ---------------------------------------------------------
|
|
654 |
// CPosDialogCtrl::CreateNotificationAndEnqueueL
|
|
655 |
//
|
|
656 |
// (other items were commented in a header).
|
|
657 |
// ---------------------------------------------------------
|
|
658 |
//
|
|
659 |
void CPosDialogCtrl::CreateNotificationAndEnqueueL()
|
|
660 |
{
|
|
661 |
TRequest verifyRequest = iRequestQueue[0];
|
|
662 |
TRequest notifyRequest;
|
|
663 |
TLbsExternalRequestInfo* requestinfocopy = NULL;
|
|
664 |
|
|
665 |
if (verifyRequest.iRequestInfo->ClassType() == EExternalRequestInfoClass)
|
|
666 |
{
|
|
667 |
requestinfocopy = new (ELeave) TLbsExternalRequestInfo;
|
|
668 |
CleanupStack::PushL(requestinfocopy);
|
|
669 |
Mem::Copy(requestinfocopy, verifyRequest.iRequestInfo, sizeof(TLbsExternalRequestInfo));
|
|
670 |
}
|
|
671 |
else
|
|
672 |
{
|
|
673 |
__ASSERT_DEBUG(verifyRequest.iRequestInfo->ClassType() == EExternalRequestInfoClass | EExternalRequestInfoClass2, User::Invariant());
|
|
674 |
requestinfocopy = new (ELeave) TLbsExternalRequestInfo2;
|
|
675 |
CleanupStack::PushL(requestinfocopy);
|
|
676 |
Mem::Copy(requestinfocopy, verifyRequest.iRequestInfo, sizeof(TLbsExternalRequestInfo2));
|
|
677 |
}
|
|
678 |
|
|
679 |
notifyRequest.iRequestInfo = requestinfocopy;
|
|
680 |
notifyRequest.iType = TPosQNInputData::ENotification;
|
|
681 |
notifyRequest.iStatus = NULL;
|
|
682 |
notifyRequest.iRequestSource = EPosRequestSourceNetwork;
|
|
683 |
|
|
684 |
notifyRequest.iTimeoutStrategy = EPosDecisionNotAvailable;
|
|
685 |
notifyRequest.iRequestDecision = verifyRequest.iTimeoutStrategy;
|
|
686 |
|
|
687 |
notifyRequest.iCancelReason = EPosCancelReasonTimeout;
|
|
688 |
notifyRequest.iNotificationReason = EPosVerificationTimeout;
|
|
689 |
|
|
690 |
EnqueueRequestL(notifyRequest);
|
|
691 |
CleanupStack::Pop(requestinfocopy);
|
|
692 |
|
|
693 |
}
|
|
694 |
// End of File
|