Update contrib.
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
20 #include "tupsclientstep.h"
21 #include "tupsintegdefs.h"
22 #include "tupsproperty.h"
23 #include <e32property.h>
26 TServiceRequestParameters::TServiceRequestParameters()
27 :iServiceUID(0), iServerName(0),iDestination(0), iExpectedError(0),
28 iOpaqueData(0), iSelectDialogOption(0), iButtonsDisplayed(0),
29 iDialogCreatorInvoked(0), iPolicyEvaluatorInvoked(0), iAccessGranted(0),
30 iCloseSession(EFalse), iHoldEvaluatorOpen(EFalse), iHoldPrepareDialogOpen(EFalse), iHoldDisplayDialogOpen(EFalse),
31 iRequestDurationThreshold(0), iLeaveDialog(EFalse), iLeaveEvaluator(EFalse), iCancelUpsRequest(EFalse),
32 iPlatSecPass(EFalse),iForcePrompt(EFalse),iExpectedEvaluatorInfo(0),iSelectFingerprint(0),
33 iWaitUntilFileAppears(0)
37 COpenSession* COpenSession::NewL(const TPtrC& aServerName)
39 COpenSession * self = new (ELeave) COpenSession();
40 CleanupStack::PushL(self);
41 self->ConstructL(aServerName);
42 CleanupStack::Pop(self);
46 void COpenSession::ConstructL(const TPtrC& aServerName)
48 iServerName = aServerName;
49 iPointerToServer = new RUpsTestServ;
50 User::LeaveIfError(iPointerToServer->Connect(iServerName, ETrue));
51 iPointerToSession = new RUpsTestSession;
52 User::LeaveIfError(iPointerToSession->Open(*iPointerToServer));
55 COpenSession::~COpenSession()
57 if (iPointerToSession)
58 iPointerToSession->Close();
60 iPointerToServer->Close();
61 delete iPointerToSession;
62 delete iPointerToServer;
65 CUpsClientStep::~CUpsClientStep()
70 iArraySersToRequest.Close();
72 CloseAllOpenSessions();
73 delete iPropertyReader;
78 CUpsClientStep::CUpsClientStep()
83 SetTestStepName(KUPSClientStep);
87 TVerdict CUpsClientStep::doTestStepPreambleL()
89 * @return - TVerdict code
90 * Override of base class virtual
96 // Read values to config servers from INI file. (ARRAY of values)
98 // Read how many times the test step needs to be repeated.
99 TName fStepRepeat(_L("StepRepeat"));
102 if(GetIntFromConfig(ConfigSection(),fStepRepeat,repeats))
111 // Read values for test sequence from INI file. (ARRAY of values)
113 TName fUseServiceUID;
114 fUseServiceUID.Format(_L("UseServiceUID_%d"),index);
115 TName fUseServerName;
116 fUseServerName.Format(_L("UseServerName_%d"),index);
118 fDestination.Format(_L("Destination_%d"),index);
119 TName fExpectedError;
120 fExpectedError.Format(_L("ExpectedError_%d"),index);
121 TName fUseOpaqueData;
122 fUseOpaqueData.Format(_L("UseOpaqueData_%d"),index);
123 TName fSelectDialogOption;
124 fSelectDialogOption.Format(_L("SelectDialogOption_%d"),index);
125 TName fButtonsDisplayed;
126 fButtonsDisplayed.Format(_L("ButtonsDisplayed_%d"),index);
127 TName fDialogCreatorInvoked;
128 fDialogCreatorInvoked.Format(_L("DialogCreatorInvoked_%d"),index);
129 TName fPolicyEvaluatorInvoked;
130 fPolicyEvaluatorInvoked.Format(_L("PolicyEvaluatorInvoked_%d"),index);
131 TName fAccessGranted;
132 fAccessGranted.Format(_L("AccessGranted_%d"), index);
134 fCloseSession.Format(_L("CloseSession_%d"), index);
135 TName fHoldEvaluatorOpen;
136 fHoldEvaluatorOpen.Format(_L("HoldEvaluatorOpen_%d"), index);
137 TName fHoldPrepareDialogOpen;
138 fHoldPrepareDialogOpen.Format(_L("HoldPrepareDialogOpen_%d"), index);
139 TName fHoldDisplayDialogOpen;
140 fHoldDisplayDialogOpen.Format(_L("HoldDisplayDialogOpen_%d"), index);
141 TName fRequestDurationThreshold;
142 fRequestDurationThreshold.Format(_L("RequestDurationThreshold_%d"), index);
144 fLeaveDialog.Format(_L("LeaveDialog_%d"), index);
145 TName fLeaveEvaluator;
146 fLeaveEvaluator.Format(_L("LeaveEvaluator_%d"), index);
147 TName fCancelUpsRequest;
148 fCancelUpsRequest.Format(_L("CancelUpsRequest_%d"), index);
150 fPlatSecPass.Format(_L("PlatSecPass_%d"), index);
152 fForcePrompt.Format(_L("ForcePrompt_%d"), index);
153 TName fExpectedEvaInfo;
154 fExpectedEvaInfo.Format(_L("ExpectedEvaluatorInfo_%d"), index);
155 TName fSelectFingerprint;
156 fSelectFingerprint.Format(_L("SelectFingerprint_%d"), index);
157 TName fWaitUntilFileAppears;
158 fWaitUntilFileAppears.Format(_L("WaitUntilFileAppears_%d"), index);
165 TPtrC selectDialogOption;
166 TInt buttonsDisplayed;
167 TInt dialogCreatorInvoked;
168 TInt policyEvaluatorInvoked;
171 TBool holdEvaluatorOpen;
172 TBool holdPrepareDialogOpen;
173 TBool holdDisplayDialogOpen;
174 TInt requestDurationThreshold;
176 TBool leaveEvaluator;
177 TBool cancelUpsRequest;
180 TInt expectedEvaInfo;
181 TInt selectFingerprint;
182 TPtrC waitUntilFileAppears;
184 while (GetHexFromConfig(ConfigSection(), fUseServiceUID,useServiceUID)
185 && GetStringFromConfig(ConfigSection(),fUseServerName,useServerName)
186 && GetStringFromConfig(ConfigSection(),fDestination,destination)
187 && GetStringFromConfig(ConfigSection(),fAccessGranted,accessGranted))
189 TServiceRequestParameters newSerReq;
190 newSerReq.iServiceUID = useServiceUID;
191 newSerReq.iServerName = useServerName;
192 newSerReq.iDestination = destination;
193 newSerReq.iAccessGranted = accessGranted;
195 // Close session is optional.
196 if(GetBoolFromConfig(ConfigSection(),fCloseSession,closeSession))
198 newSerReq.iCloseSession = closeSession;
201 // use of dialog creator is optional.
202 if(GetStringFromConfig(ConfigSection(),fSelectDialogOption,selectDialogOption)
203 && GetIntFromConfig(ConfigSection(),fButtonsDisplayed,buttonsDisplayed)
204 && GetIntFromConfig(ConfigSection(),fDialogCreatorInvoked,dialogCreatorInvoked))
206 newSerReq.iSelectDialogOption = selectDialogOption;
207 newSerReq.iButtonsDisplayed = buttonsDisplayed;
208 newSerReq.iDialogCreatorInvoked = dialogCreatorInvoked;
211 // use of policy evaluator is optional.
212 if(GetIntFromConfig(ConfigSection(),fPolicyEvaluatorInvoked,policyEvaluatorInvoked))
214 newSerReq.iPolicyEvaluatorInvoked = policyEvaluatorInvoked;
217 // Opaque data is optional
218 if(GetStringFromConfig(ConfigSection(),fUseOpaqueData,useOpaqueData))
220 HBufC8* converter = HBufC8::NewLC(useOpaqueData.Length());
221 converter->Des().Copy(useOpaqueData);
223 newSerReq.iOpaqueData = converter->Ptr() ;
224 CleanupStack::PopAndDestroy(); //converter
227 // Expected error is optional.
228 if(GetIntFromConfig(ConfigSection(),fExpectedError,expectedError))
230 newSerReq.iExpectedError = expectedError;
233 // hold policy evaluator open is optional.
234 if(GetBoolFromConfig(ConfigSection(),fHoldEvaluatorOpen, holdEvaluatorOpen))
236 newSerReq.iHoldEvaluatorOpen = holdEvaluatorOpen;
239 // hold prepare dialog open is optional.
240 if(GetBoolFromConfig(ConfigSection(),fHoldPrepareDialogOpen, holdPrepareDialogOpen))
242 newSerReq.iHoldPrepareDialogOpen = holdPrepareDialogOpen;
245 // hold display dialog open is optional.
246 if(GetBoolFromConfig(ConfigSection(),fHoldDisplayDialogOpen, holdDisplayDialogOpen))
248 newSerReq.iHoldDisplayDialogOpen = holdDisplayDialogOpen;
251 // request duration threshold - if a request takes
252 // longer than this threshold it will fail the test
253 if(GetIntFromConfig(ConfigSection(),fRequestDurationThreshold, requestDurationThreshold))
255 newSerReq.iRequestDurationThreshold = requestDurationThreshold;
258 // leave dialog is optional.
259 if(GetBoolFromConfig(ConfigSection(),fLeaveDialog,leaveDialog))
261 newSerReq.iLeaveDialog = leaveDialog;
264 // leave Evaluator is optional.
265 if(GetBoolFromConfig(ConfigSection(),fLeaveEvaluator,leaveEvaluator))
267 newSerReq.iLeaveEvaluator = leaveEvaluator;
270 // Cancel ups request is optional.
271 if(GetBoolFromConfig(ConfigSection(),fCancelUpsRequest,cancelUpsRequest))
273 newSerReq.iCancelUpsRequest = cancelUpsRequest;
276 // plat sec pass is optional.
277 if(GetBoolFromConfig(ConfigSection(),fPlatSecPass,platSecPass))
279 newSerReq.iPlatSecPass = platSecPass;
282 // Force prompt is optional.
283 if(GetBoolFromConfig(ConfigSection(),fForcePrompt,forcePrompt))
285 newSerReq.iForcePrompt = forcePrompt;
288 // use of policy evaluator is optional.
289 if(GetIntFromConfig(ConfigSection(),fExpectedEvaInfo,expectedEvaInfo))
291 newSerReq.iExpectedEvaluatorInfo = expectedEvaInfo;
294 // Fingerprint selection is optional.
295 if(GetIntFromConfig(ConfigSection(),fSelectFingerprint,selectFingerprint))
297 newSerReq.iSelectFingerprint = selectFingerprint;
300 // iRepeatUntilFileAppears is optional.
301 if(GetStringFromConfig(ConfigSection(),fWaitUntilFileAppears,waitUntilFileAppears))
303 newSerReq.iWaitUntilFileAppears = waitUntilFileAppears;
306 // Add the new service to be requested to array.
307 iArraySersToRequest.Append(newSerReq);
310 fUseServiceUID.Format(_L("UseServiceUID_%d"),index);
311 fUseServerName.Format(_L("UseServerName_%d"),index);
312 fDestination.Format(_L("Destination_%d"),index);
313 fExpectedError.Format(_L("ExpectedError_%d"),index);
314 fUseOpaqueData.Format(_L("UseOpaqueData_%d"),index);
315 fSelectDialogOption.Format(_L("SelectDialogOption_%d"),index);
316 fButtonsDisplayed.Format(_L("ButtonsDisplayed_%d"),index);
317 fDialogCreatorInvoked.Format(_L("DialogCreatorInvoked_%d"),index);
318 fPolicyEvaluatorInvoked.Format(_L("PolicyEvaluatorInvoked_%d"),index);
319 fAccessGranted.Format(_L("AccessGranted_%d"), index);
320 fCloseSession.Format(_L("CloseSession_%d"), index);
321 fHoldEvaluatorOpen.Format(_L("HoldEvaluatorOpen_%d"), index);
322 fHoldPrepareDialogOpen.Format(_L("HoldPrepareDialogOpen_%d"), index);
323 fHoldDisplayDialogOpen.Format(_L("HoldDisplayDialogOpen_%d"), index);
324 fRequestDurationThreshold.Format(_L("RequestDurationThreshold_%d"), index);
325 fLeaveDialog.Format(_L("LeaveDialog_%d"), index);
326 fLeaveEvaluator.Format(_L("LeaveEvaluator_%d"), index);
327 fCancelUpsRequest.Format(_L("CancelUpsRequest_%d"), index);
328 fPlatSecPass.Format(_L("PlatSecPass_%d"), index);
329 fForcePrompt.Format(_L("ForcePrompt_%d"), index);
330 fExpectedEvaInfo.Format(_L("ExpectedEvaluatorInfo_%d"), index);
331 fSelectFingerprint.Format(_L("SelectFingerprint_%d"), index);
332 fWaitUntilFileAppears.Format(_L("WaitUntilFileAppears_%d"), index);
335 // now try for some clientStep specific stuff
336 // this ini file entry specifies the property key value for the hold flag
337 // If the hold flag property is true then monitor it until it becomes false
340 if(GetIntFromConfig(ConfigSection(),_L("HoldClientStepKey"), holdKey))
342 iHoldClientStepKey = holdKey;
344 // as this property is present then set it to true using a direct call to p&s api because
345 // the ups p&s api only handles policy evaluators and dialog creators and not test steps
346 User::LeaveIfError(RProperty::Set(KPropertyCreatorUid, iHoldClientStepKey, 2));
349 // Instantiates property reader and seter
350 iPropertyReader= CUpsProperty::NewL(KPropertyCreatorUid);
352 // reads client name and SID
353 TParse clientFullName;
355 clientFullName.Set(client.FullName(),NULL, NULL);
356 iTEFServerName=clientFullName.Name();
357 iExpectedClientSid = client.SecureId() ;
360 SetTestStepResult(EPass);
361 return TestStepResult();
365 TVerdict CUpsClientStep::doTestStepL()
367 // loop to request for different test services.
368 TVerdict testResult= EPass;
369 TInt numServicesToRequest = iArraySersToRequest.Count();
371 if(numServicesToRequest > 0)
373 // check if the test step needs to hold until another step allows it to continue
374 if (iHoldClientStepKey)
379 // repeats the sequence of test services request as many times as specified in iStepRepeat
380 for(TInt repeatTimes = 0;repeatTimes<iStepRepeat;++repeatTimes)
382 INFO_PRINTF3(_L("%S: Repeat number: %d"),&iTEFServerName,repeatTimes);
384 for(TInt index=0;index < numServicesToRequest; ++index )
386 INFO_PRINTF6(_L("%S: Service request: %d. SysServer: %S Destination: %S ServiceUID: %X "),&iTEFServerName, index, &iArraySersToRequest[index].iServerName ,&iArraySersToRequest[index].iDestination, iArraySersToRequest[index].iServiceUID);
387 RUpsTestSession * sessionToBeUsed;
389 sessionToBeUsed = GetSessionToServerL(iArraySersToRequest[index].iServerName);
393 sessionToBeUsed->UseTestService(iRequestData,iReturnData);
395 iServerId=sessionToBeUsed->GetServerSid();
397 if(CheckResultsL(index) == EFalse)
399 ERR_PRINTF2(_L("%S: Incorrect results"),&iTEFServerName);
400 User::Leave(KErrGeneral);
403 // Checks from config value if session need to be closed.
404 if(iArraySersToRequest[index].iCloseSession)
406 INFO_PRINTF3(_L("%S :Closing session to server: %S"),&iTEFServerName, &iArraySersToRequest[index].iServerName );
407 CloseSessionL(iArraySersToRequest[index].iServerName);
409 } // End of second loop
410 }// End of first loop
412 // Sets the status of the first instance of policy evaluator and dialog creator to
413 // completed so that the coordinator step can progress in concurrent mode
414 SetClientStatusCompleteL();
419 ERR_PRINTF2(_L("%S :Problem reading ini file"),&iTEFServerName);
420 User::Leave(KErrGeneral);
427 TVerdict CUpsClientStep::doTestStepPostambleL()
429 return TestStepResult();
433 void CUpsClientStep::HoldClientL(void)
435 RProperty checkIfStillNeedtoHold;
436 User::LeaveIfError(checkIfStillNeedtoHold.Attach(KPropertyCreatorUid, iHoldClientStepKey));
437 CleanupClosePushL(checkIfStillNeedtoHold);
438 checkIfStillNeedtoHold.Set(KPropertyCreatorUid, iHoldClientStepKey, 1);
439 TRequestStatus holdStatus;
440 checkIfStillNeedtoHold.Subscribe(holdStatus);
444 checkIfStillNeedtoHold.Get(KPropertyCreatorUid, iHoldClientStepKey, holdState);
447 checkIfStillNeedtoHold.Cancel();
451 User::WaitForRequest(holdStatus);
454 RDebug::Printf("[UPS ClientStep 0x%x] HoldClient() stopped holding\n", this);
456 // set the hold state back to 1 for future holds
457 checkIfStillNeedtoHold.Set(KPropertyCreatorUid, iHoldClientStepKey, 2);
458 CleanupStack::PopAndDestroy(&checkIfStillNeedtoHold);
462 TBool CUpsClientStep::FindOpenSession(const TDesC& aServerName,TInt &position)
464 TBool sessionFound = EFalse;
465 TInt sessionsCount = iArraySessionsInUse.Count();
466 for(TInt index = 0;index < sessionsCount; ++index)
468 if(!aServerName.CompareF(iArraySessionsInUse[index]->iServerName))
471 sessionFound = ETrue;
479 RUpsTestSession* CUpsClientStep::GetSessionToServerL(const TDesC& aServerName)
481 // Finds out if a session is already open for server requested
483 RUpsTestSession* sessionToReturn;
484 if(!FindOpenSession(aServerName,foundPos))
486 // if open session for intended server not found it creates a new one
487 COpenSession* sessionToAppend=COpenSession::NewL(aServerName);
488 iArraySessionsInUse.AppendL(sessionToAppend);
489 foundPos = iArraySessionsInUse.Count()-1; // position of new session is last one in array.
491 sessionToReturn = iArraySessionsInUse[foundPos]->iPointerToSession;
493 return sessionToReturn;
497 void CUpsClientStep::CloseSessionL(const TDesC& aServerName)
499 // Finds out if a session is already open for server requested
502 if(!FindOpenSession(aServerName,foundPos))
504 // if a session for this server was not found it leaves.
505 ERR_PRINTF2(_L("%S: The server to be closed was not found"),&iTEFServerName);
506 User::Leave(KErrGeneral);
508 delete iArraySessionsInUse[foundPos]; // deletes instance.
509 iArraySessionsInUse.Remove(foundPos); // removes empty slot
514 void CUpsClientStep::CloseAllOpenSessions()
516 while(iArraySessionsInUse.Count()>0)
517 { // delete and remove first session of array.
518 delete iArraySessionsInUse[0];
519 iArraySessionsInUse.Remove(0);
521 iArraySessionsInUse.Close();
525 void CUpsClientStep::SetTestDataL(TInt aIndex)
527 // Set data for request.
528 iReturnData.iError=KErrNone;
530 iRequestData.iMeasureResponceTime = EFalse;
531 iRequestData.iServiceUid = TUid::Uid(iArraySersToRequest[aIndex].iServiceUID);
533 if(iArraySersToRequest[aIndex].iOpaqueData.CompareF(_L8(""))==0)
535 iRequestData.iOpaquePresent = EFalse;
539 iRequestData.iOpaquePresent = ETrue;
540 iRequestData.iOpaqueData =iArraySersToRequest[aIndex].iOpaqueData;
543 iRequestData.iDestination = iArraySersToRequest[aIndex].iDestination;
544 iRequestData.iCancelRequest = iArraySersToRequest[aIndex].iCancelUpsRequest;
545 iRequestData.iPlatSecPass = iArraySersToRequest[aIndex].iPlatSecPass;
547 // set properties for policy evaluator.
548 if (iArraySersToRequest[aIndex].iPolicyEvaluatorInvoked != 0)
550 //Reset various publisher and suscribe properties for policy evaluator.
551 TInt instance = iArraySersToRequest[aIndex].iPolicyEvaluatorInvoked;
552 iPropertyReader->SetL(instance,KPe_Status,CUpsProperty::EPolicyEvaluator, KUpsPeStatusReset);
553 iPropertyReader->SetL(instance,KPe_ClientSid,CUpsProperty::EPolicyEvaluator, 0);
554 iPropertyReader->SetL(instance,KPe_ServerSid,CUpsProperty::EPolicyEvaluator, 0);
555 TBool leaveEvaluator = iArraySersToRequest[aIndex].iLeaveEvaluator;
556 iPropertyReader->SetL(instance,KPe_Leave,CUpsProperty::EPolicyEvaluator, leaveEvaluator);
557 iPropertyReader->SetL(instance,KPe_Error,CUpsProperty::EPolicyEvaluator, KErrNone);
558 TBool holdEvaluatorOpen = iArraySersToRequest[aIndex].iHoldEvaluatorOpen;
559 iPropertyReader->SetL(instance,KPe_HoldEvaluatorOpen,CUpsProperty::EPolicyEvaluator, holdEvaluatorOpen);
560 TBool forcePrompt = iArraySersToRequest[aIndex].iForcePrompt;
561 iPropertyReader->SetL(instance,KPe_ForcePrompt,CUpsProperty::EPolicyEvaluator, forcePrompt);
562 iPropertyReader->SetL(instance,KPe_EvaluatorInfo,CUpsProperty::EPolicyEvaluator, 0);
565 // set properties for dialog creator.
566 if (iArraySersToRequest[aIndex].iDialogCreatorInvoked != 0)
568 //Reset various publisher and suscribe properties for dialog creator.
569 TInt instance = iArraySersToRequest[aIndex].iDialogCreatorInvoked;
570 iPropertyReader->SetL(instance,KDc_Status,CUpsProperty::EDialogCreator, KUpsDcStatusReset);
571 iPropertyReader->SetL(instance,KDc_ClientSid,CUpsProperty::EDialogCreator, 0);
572 iPropertyReader->SetL(instance,KDc_ServerSid,CUpsProperty::EDialogCreator, 0);
573 TBool dialogLeave = iArraySersToRequest[aIndex].iLeaveDialog ;
574 iPropertyReader->SetL(instance,KDc_Leave,CUpsProperty::EDialogCreator, dialogLeave);
575 iPropertyReader->SetL(instance,KDc_Error,CUpsProperty::EDialogCreator, KErrNone);
576 iPropertyReader->SetL(instance,KDc_UpsRequestedButtons,CUpsProperty::EDialogCreator, 0);
577 TInt buttonToPress = ButtonToInt(iArraySersToRequest[aIndex].iSelectDialogOption);
578 iPropertyReader->SetL(instance,KDc_WhichButtonToPress,CUpsProperty::EDialogCreator, buttonToPress);
579 TBool holdPrepareDialogOpen = iArraySersToRequest[aIndex].iHoldPrepareDialogOpen;
580 iPropertyReader->SetL(instance,KDc_HoldPrepareDialogOpen,CUpsProperty::EDialogCreator, holdPrepareDialogOpen);
581 TBool holdDisplayDialogOpen = iArraySersToRequest[aIndex].iHoldDisplayDialogOpen;
582 iPropertyReader->SetL(instance,KDc_HoldDisplayDialogOpen,CUpsProperty::EDialogCreator, holdDisplayDialogOpen);
583 TBool selectFingerprint = iArraySersToRequest[aIndex].iSelectFingerprint ;
584 iPropertyReader->SetL(instance,KDc_SelectFingerprint,CUpsProperty::EDialogCreator, selectFingerprint);
587 } // End of function.
590 void CUpsClientStep::SetClientStatusCompleteL()
592 * Sets the status of the first policy evaluator invoked by the client to "KUpsClientCompleted" so that
593 * the coordinator step can determine when the step has completely finish and progress in Concurrent mode
595 * NOTE: When using the Coordinator in this manner, ALL requests made to UPS must invoke the same instance
596 * of the Policy Evaluator and Dialog Creator! e.g. Policy Evalutor 1 and Dialog Creator 1
599 TInt requestCount = iArraySersToRequest.Count();
601 for(TInt i=0; i<requestCount; ++i)
603 if (iArraySersToRequest[i].iPolicyEvaluatorInvoked != 0)
605 TInt instance = iArraySersToRequest[i].iPolicyEvaluatorInvoked;
606 iPropertyReader->SetL(instance,KPe_Status,CUpsProperty::EPolicyEvaluator, KUpsClientCompleted);
607 iPropertyReader->SetL(instance,KDc_Status,CUpsProperty::EDialogCreator, KUpsClientCompleted);
614 TUpsDecision CUpsClientStep::StringToTUpsDecision(const TPtrC& aString)
616 if(aString.CompareF(_L("Yes"))==0)
618 return TUpsDecision(EUpsDecYes);
620 else if(aString.CompareF(_L("No"))==0)
622 return TUpsDecision(EUpsDecNo);
624 else if(aString.CompareF(_L("SessionYes"))==0)
626 return TUpsDecision(EUpsDecSessionYes);
630 return TUpsDecision(EUpsDecSessionNo);
632 } // End of function.
635 TPtrC CUpsClientStep::TUpsDecisionToString(TUpsDecision aDecision)
637 if(aDecision == EUpsDecYes)
641 else if(aDecision == EUpsDecNo)
645 else if(aDecision == EUpsDecSessionYes)
647 return _L("SessionYes");
649 else if(aDecision == EUpsDecSessionNo)
651 return _L("SessionNo");
655 return _L("Undefined");
657 } // End of function.
660 TInt CUpsClientStep::ButtonToInt(const TPtrC& aButton)
662 if(aButton.CompareF(_L("Yes"))==0)
666 else if(aButton.CompareF(_L("No"))==0)
670 else if(aButton.CompareF(_L("Always"))==0)
674 else if(aButton.CompareF(_L("SessionYes"))==0)
678 else if(aButton.CompareF(_L("SessionNo"))==0)
682 else if(aButton.CompareF(_L("Never"))==0)
688 } // End of function.
691 TBool CUpsClientStep::CheckResultsL(TInt aIndex)
693 TBool theReturn = ETrue;
695 if(iArraySersToRequest[aIndex].iExpectedError == KErrNone)
697 TUpsDecision expectedDecision = StringToTUpsDecision(iArraySersToRequest[aIndex].iAccessGranted);
698 if(expectedDecision != iReturnData.iDecision)
700 TPtrC decisionReceived(TUpsDecisionToString(iReturnData.iDecision));
701 ERR_PRINTF4(_L("%S: Decision expected: %S ,Decision received: %S"),&iTEFServerName, &iArraySersToRequest[aIndex].iAccessGranted, &decisionReceived);
706 if(iArraySersToRequest[aIndex].iExpectedError != iReturnData.iError)
708 // Incorrect error code returned.
710 ERR_PRINTF3(_L("%S: Error code expected: %d"),&iTEFServerName,iArraySersToRequest[aIndex].iExpectedError);
711 ERR_PRINTF3(_L("%S: Error code Received: %d"),&iTEFServerName,iReturnData.iError);
714 // checks returned properties from dialog creator & policy evaluator.
715 if ( CheckDialogCreatorResultsL(aIndex) == EFalse || CheckPolicyEvaluatorResultsL(aIndex) == EFalse)
720 // display the request duration and check against the ini file value, if supplied
721 INFO_PRINTF3(_L("%S: UPS decision request duration: %u milliseconds"),&iTEFServerName, iReturnData.iRequestDuration);
722 if (iArraySersToRequest[aIndex].iRequestDurationThreshold > 0)
724 // check whether the request duration was too long
725 if (static_cast<TInt>(iReturnData.iRequestDuration) > iArraySersToRequest[aIndex].iRequestDurationThreshold)
727 ERR_PRINTF3(_L("%S: UPS decision request took too long: %u"), &iTEFServerName, iArraySersToRequest[aIndex].iRequestDurationThreshold);
733 } // End of function.
736 TBool CUpsClientStep::CheckDialogCreatorResultsL(TInt aIndex)
738 TBool checkPassed = ETrue;
740 // checks return properties from dialog creator.
741 if (iArraySersToRequest[aIndex].iDialogCreatorInvoked != 0)
743 TInt instanceDia = iArraySersToRequest[aIndex].iDialogCreatorInvoked;
744 TInt dialogError = 0;
745 iPropertyReader->GetL(instanceDia,KDc_Error,CUpsProperty::EDialogCreator, dialogError);
747 // Checks that any error encountered by dialog creator is transmited by UPS to system server
748 if(dialogError != iReturnData.iError && dialogError!=KErrNone)
750 ERR_PRINTF3(_L("%S: Dialog creator found an error: %d"),&iTEFServerName,dialogError);
751 checkPassed = EFalse;
755 iPropertyReader->GetL(instanceDia,KDc_ClientSid,CUpsProperty::EDialogCreator, clientSidDia);
757 if(iExpectedClientSid != clientSidDia)
759 ERR_PRINTF2(_L("%S: Client SID returned by dialog creator is not what is expected"),&iTEFServerName);
760 checkPassed = EFalse;
763 TInt buttonsDisplayed=0;
764 iPropertyReader->GetL(instanceDia,KDc_UpsRequestedButtons,CUpsProperty::EDialogCreator, buttonsDisplayed);
765 TInt32 expectedButtonsDisplayed=iArraySersToRequest[aIndex].iButtonsDisplayed;
766 if(expectedButtonsDisplayed != buttonsDisplayed)
768 ERR_PRINTF2(_L("%S: Incorrect buttons displayed."),&iTEFServerName);
769 ERR_PRINTF3(_L("%S: Buttons displayed expected: %d"),&iTEFServerName,expectedButtonsDisplayed);
770 ERR_PRINTF3(_L("%S: Buttons displayed received: %d"),&iTEFServerName,buttonsDisplayed);
771 checkPassed = EFalse;
775 iPropertyReader->GetL(instanceDia,KDc_ServerSid,CUpsProperty::EDialogCreator, serverSidDia);
777 if(iServerId != serverSidDia)
779 ERR_PRINTF2(_L("%S: Server SID returned by dialog creator is not what is expected"),&iTEFServerName);
780 checkPassed = EFalse;
783 TInt serviceSidDia=0;
784 iPropertyReader->GetL(instanceDia,KDc_ServiceId,CUpsProperty::EDialogCreator, serviceSidDia);
785 if(serviceSidDia != iArraySersToRequest[aIndex].iServiceUID)
787 ERR_PRINTF3(_L("%S: Service ID reported by dialog creator is not what is expected: %d"),&iTEFServerName,serviceSidDia);
788 checkPassed = EFalse;
793 } // End of function.
796 TBool CUpsClientStep::CheckPolicyEvaluatorResultsL(TInt aIndex)
798 TBool checkPassed = ETrue;
800 if (iArraySersToRequest[aIndex].iPolicyEvaluatorInvoked != 0)
802 TInt instanceEva = iArraySersToRequest[aIndex].iPolicyEvaluatorInvoked;
803 TInt evaluatorError = 0;
805 // Checks that any error encountered by policy evaluator is transmited by UPS to system server
806 iPropertyReader->GetL(instanceEva,KPe_Error,CUpsProperty::EPolicyEvaluator, evaluatorError);
807 if(evaluatorError != iReturnData.iError && evaluatorError!=KErrNone)
809 ERR_PRINTF3(_L("%S: Policy evaluator found an error: %d"),&iTEFServerName,evaluatorError);
810 checkPassed = EFalse;
814 iPropertyReader->GetL(instanceEva,KPe_ClientSid,CUpsProperty::EPolicyEvaluator, clientSidEva);
816 if(iExpectedClientSid != clientSidEva)
818 ERR_PRINTF2(_L("%S: Client SID returned by policy evaluator is not what is expected"),&iTEFServerName);
819 checkPassed = EFalse;
823 iPropertyReader->GetL(instanceEva,KPe_ServerSid,CUpsProperty::EPolicyEvaluator, serverSidEva);
825 if(iServerId != serverSidEva)
827 ERR_PRINTF2(_L("%S: Server SID returned by policy evaluator is not what is expected"),&iTEFServerName);
828 checkPassed = EFalse;
831 TInt serviceSidEva = 0;
832 iPropertyReader->GetL(instanceEva,KPe_ServiceId,CUpsProperty::EPolicyEvaluator, serviceSidEva);
833 if(serviceSidEva != iArraySersToRequest[aIndex].iServiceUID)
835 ERR_PRINTF3(_L("%S: Service ID reported by policy evaluator is not what is expected: %d"),&iTEFServerName,serviceSidEva);
836 checkPassed = EFalse;
838 if( iArraySersToRequest[aIndex].iForcePrompt)
840 // Read evaluator info
841 TInt evaluatorInfo = 0;
842 iPropertyReader->GetL(instanceEva,KPe_EvaluatorInfo,CUpsProperty::EPolicyEvaluator, evaluatorInfo);
843 if(evaluatorInfo != iArraySersToRequest[aIndex].iExpectedEvaluatorInfo)
845 ERR_PRINTF4(_L("%S: incorrect evaluator info:Expected: %d Received: %d"),&iTEFServerName,iArraySersToRequest[aIndex].iExpectedEvaluatorInfo,evaluatorInfo);
846 checkPassed = EFalse;
852 } // End of function.