networkcontrol/ipupsplugins/test/te_ipups/src/te_ipups_ups_step.cpp
branchRCL_3
changeset 22 8d540f55e491
parent 21 abbed5a4b42a
child 23 425d8f4f7fa5
equal deleted inserted replaced
21:abbed5a4b42a 22:8d540f55e491
     1 // Copyright (c) 2008-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  @test
       
    19  @internalComponent - Internal Symbian test code 
       
    20 */
       
    21 
       
    22 #include "te_ipups_ups_step.h"  
       
    23 #include "upstestnotifierproperties.h"
       
    24 #include <s32mem.h> 
       
    25 
       
    26 static TInt ThreadFunction(TAny *)
       
    27 	{
       
    28 	return KErrNone;
       
    29 	}
       
    30 	
       
    31 CIpUpsStep::~CIpUpsStep()
       
    32 /**
       
    33  * Destructor
       
    34  */
       
    35 	{  	
       
    36 	} // End of function
       
    37 
       
    38 
       
    39 CIpUpsStep::CIpUpsStep()
       
    40 /**
       
    41  * Constructor
       
    42  */
       
    43 	{
       
    44 	SetTestStepName(KIpUpsClientStep);
       
    45 	} // End of function
       
    46 
       
    47 
       
    48 TVerdict CIpUpsStep::doTestStepPreambleL()
       
    49 /**
       
    50  * @return - TVerdict code
       
    51  * Override of base class virtual
       
    52  */
       
    53 	{
       
    54 	TSecurityPolicy nullPolicy(ECapability_None);
       
    55     TInt err;
       
    56     
       
    57     //Properties modified to be returned to test harness from test notifier
       
    58     err = RProperty::Define(KUidPSUPSTestNotifCategory, KUnNotifyCount, KUnCountKeyType, nullPolicy, nullPolicy);
       
    59     if (err != KErrAlreadyExists && err != KErrNone)
       
    60     	{
       
    61     	User::LeaveIfError(err);
       
    62     	}
       
    63     
       
    64     err = RProperty::Define(KUidPSUPSTestNotifCategory, KUnNotifyValues, KUnNotifyValuesKeyType, nullPolicy, nullPolicy);
       
    65     if (err != KErrAlreadyExists && err != KErrNone)
       
    66     	{
       
    67     	User::LeaveIfError(err);
       
    68     	}
       
    69     
       
    70     //Properties test notifier requires from test harness about the button press and delay
       
    71     err = RProperty::Define(KUidPSUPSTestNotifCategory, KUtButtonPress, KUtButtonPressKeyType, nullPolicy, nullPolicy);
       
    72     if (err != KErrAlreadyExists && err != KErrNone)
       
    73     	{
       
    74     	User::LeaveIfError(err);
       
    75     	}
       
    76     
       
    77     err = RProperty::Define(KUidPSUPSTestNotifCategory, KUtButtonPressDelay, KUtButtonPressDelayKeyType, nullPolicy, nullPolicy);
       
    78     if (err != KErrAlreadyExists && err != KErrNone)
       
    79     	{
       
    80     	User::LeaveIfError(err);
       
    81     	}
       
    82     
       
    83     //Get the testNotifier working mode, filemode or P&S mode
       
    84     User::LeaveIfError(RProperty::Get(KUidPSUPSTestNotifCategory, KUtFileOverride, iTestNotifierMode));
       
    85     
       
    86     //Set the property to override working of testNotifier in P&S mode instead of filemode
       
    87     User::LeaveIfError(RProperty::Set(KUidPSUPSTestNotifCategory, KUtFileOverride, KFileOverride));
       
    88     
       
    89     //Initialise optional data iNoOfAuthoriseCalls (should be '1' minimum).
       
    90     iNoOfAuthoriseCalls = 1;
       
    91     
       
    92     //Initialise optional data iPromptTriggerCount (Initialising with '-1' means no check if user not specfied in INI file).
       
    93     iPromptTriggerCount = -1;
       
    94     
       
    95     //Read data from INI file
       
    96 	GetHexFromConfig(ConfigSection(), KIpUpsServiceId, iServiceUID);
       
    97 	GetStringFromConfig(ConfigSection(),KIpUpsDestination, iDestination);
       
    98 	GetStringFromConfig(ConfigSection(),KIpUpsOpaqueData, iOpaqueData);
       
    99 	GetStringFromConfig(ConfigSection(),KIpUpsDialogOptionSelection, iDialogOption);
       
   100 	GetBoolFromConfig(ConfigSection(),KIpUpsPlatSecPass, iPlatSecPass);	
       
   101 	GetStringFromConfig(ConfigSection(),KIpUpsExpectedDecision, iExpectedUpsDecision);	
       
   102 	GetIntFromConfig(ConfigSection(),KIpUpsPromptTriggerCount, iPromptTriggerCount);
       
   103     GetIntFromConfig(ConfigSection(),KIpUpsNoOfAuthoriseCalls, iNoOfAuthoriseCalls);    
       
   104     GetBoolFromConfig(ConfigSection(),KIpUpsCancelPromptCall, iCancelPromptCall);
       
   105     
       
   106     GetBoolFromConfig(ConfigSection(),KIpUpsAlwaysOpenNewSession, iAlwaysOpenNewSession);
       
   107         
       
   108     GetBoolFromConfig(ConfigSection(),KIpUpsUseSameSubSession, iUseSameSubSession);
       
   109     GetBoolFromConfig(ConfigSection(),KIpUpsUseSameSubSessionAfterClose, iUseSameSubSessionAfterClose);
       
   110     GetBoolFromConfig(ConfigSection(),KIpUpsAlwaysOpenNewSubSession, iAlwaysOpenNewSubSession);
       
   111     
       
   112     //Keep the initial count of the notifier recorded, should be '0'
       
   113     User::LeaveIfError(RProperty::Get(KUidPSUPSTestNotifCategory, KUnNotifyCount, iNotifyCount));
       
   114     
       
   115 	SetTestStepResult(EPass);	
       
   116 	return TestStepResult();
       
   117 	} // End of function.
       
   118 
       
   119 
       
   120 TVerdict CIpUpsStep::doTestStepL()
       
   121 /**
       
   122  * @return - TVerdict code
       
   123  * Override of base class virtual
       
   124  */
       
   125 	{	
       
   126 	UserPromptService::RUpsSession 		upsSession;
       
   127     UserPromptService::RUpsSubsession 	upsSubSession[KMaxNoOfAuthoriseCalls];
       
   128         
       
   129     RThread dummyThread[KMaxNoOfAuthoriseCalls];
       
   130     TRequestStatus threadStatus; 	
       
   131  	
       
   132  	TInt notifyCountBeforeTest = iNotifyCount;
       
   133  	TInt notifyCountAfterTest = 0;
       
   134 	
       
   135 	TServiceId serviceId = TUid::Uid(iServiceUID);
       
   136 	
       
   137 	TInt subSessionCntr = 0;
       
   138 	
       
   139 	//Repeat call to Authorise as specified in INI file (through NoOfAuthoriseCalls data)
       
   140     for (TInt cntr=0; cntr<iNoOfAuthoriseCalls && cntr<KMaxNoOfAuthoriseCalls; cntr++)
       
   141     	{
       
   142     	if (upsSession.Handle() == KNullHandle)
       
   143     		{
       
   144     		User::LeaveIfError(upsSession.Connect());
       
   145     		INFO_PRINTF1(_L("UPS Session Started."));
       
   146     		}
       
   147     	
       
   148     	if (upsSubSession[subSessionCntr].SubSessionHandle() == KNullHandle)
       
   149     		{
       
   150     		//Create dummy thread with different names
       
   151     		TBuf<32> dummyThreadName;
       
   152     		dummyThreadName.Copy(_L("DummyThread_0123456789"));
       
   153     		
       
   154     		User::LeaveIfError(dummyThread[subSessionCntr].Create(dummyThreadName.Right(dummyThreadName.Length()-subSessionCntr), ThreadFunction, 4096, 4096, 4096, 0, EOwnerThread));
       
   155     		
       
   156 			dummyThread[subSessionCntr].Rendezvous(threadStatus);
       
   157 			dummyThread[subSessionCntr].Resume();
       
   158  			User::WaitForRequest(threadStatus);
       
   159  			
       
   160     		upsSubSession[subSessionCntr] = UserPromptService::RUpsSubsession();
       
   161     		User::LeaveIfError(upsSubSession[subSessionCntr].Initialise(upsSession, dummyThread[subSessionCntr]));
       
   162     		INFO_PRINTF1(_L("UPS SubSession Initialised."));
       
   163     		}
       
   164 		
       
   165 		//Get the dialog option for this iteration (specified in the INI file through 
       
   166 	    //DialogOptionSelection data, separated using KIniFileDelimeter).
       
   167 		TBuf<32> dialogOption;
       
   168 		GetValueAt(cntr, iDialogOption, KIniFileDelimeter, dialogOption);
       
   169 		
       
   170 	    UserPromptService::TPromptResult promptResult;
       
   171 	    promptResult.iSelected = ButtonToOption(dialogOption);
       
   172 	    
       
   173 		TPckg<UserPromptService::TPromptResult> resultPckg(promptResult);
       
   174 		
       
   175 		//Set the Dialog Option selection by user (specifies through DialogOptionSelection data value in INI file).
       
   176 	    User::LeaveIfError(RProperty::Set(KUidPSUPSTestNotifCategory, KUtButtonPress, resultPckg));
       
   177 		User::LeaveIfError(RProperty::Set(KUidPSUPSTestNotifCategory, KUtButtonPressDelay, iCancelPromptCall?1:0));
       
   178 		
       
   179 		INFO_PRINTF2(_L("Dialog Option Selection ( %S )."), &dialogOption);
       
   180 		
       
   181 		//Get the Notify Count BEFORE call to Authorise
       
   182 		User::LeaveIfError(RProperty::Get(KUidPSUPSTestNotifCategory, KUnNotifyCount, notifyCountBeforeTest));
       
   183 		
       
   184 	    TUpsDecision upsDecision;
       
   185 	    TRequestStatus status;
       
   186 	    
       
   187 	    if ( iOpaqueData.Length() > 0 )
       
   188 	    	{	    	
       
   189 	    	HBufC8* converter = HBufC8::NewLC(iOpaqueData.Length());
       
   190 	    	converter->Des().Copy(iOpaqueData);	             
       
   191 	       	iOpaqueDataStored = converter->Ptr();
       
   192 	       	CleanupStack::PopAndDestroy(); //converter
       
   193 	       	
       
   194 	       	INFO_PRINTF1(_L("Opaque data present."));
       
   195 	    	upsSubSession[subSessionCntr].Authorise(iPlatSecPass, serviceId, iDestination, iOpaqueDataStored, upsDecision, status);
       
   196 	    	}
       
   197 	    else
       
   198 	    	{
       
   199 	    	INFO_PRINTF1(_L("Opaque data NOT present."));
       
   200 	    	upsSubSession[subSessionCntr].Authorise(iPlatSecPass, serviceId, iDestination, upsDecision, status);
       
   201 	    	}
       
   202 	    
       
   203 
       
   204 	    if (iCancelPromptCall)
       
   205 	    	{
       
   206 	    	upsSubSession[subSessionCntr].CancelPrompt();
       
   207 	    	INFO_PRINTF1(_L("CancelPrompt called on UPS SubSession."));
       
   208 	    	}
       
   209 	    
       
   210 	    User::WaitForRequest(status);
       
   211 	    
       
   212 	    SetTestStepError(status.Int());
       
   213 	    User::LeaveIfError(status.Int());
       
   214 	    
       
   215 	    //Get the Notify Count AFTER call to Authorise
       
   216 	    User::LeaveIfError(RProperty::Get(KUidPSUPSTestNotifCategory, KUnNotifyCount, notifyCountAfterTest));
       
   217 	    
       
   218 	    INFO_PRINTF3(_L("NotifyCount Before Authorise ( %d ) <> NotifyCount After Authorise ( %d )"), notifyCountBeforeTest, notifyCountAfterTest);
       
   219 	    
       
   220 	    if ( iExpectedUpsDecision.Length() > 0 )
       
   221 	    	{
       
   222 	    	//Get the expected UPS decision for this iteration (specified in the INI file through 
       
   223 	    	//ExpectedUpsDecision data, separated using KIniFileDelimeter).
       
   224 	    	TBuf<32> expectedUpsDecision;
       
   225 	    	GetValueAt(cntr, iExpectedUpsDecision, KIniFileDelimeter, expectedUpsDecision);
       
   226 	    	
       
   227 	    	TPtrC upsDecisionString = TUpsDecisionToString(upsDecision);
       
   228 	    	
       
   229 	    	INFO_PRINTF3(_L("UPS Decision Expected ( %S ) <> UPS Decision Returned ( %S )"), &expectedUpsDecision, &upsDecisionString);
       
   230 	        
       
   231 	    	//Compare the expected and returned UPS decision
       
   232 	    	TEST( expectedUpsDecision.Compare(TUpsDecisionToString(upsDecision)) == 0);
       
   233 	    	}
       
   234 	    
       
   235 		VerifyAndPrintPromptDataL();
       
   236 		
       
   237 		//Check what user requested to do with SubSession for further iterations (if any).
       
   238 		if ( iUseSameSubSession )
       
   239 			{
       
   240 			INFO_PRINTF2(_L("Using UPS SubSession ( %d )."), subSessionCntr);
       
   241 			}
       
   242 		if ( iUseSameSubSessionAfterClose || iAlwaysOpenNewSession )
       
   243 			{
       
   244 			upsSubSession[subSessionCntr].Close();
       
   245 			INFO_PRINTF2(_L("UPS SubSession Closed ( %d )."), subSessionCntr);
       
   246 			dummyThread[subSessionCntr].Close();
       
   247 			}
       
   248 		else if ( iAlwaysOpenNewSubSession )
       
   249 			{
       
   250 			++subSessionCntr;
       
   251 			}
       
   252 			
       
   253 		if ( iAlwaysOpenNewSession  )
       
   254 			{
       
   255 			upsSession.Close();
       
   256 			INFO_PRINTF1(_L("UPS Session Closed."));
       
   257 			}
       
   258 	    } //End - for loop
       
   259      
       
   260     
       
   261     //As with multiple clients , its better not to try to synchronize the calls which change the notify count.
       
   262     //When all the concurrent calls are done , check the count finally through test step notifycount.
       
   263     if (iPromptTriggerCount >= 0)
       
   264     	{
       
   265     	TEST( notifyCountAfterTest == (iNotifyCount+iPromptTriggerCount) );
       
   266     	}    
       
   267     
       
   268     //Ensure all sub sessions are closed
       
   269     for (TInt cntr=0; cntr<subSessionCntr; cntr++)
       
   270     	{
       
   271     	if ( upsSubSession[cntr].SubSessionHandle() != KNullHandle )
       
   272     		{
       
   273     		INFO_PRINTF2(_L("UPS SubSession Closed ( %d )."), cntr);
       
   274     		upsSubSession[cntr].Close();
       
   275     		dummyThread[cntr].Close();
       
   276     		}
       
   277     	}
       
   278     
       
   279     //Ensure session is closed
       
   280     if ( upsSession.Handle() != KNullHandle )
       
   281     	{
       
   282     	upsSession.Close();
       
   283 		INFO_PRINTF1(_L("UPS Session Closed."));
       
   284     	}    
       
   285 	
       
   286 	return TestStepResult();
       
   287 	}  // End of function
       
   288 
       
   289 
       
   290 TVerdict CIpUpsStep::doTestStepPostambleL()
       
   291 /**
       
   292  * @return - TVerdict code
       
   293  * Override of base class virtual
       
   294  */
       
   295 	{
       
   296 	//ReSet the property to specify working of testNotifier in P&S or filemode
       
   297     User::LeaveIfError(RProperty::Set(KUidPSUPSTestNotifCategory, KUtFileOverride, iTestNotifierMode));
       
   298     
       
   299 	return TestStepResult();
       
   300 	} // End of function.
       
   301 
       
   302 TBool CIpUpsStep::VerifyAndPrintPromptDataL()
       
   303 /**
       
   304  * @return - TBool - ETrue of prompt data returned matched the data expected as specified in INI file, else EFalse.
       
   305  * 
       
   306  */
       
   307 	{
       
   308 	//Get the Prompt Information
       
   309 	const TInt KMaxPromptDataLenght = 512;
       
   310     HBufC8* buf=HBufC8::NewLC(KMaxPromptDataLenght);
       
   311     TPtr8 bufPtr(buf->Des());
       
   312 
       
   313 	User::LeaveIfError(RProperty::Get(KUidPSUPSTestNotifCategory, KUnNotifyValues, bufPtr));
       
   314 	
       
   315 	RDesReadStream promptDataStream(bufPtr);
       
   316 		
       
   317 	iPromptData = UserPromptService::CPromptData::NewL();
       
   318 	CleanupStack::PushL(iPromptData);
       
   319 	iPromptData->InternalizeL(promptDataStream);
       
   320 	
       
   321 	INFO_PRINTF2(_L("Client Name ( %S )"), &iPromptData->iClientName);
       
   322 	INFO_PRINTF2(_L("Vendor Name ( %S )"), &iPromptData->iVendorName);
       
   323 	INFO_PRINTF2(_L("Destination ( %S )"), &iPromptData->iDestination);	
       
   324 	INFO_PRINTF2(_L("ClientSid   ( %08x )"), iPromptData->iClientSid.iId);
       
   325 	INFO_PRINTF2(_L("ServerSid   ( %08x )"), iPromptData->iServerSid.iId);
       
   326 	INFO_PRINTF2(_L("ServiceId   ( %08x )"), iPromptData->iServiceId);
       
   327 	
       
   328 	TInt count = iPromptData->iDescriptions.Count();
       
   329    	for (TInt cntr = 0; cntr < count; ++cntr)
       
   330       {
       
   331       INFO_PRINTF3(_L("Descriptions(%d) : %S "), cntr, iPromptData->iDescriptions[cntr]);
       
   332       }	
       
   333 	
       
   334 	//Print Dialog Flags
       
   335 	TBuf<64> dialogFlags;
       
   336 	
       
   337 	if ( iPromptData->iFlags & UserPromptService::ETrustedClient )
       
   338 		{
       
   339 		dialogFlags.Append(_L(" TrustedClient "));
       
   340 		}
       
   341 	if ( iPromptData->iFlags & UserPromptService::EBuiltInApp )
       
   342 		{
       
   343 		dialogFlags.Append(_L(" BuiltInApp "));
       
   344 		}
       
   345 	INFO_PRINTF2(_L("DialogFlags Set to  ( %S )"), &dialogFlags);
       
   346 	
       
   347 	TPtrC expectedDialogOptions;
       
   348 	TBuf<64> bufOptions;
       
   349 	
       
   350 	GetStringFromConfig(ConfigSection(),KExpectedDialogOptions, iExpectedDialogOptions);
       
   351 	
       
   352 	if (iExpectedDialogOptions.Length() > 0)
       
   353 		{
       
   354 		INFO_PRINTF2(_L("Options Expected ( %S )"), &iExpectedDialogOptions);
       
   355 		
       
   356 		//Check if options presented are as expected		
       
   357 		TBool result = OptionsFlagToString(iPromptData->iOptions, bufOptions);		
       
   358 		TEST(result != EFalse);
       
   359 		}
       
   360 	else
       
   361 		{
       
   362 		OptionsFlagToString(iPromptData->iOptions, bufOptions, EFalse);
       
   363 		}
       
   364 	
       
   365 	INFO_PRINTF2(_L("Options Presented ( %S )"), &bufOptions);
       
   366 	
       
   367 	TEST(iPromptData->iServiceId.iUid == iServiceUID);
       
   368 	TEST(iPromptData->iDestination == iDestination);
       
   369 	
       
   370 	CleanupStack::PopAndDestroy(2); //buf, iPromptData
       
   371 	
       
   372 	return EFalse;
       
   373 	} // End of function.
       
   374 
       
   375 TBool CIpUpsStep::OptionsFlagToString(TUint aOptions, TDes& aOptionString, TBool aCheckAgainstExpectedOpt)
       
   376 /** OptionsFlagToString converts the dialog option(s) presented to string and check if the presented option
       
   377  * 	is amongst the one which is expected(from INI file) or not if aCheckAgainstExpectedOpt is set to ETrue.
       
   378  *
       
   379  * @return - TBool - ETrue if presented options are the ones which are expected as specified in the INI file.
       
   380  * 
       
   381  */
       
   382 	{
       
   383 	_LIT(KOptionYes, "Yes");
       
   384 	_LIT(KOptionNo, "No");	
       
   385 	_LIT(KOptionSessionYes, "SessionYes");
       
   386 	_LIT(KOptionAlways, "Always");
       
   387 	_LIT(KOptionNever, "Never");
       
   388 	_LIT(KOptionSessionNo, "SessionNo");
       
   389 	
       
   390 	const TPtrC policyOptions[] = {KOptionYes(), KOptionNo(), KOptionSessionYes(), KOptionAlways(),
       
   391 									KOptionNever(), KOptionSessionNo()};
       
   392 		
       
   393 	TInt optionsCntr = 0;
       
   394 	TBool isOptionExpected = ETrue;
       
   395 		
       
   396 	aOptionString.Append(_L("-"));
       
   397 	
       
   398 	if (aOptions & UserPromptService::CPolicy::EYes)
       
   399 		{
       
   400 		aOptionString.Copy(policyOptions[optionsCntr]);
       
   401 		aOptionString.Append(_L("-"));
       
   402 		
       
   403 		if (aCheckAgainstExpectedOpt)
       
   404 			{
       
   405 			if (iExpectedDialogOptions.FindF(policyOptions[optionsCntr]) == KErrNotFound)
       
   406 				{
       
   407 				isOptionExpected = EFalse;
       
   408 				}
       
   409 			}
       
   410 		}
       
   411 	++optionsCntr;
       
   412 	
       
   413 	if (aOptions & UserPromptService::CPolicy::ENo)
       
   414 		{		
       
   415 		aOptionString.Append(policyOptions[optionsCntr]);
       
   416 		aOptionString.Append(_L("-"));
       
   417 		
       
   418 		if (aCheckAgainstExpectedOpt)
       
   419 			{
       
   420 			if (iExpectedDialogOptions.FindF(policyOptions[optionsCntr]) == KErrNotFound)
       
   421 				{
       
   422 				isOptionExpected = EFalse;
       
   423 				}
       
   424 			}
       
   425 		}
       
   426 	++optionsCntr;
       
   427 	
       
   428 	if (aOptions & UserPromptService::CPolicy::ESessionYes)
       
   429 		{		
       
   430 		aOptionString.Append(policyOptions[optionsCntr]);
       
   431 		aOptionString.Append(_L("-"));
       
   432 		
       
   433 		if (aCheckAgainstExpectedOpt)
       
   434 			{
       
   435 			if (iExpectedDialogOptions.FindF(policyOptions[optionsCntr]) == KErrNotFound)
       
   436 				{
       
   437 				isOptionExpected = EFalse;
       
   438 				}
       
   439 			}
       
   440 		}
       
   441 	++optionsCntr;
       
   442 	
       
   443 	if (aOptions & UserPromptService::CPolicy::EAlways)
       
   444 		{		
       
   445 		aOptionString.Append(policyOptions[optionsCntr]);
       
   446 		aOptionString.Append(_L("-"));
       
   447 		
       
   448 		if (aCheckAgainstExpectedOpt)
       
   449 			{
       
   450 			if (iExpectedDialogOptions.FindF(policyOptions[optionsCntr]) == KErrNotFound)
       
   451 				{
       
   452 				isOptionExpected = EFalse;
       
   453 				}
       
   454 			}
       
   455 		}
       
   456 	++optionsCntr;
       
   457 	
       
   458 	if (aOptions & UserPromptService::CPolicy::ENever)
       
   459 		{		
       
   460 		aOptionString.Append(policyOptions[optionsCntr]);
       
   461 		aOptionString.Append(_L("-"));
       
   462 		
       
   463 		if (aCheckAgainstExpectedOpt)
       
   464 			{
       
   465 			if (iExpectedDialogOptions.FindF(policyOptions[optionsCntr]) == KErrNotFound)
       
   466 				{
       
   467 				isOptionExpected = EFalse;
       
   468 				}
       
   469 			}
       
   470 		}
       
   471 	++optionsCntr;
       
   472 	
       
   473 	if (aOptions & UserPromptService::CPolicy::ESessionNo)
       
   474 		{		
       
   475 		aOptionString.Append(policyOptions[optionsCntr]);
       
   476 		aOptionString.Append(_L("-"));
       
   477 		
       
   478 		if (aCheckAgainstExpectedOpt)
       
   479 			{
       
   480 			if (iExpectedDialogOptions.FindF(policyOptions[optionsCntr]) == KErrNotFound)
       
   481 				{
       
   482 				isOptionExpected = EFalse;
       
   483 				}
       
   484 			}
       
   485 		}
       
   486 		
       
   487 	return isOptionExpected;
       
   488 	} // End of function.
       
   489 
       
   490 /** GetValueAt provides the value of data at a specific index (specified by aPos)
       
   491 *	String containing the values is specified thorugh aArrayString and multiple values 
       
   492 *	are separated by delimeter aDelimeter.
       
   493 *	aValue is returned. 
       
   494 */
       
   495 void CIpUpsStep::GetValueAt(const TInt aPos, const TPtrC& aArrayString, const TChar aDelimeter, TDes& aValue)
       
   496 	{
       
   497 	TInt posCntr=0;	
       
   498 	TInt itemCntr = -1;	
       
   499 	
       
   500 	//Initialise it with blank string to avoid any previous copies
       
   501 	aValue.Copy(_L(""));
       
   502 	
       
   503 	while (posCntr < aArrayString.Length() && itemCntr != aPos)
       
   504 		{
       
   505 		if (aArrayString[posCntr] != aDelimeter)
       
   506 			{
       
   507 			aValue.Append(aArrayString[posCntr]);
       
   508 			}
       
   509 		else
       
   510 			{
       
   511 			++itemCntr;
       
   512 			//Is this the item we are looking for, if not, make space to next one
       
   513 			if (itemCntr != aPos)
       
   514 				{
       
   515 				aValue.Copy(_L(""));
       
   516 				}
       
   517 			}
       
   518 		++posCntr;
       
   519 		}	
       
   520 	}
       
   521 
       
   522 /* TUpsDecisionToString converts TUpsDecision to string.
       
   523 */
       
   524 TPtrC CIpUpsStep::TUpsDecisionToString(TUpsDecision aDecision)
       
   525 	{
       
   526 	if(aDecision == EUpsDecYes)
       
   527 		{
       
   528 		return _L("Yes");
       
   529 		}
       
   530 	else if(aDecision == EUpsDecNo)
       
   531 		{
       
   532 		return _L("No");
       
   533 		}
       
   534 	else if(aDecision == EUpsDecSessionYes)
       
   535 		{
       
   536 		return _L("SessionYes");
       
   537 		}
       
   538 	else if(aDecision == EUpsDecSessionNo)
       
   539 		{
       
   540 		return _L("SessionNo");
       
   541 		}
       
   542 	else 
       
   543 		{
       
   544 		ERR_PRINTF1(_L("Invalid UPS Descision, returning No by default."));
       
   545 		return _L("No");
       
   546 		}
       
   547 	} // End of function.
       
   548 
       
   549 /* TUpsDecisionFromString converts string value to TUpsDecision.
       
   550 */
       
   551 TUpsDecision CIpUpsStep::TUpsDecisionFromString(const TPtrC& aDecision)
       
   552 	{
       
   553 	if(aDecision.CompareF(_L("Yes"))==0)
       
   554 		{
       
   555 		return EUpsDecYes;
       
   556 		}
       
   557 	else if(aDecision.CompareF(_L("No"))==0)
       
   558 		{
       
   559 		return EUpsDecNo;
       
   560 		}
       
   561 	else if(aDecision.CompareF(_L("SessionYes"))==0)
       
   562 		{
       
   563 		return EUpsDecSessionYes;
       
   564 		}
       
   565 	else if(aDecision.CompareF(_L("SessionNo"))==0)
       
   566 		{
       
   567 		return EUpsDecSessionNo;
       
   568 		}
       
   569 	else 
       
   570 		{
       
   571 		ERR_PRINTF1(_L("Invalid UPS Descision, returning No by default."));
       
   572 		return EUpsDecNo;
       
   573 		}
       
   574 	} // End of function.
       
   575 
       
   576 /* ButtonToOption converts string value of button presented to CPolicy::TOptions.
       
   577 */
       
   578 UserPromptService::CPolicy::TOptions CIpUpsStep::ButtonToOption(const TPtrC& aButton)
       
   579 	{
       
   580 	if(aButton.CompareF(_L("Yes"))==0)
       
   581 		{
       
   582 		return UserPromptService::CPolicy::EYes;
       
   583 		}
       
   584 	else if(aButton.CompareF(_L("No"))==0)
       
   585 		{
       
   586 		return UserPromptService::CPolicy::ENo;
       
   587 		}
       
   588 	else if(aButton.CompareF(_L("Session"))==0)
       
   589 		{
       
   590 		return UserPromptService::CPolicy::ESession;
       
   591 		}
       
   592 	else if(aButton.CompareF(_L("SessionYes"))==0)
       
   593 		{
       
   594 		return UserPromptService::CPolicy::ESessionYes;
       
   595 		}
       
   596 	else if(aButton.CompareF(_L("Always"))==0)
       
   597 		{
       
   598 		return UserPromptService::CPolicy::EAlways;
       
   599 		}	
       
   600 	else if(aButton.CompareF(_L("Never"))==0)
       
   601 		{
       
   602 		return UserPromptService::CPolicy::ENever;
       
   603 		}
       
   604 	else if(aButton.CompareF(_L("SessionNo"))==0)
       
   605 		{
       
   606 		return UserPromptService::CPolicy::ESessionNo;
       
   607 		}	
       
   608 	else 
       
   609 		{
       
   610 		ERR_PRINTF1(_L("Invalid Button Option, returning Policy Option No by default."));
       
   611 		return UserPromptService::CPolicy::ENo;
       
   612 		}				
       
   613 	}  // End of function.