telephonyserverplugins/simtsy/src/CSimPhone.cpp
changeset 0 3553901f7fa8
child 9 962e6306d9d2
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2001-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 // This file contains the implementation for the Simulator Phone class 'CSimPhone'
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20 */
       
    21 
       
    22 #include <testconfigfileparser.h>
       
    23 #include "CSimPhone.h"
       
    24 #include "CSimCall.h"
       
    25 #include "csimsmsmess.h"
       
    26 #include "CSimPhBkStore.h"
       
    27 #include "CSimPhBkUsimStore.h"
       
    28 #include "CSimONStore.h"
       
    29 #include "CSimSignalStrength.h"
       
    30 #include "CSimNetworkStatus.h"
       
    31 #include "CSimDtmf.h"
       
    32 #include "CSimIndicator.h"
       
    33 #include "utils.h"
       
    34 #include "Simlog.h"
       
    35 #include "CSimPacketService.h"
       
    36 #include "CSimSat.h"
       
    37 #include "CSimBatteryCharger.h"
       
    38 #include "CSimCallBarring.h"
       
    39 #include "CSimCallForwarding.h"
       
    40 #include "CSimCallWaiting.h"
       
    41 #include "CSimPhoneInitialise.h"
       
    42 #include "CSimPhoneIMSAuth.h"
       
    43 #include "CSimTsyMode.h"
       
    44 #include "csimsmartcardauth.h"
       
    45 #include "csimsmartcardeap.h"
       
    46 
       
    47 #include "simtsyglobalproperties.h"
       
    48 #include "et_struct.h"
       
    49 
       
    50 
       
    51 #define PDD_NAME _L("ECDRV")				// < Name of the WINS Serial Physical Device Driver
       
    52 #define LDD_NAME _L("ECOMM")				// < Name of the WINS Serial Logical Device Driver
       
    53 
       
    54 const TInt KPhBkUSimStoreGranularity=5;		// < The granularity of the phonebook store list array.
       
    55 const TInt KPhonebookStoreGranularity=2;	// < The granularity of the phonebook store list array.
       
    56 
       
    57 GLDEF_C void SimPanic(TSimPanic aPanicNumber, TInt aLineNumber)
       
    58 	{
       
    59 	LOGPHONE3("SMS.TSY Panic %d Line %d", aPanicNumber, aLineNumber);
       
    60 	(void) aLineNumber;
       
    61 	_LIT(panicText,"SIM.TSY");
       
    62 	User::Panic(panicText,aPanicNumber);
       
    63 	}
       
    64 
       
    65 //
       
    66 // CSimPhone
       
    67 //
       
    68 void CSimPhone::CloseObj(TAny* aObj)
       
    69 /**
       
    70 *	A utility function for cleaning up the stack.
       
    71 *
       
    72 * @param aObj a pointer to the CObject to close
       
    73 */
       
    74 	{
       
    75 	((CObject*)aObj)->Close();
       
    76 	}
       
    77 
       
    78 CSimPhone* CSimPhone::NewL(CPhoneBase*& aPhoneBaseRef)
       
    79 /**
       
    80 * Standard two phase constructor.
       
    81 *
       
    82 * @return CSimPhone  pointer to the phone object created
       
    83 * @leave Leaves if no memory or object is not created for any reason
       
    84 */
       
    85 	{
       
    86 	CSimPhone* phone=new(ELeave) CSimPhone(aPhoneBaseRef);
       
    87 	TCleanupItem newPhoneClose(CloseObj,phone);
       
    88 	CleanupStack::PushL(newPhoneClose);
       
    89 	phone->ConstructL();
       
    90 	CleanupStack::Pop();
       
    91 	
       
    92 	aPhoneBaseRef = phone;
       
    93 	
       
    94 	return phone;
       
    95 	}
       
    96 
       
    97 CSimPhone::CSimPhone(CPhoneBase*& aPhoneBaseRef)
       
    98 			: iPhoneBaseRef(aPhoneBaseRef),
       
    99 			  iAPNServiceOffset(4),
       
   100 			  iUSIMServiceTable(NULL),
       
   101 			  iUSIMEnabledServiceTable(NULL),
       
   102 			  iSIMServiceTable(NULL),
       
   103 			  iModemDetection(RPhone::EDetectedPresent),
       
   104 			  iMode(RPhone::EModeIdle), 
       
   105 			  iNtwkMode(RMobilePhone::ENetworkModeUnknown)
       
   106 	{
       
   107 	iPhoneId.iError = KErrNotSupported;
       
   108 	}
       
   109 	
       
   110 /**
       
   111 * A utility function for reading the service tables and setting them up
       
   112 *
       
   113 * @param aMaxSupported size of table supported by etelmm
       
   114 * @param aLookup config file reference to the table to be looked up
       
   115 * @param pTable pointer to the table to be constructed for the config file table
       
   116 * @return void does not return anything
       
   117 */	
       
   118 void CSimPhone::PopulateServiceTableL(	TInt aMaxSupported, 
       
   119 										const TDesC8& aLookup, 
       
   120 										RMobilePhone::TMobilePhoneServiceTableV1** aTable)
       
   121 	{
       
   122 
       
   123 	RMobilePhone::TMobilePhoneServiceTableV1* pTable = NULL;
       
   124 	pTable = new(ELeave) RMobilePhone::TMobilePhoneServiceTableV1();
       
   125 	
       
   126 	// USIM Supported entry's
       
   127 	const CTestConfigItem* item=CfgFile()->Item(aLookup);
       
   128 	if (item)
       
   129 		{	
       
   130 		TInt count = CTestConfig::CountElements(item->Value(),KStdDelimiter);
       
   131 		for (TInt i= 0; i< count; i++)
       
   132 			{
       
   133 			TInt entry = 0;			
       
   134 			TUint8* pTableEntry = &(pTable->iServices1To8);		
       
   135 				
       
   136 			TInt ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,entry);
       
   137 			if(ret == KErrNone && entry < (aMaxSupported+1)) // This is the maximum supported services by etelmm.h
       
   138 				{
       
   139 					TUint8 basic = 0x01;
       
   140 					pTableEntry += ((entry-1)/8);
       
   141 					*pTableEntry |= (basic << ((entry-1)%8));
       
   142 				}
       
   143 			}
       
   144 			*aTable = pTable;	
       
   145 			LOGPHONE2("Successfully populated %s table in simtsy", &aLookup);	
       
   146 		}
       
   147 	else	
       
   148 		{
       
   149 		delete(pTable);
       
   150 		pTable = NULL;
       
   151 		LOGPHONE2("Failed to populat %s table in simtsy", &aLookup);			
       
   152 		}
       
   153 	}
       
   154 
       
   155 /**
       
   156  * A utility function for reading the USIM V8 service tables and setting them up
       
   157  *
       
   158  * @param aTableV8 pointer to the table to be constructed for the config file table
       
   159  * @param aLookup config file reference to the table to be looked up
       
   160  * @return void does not return anything
       
   161  */	
       
   162  void CSimPhone::PopulateServiceTableV8L(const TDesC8& aLookup,RMobilePhone::TMobilePhoneServiceTableV8** aTableV8)
       
   163  	{
       
   164 
       
   165   	RMobilePhone::TMobilePhoneServiceTableV8* pTable = NULL;
       
   166  	pTable = new(ELeave) RMobilePhone::TMobilePhoneServiceTableV8();
       
   167  	
       
   168  	TInt aMaxSupportedV1 = 56;
       
   169  	TInt aMaxSupportedV8 = 72;
       
   170  	// USIM Supported entry's for V8
       
   171  	
       
   172  	const CTestConfigItem* item=CfgFile()->Item(aLookup);
       
   173  	if (item)
       
   174  		{	
       
   175  		TInt count = CTestConfig::CountElements(item->Value(),KStdDelimiter);
       
   176  		for (TInt i= 0; i< count; i++)
       
   177  			{
       
   178  			TInt entry = 0;			
       
   179  			TUint8* pTableEntry = &(pTable->iServices57To64);		
       
   180  				
       
   181  			TInt ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,entry);
       
   182  			if(ret == KErrNone &&  entry > (aMaxSupportedV1) && entry < (aMaxSupportedV8 +1)) // This is the maximum supported services by etelmm.h
       
   183  				{
       
   184  					entry -= aMaxSupportedV1;
       
   185  					TUint8 basic = 0x01;
       
   186  					pTableEntry += ((entry-1)/8);
       
   187  					*pTableEntry |= (basic << ((entry-1)%8));
       
   188  				}
       
   189  			}
       
   190  			*aTableV8 = pTable;	
       
   191  			LOGPHONE2("Successfully populated %s table in simtsy", &aLookup);	
       
   192  		}
       
   193  	else	
       
   194  		{
       
   195  		delete(pTable);
       
   196  		pTable = NULL;
       
   197  		LOGPHONE2("Failed to populate %s table in simtsy", &aLookup);			
       
   198  		}
       
   199  	}
       
   200 
       
   201 void CSimPhone::ConstructL()
       
   202 /**
       
   203 * 2 Phase Construction (Second phase)
       
   204 * Loads the WINS Physical and Logical Serial Device Drivers.  C32 loads the non-WINS
       
   205 * serial drivers, so we don't have to worry about these.
       
   206 * Creates Voice (CSimVoiceLine) and Data lines (CSimDataLine), CConfigReader objects,
       
   207 * CSimSysAgent objects, CSimSmsMessaging object, CSimPhoneStore object,
       
   208 * CSimPhoneBook object, and CSimPacketService object.
       
   209 */
       
   210 	{
       
   211 #if defined (__WINS__)
       
   212 	TInt r=User::LoadPhysicalDevice(PDD_NAME);
       
   213 	r=User::LoadLogicalDevice(LDD_NAME);
       
   214 #endif
       
   215 
       
   216 	LOGPHONE1("Starting to Load and Parse the Config File");
       
   217 	(void)User::LeaveIfError(iFs.Connect());
       
   218 	iConfigFile=CTestConfig::NewLC(iFs,KConfigFileDir,KConfigFilename);
       
   219 
       
   220 	TInt testNumber;
       
   221 	(void)User::LeaveIfError(GetTestNumber(testNumber));
       
   222 	iSectionName.Format(KSectionNameFormat,testNumber);
       
   223 	if(iConfigFile->Section(iSectionName)==NULL)
       
   224 		{
       
   225 		CleanupStack::Pop();
       
   226 		User::Leave(KErrNotFound);
       
   227 		}
       
   228 	else
       
   229 		{
       
   230 		(void)User::LeaveIfError(SetTestNumberInUse(testNumber));
       
   231 		}
       
   232 	CleanupStack::Pop();	// iConfigFile pointer is safely stored as a member variable
       
   233 
       
   234 	CSimTsyMode::InitL(this);
       
   235 
       
   236 	iReduceTimers = CSimReduceTimers::NewL();
       
   237 
       
   238 	InitPhoneStatus();
       
   239 	iSimPhoneInitialise = CSimPhoneInitialise::NewL(this);
       
   240 
       
   241 	if (CSimTsyMode::GetMode() != CSimTsyMode::ECdmaV1)
       
   242 		{
       
   243 		iVoiceLine = CSimVoiceLine::NewL(this,KVoiceLineName);
       
   244 		iDataLine = CSimDataLine::NewL(this,KDataLineName);
       
   245 		iSmsMessaging = CSimSmsMessaging::NewL(this);
       
   246 		iPhoneSecurity = CSimPhoneSecurity::NewL(this);
       
   247 		iPhoneUSimApp = CSimPhoneUSimApp::NewL(this);
       
   248 		iPhoneSmartCardApp = CSimPhoneSmartCardApp::NewL(this);
       
   249 		iPhoneScAuth = CSimSmartCardAuth::NewL(this);
       
   250 
       
   251 		iPhBkStores=new(ELeave) CArrayFixFlat<CSimPhBkStore*>(KPhonebookStoreGranularity);
       
   252 		iPhBkUSimStores=new(ELeave) CArrayFixFlat<CSimPhBkUSimStore*>(KPhBkUSimStoreGranularity);
       
   253 
       
   254 		FindAndCreatePhBkStoresL();
       
   255 		CreateONStoreL();
       
   256 
       
   257 		iSignalStrength=CSimSignalStrength::NewL(this);
       
   258 		iNetworkStatus=CSimNetworkStatus::NewL(this);
       
   259 		iDtmf=CSimDtmf::NewL(this);
       
   260 
       
   261 		}
       
   262 		
       
   263 	const TInt capacityServiceTable =  56;
       
   264 	PopulateServiceTableL(capacityServiceTable,KUSIMServiceTableSupportedEntrys(),	&iUSIMServiceTable);
       
   265 	PopulateServiceTableL(capacityServiceTable,USIMServiceTableEnabledEntrys(), &iUSIMEnabledServiceTable);
       
   266 	PopulateServiceTableL(capacityServiceTable,KSIMServiceTable(),	&iSIMServiceTable);
       
   267 		
       
   268 	/* Updating the V8 features */
       
   269 	PopulateServiceTableV8L(KUSIMServiceTableSupportedEntrys(),&iUSIMServiceTableV8);
       
   270 	
       
   271 	if (ServiceEnabled(iUSIMServiceTable,iAPNServiceOffset,RMobilePhone::KUstACL))
       
   272 		{
       
   273 		TInt entries = 0;
       
   274 		const CTestConfigItem* aPNListItem=CfgFile()->Item(KAccessPointNameList);
       
   275 		if (aPNListItem)
       
   276 			{
       
   277 			TInt ret=CTestConfig::GetElement(aPNListItem->Value(),KStdDelimiter,0,entries);
       
   278 			if(ret == KErrNone && entries > 0)
       
   279 				{
       
   280 				for (TInt i= 0;i< entries;i++)
       
   281 					{
       
   282 					RMobilePhone::TAPNEntryV3 entry;
       
   283 					entry.iApn.Zero();
       
   284 					TPtrC8 startupAPNList;
       
   285 					ret=CTestConfig::GetElement(aPNListItem->Value(),KStdDelimiter,i+1,startupAPNList);
       
   286 					entry.iApn.Copy(startupAPNList);
       
   287 					iAPNList.Append(entry);	
       
   288 					}
       
   289 				}
       
   290 			}			
       
   291 		}
       
   292 
       
   293 	TPtrC8 IMSI;
       
   294 	iSubscriberId.iError = KErrNone;
       
   295 	const CTestConfigItem* item=CfgFile()->Item(KSubscriberId);
       
   296     if (item)
       
   297         {
       
   298         TInt ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,IMSI);
       
   299         if(ret!=KErrNone)
       
   300             LOGPARSERR("IMSI",ret,0,&KSubscriberId);
       
   301         // coverity[check_return]
       
   302         CTestConfig::GetElement(item->Value(),KStdDelimiter,1,iSubscriberId.iError);
       
   303         iSubscriberId.iIMSI.Copy(IMSI);
       
   304         }
       
   305 	else
       
   306 		iSubscriberId.iIMSI.Copy(KSubscriberIdDefault);
       
   307 
       
   308 	iNtwkMode=(RMobilePhone::TMobilePhoneNetworkMode)CfgFile()->ItemValue(KNetworkMode,KNetworkModeDefault);
       
   309 	//get phone id from config file
       
   310 	GetPhoneIdAndCaps();
       
   311 
       
   312 	LOGPHONE1("Loading the version configuration");
       
   313 	iSimTsyVersion = CfgFile()->ItemValue(KTsyVersionNumber,KSimTsyDefaultVersion);
       
   314 	LOGPHONE2("Simulated SIMTSY version: %d", iSimTsyVersion);
       
   315 	
       
   316 	iPacketService = CSimPacketService::NewL(this);
       
   317 	iBatteryCharger = CSimBatteryCharger::NewL(this);
       
   318 	iSat = CSimSat::NewL(this);
       
   319 	iIndicator = CSimIndicator::NewL(this);
       
   320 	iPhoneIMSAuth = CSimPhoneIMSAuth::NewL(this);
       
   321 
       
   322 	iCallBarring=CSimCallBarring::NewL(this);
       
   323 	iCallForwarding=CSimCallForwarding::NewL(this);
       
   324 	iCallWaiting=CSimCallWaiting::NewL(this);
       
   325 	iUsimRelease6=CSimUsimR6::NewL(this);
       
   326 
       
   327 	iNetworkModeArray = new (ELeave) CArrayFixFlat<TNetworkModeBundle>(KGranularity);
       
   328 
       
   329 	iPhoneScEapMan = CSimSmartCardEapManager::NewL(this);
       
   330 
       
   331 	iNetworkModeTimer = CSimTimer::NewL(this);
       
   332 	//< Read in all network mode data
       
   333 	TInt count = CfgFile()->ItemCount(KNetworkMode);
       
   334 	item = NULL;
       
   335 	for (TInt i = 0; i < count; ++i)
       
   336 		{
       
   337 		item = CfgFile()->Item(KNetworkMode,i);
       
   338 		if (!item)
       
   339 			break;
       
   340 		
       
   341 		TInt duration(0); 
       
   342 		TInt networkMode(0);
       
   343 		TInt ret = CTestConfig::GetElement(item->Value(),KStdDelimiter,0,duration);
       
   344 		if (ret != KErrNone)
       
   345 			break;
       
   346 		ret = CTestConfig::GetElement(item->Value(),KStdDelimiter,1,networkMode);
       
   347 		if (ret != KErrNone)
       
   348 			break;
       
   349 		RMobilePhone::TMobilePhoneNetworkMode mode;
       
   350 		if(networkMode == 1)
       
   351 			{
       
   352 			mode = RMobilePhone::ENetworkModeUnregistered;
       
   353 			}
       
   354 		else if(networkMode == 2)
       
   355 			{
       
   356 			mode = RMobilePhone::ENetworkModeGsm;
       
   357 			}
       
   358 		else if(networkMode == 3)
       
   359 			{
       
   360 			mode = RMobilePhone::ENetworkModeAmps;
       
   361 			}
       
   362 		else if(networkMode == 6)
       
   363 			{
       
   364 			mode = RMobilePhone::ENetworkModeWcdma;
       
   365 			}
       
   366 		else if(networkMode == 7)
       
   367 			{
       
   368 			mode = RMobilePhone::ENetworkModeTdcdma;
       
   369 			}
       
   370 		else
       
   371 			{
       
   372 			mode = RMobilePhone::ENetworkModeUnknown;
       
   373 			}
       
   374 		TNetworkModeBundle networkModeData;
       
   375 		networkModeData.iDuration = duration;
       
   376 		networkModeData.iNetworkMode = mode;
       
   377 		
       
   378 		TRAP_IGNORE(iNetworkModeArray->AppendL(networkModeData));
       
   379 		}
       
   380 	
       
   381 	if (iNetworkModeArray->Count() != 0)
       
   382 		{
       
   383 		iNetworkModeIndex = 0;
       
   384 		TNetworkModeBundle initialNetworkMode = iNetworkModeArray->At(0);
       
   385 		iNtwkMode = initialNetworkMode.iNetworkMode;		// set to new value if NetworkMode present in config.txt file
       
   386 		iTimerCallBackNetworkMode.SetHandle(this);
       
   387 		iNetworkModeTimer->Start(initialNetworkMode.iDuration, &iTimerCallBackNetworkMode);
       
   388 		}
       
   389 	// end of network mode simulation setup
       
   390 
       
   391 	LOGPHONE1("Completed Loading and Parsing the Config File");
       
   392 	}
       
   393 
       
   394 CSimReduceTimers* CSimPhone::GetReduceTimersSubject()
       
   395 	{
       
   396 	return iReduceTimers;
       
   397 	}
       
   398 
       
   399 TInt CSimPhone::GetTestNumber(TInt& aTestNumber)
       
   400 /**
       
   401  * Retrieve the test number.
       
   402  */
       
   403 	{
       
   404 	TInt  ret = RProperty::Get(KUidPSSimTsyCategory, KPSSimTsyTestNumber, aTestNumber);
       
   405 
       
   406 	if (ret == KErrNone  &&  aTestNumber >= 0)
       
   407 		{
       
   408 		LOGPHONE2("Got system property KUidPSSimTsyCategory/KPSSimTsyTestNumber. testNumber=%d", aTestNumber);
       
   409 		}
       
   410 	else
       
   411 		{
       
   412 		aTestNumber = KDefaultTestNumber;
       
   413 		}
       
   414 
       
   415 	return KErrNone;
       
   416 	}
       
   417 
       
   418 
       
   419 TInt CSimPhone::SetTestNumberInUse(TInt aTestNumber)
       
   420 /**
       
   421  * Set the test number that is actually used by the TSY
       
   422  */
       
   423 	{
       
   424 	TInt  ret = RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumberInUse, aTestNumber);
       
   425 
       
   426 	if (ret == KErrNone)
       
   427 		{
       
   428 		LOGPHONE2("Set system property KUidPSSimTsyCategory/KPSSimTsyTestNumberInUse. testNumber=%d", aTestNumber);
       
   429 		}
       
   430 
       
   431 	return ret;
       
   432 	}
       
   433 
       
   434 
       
   435 CSimPhone::~CSimPhone()
       
   436 /**
       
   437 * Standard destructor.
       
   438 * Any objects created by the ::ConstructL() function should be destroyed here.
       
   439 * The objects to be destroyed are:
       
   440 * CSimVoiceLine, CSimDataLine, CConfigReader, CSimSysAgent, CSimSmsMessaging
       
   441 * CSimPhoneStore, CSimPhoneBook, CSimPacketService
       
   442 */
       
   443 	{
       
   444 	iPhoneBaseRef = NULL;
       
   445 
       
   446 	delete iNetworkModeTimer;
       
   447 
       
   448 	delete iDtmf;
       
   449 	delete iNetworkStatus;
       
   450 	delete iSignalStrength;
       
   451 	delete iIndicator;
       
   452 	delete iBatteryCharger;
       
   453 	delete iPhoneIMSAuth;
       
   454 	delete iPhoneScEapMan;
       
   455 	delete iPhoneScAuth;
       
   456 	delete iUsimRelease6;
       
   457 	
       
   458 	iFs.Close();
       
   459 	if(iDataLine)
       
   460 		iDataLine->Close();
       
   461 	if(iVoiceLine)
       
   462 		iVoiceLine->Close();
       
   463 	if(iSmsMessaging)
       
   464 		iSmsMessaging->Close();
       
   465 	if(iPhoneSecurity)
       
   466 		iPhoneSecurity->Close();
       
   467 	if(iPhoneUSimApp)
       
   468 		iPhoneUSimApp->Close();
       
   469 	if(iPhoneSmartCardApp)
       
   470 		iPhoneSmartCardApp->Close();
       
   471 			
       
   472 	if (iUSIMServiceTable != NULL)		
       
   473 		delete(iUSIMServiceTable);
       
   474 	if (iUSIMEnabledServiceTable != NULL)		
       
   475 		delete(iUSIMEnabledServiceTable);	
       
   476 	if (iSIMServiceTable != NULL)		
       
   477 		delete(iSIMServiceTable);
       
   478 	if (iUSIMServiceTableV8 != NULL)		
       
   479 		delete(iUSIMServiceTableV8);
       
   480 	
       
   481 	
       
   482 	if(iPhBkStores)
       
   483 		{
       
   484 		TInt storeCount=iPhBkStores->Count();
       
   485 		for(TInt i=0;i<storeCount;i++)
       
   486 			{
       
   487 			iPhBkStores->At(i)->Close();
       
   488 			}
       
   489 		delete iPhBkStores;
       
   490 		}
       
   491 
       
   492 	if(iPhBkUSimStores)
       
   493 	{
       
   494 		TInt storeCount=iPhBkUSimStores->Count();
       
   495 		for(TInt i=0;i<storeCount;i++)
       
   496 			{
       
   497 			iPhBkUSimStores->At(i)->Close();
       
   498 			}
       
   499 		delete iPhBkUSimStores;
       
   500 		}
       
   501 	
       
   502 	if(iONStore)
       
   503 		{
       
   504 		iONStore->Close();
       
   505 		iONStore = NULL;
       
   506 		}
       
   507 	
       
   508 
       
   509 	if (iNetworkModeArray != NULL)
       
   510 		{
       
   511 		iNetworkModeArray->Delete(0,iNetworkModeArray->Count());
       
   512 		delete iNetworkModeArray;
       
   513 		}
       
   514 
       
   515 
       
   516 	if(iPacketService)
       
   517 		iPacketService->Close();
       
   518 
       
   519 	if(iSat)
       
   520 		iSat->Close();
       
   521 	if(iConfigFile)
       
   522 		delete iConfigFile;
       
   523 	if(iCallBarring)
       
   524 		delete iCallBarring;
       
   525 	if (iCallForwarding)
       
   526 		delete iCallForwarding;
       
   527 	if (iCallWaiting)
       
   528 		delete iCallWaiting;
       
   529 
       
   530 	if (iSetCallProcessingSuspendStateTimer)
       
   531 		{
       
   532 		iSetCallProcessingSuspendStateTimer->Cancel();
       
   533 		delete iSetCallProcessingSuspendStateTimer;		
       
   534 		}
       
   535 	delete iSimPhoneInitialise;
       
   536 	
       
   537 	delete iReduceTimers;
       
   538 
       
   539 	CSimTsyMode::FreeMode();
       
   540 	LOGPHONE1("CSimPhone Destroyed");
       
   541 	}
       
   542 
       
   543 void CSimPhone::InitPhoneStatus()
       
   544 	{
       
   545 	const CTestConfigItem* item = NULL;
       
   546 	TInt ret = KErrNone;
       
   547 
       
   548 	LOGPHONE1("Starting to Load and Parse Phone Config parameters");
       
   549 
       
   550 	item = CfgFile()->Item(KPhoneStatus);
       
   551 	if(!item)
       
   552 		return;
       
   553 
       
   554 	TInt modemDetection, mode;
       
   555 	ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, modemDetection);
       
   556 	if (ret == KErrNone)
       
   557 		{
       
   558 		iModemDetection = (RPhone::TModemDetection)modemDetection;
       
   559 		}
       
   560 	ret=CTestConfig::GetElement(item->Value(), KStdDelimiter, 1, mode);
       
   561 	if (ret != KErrNone)
       
   562 		{
       
   563 		iMode = (RPhone::TMode)mode;
       
   564 		}
       
   565 	}
       
   566 
       
   567 void CSimPhone::FindAndCreatePhBkStoresL()
       
   568 	{
       
   569 	TInt count=CfgFile()->ItemCount(KPhBkStore);
       
   570 	const CTestConfigItem* item=NULL;
       
   571 	TInt ret=KErrNone;
       
   572 
       
   573 	LOGPHONE1("Starting to Load and Parse PhoneBookStore Config parameters");
       
   574 	TInt i;
       
   575 	for(i=0;i<count;i++)
       
   576 		{
       
   577 		item=CfgFile()->Item(KPhBkStore,i);
       
   578 		if(!item)
       
   579 			break;
       
   580 
       
   581 		TPtrC8 phonebookName;
       
   582 		TInt maxNumSlots, telNumMaxLen, alphaTagMaxLen;
       
   583 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,phonebookName);
       
   584 		if(ret!=KErrNone)
       
   585 			{
       
   586 			LOGPARSERR("phonebookName",ret,0,&KPhBkStore);
       
   587 			continue;
       
   588 			}
       
   589 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,maxNumSlots);
       
   590 		if(ret!=KErrNone)
       
   591 			{
       
   592 			LOGPARSERR("maxNumSlots",ret,1,&KPhBkStore);
       
   593 			continue;
       
   594 			}
       
   595 
       
   596 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,telNumMaxLen);
       
   597 		if(ret!=KErrNone)
       
   598 			{
       
   599 			LOGPARSERR("telNumMaxLen",ret,2,&KPhBkStore);
       
   600 			continue;
       
   601 			}
       
   602 
       
   603 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,alphaTagMaxLen);
       
   604 		if(ret!=KErrNone)
       
   605 			{
       
   606 			LOGPARSERR("alphaTagMaxLen",ret,3,&KPhBkStore);
       
   607 			continue;
       
   608 			}
       
   609 
       
   610 
       
   611 		CSimPhBkStore* phBkStore=CSimPhBkStore::NewL(this,phonebookName,maxNumSlots,telNumMaxLen,alphaTagMaxLen);
       
   612 		TCleanupItem newObjClose(CloseObj,phBkStore);
       
   613 		CleanupStack::PushL(newObjClose);
       
   614 		iPhBkStores->AppendL(phBkStore);
       
   615 		CleanupStack::Pop();
       
   616 		}
       
   617 
       
   618 
       
   619 	count=CfgFile()->ItemCount(KPhBkUSimStore);
       
   620 
       
   621 	LOGPHONE1("Starting to Load and Parse USim PhoneBookStore Config parameters");
       
   622 
       
   623 	for(i=0;i<count;i++)
       
   624 		{
       
   625 		item=CfgFile()->Item(KPhBkUSimStore,i);
       
   626 		if(!item)
       
   627 			break;
       
   628 
       
   629 		TPtrC8 phonebookName, phonebookStore;
       
   630 		TInt maxNumSlots, telNumMaxLen, alphaTagMaxLen;
       
   631 		TInt additional, maxEmail, maxAdditionalTelNumLen, maxAdditionalTextLen;
       
   632 
       
   633 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,phonebookStore);
       
   634 		if(ret!=KErrNone)
       
   635 			{
       
   636 			LOGPARSERR("phonebookStore",ret,0,&KPhBkUSimStore);
       
   637 			continue;
       
   638 			}
       
   639 
       
   640 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,phonebookName);
       
   641 		if(ret!=KErrNone)
       
   642 			{
       
   643 			LOGPARSERR("phonebookName",ret,1,&KPhBkUSimStore);
       
   644 			continue;
       
   645 			}
       
   646 
       
   647 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,maxNumSlots);
       
   648 		if(ret!=KErrNone)
       
   649 			{
       
   650 			LOGPARSERR("maxNumSlots",ret,2,&KPhBkUSimStore);
       
   651 			continue;
       
   652 			}
       
   653 
       
   654 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,telNumMaxLen);
       
   655 		if(ret!=KErrNone)
       
   656 			{
       
   657 			LOGPARSERR("telNumMaxLen",ret,3,&KPhBkUSimStore);
       
   658 			continue;
       
   659 			}
       
   660 
       
   661 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,4,alphaTagMaxLen);
       
   662 		if(ret!=KErrNone)
       
   663 			{
       
   664 			LOGPARSERR("alphaTagMaxLen",ret,4,&KPhBkUSimStore);
       
   665 			continue;
       
   666 			}
       
   667 
       
   668 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,5,additional);
       
   669 		if(ret!=KErrNone)
       
   670 			{
       
   671 			LOGPARSERR("additional",ret,5,&KPhBkUSimStore);
       
   672 			continue;
       
   673 			}
       
   674 
       
   675 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,6,maxEmail);
       
   676 		if(ret!=KErrNone)
       
   677 			{
       
   678 			LOGPARSERR("maxEmail",ret,6,&KPhBkUSimStore);
       
   679 			continue;
       
   680 			}
       
   681 
       
   682 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,7,maxAdditionalTelNumLen);
       
   683 		if(ret!=KErrNone)
       
   684 			{
       
   685 			LOGPHONE1("WARNING maxAdditionalTelNumLen missing, defaulting to telNumMaxLen");
       
   686 			maxAdditionalTelNumLen = telNumMaxLen;
       
   687 			}
       
   688 	
       
   689 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,8,maxAdditionalTextLen);
       
   690 		if(ret!=KErrNone)
       
   691 			{
       
   692 			LOGPHONE1("WARNING maxAdditionalTextLen missing, defaulting to alphaTagMaxLen");
       
   693 			maxAdditionalTextLen = alphaTagMaxLen;
       
   694 			}
       
   695 
       
   696 		TInt countStores = iPhBkUSimStores->Count();
       
   697 		TBool found=EFalse;
       
   698 
       
   699 		if(phonebookName.Compare(KGsmPhoneBook) == KErrNone)
       
   700 		{
       
   701 		TInt countShort = iPhBkStores->Count();
       
   702 		TBool foundShort=EFalse;
       
   703 
       
   704 			for(TInt j=0; i < countShort; j++)
       
   705 			{
       
   706 				CSimPhBkStore* phBkStore = iPhBkStores->At(j);
       
   707 				if((phBkStore->Name().Compare(phonebookName) == KErrNone))
       
   708 					{
       
   709 					foundShort=ETrue;
       
   710 					break;
       
   711 					}
       
   712 			}
       
   713 			if(foundShort) //warn but not fail!
       
   714 				{
       
   715 				LOGPHONE1("WARNING! PhBkUSimStore and PhBkStore duplicate phonebook configuration");
       
   716 				}
       
   717 		}
       
   718 		for(TInt j=0; j < countStores; j++)
       
   719 			{
       
   720 				CSimPhBkUSimStore* phBkStore = iPhBkUSimStores->At(j);
       
   721 				if((phBkStore->Name().Compare(phonebookName) == KErrNone)&&
       
   722 					(phBkStore->PhBkStore().Compare(phonebookStore) == KErrNone))
       
   723 					{
       
   724 					found=ETrue;
       
   725 					break;
       
   726 					}
       
   727 			}
       
   728 
       
   729 		if(found)    //This store already exists!!!
       
   730 			continue;
       
   731 		
       
   732 		CSimPhBkUSimStore* phBkStore=CSimPhBkUSimStore::NewL(this,phonebookStore,phonebookName,maxNumSlots,telNumMaxLen,alphaTagMaxLen,additional,maxEmail,maxAdditionalTelNumLen,maxAdditionalTextLen);
       
   733 		TCleanupItem newObjClose(CloseObj,phBkStore);
       
   734 		CleanupStack::PushL(newObjClose);
       
   735 		iPhBkUSimStores->AppendL(phBkStore);
       
   736 		CleanupStack::Pop();
       
   737 		}
       
   738 
       
   739 
       
   740 // Populate the Phonebook Stores after construction, so as not to disturb the config file's
       
   741 // search pointer
       
   742 	for(i=0;i<iPhBkStores->Count();i++)
       
   743 		{
       
   744 		iPhBkStores->At(i)->PopulateStoreFromConfigFileL();
       
   745 		}
       
   746 	for(i=0;i<iPhBkUSimStores->Count();i++)
       
   747 		{
       
   748 		iPhBkUSimStores->At(i)->PopulateStoreFromConfigFileL();
       
   749 		}
       
   750 	LOGPHONE1("Finished parsing PhBkStores config parameters");
       
   751 	}
       
   752 
       
   753 void CSimPhone::CreateONStoreL()
       
   754 	{
       
   755 	const CTestConfigItem* item=NULL;
       
   756 	TInt ret=KErrNone;
       
   757 
       
   758 	LOGPHONE1("Starting to Load and Parse Own Number Config parameters");
       
   759 
       
   760 	TInt i=0;
       
   761 	item=CfgFile()->Item(KONStore,i);
       
   762 	if(!item)
       
   763 		return;
       
   764 
       
   765 	TInt maxNumSlots, telNumMaxLen, alphaTagMaxLen;
       
   766 	ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,maxNumSlots);
       
   767 	if(ret!=KErrNone)
       
   768 		{
       
   769 		LOGPARSERR("maxNumSlots",ret,1,&KONStore);
       
   770 		return;
       
   771 		}
       
   772 
       
   773 	ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,telNumMaxLen);
       
   774 	if(ret!=KErrNone)
       
   775 		{
       
   776 		LOGPARSERR("telNumMaxLen",ret,2,&KONStore);
       
   777 		return;
       
   778 		}
       
   779 
       
   780 	ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,alphaTagMaxLen);
       
   781 	if(ret!=KErrNone)
       
   782 		{
       
   783 		LOGPARSERR("alphaTagMaxLen",ret,3,&KONStore);
       
   784 		return;
       
   785 		}
       
   786 
       
   787 	iONStore=CSimONStore::NewL(this,maxNumSlots,telNumMaxLen,alphaTagMaxLen);
       
   788 
       
   789 // Populate the Own Number Store 
       
   790 	iONStore->PopulateStoreFromConfigFileL();
       
   791 
       
   792 	LOGPHONE1("Finished parsing Own Number Store config parameters");
       
   793 	}
       
   794 
       
   795 TInt CSimPhone::ExtFunc(const TTsyReqHandle aReqHandle, const TInt aIpc, const TDataPackage& aPckg)
       
   796 /**
       
   797 * ExtFunc is called by the server when it has a "extended", i.e. non-core ETel request
       
   798 * for the TSY to process.
       
   799 * A request handle, request type and request data are passed to the TSY.
       
   800 */
       
   801 	{
       
   802 	TAny* dataPtr = aPckg.Ptr1();
       
   803 
       
   804 	TAny* dataPtr2 = aPckg.Ptr2();
       
   805 
       
   806 	TInt functionValue;
       
   807 
       
   808 	switch (aIpc)
       
   809 		{
       
   810 	case EMobilePhoneGetMultimodeCaps:
       
   811 		return GetMultimodeCaps(aReqHandle, reinterpret_cast<TUint32*>(dataPtr));
       
   812 
       
   813 	case EMobilePhoneGetIccAccessCaps:
       
   814 		return GetIccAccessCaps(aReqHandle,
       
   815 			REINTERPRET_CAST(TUint32*,dataPtr));
       
   816 
       
   817 	case EMobilePhoneGetPhoneStoreInfo:
       
   818 		switch(aPckg.Type())
       
   819 		{
       
   820 		// Switch between the alternative implementations of GetPhoneStoreInfo
       
   821 		case TDataPackage::EPackage1n2u:
       
   822 			return GetPhoneStoreInfo(aReqHandle,
       
   823 					aPckg.Des1n(),aPckg.Des2u());
       
   824 		case TDataPackage::EPackage1n2n:
       
   825 			return GetPhoneStoreInfo(aReqHandle, aPckg.Des2n(),
       
   826 					REINTERPRET_CAST(RMobilePhone::TPhoneStoreNameAndIccType*, dataPtr));
       
   827 		default:
       
   828 			return NULL;
       
   829 		}
       
   830 
       
   831 
       
   832 //		return GetPhoneStoreInfo(aReqHandle,aPckg.Des1n(),aPckg.Des2u());
       
   833 
       
   834 // Signal Strength
       
   835 	case EMobilePhoneGetSignalCaps:
       
   836 		return iSignalStrength->GetSignalCaps(aReqHandle,aPckg.Des1n());
       
   837 
       
   838 	case EMobilePhoneGetSignalStrength:
       
   839 		return iSignalStrength->GetSignalStrength(aReqHandle,aPckg.Des1n(),aPckg.Des2n());
       
   840 
       
   841 	case EMobilePhoneNotifySignalStrengthChange:
       
   842 		return iSignalStrength->NotifySignalStrengthChange(aReqHandle,aPckg.Des1n(),aPckg.Des2n());
       
   843 
       
   844 // Indicators
       
   845 	case EMobilePhoneGetIndicator:
       
   846 		return iIndicator->GetIndicator(aReqHandle,aPckg.Des1n());
       
   847 
       
   848 	case EMobilePhoneNotifyIndicatorChange:
       
   849 		return iIndicator->NotifyIndicatorChange(aReqHandle,aPckg.Des1n());
       
   850 
       
   851 	case EMobilePhoneGetIndicatorCaps:
       
   852 		return iIndicator->GetIndicatorCaps(aReqHandle,aPckg.Des1n(), aPckg.Des2n());
       
   853 
       
   854 // Battery Charger
       
   855 	case EMobilePhoneGetBatteryInfo:
       
   856 		return iBatteryCharger->GetBatteryInfo(aReqHandle,aPckg.Des1n());
       
   857 
       
   858 	case EMobilePhoneNotifyBatteryInfoChange:
       
   859 		return iBatteryCharger->NotifyBatteryInfoChange(aReqHandle,aPckg.Des1n());
       
   860 
       
   861 	case EMobilePhoneGetBatteryCaps:
       
   862 		return iBatteryCharger->GetBatteryCaps(aReqHandle,aPckg.Des1n());
       
   863 
       
   864 // Network Information
       
   865 	case EMobilePhoneGetNetworkCaps:
       
   866 		return iNetworkStatus->GetNetworkCaps(aReqHandle,aPckg.Des1n());
       
   867 
       
   868 	case EMobilePhoneGetCurrentMode:
       
   869 		return GetCurrentMode(aReqHandle,aPckg.Des1n());
       
   870 
       
   871 
       
   872 	case EMobilePhoneNotifyModeChange:
       
   873 		return NotifyModeChange(aReqHandle,reinterpret_cast<RMobilePhone::TMobilePhoneNetworkMode*>(dataPtr)); 
       
   874 
       
   875 
       
   876 	case EMobilePhoneGetHomeNetwork:
       
   877 		return iNetworkStatus->GetHomeNetwork(aReqHandle,aPckg.Des1n());
       
   878 
       
   879 	case EMobilePhoneGetCurrentNetwork:
       
   880 		return iNetworkStatus->GetCurrentNetwork(aReqHandle,aPckg.Des1n(),aPckg.Des2n());
       
   881 
       
   882 	case EMobilePhoneGetCurrentNetworkNoLocation:
       
   883 		return iNetworkStatus->GetCurrentNetworkNoLocation(aReqHandle,aPckg.Des1n());
       
   884 
       
   885 	case EMobilePhoneNotifyCurrentNetworkChange:
       
   886 		return iNetworkStatus->NotifyCurrentNetworkChange(aReqHandle,aPckg.Des1n(),aPckg.Des2n());
       
   887 
       
   888 	case EMobilePhoneNotifyCurrentNetworkNoLocationChange:
       
   889 		return iNetworkStatus->NotifyCurrentNetworkNoLocationChange(aReqHandle,aPckg.Des1n());
       
   890 
       
   891 	case EMobilePhoneGetNetworkRegistrationStatus:
       
   892 		return iNetworkStatus->GetNetworkRegistrationStatus(aReqHandle,aPckg.Des1n());
       
   893 
       
   894 	case EMobilePhoneNotifyNetworkRegistrationStatusChange:
       
   895 		return iNetworkStatus->NotifyNetworkRegistrationStatusChange(aReqHandle,aPckg.Des1n());
       
   896 	
       
   897 	case EMobilePhoneGetServiceProviderName:
       
   898 		return iNetworkStatus->GetCurrentServiceProvider(aReqHandle,aPckg.Des1n());
       
   899 
       
   900 	case EMobilePhoneGetNetworkName:
       
   901 		return iNetworkStatus->GetCurrentNetworkName(aReqHandle,aPckg.Des1n(), aPckg.Des2n());
       
   902 		
       
   903 //USIM Release6 Infomration
       
   904 	case EMobilePhoneGetMailboxNumbers:
       
   905 		return iUsimRelease6->GetMailboxNumbers(aReqHandle,aPckg.Des1n());
       
   906 		
       
   907 	case EMobilePhoneNotifyMailboxNumbersChange:
       
   908 	 	return iUsimRelease6->NotifyMailboxNumbersChange(aReqHandle,aPckg.Des1n());
       
   909 	 	
       
   910 	case EMobilePhoneNotifyMessageWaiting:
       
   911 		return iUsimRelease6->NotifyMessageWaiting(aReqHandle,REINTERPRET_CAST(TInt*, dataPtr));
       
   912 		
       
   913 	case EMobilePhoneGetIccMessageWaitingIndicators:
       
   914 	 	return iUsimRelease6->GetIccMessageWaitingIndicators(aReqHandle,aPckg.Des1n());
       
   915 	 	
       
   916 	case EMobilePhoneSetIccMessageWaitingIndicators:
       
   917 		return iUsimRelease6->SetIccMessageWaitingIndicators(aReqHandle,aPckg.Des1n());
       
   918 		
       
   919 	case EMobilePhoneNotifyIccMessageWaitingIndicatorsChange:
       
   920 		return iUsimRelease6->NotifyIccMessageWaitingIndicatorsChange(aReqHandle,aPckg.Des1n());
       
   921 	
       
   922 	case EMobilePhoneNotifyWlanDataChange:
       
   923 		return iUsimRelease6->NotifyWlanDataChange(aReqHandle,aPckg.Des1n());
       
   924 	
       
   925 	case EMobilePhoneNotifyPreferredWlanSIDListChange:
       
   926 		return iUsimRelease6->NotifyPreferredWlanSIDListChange(aReqHandle);
       
   927 		
       
   928 	case EMobilePhoneGetWlanData:
       
   929 		return iUsimRelease6->GetWlanData(aReqHandle,aPckg.Des1n());
       
   930 		
       
   931 	case EMobilePhoneSetWlanData:
       
   932 		return iUsimRelease6->SetWlanData(aReqHandle,aPckg.Des1n());
       
   933 	
       
   934 	case EMobilePhoneGetPreferredWlanSIDsPhase1:
       
   935 		return iUsimRelease6->GetPreferredWlanSIDsPhase1(aReqHandle, 
       
   936 			REINTERPRET_CAST(RMobilePhone::TClientId*, dataPtr), 
       
   937 			REINTERPRET_CAST(TInt*, dataPtr2));
       
   938 			
       
   939 	case EMobilePhoneGetPreferredWlanSIDsPhase2:
       
   940 		return iUsimRelease6->GetPreferredWlanSIDsPhase2(aReqHandle, 
       
   941 			REINTERPRET_CAST(RMobilePhone::TClientId*, dataPtr), aPckg.Des2n());		
       
   942 						
       
   943 	case EMobilePhoneStorePreferredWlanSIDList:
       
   944 		return iUsimRelease6->StorePreferredWlanSIDList(aReqHandle, aPckg.Des1n());
       
   945 			
       
   946 	case EMobilePhoneNotifyStorePreferredNetworksListChange:
       
   947 		return iUsimRelease6->NotifyStorePreferredNetworksListChange(aReqHandle);
       
   948 					
       
   949 	case EMobilePhoneGetPreferredNetworksPhase1:
       
   950 		return iUsimRelease6->GetPreferredNetworksPhase1(aReqHandle, 
       
   951 			REINTERPRET_CAST(RMobilePhone::TClientId*, dataPtr), 
       
   952 			REINTERPRET_CAST(TInt*, dataPtr2));
       
   953 
       
   954 	case EMobilePhoneGetPreferredNetworksPhase2:
       
   955 		return iUsimRelease6->GetPreferredNetworksPhase2(aReqHandle, 
       
   956 			REINTERPRET_CAST(RMobilePhone::TClientId*, dataPtr), aPckg.Des2n());		
       
   957 			
       
   958 	case EMobilePhoneStorePreferredNetworksList:
       
   959 		return iUsimRelease6->StorePreferredNetworksList(aReqHandle, aPckg.Des1n());
       
   960 		
       
   961 	case EMobilePhoneSetGbaBootstrapParams:
       
   962 		return iUsimRelease6->SetGbaBootstrapParams(aReqHandle, aPckg.Des1n(),
       
   963 		         reinterpret_cast<RMobilePhone::TAID*>(dataPtr2));
       
   964 	
       
   965 	case EMobilePhoneNotifyAuthenticateDataChange:
       
   966 		return iUsimRelease6->NotifyAuthenticateDataChange(aReqHandle, aPckg.Des1n());
       
   967 	
       
   968 	case EMobilePhoneGetAuthenticationParams:
       
   969 		return iUsimRelease6->GetAuthenticationParams(aReqHandle, aPckg.Des1n(),
       
   970 				aPckg.Des2n());
       
   971 		
       
   972 	case EMobilePhoneAuthenticationListPhase1:
       
   973 		return iUsimRelease6->GetAuthenticationListPhase1(aReqHandle,
       
   974 				REINTERPRET_CAST(CRetrieveMobilePhoneAuthenticationIds::TAuthRequestData*, dataPtr),
       
   975 				REINTERPRET_CAST(TInt*, dataPtr2));
       
   976 		
       
   977 	case EMobilePhoneAuthenticationListPhase2:
       
   978 		return iUsimRelease6->GetAuthenticationListPhase2(aReqHandle, 
       
   979 				REINTERPRET_CAST(RMobilePhone::TClientId*, dataPtr),
       
   980 				aPckg.Des2n());
       
   981 
       
   982 // NITZ Network Information
       
   983 	case EMobilePhoneGetNITZInfo:
       
   984 		return iNetworkStatus->GetNITZInfo(aReqHandle,aPckg.Des1n());
       
   985 
       
   986 	case EMobilePhoneNotifyNITZInfoChange:
       
   987 		return iNetworkStatus->NotifyNITZInfoChange(aReqHandle,aPckg.Des1n());
       
   988 
       
   989 // Cell Information
       
   990 			case EMobilePhoneGetCellInfo:
       
   991 				return iNetworkStatus->GetCellInfo(aReqHandle,aPckg.Des1n());
       
   992 
       
   993 			case EMobilePhoneNotifyCellInfoChange:
       
   994 				return iNetworkStatus->NotifyCellInfoChange(aReqHandle,aPckg.Des1n());
       
   995 
       
   996 // Get Subscriber Info
       
   997 	case EMobilePhoneGetSubscriberId:
       
   998 		return GetSubscriberInfo(aReqHandle,aPckg.Des1n());
       
   999 
       
  1000 // DTMF Tx
       
  1001 	case EMobilePhoneGetDTMFCaps:
       
  1002 		return iDtmf->GetDtmfCaps(aReqHandle,aPckg.Des1n());
       
  1003 
       
  1004 	case EMobilePhoneNotifyDTMFCapsChange:
       
  1005 		return iDtmf->NotifyDtmfCapsChange(aReqHandle,aPckg.Des1n());
       
  1006 
       
  1007 	case EMobilePhoneSendDTMFTones:
       
  1008 		return iDtmf->SendDTMFTones(aReqHandle,aPckg.Des1u());
       
  1009 
       
  1010 	case EMobilePhoneStartDTMFTone:
       
  1011 		return iDtmf->StartDTMFTone(aReqHandle,aPckg.Des1n());
       
  1012 
       
  1013 	case EMobilePhoneStopDTMFTone:
       
  1014 		return iDtmf->StopDTMFTone(aReqHandle);
       
  1015 
       
  1016 	case EMobilePhoneNotifyStopInDTMFString:
       
  1017 		return iDtmf->NotifyStopInDTMFString(aReqHandle);
       
  1018 
       
  1019 	case EMobilePhoneContinueDTMFStringSending:
       
  1020 		return iDtmf->ContinueDtmfStringSending(aReqHandle,aPckg.Des1n());
       
  1021 // Phone ID
       
  1022 	case EMobilePhoneGetIdentityCaps:
       
  1023 		return GetIdentityCaps(aReqHandle,*REINTERPRET_CAST(TUint32*, dataPtr));
       
  1024 
       
  1025 	case EMobilePhoneGetPhoneId:
       
  1026 		return GetPhoneId(aReqHandle,REINTERPRET_CAST(RMobilePhone::TMobilePhoneIdentityV1*, dataPtr));
       
  1027 
       
  1028 // Security (ICC)
       
  1029 
       
  1030 	case EMobilePhoneGetSecurityCaps:
       
  1031 	case EMobilePhoneNotifySecurityCapsChange:
       
  1032 	case EMobilePhoneGetLockInfo:
       
  1033 	case EMobilePhoneNotifyLockInfoChange:
       
  1034 	case EMobilePhoneSetLockSetting:
       
  1035 	case EMobilePhoneChangeSecurityCode:
       
  1036 	case EMobilePhoneNotifySecurityEvent:
       
  1037 	case EMobilePhoneVerifySecurityCode:
       
  1038 	case EMobilePhoneAbortSecurityCode:
       
  1039 	case EMobilePhoneGetSecurityCodeInfo:
       
  1040 	case EMobilePhoneNotifySecurityCodeInfoChange:
       
  1041 		return iPhoneSecurity->ExtFunc(aReqHandle, aIpc, aPckg);
       
  1042 
       
  1043 //USim Application Support
       
  1044 	case EMobilePhoneEnumerateUSimApplications:
       
  1045 	case EMobilePhoneSetUSimApplicationStatus:
       
  1046 	case EMobilePhoneGetUSimApplicationsInfo:
       
  1047 	case EMobilePhoneNotifyUSimApplicationsInfoChange:
       
  1048 		if(iPhoneUSimApp->FoundUSimAppTags())
       
  1049 			{
       
  1050 			return iPhoneUSimApp->ExtFunc(aReqHandle, aIpc, aPckg);
       
  1051 			}
       
  1052 		else
       
  1053 			{
       
  1054 			return iPhoneSmartCardApp->ExtFunc(aReqHandle, aIpc, aPckg);
       
  1055 			}
       
  1056 			
       
  1057 //SmartCard Application Support
       
  1058 	case EMobilePhoneEnumerateSmartCardApplications:
       
  1059 	case EMobilePhoneGetSmartCardApplicationInfo:
       
  1060 	case EMobilePhoneSetSmartCardApplicationStatus:
       
  1061 	case EMobilePhoneNotifySmartCardApplicationInfoChange:
       
  1062 	case EMobilePhoneGetScFileInfo:
       
  1063 	case EMobilePhoneReadScFile:
       
  1064 	case EMobilePhoneUpdateScFile:
       
  1065 		if(iPhoneSmartCardApp->FoundScAppTags())
       
  1066 			{
       
  1067 			return iPhoneSmartCardApp->ExtFunc(aReqHandle, aIpc, aPckg);
       
  1068 			}
       
  1069 		else
       
  1070 			{
       
  1071 			ReqCompleted(aReqHandle, KErrNotSupported);
       
  1072 			return KErrNone;
       
  1073 			}
       
  1074 
       
  1075 		
       
  1076 //USim/SmartCard Application Supoprt
       
  1077 	case EMobilePhoneGetCurrentActiveUSimApplication:
       
  1078 	case EMobilePhoneGetUSimAppsSelectionMode:
       
  1079 	case EMobilePhoneSetUSimAppsSelectionMode:
       
  1080 	case EMobilePhoneNotifyUSimAppsSelectionModeChange:
       
  1081 		if(iPhoneUSimApp->FoundUSimAppTags())
       
  1082 			{
       
  1083 			return iPhoneUSimApp->ExtFunc(aReqHandle, aIpc, aPckg);
       
  1084 			}
       
  1085 		else
       
  1086 			{
       
  1087 			return iPhoneSmartCardApp->ExtFunc(aReqHandle, aIpc, aPckg);
       
  1088 			}		
       
  1089 
       
  1090 // CallBarring
       
  1091 	case EMobilePhoneSetCallBarringStatus:
       
  1092 	case EMobilePhoneSetCallBarringPassword:
       
  1093 	case EMobilePhoneNotifyCallBarringStatusChange:
       
  1094 	case EMobilePhoneGetBarringStatusPhase1:
       
  1095 	case EMobilePhoneGetBarringStatusPhase2:
       
  1096 		return iCallBarring->ExtFunc(aReqHandle, aIpc, aPckg);
       
  1097 
       
  1098 // CallForwarding
       
  1099 	case EMobilePhoneSetCallForwardingStatus:
       
  1100 	case EMobilePhoneNotifyCallForwardingStatusChange:
       
  1101 	case EMobilePhoneGetIdentityServiceStatus:
       
  1102 	case EMobilePhoneGetCallForwardingStatusPhase1:
       
  1103 	case EMobilePhoneGetCallForwardingStatusPhase2:
       
  1104 		return iCallForwarding->ExtFunc(aReqHandle, aIpc, aPckg);
       
  1105 
       
  1106 // CallWaiting
       
  1107 	case EMobilePhoneSetCallWaitingStatus:
       
  1108 	case EMobilePhoneNotifyCallWaitingStatusChange:
       
  1109 	case EMobilePhoneGetWaitingStatusPhase1:
       
  1110 	case EMobilePhoneGetWaitingStatusPhase2:
       
  1111 		{
       
  1112 		functionValue = 0;
       
  1113 		TRAPD(leaveValue, functionValue = iCallWaiting->ExtFuncL(aReqHandle, aIpc, aPckg));
       
  1114 		if (leaveValue != KErrNone)
       
  1115 	 		{
       
  1116  			return leaveValue;
       
  1117  			}
       
  1118 		else
       
  1119  			{
       
  1120  			return functionValue;
       
  1121  			}		
       
  1122 		}
       
  1123 
       
  1124 // IMS Auth
       
  1125 	case EMobilePhoneAuthorizationInfoPhase1:
       
  1126 			return iPhoneIMSAuth->GetAuthorizationInfoPhase1(aReqHandle,
       
  1127 			reinterpret_cast<RMobilePhone::TClientId*>(dataPtr),
       
  1128 			reinterpret_cast<TInt*>(dataPtr2));
       
  1129 
       
  1130 	case EMobilePhoneAuthorizationInfoPhase2:
       
  1131 		return iPhoneIMSAuth->GetAuthorizationInfoPhase2(aReqHandle,
       
  1132 			reinterpret_cast<RMobilePhone::TClientId*>(dataPtr), aPckg.Des2n());
       
  1133 			
       
  1134 	case EMobilePhoneIMSAuthenticate:
       
  1135 		return iPhoneIMSAuth->GetAuthenticationData(aReqHandle, aPckg.Des1n());
       
  1136 
       
  1137 	case EMobilePhoneNotifyImsAuthorizationInfoChanged:
       
  1138 		return iPhoneIMSAuth->NotifyImsAuthorizationInfoChanged(aReqHandle);
       
  1139 
       
  1140 // Generic Smart Card Authentication
       
  1141 	case EMobilePhoneSmartCardAuthenticate:
       
  1142 		return iPhoneScAuth->GetScAuthenticationData(aReqHandle, aPckg.Des1n(),
       
  1143 		         reinterpret_cast<RMobilePhone::TAID*>(dataPtr2));
       
  1144 
       
  1145 // Access Point Name (APN)
       
  1146 	case EMobilePhoneEnumerateAPNEntries:
       
  1147 		{
       
  1148 		TUint32* count = static_cast<TUint32*>(dataPtr);
       
  1149 		return EnumerateAPNEntries(aReqHandle,count);
       
  1150 		}
       
  1151 	
       
  1152 	case EMobilePhoneGetAPNname:
       
  1153 		{
       
  1154 		TUint32 index = *static_cast<TUint32*>(dataPtr);
       
  1155 		
       
  1156 		RMobilePhone::TAPNEntryV3Pckg* entryToReturnPckg = 
       
  1157 			static_cast<RMobilePhone::TAPNEntryV3Pckg*> (aPckg.Des2n());
       
  1158 		
       
  1159 		return GetAPNname(aReqHandle, index, *entryToReturnPckg);
       
  1160 		}
       
  1161 
       
  1162 	case EMobilePhoneAppendAPNName:
       
  1163 		{
       
  1164 		RMobilePhone::TAPNEntryV3 entryToAppend = 
       
  1165 			*static_cast<RMobilePhone::TAPNEntryV3*>(dataPtr);
       
  1166 				
       
  1167 		RMobilePhone::TAPNEntryV3Pckg entryToAppendPckg(entryToAppend);	
       
  1168 		return AppendAPNName(aReqHandle,entryToAppendPckg);
       
  1169 		}
       
  1170 		
       
  1171 	case EMobilePhoneDeleteAPNName:
       
  1172 		{
       
  1173 		TUint32 tmp = *static_cast<TUint32*>(dataPtr);
       
  1174 		
       
  1175 		return DeleteAPNName(aReqHandle,tmp);
       
  1176 		}
       
  1177 	
       
  1178 	case EMobilePhoneNotifyAPNListChanged:
       
  1179 		return NotifyAPNListChanged(aReqHandle);
       
  1180 	
       
  1181 	case EMobilePhoneSetAPNControlListServiceStatus:
       
  1182 		return SetAPNControlListServiceStatus(aReqHandle,
       
  1183 				*static_cast<RMobilePhone::TAPNControlListServiceStatus*>(dataPtr));
       
  1184 	
       
  1185 	case EMobilePhoneGetAPNControlListServiceStatus:
       
  1186 		return GetAPNControlListServiceStatus(aReqHandle,
       
  1187 				*static_cast<RMobilePhone::TAPNControlListServiceStatus*>(dataPtr));
       
  1188 	
       
  1189 	case EMobilePhoneNotifyAPNControlListServiceStatusChange:
       
  1190 		return NotifyAPNControlListServiceStatusChange(aReqHandle,
       
  1191 				*static_cast<RMobilePhone::TAPNControlListServiceStatus*>(dataPtr));
       
  1192 
       
  1193 	case EMobilePhoneGetServiceTable:
       
  1194 		return GetServiceTable(aReqHandle, 
       
  1195 			*static_cast<RMobilePhone::TMobilePhoneServiceTable*>(dataPtr), 
       
  1196 				(aPckg.Des2n()));	
       
  1197 	default:
       
  1198 		ReqCompleted(aReqHandle, KErrNotSupported);
       
  1199 		return KErrNone;		// Real error value returned in completion of clients request
       
  1200 		}
       
  1201 		
       
  1202 	}
       
  1203 
       
  1204 TInt CSimPhone::CancelService(const TInt aIpc,const TTsyReqHandle aTsyReqHandle)
       
  1205 /**
       
  1206  * Cancel an outstanding request.
       
  1207  * @param aIpc The IPC number of the request that must be cancelled.  Note: this is not the
       
  1208  *             IPC number of the cancel request itself.
       
  1209  * @param aTsyReqHandle The TSY Request Handle of the request to be cancelled.
       
  1210  */
       
  1211 	{
       
  1212 	switch(aIpc)
       
  1213 		{
       
  1214 	case EMobilePhoneNotifyIndicatorChange:
       
  1215 		iIndicator->NotifyIndicatorChangeCancel();
       
  1216 		break;
       
  1217 
       
  1218 	case EMobilePhoneNotifyBatteryInfoChange:
       
  1219 		iBatteryCharger->NotifyBatteryInfoCancel();
       
  1220 		break;
       
  1221 
       
  1222 	case EMobilePhoneNotifySignalStrengthChange:
       
  1223 		iSignalStrength->NotifySignalStrengthChangeCancel();
       
  1224 		break;
       
  1225 				
       
  1226 	case EMobilePhoneNotifyNetworkRegistrationStatusChange:
       
  1227 		iNetworkStatus->NotifyNetworkRegistrationStatusChangeCancel();
       
  1228 		break;
       
  1229 
       
  1230 	case EMobilePhoneNotifyCurrentNetworkChange:
       
  1231 		iNetworkStatus->NotifyCurrentNetworkChangeCancel(aTsyReqHandle);
       
  1232 		break;
       
  1233 
       
  1234 	case EMobilePhoneNotifyCurrentNetworkNoLocationChange:
       
  1235 		iNetworkStatus->NotifyCurrentNetworkNoLocationChangeCancel(aTsyReqHandle);
       
  1236 		break;	
       
  1237 
       
  1238 	case EMobilePhoneNotifyNITZInfoChange:
       
  1239 		iNetworkStatus->NotifyNITZInfoChangeCancel();
       
  1240 		break;
       
  1241 
       
  1242 	case EMobilePhoneNotifyCellInfoChange:
       
  1243 		iNetworkStatus->NotifyCellInfoChangeCancel(aTsyReqHandle);
       
  1244 		break;
       
  1245 
       
  1246 	case EMobilePhoneNotifyModeChange:
       
  1247 		NotifyModeChangeCancel(aTsyReqHandle);
       
  1248 		break;
       
  1249 
       
  1250 
       
  1251 // Get Subscriber Info
       
  1252 	case EMobilePhoneSendDTMFTones:
       
  1253 		iDtmf->SendDTMFTonesCancel();
       
  1254 		break;
       
  1255 
       
  1256 	case EMobilePhoneNotifyStopInDTMFString:
       
  1257 		iDtmf->NotifyStopInDTMFStringCancel();
       
  1258 		break;
       
  1259 
       
  1260 	case EMobilePhoneNotifyDTMFCapsChange:
       
  1261 		iDtmf->NotifyDtmfCapsChangeCancel(aTsyReqHandle);
       
  1262 		break;
       
  1263 
       
  1264 	case EMobilePhoneNotifySecurityCapsChange:
       
  1265 	case EMobilePhoneGetLockInfo:
       
  1266 	case EMobilePhoneNotifyLockInfoChange:
       
  1267 	case EMobilePhoneSetLockSetting:
       
  1268 	case EMobilePhoneChangeSecurityCode:
       
  1269 	case EMobilePhoneNotifySecurityEvent:
       
  1270 	case EMobilePhoneVerifySecurityCode:
       
  1271 	case EMobilePhoneAbortSecurityCode:
       
  1272 	case EMobilePhoneGetSecurityCodeInfo:
       
  1273 	case EMobilePhoneNotifySecurityCodeInfoChange:
       
  1274 		return iPhoneSecurity->CancelService(aIpc,aTsyReqHandle);
       
  1275 
       
  1276 //USim Application Support
       
  1277 	case EMobilePhoneEnumerateUSimApplications:
       
  1278 	case EMobilePhoneSetUSimApplicationStatus:
       
  1279 	case EMobilePhoneGetUSimApplicationsInfo:
       
  1280 	case EMobilePhoneNotifyUSimApplicationsInfoChange:
       
  1281 		if(iPhoneUSimApp->FoundUSimAppTags())
       
  1282 			{
       
  1283 			return iPhoneUSimApp->CancelService(aIpc,aTsyReqHandle);
       
  1284 			}
       
  1285 		else
       
  1286 			{
       
  1287 			return iPhoneSmartCardApp->CancelService(aIpc,aTsyReqHandle);
       
  1288 			}
       
  1289 			
       
  1290 //SmartCard Application Support
       
  1291 	case EMobilePhoneEnumerateSmartCardApplications:
       
  1292 	case EMobilePhoneGetSmartCardApplicationInfo:
       
  1293 	case EMobilePhoneSetSmartCardApplicationStatus:
       
  1294 	case EMobilePhoneNotifySmartCardApplicationInfoChange:
       
  1295 	case EMobilePhoneGetScFileInfo:
       
  1296 	case EMobilePhoneReadScFile:
       
  1297 	case EMobilePhoneUpdateScFile:
       
  1298 		if(iPhoneSmartCardApp->FoundScAppTags())
       
  1299 			{
       
  1300 			return iPhoneSmartCardApp->CancelService(aIpc,aTsyReqHandle);
       
  1301 			}
       
  1302 		else
       
  1303 			{
       
  1304 			return CPhoneBase::CancelService(aIpc,aTsyReqHandle);;
       
  1305 			}
       
  1306 
       
  1307 		
       
  1308 //USim/SmartCard Application Supoprt
       
  1309 	case EMobilePhoneGetCurrentActiveUSimApplication:
       
  1310 	case EMobilePhoneGetUSimAppsSelectionMode:
       
  1311 	case EMobilePhoneSetUSimAppsSelectionMode:
       
  1312 	case EMobilePhoneNotifyUSimAppsSelectionModeChange:
       
  1313 		if(iPhoneUSimApp->FoundUSimAppTags())
       
  1314 			{
       
  1315 			return iPhoneUSimApp->CancelService(aIpc,aTsyReqHandle);
       
  1316 			}
       
  1317 		else
       
  1318 			{
       
  1319 			return iPhoneSmartCardApp->CancelService(aIpc,aTsyReqHandle);
       
  1320 			}
       
  1321 
       
  1322 
       
  1323 		// CallBarring
       
  1324 	case EMobilePhoneSetCallBarringStatus:
       
  1325 	case EMobilePhoneSetCallBarringPassword:
       
  1326 	case EMobilePhoneNotifyCallBarringStatusChange:
       
  1327 	case EMobilePhoneGetBarringStatusPhase1:
       
  1328 	case EMobilePhoneGetBarringStatusPhase2:
       
  1329 		return iCallBarring->CancelService(aIpc, aTsyReqHandle);
       
  1330 
       
  1331 		// CallForwarding
       
  1332 	case EMobilePhoneSetCallForwardingStatus:
       
  1333 	case EMobilePhoneNotifyCallForwardingStatusChange:
       
  1334 	case EMobilePhoneGetIdentityServiceStatus:
       
  1335 	case EMobilePhoneGetCallForwardingStatusPhase1:
       
  1336 	case EMobilePhoneGetCallForwardingStatusPhase2:
       
  1337 		return iCallForwarding->CancelService(aIpc, aTsyReqHandle);
       
  1338 
       
  1339 		// CallWaiting
       
  1340 	case EMobilePhoneSetCallWaitingStatus:
       
  1341 	case EMobilePhoneNotifyCallWaitingStatusChange:
       
  1342 	case EMobilePhoneGetWaitingStatusPhase1:
       
  1343 	case EMobilePhoneGetWaitingStatusPhase2:
       
  1344 		return iCallWaiting->CancelService(aIpc, aTsyReqHandle);
       
  1345 
       
  1346 		//IMS Auth
       
  1347 	case EMobilePhoneNotifyImsAuthorizationInfoChanged:
       
  1348 		return iPhoneIMSAuth->NotifyImsAuthorizationInfoChangedCancel(aTsyReqHandle);
       
  1349 
       
  1350 	case EMobilePhoneAuthorizationInfoPhase1:
       
  1351 	case EMobilePhoneAuthorizationInfoPhase2:
       
  1352 		return iPhoneIMSAuth->GetAuthorizationInfoCancel(aTsyReqHandle);
       
  1353 
       
  1354 	case EMobilePhoneIMSAuthenticate:
       
  1355 		return iPhoneIMSAuth->GetAuthenticationDataCancel(aTsyReqHandle);
       
  1356 
       
  1357 		// Generic Smart Card Authenticate cancel
       
  1358 	case EMobilePhoneSmartCardAuthenticate:
       
  1359 		return iPhoneScAuth->GetScAuthenticationDataCancel(aTsyReqHandle);
       
  1360 
       
  1361 // Access Point Name (APN)
       
  1362 	case EMobilePhoneEnumerateAPNEntries:		
       
  1363 	case EMobilePhoneGetAPNname:
       
  1364 	case EMobilePhoneAppendAPNName:
       
  1365 	case EMobilePhoneDeleteAPNName:
       
  1366 		ReqCompleted(aTsyReqHandle, KErrNone);
       
  1367 		return KErrNone;		
       
  1368 	case EMobilePhoneNotifyAPNListChanged:
       
  1369 		if (iAPNListNotify.iNotifyPending == TRUE)
       
  1370 			{
       
  1371 			iAPNListNotify.iNotifyPending = EFalse;
       
  1372 			ReqCompleted(iAPNListNotify.iNotifyHandle, KErrCancel);
       
  1373 			}
       
  1374 		return KErrNone;
       
  1375 	case EMobilePhoneSetAPNControlListServiceStatus:
       
  1376 	case EMobilePhoneGetAPNControlListServiceStatus:
       
  1377 		ReqCompleted(aTsyReqHandle, KErrNone);
       
  1378 		return KErrNone;
       
  1379 	case EMobilePhoneNotifyAPNControlListServiceStatusChange:		
       
  1380 		if (iAPNStatusNotify.iNotifyPending == TRUE)
       
  1381 			{
       
  1382 			iAPNStatusNotify.iNotifyPending = EFalse;
       
  1383 			ReqCompleted(iAPNStatusNotify.iNotifyHandle, KErrCancel);
       
  1384 			}
       
  1385 		return KErrNone;
       
  1386 	case EMobilePhoneGetServiceTable:
       
  1387 		ReqCompleted(aTsyReqHandle, KErrNone);
       
  1388 		return KErrNone;	
       
  1389 				
       
  1390 	
       
  1391 	case EMobilePhoneNotifyMessageWaiting:
       
  1392 		return iUsimRelease6->NotifyMessageWaitingCancel(aTsyReqHandle);
       
  1393 		
       
  1394 	case EMobilePhoneNotifyIccMessageWaitingIndicatorsChange:
       
  1395 		return iUsimRelease6->NotifyIccMessageWaitingIndicatorsChangeCancel(aTsyReqHandle);
       
  1396 		
       
  1397 	case EMobilePhoneNotifyMailboxNumbersChange:
       
  1398 		return iUsimRelease6->NotifyMailboxNumbersChangeCancel(aTsyReqHandle);
       
  1399 	
       
  1400 	case EMobilePhoneNotifyWlanDataChange:
       
  1401 		return iUsimRelease6->NotifyWlanDataChangeCancel(aTsyReqHandle);
       
  1402 
       
  1403 	case EMobilePhoneNotifyPreferredWlanSIDListChange:
       
  1404 		return iUsimRelease6->NotifyPreferredWlanSIDListChangeCancel(aTsyReqHandle);
       
  1405 	
       
  1406 	case EMobilePhoneNotifyStorePreferredNetworksListChange:
       
  1407 		return iUsimRelease6->NotifyStorePreferredNetworksListChangeCancel(aTsyReqHandle);
       
  1408 		
       
  1409 	case EMobilePhoneGetPreferredNetworksPhase1:
       
  1410 	case EMobilePhoneGetPreferredNetworksPhase2:
       
  1411 		return iUsimRelease6->GetPreferredNetworksCancel(aTsyReqHandle);
       
  1412 		
       
  1413 	case EMobilePhoneGetPreferredWlanSIDsPhase1:
       
  1414 	case EMobilePhoneGetPreferredWlanSIDsPhase2:
       
  1415 		return iUsimRelease6->GetPreferredWlanSIDsCancel(aTsyReqHandle);
       
  1416 		
       
  1417 	case EMobilePhoneSetGbaBootstrapParams:
       
  1418 		return iUsimRelease6->SetGbaBootstrapParamsCancel(aTsyReqHandle);
       
  1419 		
       
  1420 	case EMobilePhoneNotifyAuthenticateDataChange:
       
  1421 		return iUsimRelease6->NotifyAuthenticateDataChangeCancel(aTsyReqHandle);
       
  1422 		
       
  1423 	case EMobilePhoneGetAuthenticationParams:
       
  1424 		return iUsimRelease6->GetAuthenticationParamsCancel(aTsyReqHandle);
       
  1425 		
       
  1426 	case EMobilePhoneAuthenticationListPhase1:
       
  1427 	case EMobilePhoneAuthenticationListPhase2:
       
  1428 		return iUsimRelease6->GetAuthenticationListCancel(aTsyReqHandle);
       
  1429 
       
  1430 	// Default
       
  1431 	default:
       
  1432 		return CPhoneBase::CancelService(aIpc,aTsyReqHandle);
       
  1433 		}
       
  1434 	return KErrNone;
       
  1435 	}
       
  1436 
       
  1437 CTelObject* CSimPhone::OpenNewObjectByNameL(const TDesC& aName)
       
  1438 /**
       
  1439 * This function will open a new LINE by name.
       
  1440 * In reality the lines should be pre-constructed in the phone's two phase constructor,
       
  1441 * so this will just return a pointer to the relevant line.
       
  1442 *
       
  1443 * @param aName the name of the line object to be opened
       
  1444 * @return CTelObject pointer to the phone object created
       
  1445 * @leave Leaves if incorrect phone name
       
  1446 */
       
  1447 	{
       
  1448 	LOGPHONE1(">>CSimPhone::OpenNewObjectByNameL");
       
  1449 
       
  1450 // Is it a voice line?
       
  1451 	if (aName.CompareF(KVoiceLineName) == 0)
       
  1452 		{
       
  1453 		__ASSERT_ALWAYS(iVoiceLine!=NULL,SimPanic(ELineNotPreInstantiated));
       
  1454 		// Base class open.
       
  1455 		(void)iVoiceLine->Open();
       
  1456 		return iVoiceLine;
       
  1457 		}
       
  1458 
       
  1459 // Is it a data line?
       
  1460 	else if (aName.CompareF(KDataLineName) == 0)
       
  1461 		{
       
  1462 		__ASSERT_ALWAYS(iDataLine!=NULL,SimPanic(ESubsessionNotPreInstantiated));
       
  1463 		// Base class open.
       
  1464 		(void)iDataLine->Open();
       
  1465 		return iDataLine;
       
  1466 		}
       
  1467 
       
  1468 // Is it an SMS messaging class?
       
  1469 	else if (aName.CompareF(KETelSmsMessaging) == 0)
       
  1470 		{
       
  1471 		__ASSERT_ALWAYS(iSmsMessaging!=NULL,SimPanic(ESubsessionNotPreInstantiated));
       
  1472 		// Base class open.
       
  1473 		(void)iSmsMessaging->Open();
       
  1474 		return iSmsMessaging;
       
  1475 		}
       
  1476 
       
  1477 	else if (aName.CompareF(KPacketName) == 0)
       
  1478 		{
       
  1479 		__ASSERT_ALWAYS(iPacketService!=NULL,SimPanic(ESubsessionNotPreInstantiated));
       
  1480 		// Base class open.
       
  1481 		(void)iPacketService->Open();
       
  1482 		return iPacketService;
       
  1483 		}
       
  1484 	else if (aName.CompareF(KSatName) == 0)
       
  1485 		{
       
  1486 		__ASSERT_ALWAYS(iSat!=NULL,SimPanic(ESubsessionNotPreInstantiated));
       
  1487 		// Base class open.
       
  1488 		(void)iSat->Open();
       
  1489 		return iSat;
       
  1490 		}
       
  1491 	else if (aName.Left(SCEAP_SSN_LENGTH).Compare(KETelSmartCardEapSession) == 0)
       
  1492 		{
       
  1493 		// "num" is used for both lengths and error codes!  saves on stack! :)
       
  1494 
       
  1495 		// Extracting AID
       
  1496 		RMobilePhone::TAID tempAID;
       
  1497 		// get number of AID bytes (each byte uses two chars)
       
  1498 		TInt num = CharToSeptNumL(aName[SCEAP_SSN_LENGTH]) * 2;
       
  1499 		// get the segment containing the AID
       
  1500 		TPtrC ptrAid = aName.Mid(SCEAP_SSN_LENGTH + 1, num);
       
  1501 		// convert AID to its correct binary value
       
  1502 		ConvertTextToBinary(ptrAid, tempAID);
       
  1503 
       
  1504 		// Extracting EapType
       
  1505 		RMobileSmartCardEap::TEapType eapType;
       
  1506 		// get position of EAP type's length
       
  1507 		TInt posTypeLength = SCEAP_SSN_LENGTH + num + 1;
       
  1508 		// get the value of the length of EAP type
       
  1509 		num = CharToSeptNumL(aName[posTypeLength]);
       
  1510 		// get the segment containing the EAP type
       
  1511 		TPtrC ptrEapT = aName.Mid(posTypeLength + 1, num);
       
  1512 		eapType.Copy(ptrEapT);
       
  1513 
       
  1514 		CTelObject* phoneScEap = iPhoneScEapMan->CreateScEapSubSessionL(tempAID, eapType);
       
  1515 
       
  1516 		if (phoneScEap == NULL)
       
  1517 			{
       
  1518 			LOGPHONE1("ERROR CSimSmartCardEap object not created, returning KErrGeneral");
       
  1519 			User::Leave(KErrGeneral);
       
  1520 			}
       
  1521 
       
  1522 		LOGPHONE2("CSimPhone::OpenNewObjectByNameL CSimSmartCardEap object created [0x%08x]", phoneScEap);
       
  1523 		return phoneScEap;
       
  1524 		} // End of opening Smart Card EAP sub-session
       
  1525 	else if (aName.CompareF(KETelOwnNumberStore) == 0)
       
  1526 		{
       
  1527 		if(iONStore==NULL)
       
  1528 			{
       
  1529 			LOGPHONE1("ERROR CSimONStore object not found. Please check config file.");
       
  1530 			User::Leave(KErrNotFound);
       
  1531 			}
       
  1532 		else
       
  1533 			{
       
  1534 			(void)iONStore->Open();
       
  1535 			return iONStore;
       
  1536 			}
       
  1537 		}
       
  1538 // Is it a phonebook store?
       
  1539 	else
       
  1540 		{
       
  1541 		TInt i = 0;
       
  1542 		TBuf8<KMaxName> name;
       
  1543 		TInt tLength;
       
  1544 		TPtrC remain(aName);
       
  1545 		name.Copy(aName);		// Do simple 16 bit to 8 bit conversion
       
  1546 
       
  1547 		if ((tLength=remain.Find(PHBOOK_DELIMITER))==KErrNotFound)
       
  1548 			{
       
  1549 			for(i=0;i<iPhBkStores->Count();i++)
       
  1550 				{
       
  1551 				if(name.MatchF(iPhBkStores->At(i)->Name())==0)
       
  1552 					{
       
  1553 					// Base class open.
       
  1554 					(void)iPhBkStores->At(i)->Open();
       
  1555 					return iPhBkStores->At(i);
       
  1556 					}
       
  1557 				}
       
  1558 			for(i=0;i<iPhBkUSimStores->Count();i++)
       
  1559 				{
       
  1560 				if((name.MatchF(iPhBkUSimStores->At(i)->Name())==0) &&
       
  1561 					(iPhBkUSimStores->At(i)->PhBkStore().Compare(KGsmPhoneBook)==0))
       
  1562 
       
  1563 					{
       
  1564 					(void)iPhBkUSimStores->At(i)->Open();
       
  1565 					return iPhBkUSimStores->At(i);
       
  1566 					}
       
  1567 
       
  1568 				}
       
  1569 			}
       
  1570 		else
       
  1571 			{
       
  1572 			TBuf8<KMaxName> PhBkName;
       
  1573 			TBuf8<KMaxName> PhBkStore;
       
  1574 			PhBkName.Copy(aName.Left(tLength));
       
  1575 			PhBkStore.Copy(aName.Right(aName.Length()-tLength-2));
       
  1576 
       
  1577 			for(TInt i=0;i<iPhBkUSimStores->Count();i++)
       
  1578 				{
       
  1579 				if((PhBkName.MatchF(iPhBkUSimStores->At(i)->Name())==0) &&
       
  1580 					(PhBkStore.MatchF(iPhBkUSimStores->At(i)->PhBkStore())==0))
       
  1581 
       
  1582 					{
       
  1583 					(void)iPhBkUSimStores->At(i)->Open();
       
  1584 					return iPhBkUSimStores->At(i);
       
  1585 					}
       
  1586 
       
  1587 				}
       
  1588 			}
       
  1589 		}
       
  1590 // Not matched...
       
  1591 	User::Leave(KErrNotFound);
       
  1592 	return NULL;
       
  1593 	}
       
  1594 
       
  1595 
       
  1596 CTelObject* CSimPhone::OpenNewObjectL(TDes& /*aNewName*/)
       
  1597 /**
       
  1598 * This function would open a new unnamed object,
       
  1599 * but this functionality is not supported at the phone level.
       
  1600 * All lines must be opened by name.
       
  1601 *
       
  1602 * @param aNewName a reference to the name of the phone object created
       
  1603 * @return CTelObject a pointer to the phone object created
       
  1604 * @leave Leaves if no memory is available
       
  1605 */
       
  1606 	{
       
  1607 	User::Leave(KErrNotSupported);
       
  1608 	return NULL;
       
  1609 	}
       
  1610 
       
  1611 CTelObject::TReqMode CSimPhone::ReqModeL(const TInt aIpc)
       
  1612 /**
       
  1613 * This function returns the Request Mode for the request with the passed IPC value.
       
  1614 * The ETel Server provides a function for returning the standard request modes for
       
  1615 * the Core API requests.
       
  1616 */
       
  1617 	{
       
  1618 	TReqMode reqMode=0;
       
  1619 	switch(aIpc)
       
  1620 		{
       
  1621 	case EMobilePhoneGetPhoneStoreInfo:
       
  1622 	case EMobilePhoneGetSignalCaps:
       
  1623 	case EMobilePhoneGetSignalStrength:
       
  1624 	case EMobilePhoneGetNetworkCaps:
       
  1625 	case EMobilePhoneGetCurrentMode:
       
  1626 
       
  1627 	case EMobilePhoneNotifyModeChange:
       
  1628 
       
  1629 	case EMobilePhoneGetHomeNetwork:
       
  1630 	case EMobilePhoneGetCurrentNetwork:
       
  1631 	case EMobilePhoneGetCurrentNetworkNoLocation:
       
  1632 	case EMobilePhoneGetNetworkRegistrationStatus:
       
  1633 	case EMobilePhoneGetNITZInfo:
       
  1634 	case EMobilePhoneGetCellInfo:
       
  1635 	case EMobilePhoneGetSubscriberId:
       
  1636 	case EMobilePhoneGetDTMFCaps:
       
  1637 	case EMobilePhoneSendDTMFTones:
       
  1638 	case EMobilePhoneStartDTMFTone:
       
  1639 	case EMobilePhoneStopDTMFTone:
       
  1640 	case EMobilePhoneContinueDTMFStringSending:
       
  1641 	case EMobilePhoneGetMultimodeCaps:
       
  1642 	case EMobilePhoneGetIndicator:
       
  1643 	case EMobilePhoneGetIndicatorCaps:
       
  1644 	case EMobilePhoneGetBatteryInfo:
       
  1645 	case EMobilePhoneGetBatteryCaps:
       
  1646 	case EMobilePhoneGetIccAccessCaps:
       
  1647 	case EMobilePhoneGetSecurityCaps:
       
  1648 	case EMobilePhoneGetLockInfo:
       
  1649 	case EMobilePhoneSetLockSetting:
       
  1650 	case EMobilePhoneGetSecurityCodeInfo:
       
  1651 	case EMobilePhoneChangeSecurityCode:
       
  1652 	case EMobilePhoneVerifySecurityCode:
       
  1653 	case EMobilePhoneAbortSecurityCode:
       
  1654 	case EMobilePhoneEnumerateUSimApplications:
       
  1655 	case EMobilePhoneGetCurrentActiveUSimApplication:
       
  1656 	case EMobilePhoneSetUSimApplicationStatus:
       
  1657 	case EMobilePhoneGetUSimApplicationsInfo:
       
  1658 	case EMobilePhoneGetUSimAppsSelectionMode:
       
  1659 	case EMobilePhoneSetUSimAppsSelectionMode:
       
  1660 	case EMobilePhoneEnumerateSmartCardApplications:
       
  1661 	case EMobilePhoneGetSmartCardApplicationInfo:
       
  1662 	case EMobilePhoneSetSmartCardApplicationStatus:
       
  1663 	case EMobilePhoneGetScFileInfo:
       
  1664 	case EMobilePhoneReadScFile:
       
  1665 	case EMobilePhoneUpdateScFile:
       
  1666 	case EMobilePhoneSetCallBarringStatus:
       
  1667 	case EMobilePhoneSetCallBarringPassword:
       
  1668 	case EMobilePhoneGetBarringStatusPhase1:
       
  1669 	case EMobilePhoneGetBarringStatusPhase2:
       
  1670 	case EMobilePhoneSetCallForwardingStatus:
       
  1671 	case EMobilePhoneGetIdentityServiceStatus:
       
  1672 	case EMobilePhoneGetCallForwardingStatusPhase1:
       
  1673 	case EMobilePhoneGetCallForwardingStatusPhase2:
       
  1674 	case EMobilePhoneGetIdentityCaps:
       
  1675 	case EMobilePhoneGetPhoneId:
       
  1676 	case EMobilePhoneGetServiceProviderName:
       
  1677 	case EMobilePhoneGetNetworkName:
       
  1678 	case EMobilePhoneSetCallWaitingStatus:
       
  1679 	case EMobilePhoneGetWaitingStatusPhase1:
       
  1680 	case EMobilePhoneGetWaitingStatusPhase2:
       
  1681 	case EMobilePhoneAuthorizationInfoPhase1:
       
  1682 	case EMobilePhoneAuthorizationInfoPhase2:
       
  1683 	case EMobilePhoneIMSAuthenticate:
       
  1684 	case EMobilePhoneSmartCardAuthenticate:
       
  1685 	case EMobilePhoneGetMailboxNumbers:
       
  1686 	case EMobilePhoneGetIccMessageWaitingIndicators:
       
  1687 	case EMobilePhoneSetIccMessageWaitingIndicators:
       
  1688 	case EMobilePhoneGetWlanData:
       
  1689 	case EMobilePhoneSetWlanData:
       
  1690 	case EMobilePhoneGetPreferredWlanSIDsPhase1:
       
  1691 	case EMobilePhoneGetPreferredWlanSIDsPhase2:
       
  1692 	case EMobilePhoneStorePreferredWlanSIDList:	
       
  1693 	case EMobilePhoneGetPreferredNetworksPhase1:
       
  1694 	case EMobilePhoneGetPreferredNetworksPhase2:
       
  1695 	case EMobilePhoneStorePreferredNetworksList:
       
  1696 	case EMobilePhoneSetGbaBootstrapParams:
       
  1697 	case EMobilePhoneGetAuthenticationParams:
       
  1698 	case EMobilePhoneNotifyAuthenticateDataChange:
       
  1699 	case EMobilePhoneAuthenticationListPhase1:
       
  1700 	case EMobilePhoneAuthenticationListPhase2:
       
  1701 		break;
       
  1702 
       
  1703 // Service Tables
       
  1704 	case EMobilePhoneEnumerateAPNEntries:
       
  1705 	case EMobilePhoneGetAPNname:
       
  1706 	case EMobilePhoneAppendAPNName:
       
  1707 	case EMobilePhoneDeleteAPNName:
       
  1708 	case EMobilePhoneNotifyAPNListChanged:
       
  1709 	case EMobilePhoneSetAPNControlListServiceStatus:
       
  1710 	case EMobilePhoneGetAPNControlListServiceStatus:
       
  1711 	case EMobilePhoneNotifyAPNControlListServiceStatusChange:
       
  1712 	case EMobilePhoneGetServiceTable:
       
  1713 		break;
       
  1714 
       
  1715 	case EMobilePhoneNotifyIndicatorChange:
       
  1716 	case EMobilePhoneNotifyBatteryInfoChange:
       
  1717 	case EMobilePhoneNotifySignalStrengthChange:
       
  1718 	case EMobilePhoneNotifyNetworkRegistrationStatusChange:
       
  1719 	case EMobilePhoneNotifyCurrentNetworkChange:
       
  1720 	case EMobilePhoneNotifyCurrentNetworkNoLocationChange:
       
  1721 	case EMobilePhoneNotifyNITZInfoChange:
       
  1722 	case EMobilePhoneNotifyCellInfoChange:
       
  1723 	case EMobilePhoneNotifyDTMFCapsChange:
       
  1724 	case EMobilePhoneNotifyStopInDTMFString:
       
  1725 	case EMobilePhoneNotifySecurityEvent:
       
  1726 	case EMobilePhoneNotifySecurityCapsChange:
       
  1727 	case EMobilePhoneNotifyUSimApplicationsInfoChange:
       
  1728 	case EMobilePhoneNotifySmartCardApplicationInfoChange:
       
  1729 	case EMobilePhoneNotifyUSimAppsSelectionModeChange:
       
  1730 	case EMobilePhoneNotifyCallBarringStatusChange:
       
  1731 	case EMobilePhoneNotifyCallWaitingStatusChange:
       
  1732 	case EMobilePhoneNotifyCallForwardingStatusChange:
       
  1733 	case EMobilePhoneNotifyImsAuthorizationInfoChanged:
       
  1734 	case EMobilePhoneNotifyMailboxNumbersChange:
       
  1735 	case EMobilePhoneNotifyIccMessageWaitingIndicatorsChange:
       
  1736 	case EMobilePhoneNotifyMessageWaiting:
       
  1737 	case EMobilePhoneNotifyWlanDataChange:
       
  1738 	case EMobilePhoneNotifyPreferredWlanSIDListChange:
       
  1739 	case EMobilePhoneNotifyStorePreferredNetworksListChange:
       
  1740 		reqMode=KReqModeMultipleCompletionEnabled | KReqModeRePostImmediately;
       
  1741 		break;
       
  1742 	case EMobilePhoneNotifyLockInfoChange:
       
  1743 	case EMobilePhoneNotifySecurityCodeInfoChange:
       
  1744 		reqMode=KReqModeMultipleCompletionEnabled;
       
  1745 		break;
       
  1746 	default:
       
  1747 		reqMode=CPhoneBase::ReqModeL(aIpc);
       
  1748 		break;
       
  1749 		}
       
  1750 	return reqMode;
       
  1751 	}
       
  1752 
       
  1753 TInt CSimPhone::RegisterNotification(const TInt /*aIpc*/)
       
  1754 /**
       
  1755 * The ETel Server calls this function when the first client makes a notification request.
       
  1756 * If supported by the underlying protocol controlling the signalling stack,
       
  1757 * this can be used to start requesting updates for the relevant	service.
       
  1758 * This function does nothing in this TSY.
       
  1759 *
       
  1760 * @param aIpc The Ipc representing the client notification request
       
  1761 * @return KErrNone
       
  1762 */
       
  1763 	{
       
  1764 	return KErrNone;
       
  1765 	}
       
  1766 
       
  1767 TInt CSimPhone::DeregisterNotification(const TInt /*aIpc*/)
       
  1768 /**
       
  1769 * The ETel Server calls this function when the last client that had previously
       
  1770 * made a notification request closes its ETel Server handle.  If supported by
       
  1771 * the underlying protocol controlling the	signalling stack, this can be used
       
  1772 * to stop requesting updates for the relevant service.
       
  1773 *
       
  1774 * @param aIpc The Ipc representing the client notification request
       
  1775 * @return KErrNone
       
  1776 */
       
  1777 	{
       
  1778 	return KErrNone;
       
  1779 	}
       
  1780 
       
  1781 TInt CSimPhone::NumberOfSlotsL(const TInt aIpc)
       
  1782 	{
       
  1783 	switch(aIpc)
       
  1784 		{
       
  1785 	case EMobilePhoneNotifyIndicatorChange:
       
  1786 	case EMobilePhoneNotifyBatteryInfoChange:
       
  1787 	case EMobilePhoneNotifySignalStrengthChange:
       
  1788 	case EMobilePhoneNotifyCurrentNetworkChange:
       
  1789 	case EMobilePhoneNotifyCurrentNetworkNoLocationChange:
       
  1790 	case EMobilePhoneNotifyNetworkRegistrationStatusChange:
       
  1791 	case EMobilePhoneNotifyNITZInfoChange:
       
  1792 	case EMobilePhoneNotifyCellInfoChange:
       
  1793 	case EMobilePhoneNotifyStopInDTMFString:
       
  1794 	case EMobilePhoneNotifySecurityEvent:
       
  1795 	case EMobilePhoneNotifyUSimApplicationsInfoChange:
       
  1796 	case EMobilePhoneNotifySmartCardApplicationInfoChange:
       
  1797 	case EMobilePhoneNotifyUSimAppsSelectionModeChange:
       
  1798 	case EMobilePhoneNotifySecurityCapsChange:
       
  1799 	case EMobilePhoneNotifyCallBarringStatusChange:
       
  1800 	case EMobilePhoneNotifyCallForwardingStatusChange:
       
  1801 	case EMobilePhoneNotifyCallWaitingStatusChange:
       
  1802 	case EMobilePhoneNotifyImsAuthorizationInfoChanged:
       
  1803 	case EMobilePhoneNotifyMailboxNumbersChange:
       
  1804 	case EMobilePhoneNotifyIccMessageWaitingIndicatorsChange:
       
  1805 	case EMobilePhoneNotifyMessageWaiting:
       
  1806 	case EMobilePhoneNotifyWlanDataChange:
       
  1807 	case EMobilePhoneNotifyPreferredWlanSIDListChange:
       
  1808 	case EMobilePhoneNotifyStorePreferredNetworksListChange:
       
  1809 		return KDefaultNumberOfSlots;
       
  1810 	default:
       
  1811 		break;
       
  1812 		}
       
  1813 	return CPhoneBase::NumberOfSlotsL(aIpc);
       
  1814 	}
       
  1815 
       
  1816 void CSimPhone::Init()
       
  1817 /**
       
  1818 *	This function can be used to perform any necessary synchronous initialisation.
       
  1819 */
       
  1820 	{
       
  1821 	}
       
  1822 
       
  1823 TInt CSimPhone::ControlledInitialisation(const TTsyReqHandle aTsyReqHandle)
       
  1824 /**
       
  1825 * This function can be used to start any necessary asynchronous initialisation.
       
  1826 * In this TSY, there are no asynchronous initialisation procedures, so its empty.
       
  1827 */
       
  1828 	{
       
  1829 	iSimPhoneInitialise->Start(aTsyReqHandle);
       
  1830 	return KErrNone;
       
  1831 	}
       
  1832 
       
  1833 TInt CSimPhone::ControlledInitialisationCancel(const TTsyReqHandle /*aTsyReqHandle*/)
       
  1834 /**
       
  1835 * Request to cancel the ::ControlledInitialisation function.
       
  1836 * Since this TSY has no asynchronous initialisation procedures,
       
  1837 * this function should never be called.
       
  1838 */
       
  1839 	{
       
  1840 	iSimPhoneInitialise->Cancel();
       
  1841 	return KErrNone;
       
  1842 	}
       
  1843 
       
  1844 TInt CSimPhone::NotifyCapsChange(const TTsyReqHandle aTsyReqHandle, RPhone::TCaps* /*aCaps*/)
       
  1845 /**
       
  1846 * The phone caps will not change dynamically in this TSY as it is hardcoded,
       
  1847 * so there is no chance of completing this request.
       
  1848 *
       
  1849 * @param aTsyReqHandle
       
  1850 * @param aCaps a pointer to the phone capability
       
  1851 * @return KErrNone
       
  1852 */
       
  1853 	{
       
  1854 	ReqCompleted(aTsyReqHandle, KErrNotSupported);
       
  1855 	return KErrNone;
       
  1856 	}
       
  1857 
       
  1858 TInt CSimPhone::NotifyCapsChangeCancel(const TTsyReqHandle /*aTsyReqHandle*/)
       
  1859 /**
       
  1860 *	Cancel the NotifyCapsChange request.
       
  1861 *
       
  1862 * @param aTsyReqHandle
       
  1863 * @return KErrNone
       
  1864 */
       
  1865 	{
       
  1866 	return KErrNone;
       
  1867 	}
       
  1868 
       
  1869 
       
  1870 
       
  1871 TInt CSimPhone::NotifyModemDetected(const TTsyReqHandle aTsyReqHandle, RPhone::TModemDetection* /*aDetection*/)
       
  1872 /**
       
  1873 * This request will be completed when the phone's connection status changes.
       
  1874 * This function is not supported in this version of the TSY
       
  1875 */
       
  1876 	{
       
  1877 	ReqCompleted(aTsyReqHandle,KErrNotSupported);
       
  1878 	return KErrNone;
       
  1879 	}
       
  1880 
       
  1881 TInt CSimPhone::NotifyModemDetectedCancel(const TTsyReqHandle /*aTsyReqHandle*/)
       
  1882 /**
       
  1883 * Cancel outstanding modem detection notification, by TSY handle
       
  1884 * Returns KErrNone
       
  1885 */
       
  1886 	{
       
  1887 	return KErrNone;
       
  1888 	}
       
  1889 
       
  1890 TInt CSimPhone::GetInfo(const TTsyReqHandle aTsyReqHandle, RPhone::TPhoneInfo* aPhoneInfo)
       
  1891 /**
       
  1892 * Retrieve the Phone Information
       
  1893 * It should always return TModemDetection::EDetectedPresent
       
  1894 *
       
  1895 * @param aTsyReqHandle
       
  1896 * @param aPhoneInfo pointer to the phone information to be returned to client
       
  1897 * @return KErrNone
       
  1898 */
       
  1899 	{
       
  1900 	aPhoneInfo->iDetection=iModemDetection;
       
  1901 	ReqCompleted(aTsyReqHandle,KErrNone);
       
  1902 	return KErrNone;
       
  1903 	}
       
  1904 
       
  1905 void CSimPhone::UpdateNetworkMode(RMobilePhone::TMobilePhoneNetworkMode aNetworkMode)
       
  1906 	{
       
  1907 	iNtwkMode = aNetworkMode;
       
  1908 	}
       
  1909 
       
  1910 RMobilePhone::TMobilePhoneNetworkMode CSimPhone::NetworkMode()
       
  1911 	{
       
  1912 	return iNtwkMode;
       
  1913 	}
       
  1914 
       
  1915 TInt CSimPhone::GetCurrentMode(TTsyReqHandle aReqHandle,TDes8* aPckg1)
       
  1916 /**
       
  1917  * Retrieve the Current Mode.
       
  1918  * @param aReqHandle	The request handle associated with this request.
       
  1919  * @param aPckg1		The first parameter package.  This will be populated with the
       
  1920  *						mode setting to be returned.
       
  1921  * @return TInt			Standard error value.
       
  1922  */
       
  1923 	{
       
  1924 	TPckg<RMobilePhone::TMobilePhoneNetworkMode>* modePckg=(TPckg<RMobilePhone::TMobilePhoneNetworkMode>*)aPckg1;
       
  1925 	RMobilePhone::TMobilePhoneNetworkMode& mode=(*modePckg)();
       
  1926 
       
  1927 	mode=iNtwkMode;
       
  1928 	ReqCompleted(aReqHandle,KErrNone);
       
  1929 	return KErrNone;
       
  1930 	}
       
  1931 
       
  1932 TInt CSimPhone::GetCaps(const TTsyReqHandle aTsyReqHandle, RPhone::TCaps* aCaps)
       
  1933 /**
       
  1934 * Retrieve the phone capabilities
       
  1935 *
       
  1936 * @param aTsyReqHandle
       
  1937 * @param aCaps a pointer to the Phone capability
       
  1938 * @return KErrNone
       
  1939 */
       
  1940 	{
       
  1941 	aCaps->iFlags= RPhone::KCapsVoice | RPhone::KCapsData;
       
  1942 	ReqCompleted(aTsyReqHandle,KErrNone);
       
  1943 	return KErrNone;
       
  1944 	}
       
  1945 
       
  1946 TInt CSimPhone::GetStatus(const TTsyReqHandle aTsyReqHandle, RPhone::TStatus* aStatus)
       
  1947 /**
       
  1948 * Retrieve the phone status.
       
  1949 *
       
  1950 * @param aTsyReqHandle
       
  1951 * @param aStatus pointer to the phone status info.
       
  1952 * @return KErrNone
       
  1953 */
       
  1954 	{
       
  1955 	aStatus->iModemDetected=iModemDetection;
       
  1956 	aStatus->iMode=iMode;
       
  1957 	ReqCompleted(aTsyReqHandle,KErrNone);
       
  1958 	return KErrNone;
       
  1959 	}
       
  1960 
       
  1961 TInt CSimPhone::EnumerateLines(const TTsyReqHandle aTsyReqHandle, TInt* aParams)
       
  1962 /**
       
  1963 * Enumerate the lines
       
  1964 * Returns 2 (for the voice and data lines) in the integer reference passed in
       
  1965 * through its function argument.
       
  1966 *
       
  1967 * @param aTsyReqHandle
       
  1968 * @param aParams pointer to the number of lines supported
       
  1969 * @return KErrNone
       
  1970 */
       
  1971 	{
       
  1972 	*aParams = KNumberOfLines;
       
  1973 	ReqCompleted(aTsyReqHandle,KErrNone);
       
  1974 	return KErrNone;
       
  1975 	}
       
  1976 
       
  1977 TInt CSimPhone::GetLineInfo(const TTsyReqHandle aTsyReqHandle, TLineInfoIndex* aParams)
       
  1978 /**
       
  1979 * Gets the line info on the particular CSimLine object required.
       
  1980 * Returns the current hook status, the current line status, name of last call created on
       
  1981 * that line and the name of the call to which a new incoming call will be directed.
       
  1982 * TLineInfoIndex specifies which lines' info is requested.
       
  1983 *
       
  1984 * @param aTsyReqHandle
       
  1985 * @param aParam pointer to the line info
       
  1986 * @return KErrNone
       
  1987 */
       
  1988 	{
       
  1989 	if (aParams->iIndex==KVoiceLineIndex)
       
  1990 		{
       
  1991 		aParams->iInfo.iStatus = (RCall::TStatus)iVoiceLine->iState;
       
  1992 		aParams->iInfo.iName = iVoiceLine->iLineName;
       
  1993 		aParams->iInfo.iLineCapsFlags = (RLine::KCapsVoice|RLine::KCapsEventIncomingCall);
       
  1994 		ReqCompleted(aTsyReqHandle,KErrNone);
       
  1995 		}
       
  1996 	else if (aParams->iIndex==KDataLineIndex)
       
  1997 		{
       
  1998 		aParams->iInfo.iStatus = (RCall::TStatus)iDataLine->iState;
       
  1999 		aParams->iInfo.iName = iDataLine->iLineName;
       
  2000 		aParams->iInfo.iLineCapsFlags = (RLine::KCapsData|RLine::KCapsEventIncomingCall);
       
  2001 		ReqCompleted(aTsyReqHandle,KErrNone);
       
  2002 		}
       
  2003 	else
       
  2004 		{
       
  2005 		ReqCompleted(aTsyReqHandle,KErrNotFound);
       
  2006 		}
       
  2007 	return KErrNone;
       
  2008 	}
       
  2009 
       
  2010 TInt CSimPhone::GetPhoneStoreInfo(TTsyReqHandle aReqHandle,TDes8* aPckg1,TDes16* aPckg2)
       
  2011 /**
       
  2012  * Retrieve information about a named Phonebook Store.
       
  2013  * @param aReqHandle	The TSY request handle associated with this request.
       
  2014  * @param aPckg1		The parameter package containing the index of the SMS Store for which
       
  2015  *						information is going to be retrieved.
       
  2016  * @param aPckg2		The parameter package in which the retrieved SMS Store information will
       
  2017  *						be passed back to the client.
       
  2018  * @return TInt			Standard error value.
       
  2019  */
       
  2020 	{
       
  2021 	TPckg<RMobilePhoneStore::TMobilePhoneStoreInfoV1>* infoPckg=(TPckg<RMobilePhoneStore::TMobilePhoneStoreInfoV1>*)aPckg1;
       
  2022 	RMobilePhoneStore::TMobilePhoneStoreInfoV1& info=(*infoPckg)();
       
  2023 
       
  2024 	// Check that the data structure is supported by the simulated TSY version
       
  2025 	TInt err = CheckSimTsyVersion(info);
       
  2026 	if(err != KErrNone)
       
  2027 		{
       
  2028 		ReqCompleted(aReqHandle, err);
       
  2029 		return KErrNone;
       
  2030 		}
       
  2031 
       
  2032 	TInt i;
       
  2033 	for(i=0;i<iPhBkStores->Count();i++)
       
  2034 		{
       
  2035 		TBuf8<KMaxName> nBuf;
       
  2036 		nBuf.Copy(*aPckg2);
       
  2037 		if(iPhBkStores->At(i)->Name().MatchF(nBuf)==0)
       
  2038 			break;
       
  2039 		}
       
  2040 
       
  2041 	if(i==iPhBkStores->Count())
       
  2042 		{
       
  2043 		ReqCompleted(aReqHandle,KErrNotFound);
       
  2044 		return KErrNone;
       
  2045 		}
       
  2046 
       
  2047 	iPhBkStores->At(i)->PopulatePhBkStoreInfo(&info);
       
  2048 	ReqCompleted(aReqHandle,KErrNone);
       
  2049 	return KErrNone;
       
  2050 	}
       
  2051 
       
  2052 TInt CSimPhone::GetPhoneStoreInfo(TTsyReqHandle aReqHandle,TDes8* aPckg1,
       
  2053 								  RMobilePhone::TPhoneStoreNameAndIccType* aTable)
       
  2054 /**
       
  2055  * Retrieve information about a named Phonebook Store.
       
  2056  * @param aReqHandle	The TSY request handle associated with this request.
       
  2057  * @param aPckg1		The parameter package containing the index of the PhoneBook Store for which
       
  2058  *						information is going to be retrieved.
       
  2059  * @param aTable		The parameter package in which the retrieved PhoneBook Store name and type information will
       
  2060  *						be passed from the client.
       
  2061  * @return TInt			Standard error value.
       
  2062  */
       
  2063 	{
       
  2064 	TBool found = EFalse;
       
  2065 	TPckg<RMobilePhoneStore::TMobilePhoneStoreInfoV1>* infoPckg=(TPckg<RMobilePhoneStore::TMobilePhoneStoreInfoV1>*)aPckg1;
       
  2066 	RMobilePhoneStore::TMobilePhoneStoreInfoV1& info=(*infoPckg)();
       
  2067 
       
  2068 	// Check that the data structure is supported by the simulated TSY version
       
  2069 	TInt err = CheckSimTsyVersion(info);
       
  2070 	if(err != KErrNone)
       
  2071 		{
       
  2072 		ReqCompleted(aReqHandle, err);
       
  2073 		return KErrNone;
       
  2074 		}
       
  2075 
       
  2076 	TBuf8<KMaxName> n1Buf,n2Buf;
       
  2077 
       
  2078 	n1Buf.Copy(aTable->iStoreName);
       
  2079 	n2Buf.Copy(aTable->iMode);
       
  2080 
       
  2081 	TInt i;
       
  2082 
       
  2083 	for(i=0;i<iPhBkUSimStores->Count();i++)
       
  2084 		{
       
  2085 		if((iPhBkUSimStores->At(i)->Name().MatchF(n1Buf)==0) &&
       
  2086 			(iPhBkUSimStores->At(i)->PhBkStore().MatchF(n2Buf)==0))
       
  2087 			{
       
  2088 			found = ETrue;
       
  2089 			break;
       
  2090 			}
       
  2091 		}
       
  2092 
       
  2093 	if(!found)
       
  2094 		{
       
  2095 			for(i=0;i<iPhBkStores->Count();i++)
       
  2096 				{
       
  2097 				if((iPhBkStores->At(i)->Name().MatchF(n1Buf)==0)  &&
       
  2098 					n2Buf != KUSimPhoneBook)
       
  2099 					{
       
  2100 					found = ETrue;
       
  2101 					break;
       
  2102 					}
       
  2103 				}
       
  2104 			if(!found)
       
  2105 				{
       
  2106 				ReqCompleted(aReqHandle,KErrNotFound);
       
  2107 				return KErrNone;
       
  2108 				}
       
  2109 			else
       
  2110 				{
       
  2111 				iPhBkStores->At(i)->PopulatePhBkStoreInfo(&info);
       
  2112 				ReqCompleted(aReqHandle,KErrNone);
       
  2113 				}
       
  2114 		}
       
  2115 	else
       
  2116 		{
       
  2117 		if(iPhBkUSimStores->At(i)->CheckAndSwitchUSimApps()!=KErrNone)
       
  2118 			{
       
  2119 			ReqCompleted(aReqHandle, KErrNotFound);
       
  2120 			return KErrNone;
       
  2121 			}
       
  2122 
       
  2123 		iPhBkUSimStores->At(i)->PopulatePhBkStoreInfo(&info);
       
  2124 		ReqCompleted(aReqHandle,KErrNone);
       
  2125 		}
       
  2126 	return KErrNone;
       
  2127 	}
       
  2128 
       
  2129 TInt CSimPhone::GetMultimodeCaps(const TTsyReqHandle aTsyReqHandle,TUint32* aCaps)
       
  2130 /**
       
  2131  * Retrieve the multimode capabilities of this TSY.  This is hardcoded to support GSM, GPRS and CDMA.
       
  2132  * @param aTsyReqHandle		TSY Request Handle associated with this request.
       
  2133  * @param aCaps				The multimode capability structure to be populated with the result.
       
  2134  * @return TInt				Standard error value.
       
  2135  */
       
  2136 	{
       
  2137 	*aCaps = RMobilePhone::KCapsGsmSupported |
       
  2138 	         RMobilePhone::KCapsGprsSupported |
       
  2139 	         RMobilePhone::KCapsEapSupported | 
       
  2140 	         RMobilePhone::KCapsWcdmaSupported;
       
  2141 
       
  2142 	ReqCompleted(aTsyReqHandle,KErrNone);
       
  2143 
       
  2144 	return KErrNone;
       
  2145 	}
       
  2146 
       
  2147 TInt CSimPhone::GetIccAccessCaps(const TTsyReqHandle aTsyReqHandle,TUint32* aCaps)
       
  2148 /**
       
  2149  * Retrieve the access capabilities of this ICC using SimTSY.  This is hardcoded to support SIM, RUIM and USIM.
       
  2150  * @param aTsyReqHandle		TSY Request Handle associated with this request.
       
  2151  * @param aCaps				The multimode capability structure to be populated with the result.
       
  2152  * @return TInt				Standard error value.
       
  2153  */
       
  2154 	{
       
  2155 	*aCaps = RMobilePhone::KCapsSimAccessSupported | RMobilePhone::KCapsRUimAccessSupported | RMobilePhone::KCapsUSimAccessSupported;
       
  2156 	ReqCompleted(aTsyReqHandle,KErrNone);
       
  2157 
       
  2158 	return KErrNone;
       
  2159 	}
       
  2160 
       
  2161 TInt CSimPhone::GetSubscriberInfo(TTsyReqHandle aReqHandle,TDes8* aPckg1)
       
  2162 /**
       
  2163  * Retrieve the Subscriber Identifier.
       
  2164  * @param aReqHandle	The TSY request handle associated with this request.
       
  2165  * @param aPckg1		The first parameter package.  This will be populated with the
       
  2166  *						subscriber information.
       
  2167  * @return TInt			Standard error value.
       
  2168  */
       
  2169 	{
       
  2170 	TPckg<RMobilePhone::TMobilePhoneSubscriberId>* subscribePckg=(TPckg<RMobilePhone::TMobilePhoneSubscriberId>*)aPckg1;
       
  2171 	RMobilePhone::TMobilePhoneSubscriberId& subscribe=(*subscribePckg)();
       
  2172 	TInt ret = KErrNone;
       
  2173 	if (iSubscriberId.iError == KErrNone)
       
  2174 		{
       
  2175 		if(iSubscriberId.iIMSI.Length()>RMobilePhone::KIMSISize)
       
  2176 			subscribe.Copy(iSubscriberId.iIMSI.Left(RMobilePhone::KIMSISize));
       
  2177 		else
       
  2178 			subscribe.Copy(iSubscriberId.iIMSI);
       
  2179 		}
       
  2180 	else
       
  2181 		ret = iSubscriberId.iError;
       
  2182 	ReqCompleted(aReqHandle,ret);
       
  2183 	return KErrNone;
       
  2184 	}
       
  2185 
       
  2186 const CTestConfigSection* CSimPhone::CfgFile()
       
  2187 /**
       
  2188 *	Return a pointer to the Configuration File Section
       
  2189 *
       
  2190 * @return CTestConfigSection	pointer to the configuration file section
       
  2191 */
       
  2192 	{
       
  2193 	return iConfigFile->Section(iSectionName);
       
  2194 	}
       
  2195 
       
  2196 const CTestConfigSection* CSimPhone::DefaultCfgFile()
       
  2197 /**
       
  2198 *	Return a pointer to the Default Configuration File Section
       
  2199 *
       
  2200 * @return CTestConfigSection	pointer to the default configuration file section
       
  2201 */
       
  2202 	{
       
  2203 	return iConfigFile->Section(KScriptDefaults);
       
  2204 	}
       
  2205 
       
  2206 TInt CSimPhone::ValidateChangeState(CSimLine* aOriginatingLine, RMobileCall::TMobileCallStatus aState)
       
  2207 /**
       
  2208 *	This function validates the proposed state change by using the iActiveLine
       
  2209 *	pointer member variable.  If the proposed change of state would clash with
       
  2210 *	an existing call, the change is	errored.
       
  2211 *	The function also updates the iMode state to reflect the new call state.
       
  2212 *
       
  2213 * @param aOriginatingLine pointer to the line requesting for the change of state
       
  2214 * @param aState the state the aOriginatingLine wants to change to
       
  2215 * @return Error indicates whether the change of state is successful or not
       
  2216 */
       
  2217 	{
       
  2218 	__ASSERT_ALWAYS(iMode!=RPhone::EModeUnknown,SimPanic(EPhoneModeUnknownIllegal));
       
  2219 	__ASSERT_ALWAYS(iNtwkMode!=RMobilePhone::ENetworkModeUnknown,SimPanic(ENetworkModeUnknownIllegal));
       
  2220 
       
  2221 // If there is no active line defined, then any state changes are fine.  However,
       
  2222 // we need to watch for a shift to an "active" status.
       
  2223 	LOGPHONE1(">>CSimPhone::ValidateChangeState");
       
  2224 	if(!iActiveLine)
       
  2225 		{
       
  2226 		iMode=ConvertStateToMode(aState);
       
  2227 		if(IsStateActive(aState))
       
  2228 			iActiveLine=aOriginatingLine;
       
  2229 		// If a call is in progress, we may need to trigger NotifyIndicatorChange
       
  2230 		CheckIndicatorNotification();
       
  2231 		return KErrNone;
       
  2232 		}
       
  2233 
       
  2234 // If this state change request is coming from the active line then any state changes
       
  2235 // are ok, but we must watch for a change that would "deactivate" the line.
       
  2236 	if(iActiveLine==aOriginatingLine)
       
  2237 		{
       
  2238 		iMode=ConvertStateToMode(aState);
       
  2239 		if(!IsStateActive(aState))
       
  2240 			iActiveLine=NULL;
       
  2241 		// If a call is in progress, we may need to trigger NotifyIndicatorChange
       
  2242 		CheckIndicatorNotification();
       
  2243 		return KErrNone;
       
  2244 		}
       
  2245 
       
  2246 // If we have got this far, then there is an active line, but this state change
       
  2247 // request has not come from it.  If this is the case, then a change to ringing
       
  2248 // or Idle are the only valid state changes.
       
  2249 
       
  2250 	if((aState==RMobileCall::EStatusRinging) ||
       
  2251 	   (aState==RMobileCall::EStatusIdle))
       
  2252 		return KErrNone;
       
  2253 
       
  2254 	LOGPHONE1("<<CSimPhone::ValidateChangeState");
       
  2255 	return KErrGeneral;
       
  2256 	}
       
  2257 
       
  2258 TInt CSimPhone::FindActiveVoiceCall(CSimVoiceCall*& aCall)
       
  2259 /**
       
  2260  * Find an active voice call.  Return KErrNotFound if no voice calls active.
       
  2261  * @param aCall		Pointer to active voice call.
       
  2262  * @return TInt		Standard return error.
       
  2263  */
       
  2264 	{
       
  2265 	return iVoiceLine->FindActiveVoiceCall(aCall);
       
  2266 	}
       
  2267 
       
  2268 TInt CSimPhone::ValidateChangeState(RPacketService::TStatus aState)
       
  2269 /**
       
  2270 *	This function validates the proposed state change by using the iActiveLine
       
  2271 *	pointer member variable.  If the proposed change of state would clash with
       
  2272 *	an existing call, the change is	errored.
       
  2273 *	The function also updates the iMode state to reflect the new call state.
       
  2274 *
       
  2275 * @param aOriginatingLine pointer to the line requesting for the change of state
       
  2276 * @param aState the state the aOriginatingLine wants to change to
       
  2277 * @return Error indicates whether the change of state is successful or not
       
  2278 */
       
  2279 	{
       
  2280 	LOGPHONE1(">>CSimPhone::ValidateChangeState packet");
       
  2281 	__ASSERT_ALWAYS(iMode!=RPhone::EModeUnknown,SimPanic(EPhoneModeUnknownIllegal));
       
  2282 	__ASSERT_ALWAYS(iNtwkMode!=RMobilePhone::ENetworkModeUnknown,SimPanic(ENetworkModeUnknownIllegal));
       
  2283 	__ASSERT_ALWAYS(iPacketService->MSClass()!=RPacketService::EMSClassUnknown,SimPanic(EPacketMSClassUnKnown));
       
  2284 
       
  2285 //we must know the type of class the phone supports in order to determine what action to take.
       
  2286 	switch(iPacketService->MSClass())
       
  2287 		{
       
  2288 	case RPacketService::EMSClassDualMode:				//< Active Simultaneous PS & CS calls supported (ClassA)
       
  2289 		return KErrNone;
       
  2290 	case RPacketService::EMSClassSuspensionRequired:	//< Active CS & Suspended PS simultaneous calls supported (ClassB)
       
  2291 		if(iMode == RPhone::EModeIdle)
       
  2292 			return KErrNone;
       
  2293 		else if((aState == RPacketService::EStatusUnattached) || (aState == RPacketService::EStatusSuspended))
       
  2294 			return KErrNone;
       
  2295 		else return KErrNotSupported; //Should actually force a suspend of the packet context and service
       
  2296 	case RPacketService::EMSClassAlternateMode:			//< Active CS or Active PS only call supported (ClassC)
       
  2297 		if(iMode == RPhone::EModeIdle)
       
  2298 			return KErrNone;
       
  2299 		else if(aState == RPacketService::EStatusUnattached)
       
  2300 			return KErrNone;
       
  2301 		else return KErrNotSupported;
       
  2302 	case RPacketService::EMSClassCircuitSwitchedOnly:	//< Active CS only call supported (ClassC)
       
  2303 		return KErrNotSupported; //Should actually force a detach from the network if not in unattached state already
       
  2304 	case RPacketService::EMSClassPacketSwitchedOnly:	//< Active PS only call supported (ClassC)
       
  2305 		return KErrNone; //Should disconnect all active calls if mode is not Idle.
       
  2306 	default:
       
  2307 		return KErrNotSupported;
       
  2308 		}
       
  2309 	}
       
  2310 
       
  2311 RMobilePhone::TMobilePhoneBatteryStatus CSimPhone::BatteryStatus()
       
  2312 	{
       
  2313 	return iBatteryCharger->Status();
       
  2314 	}
       
  2315 
       
  2316 RMobilePhone::TMobilePhoneRegistrationStatus CSimPhone::RegistrationStatus()
       
  2317 	{
       
  2318 	return iNetworkStatus->RegistrationStatus();
       
  2319 	}
       
  2320 
       
  2321 void CSimPhone::CheckIndicatorNotification()
       
  2322 	{
       
  2323 	iIndicator->CheckNotification();
       
  2324 	}
       
  2325 
       
  2326 /**
       
  2327 * A utility function for checking whether the first pin on the phone 
       
  2328 * requires authentication 
       
  2329 *
       
  2330 * @return TBool true if required and false if not 
       
  2331 */
       
  2332 TBool CSimPhone::IsICCLocked()
       
  2333 	{
       
  2334 	return iPhoneSecurity->IsICCLocked();
       
  2335 	}
       
  2336 
       
  2337 /**
       
  2338 * A utility function for checking whether the second pin on the phone 
       
  2339 * requires authentication 
       
  2340 *
       
  2341 * @return TBool true if required and false if not 
       
  2342 */
       
  2343 TBool CSimPhone::IsPIN2Locked()
       
  2344 	{
       
  2345 	return iPhoneSecurity->IsPIN2Locked();
       
  2346 	}
       
  2347 
       
  2348 TBool CSimPhone::IsHiddenEnabled()
       
  2349 	{
       
  2350 	return iPhoneSecurity->IsHiddenEnabled();
       
  2351 	}
       
  2352 
       
  2353 void CSimPhone::SecurityEvent(RMobilePhone::TMobilePhoneSecurityEvent aEvent)
       
  2354 	{
       
  2355 	iPhoneSecurity->SecurityEvent(aEvent);
       
  2356 	}
       
  2357 
       
  2358 RMobilePhone::TAID CSimPhone::GetActiveUSim()
       
  2359 	{
       
  2360 	if(iPhoneUSimApp->FoundUSimAppTags())
       
  2361 		{
       
  2362 		return iPhoneUSimApp->GetActiveUSim();
       
  2363 		}
       
  2364 	else
       
  2365 		{
       
  2366 		return iPhoneSmartCardApp->GetActiveUSim();
       
  2367 		}
       
  2368 	
       
  2369 	}
       
  2370 
       
  2371 RMobilePhone::TMobilePhoneSubscriberId CSimPhone::GetImsi()
       
  2372 	{
       
  2373 	return iSubscriberId.iIMSI;
       
  2374 	}
       
  2375 void CSimPhone::GetPhoneIdAndCaps()
       
  2376 	{
       
  2377 	TPtrC8 imei, model, manufacturer, revision;
       
  2378 	const CTestConfigItem* item=CfgFile()->Item(KPhoneId);
       
  2379 	if (item)
       
  2380 		{
       
  2381 		TInt ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,manufacturer);
       
  2382 		if(ret!=KErrNone)
       
  2383 			LOGPARSERR("manufacturer",ret,0,&KPhoneId);
       
  2384 		ret = CTestConfig::GetElement(item->Value(),KStdDelimiter,1,model);
       
  2385 		if(ret!=KErrNone)
       
  2386 			LOGPARSERR("model",ret,1,&KPhoneId);
       
  2387 		ret = CTestConfig::GetElement(item->Value(),KStdDelimiter,2,revision);
       
  2388 		if(ret!=KErrNone)
       
  2389 			LOGPARSERR("revision",ret,2,&KPhoneId);
       
  2390 		ret = CTestConfig::GetElement(item->Value(),KStdDelimiter,3,imei);
       
  2391 		if(ret!=KErrNone)
       
  2392 			LOGPARSERR("imei",ret,3,&KPhoneId);
       
  2393 		ret = CTestConfig::GetElement(item->Value(),KStdDelimiter,4,iPhoneId.iError);
       
  2394 
       
  2395 		iPhoneId.iManufacturerId.Copy(manufacturer);
       
  2396 		iPhoneId.iModelId.Copy(model);
       
  2397 		iPhoneId.iRevisionId.Copy(revision);
       
  2398 		iPhoneId.iSerialId.Copy(imei);
       
  2399 		}
       
  2400 	else
       
  2401 		{
       
  2402 		//set to default
       
  2403 		iPhoneId.iManufacturerId.Copy(KPhoneManufacturerDefault);
       
  2404 		iPhoneId.iModelId.Copy(KPhoneModelDefault);
       
  2405 		iPhoneId.iRevisionId.Copy(KPhoneRevesionDefault);
       
  2406 		iPhoneId.iSerialId.Copy(KPhoneSerialNumberDefault);
       
  2407 		iPhoneId.iError = KErrNone;
       
  2408 		}
       
  2409 
       
  2410 	//Set Phone Identity Caps
       
  2411 	iPhoneIdCaps = 0;
       
  2412 	if(iPhoneId.iManufacturerId.Length() > 0)
       
  2413 		iPhoneIdCaps |= RMobilePhone::KCapsGetManufacturer;
       
  2414 
       
  2415 	if(iPhoneId.iModelId.Length() > 0)
       
  2416 		iPhoneIdCaps |=  RMobilePhone::KCapsGetModel;
       
  2417 
       
  2418 	if(iPhoneId.iRevisionId.Length() > 0)
       
  2419 		iPhoneIdCaps |=  RMobilePhone::KCapsGetRevision;
       
  2420 
       
  2421 	if(iPhoneId.iSerialId.Length() > 0)
       
  2422 		iPhoneIdCaps |=  RMobilePhone:: KCapsGetSerialNumber;
       
  2423 
       
  2424 	if(iSubscriberId.iIMSI.Length() > 0)
       
  2425 		iPhoneIdCaps |=  RMobilePhone::KCapsGetSubscriberId;
       
  2426 	}
       
  2427 
       
  2428 TInt CSimPhone::GetIdentityCaps(TTsyReqHandle aReqHandle, TUint32& aCaps)
       
  2429 	{
       
  2430 	aCaps = iPhoneIdCaps;
       
  2431 	ReqCompleted(aReqHandle,KErrNone);
       
  2432 	return KErrNone;
       
  2433 	}
       
  2434 	
       
  2435 /**
       
  2436 * A utility function for checking whether a service is active in the service table
       
  2437 *
       
  2438 * @param aTable pointer to the table to be tested for active service
       
  2439 * @param aOffset to pointer in the service table
       
  2440 * @param aModifier which service to be tested for in the table
       
  2441 * @return TBool true if active and false if not enabled
       
  2442 */		
       
  2443 TBool CSimPhone::ServiceEnabled(RMobilePhone::TMobilePhoneServiceTableV1* aTable, 
       
  2444 								TInt aOffset, 
       
  2445 								TUint8 aModifier)
       
  2446 	{
       
  2447 	if (aTable)
       
  2448 		{
       
  2449 		TUint8* pService = &(aTable->iServices1To8);
       
  2450 		TUint8 service = *(pService+aOffset);		
       
  2451 		if (service & aModifier)
       
  2452 			{
       
  2453 			return true;
       
  2454 			}
       
  2455 		}
       
  2456 	return false;
       
  2457 	}
       
  2458 
       
  2459 /**
       
  2460 * An IPC support function for counting the number of entries in the Acces Point Name (APN) List
       
  2461 *
       
  2462 * @param aReqHandle handle to the IPC call used for completing the round trip
       
  2463 * @param aIndex a pointer to some memory for storing the number of entries
       
  2464 * @return TInt always returns KErrNone
       
  2465 */
       
  2466 TInt CSimPhone::EnumerateAPNEntries(TTsyReqHandle aReqHandle, TUint32* aIndex)
       
  2467 	{
       
  2468 	if (IsICCLocked())
       
  2469 		{
       
  2470 		SYMBIAN_REQEXTERR(aReqHandle, KErrGsm0707SimPin1Required, KErrAccessDenied);
       
  2471 		return KErrNone;
       
  2472 		}
       
  2473 		
       
  2474 	if (ServiceEnabled(iUSIMServiceTable,iAPNServiceOffset,RMobilePhone::KUstACL))
       
  2475 		{
       
  2476 		if (ServiceEnabled(iUSIMEnabledServiceTable,iAPNServiceOffset,RMobilePhone::KUstACL))
       
  2477 			{
       
  2478 			*aIndex = iAPNList.Count();
       
  2479 			ReqCompleted(aReqHandle,KErrNone);
       
  2480 			}
       
  2481 		else
       
  2482 			{
       
  2483 			SYMBIAN_REQEXTERR(aReqHandle,KErrMMEtelAPNEnabledServicesTableNotFound,KErrNotFound);
       
  2484 			}		
       
  2485 		}
       
  2486 	else
       
  2487 		{
       
  2488 		SYMBIAN_REQEXTERR(aReqHandle,KErrMMEtelAPNNameACLNotFound,KErrNotSupported);
       
  2489 		}
       
  2490 
       
  2491 	return KErrNone;
       
  2492 	}
       
  2493 	
       
  2494 /**
       
  2495 * An IPC support function for retrieving a name in the Acces Point Name (APN) List
       
  2496 *
       
  2497 * @param aReqHandle handle to the IPC call used for completing the round trip
       
  2498 * @param aIndex a index into the APN List for the name to be retrieved
       
  2499 * @param aRetrieved a TAPNEntryV3Pckg to store the name from the APN List
       
  2500 * @return TInt always returns KErrNone
       
  2501 */	
       
  2502 TInt CSimPhone::GetAPNname(	TTsyReqHandle aReqHandle, 
       
  2503 							TUint32& aIndex, 
       
  2504 							RMobilePhone::TAPNEntryV3Pckg& aRetrieved)
       
  2505 	{
       
  2506 	if (IsICCLocked())
       
  2507 		{
       
  2508 		ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrGsm0707SimPin1Required,	KErrAccessDenied));		
       
  2509 		return KErrNone;
       
  2510 		}
       
  2511 			
       
  2512 	if (ServiceEnabled(iUSIMServiceTable,iAPNServiceOffset,RMobilePhone::KUstACL))
       
  2513 		{
       
  2514 		if (ServiceEnabled(iUSIMEnabledServiceTable,iAPNServiceOffset,RMobilePhone::KUstACL))
       
  2515 			{	
       
  2516 			if (aIndex < iAPNList.Count() )
       
  2517 				{
       
  2518 				RMobilePhone::TAPNEntryV3& tAPNEntryV3 = aRetrieved();
       
  2519 				
       
  2520 				tAPNEntryV3.iApn.Zero();
       
  2521 				tAPNEntryV3.iApn.Insert(0,iAPNList[aIndex].iApn);
       
  2522 				
       
  2523 				ReqCompleted(aReqHandle,KErrNone);
       
  2524 				}
       
  2525 			else
       
  2526 				{
       
  2527 				ReqCompleted(aReqHandle,SYMBIAN_EXTERR(KErrMMEtelAPNNameInvalidIndex,KErrNotFound));
       
  2528 				}
       
  2529 			}
       
  2530 		else
       
  2531 			{
       
  2532 			ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrMMEtelAPNEnabledServicesTableNotFound,
       
  2533 													KErrNotFound));
       
  2534 			}		
       
  2535 		}
       
  2536 	else
       
  2537 		{
       
  2538 		ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrMMEtelAPNNameACLNotFound,
       
  2539 												KErrNotSupported));
       
  2540 		}
       
  2541 	return KErrNone;		
       
  2542 	}
       
  2543 	
       
  2544 /**
       
  2545 * An IPC support function for adding a name to the Acces Point Name (APN) List
       
  2546 *
       
  2547 * @param aReqHandle handle to the IPC call used for completing the round trip
       
  2548 * @param aIndex a index into the APN List for the name to be retrieved
       
  2549 * @param aEntry a TAPNEntryV3Pckg to add to the end of the APN List
       
  2550 * @return TInt always returns KErrNone
       
  2551 */				
       
  2552 TInt CSimPhone::AppendAPNName(TTsyReqHandle aReqHandle, RMobilePhone::TAPNEntryV3Pckg& aEntry)
       
  2553 	{
       
  2554 	if (IsPIN2Locked())
       
  2555 		{
       
  2556 		ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrGsm0707SimPin2Required,	KErrAccessDenied));		
       
  2557 		return KErrNone;
       
  2558 		}
       
  2559 			
       
  2560 	if (ServiceEnabled(iUSIMServiceTable,iAPNServiceOffset,RMobilePhone::KUstACL))
       
  2561 		{
       
  2562 		if (ServiceEnabled(iUSIMEnabledServiceTable,iAPNServiceOffset,RMobilePhone::KUstACL))
       
  2563 			{		
       
  2564 			RMobilePhone::TAPNEntryV3& entry = (aEntry)();
       
  2565 			iAPNList.Append(entry);
       
  2566 			
       
  2567 			ReqCompleted(aReqHandle,KErrNone);
       
  2568 			
       
  2569 			if (iAPNListNotify.iNotifyPending == TRUE)
       
  2570 				{
       
  2571 				iAPNListNotify.iNotifyPending = EFalse;
       
  2572 				ReqCompleted(iAPNListNotify.iNotifyHandle,KErrNone);
       
  2573 				}
       
  2574 			}
       
  2575 		else
       
  2576 			{
       
  2577 			ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrMMEtelAPNEnabledServicesTableNotFound,
       
  2578 													KErrNotFound));
       
  2579 			}		
       
  2580 		}
       
  2581 	else
       
  2582 		{
       
  2583 		ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrMMEtelAPNNameACLNotFound,
       
  2584 												KErrNotSupported));
       
  2585 		}
       
  2586 			
       
  2587 	return KErrNone;
       
  2588 	}	
       
  2589 	
       
  2590 /**
       
  2591 * An IPC support function for removing a name from the Acces Point Name (APN) List
       
  2592 *
       
  2593 * @param aReqHandle handle to the IPC call used for completing the round trip
       
  2594 * @param aIndex a index into the APN List for the name to be deleted
       
  2595 * @return TInt always returns KErrNone
       
  2596 */		
       
  2597 TInt CSimPhone::DeleteAPNName(TTsyReqHandle aReqHandle, TUint32& aIndex)
       
  2598 	{
       
  2599 	if (IsPIN2Locked())
       
  2600 		{
       
  2601 		ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrGsm0707SimPin2Required,	KErrAccessDenied));		
       
  2602 		return KErrNone;
       
  2603 		}
       
  2604 			
       
  2605 	if (ServiceEnabled(iUSIMServiceTable,iAPNServiceOffset,RMobilePhone::KUstACL))
       
  2606 		{
       
  2607 		if (ServiceEnabled(iUSIMEnabledServiceTable,iAPNServiceOffset,RMobilePhone::KUstACL))
       
  2608 			{		
       
  2609 			if (aIndex < iAPNList.Count())
       
  2610 				{
       
  2611 				iAPNList.Remove(aIndex);
       
  2612 				iAPNList.Compress();
       
  2613 				ReqCompleted(aReqHandle,KErrNone);
       
  2614 				if (iAPNListNotify.iNotifyPending == TRUE)
       
  2615 					{
       
  2616 					iAPNListNotify.iNotifyPending = EFalse;
       
  2617 					ReqCompleted(iAPNListNotify.iNotifyHandle,KErrNone);
       
  2618 					}
       
  2619 				}
       
  2620 			else
       
  2621 				{
       
  2622 				ReqCompleted(aReqHandle,SYMBIAN_EXTERR(KErrMMEtelAPNNameInvalidIndex,KErrNotFound));			
       
  2623 				}
       
  2624 			}
       
  2625 		else
       
  2626 			{
       
  2627 			ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrMMEtelAPNEnabledServicesTableNotFound,
       
  2628 													KErrNotFound));
       
  2629 			}		
       
  2630 		}
       
  2631 	else
       
  2632 		{
       
  2633 		ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrMMEtelAPNNameACLNotFound,
       
  2634 												KErrNotSupported));
       
  2635 		}
       
  2636 	return KErrNone;
       
  2637 	}
       
  2638 
       
  2639 /**
       
  2640 * An IPC support function for registering interest in APN List changes
       
  2641 *
       
  2642 * @param aReqHandle handle to the IPC call used for completing the round trip
       
  2643 * @return TInt always returns KErrNone
       
  2644 */		
       
  2645 TInt CSimPhone::NotifyAPNListChanged(TTsyReqHandle aReqHandle)
       
  2646 	{
       
  2647 	if (ServiceEnabled(iUSIMServiceTable,iAPNServiceOffset,RMobilePhone::KUstACL))
       
  2648 		{
       
  2649 		if (ServiceEnabled(iUSIMEnabledServiceTable,iAPNServiceOffset,RMobilePhone::KUstACL))
       
  2650 			{
       
  2651 			iAPNListNotify.iNotifyPending = ETrue;
       
  2652 			iAPNListNotify.iNotifyHandle = aReqHandle;
       
  2653 			}
       
  2654 		else
       
  2655 			{
       
  2656 			ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrMMEtelAPNEnabledServicesTableNotFound,
       
  2657 													KErrNotFound));
       
  2658 			}		
       
  2659 		}
       
  2660 	else
       
  2661 		{
       
  2662 		ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrMMEtelAPNNameACLNotFound,
       
  2663 												KErrNotSupported));
       
  2664 		}
       
  2665 	return KErrNone;	
       
  2666 	}
       
  2667 	
       
  2668 /**
       
  2669 * An IPC support function for switching the Acces Point Name (APN) List to enabled or disabled
       
  2670 *
       
  2671 * @param aReqHandle handle to the IPC call used for completing the round trip
       
  2672 * @param aAPNControlListServiceStatus service status to be set
       
  2673 * @return TInt always returns KErrNone
       
  2674 */		
       
  2675 TInt CSimPhone::SetAPNControlListServiceStatus(TTsyReqHandle aReqHandle, 
       
  2676 		RMobilePhone::TAPNControlListServiceStatus& aAPNControlListServiceStatus)	
       
  2677 	{
       
  2678 	if (IsPIN2Locked())
       
  2679 		{
       
  2680 		ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrGsm0707SimPin2Required,	KErrAccessDenied));		
       
  2681 		return KErrNone;
       
  2682 		}
       
  2683 			
       
  2684 	if (ServiceEnabled(iUSIMServiceTable,iAPNServiceOffset,RMobilePhone::KUstACL))
       
  2685 		{
       
  2686 		switch (aAPNControlListServiceStatus)
       
  2687 			{
       
  2688 			case RMobilePhone::EAPNControlListServiceDisabled:
       
  2689 				{
       
  2690 				if (iUSIMEnabledServiceTable)
       
  2691 					{
       
  2692 					iUSIMEnabledServiceTable->iServices33To40 = 
       
  2693 					(iUSIMEnabledServiceTable->iServices33To40 & RMobilePhone::KUstACL) 
       
  2694 						^ iUSIMEnabledServiceTable->iServices33To40;
       
  2695 						
       
  2696 					ReqCompleted(aReqHandle,KErrNone);
       
  2697 					if (iAPNStatusNotify.iNotifyPending == TRUE)
       
  2698 						{
       
  2699 						*static_cast<RMobilePhone::TAPNControlListServiceStatus*>(iAPNStatusNotify.iNotifyData) = 
       
  2700 								RMobilePhone::EAPNControlListServiceDisabled;
       
  2701 						iAPNStatusNotify.iNotifyPending = EFalse;
       
  2702 						ReqCompleted(iAPNStatusNotify.iNotifyHandle,KErrNone);
       
  2703 						}					
       
  2704 					}
       
  2705 				else
       
  2706 					{
       
  2707 					ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrMMEtelAPNEnabledServicesTableNotFound,
       
  2708 															KErrNotSupported));					
       
  2709 					}
       
  2710 				}
       
  2711 				break;				
       
  2712 			case RMobilePhone::EAPNControlListServiceEnabled:
       
  2713 				{
       
  2714 				if (iUSIMEnabledServiceTable)
       
  2715 					{
       
  2716 					iUSIMEnabledServiceTable->iServices33To40 |= RMobilePhone::KUstACL;
       
  2717 					ReqCompleted(aReqHandle,KErrNone);
       
  2718 					if (iAPNStatusNotify.iNotifyPending == TRUE)
       
  2719 						{
       
  2720 						*static_cast<RMobilePhone::TAPNControlListServiceStatus*>(iAPNStatusNotify.iNotifyData) = 
       
  2721 								RMobilePhone::EAPNControlListServiceEnabled;						
       
  2722 						iAPNStatusNotify.iNotifyPending = EFalse;
       
  2723 						ReqCompleted(iAPNStatusNotify.iNotifyHandle,KErrNone);
       
  2724 						}
       
  2725 					}
       
  2726 				else
       
  2727 					{
       
  2728 					ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrMMEtelAPNEnabledServicesTableNotFound,
       
  2729 															KErrNotSupported));	
       
  2730 					}						
       
  2731 				}
       
  2732 				break;	
       
  2733 			default:
       
  2734 				ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrMMEtelFormatNotSupported,
       
  2735 														KErrNotFound));				
       
  2736 			}
       
  2737 		}
       
  2738 	else
       
  2739 		{
       
  2740 		ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrMMEtelAPNEnabledServicesTableNotFound,
       
  2741 												KErrNotSupported));		
       
  2742 		}
       
  2743 	return KErrNone;	
       
  2744 	}
       
  2745 	
       
  2746 /**
       
  2747 * An IPC support function for retrieving the Acces Point Name (APN) List enabled/ disabled
       
  2748 * status
       
  2749 *
       
  2750 * @param aReqHandle handle to the IPC call used for completing the round trip
       
  2751 * @param aAPNControlListServiceStatus memory for storing the current status for the user
       
  2752 * @return TInt always returns KErrNone
       
  2753 */		
       
  2754 TInt CSimPhone::GetAPNControlListServiceStatus(TTsyReqHandle aReqHandle, 
       
  2755 		RMobilePhone::TAPNControlListServiceStatus& aAPNControlListServiceStatus)
       
  2756 	{
       
  2757 	if (IsICCLocked())
       
  2758 		{
       
  2759 		ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrGsm0707SimPin1Required,	KErrAccessDenied));		
       
  2760 		return KErrNone;
       
  2761 		}
       
  2762 			
       
  2763 	if (ServiceEnabled(iUSIMServiceTable,iAPNServiceOffset,RMobilePhone::KUstACL))
       
  2764 		{
       
  2765 		if (ServiceEnabled(iUSIMEnabledServiceTable,iAPNServiceOffset,RMobilePhone::KUstACL))
       
  2766 			{
       
  2767 			aAPNControlListServiceStatus = RMobilePhone::EAPNControlListServiceEnabled;
       
  2768 			}
       
  2769 		else
       
  2770 			{
       
  2771 			aAPNControlListServiceStatus = RMobilePhone::EAPNControlListServiceDisabled;
       
  2772 			}	
       
  2773 		ReqCompleted(aReqHandle,KErrNone);	
       
  2774 		}
       
  2775 	else
       
  2776 		{
       
  2777 		ReqCompleted(aReqHandle,SYMBIAN_EXTERR(	KErrMMEtelAPNEnabledServicesTableNotFound,
       
  2778 												KErrNotSupported));				
       
  2779 		}
       
  2780 	return KErrNone;	
       
  2781 	}
       
  2782 	
       
  2783 /**
       
  2784 * An IPC support function for registering interest in the Acces Point Name (APN) List 
       
  2785 * enabled/ disabled status changing
       
  2786 *
       
  2787 * @param aReqHandle handle to the IPC call used for completing the round trip
       
  2788 * @param aAPNControlListServiceStatus memory for storing the current status for the user
       
  2789 * @return TInt always returns KErrNone
       
  2790 */			
       
  2791 TInt CSimPhone::NotifyAPNControlListServiceStatusChange(TTsyReqHandle aReqHandle, 
       
  2792 		RMobilePhone::TAPNControlListServiceStatus& aAPNControlListServiceStatus)
       
  2793 	{
       
  2794 	iAPNStatusNotify.iNotifyPending = ETrue;
       
  2795 	iAPNStatusNotify.iNotifyHandle = aReqHandle;
       
  2796 	iAPNStatusNotify.iNotifyData = &aAPNControlListServiceStatus;
       
  2797 	return KErrNone;	
       
  2798 	}
       
  2799 	
       
  2800 /**
       
  2801 * A utility function for checking table availabilty and performing a copy on it
       
  2802 *
       
  2803 * @param aFrom The TMobilePhoneServiceTableV1 table to copied out of
       
  2804 * @param aTo The TMobilePhoneServiceTableV1 table to copied into
       
  2805 * @return TInt returns KErrNone for success and KErrNotSupported if the table aren't 
       
  2806 * valid
       
  2807 */		
       
  2808 TInt CSimPhone::CopyServiceTable(RMobilePhone::TMobilePhoneServiceTableV1* aFrom, 
       
  2809 		RMobilePhone::TMobilePhoneServiceTableV1* aTo)
       
  2810 	{
       
  2811 	if (aFrom && aTo)
       
  2812 		{
       
  2813 		*aTo = *aFrom;
       
  2814 		return KErrNone;
       
  2815 		}
       
  2816 	else 
       
  2817 		{
       
  2818 		// This value is returned because this function tests the existance of the table 
       
  2819 		// not just that the args are OK.
       
  2820 		return SYMBIAN_EXTERR(KErrMMEtelAPNEnabledServicesTableNotFound, KErrNotSupported);
       
  2821 		}
       
  2822 	}
       
  2823 	
       
  2824 /**
       
  2825  * A utility function for checking table availabilty and performing a copy on it
       
  2826  *
       
  2827  * @param aFrom The TMobilePhoneServiceTableV8 table to copied out of
       
  2828  * @param aTo The TMobilePhoneServiceTableV8 table to copied into
       
  2829  * @return TInt returns KErrNone for success and KErrNotSupported if the table aren't 
       
  2830  * valid
       
  2831  */		
       
  2832  TInt CSimPhone::CopyServiceTableV8(RMobilePhone::TMobilePhoneServiceTableV8* aFrom, 
       
  2833  		RMobilePhone::TMobilePhoneServiceTableV8* aTo)
       
  2834  	{
       
  2835  	if (aFrom && aTo)
       
  2836  		{
       
  2837  		*aTo = *aFrom;
       
  2838  		return KErrNone;
       
  2839  		}
       
  2840  	else 
       
  2841  		{
       
  2842  		// This value is returned because this function tests the existance of the table 
       
  2843  		// not just that the args are OK.
       
  2844  		return SYMBIAN_EXTERR(KErrMMEtelAPNEnabledServicesTableNotFound, KErrNotSupported);
       
  2845  		}
       
  2846  	}
       
  2847 
       
  2848 /**
       
  2849 * An IPC support function for retrieving one of the service tables
       
  2850 *
       
  2851 * @param aReqHandle handle to the IPC call used for completing the round trip
       
  2852 * @param aTable the type of table the user has interest in
       
  2853 * @param aPCmd memory to store the retrieved table
       
  2854 * @return TInt always returns KErrNone
       
  2855 */		
       
  2856 TInt CSimPhone::GetServiceTable(TTsyReqHandle aReqHandle, 
       
  2857 		RMobilePhone::TMobilePhoneServiceTable aTable, 
       
  2858 		TDes8* aPCmd)	
       
  2859 	{
       
  2860 	TInt ret = KErrNone;
       
  2861 	RMobilePhone::TMobilePhoneServiceTableV1Pckg *pTablePckg = (RMobilePhone::TMobilePhoneServiceTableV1Pckg*) aPCmd;
       
  2862 	RMobilePhone::TMobilePhoneServiceTableV1 &aSst = (*pTablePckg)();
       
  2863 	
       
  2864 	switch (aTable)
       
  2865 		{
       
  2866 
       
  2867 		/** Retrieve SIM service table from active SIM application on UICC.
       
  2868 		 Modes: GSM/WCDMA */
       
  2869 		case RMobilePhone::ESIMServiceTable:
       
  2870 			ret = CopyServiceTable (iSIMServiceTable, &aSst);
       
  2871 			break;
       
  2872 			/** Retrieve USIM service table from active USIM application on UICC.
       
  2873 			 
       
  2874 			 Modes: WCDMA */
       
  2875 		case RMobilePhone::EUSIMServiceTable:
       
  2876 			if ( aSst.ExtensionId ()== KEtelExtMultimodeV8)
       
  2877 				{
       
  2878 				RMobilePhone::TMobilePhoneServiceTableV8Pckg* pTableV8Pckg = (RMobilePhone::TMobilePhoneServiceTableV8Pckg*) aPCmd;
       
  2879 				RMobilePhone::TMobilePhoneServiceTableV8 &pTableV8 = (*pTableV8Pckg) ();
       
  2880 				ret = CopyServiceTableV8 (iUSIMServiceTableV8, &pTableV8);
       
  2881 				}
       
  2882 			else
       
  2883 				{
       
  2884 				ret = CopyServiceTable (iUSIMServiceTable, &aSst);
       
  2885 				}
       
  2886 			break;
       
  2887 			/** USIM Enabled Services Table to be used in conjunction with the USIM Service Table.
       
  2888 			 
       
  2889 			 Modes: WCDMA */
       
  2890 		case RMobilePhone::EUSIMEnabledServiceTable:
       
  2891 			ret = CopyServiceTable (iUSIMEnabledServiceTable, &aSst);
       
  2892 			break;
       
  2893 		default:
       
  2894 			ReqCompleted (aReqHandle, SYMBIAN_EXTERR( KErrMMEtelFormatNotSupported,
       
  2895 					KErrArgument));
       
  2896 			return KErrNone;
       
  2897 		}
       
  2898 	// Extended error codes are handled here by the CopyServiceTable() func.
       
  2899 	ReqCompleted(aReqHandle,ret);
       
  2900 	return KErrNone;
       
  2901 	}
       
  2902 
       
  2903 TInt CSimPhone::GetPhoneId(TTsyReqHandle aReqHandle,RMobilePhone::TMobilePhoneIdentityV1* aPhoneId)
       
  2904 	{
       
  2905 
       
  2906 	//complete with error if error specified.
       
  2907 	if(iPhoneId.iError != KErrNone)
       
  2908 		{
       
  2909 		ReqCompleted(aReqHandle,iPhoneId.iError);
       
  2910 		return KErrNone;
       
  2911 		}
       
  2912 	//fill out phone identity.
       
  2913 	if(iPhoneIdCaps & RMobilePhone:: KCapsGetManufacturer)
       
  2914 		{
       
  2915 		if(iPhoneId.iManufacturerId.Length() > RMobilePhone::KPhoneManufacturerIdSize)
       
  2916 			aPhoneId->iManufacturer.Copy(iPhoneId.iManufacturerId.Left(RMobilePhone::KPhoneManufacturerIdSize));
       
  2917 		else
       
  2918 			aPhoneId->iManufacturer.Copy(iPhoneId.iManufacturerId);
       
  2919 		}
       
  2920 
       
  2921 	if(iPhoneIdCaps & RMobilePhone::KCapsGetModel)
       
  2922 		{
       
  2923 		if(iPhoneId.iModelId.Length() > RMobilePhone::KPhoneModelIdSize)
       
  2924 			aPhoneId->iModel.Copy(iPhoneId.iModelId.Left(RMobilePhone::KPhoneModelIdSize));
       
  2925 		else
       
  2926 			aPhoneId->iModel.Copy(iPhoneId.iModelId);
       
  2927 		}
       
  2928 
       
  2929 	if(iPhoneIdCaps & RMobilePhone::KCapsGetRevision)
       
  2930 		{
       
  2931 		if(iPhoneId.iRevisionId.Length() > RMobilePhone::KPhoneRevisionIdSize)
       
  2932 			aPhoneId->iRevision.Copy(iPhoneId.iRevisionId.Left(RMobilePhone::KPhoneRevisionIdSize));
       
  2933 		else
       
  2934 			aPhoneId->iRevision.Copy(iPhoneId.iRevisionId);
       
  2935 		}
       
  2936 
       
  2937 	if(iPhoneIdCaps & RMobilePhone::KCapsGetSerialNumber)
       
  2938 		{
       
  2939 		if(iPhoneId.iSerialId.Length() > RMobilePhone::KPhoneSerialNumberSize)
       
  2940 			aPhoneId->iSerialNumber.Copy(iPhoneId.iSerialId.Left(RMobilePhone::KPhoneSerialNumberSize));
       
  2941 		else
       
  2942 			aPhoneId->iSerialNumber.Copy(iPhoneId.iSerialId);
       
  2943 		}
       
  2944 
       
  2945 	ReqCompleted(aReqHandle,KErrNone);
       
  2946 	return KErrNone;
       
  2947 	}
       
  2948 
       
  2949 /**
       
  2950 	Constructor for suspend call processing timer
       
  2951 */
       
  2952 CSimPhone::CSetCallProcessingSuspendStateTimerCallBack::CSetCallProcessingSuspendStateTimerCallBack()
       
  2953 	{}
       
  2954 
       
  2955 /**
       
  2956 	Must be called before setting the timer. Simply stores the request to be completed when
       
  2957 	timer expires
       
  2958 
       
  2959  @param the pointer to the phone that the request will be completed on when the timer expires
       
  2960  @param aReqHandle handle to request that will be completed when the timer expires
       
  2961 */
       
  2962 void CSimPhone::CSetCallProcessingSuspendStateTimerCallBack::SetHandle(CSimPhone* aPhone, const TTsyReqHandle aHandle)
       
  2963 	{
       
  2964 	iPhone = aPhone;
       
  2965 	iHandle = aHandle;
       
  2966 	}
       
  2967 
       
  2968 /**
       
  2969 	Implementation of MTimerCallback::TimerCallBack
       
  2970 	Simply completes the suspend call processing request after the delay
       
  2971 */
       
  2972 void CSimPhone::CSetCallProcessingSuspendStateTimerCallBack::TimerCallBack(TInt /*aId*/)
       
  2973 	{
       
  2974 	iPhone->ReqCompleted(iHandle,KErrNone);
       
  2975 	}
       
  2976 
       
  2977 /**
       
  2978 	Constructor for network mode processing timer
       
  2979 */
       
  2980 CSimPhone::CNetworkModeTimerCallBack::CNetworkModeTimerCallBack()
       
  2981 	{
       
  2982 	}
       
  2983 
       
  2984 void CSimPhone::CNetworkModeTimerCallBack::SetHandle(CSimPhone* aPhone)
       
  2985 	{
       
  2986 	iPhone = aPhone;
       
  2987 	}
       
  2988 /**
       
  2989 	Implementation of MTimerCallback::TimerCallBack
       
  2990 	Simply completes the suspend call processing request after the delay
       
  2991 */
       
  2992 void CSimPhone::CNetworkModeTimerCallBack::TimerCallBack(TInt /*aId*/)
       
  2993 	{
       
  2994 	LOGPACKET1(">>CSimPhone::CNetworkModeTimerCallBack::TimerCallBack");
       
  2995 	iPhone->TimerCallBackNetworkMode();
       
  2996 	}
       
  2997 
       
  2998 TInt CSimPhone::NotifyModeChange(const TTsyReqHandle aTsyReqHandle, RMobilePhone::TMobilePhoneNetworkMode* aCaps)
       
  2999 	{
       
  3000 	LOGPACKET1("CSimPhone::NotifyModeChange called");
       
  3001 	__ASSERT_ALWAYS(!iNotifyNetworkModeChange.iNotifyPending,SimPanic(ENotificationAlreadyPending));
       
  3002  
       
  3003 	if (iNetworkModeArray->Count() == 0)
       
  3004 		{
       
  3005 		ReqCompleted(aTsyReqHandle,KErrNotSupported);
       
  3006 		return KErrNone;
       
  3007 		}
       
  3008 	
       
  3009 	iNotifyNetworkModeChange.iNotifyPending = ETrue;
       
  3010 	iNotifyNetworkModeChange.iNotifyHandle = aTsyReqHandle;
       
  3011 	iNotifyNetworkModeChange.iNotifyData = aCaps;
       
  3012 	return KErrNone;
       
  3013 	}
       
  3014 
       
  3015 /**
       
  3016 * Cancels a clients interest in the change of dynamic caps.
       
  3017 *
       
  3018 * @param aTsyReqHandle Tsy Request handle for the client cancel request
       
  3019 * @return KErrNone
       
  3020 */
       
  3021 TInt CSimPhone::NotifyModeChangeCancel(const TTsyReqHandle aTsyReqHandle)
       
  3022 	{
       
  3023 	LOGPACKET1("CSimPhone::NotifyModeChangeCancel called");
       
  3024 	if( (iNotifyNetworkModeChange.iNotifyPending) && (aTsyReqHandle == iNotifyNetworkModeChange.iNotifyHandle))
       
  3025 		{
       
  3026 		iNotifyNetworkModeChange.iNotifyPending=EFalse;
       
  3027 		ReqCompleted(aTsyReqHandle,KErrCancel);
       
  3028 		}
       
  3029 	return KErrNone;
       
  3030 	}
       
  3031 
       
  3032 /**
       
  3033 * Timer callback function to simulate a change in the Network Mode of the phone
       
  3034 */
       
  3035 void CSimPhone::TimerCallBackNetworkMode()
       
  3036 	{
       
  3037 	if (++iNetworkModeIndex >= iNetworkModeArray->Count())
       
  3038 		{
       
  3039 		return;
       
  3040 		}
       
  3041 	iNtwkMode = iNetworkModeArray->At(iNetworkModeIndex).iNetworkMode;
       
  3042 	if (iNotifyNetworkModeChange.iNotifyPending)
       
  3043 		{
       
  3044 		iNotifyNetworkModeChange.iNotifyPending = EFalse;
       
  3045 		*(RMobilePhone::TMobilePhoneNetworkMode*)iNotifyNetworkModeChange.iNotifyData = (RMobilePhone::TMobilePhoneNetworkMode)iNtwkMode;
       
  3046 		ReqCompleted(iNotifyNetworkModeChange.iNotifyHandle,KErrNone);
       
  3047 		}
       
  3048 	
       
  3049 	iNetworkModeTimer->Start(iNetworkModeArray->At(iNetworkModeIndex).iDuration, &iTimerCallBackNetworkMode);
       
  3050 	}
       
  3051 
       
  3052 
       
  3053 void CSimPhone::ResetTestNumber()
       
  3054 	{
       
  3055 	TInt testNumber;
       
  3056 	GetTestNumber(testNumber);
       
  3057 	iSectionName.Format(KSectionNameFormat,testNumber);
       
  3058 	}
       
  3059 
       
  3060 TInt CSimPhone::CheckSimTsyVersion(RMobilePhone::TMultimodeType& aDataStruct) // overload this for other types of structures
       
  3061 /**
       
  3062 * Checks the version of a data structure against the (simulated) version of SIMTSY, in order
       
  3063 * to determine if the version of the API used is compatible with the version of the TSY used.
       
  3064 *
       
  3065 * @param aDataStruct A versioned data-holding structure, derived from RMobilePhone::TMultimodeType
       
  3066 *
       
  3067 * @return KErrNone if the version of aDataStruct is supported by the user-defined simulated TSY version. KErrNotSupported otherwise
       
  3068 */
       
  3069 	{
       
  3070 	TInt ret = KErrNone;
       
  3071 	
       
  3072 	//retrieval of data version
       
  3073 	TInt dataVersion;
       
  3074 	switch (aDataStruct.ExtensionId())
       
  3075 		{
       
  3076 		case KETelExtMultimodeV1:
       
  3077 		case RMobilePhoneStore::KETelMobilePhonebookStoreV1:
       
  3078 		case RMobileSmsMessaging::KETelMobileSmsSendAttributesV1:
       
  3079 		case KETelExt3rdPartyV1:
       
  3080 			dataVersion = 1;
       
  3081 			break;
       
  3082 		case KETelExtMultimodeV2:
       
  3083 		//case KETelMobilePhonebookStoreV2: - omitted because it is equal to KETelExtMultimodeV2
       
  3084 			dataVersion = 2;
       
  3085 			break;
       
  3086 		case KETelExtMultimodeV3:
       
  3087 			dataVersion = 3;
       
  3088 			break;
       
  3089 		case KETelExtMultimodeV4:
       
  3090 			dataVersion = 4;
       
  3091 			break;
       
  3092 		case KEtelExtMultimodeV5:
       
  3093 		//case KETelMobilePhonebookStoreV5: - omitted because it is equal to KETelExtMultimodeV5
       
  3094 			dataVersion = 5;
       
  3095 			break;
       
  3096 		case KEtelExtMultimodeV6:
       
  3097 			dataVersion = 6;
       
  3098 			break;
       
  3099 		case KEtelExtMultimodeV7:
       
  3100 			dataVersion = 7;
       
  3101 			break;
       
  3102 		case KEtelExtMultimodeV8:
       
  3103 			dataVersion = 8;
       
  3104 			break;
       
  3105 		case KEtelExtMultimodeV9:
       
  3106 			dataVersion = 9;
       
  3107 			break;
       
  3108 		default:
       
  3109 			dataVersion = KSimTsyDefaultVersion; 
       
  3110 			break;
       
  3111 		}
       
  3112 		
       
  3113 	if(iSimTsyVersion < dataVersion)
       
  3114 		{
       
  3115 		ret = KErrNotSupported;
       
  3116 		}
       
  3117 		
       
  3118 	return ret;	
       
  3119 	}
       
  3120 
       
  3121 TInt CSimPhone::CheckSimTsyVersion(TPacketBase& aDataStruct)
       
  3122 /**
       
  3123 * Checks the version of a data structure against the (simulated) version of SIMTSY, in order
       
  3124 * to determine if the version of the API used is compatible with the version of the TSY used.
       
  3125 *
       
  3126 * @param aDataStruct A versioned data-holding structure, derived from TPacketBase
       
  3127 *
       
  3128 * @return KErrNone if the version of aDataStruct is supported by the user-defined simulated TSY version. KErrNotSupported otherwise
       
  3129 */
       
  3130 	{
       
  3131 	TInt ret = KErrNone;
       
  3132 	
       
  3133 	//retrieval of data version
       
  3134 	TInt dataVersion;
       
  3135 	switch (aDataStruct.ExtensionId())
       
  3136 		{
       
  3137 		case KETelExtPcktV1:
       
  3138 			dataVersion = 1;
       
  3139 			break;
       
  3140 		case KETelExtPcktV2:
       
  3141 			dataVersion = 2;
       
  3142 			break;
       
  3143 		case KETelExtPcktV3:
       
  3144 			dataVersion = 3;
       
  3145 			break;
       
  3146 		default:
       
  3147 			dataVersion = KSimTsyDefaultVersion; 
       
  3148 			break;
       
  3149 		}
       
  3150 		
       
  3151 	if(iSimTsyVersion < dataVersion)
       
  3152 		{
       
  3153 		ret = KErrNotSupported;
       
  3154 		}
       
  3155 		
       
  3156 	return ret;	
       
  3157 	}
       
  3158 
       
  3159 
       
  3160 TInt CSimPhone::CheckSimTsyVersion(RCall::TCallParams& aDataStruct)
       
  3161 /**
       
  3162 * Checks the version of a data structure against the (simulated) version of SIMTSY, in order
       
  3163 * to determine if the version of the API used is compatible with the version of the TSY used.
       
  3164 *
       
  3165 * @param aDataStruct A versioned data-holding structure, derived from TCallParams
       
  3166 *
       
  3167 * @return KErrNone if the version of aDataStruct is supported by the user-defined simulated TSY version. KErrNotSupported otherwise
       
  3168 */
       
  3169 	{
       
  3170 	TInt ret = KErrNone;
       
  3171 
       
  3172 	//retrieval of data version
       
  3173 	TInt dataVersion;
       
  3174 	switch (aDataStruct.ExtensionId())
       
  3175 		{
       
  3176 		case RMobileCall::KETelMobileCallParamsV1:
       
  3177 		case RMobileCall::KETelMobileDataCallParamsV1:
       
  3178 		case RMobileCall::KETelMobileHscsdCallParamsV1:
       
  3179 		case RMobileCall::KETel3rdPartyCallParamsV1:
       
  3180 			dataVersion = 1;
       
  3181 			break;
       
  3182 		case RMobileCall::KETelMobileCallParamsV2:
       
  3183 		case RMobileCall::KETelMobileDataCallParamsV2:
       
  3184 		case RMobileCall::KETelMobileHscsdCallParamsV2:
       
  3185 			dataVersion = 2;
       
  3186 			break;
       
  3187 		default:
       
  3188 			dataVersion = KSimTsyDefaultVersion; 
       
  3189 			break;
       
  3190 		}
       
  3191 		
       
  3192 	if(iSimTsyVersion < dataVersion)
       
  3193 		{
       
  3194 		ret = KErrNotSupported;
       
  3195 		}
       
  3196 		
       
  3197 	return ret;	
       
  3198 	}
       
  3199 
       
  3200 
       
  3201 TInt CSimPhone::CheckSimTsyVersion(RMobilePhone::CImsAuthorizationInfoV5& /*aDataStruct*/) // overload this for other types of structures
       
  3202 /**
       
  3203 * Checks the version of a data structure against the (simulated) version of SIMTSY, in order
       
  3204 * to determine if the version of the API used is compatible with the version of the TSY used.
       
  3205 *
       
  3206 * @param aDataStruct A versioned data-holding structure, of type RMobilePhone::CImsAuthorizationInfoV5 or a class derived from it.
       
  3207 *
       
  3208 * @return KErrNone if the version of aDataStruct is supported by the user-defined simulated TSY version. KErrNotSupported otherwise
       
  3209 */
       
  3210 	{
       
  3211 
       
  3212 	TInt ret = KErrNone;
       
  3213 	
       
  3214 	//retrieval of data version
       
  3215 	TInt dataVersion = 5; // (does not derive from the TMultimodeType data structure as usual...)
       
  3216 		
       
  3217 	if(iSimTsyVersion < dataVersion)
       
  3218 		{
       
  3219 		ret = KErrNotSupported;
       
  3220 		}
       
  3221 		
       
  3222 	return ret;	
       
  3223 	}
       
  3224 	
       
  3225 
       
  3226 TInt CSimPhone::CheckSimTsyVersion(RPacketContext::CTFTMediaAuthorizationV3& /*aDataStruct*/) // overload this for other types of structures
       
  3227 /**
       
  3228 * Checks the version of a data structure against the (simulated) version of SIMTSY, in order
       
  3229 * to determine if the version of the API used is compatible with the version of the TSY used.
       
  3230 *
       
  3231 * @param aDataStruct A versioned data-holding structure, of type RPacketContext::CTFTMediaAuthorizationV3 or a class derived from it.
       
  3232 *
       
  3233 * @return KErrNone if the version of aDataStruct is supported by the user-defined simulated TSY version. KErrNotSupported otherwise
       
  3234 */
       
  3235 	{
       
  3236 
       
  3237 	TInt ret = KErrNone;
       
  3238 	
       
  3239 	//retrieval of data version
       
  3240 	TInt dataVersion = 3; // (does not derive from the TMultimodeType data structure as usual...)
       
  3241 		
       
  3242 	if(iSimTsyVersion < dataVersion)
       
  3243 		{
       
  3244 		ret = KErrNotSupported;
       
  3245 		}
       
  3246 		
       
  3247 	return ret;	
       
  3248 	}