telephonyserverplugins/simtsy/src/CSimNetworkStatus.cpp
changeset 0 3553901f7fa8
child 19 630d2f34d719
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 // Implements the functionality required to provide clients with
       
    15 // network status, registration and NITZ information.
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21 */
       
    22 
       
    23 #include <e32property.h>
       
    24 #include <testconfigfileparser.h>
       
    25 #include <sacls.h>
       
    26 #include "CSimNetworkStatus.h"
       
    27 #include "CSimPhone.h"
       
    28 #include "Simlog.h"
       
    29 #include "CSimPubSubChange.h"
       
    30 #include "CSimTsyMode.h"
       
    31 #include "etelmmerr.h"
       
    32 #include "CSimPubSub.h"
       
    33 #include "simtsyglobalproperties.h"
       
    34 
       
    35 const TInt KSettingListGranularity=5;	// < The granularity used for parameter list arrays.
       
    36 
       
    37 // Timer values
       
    38 const TInt KNetStatTimeoutDefault=1;
       
    39 
       
    40 CSimNetworkStatus* CSimNetworkStatus::NewL(CSimPhone* aPhone)
       
    41 /**
       
    42  * Standard two-phase constructor.
       
    43  * @param aPhone				The parent phone object.
       
    44  * @return CSimNetworkStatus	The new network status class.
       
    45  */
       
    46 	{
       
    47 	CSimNetworkStatus* self=new(ELeave) CSimNetworkStatus(aPhone);
       
    48 	CleanupStack::PushL(self);
       
    49 	self->ConstructL();
       
    50 	CleanupStack::Pop();
       
    51 	return self;
       
    52 	}
       
    53 
       
    54 CSimNetworkStatus::CSimNetworkStatus(CSimPhone* aPhone)
       
    55 		: iPhone(aPhone)
       
    56 /**
       
    57  * Trivial first phase construction.
       
    58  * @param aPhone				The parent phone object.
       
    59  */
       
    60 	{
       
    61 	iCurrNetChangeV1NotificationPending = EFalse;
       
    62 	iCurrNetChangeV2NotificationPending = EFalse;
       
    63 	iCurrNetChangeEtelIsvNotificationPending = EFalse;
       
    64 	iCurrNetChangeNoLocV1NotificationPending = EFalse;
       
    65 	iCurrNetChangeNoLocV2NotificationPending = EFalse;
       
    66 	iCurrNetChangeV5NotificationPending = EFalse;
       
    67 	iCurrNetChangeV8NotificationPending = EFalse;
       
    68 	iCurrNetChangeNoLocV5NotificationPending = EFalse;
       
    69 	iCurrNetChangeNoLocV8NotificationPending = EFalse;
       
    70 	iCurrentNetworkChangeLocationAreaNotificationPending = EFalse;
       
    71 
       
    72 	iRoamStatGetTimeout = KNetStatTimeoutDefault;
       
    73 
       
    74 	iRoamStatTimer = NULL;
       
    75 	iRoamStatGetClients = NULL;
       
    76 	iRoamStatNotifyClients = NULL;
       
    77 	}
       
    78 
       
    79 void CSimNetworkStatus::ConstructL()
       
    80 /**
       
    81  * Second phase construction.  Create instances of the necessary heap-based
       
    82  * objects and read in the network, Network Registration and NITZ information
       
    83  * from the configuration file.
       
    84  * If any network registration status tags have been read, the initial values
       
    85  * will be loaded and the network registration timer started.
       
    86  * Similarly, if any NITZ tags have been read, the initial NITZ values will be loaded
       
    87  * and the NITZ timer started.
       
    88  *
       
    89  * Entries in the configuration file will take the following formats:
       
    90  *
       
    91  * "NetworkInfo= <CountryCode>, <NetworkId>, <DisplayTag>, <NetworkShortName>, <NetworkLongName> , <NetworkAccess> "
       
    92  * A number of these tags may be included to create a list of Network Information
       
    93  * that can be used via the RegStatus tag during the test.
       
    94  * "LocationArea= <AreaKnown>, <LocationAreaCode>, <CellId>"
       
    95  * that can be used via the RegStatus tag during the test.
       
    96  *
       
    97  * "RegStatus= <Duration>, <RegistrationStatus>, <NetworkIndex>"
       
    98  * The RegistrationStatus is taken from the RMoiblePhone::TMobilePhoneRegistrationStatus
       
    99  * enumeration.  The NetworkIndex is a reference to the NetworkInfo list.
       
   100  * A number of these tags may be included to create a Network Registration Profile.
       
   101  *
       
   102  * "NitzInfo= <Duration>, <Year>, <Month>, <Day>, <Hour>, <Minute>, <Second>, <Microsecond>,
       
   103  *            <Timezone>, <DayTimeSavings>"
       
   104  * A number of these tags may be included to create a NITZ Profile.
       
   105  * 
       
   106  * "CellInfo= <Duration>, <mode>, <CellId>, <timingAdvance>, <cellInfoStatus>"
       
   107  * A number of these tags may be included to create a Cell Information Profile.
       
   108  */
       
   109 	{
       
   110 	LOGNETWORK1("Starting to parse Network Status config parameters...");
       
   111 	iRegStatTimer=CSimTimer::NewL(iPhone);
       
   112 	iNitzTimer=CSimTimer::NewL(iPhone);
       
   113 	iRadioModeTimer=CSimTimer::NewL(iPhone);
       
   114 	iCellInfoTimer=CSimTimer::NewL(iPhone);
       
   115 	
       
   116 	iRegStatusInfo=new(ELeave) CArrayFixFlat<TRegStatus>(KSettingListGranularity);
       
   117 	iNetworkInfo=new(ELeave) CArrayFixFlat<RMobilePhone::TMobilePhoneNetworkInfoV2>(KSettingListGranularity);
       
   118 	iNetworkInfoV8=new(ELeave) CArrayFixFlat<RMobilePhone::TMobilePhoneNetworkInfoV8>(KSettingListGranularity);
       
   119 	iNitzInfo=new(ELeave) CArrayFixFlat<TNitzInfoAndDuration>(KSettingListGranularity);
       
   120 	iRadioModeInfo=new(ELeave) CArrayFixFlat<TRadioMode>(KSettingListGranularity);
       
   121 	iCellInfo = new (ELeave)CArrayFixFlat<TCellInfoAndDuration>(KSettingListGranularity);
       
   122 	iLocationArea  = new (ELeave)CArrayFixFlat<RMobilePhone::TMobilePhoneLocationAreaV1>(KSettingListGranularity);
       
   123 	
       
   124 	TInt count;
       
   125 	count=CfgFile()->ItemCount(KNetworkInfo);
       
   126 	const CTestConfigItem* item=NULL;
       
   127 	TInt ret=KErrNone;
       
   128 
       
   129 	TInt i;
       
   130 	for(i=0;i<count;i++)
       
   131 		{
       
   132 		item=CfgFile()->Item(KNetworkInfo,i);
       
   133 		if(!item)
       
   134 			break;
       
   135 
       
   136 		TPtrC8 countryCode,networkIdentify,displayTag,longName,shortName;
       
   137 		TInt status;
       
   138 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,countryCode);
       
   139 		if(ret!=KErrNone)
       
   140 			{
       
   141 			LOGPARSERR("countryCode",ret,0,&KNetworkInfo);
       
   142 			continue;
       
   143 			}
       
   144 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,networkIdentify);
       
   145 		if(ret!=KErrNone)
       
   146 			{
       
   147 			LOGPARSERR("networkIdentify",ret,1,&KNetworkInfo);
       
   148 			continue;
       
   149 			}
       
   150 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,displayTag);
       
   151 		if(ret!=KErrNone)
       
   152 			{
       
   153 			LOGPARSERR("displayTag",ret,2,&KNetworkInfo);
       
   154 			continue;
       
   155 			}
       
   156 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,shortName);
       
   157 		if(ret!=KErrNone)
       
   158 			{
       
   159 			LOGPARSERR("shortName",ret,3,&KNetworkInfo);
       
   160 			continue;
       
   161 			}
       
   162 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,4,longName);
       
   163 		if(ret!=KErrNone)
       
   164 			{
       
   165 			LOGPARSERR("longName",ret,4,&KNetworkInfo);
       
   166 			continue;
       
   167 			}
       
   168 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,5,status);
       
   169 		if(ret!=KErrNone)
       
   170 			{
       
   171 			LOGPARSERR("status",ret,5,&KNetworkInfo);
       
   172 			continue;
       
   173 			}
       
   174 		RMobilePhone::TMobilePhoneNetworkInfoV2 networkInfo;
       
   175 		RMobilePhone::TMobilePhoneNetworkInfoV8 networkInfoV8;
       
   176 
       
   177 		TInt mode;
       
   178 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,6,mode);
       
   179 		if(ret!=KErrNone)
       
   180 			{
       
   181 			// It's ok, this element is optional. Assume that the
       
   182 			// config file is old, and default mode to GSM
       
   183 			mode = RMobilePhone::ENetworkModeGsm;
       
   184 			}
       
   185 		networkInfo.iMode=RMobilePhone::TMobilePhoneNetworkMode(mode);
       
   186 
       
   187 		networkInfo.iStatus=RMobilePhone::TMobilePhoneNetworkStatus(status);
       
   188 		networkInfo.iBandInfo=RMobilePhone::EBandUnknown;
       
   189 		networkInfo.iCountryCode.Copy(countryCode);
       
   190 		networkInfo.iAnalogSID.SetLength(0);
       
   191 		networkInfo.iNetworkId.Copy(networkIdentify);
       
   192 		networkInfo.iDisplayTag.Copy(displayTag);		
       
   193 				
       
   194 		TInt maxLength = networkInfo.iShortName.MaxLength();
       
   195 		if (shortName.Length() > maxLength)
       
   196 			{
       
   197 			networkInfo.iShortName.Copy(shortName.Left(maxLength));
       
   198 			}
       
   199 		else 
       
   200 			{
       
   201 			networkInfo.iShortName.Copy(shortName);	
       
   202 			}
       
   203 		
       
   204 		maxLength = networkInfo.iLongName.MaxLength();
       
   205 		if (longName.Length() > maxLength)
       
   206 			{
       
   207 			networkInfo.iLongName.Copy(longName.Left(maxLength));
       
   208 			}
       
   209 		else
       
   210 			{
       
   211 			networkInfo.iLongName.Copy(longName);	
       
   212 			}
       
   213 		
       
   214 		networkInfo.iAccess = RMobilePhone::ENetworkAccessGsm;
       
   215 		networkInfoV8.iHsdpaAvailableIndicator=EFalse;
       
   216 		networkInfoV8.iEgprsAvailableIndicator=EFalse;
       
   217 		networkInfoV8.iHsupaAvailableIndicator=ETrue;
       
   218 		iNetworkInfo->AppendL(networkInfo);
       
   219 		iNetworkInfoV8->AppendL(networkInfoV8);
       
   220 		}
       
   221 
       
   222 		     
       
   223 // Read in the Registration status profile.
       
   224 	count=CfgFile()->ItemCount(KRegStatus);
       
   225 	item=NULL;
       
   226 	for(i=0;i<count;i++)
       
   227 		{
       
   228 		item=CfgFile()->Item(KRegStatus,i);
       
   229 		if(!item)
       
   230 			break;
       
   231 
       
   232 		TInt duration,regStat,networkIndex;
       
   233 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,duration);
       
   234 		if(ret!=KErrNone)
       
   235 			{
       
   236 			LOGPARSERR("duration",ret,0,&KRegStatus);
       
   237 			continue;
       
   238 			}
       
   239 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,regStat);
       
   240 		if(ret!=KErrNone)
       
   241 			{
       
   242 			LOGPARSERR("regStat",ret,1,&KRegStatus);
       
   243 			continue;
       
   244 			}
       
   245 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,networkIndex);
       
   246 		if(ret!=KErrNone)
       
   247 			networkIndex=KErrNotFound;		// Network Index is optional.
       
   248 
       
   249 		TRegStatus regStatus;
       
   250 		regStatus.iDuration=duration;
       
   251 		regStatus.iRegStatus=(RMobilePhone::TMobilePhoneRegistrationStatus)regStat;
       
   252 		regStatus.iNetworkInfoIndex=networkIndex;
       
   253 		iRegStatusInfo->AppendL(regStatus);
       
   254 		}
       
   255 		
       
   256 		count=CfgFile()->ItemCount(KRadioMode);
       
   257 		item=NULL;
       
   258 		for(i=0;i<count;i++)
       
   259 			{
       
   260 			item=CfgFile()->Item(KRadioMode,i);
       
   261 			if(!item)
       
   262 				break;
       
   263 
       
   264 			TInt duration,radioStatus;
       
   265 			
       
   266 			ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,duration);
       
   267 			if(ret!=KErrNone)
       
   268 				{
       
   269 				LOGPARSERR("duration",ret,0,&KRadioMode);
       
   270 				continue;
       
   271 				}
       
   272 			ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,radioStatus);
       
   273 			if(ret!=KErrNone)
       
   274 				{
       
   275 				LOGPARSERR("radioStatus",ret,1,&KRadioMode);
       
   276 				continue;
       
   277 				}
       
   278 			
       
   279 
       
   280 			TRadioMode radioMode;
       
   281 			radioMode.iDuration=duration;
       
   282 			radioMode.iRadioOn=(TBool)radioStatus;
       
   283 			iRadioModeInfo->AppendL(radioMode);
       
   284 			}
       
   285 
       
   286 // Read the NITZ information
       
   287 	count=CfgFile()->ItemCount(KNitzInfo);
       
   288 	item=NULL;
       
   289 	for(i=0;i<count;i++)
       
   290 		{
       
   291 		item=CfgFile()->Item(KNitzInfo,i);
       
   292 		if(!item)
       
   293 			break;
       
   294 
       
   295 		TInt duration,year,month,day,hour,min,sec,microsec,tz,dst;
       
   296 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,duration);
       
   297 		if(ret!=KErrNone)
       
   298 			{
       
   299 			LOGPARSERR("duration",ret,0,&KNitzInfo);
       
   300 			continue;
       
   301 			}
       
   302 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,year);
       
   303 		if(ret!=KErrNone)
       
   304 			{
       
   305 			LOGPARSERR("year",ret,1,&KNitzInfo);
       
   306 			continue;
       
   307 			}
       
   308 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,month);
       
   309 		if(ret!=KErrNone)
       
   310 			{
       
   311 			LOGPARSERR("month",ret,2,&KNitzInfo);
       
   312 			continue;
       
   313 			}
       
   314 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,day);
       
   315 		if(ret!=KErrNone)
       
   316 			{
       
   317 			LOGPARSERR("day",ret,3,&KNitzInfo);
       
   318 			continue;
       
   319 			}
       
   320 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,4,hour);
       
   321 		if(ret!=KErrNone)
       
   322 			{
       
   323 			LOGPARSERR("hour",ret,4,&KNitzInfo);
       
   324 			continue;
       
   325 			}
       
   326 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,5,min);
       
   327 		if(ret!=KErrNone)
       
   328 			{
       
   329 			LOGPARSERR("min",ret,5,&KNitzInfo);
       
   330 			continue;
       
   331 			}
       
   332 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,6,sec);
       
   333 		if(ret!=KErrNone)
       
   334 			{
       
   335 			LOGPARSERR("sec",ret,6,&KNitzInfo);
       
   336 			continue;
       
   337 			}
       
   338 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,7,microsec);
       
   339 		if(ret!=KErrNone)
       
   340 			{
       
   341 			LOGPARSERR("microsec",ret,7,&KNitzInfo);
       
   342 			continue;
       
   343 			}
       
   344 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,8,tz);
       
   345 		if(ret!=KErrNone)
       
   346 			{
       
   347 			LOGPARSERR("tz",ret,8,&KNitzInfo);
       
   348 			continue;
       
   349 			}
       
   350 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,9,dst);
       
   351 		if(ret!=KErrNone)
       
   352 			{
       
   353 			LOGPARSERR("dst",ret,9,&KNitzInfo);
       
   354 			continue;
       
   355 			}
       
   356 
       
   357 		RMobilePhone::TMobilePhoneNITZ nitzInfo(year,(TMonth)month,day,hour,min,sec,microsec);
       
   358 		nitzInfo.iTimeZone=tz;
       
   359 		nitzInfo.iDST=dst;
       
   360 		nitzInfo.iNitzFieldsUsed=	(RMobilePhone::KCapsTimeAvailable
       
   361 								    |RMobilePhone::KCapsTimezoneAvailable
       
   362 									|RMobilePhone::KCapsDSTAvailable);
       
   363 
       
   364 		TNitzInfoAndDuration nitzInfoAndDuration;
       
   365 		nitzInfoAndDuration.iNitz=nitzInfo;
       
   366 		nitzInfoAndDuration.iDuration=duration;
       
   367 		iNitzInfo->AppendL(nitzInfoAndDuration);
       
   368 		}
       
   369 
       
   370 	// Read the Cell Info information
       
   371 		count=CfgFile()->ItemCount(KCellInfo);
       
   372 		item=NULL;
       
   373 		for(i=0;i<count;i++)
       
   374 			{
       
   375 			item=CfgFile()->Item(KCellInfo,i);
       
   376 			if(!item)
       
   377 				break;
       
   378 
       
   379 			TInt duration,mode,cellId,timingAdvance,cellInfoStatus;
       
   380 			ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,duration);
       
   381 			if(ret!=KErrNone)
       
   382 				{
       
   383 				LOGPARSERR("duration",ret,0,&KCellInfo);
       
   384 				continue;
       
   385 				}
       
   386 			ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,mode);
       
   387 			if(ret!=KErrNone)
       
   388 				{
       
   389 				LOGPARSERR("mode",ret,1,&KCellInfo);
       
   390 				continue;
       
   391 				}
       
   392 			ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,cellId);
       
   393 			if(ret!=KErrNone)
       
   394 				{
       
   395 				LOGPARSERR("cellId",ret,2,&KCellInfo);
       
   396 				continue;
       
   397 				}
       
   398 			ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,timingAdvance);
       
   399 			if(ret!=KErrNone)
       
   400 				{
       
   401 				LOGPARSERR("timingAdvance",ret,3,&KCellInfo);
       
   402 				continue;
       
   403 				}
       
   404 			ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,4,cellInfoStatus);
       
   405 			if(ret!=KErrNone)
       
   406 				{
       
   407 				LOGPARSERR("cellInfoStatus",ret,3,&KCellInfo);
       
   408 				continue;
       
   409 				}
       
   410 			
       
   411 			TCellInfoAndDuration cellInfoAndDuration;
       
   412 			cellInfoAndDuration.iInfo.iMode = static_cast<RMobilePhone::TCellMode>(mode);
       
   413 			cellInfoAndDuration.iInfo.iCellId = static_cast<TUint>(cellId);
       
   414 			cellInfoAndDuration.iInfo.iTimingAdvance = static_cast<RMobilePhone::TGsmTimingAdvance>(timingAdvance);
       
   415 			cellInfoAndDuration.iInfo.iStatus = static_cast<RMobilePhone::TCellInfoStatus>(cellInfoStatus);
       
   416 
       
   417 			cellInfoAndDuration.iDuration=duration;
       
   418 			iCellInfo->AppendL(cellInfoAndDuration);
       
   419 			}
       
   420 
       
   421 		// Read the Location Area information
       
   422 			count=CfgFile()->ItemCount(KLocationArea);
       
   423 			item=NULL;
       
   424 			for(i=0;i<count;i++)
       
   425 				{
       
   426 				item=CfgFile()->Item(KLocationArea,i);
       
   427 				if(!item)
       
   428 					break;
       
   429 
       
   430 				TBool areaKnown;
       
   431 				TInt locationAreaCode, cellId;
       
   432 				ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,areaKnown);
       
   433 				if(ret!=KErrNone)
       
   434 					{
       
   435 					ret = EFalse;
       
   436 					}
       
   437 				ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,locationAreaCode);
       
   438 				if(ret!=KErrNone)
       
   439 					{
       
   440 					locationAreaCode = 0;
       
   441 					}
       
   442 				ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,cellId);
       
   443 				if(ret!=KErrNone)
       
   444 					{
       
   445 					cellId = 0;
       
   446 					}
       
   447 
       
   448 				RMobilePhone::TMobilePhoneLocationAreaV1 locationArea;
       
   449 				locationArea.iAreaKnown = areaKnown;
       
   450 				locationArea.iLocationAreaCode = locationAreaCode;
       
   451 				locationArea.iCellId= cellId;
       
   452 				iLocationArea->AppendL(locationArea);
       
   453 				}
       
   454 	LOGNETWORK1("...Finished parsing Network Status config parameters...");
       
   455 
       
   456 // If present load the first registration status settings and start the registration
       
   457 // status timer.
       
   458 	if(iRegStatusInfo->Count()!=0)
       
   459 		{
       
   460 		iRegStatIndex=0;
       
   461 		iCurrentRegStatus=iRegStatusInfo->At(0).iRegStatus;
       
   462 		iCurrentNetworkIndex=iRegStatusInfo->At(0).iNetworkInfoIndex;
       
   463 		LOGNETWORK2("Starting ETimerIdNtwkStatRegStat for duration:%d", iRegStatusInfo->At(0).iDuration);
       
   464 		iRegStatTimer->Start(iRegStatusInfo->At(0).iDuration,this,ETimerIdNtwkStatRegStat);
       
   465 		}
       
   466 
       
   467 // If present load the first NITZ settings and start the NITZ timer.
       
   468 	if(iNitzInfo->Count()!=0)
       
   469 		{
       
   470 		iNitzIndex=0;
       
   471 		iCurrentNitzInfo=iNitzInfo->At(0).iNitz;
       
   472 		iNitzTimer->Start(iNitzInfo->At(0).iDuration,this,ETimerIdNtwkStatNitz);
       
   473 		}
       
   474 		
       
   475 // If present load the first Cell Info settings and start the cell info timer.
       
   476 	if(iCellInfo->Count()!=0)
       
   477 		{
       
   478 		iCellInfoIndex=0;
       
   479 		iCurrentCellInfo=iCellInfo->At(0).iInfo;
       
   480 		iCellInfoTimer->Start(iCellInfo->At(0).iDuration,this,ETimerIdCellInfo);
       
   481 		}
       
   482 		
       
   483 	if(iRadioModeInfo->Count()!=0)
       
   484 		{
       
   485 		iRadioModeIndex=0;
       
   486 		iRadioMode.iRadioOn=iRadioModeInfo->At(0).iRadioOn;
       
   487 		if(iRadioMode.iRadioOn==EFalse)
       
   488 			{
       
   489 			RProperty::Set(KUidSystemCategory, KUidPhonePwrValue, ESAPhoneOff);
       
   490 			LOGNETWORK1("Radio Mode = OFF (from config)");
       
   491 			}
       
   492 		else
       
   493 			{
       
   494 			RProperty::Set(KUidSystemCategory, KUidPhonePwrValue, ESAPhoneOn);			
       
   495 				LOGNETWORK1("Radio Mode = ON (from config)");
       
   496 			}
       
   497 		LOGNETWORK2("Radio Mode duration = %d (from config)", iRadioModeInfo->At(0).iDuration);
       
   498 
       
   499  		iRadioModeTimer->Start(iRadioModeInfo->At(0).iDuration,this,ETimerIdNtwkStatRadioMode);
       
   500 		}
       
   501 	else
       
   502 		{
       
   503 		//default to on
       
   504 		RProperty::Set(KUidSystemCategory, KUidPhonePwrValue, ESAPhoneOn);
       
   505 		LOGNETWORK1("Radio Mode = ON (no config)");
       
   506 		}
       
   507 
       
   508 //If present read in Service Provider settings
       
   509 	TPtrC8 spname, plmnfield;
       
   510 	TInt displayreq;
       
   511 	item=CfgFile()->Item(KServiceProviderName);
       
   512 	if (item)
       
   513 		{
       
   514 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,displayreq);
       
   515 		if(ret!=KErrNone)
       
   516 			{
       
   517 			LOGPARSERR("displayreq",ret,0,&KServiceProviderName);
       
   518 			}
       
   519 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,spname);
       
   520 		if(ret!=KErrNone)
       
   521 			{
       
   522 			LOGPARSERR("spname",ret,1,&KServiceProviderName);
       
   523 			}
       
   524 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,plmnfield);
       
   525 		if(ret!=KErrNone)
       
   526 			{
       
   527 			LOGPARSERR("plmnfield",ret,2,&KServiceProviderName);
       
   528 			}
       
   529 		iServiceProvider.iDisplayReq = static_cast<RMobilePhone::TDisplayRequirements>(displayreq);
       
   530 		
       
   531 		TInt maxLength = iServiceProvider.iSPName.MaxLength();
       
   532 		if (spname.Length() > maxLength)
       
   533 			{
       
   534 			iServiceProvider.iSPName.Copy(spname.Left(maxLength));
       
   535 			}
       
   536 		else
       
   537 			{
       
   538 			iServiceProvider.iSPName.Copy(spname);	
       
   539 			}
       
   540 			
       
   541 		maxLength = iServiceProvider.iPLMNField.MaxLength();
       
   542 		if (plmnfield.Length() > maxLength)
       
   543 			{
       
   544 			iServiceProvider.iPLMNField.Copy(plmnfield.Left(maxLength));
       
   545 			}
       
   546 		else
       
   547 			{
       
   548 			iServiceProvider.iPLMNField.Copy(plmnfield);		
       
   549 			}
       
   550 		}
       
   551 	else
       
   552 		{
       
   553 		iServiceProvider.iDisplayReq = KDisplayReqDefault;
       
   554 		iServiceProvider.iSPName.Copy(KSPNameDefault);
       
   555 		iServiceProvider.iPLMNField.Copy(KPLMNFieldDefault);		
       
   556 		}
       
   557 
       
   558 	iRegStatChange=CSimPubSubChange::NewL(this, CSimPubSub::TPubSubProperty(KUidSimtsyCategoryLocal, KSimtsyRegStatChange, KSimtsyRegStatChangeType));
       
   559 	//also listen on new P&S uids
       
   560 	iPSRegStatChange=CSimPubSubChange::NewL(this, CSimPubSub::TPubSubProperty(KUidPSSimTsyCategory, KPSSimTsyRegStatChange, KPSSimTsyRegStatChangeKeyType));
       
   561 		
       
   562 	}
       
   563 
       
   564 void CSimNetworkStatus::FindRoamStatSettings()
       
   565 /**
       
   566  * Get Roaming Status Configuration
       
   567  */
       
   568 	{
       
   569 	const CTestConfigItem* item=NULL;
       
   570 	TInt ret=KErrNone;
       
   571 
       
   572 	//If present read in Service Provider settings
       
   573 	TInt getTimer;
       
   574 	item=CfgFile()->Item(KRoamStatTimers);
       
   575 	if (item)
       
   576 		{
       
   577 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,getTimer);
       
   578 		if(ret!=KErrNone)
       
   579 			{
       
   580 			LOGNETWORK1("WARNING: CSimNetworkStatus::FindRoamStatSettings found ERROR with Config");
       
   581 			}
       
   582 		iRoamStatGetTimeout = getTimer;
       
   583 		}
       
   584 	}
       
   585 
       
   586 void CSimNetworkStatus::SetNetworkMode()
       
   587 /**
       
   588  * Initialize iPhone->NetworkMode().
       
   589  */
       
   590 	{
       
   591 	if(iCurrentNetworkIndex != KErrNotFound)
       
   592 		{
       
   593 	    if(iNetworkInfo->Count()>iCurrentNetworkIndex)
       
   594 			{
       
   595 			iPhone->UpdateNetworkMode(iNetworkInfo->At(iCurrentNetworkIndex).iMode);
       
   596 			}
       
   597 		}
       
   598 	}
       
   599 	
       
   600 CSimNetworkStatus::~CSimNetworkStatus()
       
   601 /**
       
   602  * Standard destructor.  Destroy the heap-based object owned by this object.
       
   603  */
       
   604 	{
       
   605 	delete iCellInfoTimer;
       
   606 	delete iNitzTimer;
       
   607 	delete iRegStatTimer;
       
   608 	delete iRegStatChange;
       
   609 	delete iPSRegStatChange;
       
   610 	delete iRadioModeTimer;
       
   611 	if (iCellInfo)
       
   612 		{
       
   613 		iCellInfo->Delete(0,iCellInfo->Count());
       
   614 		delete iCellInfo;
       
   615 		}
       
   616 	if (iNitzInfo)
       
   617 		{
       
   618 		iNitzInfo->Delete(0,iNitzInfo->Count());
       
   619 		delete iNitzInfo;//todo check ptr
       
   620 		}
       
   621 	if (iRegStatusInfo)
       
   622 		{
       
   623 		iRegStatusInfo->Delete(0,iRegStatusInfo->Count());
       
   624 		delete iRegStatusInfo;//todo check ptr
       
   625 		}
       
   626 	if (iNetworkInfo)
       
   627 		{
       
   628 		iNetworkInfo->Delete(0,iNetworkInfo->Count());
       
   629 		delete iNetworkInfo;//todo check ptr
       
   630 		}
       
   631 	if (iNetworkInfoV8)
       
   632 		{
       
   633 		iNetworkInfoV8->Delete(0,iNetworkInfoV8->Count());
       
   634 		delete iNetworkInfoV8;//todo check ptr
       
   635 		}
       
   636 	if (iRadioModeInfo)
       
   637 		{
       
   638 		iRadioModeInfo->Delete(0,iRadioModeInfo->Count());
       
   639 		delete iRadioModeInfo;//todo check ptr
       
   640 		}
       
   641 	if(iLocationArea)
       
   642 		{
       
   643 		iLocationArea->Delete(0,iLocationArea->Count());
       
   644 		delete iLocationArea;
       
   645 		}
       
   646 		
       
   647 	delete iRoamStatTimer;
       
   648 	if(iRoamStatGetClients)
       
   649 		{
       
   650 		TInt i;
       
   651 		TRoamStatClient client;
       
   652 		for(i=0;i<iRoamStatGetClients->Count();i++)
       
   653 			{
       
   654 			client = iRoamStatGetClients->At(i);
       
   655 			iPhone->ReqCompleted(client.iReqHandle, KErrCancel);
       
   656 			}	
       
   657 		iRoamStatGetClients->Reset();
       
   658 		delete iRoamStatGetClients;
       
   659 		}
       
   660 	if(iRoamStatNotifyClients)
       
   661 		{
       
   662 		TInt i;
       
   663 		TRoamStatClient client;
       
   664 		for(i=0;i<iRoamStatNotifyClients->Count();i++)
       
   665 			{
       
   666 			client = iRoamStatNotifyClients->At(i);
       
   667 			iPhone->ReqCompleted(client.iReqHandle, KErrCancel);
       
   668 			}	
       
   669 		iRoamStatNotifyClients->Reset();
       
   670 		delete iRoamStatNotifyClients;
       
   671 		}
       
   672 	}
       
   673 
       
   674 TInt CSimNetworkStatus::GetNetworkCaps(TTsyReqHandle aReqHandle,TDes8* aPckg1)
       
   675 /**
       
   676  * Retrieve the Network Capability information.  Network capabilities for this test
       
   677  * are deduced from the tags, and therefore loaded information, for this test.
       
   678  * @param aReqHandle	The request handle associated with this request.
       
   679  * @param aPckg1		The first parameter package.  This will be populated with the
       
   680  *						capability data to be returned.
       
   681  * @return TInt			Standard error value.
       
   682  */
       
   683 {
       
   684 	TPckg<TUint32>* networkCapsPckg=(TPckg<TUint32>*)aPckg1;
       
   685 	TUint32& networkCaps=(*networkCapsPckg)();
       
   686 
       
   687 	if(iRegStatusInfo->Count()==0)
       
   688 		networkCaps=RMobilePhone::KCapsGetCurrentMode;
       
   689 	else
       
   690 		networkCaps=RMobilePhone::KCapsGetRegistrationStatus |
       
   691 					RMobilePhone::KCapsNotifyRegistrationStatus | 
       
   692 					RMobilePhone::KCapsGetCurrentMode |
       
   693 					RMobilePhone::KCapsGetCurrentNetwork | 
       
   694 					RMobilePhone::KCapsNotifyCurrentNetwork |
       
   695 					RMobilePhone::KCapsGetHomeNetwork;
       
   696 
       
   697 	if(iNetworkInfo->Count()>=1)
       
   698 		networkCaps|=RMobilePhone::KCapsGetHomeNetwork;
       
   699 
       
   700 	iPhone->ReqCompleted(aReqHandle,KErrNone);
       
   701 	return KErrNone;
       
   702 	}
       
   703 
       
   704 TInt CSimNetworkStatus::GetHomeNetwork(TTsyReqHandle aReqHandle,TDes8* aPckg1)
       
   705 /**
       
   706  * Retrieve information about the Home Network.  The first NetworkInfo tag information
       
   707  * is taken to be the "home" network.  If this information is not present, the
       
   708  * request is completed with KErrNotSupported.
       
   709  * @param aReqHandle	The request handle associated with this request.
       
   710  * @param aPckg1		The first parameter package.  This will be populated with the
       
   711  *						Home Network information to be returned.
       
   712  * @return TInt			Standard error value.+
       
   713  */
       
   714 	{
       
   715 	RMobilePhone::TMobilePhoneNetworkInfoV1Pckg* homeNetworkPckg=(RMobilePhone::TMobilePhoneNetworkInfoV1Pckg*)aPckg1;
       
   716 	RMobilePhone::TMultimodeType& packagetype = (*homeNetworkPckg)();
       
   717 	RMobilePhone::TMobilePhoneNetworkInfoV1& homeNetwork=(*homeNetworkPckg)();
       
   718 
       
   719 	// Check that the data structure is supported by the simulated TSY version
       
   720 	TInt err = iPhone->CheckSimTsyVersion(homeNetwork);
       
   721 	if(err != KErrNone)
       
   722 		{
       
   723 		iPhone->ReqCompleted(aReqHandle, err);
       
   724 		return KErrNone;
       
   725 		}
       
   726 
       
   727 	if(iNetworkInfo->Count()==0) 
       
   728 		{
       
   729 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);
       
   730 		return KErrNone;
       
   731 		}
       
   732 
       
   733 	PopulateNetworkInfoV1(0,homeNetwork);
       
   734 	
       
   735 	if(packagetype.ExtensionId() == KETelExtMultimodeV1 || packagetype.ExtensionId() == KETelExtMultimodeV2 || \
       
   736 	   packagetype.ExtensionId() == KEtelExtMultimodeV5 || packagetype.ExtensionId() == KEtelExtMultimodeV8 )
       
   737 		{	
       
   738 		RMobilePhone::TMobilePhoneNetworkInfoV1Pckg* homeNetworkPckg=(RMobilePhone::TMobilePhoneNetworkInfoV1Pckg*)aPckg1;
       
   739 		RMobilePhone::TMobilePhoneNetworkInfoV1& homeNetwork=(*homeNetworkPckg)();		
       
   740 
       
   741 		// Check that the data structure is supported by the simulated TSY version
       
   742 		TInt err = iPhone->CheckSimTsyVersion(homeNetwork);
       
   743 		if(err != KErrNone)
       
   744 			{
       
   745 			iPhone->ReqCompleted(aReqHandle, err);
       
   746 			return KErrNone;
       
   747 			}
       
   748 	
       
   749 		PopulateNetworkInfoV1(0,homeNetwork);
       
   750 		
       
   751 		//if V2 package then set its paramters as well
       
   752 		if(packagetype.ExtensionId() == KETelExtMultimodeV2 || packagetype.ExtensionId() == KEtelExtMultimodeV5 || \
       
   753 		   packagetype.ExtensionId() == KEtelExtMultimodeV8)
       
   754 			{
       
   755 			RMobilePhone::TMobilePhoneNetworkInfoV2Pckg* homeNetworkPckgV2=(RMobilePhone::TMobilePhoneNetworkInfoV2Pckg*)aPckg1;
       
   756 			RMobilePhone::TMobilePhoneNetworkInfoV2& homeNetworkV2=(*homeNetworkPckgV2)();
       
   757 
       
   758 			// Check that the data structure is supported by the simulated TSY version
       
   759 			TInt err = iPhone->CheckSimTsyVersion(homeNetworkV2);
       
   760 			if(err != KErrNone)
       
   761 				{
       
   762 				iPhone->ReqCompleted(aReqHandle, err);
       
   763 				return KErrNone;
       
   764 				}
       
   765 
       
   766 			homeNetworkV2.iAccess = iNetworkInfo->At(iCurrentNetworkIndex).iAccess;
       
   767 		
       
   768 			if(packagetype.ExtensionId() == KEtelExtMultimodeV5 || packagetype.ExtensionId() == KEtelExtMultimodeV8)
       
   769 				{
       
   770 				RMobilePhone::TMobilePhoneNetworkInfoV5Pckg* homeNetworkPckgV5=(RMobilePhone::TMobilePhoneNetworkInfoV5Pckg*)aPckg1;
       
   771 				RMobilePhone::TMobilePhoneNetworkInfoV5& homeNetworkV5=(*homeNetworkPckgV5)();
       
   772 	
       
   773 				// Check that the data structure is supported by the simulated TSY version
       
   774 				TInt err = iPhone->CheckSimTsyVersion(homeNetworkV5);
       
   775 				if(err != KErrNone)
       
   776 					{
       
   777 					iPhone->ReqCompleted(aReqHandle, err);
       
   778 					return KErrNone;
       
   779 					}
       
   780 
       
   781 				homeNetworkV5.iHsdpaAvailableIndicator = iNetworkInfoV8->At(0).iHsdpaAvailableIndicator;
       
   782 				homeNetworkV5.iEgprsAvailableIndicator = iNetworkInfoV8->At(0).iEgprsAvailableIndicator;
       
   783 			
       
   784 		 		if(packagetype.ExtensionId() == KEtelExtMultimodeV8)
       
   785 					{
       
   786 					RMobilePhone::TMobilePhoneNetworkInfoV8Pckg* homeNetworkPckgV8=(RMobilePhone::TMobilePhoneNetworkInfoV8Pckg*)aPckg1;
       
   787 					RMobilePhone::TMobilePhoneNetworkInfoV8& homeNetworkV8=(*homeNetworkPckgV8)();
       
   788 
       
   789 					// Check that the data structure is supported by the simulated TSY version
       
   790 					TInt err = iPhone->CheckSimTsyVersion(homeNetworkV8);
       
   791 					if(err != KErrNone)
       
   792 						{
       
   793 						iPhone->ReqCompleted(aReqHandle, err);
       
   794 						return KErrNone;
       
   795 						}
       
   796 
       
   797 					homeNetworkV8.iHsupaAvailableIndicator = iNetworkInfoV8->At(0).iHsupaAvailableIndicator;
       
   798 					}
       
   799 				}
       
   800 			}
       
   801 		}
       
   802 	else
       
   803 		{
       
   804 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);
       
   805 		return KErrNone;		
       
   806 		}
       
   807 	iPhone->ReqCompleted(aReqHandle,KErrNone);
       
   808 	return KErrNone;
       
   809 	}
       
   810 	
       
   811 TInt CSimNetworkStatus::GetCurrentNetwork(TTsyReqHandle aReqHandle,TDes8* aPckg1,TDes8* aPckg2)
       
   812 /**
       
   813  * Retrieve information about the Current Network.  The current network is given by the
       
   814  * iCurrentNetworkIndex member variable.  It will be updated from RegStat tags in the
       
   815  * configuration file.  If there is no network information currently available (perhaps
       
   816  * because the SIM TSY is simulating a network search) KErrNotFound will be
       
   817  * returned.  If no registration status profile information is contained in the
       
   818  * configuration file KErrNotSupported will be returned.
       
   819  * @param aReqHandle	The request handle associated with this request.
       
   820  * @param aPckg1		The first parameter package.  This will be populated with the
       
   821  *						Current Network information to be returned.
       
   822  * @return TInt			Standard error value.
       
   823  */
       
   824 	{
       
   825 	RMobilePhone::TMobilePhoneNetworkInfoV1Pckg* currentNetworkPckg=(RMobilePhone::TMobilePhoneNetworkInfoV1Pckg*)aPckg1;
       
   826 	RMobilePhone::TMultimodeType& packagetype = (*currentNetworkPckg)();
       
   827 	
       
   828 	if(aPckg2)
       
   829 		{
       
   830 		TPckg<RMobilePhone::TMobilePhoneLocationAreaV1>* areaPckg=(TPckg<RMobilePhone::TMobilePhoneLocationAreaV1>*)aPckg2;
       
   831 		RMobilePhone::TMobilePhoneLocationAreaV1& area=(*areaPckg)();	
       
   832 
       
   833 		// Check that the data structure is supported by the simulated TSY version
       
   834 		TInt err = iPhone->CheckSimTsyVersion(area);
       
   835 		if(err != KErrNone)
       
   836 			{
       
   837 			iPhone->ReqCompleted(aReqHandle, err);
       
   838 			return KErrNone;
       
   839 			}
       
   840 		if((iCurrentNetworkIndex >=0) && (iCurrentNetworkIndex <iLocationArea->Count()))
       
   841 			{
       
   842 			area.iAreaKnown = iLocationArea->At(iCurrentNetworkIndex).iAreaKnown;
       
   843 			area.iLocationAreaCode = iLocationArea->At(iCurrentNetworkIndex).iLocationAreaCode;
       
   844 			area.iCellId = iLocationArea->At(iCurrentNetworkIndex).iCellId;
       
   845 			}
       
   846 		else
       
   847 			{
       
   848 			area.iAreaKnown=EFalse;		// Area information not currently supported.
       
   849 			}
       
   850 		}
       
   851 	
       
   852 	
       
   853 	if(iRegStatusInfo->Count()==0)
       
   854 		{
       
   855 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);
       
   856 		return KErrNone;
       
   857 		}
       
   858 
       
   859 	if(iCurrentNetworkIndex==KErrNotFound)
       
   860 		{
       
   861 		iPhone->ReqCompleted(aReqHandle,KErrNotFound);
       
   862 		return KErrNone;
       
   863 		}
       
   864 	
       
   865 	if(packagetype.ExtensionId() == KETelExtMultimodeV1 || packagetype.ExtensionId() == KETelExtMultimodeV2 || \
       
   866 	   	packagetype.ExtensionId() == KEtelExtMultimodeV5 || packagetype.ExtensionId() == KEtelExtMultimodeV8 )
       
   867 		{	
       
   868 		RMobilePhone::TMobilePhoneNetworkInfoV1Pckg* currentNetworkPckg=(RMobilePhone::TMobilePhoneNetworkInfoV1Pckg*)aPckg1;
       
   869 		RMobilePhone::TMobilePhoneNetworkInfoV1& currentNetwork=(*currentNetworkPckg)();		
       
   870 
       
   871 		// Check that the data structure is supported by the simulated TSY version
       
   872 		TInt err = iPhone->CheckSimTsyVersion(currentNetwork);
       
   873 		if(err != KErrNone)
       
   874 			{
       
   875 			iPhone->ReqCompleted(aReqHandle, err);
       
   876 			return KErrNone;
       
   877 			}
       
   878 	
       
   879 		PopulateNetworkInfoV1(iCurrentNetworkIndex,currentNetwork);
       
   880 	//if V2 package then set its paramters as well
       
   881 		if(currentNetwork.ExtensionId() == KETelExtMultimodeV2 || packagetype.ExtensionId() == KEtelExtMultimodeV5 || \
       
   882 		  	packagetype.ExtensionId() == KEtelExtMultimodeV8)
       
   883 			{
       
   884 			RMobilePhone::TMobilePhoneNetworkInfoV2Pckg* currentNetworkPckgV2=(RMobilePhone::TMobilePhoneNetworkInfoV2Pckg*)aPckg1;
       
   885 			RMobilePhone::TMobilePhoneNetworkInfoV2& currentNetworkV2=(*currentNetworkPckgV2)();
       
   886 
       
   887 			// Check that the data structure is supported by the simulated TSY version
       
   888 			TInt err = iPhone->CheckSimTsyVersion(currentNetworkV2);
       
   889 			if(err != KErrNone)
       
   890 				{
       
   891 				iPhone->ReqCompleted(aReqHandle, err);
       
   892 				return KErrNone;
       
   893 				}
       
   894 
       
   895 			currentNetworkV2.iAccess = iNetworkInfo->At(iCurrentNetworkIndex).iAccess;
       
   896 		
       
   897 			if(packagetype.ExtensionId() == KEtelExtMultimodeV5 || packagetype.ExtensionId() == KEtelExtMultimodeV8)
       
   898 				{
       
   899 				RMobilePhone::TMobilePhoneNetworkInfoV5Pckg* currentNetworkPckgV5=(RMobilePhone::TMobilePhoneNetworkInfoV5Pckg*)aPckg1;
       
   900 				RMobilePhone::TMobilePhoneNetworkInfoV5& currentNetworkV5=(*currentNetworkPckgV5)();
       
   901 
       
   902 				// Check that the data structure is supported by the simulated TSY version
       
   903 				TInt err = iPhone->CheckSimTsyVersion(currentNetworkV5);
       
   904 				if(err != KErrNone)
       
   905 					{
       
   906 					iPhone->ReqCompleted(aReqHandle, err);
       
   907 					return KErrNone;
       
   908 					}
       
   909 
       
   910 				currentNetworkV5.iHsdpaAvailableIndicator = iNetworkInfoV8->At(0).iHsdpaAvailableIndicator;
       
   911 				currentNetworkV5.iEgprsAvailableIndicator = iNetworkInfoV8->At(0).iEgprsAvailableIndicator;
       
   912 			
       
   913 				if(packagetype.ExtensionId() == KEtelExtMultimodeV8)
       
   914 					{
       
   915 					RMobilePhone::TMobilePhoneNetworkInfoV8Pckg* currentNetworkPckgV8=(RMobilePhone::TMobilePhoneNetworkInfoV8Pckg*)aPckg1;
       
   916 					RMobilePhone::TMobilePhoneNetworkInfoV8& currentNetworkV8=(*currentNetworkPckgV8)();
       
   917 
       
   918 					// Check that the data structure is supported by the simulated TSY version
       
   919 					TInt err = iPhone->CheckSimTsyVersion(currentNetworkV8);
       
   920 					if(err != KErrNone)
       
   921 						{
       
   922 						iPhone->ReqCompleted(aReqHandle, err);
       
   923 						return KErrNone;
       
   924 						}
       
   925 
       
   926 					currentNetworkV8.iHsupaAvailableIndicator = iNetworkInfoV8->At(0).iHsupaAvailableIndicator;
       
   927 					}
       
   928 				}
       
   929 			}
       
   930 		}
       
   931 		
       
   932 	else if(packagetype.ExtensionId() == KETelExt3rdPartyV1)
       
   933 		{
       
   934 		RMobilePhone::TEtel3rdPartyMobileNetworkInfoV1Pckg* currentNetworkPckg=(RMobilePhone::TEtel3rdPartyMobileNetworkInfoV1Pckg*)aPckg1;
       
   935 		RMobilePhone::TEtel3rdPartyMobileNetworkInfoV1& currentNetwork=(*currentNetworkPckg)();			
       
   936 
       
   937 		// Check that the data structure is supported by the simulated TSY version
       
   938 		TInt err = iPhone->CheckSimTsyVersion(currentNetwork);
       
   939 		if(err != KErrNone)
       
   940 			{
       
   941 			iPhone->ReqCompleted(aReqHandle, err);
       
   942 			return KErrNone;
       
   943 			}
       
   944 
       
   945 		PopulateEtel3rdPartyNetworkInfoV1(iCurrentNetworkIndex, currentNetwork);
       
   946 		}
       
   947 	else
       
   948 		{
       
   949 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);
       
   950 		return KErrNone;		
       
   951 		}
       
   952 	
       
   953 	iPhone->ReqCompleted(aReqHandle,KErrNone);
       
   954 	return KErrNone;
       
   955 	}
       
   956 
       
   957 TInt CSimNetworkStatus::GetCurrentNetworkNoLocation(TTsyReqHandle aReqHandle,TDes8* aPckg1)
       
   958 /**
       
   959  * Retrieve information about the Current Network excluding loation information.  The current network is given by the
       
   960  * iCurrentNetworkIndex member variable.  It will be updated from RegStat tags in the
       
   961  * configuration file.  If there is no network information currently available (perhaps
       
   962  * because the SIM TSY is simulating a network search) KErrNotFound will be
       
   963  * returned.  If no registration status profile information is contained in the
       
   964  * configuration file KErrNotSupported will be returned.
       
   965  * @param aReqHandle	The request handle associated with this request.
       
   966  * @param aPckg1		The first parameter package.  This will be populated with the
       
   967  *						Current Network information to be returned. This is either a packaged TMobilePhoneNetworkInfoV1 or TMobilePhoneNetworkInfoV2
       
   968  * @return TInt			Standard error value.
       
   969  */
       
   970 	{	
       
   971 	return GetCurrentNetwork(aReqHandle, aPckg1, NULL);
       
   972 	}
       
   973 
       
   974 TInt CSimNetworkStatus::GetNetworkRegistrationStatus(TTsyReqHandle aReqHandle,TDes8* aPckg)
       
   975 /**
       
   976  * Retrieve information about the Current Network Registration Status.  This is given by
       
   977  * the iCurrentRegStatus member variable.  It will be updated from RegStat tags in the
       
   978  * configuration file.  If no registration status profile information is contained in the
       
   979  * configuration file KErrNotSupported will be returned.
       
   980  * @param aReqHandle	The request handle associated with this request.
       
   981  * @param aPckg1		The first parameter package.  This will be populated with the
       
   982  *						Current Network Registration Status to be returned.
       
   983  * @return TInt			Standard error value.
       
   984  */
       
   985 	{
       
   986 	TPckg<RMobilePhone::TMobilePhoneRegistrationStatus>* regStatusPckg=(TPckg<RMobilePhone::TMobilePhoneRegistrationStatus>*)aPckg;
       
   987 	RMobilePhone::TMobilePhoneRegistrationStatus& regStatus=(*regStatusPckg)();
       
   988 
       
   989 	if(iRegStatusInfo->Count()==0)
       
   990 		{
       
   991 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);
       
   992 		return KErrNone;
       
   993 		}
       
   994 
       
   995 	regStatus=(RMobilePhone::TMobilePhoneRegistrationStatus)iCurrentRegStatus;
       
   996 	iPhone->ReqCompleted(aReqHandle,KErrNone);
       
   997 	return KErrNone;
       
   998 	}
       
   999 
       
  1000 TInt CSimNetworkStatus::NotifyNetworkRegistrationStatusChange(TTsyReqHandle aReqHandle,TDes8* aPckg)
       
  1001 /**
       
  1002  * Register a client's interest in being notified when the Network Registration Status
       
  1003  * changes.
       
  1004  * This function records the request's parameters and awaits a change in network registration
       
  1005  * status before completing.
       
  1006  *
       
  1007  * @param aPckg			The first parameter package.  This is populated with the network registration
       
  1008  *						status.
       
  1009  * @return TInt			Standard error value.
       
  1010  */
       
  1011 	{
       
  1012 	TPckg<RMobilePhone::TMobilePhoneRegistrationStatus>* regStatusPckg=(TPckg<RMobilePhone::TMobilePhoneRegistrationStatus>*)aPckg;
       
  1013 	RMobilePhone::TMobilePhoneRegistrationStatus& regStatus=(*regStatusPckg)();
       
  1014 
       
  1015 	if(iRegStatusInfo->Count()==0)
       
  1016 		{
       
  1017 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);
       
  1018 		return KErrNone;
       
  1019 		}
       
  1020 
       
  1021 	__ASSERT_ALWAYS(!iRegStatChangeNotificationPending,SimPanic(ENotificationReqAlreadyOutstanding));
       
  1022 	iRegStatChangeNotificationPending=ETrue;
       
  1023 	iRegStatChangeNotificationReqHandle=aReqHandle;
       
  1024 	iRegStatChangeNotificationRegStatus=&regStatus;
       
  1025 	return KErrNone;
       
  1026 	}
       
  1027 
       
  1028 void CSimNetworkStatus::NotifyNetworkRegistrationStatusChangeCancel()
       
  1029 /**
       
  1030  * Cancel a previous request to be notified of a change in network registration status.
       
  1031  */
       
  1032 	{
       
  1033 	if(iRegStatChangeNotificationPending)
       
  1034 		{
       
  1035 		iRegStatChangeNotificationPending=EFalse;
       
  1036 		iPhone->ReqCompleted(iRegStatChangeNotificationReqHandle,KErrCancel);
       
  1037 		}
       
  1038 	}
       
  1039 
       
  1040 TInt CSimNetworkStatus::NotifyCurrentNetworkChange(TTsyReqHandle aReqHandle,TDes8* aPckg1,TDes8* aPckg2)
       
  1041 /**
       
  1042  * Register a client's interest in being notified when the current network changes.
       
  1043  * This function records the request's parameters and awaits a change in current network
       
  1044  * before completing.
       
  1045  *
       
  1046  * @param aPckg1		The first parameter package.  This is populated with the current network 
       
  1047  *						information when the request completes.
       
  1048  * @return TInt			Standard error value.
       
  1049  */
       
  1050 	{
       
  1051 	TPckg<RMobilePhone::TMobilePhoneLocationAreaV1>* areaPckg=(TPckg<RMobilePhone::TMobilePhoneLocationAreaV1>*)aPckg2;
       
  1052 	RMobilePhone::TMobilePhoneLocationAreaV1& area=(*areaPckg)();
       
  1053 
       
  1054 	// Check that the data structure is supported by the simulated TSY version
       
  1055 	TInt err = iPhone->CheckSimTsyVersion(area);
       
  1056 	if(err != KErrNone)
       
  1057 		{
       
  1058 		iPhone->ReqCompleted(aReqHandle, err);
       
  1059 		return KErrNone;
       
  1060 		}
       
  1061 
       
  1062 	TPckg<RMobilePhone::TMultimodeType>* paramPckg=(TPckg<RMobilePhone::TMultimodeType>*)aPckg1;
       
  1063 	RMobilePhone::TMultimodeType& paramclass=(*paramPckg)();
       
  1064 	
       
  1065 	if(iRegStatusInfo->Count()==0)
       
  1066 		{
       
  1067 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);
       
  1068 		return KErrNone;
       
  1069 		}
       
  1070 
       
  1071 	if(paramclass.ExtensionId() == KETelExtMultimodeV1)
       
  1072 		{
       
  1073 		__ASSERT_ALWAYS(!iCurrNetChangeV1NotificationPending,SimPanic(ENotificationReqAlreadyOutstanding));
       
  1074 		
       
  1075 		RMobilePhone::TMobilePhoneNetworkInfoV1Pckg* currentNetworkPckg=(RMobilePhone::TMobilePhoneNetworkInfoV1Pckg*)aPckg1;
       
  1076 		RMobilePhone::TMobilePhoneNetworkInfoV1& currentNetwork=(*currentNetworkPckg)();
       
  1077 
       
  1078 		// Check that the data structure is supported by the simulated TSY version
       
  1079 		TInt err = iPhone->CheckSimTsyVersion(currentNetwork);
       
  1080 		if(err != KErrNone)
       
  1081 			{
       
  1082 			iPhone->ReqCompleted(aReqHandle, err);
       
  1083 			return KErrNone;
       
  1084 			}
       
  1085 				
       
  1086 		iCurrNetChangeV1NotificationPending=ETrue;
       
  1087 		iCurrNetChangeV1NotificationReqHandle=aReqHandle;
       
  1088 		iCurrNetChangeV1NotificationNetInfo=&currentNetwork;
       
  1089 		}
       
  1090 	else if(paramclass.ExtensionId() == KETelExtMultimodeV2)
       
  1091 		{
       
  1092 		__ASSERT_ALWAYS(!iCurrNetChangeV2NotificationPending,SimPanic(ENotificationReqAlreadyOutstanding));
       
  1093 		
       
  1094 		RMobilePhone::TMobilePhoneNetworkInfoV2Pckg* currentNetworkPckg=(RMobilePhone::TMobilePhoneNetworkInfoV2Pckg*)aPckg1;
       
  1095 		RMobilePhone::TMobilePhoneNetworkInfoV2& currentNetwork=(*currentNetworkPckg)();
       
  1096 
       
  1097 		// Check that the data structure is supported by the simulated TSY version
       
  1098 		TInt err = iPhone->CheckSimTsyVersion(currentNetwork);
       
  1099 		if(err != KErrNone)
       
  1100 			{
       
  1101 			iPhone->ReqCompleted(aReqHandle, err);
       
  1102 			return KErrNone;
       
  1103 			}
       
  1104 				
       
  1105 		iCurrNetChangeV2NotificationPending=ETrue;
       
  1106 		iCurrNetChangeV2NotificationReqHandle=aReqHandle;
       
  1107 		iCurrNetChangeV2NotificationNetInfo=&currentNetwork;
       
  1108 		}
       
  1109 	else if(paramclass.ExtensionId() == KEtelExtMultimodeV5)
       
  1110 		{
       
  1111 		__ASSERT_ALWAYS(!iCurrNetChangeV5NotificationPending,SimPanic(ENotificationReqAlreadyOutstanding));
       
  1112 		
       
  1113 		RMobilePhone::TMobilePhoneNetworkInfoV5Pckg* currentNetworkPckg=(RMobilePhone::TMobilePhoneNetworkInfoV5Pckg*)aPckg1;
       
  1114 		RMobilePhone::TMobilePhoneNetworkInfoV5& currentNetwork=(*currentNetworkPckg)();
       
  1115 
       
  1116 		// Check that the data structure is supported by the simulated TSY version
       
  1117 		TInt err = iPhone->CheckSimTsyVersion(currentNetwork);
       
  1118 		if(err != KErrNone)
       
  1119 			{
       
  1120 			iPhone->ReqCompleted(aReqHandle, err);
       
  1121 			return KErrNone;
       
  1122 			}
       
  1123 				
       
  1124 		iCurrNetChangeV5NotificationPending=ETrue;
       
  1125 		iCurrNetChangeV5NotificationReqHandle=aReqHandle;
       
  1126 		iCurrNetChangeV5NotificationNetInfo=&currentNetwork;
       
  1127 		}
       
  1128 	else if(paramclass.ExtensionId() == KEtelExtMultimodeV8)
       
  1129 		{
       
  1130 		__ASSERT_ALWAYS(!iCurrNetChangeV8NotificationPending,SimPanic(ENotificationReqAlreadyOutstanding));
       
  1131 		
       
  1132 		RMobilePhone::TMobilePhoneNetworkInfoV8Pckg* currentNetworkPckg=(RMobilePhone::TMobilePhoneNetworkInfoV8Pckg*)aPckg1;
       
  1133 		RMobilePhone::TMobilePhoneNetworkInfoV8& currentNetwork=(*currentNetworkPckg)();
       
  1134 
       
  1135 		// Check that the data structure is supported by the simulated TSY version
       
  1136 		TInt err = iPhone->CheckSimTsyVersion(currentNetwork);
       
  1137 		if(err != KErrNone)
       
  1138 			{
       
  1139 			iPhone->ReqCompleted(aReqHandle, err);
       
  1140 			return KErrNone;
       
  1141 			}
       
  1142 				
       
  1143 		iCurrNetChangeV8NotificationPending=ETrue;
       
  1144 		iCurrNetChangeV8NotificationReqHandle=aReqHandle;
       
  1145 		iCurrNetChangeV8NotificationNetInfo=&currentNetwork;
       
  1146 		}
       
  1147 	else if(paramclass.ExtensionId() == KETelExt3rdPartyV1)
       
  1148 		{
       
  1149 		RMobilePhone::TEtel3rdPartyMobileNetworkInfoV1Pckg* currentNetworkPckg=(RMobilePhone::TEtel3rdPartyMobileNetworkInfoV1Pckg*)aPckg1;
       
  1150 		RMobilePhone::TEtel3rdPartyMobileNetworkInfoV1& currentNetwork=(*currentNetworkPckg)();			
       
  1151 
       
  1152 		// Check that the data structure is supported by the simulated TSY version
       
  1153 		TInt err = iPhone->CheckSimTsyVersion(currentNetwork);
       
  1154 		if(err != KErrNone)
       
  1155 			{
       
  1156 			iPhone->ReqCompleted(aReqHandle, err);
       
  1157 			return KErrNone;
       
  1158 			}
       
  1159 		
       
  1160 		iCurrNetChangeEtelIsvNotificationPending=ETrue;
       
  1161 		iCurrNetChangeEtelIsvNotificationReqHandle=aReqHandle;
       
  1162 		iCurrNetChangeEtelIsvNotificationNetInfo=&currentNetwork;
       
  1163 		}
       
  1164 	else 
       
  1165 		{	
       
  1166 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);
       
  1167 		return KErrNone;
       
  1168 		}
       
  1169 
       
  1170 	__ASSERT_ALWAYS(!iCurrentNetworkChangeLocationAreaNotificationPending,SimPanic(ENotificationReqAlreadyOutstanding));
       
  1171 	iCurrentNetworkChangeLocationArea = &area;
       
  1172 	iCurrentNetworkChangeLocationAreaNotificationPending = ETrue;
       
  1173 	
       
  1174 	return KErrNone;
       
  1175 	}
       
  1176 
       
  1177 void CSimNetworkStatus::NotifyCurrentNetworkChangeCancel(const TTsyReqHandle aTsyReqHandle)
       
  1178 /**
       
  1179  * Cancel a previous request to be notified of a change in current network.
       
  1180  * @param aTsyReqHandle request handle
       
  1181  */
       
  1182 	{
       
  1183 	if(iCurrNetChangeV1NotificationPending && iCurrNetChangeV1NotificationReqHandle == aTsyReqHandle)
       
  1184 		{
       
  1185 		iCurrNetChangeV1NotificationPending=EFalse;
       
  1186 		iPhone->ReqCompleted(iCurrNetChangeV1NotificationReqHandle,KErrCancel);
       
  1187 		}
       
  1188 	else if(iCurrNetChangeV2NotificationPending && iCurrNetChangeV2NotificationReqHandle == aTsyReqHandle)
       
  1189 		{
       
  1190 		iCurrNetChangeV2NotificationPending=EFalse;
       
  1191 		iPhone->ReqCompleted(iCurrNetChangeV2NotificationReqHandle,KErrCancel);
       
  1192 		}
       
  1193 	else if(iCurrNetChangeV5NotificationPending && iCurrNetChangeV5NotificationReqHandle == aTsyReqHandle)
       
  1194 		{
       
  1195 		iCurrNetChangeV5NotificationPending=EFalse;
       
  1196 		iPhone->ReqCompleted(iCurrNetChangeV5NotificationReqHandle,KErrCancel);
       
  1197 		}
       
  1198 	else if(iCurrNetChangeV8NotificationPending && iCurrNetChangeV8NotificationReqHandle == aTsyReqHandle)
       
  1199 		{
       
  1200 		iCurrNetChangeV8NotificationPending=EFalse;
       
  1201 		iPhone->ReqCompleted(iCurrNetChangeV8NotificationReqHandle,KErrCancel);
       
  1202 		}
       
  1203 	else if(iCurrNetChangeEtelIsvNotificationPending && iCurrNetChangeEtelIsvNotificationReqHandle == aTsyReqHandle)
       
  1204 		{
       
  1205 		iCurrNetChangeEtelIsvNotificationPending=EFalse;
       
  1206 		iPhone->ReqCompleted(iCurrNetChangeEtelIsvNotificationReqHandle,KErrCancel);
       
  1207 		}
       
  1208 	iCurrentNetworkChangeLocationAreaNotificationPending = EFalse;
       
  1209 	}
       
  1210 
       
  1211 TInt CSimNetworkStatus::NotifyCurrentNetworkNoLocationChange(TTsyReqHandle aReqHandle,TDes8* aPckg1)
       
  1212 /**
       
  1213  * Register an EtelISV client's interest in being notified when the current network changes.
       
  1214  * This function records the request's parameters and awaits a change in current network
       
  1215  * before completing.
       
  1216  *
       
  1217  * @param aPckg1		The first parameter package.  This is populated with the current network 
       
  1218  *						information when the request completes.
       
  1219  * @return TInt			Standard error value.
       
  1220  */
       
  1221 	{
       
  1222 	TPckg<RMobilePhone::TMultimodeType>* paramPckg=(TPckg<RMobilePhone::TMultimodeType>*)aPckg1;
       
  1223 	RMobilePhone::TMultimodeType& paramclass=(*paramPckg)();
       
  1224 	
       
  1225 	if(iRegStatusInfo->Count()==0)
       
  1226 		{
       
  1227 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);
       
  1228 		return KErrNone;
       
  1229 		}
       
  1230 
       
  1231 	if(paramclass.ExtensionId() == KETelExtMultimodeV1)
       
  1232 		{
       
  1233 		__ASSERT_ALWAYS(!iCurrNetChangeNoLocV1NotificationPending,SimPanic(ENotificationReqAlreadyOutstanding));
       
  1234 		
       
  1235 		RMobilePhone::TMobilePhoneNetworkInfoV1Pckg* currentNetworkPckg=(RMobilePhone::TMobilePhoneNetworkInfoV1Pckg*)aPckg1;
       
  1236 		RMobilePhone::TMobilePhoneNetworkInfoV1& currentNetwork=(*currentNetworkPckg)();
       
  1237 
       
  1238 
       
  1239 		// Check that the data structure is supported by the simulated TSY version
       
  1240 		TInt err = iPhone->CheckSimTsyVersion(currentNetwork);
       
  1241 		if(err != KErrNone)
       
  1242 			{
       
  1243 			iPhone->ReqCompleted(aReqHandle, err);
       
  1244 			return KErrNone;
       
  1245 			}
       
  1246 				
       
  1247 		iCurrNetChangeNoLocV1NotificationPending=ETrue;
       
  1248 		iCurrNetChangeNoLocV1NotificationReqHandle=aReqHandle;
       
  1249 		iCurrNetChangeNoLocV1NotificationNetInfo=&currentNetwork;
       
  1250 		}
       
  1251 	else if(paramclass.ExtensionId() == KETelExtMultimodeV2)
       
  1252 		{
       
  1253 		__ASSERT_ALWAYS(!iCurrNetChangeNoLocV2NotificationPending,SimPanic(ENotificationReqAlreadyOutstanding));
       
  1254 		
       
  1255 		RMobilePhone::TMobilePhoneNetworkInfoV2Pckg* currentNetworkPckg=(RMobilePhone::TMobilePhoneNetworkInfoV2Pckg*)aPckg1;
       
  1256 		RMobilePhone::TMobilePhoneNetworkInfoV2& currentNetwork=(*currentNetworkPckg)();
       
  1257 
       
  1258 		// Check that the data structure is supported by the simulated TSY version
       
  1259 		TInt err = iPhone->CheckSimTsyVersion(currentNetwork);
       
  1260 		if(err != KErrNone)
       
  1261 			{
       
  1262 			iPhone->ReqCompleted(aReqHandle, err);
       
  1263 			return KErrNone;
       
  1264 			}
       
  1265 
       
  1266 		iCurrNetChangeNoLocV2NotificationPending=ETrue;
       
  1267 		iCurrNetChangeNoLocV2NotificationReqHandle=aReqHandle;
       
  1268 		iCurrNetChangeNoLocV2NotificationNetInfo=&currentNetwork;
       
  1269 		}
       
  1270 	else if(paramclass.ExtensionId() == KEtelExtMultimodeV5)
       
  1271 		{
       
  1272 		__ASSERT_ALWAYS(!iCurrNetChangeNoLocV5NotificationPending,SimPanic(ENotificationReqAlreadyOutstanding));
       
  1273 		
       
  1274 		RMobilePhone::TMobilePhoneNetworkInfoV5Pckg* currentNetworkPckg=(RMobilePhone::TMobilePhoneNetworkInfoV5Pckg*)aPckg1;
       
  1275 		RMobilePhone::TMobilePhoneNetworkInfoV5& currentNetwork=(*currentNetworkPckg)();
       
  1276 
       
  1277 		// Check that the data structure is supported by the simulated TSY version
       
  1278 		TInt err = iPhone->CheckSimTsyVersion(currentNetwork);
       
  1279 		if(err != KErrNone)
       
  1280 			{
       
  1281 			iPhone->ReqCompleted(aReqHandle, err);
       
  1282 			return KErrNone;
       
  1283 			}
       
  1284 
       
  1285 		iCurrNetChangeNoLocV5NotificationPending=ETrue;
       
  1286 		iCurrNetChangeNoLocV5NotificationReqHandle=aReqHandle;
       
  1287 		iCurrNetChangeNoLocV5NotificationNetInfo=&currentNetwork;
       
  1288 		}
       
  1289 	else if(paramclass.ExtensionId() == KEtelExtMultimodeV8)
       
  1290 		{
       
  1291 		__ASSERT_ALWAYS(!iCurrNetChangeNoLocV8NotificationPending,SimPanic(ENotificationReqAlreadyOutstanding));
       
  1292 		
       
  1293 		RMobilePhone::TMobilePhoneNetworkInfoV8Pckg* currentNetworkPckg=(RMobilePhone::TMobilePhoneNetworkInfoV8Pckg*)aPckg1;
       
  1294 		RMobilePhone::TMobilePhoneNetworkInfoV8& currentNetwork=(*currentNetworkPckg)();
       
  1295 
       
  1296 		// Check that the data structure is supported by the simulated TSY version
       
  1297 		TInt err = iPhone->CheckSimTsyVersion(currentNetwork);
       
  1298 		if(err != KErrNone)
       
  1299 			{
       
  1300 			iPhone->ReqCompleted(aReqHandle, err);
       
  1301 			return KErrNone;
       
  1302 			}
       
  1303 
       
  1304 		iCurrNetChangeNoLocV8NotificationPending=ETrue;
       
  1305 		iCurrNetChangeNoLocV8NotificationReqHandle=aReqHandle;
       
  1306 		iCurrNetChangeNoLocV8NotificationNetInfo=&currentNetwork;
       
  1307 		}
       
  1308 	else 
       
  1309 		{	
       
  1310 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);
       
  1311 		return KErrNone;
       
  1312 		}
       
  1313 	return KErrNone;
       
  1314 	}
       
  1315 
       
  1316 void CSimNetworkStatus::NotifyCurrentNetworkNoLocationChangeCancel(const TTsyReqHandle aTsyReqHandle)
       
  1317 /**
       
  1318  * Cancel a previous request from an EtelISV client to be notified of a change in current network.
       
  1319  * @param aTsyReqHandle request handle
       
  1320  */
       
  1321 	{
       
  1322 	if(iCurrNetChangeNoLocV1NotificationPending && iCurrNetChangeNoLocV1NotificationReqHandle == aTsyReqHandle)
       
  1323 		{
       
  1324 		iCurrNetChangeNoLocV1NotificationPending=EFalse;
       
  1325 		iPhone->ReqCompleted(iCurrNetChangeNoLocV1NotificationReqHandle,KErrCancel);
       
  1326 		}
       
  1327 	else if(iCurrNetChangeNoLocV2NotificationPending && iCurrNetChangeNoLocV2NotificationReqHandle == aTsyReqHandle)
       
  1328 		{
       
  1329 		iCurrNetChangeNoLocV2NotificationPending=EFalse;
       
  1330 		iPhone->ReqCompleted(iCurrNetChangeNoLocV2NotificationReqHandle,KErrCancel);
       
  1331 		}
       
  1332 	else if(iCurrNetChangeNoLocV5NotificationPending && iCurrNetChangeNoLocV5NotificationReqHandle == aTsyReqHandle)
       
  1333 		{
       
  1334 		iCurrNetChangeNoLocV5NotificationPending=EFalse;
       
  1335 		iPhone->ReqCompleted(iCurrNetChangeNoLocV5NotificationReqHandle,KErrCancel);
       
  1336 		}
       
  1337 	else if(iCurrNetChangeNoLocV8NotificationPending && iCurrNetChangeNoLocV8NotificationReqHandle == aTsyReqHandle)
       
  1338 		{
       
  1339 		iCurrNetChangeNoLocV8NotificationPending=EFalse;
       
  1340 		iPhone->ReqCompleted(iCurrNetChangeNoLocV8NotificationReqHandle,KErrCancel);
       
  1341 		}
       
  1342 	}
       
  1343 
       
  1344 TInt CSimNetworkStatus::GetNITZInfo(TTsyReqHandle aReqHandle,TDes8* aPckg)
       
  1345 /**
       
  1346  * Retrieve the current "Network Information and Time Zone" (NITZ) information.
       
  1347  * It will be updated from NitzInfo tags in the configuration file.  If no NITZ
       
  1348  * profile information is contained in the configuration file KErrNotSupported
       
  1349  * will be returned.
       
  1350  * @param aReqHandle	The request handle associated with this request.
       
  1351  * @param aPckg			The first parameter package.  This will be populated with the
       
  1352  *						NITZ information to be returned.
       
  1353  * @return TInt			Standard error value.
       
  1354  */
       
  1355 	{
       
  1356 	TPckg<RMobilePhone::TMobilePhoneNITZ>* nitzPckg=(TPckg<RMobilePhone::TMobilePhoneNITZ>*)aPckg;
       
  1357 	RMobilePhone::TMobilePhoneNITZ& nitz=(*nitzPckg)();
       
  1358 
       
  1359 	if(iNitzInfo->Count()==0)
       
  1360 		{
       
  1361 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);
       
  1362 		return KErrNone;
       
  1363 		}
       
  1364 
       
  1365 	nitz=iCurrentNitzInfo;
       
  1366 	PopulateNitzNetworkNames(nitz);
       
  1367 	iPhone->ReqCompleted(aReqHandle,KErrNone);
       
  1368 	return KErrNone;
       
  1369 	}
       
  1370 
       
  1371 TInt CSimNetworkStatus::NotifyNITZInfoChange(TTsyReqHandle aReqHandle,TDes8* aPckg)
       
  1372 /**
       
  1373  * Register a client's interest in being notified when NITZ information is received.
       
  1374  * This function records the request's parameters and awaits a NITZ information event, as
       
  1375  * scheduled by the "NitzInfo" tags in the configuration file.
       
  1376  *
       
  1377  * @param aPckg			The first parameter package.  This is populated with the NITZ
       
  1378  *						information when the request completes.
       
  1379  * @return TInt			Standard error value.
       
  1380  */
       
  1381 	{
       
  1382 	TPckg<RMobilePhone::TMobilePhoneNITZ>* nitzPckg=(TPckg<RMobilePhone::TMobilePhoneNITZ>*)aPckg;
       
  1383 	RMobilePhone::TMobilePhoneNITZ& nitz=(*nitzPckg)();
       
  1384 
       
  1385 	if(iNitzInfo->Count()==0)
       
  1386 		{
       
  1387 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);
       
  1388 		return KErrNone;
       
  1389 		}
       
  1390 
       
  1391 	iNitzChangeNotificationPending=ETrue;
       
  1392 	iNitzChangeNotificationReqHandle=aReqHandle;
       
  1393 	iNitzChangeNotificationInfo=&nitz;
       
  1394 	return KErrNone;
       
  1395 	}
       
  1396 
       
  1397 void CSimNetworkStatus::NotifyNITZInfoChangeCancel()
       
  1398 /**
       
  1399  * Cancel a previous request to be notified of new NITZ informations.
       
  1400  */
       
  1401 	{
       
  1402 	if(iNitzChangeNotificationPending)
       
  1403 		{
       
  1404 		iNitzChangeNotificationPending=EFalse;
       
  1405 		iPhone->ReqCompleted(iNitzChangeNotificationReqHandle,KErrCancel);
       
  1406 		}
       
  1407 	}
       
  1408 
       
  1409 void CSimNetworkStatus::TimerCallBack(TInt aId)
       
  1410 /**
       
  1411  * The timer callback function.  This function will be called when either the
       
  1412  * Registration Status timer, cell info timer or the NITZ timer complete.  The aId parameter
       
  1413  * is used to indicate which timer has completed and the appropriate callback function
       
  1414  * is called.
       
  1415  * @param aId	This parameter indicates which timer has completed.  The timer ID is
       
  1416  *				registered when the timer is started.
       
  1417  */
       
  1418 	{
       
  1419 	switch(aId)
       
  1420 		{
       
  1421 	case ETimerIdNtwkStatRegStat:
       
  1422 		TimerCallBackRegStat();
       
  1423 		break;
       
  1424 	case ETimerIdNtwkStatNitz:
       
  1425 		TimerCallBackNitz();
       
  1426 		break;
       
  1427 	case ETimerIdNtwkStatRadioMode:
       
  1428 		TInt err;
       
  1429 		err = KErrNone;
       
  1430 		TRAP(err,TimerCallBackRadioModeL());
       
  1431 		break;
       
  1432 
       
  1433 	case ETimerIdNtwkStatRoamStat:
       
  1434 		 SimPanic(EIllegalCallBackId);		
       
  1435 		break;
       
  1436 	case ETimerIdCellInfo:
       
  1437 		TimerCallBackCellInfo();
       
  1438 		break;
       
  1439 	default:
       
  1440 		LOGNETWORK3("CSimNetworkStatus::TimerCallBack(%d), OOR [%d]",aId, ETimerIdNtwkStatRegStat);
       
  1441 		SimPanic(EIllegalCallBackId);
       
  1442 		break;
       
  1443 		}
       
  1444 	}
       
  1445 
       
  1446 void CSimNetworkStatus::TimerCallBackRegStat()
       
  1447 /**
       
  1448  * The Registration timer callback function.  This function will be called when the
       
  1449  * Network Registration timer completes.  It indicates a simulated change in registration
       
  1450  * status. So, the new network settings must be loaded into the relevant member variables
       
  1451  * and any pending registration notification requests must be completed.
       
  1452  * Finally, the next Network Registration timer is started.
       
  1453  */
       
  1454 	{
       
  1455 	iRegStatIndex++;
       
  1456 	if(iRegStatusInfo->Count()<=iRegStatIndex)
       
  1457 		return;
       
  1458 
       
  1459 	TInt oldNetworkIndex=iCurrentNetworkIndex;
       
  1460 	iCurrentRegStatus=iRegStatusInfo->At(iRegStatIndex).iRegStatus;
       
  1461 	iCurrentNetworkIndex=iRegStatusInfo->At(iRegStatIndex).iNetworkInfoIndex;
       
  1462 
       
  1463 	// Ask phone to check if indicator notification needs to be triggered
       
  1464 	iPhone->CheckIndicatorNotification();
       
  1465 
       
  1466 	if(iRegStatChangeNotificationPending)
       
  1467 		{
       
  1468 		iRegStatChangeNotificationPending=EFalse;
       
  1469 		*iRegStatChangeNotificationRegStatus=(RMobilePhone::TMobilePhoneRegistrationStatus)iCurrentRegStatus;
       
  1470 		iPhone->ReqCompleted(iRegStatChangeNotificationReqHandle,KErrNone);
       
  1471 		}
       
  1472 	if(oldNetworkIndex!=iCurrentNetworkIndex && iCurrentNetworkIndex>=0)
       
  1473 		{
       
  1474 		if(iCurrentNetworkChangeLocationAreaNotificationPending)
       
  1475 			{
       
  1476 			if((iCurrentNetworkIndex >= 0) &&(iCurrentNetworkIndex < iLocationArea->Count()))
       
  1477 				{
       
  1478 				iCurrentNetworkChangeLocationArea->iAreaKnown = iLocationArea->At(iCurrentNetworkIndex).iAreaKnown;
       
  1479 				iCurrentNetworkChangeLocationArea->iLocationAreaCode = iLocationArea->At(iCurrentNetworkIndex).iLocationAreaCode;
       
  1480 				iCurrentNetworkChangeLocationArea->iCellId = iLocationArea->At(iCurrentNetworkIndex).iCellId;
       
  1481 				}
       
  1482 			else
       
  1483 				{
       
  1484 				iCurrentNetworkChangeLocationArea->iAreaKnown = EFalse;
       
  1485 				}
       
  1486 			iCurrentNetworkChangeLocationAreaNotificationPending=EFalse;
       
  1487 			}
       
  1488 		if(iCurrNetChangeV1NotificationPending)
       
  1489 			{
       
  1490 			LOGNETWORK1("CSimNetworkStatus::TimerCallBackRegStat() - completing NotifyCurrentNetworkChange TMobilePhoneNetworkInfoV1");
       
  1491 			iCurrNetChangeV1NotificationPending = EFalse;
       
  1492 			RMobilePhone::TMobilePhoneNetworkInfoV1* changeNetInfoV1 = reinterpret_cast<RMobilePhone::TMobilePhoneNetworkInfoV1*>(iCurrNetChangeV1NotificationNetInfo);
       
  1493 
       
  1494 			PopulateNetworkInfoV1(iCurrentNetworkIndex,*changeNetInfoV1);
       
  1495 			iPhone->ReqCompleted(iCurrNetChangeV1NotificationReqHandle,KErrNone);
       
  1496 			}
       
  1497 			
       
  1498 		if(iCurrNetChangeV2NotificationPending)
       
  1499 			{
       
  1500 			LOGNETWORK1("CSimNetworkStatus::TimerCallBackRegStat() - completing NotifyCurrentNetworkChange TMobilePhoneNetworkInfoV2");
       
  1501 			iCurrNetChangeV2NotificationPending = EFalse;
       
  1502 			RMobilePhone::TMobilePhoneNetworkInfoV2* changeNetInfoV2 = reinterpret_cast<RMobilePhone::TMobilePhoneNetworkInfoV2*>(iCurrNetChangeV2NotificationNetInfo);
       
  1503 			PopulateNetworkInfoV1(iCurrentNetworkIndex,*changeNetInfoV2);
       
  1504 			//also set v2 paramaters
       
  1505 			changeNetInfoV2->iAccess = iNetworkInfo->At(iCurrentNetworkIndex).iAccess;
       
  1506 			iPhone->ReqCompleted(iCurrNetChangeV2NotificationReqHandle,KErrNone);
       
  1507 			}
       
  1508 		
       
  1509 		if(iCurrNetChangeV5NotificationPending)
       
  1510 			{
       
  1511 			LOGNETWORK1("CSimNetworkStatus::TimerCallBackRegStat() - completing NotifyCurrentNetworkChange TMobilePhoneNetworkInfoV5");
       
  1512 			iCurrNetChangeV5NotificationPending = EFalse;
       
  1513 			RMobilePhone::TMobilePhoneNetworkInfoV5* changeNetInfoV5 = reinterpret_cast<RMobilePhone::TMobilePhoneNetworkInfoV5*>(iCurrNetChangeV5NotificationNetInfo);
       
  1514 			PopulateNetworkInfoV1(iCurrentNetworkIndex,*changeNetInfoV5);
       
  1515 			//also set v5 paramaters
       
  1516 			changeNetInfoV5->iAccess = iNetworkInfoV8->At(0).iAccess;
       
  1517 			changeNetInfoV5->iHsdpaAvailableIndicator= iNetworkInfoV8->At(0).iHsdpaAvailableIndicator;
       
  1518 			changeNetInfoV5->iEgprsAvailableIndicator = iNetworkInfoV8->At(0).iEgprsAvailableIndicator;
       
  1519 			iPhone->ReqCompleted(iCurrNetChangeV5NotificationReqHandle,KErrNone);
       
  1520 			}
       
  1521 			
       
  1522 		if(iCurrNetChangeV8NotificationPending)
       
  1523 			{
       
  1524 			LOGNETWORK1("CSimNetworkStatus::TimerCallBackRegStat() - completing NotifyCurrentNetworkChange TMobilePhoneNetworkInfoV8");
       
  1525 			iCurrNetChangeV8NotificationPending = EFalse;
       
  1526 			RMobilePhone::TMobilePhoneNetworkInfoV8* changeNetInfoV8 = reinterpret_cast<RMobilePhone::TMobilePhoneNetworkInfoV8*>(iCurrNetChangeV8NotificationNetInfo);
       
  1527 			PopulateNetworkInfoV1(iCurrentNetworkIndex,*changeNetInfoV8);
       
  1528 			//also set v5 paramaters
       
  1529 			changeNetInfoV8->iAccess = iNetworkInfo->At(iCurrentNetworkIndex).iAccess;
       
  1530 			changeNetInfoV8->iHsdpaAvailableIndicator = iNetworkInfoV8->At(0).iHsdpaAvailableIndicator;
       
  1531 			changeNetInfoV8->iEgprsAvailableIndicator = iNetworkInfoV8->At(0).iEgprsAvailableIndicator;
       
  1532 			changeNetInfoV8->iHsupaAvailableIndicator = iNetworkInfoV8->At(0).iHsupaAvailableIndicator;
       
  1533 			iPhone->ReqCompleted(iCurrNetChangeV8NotificationReqHandle,KErrNone);
       
  1534 			}
       
  1535 					
       
  1536 		if(iCurrNetChangeEtelIsvNotificationPending)
       
  1537 			{
       
  1538 			LOGNETWORK1("CSimNetworkStatus::TimerCallBackRegStat() - completing NotifyCurrentNetworkChange TEtel3rdPartyMobileNetworkInfoV1");
       
  1539 			iCurrNetChangeEtelIsvNotificationPending = EFalse;
       
  1540 			RMobilePhone::TEtel3rdPartyMobileNetworkInfoV1* changeNetInfoEtelIsv = reinterpret_cast<RMobilePhone::TEtel3rdPartyMobileNetworkInfoV1*>(iCurrNetChangeEtelIsvNotificationNetInfo);
       
  1541 
       
  1542 			PopulateEtel3rdPartyNetworkInfoV1(iCurrentNetworkIndex, *changeNetInfoEtelIsv);
       
  1543 			iPhone->ReqCompleted(iCurrNetChangeEtelIsvNotificationReqHandle,KErrNone);
       
  1544 			}
       
  1545 		if(iCurrNetChangeNoLocV1NotificationPending)
       
  1546 			{
       
  1547 			LOGNETWORK1("CSimNetworkStatus::TimerCallBackRegStat() - completing NotifyCurrentNetworkChange TMobilePhoneNetworkInfoV1 (No Location)");
       
  1548 			iCurrNetChangeNoLocV1NotificationPending = EFalse;
       
  1549 			RMobilePhone::TMobilePhoneNetworkInfoV1* changeNetInfoV1 = reinterpret_cast<RMobilePhone::TMobilePhoneNetworkInfoV1*>(iCurrNetChangeNoLocV1NotificationNetInfo);
       
  1550 
       
  1551 			PopulateNetworkInfoV1(iCurrentNetworkIndex,*changeNetInfoV1);
       
  1552 			iPhone->ReqCompleted(iCurrNetChangeNoLocV1NotificationReqHandle,KErrNone);
       
  1553 			}
       
  1554 			
       
  1555 		if(iCurrNetChangeNoLocV2NotificationPending)
       
  1556 			{
       
  1557 			LOGNETWORK1("CSimNetworkStatus::TimerCallBackRegStat() - completing NotifyCurrentNetworkChange TMobilePhoneNetworkInfoV2 (No Location)");
       
  1558 			iCurrNetChangeNoLocV2NotificationPending = EFalse;
       
  1559 			RMobilePhone::TMobilePhoneNetworkInfoV2* changeNetInfoV2 = reinterpret_cast<RMobilePhone::TMobilePhoneNetworkInfoV2*>(iCurrNetChangeNoLocV2NotificationNetInfo);
       
  1560 
       
  1561 			PopulateNetworkInfoV1(iCurrentNetworkIndex,*changeNetInfoV2);
       
  1562 			//also set v2 paramaters
       
  1563 			changeNetInfoV2->iAccess = iNetworkInfo->At(iCurrentNetworkIndex).iAccess;
       
  1564 			iPhone->ReqCompleted(iCurrNetChangeNoLocV2NotificationReqHandle,KErrNone);
       
  1565 			}
       
  1566 			
       
  1567 		if(iCurrNetChangeNoLocV5NotificationPending)
       
  1568 			{
       
  1569 			LOGNETWORK1("CSimNetworkStatus::TimerCallBackRegStat() - completing NotifyCurrentNetworkChange TMobilePhoneNetworkInfoV5 (No Location)");
       
  1570 			iCurrNetChangeNoLocV5NotificationPending = EFalse;
       
  1571 			RMobilePhone::TMobilePhoneNetworkInfoV5* changeNetInfoV5 = reinterpret_cast<RMobilePhone::TMobilePhoneNetworkInfoV5*>(iCurrNetChangeNoLocV5NotificationNetInfo);
       
  1572 
       
  1573 			PopulateNetworkInfoV1(iCurrentNetworkIndex,*changeNetInfoV5);
       
  1574 			//also set v5 paramaters
       
  1575 			changeNetInfoV5->iAccess = iNetworkInfoV8->At(0).iAccess;
       
  1576 			changeNetInfoV5->iHsdpaAvailableIndicator= iNetworkInfoV8->At(0).iHsdpaAvailableIndicator;
       
  1577 			changeNetInfoV5->iEgprsAvailableIndicator= iNetworkInfoV8->At(0).iEgprsAvailableIndicator;
       
  1578 			iPhone->ReqCompleted(iCurrNetChangeNoLocV5NotificationReqHandle,KErrNone);
       
  1579 			}
       
  1580 			
       
  1581 		if(iCurrNetChangeNoLocV8NotificationPending)
       
  1582 			{
       
  1583 			LOGNETWORK1("CSimNetworkStatus::TimerCallBackRegStat() - completing NotifyCurrentNetworkChange TMobilePhoneNetworkInfoV8 (No Location)");
       
  1584 			iCurrNetChangeNoLocV8NotificationPending = EFalse;
       
  1585 			RMobilePhone::TMobilePhoneNetworkInfoV8* changeNetInfoV8 = reinterpret_cast<RMobilePhone::TMobilePhoneNetworkInfoV8*>(iCurrNetChangeNoLocV8NotificationNetInfo);
       
  1586 
       
  1587 			PopulateNetworkInfoV1(iCurrentNetworkIndex,*changeNetInfoV8);
       
  1588 			//also set v8 paramaters
       
  1589 			changeNetInfoV8->iAccess = iNetworkInfo->At(iCurrentNetworkIndex).iAccess;
       
  1590 			changeNetInfoV8->iHsdpaAvailableIndicator= iNetworkInfoV8->At(0).iHsdpaAvailableIndicator;
       
  1591 			changeNetInfoV8->iEgprsAvailableIndicator= iNetworkInfoV8->At(0).iEgprsAvailableIndicator;
       
  1592 			changeNetInfoV8->iHsupaAvailableIndicator= iNetworkInfoV8->At(0).iHsupaAvailableIndicator;
       
  1593 			iPhone->ReqCompleted(iCurrNetChangeNoLocV8NotificationReqHandle,KErrNone);
       
  1594 			}			
       
  1595 		}		
       
  1596 
       
  1597 	iRegStatTimer->Start(iRegStatusInfo->At(iRegStatIndex).iDuration,this,ETimerIdNtwkStatRegStat);
       
  1598 	}
       
  1599 
       
  1600 void CSimNetworkStatus::TimerCallBackNitz()
       
  1601 /**
       
  1602  * The NITZ timer callback function.  This function will be called when the NITZ timer
       
  1603  * completes.  It indicates a simulated new NITZ information event. So, the new
       
  1604  * NITZ settings must be loaded into the relevant NITZ member variables and any
       
  1605  * pending NITZ notification requests must be completed.
       
  1606  * Finally, the next NITZ timer is started.
       
  1607  */
       
  1608 	{
       
  1609 	iNitzIndex++;
       
  1610 	if(iNitzInfo->Count()<=iNitzIndex)
       
  1611 		return;
       
  1612 	
       
  1613 	iCurrentNitzInfo=iNitzInfo->At(iNitzIndex).iNitz;
       
  1614 
       
  1615 	if(iNitzChangeNotificationPending)
       
  1616 		{
       
  1617 		iNitzChangeNotificationPending=EFalse;
       
  1618 		*iNitzChangeNotificationInfo=iCurrentNitzInfo;
       
  1619 		PopulateNitzNetworkNames(*iNitzChangeNotificationInfo);
       
  1620 		iPhone->ReqCompleted(iNitzChangeNotificationReqHandle,KErrNone);
       
  1621 		}
       
  1622 
       
  1623 	iNitzTimer->Start(iNitzInfo->At(iNitzIndex).iDuration,this,ETimerIdNtwkStatNitz);
       
  1624 	}
       
  1625 	
       
  1626 void CSimNetworkStatus::TimerCallBackRadioModeL()
       
  1627 /**
       
  1628  * The RadioMode timer callback function.  This function will be called when the RadioMode timer
       
  1629  * completes.  
       
  1630  */
       
  1631 	{
       
  1632 	LOGNETWORK1("CSimNetworkStatus::TimerCallBackRadioModeL");
       
  1633 	iRadioModeIndex++;
       
  1634 	if(iRadioModeInfo->Count()<=iRadioModeIndex)
       
  1635 		{
       
  1636 		LOGNETWORK1("CSimNetworkStatus::TimerCallBackRadioModeL returning, no more config");
       
  1637 		return;
       
  1638 		}
       
  1639 
       
  1640 	iRadioMode=iRadioModeInfo->At(iRadioModeIndex);
       
  1641 	if(iRadioMode.iRadioOn==EFalse)
       
  1642 		{
       
  1643 		RProperty::Set(KUidSystemCategory, KUidPhonePwrValue, ESAPhoneOff);
       
  1644 		LOGNETWORK1("Radio Mode = OFF (config duration passed)");
       
  1645 		}
       
  1646 	else
       
  1647 		{
       
  1648 		RProperty::Set(KUidSystemCategory, KUidPhonePwrValue, ESAPhoneOn);
       
  1649 		LOGNETWORK1("Radio Mode = ON (config duration passed)");
       
  1650 		}
       
  1651 
       
  1652 	LOGNETWORK2("Next radio Mode duration = %d (from config)", iRadioModeInfo->At(iRadioModeIndex).iDuration);
       
  1653 	iRadioModeTimer->Start(iRadioModeInfo->At(iRadioModeIndex).iDuration,this,ETimerIdNtwkStatRadioMode);
       
  1654 	}
       
  1655 
       
  1656 void CSimNetworkStatus::PopulateNetworkInfoV1(TInt aIndex,RMobilePhone::TMobilePhoneNetworkInfoV1& aNetInfo)
       
  1657 /**
       
  1658  * A helper function to copy network information structures.
       
  1659  */
       
  1660 	{
       
  1661 	RMobilePhone::TMobilePhoneNetworkInfoV1& curNetnfo=reinterpret_cast<RMobilePhone::TMobilePhoneNetworkInfoV1&>(iNetworkInfo->At(aIndex));	
       
  1662 	aNetInfo.iMode = curNetnfo.iMode;
       
  1663 	aNetInfo.iStatus = curNetnfo.iStatus;
       
  1664 	aNetInfo.iBandInfo = curNetnfo.iBandInfo;
       
  1665 	aNetInfo.iCountryCode = curNetnfo.iCountryCode;
       
  1666 	//aNetInfo.iCdmaSID = curNetnfo.iCdmaSID;
       
  1667 	aNetInfo.iAnalogSID = curNetnfo.iAnalogSID;
       
  1668 	aNetInfo.iNetworkId = curNetnfo.iNetworkId;
       
  1669 	aNetInfo.iDisplayTag = curNetnfo.iDisplayTag;
       
  1670 	aNetInfo.iShortName = curNetnfo.iShortName;
       
  1671 	aNetInfo.iLongName = curNetnfo.iLongName;
       
  1672 	}
       
  1673 	
       
  1674 void CSimNetworkStatus::PopulateEtel3rdPartyNetworkInfoV1(TInt aIndex,RMobilePhone::TEtel3rdPartyMobileNetworkInfoV1& aNetInfo)
       
  1675 /**
       
  1676  * A helper function to copy network information structures.
       
  1677  */
       
  1678 	{
       
  1679 	RMobilePhone::TMobilePhoneNetworkInfoV2& curNetnfo=iNetworkInfo->At(aIndex);	
       
  1680 	aNetInfo.iMode = curNetnfo.iMode;
       
  1681 	aNetInfo.iStatus = curNetnfo.iStatus;
       
  1682 	aNetInfo.iBandInfo = curNetnfo.iBandInfo;
       
  1683 	aNetInfo.iCountryCode = curNetnfo.iCountryCode;
       
  1684 	//aNetInfo.iCdmaSID = curNetnfo.iCdmaSID;
       
  1685 	aNetInfo.iNetworkId = curNetnfo.iNetworkId;
       
  1686 	aNetInfo.iDisplayTag = curNetnfo.iDisplayTag;
       
  1687 	aNetInfo.iShortName = curNetnfo.iShortName;
       
  1688 	aNetInfo.iLongName = curNetnfo.iLongName;
       
  1689 	aNetInfo.iAccess = curNetnfo.iAccess;
       
  1690 	}
       
  1691 
       
  1692 RMobilePhone::TMobilePhoneNetworkStatus CSimNetworkStatus::NetWorkStatus()
       
  1693 /**
       
  1694 * A helper function that returns the network status;
       
  1695 */
       
  1696 	{
       
  1697 	if(!iNetworkInfo || (iCurrentNetworkIndex==KErrNotFound))
       
  1698 		{
       
  1699 		return RMobilePhone::ENetworkStatusUnknown;
       
  1700 		}
       
  1701 	return iNetworkInfo->At(iCurrentNetworkIndex).iStatus;
       
  1702 	}
       
  1703 
       
  1704 void CSimNetworkStatus::PopulateNitzNetworkNames(RMobilePhone::TMobilePhoneNITZ& aNitz)
       
  1705 /**
       
  1706  * A helper function to populate the long and short network name fields in the NITZ
       
  1707  * data structures.  These are taken from the current network settings.  If no network
       
  1708  * name information is available this is indicated in the "NITZ fields used" structure.
       
  1709  * @param aNitz		The NITZ data structure which must be populated with network name
       
  1710  *					information.
       
  1711  */
       
  1712 	{
       
  1713 	if((iNetworkInfo->Count()>0)&&(iRegStatusInfo->Count()>0))
       
  1714 		{
       
  1715 		if(iCurrentNetworkIndex>=0)
       
  1716 			{
       
  1717 			aNitz.iShortNetworkId.Copy(iNetworkInfo->At(iCurrentNetworkIndex).iShortName);
       
  1718 			aNitz.iLongNetworkId.Copy(iNetworkInfo->At(iCurrentNetworkIndex).iLongName);
       
  1719 			aNitz.iNitzFieldsUsed|=	(RMobilePhone::KCapsShortNameAvailable
       
  1720 									|RMobilePhone::KCapsLongNameAvailable);
       
  1721 			}
       
  1722 		}
       
  1723 	}
       
  1724 
       
  1725 TInt CSimNetworkStatus::GetCurrentServiceProvider(TTsyReqHandle aReqHandle,TDes8* aPckg)
       
  1726 /**
       
  1727  * Completes the request to get the current service provider name
       
  1728  */
       
  1729 	{
       
  1730 	RMobilePhone::TMobilePhoneServiceProviderNameV2Pckg* currentSPPckg=(RMobilePhone::TMobilePhoneServiceProviderNameV2Pckg*)aPckg;
       
  1731 	RMobilePhone::TMobilePhoneServiceProviderNameV2& currenSP=(*currentSPPckg)();
       
  1732 
       
  1733 	// Check that the data structure is supported by the simulated TSY version
       
  1734 	TInt err = iPhone->CheckSimTsyVersion(currenSP);
       
  1735 	if(err != KErrNone)
       
  1736 		{
       
  1737 		iPhone->ReqCompleted(aReqHandle, err);
       
  1738 		return KErrNone;
       
  1739 		}
       
  1740 	
       
  1741 	currenSP = iServiceProvider;
       
  1742 	
       
  1743 	iPhone->ReqCompleted(aReqHandle,KErrNone);
       
  1744 	return KErrNone;
       
  1745 	}
       
  1746 	
       
  1747 TInt CSimNetworkStatus::GetCurrentNetworkName(TTsyReqHandle aReqHandle,TDes8* aNetworkName, TDes8* aLocInfo)
       
  1748 /**
       
  1749  * Completes request to get current network name.
       
  1750  */
       
  1751 	{
       
  1752 	if(iRegStatusInfo->Count()==0)
       
  1753 		{
       
  1754 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);
       
  1755 		return KErrNone;
       
  1756 		}
       
  1757 	
       
  1758 	if(iCurrentNetworkIndex==KErrNotFound)
       
  1759 		{
       
  1760 		iPhone->ReqCompleted(aReqHandle,KErrNotFound);
       
  1761 		return KErrNone;
       
  1762 		}
       
  1763 	
       
  1764 	RMobilePhone::TMobilePhoneNetworkNameV3Pckg* networknamePckg=REINTERPRET_CAST(RMobilePhone::TMobilePhoneNetworkNameV3Pckg*, aNetworkName);
       
  1765 	RMobilePhone::TMobilePhoneNetworkNameV3& networkname=(*networknamePckg)();
       
  1766 
       
  1767 	// Check that the data structure is supported by the simulated TSY version
       
  1768 	TInt err = iPhone->CheckSimTsyVersion(networkname);
       
  1769 	if(err != KErrNone)
       
  1770 		{
       
  1771 		iPhone->ReqCompleted(aReqHandle, err);
       
  1772 		return KErrNone;
       
  1773 		}
       
  1774 	
       
  1775 	RMobilePhone::TMobilePhoneOPlmnV3Pckg* locInfoPckg=REINTERPRET_CAST(RMobilePhone::TMobilePhoneOPlmnV3Pckg*, aLocInfo);
       
  1776 	RMobilePhone::TMobilePhoneOPlmnV3& locInfo=(*locInfoPckg)();
       
  1777 
       
  1778 	// Check that the data structure is supported by the simulated TSY version
       
  1779 	err = iPhone->CheckSimTsyVersion(locInfo);
       
  1780 	if(err != KErrNone)
       
  1781 		{
       
  1782 		iPhone->ReqCompleted(aReqHandle, err);
       
  1783 		return KErrNone;
       
  1784 		}
       
  1785 	
       
  1786 	//use the current network info to populate the current networkname details.
       
  1787 	RMobilePhone::TMobilePhoneNetworkInfoV1& currentNetwork = reinterpret_cast<RMobilePhone::TMobilePhoneNetworkInfoV1&>(iNetworkInfo->At(iCurrentNetworkIndex));
       
  1788 
       
  1789 	// Check that the data structure is supported by the simulated TSY version
       
  1790 	err = iPhone->CheckSimTsyVersion(currentNetwork);
       
  1791 	if(err != KErrNone)
       
  1792 		{
       
  1793 		iPhone->ReqCompleted(aReqHandle, err);
       
  1794 		return KErrNone;
       
  1795 		}
       
  1796 
       
  1797 	
       
  1798 	networkname.iLongName.Copy(currentNetwork.iLongName);
       
  1799 	networkname.iShortName.Copy(currentNetwork.iShortName);
       
  1800 	networkname.iOtherNames.Zero();
       
  1801 	
       
  1802 	locInfo.iCountryCode = currentNetwork.iCountryCode;
       
  1803 	locInfo.iFirstLocationAreaCode = KFirstLACDefault;
       
  1804 	locInfo.iLastLocationAreaCode = KLastLACDefault;
       
  1805 	locInfo.iNetworkId = currentNetwork.iNetworkId;
       
  1806 	locInfo.iPNNid = 0;	//set to 0 so that it does not require a lookup in the TMobilePhoneOPlmnV3.iOtherNames field for display name - which is emtpy.
       
  1807 	
       
  1808 	iPhone->ReqCompleted(aReqHandle,KErrNone);
       
  1809 		
       
  1810 	return KErrNone;	
       
  1811 	}
       
  1812 const CTestConfigSection* CSimNetworkStatus::CfgFile()
       
  1813 /**
       
  1814  * Returns a pointer to the current configuration file section.
       
  1815  *
       
  1816  * @return CTestConfigSection	A pointer to the current configuration file data section.
       
  1817  */
       
  1818 	{
       
  1819 	return iPhone->CfgFile();
       
  1820 	}
       
  1821 
       
  1822 void CSimNetworkStatus::PubSubCallback(TInt aRegStat)
       
  1823 /**
       
  1824  * Called by CSimNetStatChange when a network registration status change request has been received.
       
  1825  *
       
  1826  * @param aNewVal The new network registration value (number of bars)
       
  1827  */
       
  1828 	{
       
  1829 	if (iCurrentRegStatus == aRegStat)
       
  1830 		{
       
  1831 		return;
       
  1832 		}
       
  1833 
       
  1834 	iCurrentRegStatus = aRegStat;
       
  1835 	
       
  1836 	// Ask phone to check if indicator notification needs to be triggered
       
  1837 	iPhone->CheckIndicatorNotification();
       
  1838 
       
  1839 	if(iRegStatChangeNotificationPending)
       
  1840 		{
       
  1841 		iRegStatChangeNotificationPending=EFalse;
       
  1842 		*iRegStatChangeNotificationRegStatus=(RMobilePhone::TMobilePhoneRegistrationStatus)iCurrentRegStatus;
       
  1843 		iPhone->ReqCompleted(iRegStatChangeNotificationReqHandle,KErrNone);
       
  1844 		}
       
  1845 	}
       
  1846 
       
  1847 TInt CSimNetworkStatus::GetCellInfo(TTsyReqHandle aReqHandle,TDes8* aPckg)
       
  1848 /**
       
  1849  * Retrieve the current Cell information.
       
  1850  * It will be updated from CellInfo tags in the configuration file.  If no cell
       
  1851  * information is contained in the configuration file KErrNotSupported
       
  1852  * will be returned.
       
  1853  * @param aReqHandle	The request handle associated with this request.
       
  1854  * @param aPckg			The first parameter package.  This will be populated with the
       
  1855  *						cell information to be returned.
       
  1856  * @return TInt			Standard error value.
       
  1857  */
       
  1858 	{
       
  1859 	TPckg<RMobilePhone::TMobilePhoneCellInfoV9>* cellInfoPckg=(TPckg<RMobilePhone::TMobilePhoneCellInfoV9>*)aPckg;
       
  1860 	RMobilePhone::TMobilePhoneCellInfoV9& cellInfo=(*cellInfoPckg)();
       
  1861 
       
  1862 	if(iCellInfo->Count()==0)
       
  1863 		{
       
  1864 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);
       
  1865 		return KErrNone;
       
  1866 		}
       
  1867 
       
  1868 	cellInfo=iCurrentCellInfo;
       
  1869 	iPhone->ReqCompleted(aReqHandle,KErrNone);
       
  1870 	return KErrNone;
       
  1871 	}
       
  1872 
       
  1873 TInt CSimNetworkStatus::NotifyCellInfoChange(TTsyReqHandle aReqHandle,TDes8* aPckg)
       
  1874 /**
       
  1875  * Register a client's interest in being notified when cell information is received.
       
  1876  * This function records the request's parameters and awaits a cell information event, as
       
  1877  * scheduled by the "CellInfo" tags in the configuration file.
       
  1878  *
       
  1879  * @param aPckg			The first parameter package.  This is populated with the cell
       
  1880  *						information when the request completes.
       
  1881  * @return TInt			Standard error value.
       
  1882  */
       
  1883 	{
       
  1884 	TPckg<RMobilePhone::TMobilePhoneCellInfoV9>* cellInfoPckg=(TPckg<RMobilePhone::TMobilePhoneCellInfoV9>*)aPckg;
       
  1885 	RMobilePhone::TMobilePhoneCellInfoV9& cellInfo=(*cellInfoPckg)();
       
  1886 
       
  1887 	if(iCellInfo->Count()==0)
       
  1888 		{
       
  1889 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);
       
  1890 		return KErrNone;
       
  1891 		}
       
  1892 
       
  1893 	iCellInfoChangeNotificationPending=ETrue;
       
  1894 	iCellInfoChangeNotificationReqHandle=aReqHandle;
       
  1895 	iCellInfoChangeNotificationInfo=&cellInfo;
       
  1896 	return KErrNone;
       
  1897 	}
       
  1898 
       
  1899 void CSimNetworkStatus::NotifyCellInfoChangeCancel(TTsyReqHandle aTsyReqHandle)
       
  1900 /**
       
  1901  * Cancel a previous request to be notified of new cell informations.
       
  1902  * @param aTsyReqHandle request handle
       
  1903  */
       
  1904 	{
       
  1905 	if((iCellInfoChangeNotificationPending) && (aTsyReqHandle == iCellInfoChangeNotificationReqHandle))
       
  1906 		{
       
  1907 		iCellInfoChangeNotificationPending=EFalse;
       
  1908 		iPhone->ReqCompleted(aTsyReqHandle,KErrCancel);
       
  1909 		}
       
  1910 	}
       
  1911 
       
  1912 void CSimNetworkStatus::TimerCallBackCellInfo()
       
  1913 /**
       
  1914  * The CellInfo timer callback function.  This function will be called when the cell info timer
       
  1915  * completes.  It indicates a simulated new cell info information event. So, the new
       
  1916  * cell info settings must be loaded into the relevant cell info member variables and any
       
  1917  * pending cell info notification requests must be completed.
       
  1918  * Finally, the next cell info timer is started.
       
  1919  */
       
  1920 	{
       
  1921 	iCellInfoIndex++;
       
  1922 	if(iCellInfo->Count()<=iCellInfoIndex)
       
  1923 		return;
       
  1924 	
       
  1925 	iCurrentCellInfo=iCellInfo->At(iCellInfoIndex).iInfo;
       
  1926 
       
  1927 	if(iCellInfoChangeNotificationPending)
       
  1928 		{
       
  1929 		iCellInfoChangeNotificationPending=EFalse;
       
  1930 		*iCellInfoChangeNotificationInfo=iCurrentCellInfo;
       
  1931 		iPhone->ReqCompleted(iCellInfoChangeNotificationReqHandle,KErrNone);
       
  1932 		}
       
  1933 
       
  1934 	iCellInfoTimer->Start(iCellInfo->At(iCellInfoIndex).iDuration,this,ETimerIdCellInfo);
       
  1935 	}