telephonyserverplugins/multimodetsy/test/Te_Sms/Te_SmsTestStepBase.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     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 #include "Te_SmsTestStepBase.h"
       
    17 
       
    18 TVerdict CSmsTestStep::doTestStepPreambleL()
       
    19 	{
       
    20 	__UHEAP_MARK;
       
    21 
       
    22 	iTestScheduler=new (ELeave) CActiveScheduler;
       
    23 	CActiveScheduler::Install(iTestScheduler);
       
    24 	
       
    25 	TInt ret = iTelServer.Connect();
       
    26 	if (ret!=KErrNone)
       
    27 		{
       
    28 		INFO_PRINTF1(_L("Failed to connect to telephony server"));
       
    29 		delete iTestScheduler;
       
    30 		User::Leave(ret);
       
    31 		}
       
    32    	ret=iTelServer.LoadPhoneModule(KtsyName);
       
    33 	if (ret!=KErrNone)
       
    34 		{
       
    35 		INFO_PRINTF1(_L("Failed to load phone module"));
       
    36 		iTelServer.Close();
       
    37 		delete iTestScheduler;
       
    38 		User::Leave(ret);
       
    39 		}
       
    40 
       
    41 	CConfigParams* testConfigParams=NULL;
       
    42 	TRAP(ret,testConfigParams=CConfigParams::NewL(KTSSMSConfigFile()));
       
    43 	if (ret!=KErrNone)
       
    44 		{
       
    45 		INFO_PRINTF2(_L("Failed to create config parameters (%d)"), ret);
       
    46 		iTelServer.UnloadPhoneModule(KtsyName);
       
    47 		iTelServer.Close();
       
    48 		delete iTestScheduler;
       
    49 		User::Leave(ret);
       
    50 		}
       
    51 	const TPtrC scanumber = testConfigParams->FindAlphaVar(KTestSCANumber,KNullDesC);
       
    52 	iSCANumber.Copy(scanumber);
       
    53 	const TPtrC simnumber = testConfigParams->FindAlphaVar(KestSimNumber,KNullDesC);
       
    54 	iTelNumber.Copy(simnumber);
       
    55 	delete testConfigParams;
       
    56 
       
    57 	ret=iPhone.Open(iTelServer,KPhoneName);
       
    58 	if (ret!=KErrNone)
       
    59 		{
       
    60 		INFO_PRINTF1(_L("Failed to open phone module"));
       
    61 		iTelServer.UnloadPhoneModule(KtsyName);
       
    62 		iTelServer.Close();
       
    63 		delete iTestScheduler;
       
    64 		User::Leave(ret);
       
    65 		}
       
    66 //
       
    67 //	This test requires a mobile phone to be connected to the serial port
       
    68 //      specified in the .cfg file for the initialise below to work
       
    69 //
       
    70 	ret=iPhone.Initialise();
       
    71 	if (ret!=KErrNone)
       
    72 		{
       
    73 		INFO_PRINTF2(_L("Failed to initialise the phone (%d)"), ret);
       
    74 		iPhone.Close();
       
    75 		iTelServer.UnloadPhoneModule(KtsyName);
       
    76 		iTelServer.Close();
       
    77 		delete iTestScheduler;
       
    78 		User::Leave(ret);
       
    79 		}
       
    80 
       
    81 	ret=iSms.Open(iPhone); 
       
    82 	if (ret!=KErrNone)
       
    83 		{
       
    84 		INFO_PRINTF1(_L("Failed to open SMS"));
       
    85 		iPhone.Close();
       
    86 		iTelServer.UnloadPhoneModule(KtsyName);
       
    87 		iTelServer.Close();
       
    88 		delete iTestScheduler;
       
    89 		User::Leave(ret);
       
    90 		}
       
    91 
       
    92 	return TestStepResult();
       
    93 	}
       
    94 
       
    95 TVerdict CSmsTestStep::doTestStepPostambleL()
       
    96 	{
       
    97 	iSms.Close();
       
    98 	iPhone.Close();
       
    99 	iTelServer.UnloadPhoneModule(KtsyName);
       
   100 	iTelServer.Close();
       
   101 	delete iTestScheduler;
       
   102 
       
   103 	__UHEAP_MARKEND;
       
   104 	User::After(5000000);
       
   105 	return TestStepResult();
       
   106 	}
       
   107 
       
   108 TInt CSmsTestStep::AppendAddressToAscii(TDes8& aAscii,const RMobilePhone::TMobileAddress& aAddress)
       
   109 /**
       
   110  * THIS CODE HAS BEEN COPIED FROM MMTSY\MULTIMODE\SMS\SMSUTIL.CPP
       
   111  *
       
   112  * Default operation is to code Address-Length according to=
       
   113  * 04.11 spec (ie. Address-Length=number of digits in Address-Value).
       
   114  *
       
   115  * @return Standard KErr... values
       
   116  */
       
   117 	{
       
   118 	// Duplicate tel number, removing all the weird chars
       
   119 	TBuf<RMobilePhone::KMaxMobileTelNumberSize> telNumber;
       
   120 	const TInt count(aAddress.iTelNumber.Length());
       
   121 	TInt i;
       
   122 	for(i=0;i<count;++i)
       
   123 		{
       
   124 		if(IsAddressChar(TChar(aAddress.iTelNumber[i])))
       
   125 			telNumber.Append(aAddress.iTelNumber[i]);
       
   126 		}
       
   127 
       
   128 	const TInt telNumberLength(telNumber.Length());
       
   129 	// Validate the size of the supplied SCA
       
   130 
       
   131 	// Calculate the number of ascii chars we'll need
       
   132 	// We need 4 chars to code the Address-Length and Address-Type fields.
       
   133 	// We need to add on an extra 'padding' char if the total number of chars is odd.
       
   134 	const TInt neededAsciiChars=(4+telNumberLength)+(telNumberLength%2);
       
   135 	if((aAscii.MaxLength()-aAscii.Length())<neededAsciiChars)	
       
   136 		return KErrOverflow;
       
   137 	// Code Address-Length
       
   138 	AppendOctet(telNumberLength,aAscii);
       
   139 	// Code Type-Of-Address
       
   140 	TInt typeOfNumber=ConvertTypeOfNumber(aAddress.iTypeOfNumber);
       
   141 	TInt numberingPlan=ConvertNumberingPlan(aAddress.iNumberPlan);
       
   142 	AppendOctet(0x80+(typeOfNumber<<4)+(numberingPlan),aAscii);
       
   143 	// Code Address-Value
       
   144 	TInt highSemiOctet;
       
   145 	TInt lowSemiOctet;
       
   146 	const TInt octets(telNumberLength/2);	// This division will be rounded down
       
   147 	for(i=0;i<octets;++i)
       
   148 		{
       
   149 		// See ETSI 03.40 section 9.1.2.3
       
   150 		// Address digits are coded into octets as pairs.
       
   151 		lowSemiOctet=ConvertAddressChar(TChar(telNumber[i*2]));
       
   152 		highSemiOctet=ConvertAddressChar(TChar(telNumber[(i*2)+1]));
       
   153 		AppendOctet((highSemiOctet<<4)+lowSemiOctet,aAscii);
       
   154 		}
       
   155 	// If number of semi octects is odd then process the final octet
       
   156 	if(telNumberLength%2==1)		
       
   157 		{
       
   158 		lowSemiOctet=ConvertAddressChar(TChar(telNumber[telNumberLength-1]));
       
   159 		AppendOctet(0xf0+lowSemiOctet,aAscii);
       
   160 		}
       
   161 	return KErrNone;
       
   162 	}
       
   163 
       
   164 void CSmsTestStep::AppendOctet(TInt aOctet,TDes8& aAscii)
       
   165 /**
       
   166  * THIS CODE HAS BEEN COPIED FROM MMTSY\MULTIMODE\SMS\SMSUTIL.CPP
       
   167  *
       
   168  * Converts a TInt octet value into ASCII representation and then appends that
       
   169  * ASCII representation to the end of the given ASCII string.
       
   170  *
       
   171  * @param aOctet the octet value to append
       
   172  * @param aAscii the ASCII string to which aOctet value should be appended
       
   173  */
       
   174 	{
       
   175 	// Ensure client has only passed us a octet (ie. low 8 bits only)
       
   176 	aOctet=aOctet&0xff;
       
   177 	// Append octet 
       
   178 	// (prefix '0' if the octets value only uses one digit as final octet coding must use two digits)
       
   179 	if(aOctet<=0x0f)
       
   180 		aAscii.Append(TChar('0'));
       
   181 	aAscii.AppendNum(aOctet,EHex);
       
   182 	}
       
   183 
       
   184 TBool CSmsTestStep::IsAddressChar(TChar aChar)
       
   185 /**
       
   186  * THIS CODE HAS BEEN COPIED FROM MMTSY\MULTIMODE\SMS\SMSUTIL.CPP
       
   187  *
       
   188  * Returns ETrue if, and only if, the given ASCII charcater is valid as an ASCII address character.
       
   189  */
       
   190  	{
       
   191 	if(aChar.IsDigit())
       
   192 		return ETrue;
       
   193 	if(aChar==TChar('*') ||
       
   194 	   aChar==TChar('#') ||
       
   195 	   aChar==TChar('a') ||
       
   196 	   aChar==TChar('b') ||
       
   197 	   aChar==TChar('c'))
       
   198 		return ETrue;
       
   199 	return EFalse;
       
   200 	}
       
   201 
       
   202 TInt CSmsTestStep::ConvertTypeOfNumber(RMobilePhone::TMobileTON aEnum) 
       
   203 /**
       
   204  * THIS CODE HAS BEEN COPIED FROM MMTSY\MULTIMODE\SMS\SMSUTIL.CPP
       
   205  *
       
   206  * @param aEnum must be a RMobile::TMobileTON value 
       
   207  * @return The equivalent ETSI Type-Of-Number value for aEnum
       
   208  */
       
   209 	{
       
   210 	switch(aEnum)
       
   211 		{
       
   212 		// The below 'magic numbers' come from the ETSI 03.40
       
   213 		// specification for Address Fields (section 9.1.2.5)
       
   214 	case RMobilePhone::EInternationalNumber:
       
   215 		return 1;
       
   216 	case RMobilePhone::ENationalNumber:
       
   217 		return 2;
       
   218 	case RMobilePhone::ENetworkSpecificNumber:
       
   219 		return 3;
       
   220 	case RMobilePhone::ESubscriberNumber:
       
   221 		return 4;
       
   222 	case RMobilePhone::EUnknownNumber:
       
   223 	case RMobilePhone::EAbbreviatedNumber:
       
   224 	default:
       
   225 		return 0;
       
   226 		}
       
   227 	}
       
   228 
       
   229 TInt CSmsTestStep::ConvertNumberingPlan(RMobilePhone::TMobileNPI aEnum)  
       
   230 /**
       
   231  * THIS CODE HAS BEEN COPIED FROM MMTSY\MULTIMODE\SMS\SMSUTIL.CPP
       
   232  *
       
   233  * @param aEnum must be a n RMobile::TMobileNPI value 
       
   234  * @return The equivalent ETSI Numbering-Plan-Identification value for aEnum
       
   235  */
       
   236 	{
       
   237 	switch(aEnum)
       
   238 		{
       
   239 		// The below 'magic numbers' come from the ETSI 03.40
       
   240 		// specification for Address Fields (section 9.1.2.5)
       
   241 	case RMobilePhone::EIsdnNumberPlan:
       
   242 		return 1;
       
   243 	case RMobilePhone::EDataNumberPlan:
       
   244 		return 3;
       
   245 	case RMobilePhone::ETelexNumberPlan:
       
   246 		return 4;
       
   247 	case RMobilePhone::ENationalNumberPlan:
       
   248 		return 8;
       
   249 	case RMobilePhone::EPrivateNumberPlan:
       
   250 		return 9;
       
   251 	case RMobilePhone::EUnknownNumberingPlan:
       
   252 	default:
       
   253 		return 0;
       
   254 		}
       
   255 	}
       
   256 
       
   257 TInt CSmsTestStep::ConvertAddressChar(TChar aChar)
       
   258 /**
       
   259  * THIS CODE HAS BEEN COPIED FROM MMTSY\MULTIMODE\SMS\SMSUTIL.CPP
       
   260  *
       
   261  * Returns the equivalent numeric value for a given ASCII address character.
       
   262  *
       
   263  * @param aChar the address character to be converted
       
   264  * @return The numeric value equivalent of the given address character.
       
   265  */
       
   266  	{
       
   267 	aChar.LowerCase();
       
   268 	if(aChar-TChar('0')<=9)  
       
   269 		return aChar-TChar('0');		// Assumes digit characters are one after each other
       
   270 	else if(aChar==TChar('*'))
       
   271 		return 10;
       
   272 	else if(aChar==TChar('#'))
       
   273 		return 11;
       
   274 	else if(aChar==TChar('a'))
       
   275 		return 12;
       
   276 	else if(aChar==TChar('b'))
       
   277 		return 13;
       
   278 	else if(aChar==TChar('c'))
       
   279 		return 14;
       
   280 	return 15;
       
   281 	}
       
   282 
       
   283 void CSmsTestStep::GetSmspListL(RMobileSmsMessaging::TMobileSmspEntryV1& aSmspEntry)
       
   284 /**
       
   285  * This function tests CRetrieveMobilePhoneSmspList
       
   286  */
       
   287 	{
       
   288 	CTestGetSmspList* retrieveSmspList;
       
   289 	CMobilePhoneSmspList* smspList;
       
   290 	retrieveSmspList = CTestGetSmspList::NewLC(iSms);
       
   291 	retrieveSmspList->Start();
       
   292 	CActiveScheduler::Start();
       
   293 	smspList = retrieveSmspList->RetrieveList();
       
   294 	if(!smspList)
       
   295 		return;		// Ooooooooooooops ;-(
       
   296 	TInt count = smspList->Enumerate();
       
   297 	INFO_PRINTF2(_L("SMSP list has %d entries"), count);
       
   298 	TInt i;
       
   299 	for (i=0; i<count; i++)
       
   300 		{
       
   301 		aSmspEntry = smspList->GetEntryL(i);
       
   302 		INFO_PRINTF3(_L("Entry %d: Service Centre = >%S<"),i,&aSmspEntry.iServiceCentre.iTelNumber);
       
   303 		}
       
   304 	CleanupStack::PopAndDestroy(); // retrieveSmspList;
       
   305 	delete smspList;
       
   306 	User::After(1000000);		// Give user time to see the test results 
       
   307 	}
       
   308 
       
   309 void CSmsTestStep::SetSmspListL(RMobileSmsMessaging::TMobileSmspEntryV1& aSmspEntry)
       
   310 /**
       
   311  * This function tests writing service centre address
       
   312  */
       
   313 	{
       
   314 	CMobilePhoneSmspList* smspList = CMobilePhoneSmspList::NewL();
       
   315 	CleanupStack::PushL(smspList);
       
   316 	smspList->AddEntryL(aSmspEntry);
       
   317 	TRequestStatus reqStatus;
       
   318 	iSms.StoreSmspListL(reqStatus, smspList);
       
   319 	User::WaitForRequest(reqStatus);
       
   320 	TEST(reqStatus.Int()==KErrNone);
       
   321 	CleanupStack::PopAndDestroy(); // smspList;
       
   322 	}
       
   323 
       
   324 void CSmsTestStep::PrintMessageStoreCaps(TUint32 aCaps)
       
   325 	{
       
   326 	if(aCaps & RMobilePhoneStore::KCapsReadAccess)
       
   327 		INFO_PRINTF1(_L("Store supports read access"));
       
   328 	if(aCaps & RMobilePhoneStore::KCapsWriteAccess)
       
   329 		INFO_PRINTF1(_L("Store supports write/delete access"));
       
   330 	if(aCaps & RMobilePhoneStore::KCapsDeleteAll)
       
   331 		INFO_PRINTF1(_L("Store supports deleting all entries at once"));
       
   332 	if(aCaps & RMobilePhoneStore::KCapsNotifyEvent)
       
   333 		INFO_PRINTF1(_L("Store supports event notification"));
       
   334 	if(aCaps & static_cast<TUint32>(RMobilePhoneStore::KCapsWholeStore))
       
   335 		INFO_PRINTF1(_L("Store supports reading whole store in a list"));
       
   336 	if(aCaps & RMobilePhoneStore::KCapsIndividualEntry)
       
   337 		INFO_PRINTF1(_L("Store supports reading entries one at a time"));
       
   338 	if(aCaps & RMobileSmsStore::KCapsUnreadMessages)
       
   339 		INFO_PRINTF1(_L("Store contains unread messages"));
       
   340 	if(aCaps & RMobileSmsStore::KCapsReadMessages)
       
   341 		INFO_PRINTF1(_L("Store contains read messages"));
       
   342 	if(aCaps & RMobileSmsStore::KCapsSentMessages)
       
   343 		INFO_PRINTF1(_L("Store contains sent messages"));
       
   344 	if(aCaps & RMobileSmsStore::KCapsUnsentMessages)
       
   345 		INFO_PRINTF1(_L("Store contains unsent messages"));
       
   346 	if(aCaps & RMobileSmsStore::KCapsGsmMessages)
       
   347 		INFO_PRINTF1(_L("Store contains GSM format messages"));
       
   348 	if(aCaps & RMobileSmsStore::KCapsCdmaMessages)
       
   349 		INFO_PRINTF1(_L("Store contains CDMA format messages"));
       
   350 	}
       
   351 
       
   352 TInt CSmsTestStep::SendSms(TBool aQuiet)
       
   353 /**
       
   354  * SendSms test.
       
   355  */
       
   356 	{
       
   357 	_LIT8(KMsgDataBeforeTargetAddress,"1100");
       
   358 	_LIT8(KMsgDataAfterTargetAddress,"0000a705f4f29cde00");
       
   359 
       
   360 	if(!aQuiet) 
       
   361 		INFO_PRINTF1(_L("Sending SMS."));
       
   362 	// Create message PDU and convert to binary 
       
   363 	TBuf8<400> msgData;
       
   364 	TLex8 lex;
       
   365 	TUint8 val;
       
   366 	TInt i;
       
   367 	TInt ret;
       
   368 	msgData.Zero();
       
   369 	const TInt count_before((&KMsgDataBeforeTargetAddress)->Length()/2);	// Assume length of pdu is always even
       
   370 	for(i=0;i<count_before;++i)
       
   371 		{
       
   372 		lex=(&KMsgDataBeforeTargetAddress)->Mid(i*2,2);
       
   373 		ret = lex.Val(val,EHex);					
       
   374 		TEST(ret == KErrNone);
       
   375 		msgData.Append(TChar(val));
       
   376 		}
       
   377 	TBuf8<20> targetAddressAscii;
       
   378 	targetAddressAscii.Zero();
       
   379 	RMobilePhone::TMobileAddress targetAddress;
       
   380 	targetAddress.iTypeOfNumber=RMobilePhone::EInternationalNumber;
       
   381 	targetAddress.iNumberPlan=RMobilePhone::EIsdnNumberPlan;
       
   382 	targetAddress.iTelNumber.Copy(iTelNumber);
       
   383 	ret = AppendAddressToAscii(targetAddressAscii,targetAddress);
       
   384 	TEST(ret == KErrNone);
       
   385 	const TInt count_address(targetAddressAscii.Length()/2);	// Assume length is always even
       
   386 	for(i=0;i<count_address;++i)
       
   387 		{
       
   388 		lex=targetAddressAscii.Mid(i*2,2);
       
   389 		ret = lex.Val(val,EHex);					
       
   390 		TEST(ret == KErrNone);
       
   391 		msgData.Append(TChar(val));
       
   392 		}
       
   393 	const TInt count_after((&KMsgDataAfterTargetAddress)->Length()/2);	// Assume length of pdu is always even
       
   394 	for(i=0;i<count_after;++i)
       
   395 		{
       
   396 		lex=(&KMsgDataAfterTargetAddress)->Mid(i*2,2);
       
   397 		ret = lex.Val(val,EHex);
       
   398 		TEST(ret == KErrNone);
       
   399 		msgData.Append(TChar(val));
       
   400 		}
       
   401 	// Create message attibutes 
       
   402 	RMobileSmsMessaging::TMobileSmsSendAttributesV1	msgAttr;
       
   403 	msgAttr.iFlags=RMobileSmsMessaging::KSmsDataFormat | RMobileSmsMessaging::KGsmServiceCentre;
       
   404 	msgAttr.iDataFormat=RMobileSmsMessaging::EFormatGsmTpdu;
       
   405 	msgAttr.iGsmServiceCentre.iTypeOfNumber=RMobilePhone::EInternationalNumber;
       
   406 	msgAttr.iGsmServiceCentre.iNumberPlan=RMobilePhone::EIsdnNumberPlan;
       
   407 	msgAttr.iGsmServiceCentre.iTelNumber.Copy(iSCANumber);
       
   408 	// Package up data ready for sending to etel
       
   409 	RMobileSmsMessaging::TMobileSmsSendAttributesV1Pckg msgAttrPkg(msgAttr);
       
   410 	// Send the message, try upto 3 times if phone is not ready
       
   411 	TRequestStatus status;
       
   412 	INFO_PRINTF1(_L(".."));
       
   413 	iSms.SendMessage(status,msgData,msgAttrPkg);
       
   414 	User::WaitForRequest(status);
       
   415 	if(status==KErrGsmSMSFailureInME || status==KErrGeneral || status==KErrGsmSMSUnknownError)
       
   416 		{
       
   417 		INFO_PRINTF1(_L(".."));
       
   418 		iSms.SendMessage(status,msgData,msgAttrPkg);
       
   419 		User::WaitForRequest(status);
       
   420 		if(status==KErrGsmSMSFailureInME || status==KErrGeneral || status==KErrGsmSMSUnknownError)
       
   421 			{
       
   422 			INFO_PRINTF1(_L(".."));
       
   423 			iSms.SendMessage(status,msgData,msgAttrPkg);
       
   424 			User::WaitForRequest(status);
       
   425 			}
       
   426 		}	
       
   427 	TEST(status.Int() == KErrNone);
       
   428 	// Validate message reference number has changed 
       
   429 	TEST(msgAttr.iFlags&RMobileSmsMessaging::KMessageReference);
       
   430 	if(!aQuiet) 
       
   431 		INFO_PRINTF1(_L("test(s) passed"));
       
   432 	return(KErrNone);
       
   433 	}
       
   434 
       
   435 void CSmsTestStep::WaitWithTimeout(TRequestStatus& aStatus, TInt aNumberOfMicroSeconds)
       
   436 /**
       
   437  * Timeout function
       
   438  */
       
   439 	{
       
   440 	TRequestStatus timerStatus;
       
   441 	RTimer timer ;
       
   442 	timer.CreateLocal() ;
       
   443 	timer.After(timerStatus,aNumberOfMicroSeconds);
       
   444 
       
   445 	User::WaitForRequest(aStatus, timerStatus);
       
   446 	if (timerStatus == KRequestPending)
       
   447 		{
       
   448 		timer.Cancel();
       
   449 		User::WaitForRequest(timerStatus);
       
   450 		}
       
   451 	else
       
   452 		{
       
   453 		INFO_PRINTF1(_L("Time is over!!!")) ;
       
   454 		}
       
   455 	timer.Close() ;
       
   456 	}
       
   457 
       
   458 CConfigParams* CConfigParams::NewL(const TDesC &aCfgFileName)
       
   459 	{
       
   460 	CConfigParams *f;
       
   461 	f=new (ELeave) CConfigParams();
       
   462 	CleanupStack::PushL(f);
       
   463 	//A leave during the ConstrucL is not fatal, just means there's no param file
       
   464 	TRAP_IGNORE(f->ConstructL(aCfgFileName));
       
   465 	CleanupStack::Pop();
       
   466 	return f;
       
   467 	}
       
   468 
       
   469 void CConfigParams::ConstructL(const TDesC &aCfgFileName)
       
   470 	{
       
   471 	//Find the config file
       
   472 	TAutoClose<RFs> fs;
       
   473 	User::LeaveIfError(fs.iObj.Connect());
       
   474 	fs.PushL();
       
   475 	//Location for the test parameter config file
       
   476 	_LIT(KTinetConfigFilePaths,"\\;\\system\\data\\");
       
   477 	TFindFile filePath(fs.iObj);
       
   478 	User::LeaveIfError(filePath.FindByPath(aCfgFileName,&KTinetConfigFilePaths));
       
   479 	//read the content of the file
       
   480 	TAutoClose<RFile> fl;
       
   481 	fl.PushL();
       
   482 	User::LeaveIfError(fl.iObj.Open(fs.iObj,filePath.File(),EFileShareExclusive));
       
   483 	User::LeaveIfError(fl.iObj.Read(iConfigParamBuf8));
       
   484 	iConfigParamBuf.Copy(iConfigParamBuf8);
       
   485 	CleanupStack::PopAndDestroy(2);
       
   486 	iFileExist = ETrue;
       
   487 	}
       
   488 
       
   489 const TPtrC CConfigParams::FindAlphaVar(const TDesC &aVarName, const TDesC &aDefault)
       
   490 	{
       
   491 	if(!iFileExist)
       
   492 		return TPtrC(aDefault);
       
   493 	TInt pos=iConfigParamBuf.Find(aVarName);
       
   494 	if (pos==KErrNotFound)
       
   495 		return TPtrC(aDefault);
       
   496 	TLex lex(iConfigParamBuf.Mid(pos));
       
   497 	lex.SkipCharacters();
       
   498 	lex.SkipSpaceAndMark();		// Should be at the start of the data
       
   499 	lex.SkipCharacters();
       
   500 	return TPtrC(lex.MarkedToken().Ptr(),lex.MarkedToken().Length());
       
   501 	}
       
   502 
       
   503 TInt CConfigParams::FindNumVar(const TDesC &aVarName, const TInt aDefault)
       
   504 	{
       
   505 	TInt result;
       
   506 	TPtrC ptr = FindAlphaVar(aVarName,KNullDesC);
       
   507 	if(ptr.Length())
       
   508 		{
       
   509 		TLex lex(ptr);
       
   510 		if (lex.Val(result)==KErrNone)
       
   511 			return result;
       
   512 		}
       
   513 	return aDefault;
       
   514 	}
       
   515 
       
   516 /**************************************************************/
       
   517 //
       
   518 // Testing asynchronous retrieve of SMSP list
       
   519 //
       
   520 /**************************************************************/
       
   521 
       
   522 CTestGetSmspList* CTestGetSmspList::NewLC(RMobileSmsMessaging& aSmsMessaging)
       
   523 	{
       
   524 	CTestGetSmspList* r=new(ELeave) CTestGetSmspList(aSmsMessaging);
       
   525 	CleanupStack::PushL(r);
       
   526 	r->ConstructL();
       
   527 	return r;
       
   528 	}
       
   529       
       
   530 CTestGetSmspList::CTestGetSmspList(RMobileSmsMessaging& aSmsMessaging)
       
   531     : CActive(EPriorityNormal), iSmsMessaging(aSmsMessaging)
       
   532     {
       
   533 	}
       
   534       
       
   535 void CTestGetSmspList::ConstructL()
       
   536 	{
       
   537     CActiveScheduler::Add(this);
       
   538 	iRetrieve=CRetrieveMobilePhoneSmspList::NewL(iSmsMessaging);
       
   539     }
       
   540          
       
   541 CTestGetSmspList::~CTestGetSmspList()
       
   542     {
       
   543 	delete iRetrieve;
       
   544 	}
       
   545       
       
   546 void CTestGetSmspList::Start()
       
   547     {
       
   548     iRetrieve->Start(iStatus);
       
   549     SetActive();
       
   550     }       
       
   551 
       
   552 CMobilePhoneSmspList* CTestGetSmspList::RetrieveList()
       
   553 	{
       
   554 	CMobilePhoneSmspList* ptr=NULL;
       
   555 	TRAP_IGNORE(ptr=iRetrieve->RetrieveListL());		// trap but ignore error
       
   556 	return ptr;
       
   557 	}
       
   558           
       
   559 void CTestGetSmspList::RunL()
       
   560     {
       
   561 	TInt ret=iStatus.Int();
       
   562     User::LeaveIfError(ret);
       
   563     CActiveScheduler::Stop();
       
   564 	}
       
   565 
       
   566 void CTestGetSmspList::DoCancel()
       
   567     {
       
   568     iRetrieve->Cancel();
       
   569     }       
       
   570