telephonyserverplugins/simtsy/src/CSimUsimR6.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
child 42 3adadc800673
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This file contains the implementation for the Simulator USIM R6 class 'CSimUsimR6'
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20 */
       
    21 
       
    22 #include <e32property.h>
       
    23 #include <testconfigfileparser.h>
       
    24 #include <sacls.h>
       
    25 #include <e32math.h>
       
    26 #include "CSimPhone.h"
       
    27 #include "Simlog.h"
       
    28 #include "CSimPubSubChange.h"
       
    29 #include "CSimTsyMode.h"
       
    30 #include <etelmmerr.h>
       
    31 #include "CSimPubSub.h"
       
    32 #include "SimTsy.h"
       
    33 #include "simtsyglobalproperties.h"
       
    34 #include "CSimUsimR6.h"
       
    35 #include <et_phone.h>
       
    36 
       
    37 const TInt KUsimGranularity=2;		// < Granularity for USIM list array
       
    38 const TInt KUsimRel6DurationTimeoutDefault=1;
       
    39 const TInt KUsimRel6DurationTimeoutDefault1=2;
       
    40 const TInt KUsimRel6DurationTimeoutDefault2=3;
       
    41 
       
    42 CSimUsimR6* CSimUsimR6::NewL(CSimPhone* aPhone)
       
    43 /**
       
    44  * Standard two-phase constructor.
       
    45  * @param aPhone				The parent phone object.
       
    46  * @return CSimUsimR6	The new network status class.
       
    47  */
       
    48 	{
       
    49 	CSimUsimR6* self=new(ELeave) CSimUsimR6(aPhone);
       
    50 	CleanupStack::PushL(self);
       
    51 	self->ConstructL();
       
    52 	CleanupStack::Pop();
       
    53 	return self;
       
    54 	}
       
    55 
       
    56 CSimUsimR6::CSimUsimR6(CSimPhone* aPhone)
       
    57 : iPhone(aPhone)
       
    58 /**
       
    59 * Trivial first phase construction.
       
    60 * @param aPhone				The parent phone object.
       
    61 */
       
    62 	{
       
    63 	iMailBoxNumberChangePending = EFalse;
       
    64 	iIccMessageWaitingPending = EFalse;
       
    65 	iMessageWaitingPending = EFalse;
       
    66 	iMailBoxNumberChangePendingV8 = EFalse;
       
    67 	iIccMessageWaitingPendingV8 = EFalse;
       
    68 	iNotifyWlanDataChangePending=EFalse;
       
    69 	iNotifyPreferredWlanSIDListChangePending= EFalse;
       
    70 	}
       
    71 
       
    72 void CSimUsimR6::ConstructL()
       
    73 /**
       
    74  * Second phase construction. Create instances of the necessary heap-based objects and read the necessary Release6  information
       
    75  * from the configuration file. The config file informations simulates the information given by Network
       
    76  *
       
    77  * 
       
    78  */
       
    79 	{
       
    80 	LOGMISC1("CSimUsimR6: Entered ConstructL()");
       
    81 	iVoiceMailIds=new(ELeave) CArrayFixFlat<RMobilePhone::TMobilePhoneVoicemailIdsV8>(KUsimGranularity);
       
    82 	iMessageWaiting=new(ELeave) CArrayFixFlat<RMobilePhone::TMobilePhoneMessageWaitingV8>(KUsimGranularity);
       
    83 	
       
    84 	iWlanData=new(ELeave) CArrayFixFlat<RMobilePhone::TUsimWlanDataV8>(KUsimGranularity);
       
    85 	iWlanSid=new(ELeave) CArrayFixFlat<RMobilePhone::TWlanSIDV8>(KUsimGranularity);	
       
    86 	iPreferredNetworks=new(ELeave) CArrayFixFlat<RMobilePhone::TMobilePreferredNetworkEntryV3>(KUsimGranularity);
       
    87 	
       
    88 	iGBAAuthInfoList =new(ELeave) CArrayFixFlat<TGBAAuthInfo>(KUsimGranularity);
       
    89 	iMBMSInfoList = new(ELeave) CArrayFixFlat<TMBMSInfo>(KUsimGranularity);
       
    90 
       
    91 	iGbaNafList = CMobilePhoneGbaNafIdList::NewL();
       
    92 	iMbmsMskList = CMobilePhoneMbmsMskIdList::NewL();
       
    93 	
       
    94 	iTimer = CSimTimer::NewL(iPhone);
       
    95 	iWlanTimer = CSimTimer::NewL(iPhone);
       
    96 	iNotifyAuthTimer = CSimTimer::NewL(iPhone);
       
    97 	
       
    98 	iAuthListInfo = new(ELeave)CArrayPtrFlat<CListReadAllAttempt>(1);
       
    99 	iGetWlanSIDsData = new(ELeave) CArrayPtrFlat<CListReadAllAttempt>(1);
       
   100 	iGetPreferredNetworks = new(ELeave) CArrayPtrFlat<CListReadAllAttempt>(1);
       
   101 
       
   102 	iCurrentNotifyMailboxIndex=0;
       
   103 	iCurrentIccMessageWaitingIndex=0;
       
   104 	iCurrentMessageWaitingIndex=0;
       
   105 	iGetIccMsgIdCurrentIndex=0;
       
   106 	iSetIccMsgIdCurrentIndex=0;
       
   107 	iNotifyWlanDataChangeIndex=0;
       
   108 	iNotifyPreferredWlanSIDListChangeIndex=0;
       
   109 	iNotifyPreferredNetworksChangeIndex=0;
       
   110 	iMailBoxIndex=0;			
       
   111 	iIndex=0;
       
   112 	
       
   113 	TInt count;
       
   114 	count=CfgFile()->ItemCount(KUsimMailBoxIdInfo);
       
   115 	CTestConfigItem* item=NULL;
       
   116 	TInt ret=KErrNone;
       
   117 
       
   118 	TInt i;
       
   119 	for(i=0;i<count;i++)
       
   120 		{
       
   121 		item=const_cast<CTestConfigItem*>(CfgFile()->Item(KUsimMailBoxIdInfo,i));
       
   122 		if(!item)
       
   123 			{
       
   124 			break;
       
   125 			}
       
   126 		TInt voice,data,fax,other,video;
       
   127 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,voice);
       
   128 		if(ret!=KErrNone)
       
   129 			{
       
   130 			LOGPARSERR("voice",ret,0,&KUsimMailBoxIdInfo);
       
   131 			continue;
       
   132 			}
       
   133 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,data);
       
   134 		if(ret!=KErrNone)
       
   135 			{
       
   136 			LOGPARSERR("data",ret,1,&KUsimMailBoxIdInfo);
       
   137 			continue;
       
   138 			}
       
   139 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,fax);
       
   140 		if(ret!=KErrNone)
       
   141 			{
       
   142 			LOGPARSERR("fax",ret,2,&KUsimMailBoxIdInfo);
       
   143 			continue;
       
   144 			}
       
   145 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,other);
       
   146 		if(ret!=KErrNone)
       
   147 			{
       
   148 			LOGPARSERR("other",ret,3,&KUsimMailBoxIdInfo);
       
   149 			continue;
       
   150 			}
       
   151 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,4,video);
       
   152 		if(ret!=KErrNone)
       
   153 			{
       
   154 			LOGPARSERR("video",ret,4,&KUsimMailBoxIdInfo);
       
   155 			continue;
       
   156 			}
       
   157 		RMobilePhone::TMobilePhoneVoicemailIdsV8 mailboxIdInfo;
       
   158 		mailboxIdInfo.iVoice=voice;
       
   159 		mailboxIdInfo.iData=data;
       
   160 		mailboxIdInfo.iFax=fax;
       
   161 		mailboxIdInfo.iOther=other;
       
   162 		mailboxIdInfo.iVideo=video;	
       
   163 		iVoiceMailIds->AppendL(mailboxIdInfo);
       
   164 		}
       
   165 	count=CfgFile()->ItemCount(KUsimMessageWaitingIdInfo);
       
   166 	item=NULL;
       
   167 	for(i=0;i<count;i++)
       
   168 		{
       
   169 		item=const_cast<CTestConfigItem*>(CfgFile()->Item(KUsimMessageWaitingIdInfo,i));
       
   170 		if(!item)
       
   171 			{
       
   172 			break;
       
   173 			}
       
   174 		TInt displayStatus,voiceMsgs,auxVoiceMsgs,dataMsgs,faxMsgs,emailMsgs,otherMsgs,videoMsgs;
       
   175 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,displayStatus);
       
   176 		if(ret!=KErrNone)
       
   177 			{
       
   178 			LOGPARSERR("displayStatus",ret,0,&KUsimMessageWaitingIdInfo);
       
   179 			continue;
       
   180 			}
       
   181 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,voiceMsgs);
       
   182 		if(ret!=KErrNone)
       
   183 			{
       
   184 			LOGPARSERR("voiceMsgs",ret,1,&KUsimMessageWaitingIdInfo);
       
   185 			continue;
       
   186 			}
       
   187 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,auxVoiceMsgs);
       
   188 		if(ret!=KErrNone)
       
   189 			{
       
   190 			LOGPARSERR("auxVoiceMsgs",ret,2,&KUsimMessageWaitingIdInfo);
       
   191 			continue;
       
   192 			}
       
   193 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,dataMsgs);
       
   194 		if(ret!=KErrNone)
       
   195 			{
       
   196 			LOGPARSERR("dataMsgs",ret,3,&KUsimMessageWaitingIdInfo);
       
   197 			continue;
       
   198 			}
       
   199 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,4,faxMsgs);
       
   200 		if(ret!=KErrNone)
       
   201 			{
       
   202 			LOGPARSERR("faxMsgs",ret,4,&KUsimMessageWaitingIdInfo);
       
   203 			continue;
       
   204 			}
       
   205 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,5,emailMsgs);
       
   206 		if(ret!=KErrNone)
       
   207 			{
       
   208 			LOGPARSERR("emailMsgs",ret,5,&KUsimMessageWaitingIdInfo);
       
   209 			continue;
       
   210 			}
       
   211 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,6,otherMsgs);
       
   212 		if(ret!=KErrNone)
       
   213 			{
       
   214 			LOGPARSERR("otherMsgs",ret,6,&KUsimMessageWaitingIdInfo);
       
   215 			continue;
       
   216 			}
       
   217 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,7,videoMsgs);
       
   218 		if(ret!=KErrNone)
       
   219 			{
       
   220 			LOGPARSERR("longName",ret,7,&KUsimMessageWaitingIdInfo);
       
   221 			continue;
       
   222 			}
       
   223 		RMobilePhone::TMobilePhoneMessageWaitingV8 messageWaiting;
       
   224 		messageWaiting.iDisplayStatus = RMobilePhone::TMobilePhoneIndicatorDisplay(displayStatus);
       
   225 		messageWaiting.iVoiceMsgs = voiceMsgs;
       
   226 		messageWaiting.iAuxVoiceMsgs = auxVoiceMsgs;
       
   227 		messageWaiting.iDataMsgs = dataMsgs;
       
   228 		messageWaiting.iFaxMsgs = faxMsgs;
       
   229 		messageWaiting.iEmailMsgs = emailMsgs;
       
   230 		messageWaiting.iOtherMsgs = otherMsgs;
       
   231 		messageWaiting.iVideoMsgs = videoMsgs;
       
   232 		iMessageWaiting->AppendL(messageWaiting);
       
   233 		}
       
   234 	count=CfgFile()->ItemCount(KUsimWlanDataInfo);
       
   235 	item=NULL;
       
   236 	TUint16 digit=0;
       
   237 	RMobilePhone::TUsimWlanDataV8 wlanData;
       
   238 	for(i=0;i<count;i++)
       
   239 		{
       
   240 		item=const_cast<CTestConfigItem*>(CfgFile()->Item(KUsimWlanDataInfo,i));
       
   241 		if(!item)
       
   242 			{
       
   243 			break;
       
   244 			}
       
   245 		TPtrC8 FieldsUsed,Pseudonym,ReauthenticationId,MasterKey,Counter;
       
   246 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,FieldsUsed);
       
   247 		if(ret!=KErrNone)
       
   248 			{
       
   249 			LOGPARSERR("Fields Used",ret,0,&KUsimWlanDataInfo);
       
   250 			continue;
       
   251 			}
       
   252 		else 
       
   253 			{
       
   254 			if(AsciiToNum(FieldsUsed, digit)==KErrNone)
       
   255 				{
       
   256 				wlanData.iFieldsUsed=digit;
       
   257 				}
       
   258 			}
       
   259 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,Pseudonym);
       
   260 		if(ret!=KErrNone)
       
   261 			{
       
   262 			LOGPARSERR("Pseudonym",ret,1,&KUsimWlanDataInfo);
       
   263 			continue;
       
   264 			}
       
   265 		else
       
   266 			{
       
   267 			wlanData.iPseudonym.Copy(Pseudonym);
       
   268 			}
       
   269 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,ReauthenticationId);
       
   270 		if(ret!=KErrNone)
       
   271 			{
       
   272 			LOGPARSERR("ReauthenticationId",ret,2,&KUsimWlanDataInfo);
       
   273 			continue;
       
   274 			}
       
   275 		else
       
   276 			{
       
   277 			wlanData.iReauthenticationId.Copy(ReauthenticationId);
       
   278 			}
       
   279 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,MasterKey);
       
   280 		if(ret!=KErrNone)
       
   281 			{
       
   282 			LOGPARSERR("MasterKey",ret,3,&KUsimWlanDataInfo);
       
   283 			continue;
       
   284 			}
       
   285 		else
       
   286 			{
       
   287 			wlanData.iMasterKey.Copy(MasterKey);
       
   288 			}
       
   289 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,4,Counter);
       
   290 		if(ret!=KErrNone)
       
   291 			{
       
   292 			LOGPARSERR("Counter",ret,4,&KUsimWlanDataInfo);
       
   293 			continue;
       
   294 			}
       
   295 		else
       
   296 			{
       
   297 			wlanData.iCounter.Copy(Counter);
       
   298 			}
       
   299 		iWlanData->AppendL(wlanData);
       
   300 		}
       
   301 	count=CfgFile()->ItemCount(KUsimWlanSidInfo);
       
   302 	item=NULL;
       
   303 	RMobilePhone::TWlanSIDV8 wlanSid;
       
   304 	for(i=0;i<count;i++)
       
   305 		{
       
   306 		item=const_cast<CTestConfigItem*>(CfgFile()->Item(KUsimWlanSidInfo,i));
       
   307 		if(!item)
       
   308 			{
       
   309 			break;
       
   310 			}
       
   311 		TPtrC8 wlanSidBuf;
       
   312 		TInt userDef;
       
   313 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,wlanSidBuf);
       
   314 		if(ret!=KErrNone)
       
   315 			{
       
   316 			LOGPARSERR("Wlan Sid Buffer",ret,0,&KUsimWlanSidInfo);
       
   317 			continue;
       
   318 			}
       
   319 		else 
       
   320 			{
       
   321 			wlanSid.iWSID.Copy(wlanSidBuf);
       
   322 			}
       
   323 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,userDef);
       
   324 		if(ret!=KErrNone)
       
   325 			{
       
   326 			LOGPARSERR("User Defined",ret,1,&KUsimWlanSidInfo);
       
   327 			continue;
       
   328 			}
       
   329 		else
       
   330 			{
       
   331 			wlanSid.iUserDefined=userDef;
       
   332 			}
       
   333 		iWlanSid->AppendL(wlanSid);
       
   334 		}
       
   335 	count=CfgFile()->ItemCount(KUsimPreferredNetworksInfo);
       
   336 	item=NULL;
       
   337 	RMobilePhone::TMobilePreferredNetworkEntryV3 networkEntry;
       
   338 	for(i=0;i<count;i++)
       
   339 		{
       
   340 		item=const_cast<CTestConfigItem*>(CfgFile()->Item(KUsimPreferredNetworksInfo,i));
       
   341 		if(!item)
       
   342 			{
       
   343 			break;
       
   344 			}
       
   345 		TPtrC8 accessId,countryCode,networkId;
       
   346 		TInt userDef;
       
   347 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,accessId);
       
   348 		if(ret!=KErrNone)
       
   349 			{
       
   350 			LOGPARSERR("Access Id",ret,0,&KUsimPreferredNetworksInfo);
       
   351 			continue;
       
   352 			}
       
   353 		else 
       
   354 			{
       
   355 			if(AsciiToNum(accessId, digit)==KErrNone)
       
   356 				{
       
   357 				networkEntry.iAccess=digit;
       
   358 				}
       
   359 			}
       
   360 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,userDef);
       
   361 		if(ret!=KErrNone)
       
   362 			{
       
   363 			LOGPARSERR("User Defined",ret,1,&KUsimPreferredNetworksInfo);
       
   364 			continue;
       
   365 			}
       
   366 		else
       
   367 			{
       
   368 			networkEntry.iUserDefined=userDef;
       
   369 			}
       
   370 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,countryCode);
       
   371 		if(ret!=KErrNone)
       
   372 			{
       
   373 			LOGPARSERR("Country Code",ret,1,&KUsimPreferredNetworksInfo);
       
   374 			continue;
       
   375 			}
       
   376 		else
       
   377 			{
       
   378 			networkEntry.iCountryCode.Copy(countryCode);
       
   379 			}
       
   380 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,networkId);
       
   381 		if(ret!=KErrNone)
       
   382 			{
       
   383 			LOGPARSERR("Network Id",ret,1,&KUsimPreferredNetworksInfo);
       
   384 			continue;
       
   385 			}
       
   386 		else
       
   387 			{
       
   388 			networkEntry.iNetworkId.Copy(networkId);
       
   389 			}
       
   390 		
       
   391 		iPreferredNetworks->AppendL(networkEntry);
       
   392 		}	
       
   393 	LOGPHONE1("Starting to Parse GBA Authentication Info");
       
   394 	count = CfgFile()->ItemCount(KGBAAuthInfo);
       
   395 	TGBAAuthInfo authInfo;
       
   396 
       
   397 	TInt index;
       
   398 	for(index = 0; index < count; index++)
       
   399 		{
       
   400 		item = const_cast<CTestConfigItem*>(CfgFile()->Item(KGBAAuthInfo, index));
       
   401 		if(item == NULL)
       
   402 			{
       
   403 			break;
       
   404 			}
       
   405 		CleanupStack::PushL(item);
       
   406 		TInt ret = KErrNone, authErr = KErrNone;
       
   407 		TPtrC8 AUTN, RAND, appId, RES, AUTS, NAFID,IMPI, KSExtNaf, BtID, KeyLifeTime ;
       
   408 		TBool OtherApplnBusy, applnActive;
       
   409 
       
   410 		//Get the AUTN
       
   411 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, AUTN);
       
   412 		if(ret != KErrNone)
       
   413 			{
       
   414 			LOGPARSERR("AUTN",ret,0,&KGBAAuthInfo);
       
   415 			continue;
       
   416 			}
       
   417 		else
       
   418 			{
       
   419 			authInfo.iAUTN.Copy(AUTN);
       
   420 			}
       
   421 		//Get the RAND
       
   422 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 1, RAND);
       
   423 		if(ret != KErrNone)
       
   424 			{
       
   425 			LOGPARSERR("RAND",ret,1,&KGBAAuthInfo);
       
   426 			continue;
       
   427 			}
       
   428 		else
       
   429 			{
       
   430 			authInfo.iRAND.Copy(RAND);
       
   431 			}
       
   432 		//Get the APPID
       
   433 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 2, appId);
       
   434 		if(ret != KErrNone)
       
   435 			{
       
   436 			LOGPARSERR("APPID",ret,2,&KGBAAuthInfo);
       
   437 			continue;
       
   438 			}
       
   439 		else
       
   440 			{
       
   441 			authInfo.iAID.Copy(appId);
       
   442 			}
       
   443 		//Get the RES
       
   444 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 3, RES);
       
   445 		if(ret != KErrNone)
       
   446 			{
       
   447 			LOGPARSERR("RES",ret,3,&KGBAAuthInfo);
       
   448 			continue;
       
   449 			}
       
   450 		else
       
   451 			{
       
   452 			authInfo.iRES.Copy(RES);
       
   453 			}
       
   454 		//Get the AUTS
       
   455 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 4, AUTS);
       
   456 		if(ret != KErrNone)
       
   457 			{
       
   458 			LOGPARSERR("AUTS",ret,4,&KGBAAuthInfo);
       
   459 			continue;
       
   460 			}
       
   461 		else
       
   462 			{
       
   463 			authInfo.iAUTS.Copy(AUTS);
       
   464 			}
       
   465 		//Get the NAFID
       
   466 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 5, NAFID);
       
   467 		if(ret != KErrNone)
       
   468 			{
       
   469 			LOGPARSERR("NAFID",ret,5,&KGBAAuthInfo);
       
   470 			continue;
       
   471 			}
       
   472 		else
       
   473 			{
       
   474 			authInfo.iNAFID.Copy(NAFID);
       
   475 			}
       
   476 		//Get the IMPI
       
   477 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 6, IMPI);
       
   478 		if(ret != KErrNone)
       
   479 			{
       
   480 			LOGPARSERR("IMPI",ret,6,&KGBAAuthInfo);
       
   481 			continue;
       
   482 			}
       
   483 		else
       
   484 			{
       
   485 			authInfo.iIMPI.Copy(IMPI);
       
   486 			}
       
   487 		//Get the KsExtNaf
       
   488 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 7, KSExtNaf);
       
   489 		if(ret != KErrNone)
       
   490 			{
       
   491 			LOGPARSERR("KSExtNaf",ret,7,&KGBAAuthInfo);
       
   492 			continue;
       
   493 			}
       
   494 		else
       
   495 			{
       
   496 			authInfo.iKsExtNaf.Copy(KSExtNaf);
       
   497 			}
       
   498 		//Get the BtID
       
   499 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 8, BtID);
       
   500 		if(ret != KErrNone)
       
   501 			{
       
   502 			LOGPARSERR("BtID",ret,8,&KGBAAuthInfo);
       
   503 			continue;
       
   504 			}
       
   505 		else
       
   506 			{
       
   507 			authInfo.iBtid.Copy(BtID);
       
   508 			}
       
   509 		//Get the KeyLifeTime
       
   510 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 9, KeyLifeTime);
       
   511 		if(ret != KErrNone)
       
   512 			{
       
   513 			LOGPARSERR("KeyLifeTime",ret,9,&KGBAAuthInfo);
       
   514 			continue;
       
   515 			}
       
   516 		else
       
   517 			{
       
   518 			authInfo.iKeyLifeTime.Copy(KeyLifeTime);
       
   519 			}
       
   520 		//Get the OtherApplnBusy
       
   521 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 10, OtherApplnBusy);
       
   522 		if(ret != KErrNone)
       
   523 			{
       
   524 			LOGPARSERR("OtherApplnBusy",ret,10,&KGBAAuthInfo);
       
   525 			continue;
       
   526 			}
       
   527 		else
       
   528 			{
       
   529 			authInfo.iOtherAppBusy = OtherApplnBusy;
       
   530 			}
       
   531 		//Get the CurrentApplnActive
       
   532 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 11, applnActive);
       
   533 		if(ret != KErrNone)
       
   534 			{
       
   535 			LOGPARSERR("applnActive",ret,11,&KGBAAuthInfo);
       
   536 			continue;
       
   537 			}
       
   538 		else
       
   539 			{
       
   540 			authInfo.iAppActive = applnActive;
       
   541 			}
       
   542 		//Get authentication error
       
   543 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 12, authErr);
       
   544 		if(ret != KErrNone)
       
   545 			{
       
   546 			LOGPARSERR("authErr",ret,12,&KGBAAuthInfo);
       
   547 			continue;
       
   548 			}
       
   549 		else
       
   550 			{
       
   551 			authInfo.iAuthErr = authErr;
       
   552 			}
       
   553 		iGBAAuthInfoList->AppendL(authInfo);
       
   554 		CleanupStack::Pop(item);
       
   555 		} // end FOR Loop
       
   556 	LOGPHONE1("Starting to Parse GBA 2 Phase Retrieval list information");
       
   557 	count = CfgFile()->ItemCount(KGBAListInfo);
       
   558 	RMobilePhone::TGbaNafEntryV8 entry;
       
   559 	for(index = 0; index < count; index++)
       
   560 		{
       
   561 		item = const_cast<CTestConfigItem*>(CfgFile()->Item(KGBAListInfo, index));
       
   562 		if(item == NULL)
       
   563 			{
       
   564 			break;
       
   565 			}
       
   566 		CleanupStack::PushL(item);
       
   567 		TInt ret = KErrNone;
       
   568 		TPtrC8 NafId, Btid;
       
   569 		
       
   570 		//Get the NafID
       
   571 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, NafId);
       
   572 		if(ret != KErrNone)
       
   573 			{
       
   574 			LOGPARSERR("NafID",ret,0,&KGBAListInfo);
       
   575 			continue;
       
   576 			}
       
   577 		else
       
   578 			{
       
   579 			entry.iNafId.Copy(NafId);
       
   580 			}
       
   581 
       
   582 		//Get the Btid
       
   583 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 1, Btid);
       
   584 		if(ret != KErrNone)
       
   585 			{
       
   586 			LOGPARSERR("BTID",ret,1,&KGBAListInfo);
       
   587 			continue;
       
   588 			}
       
   589 		else
       
   590 			{
       
   591 			entry.iBtid.Copy(Btid);
       
   592 			}
       
   593 		
       
   594 		iGbaNafList->AddEntryL(entry);
       
   595 		CleanupStack::Pop(item);
       
   596 		}	
       
   597 	LOGPHONE1("Starting to Parse MBMS related config information");
       
   598 	count = CfgFile()->ItemCount(KMBMSInfo);
       
   599 	TMBMSInfo tMbmsInfo;
       
   600 	for(index = 0; index < count; index++)
       
   601 		{
       
   602 		item = const_cast<CTestConfigItem*>(CfgFile()->Item(KMBMSInfo, index));
       
   603 		if(item == NULL)
       
   604 			{
       
   605 			break;
       
   606 			}
       
   607 		CleanupStack::PushL(item);
       
   608 		
       
   609 		TInt ret = KErrNone;
       
   610 		TPtrC8 iMikey,oMikey,mtk,saltKey,keyDmn, MskIdgrp;
       
   611 		TPtrC8 MukId,MukIdi,MukIdr,MukTimeStamp,appId,KSIntNaf;
       
   612 		TBool applnActive;
       
   613 		TInt authErr;
       
   614 		
       
   615 		//Get the input Mikey
       
   616 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, iMikey);
       
   617 		if(ret != KErrNone)
       
   618 			{
       
   619 			LOGPARSERR("iMikey",ret,0,&KMBMSInfo);
       
   620 			continue;
       
   621 			}
       
   622 		else
       
   623 			{
       
   624 			tMbmsInfo.iInputMikey.Copy(iMikey);
       
   625 			}
       
   626 		
       
   627 		//Get the output Mikey
       
   628 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 1, oMikey);
       
   629 		if(ret != KErrNone)
       
   630 			{
       
   631 			LOGPARSERR("oMikey",ret,1,&KMBMSInfo);
       
   632 			continue;
       
   633 			}
       
   634 		else
       
   635 			{
       
   636 			tMbmsInfo.iOutputMikey.Copy(oMikey);
       
   637 			}
       
   638 
       
   639 		//Get the MTK
       
   640 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 2, mtk);
       
   641 		if(ret != KErrNone)
       
   642 			{
       
   643 			LOGPARSERR("MTK",ret,2,&KMBMSInfo);
       
   644 			continue;
       
   645 			}
       
   646 		else
       
   647 			{
       
   648 			tMbmsInfo.iMtk.Copy(mtk);
       
   649 			}
       
   650 
       
   651 		//Get the SaltKey
       
   652 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 3, saltKey);
       
   653 		if(ret != KErrNone)
       
   654 			{
       
   655 			LOGPARSERR("saltKey",ret,3,&KMBMSInfo);
       
   656 			continue;
       
   657 			}
       
   658 		else
       
   659 			{
       
   660 			tMbmsInfo.iSaltkey.Copy(saltKey);
       
   661 			}
       
   662 
       
   663 		//Get the KeyDomain
       
   664 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 4, keyDmn );
       
   665 		if(ret != KErrNone)
       
   666 			{
       
   667 			LOGPARSERR("keyDmn ",ret,4,&KMBMSInfo);
       
   668 			continue;
       
   669 			}
       
   670 		else
       
   671 			{
       
   672 			tMbmsInfo.iKeyDmn.Copy(keyDmn );
       
   673 			}
       
   674 
       
   675 		//Get the MskIdgrp
       
   676 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 5, MskIdgrp);
       
   677 		if(ret != KErrNone)
       
   678 			{
       
   679 			LOGPARSERR("MskIdgrp",ret,5,&KMBMSInfo);
       
   680 			continue;
       
   681 			}
       
   682 		else
       
   683 			{
       
   684 			tMbmsInfo.iMskIdGrp.Copy(MskIdgrp);
       
   685 			}
       
   686 
       
   687 		//Get the iMukid
       
   688 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 6, MukId );
       
   689 		if(ret != KErrNone)
       
   690 			{
       
   691 			LOGPARSERR("iMukIdTlv ",ret,6,&KMBMSInfo);
       
   692 			continue;
       
   693 			}
       
   694 		else
       
   695 			{
       
   696 			tMbmsInfo.iMukIdTlv.Copy(MukId );
       
   697 			}
       
   698 
       
   699 		//Get the MukIdi
       
   700 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 7, MukIdi);
       
   701 		if(ret != KErrNone)
       
   702 			{
       
   703 			LOGPARSERR("MukIdi",ret,7,&KMBMSInfo);
       
   704 			continue;
       
   705 			}
       
   706 		else
       
   707 			{
       
   708 			tMbmsInfo.iMukIdi.Copy(MukIdi);
       
   709 			}
       
   710 
       
   711 		//Get the MukIdr 
       
   712 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 8, MukIdr );
       
   713 		if(ret != KErrNone)
       
   714 			{
       
   715 			LOGPARSERR("MukIdr ",ret,8,&KMBMSInfo);
       
   716 			continue;
       
   717 			}
       
   718 		else
       
   719 			{
       
   720 			tMbmsInfo.iMukIdr.Copy(MukIdr );
       
   721 			}
       
   722 
       
   723 		//Get the MukTimeStamp
       
   724 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 9, MukTimeStamp );
       
   725 		if(ret != KErrNone)
       
   726 			{
       
   727 			LOGPARSERR("iMikey",ret,9,&KMBMSInfo);
       
   728 			continue;
       
   729 			}
       
   730 		else
       
   731 			{
       
   732 			tMbmsInfo.iMukTimestamp.Copy(MukTimeStamp );
       
   733 			}
       
   734 		
       
   735 		//Get the APPID
       
   736 		ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 10, appId);
       
   737 		if ( ret != KErrNone)
       
   738 			{
       
   739 			LOGPARSERR ("APPID", ret, 10, &KMBMSInfo);
       
   740 			continue;
       
   741 			}
       
   742 		else
       
   743 			{
       
   744 			tMbmsInfo.iAID.Copy (appId);
       
   745 			}
       
   746 
       
   747 		//Get the KsIntNaf
       
   748 		ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 11,KSIntNaf);
       
   749 		if ( ret != KErrNone)
       
   750 			{
       
   751 			LOGPARSERR ("KSIntNaf", ret, 11, &KMBMSInfo);
       
   752 			continue;
       
   753 			}
       
   754 		else
       
   755 			{
       
   756 			tMbmsInfo.iKsIntNaf.Copy (KSIntNaf);
       
   757 			}
       
   758 
       
   759 		//Get the CurrentApplnActive
       
   760 		ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 12,applnActive);
       
   761 		if ( ret != KErrNone)
       
   762 			{
       
   763 			LOGPARSERR ("applnActive", ret, 12, &KMBMSInfo);
       
   764 			continue;
       
   765 			}
       
   766 		else
       
   767 			{
       
   768 			tMbmsInfo.iAppActive = applnActive;
       
   769 			}
       
   770 
       
   771 		//Get authentication error
       
   772 		ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 13,authErr);
       
   773 		if ( ret != KErrNone)
       
   774 			{
       
   775 			LOGPARSERR ("authErr", ret, 13, &KMBMSInfo);
       
   776 			continue;
       
   777 			}
       
   778 		else
       
   779 			{
       
   780 			tMbmsInfo.iAuthErr = authErr;
       
   781 			}
       
   782 
       
   783 		iMBMSInfoList->AppendL(tMbmsInfo);
       
   784 		CleanupStack::Pop(item);
       
   785 		}
       
   786 	
       
   787 	LOGPHONE1("Starting to Parse MBMS 2 Phase Retrieval list information");
       
   788 	count = CfgFile()->ItemCount(KMBMSListInfo);
       
   789 	RMobilePhone::TMskEntryV8 mskEntry;
       
   790 	for(index = 0; index < count; index++)
       
   791 		{
       
   792 		item = const_cast<CTestConfigItem*>(CfgFile()->Item(KMBMSListInfo, index));
       
   793 		if(item == NULL)
       
   794 			{
       
   795 			break;
       
   796 			}
       
   797 		CleanupStack::PushL(item);
       
   798 		TInt ret = KErrNone;
       
   799 		TPtrC8 MskId,KeyDomain,TimeStamp;
       
   800 		
       
   801 		//Get the MskId
       
   802 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, MskId);
       
   803 		if(ret != KErrNone)
       
   804 			{
       
   805 			LOGPARSERR("MskId",ret,0,&KMBMSListInfo);
       
   806 			continue;
       
   807 			}
       
   808 		else
       
   809 			{
       
   810 			mskEntry.iMskId.Copy(MskId);
       
   811 			}
       
   812 
       
   813 		//Get the KeyDomainGroup
       
   814 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 1, KeyDomain);
       
   815 		if(ret != KErrNone)
       
   816 			{
       
   817 			LOGPARSERR("KeyDomain",ret,1,&KMBMSListInfo);
       
   818 			continue;
       
   819 			}
       
   820 		else
       
   821 			{
       
   822 			mskEntry.iKeyDomainId.Copy(KeyDomain);
       
   823 			}
       
   824 		
       
   825 		//Get the TimeStampCounter
       
   826 		
       
   827 		ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 2, TimeStamp);
       
   828 		if(ret != KErrNone)
       
   829 			{
       
   830 			LOGPARSERR("TimeStampCounter",ret,2,&KMBMSListInfo);
       
   831 			continue;
       
   832 			}
       
   833 		else
       
   834 			{
       
   835 			mskEntry.iTimeStampCounter.Copy(TimeStamp);
       
   836 			}
       
   837 
       
   838 		iMbmsMskList->AddEntryL(mskEntry);
       
   839 		CleanupStack::Pop(item);
       
   840 		}
       
   841 	if((iGBAAuthInfoList->Count()!=0) ||
       
   842 			(iMBMSInfoList->Count() !=0 ) ||
       
   843 			(iMessageWaiting->Count()!=0))
       
   844 		{
       
   845 		iListIndex=0;
       
   846 		iTimer->Start(KUsimRel6DurationTimeoutDefault2,this,ETimerIdNotifyUSimRel6Event);
       
   847 		}
       
   848 	};
       
   849 
       
   850 CSimUsimR6::~CSimUsimR6()
       
   851 /**
       
   852 * Trivial Destructor
       
   853 * Closes all CObject type objects and destroys all other objects created in the ConstructL()
       
   854 *
       
   855 */
       
   856 	{
       
   857 	LOGMISC1("CSimUsimR6: Entered destructor");
       
   858 	if(iTimer)
       
   859 		{
       
   860 		delete iTimer;
       
   861 		}
       
   862 	if(iWlanTimer)
       
   863 		{
       
   864 		delete iWlanTimer;
       
   865 		}		
       
   866 	if(iNotifyAuthTimer)
       
   867 		{
       
   868 		delete iNotifyAuthTimer;
       
   869 		}
       
   870 	if (iVoiceMailIds)
       
   871 		{
       
   872 		iVoiceMailIds->Delete(0,iVoiceMailIds->Count());
       
   873 		delete iVoiceMailIds;
       
   874 		}
       
   875 	if (iMessageWaiting)
       
   876 		{
       
   877 		iMessageWaiting->Delete(0,iMessageWaiting->Count());
       
   878 		delete iMessageWaiting;
       
   879 		}
       
   880 	if (iWlanData)
       
   881 		{
       
   882 		iWlanData->Delete(0,iWlanData->Count());
       
   883 		delete iWlanData;
       
   884 		}
       
   885 	if (iWlanSid)
       
   886 		{
       
   887 		iWlanSid->Delete(0,iWlanSid->Count());
       
   888 		delete iWlanSid;
       
   889 		}
       
   890 	if (iPreferredNetworks)
       
   891 		{
       
   892 		iPreferredNetworks->Delete(0,iPreferredNetworks->Count());
       
   893 		delete iPreferredNetworks;
       
   894 		}
       
   895 	if(iGetWlanSIDsData)
       
   896 		{
       
   897 		iGetWlanSIDsData->ResetAndDestroy();
       
   898 		}
       
   899 	delete iGetWlanSIDsData;
       
   900 	if(iGetPreferredNetworks)
       
   901 		{
       
   902 		iGetPreferredNetworks->ResetAndDestroy();	
       
   903 		}
       
   904 	delete iGetPreferredNetworks;
       
   905 	if(iGBAAuthInfoList)
       
   906 		{
       
   907 		iGBAAuthInfoList->Delete(0,iGBAAuthInfoList->Count());
       
   908 		delete iGBAAuthInfoList;
       
   909 		}
       
   910 	if(iAuthListInfo)
       
   911 		{
       
   912 		iAuthListInfo->ResetAndDestroy();
       
   913 		}
       
   914 	delete iAuthListInfo;
       
   915 	if(iMBMSInfoList)
       
   916 		{
       
   917 		iMBMSInfoList->Delete(0,iMBMSInfoList->Count());
       
   918 		delete iMBMSInfoList;	
       
   919 		}
       
   920 	if(iGbaNafList)
       
   921 		{
       
   922 		delete iGbaNafList;
       
   923 		}
       
   924 	if(iMbmsMskList)
       
   925 		{
       
   926 		delete iMbmsMskList;
       
   927 		}
       
   928 	LOGMISC1("CSimUsimR6: Leaving destructor");
       
   929 	}
       
   930 
       
   931 const CTestConfigSection* CSimUsimR6::CfgFile()
       
   932 /**
       
   933  * Returns a pointer to the current configuration file section.
       
   934  *
       
   935  * @return CTestConfigSection	A pointer to the current configuration file data section.
       
   936  */
       
   937 	{
       
   938 	return iPhone->CfgFile();
       
   939 	}
       
   940 
       
   941 void CSimUsimR6::TimerCallBack(TInt /**aId*/)
       
   942 /**
       
   943 * Timer callback function.  When the timer goes off, it will call back into this
       
   944 * function for further processing.
       
   945 *
       
   946 * @param aId an id identifying which timer callback is being called
       
   947 */
       
   948 	{
       
   949 	if (iMailBoxNumberChangePending)
       
   950 		{
       
   951 		iMailBoxNumberChangePending = EFalse;
       
   952 		RMobilePhone::TMobilePhoneVoicemailIdsV3* mailbox = reinterpret_cast<RMobilePhone::TMobilePhoneVoicemailIdsV3*>(iMailBoxNumberChange);
       
   953 		mailbox->iVoice = iVoiceMailIds->At(0).iVoice;
       
   954 		mailbox->iData= iVoiceMailIds->At(0).iData;
       
   955 		mailbox->iFax = iVoiceMailIds->At(0).iFax;
       
   956 		mailbox->iOther = iVoiceMailIds->At(0).iOther;
       
   957 		iPhone->ReqCompleted (iMailBoxNumberChangeNotificationReqHandle,KErrNone);
       
   958 		iTimer->Start (KUsimRel6DurationTimeoutDefault2, this,ETimerIdNotifyUSimRel6Event);
       
   959 		}
       
   960 
       
   961 	else if (iMailBoxNumberChangePendingV8)
       
   962 		{
       
   963 		iMailBoxNumberChangePendingV8 = EFalse;
       
   964 		RMobilePhone::TMobilePhoneVoicemailIdsV8* mailbox = reinterpret_cast<RMobilePhone::TMobilePhoneVoicemailIdsV8*>(iMailBoxNumberChangeV8);
       
   965 		mailbox->iVoice = iVoiceMailIds->At(iCurrentNotifyMailboxIndex).iVoice;
       
   966 		mailbox->iData= iVoiceMailIds->At(iCurrentNotifyMailboxIndex).iData;
       
   967 		mailbox->iFax = iVoiceMailIds->At(iCurrentNotifyMailboxIndex).iFax;
       
   968 		mailbox->iOther = iVoiceMailIds->At(iCurrentNotifyMailboxIndex).iOther;
       
   969 		mailbox->iVideo= iVoiceMailIds->At(iCurrentNotifyMailboxIndex).iVideo;
       
   970 		iPhone->ReqCompleted (iMailBoxNumberChangeNotificationReqHandleV8,KErrNone);
       
   971 		iCurrentNotifyMailboxIndex++;
       
   972 		iTimer->Start (KUsimRel6DurationTimeoutDefault2, this,ETimerIdNotifyUSimRel6Event);
       
   973 		}
       
   974 
       
   975 	else if (iIccMessageWaitingPending)
       
   976 		{
       
   977 		iIccMessageWaitingPending=EFalse;
       
   978 		RMobilePhone::TMobilePhoneMessageWaitingV1* messageWaiting = reinterpret_cast<RMobilePhone::TMobilePhoneMessageWaitingV1*>(iIccMsgWaiting);
       
   979 		messageWaiting->iDisplayStatus = iMessageWaiting->At(0).iDisplayStatus;
       
   980 		messageWaiting->iVoiceMsgs= iMessageWaiting->At(0).iVoiceMsgs;
       
   981 		messageWaiting->iAuxVoiceMsgs = iMessageWaiting->At(0).iAuxVoiceMsgs;
       
   982 		messageWaiting->iDataMsgs = iMessageWaiting->At(0).iDataMsgs;
       
   983 		messageWaiting->iFaxMsgs= iMessageWaiting->At(0).iFaxMsgs;
       
   984 		messageWaiting->iEmailMsgs= iMessageWaiting->At(0).iEmailMsgs;
       
   985 		messageWaiting->iOtherMsgs= iMessageWaiting->At(0).iOtherMsgs;
       
   986 		iPhone->ReqCompleted (iIccMessageWaitingNotificationReqHandle,KErrNone);
       
   987 		iTimer->Start (KUsimRel6DurationTimeoutDefault1, this,ETimerIdNotifyUSimRel6Event);
       
   988 		}
       
   989 
       
   990 	else if (iIccMessageWaitingPendingV8)
       
   991 		{
       
   992 		iIccMessageWaitingPendingV8=EFalse;
       
   993 		RMobilePhone::TMobilePhoneMessageWaitingV8* messageWaiting = reinterpret_cast<RMobilePhone::TMobilePhoneMessageWaitingV8*>(iIccMsgWaitingV8);
       
   994 		messageWaiting->iDisplayStatus = iMessageWaiting->At(iCurrentIccMessageWaitingIndex).iDisplayStatus;
       
   995 		messageWaiting->iVoiceMsgs= iMessageWaiting->At(iCurrentIccMessageWaitingIndex).iVoiceMsgs;
       
   996 		messageWaiting->iAuxVoiceMsgs = iMessageWaiting->At(iCurrentIccMessageWaitingIndex).iAuxVoiceMsgs;
       
   997 		messageWaiting->iDataMsgs = iMessageWaiting->At(iCurrentIccMessageWaitingIndex).iDataMsgs;
       
   998 		messageWaiting->iFaxMsgs= iMessageWaiting->At(iCurrentIccMessageWaitingIndex).iFaxMsgs;
       
   999 		messageWaiting->iEmailMsgs= iMessageWaiting->At(iCurrentIccMessageWaitingIndex).iEmailMsgs;
       
  1000 		messageWaiting->iOtherMsgs= iMessageWaiting->At(iCurrentIccMessageWaitingIndex).iOtherMsgs;
       
  1001 		messageWaiting->iVideoMsgs= iMessageWaiting->At(iCurrentIccMessageWaitingIndex).iVideoMsgs;
       
  1002 		iPhone->ReqCompleted (iIccMessageWaitingNotificationReqHandleV8, KErrNone);
       
  1003 		iCurrentIccMessageWaitingIndex++;
       
  1004 		iTimer->Start (KUsimRel6DurationTimeoutDefault1, this,ETimerIdNotifyUSimRel6Event);
       
  1005 		}
       
  1006 
       
  1007 	else if (iMessageWaitingPending)
       
  1008 		{
       
  1009 		iMessageWaitingPending=EFalse;
       
  1010 		*iMsgWaitingCount=6;
       
  1011 		iPhone->ReqCompleted (iMessageWaitingNotificationReqHandle, KErrNone);
       
  1012 		iTimer->Start (KUsimRel6DurationTimeoutDefault, this,ETimerIdNotifyUSimRel6Event);
       
  1013 		}
       
  1014 
       
  1015 	else if (iNotifyPreferredWlanSIDListChangePending)
       
  1016 		{
       
  1017 		iNotifyPreferredWlanSIDListChangePending=EFalse;
       
  1018 		iPhone->ReqCompleted (iNotifyPreferredWlanSIDListReqHandle,KErrNone);
       
  1019 		iNotifyPreferredWlanSIDListChangeIndex++;
       
  1020 		iTimer->Start (KUsimRel6DurationTimeoutDefault1,this, ETimerIdNotifyUSimRel6Event);
       
  1021 		}
       
  1022 
       
  1023 	else if ( iNotifyPreferredNetworksChangePending)
       
  1024 		{
       
  1025 		iNotifyPreferredNetworksChangePending=EFalse;
       
  1026 		iPhone->ReqCompleted (iNotifyPreferredNetworksReqHandle,KErrNone);
       
  1027 		iNotifyPreferredNetworksChangeIndex++;
       
  1028 		iTimer->Start (KUsimRel6DurationTimeoutDefault1, this,ETimerIdNotifyUSimRel6Event);
       
  1029 		}
       
  1030 
       
  1031 	else if (iNotifyWlanDataChangePending)
       
  1032 		{
       
  1033 		iNotifyWlanDataChangePending=EFalse;
       
  1034 		if (iNotifyWlanDataChange->iFieldsUsed == iWlanData->At(0).iFieldsUsed)
       
  1035 			{
       
  1036 			iNotifyWlanDataChange->iPseudonym = iWlanData->At(0).iPseudonym;
       
  1037 			iNotifyWlanDataChange->iReauthenticationId = iWlanData->At(0).iReauthenticationId;
       
  1038 			}
       
  1039 		else if (iNotifyWlanDataChange->iFieldsUsed == iWlanData->At(1).iFieldsUsed)
       
  1040 			{
       
  1041 			iNotifyWlanDataChange->iPseudonym = iWlanData->At(1).iPseudonym;
       
  1042 			iNotifyWlanDataChange->iReauthenticationId = iWlanData->At(1).iReauthenticationId;
       
  1043 			iNotifyWlanDataChange->iMasterKey = iWlanData->At(1).iMasterKey;
       
  1044 			iNotifyWlanDataChange->iCounter = iWlanData->At(1).iCounter;
       
  1045 			}
       
  1046 		else
       
  1047 			{
       
  1048 			iNotifyWlanDataChange->iFieldsUsed = iWlanData->At(1).iFieldsUsed;
       
  1049 			iNotifyWlanDataChange->iPseudonym = iWlanData->At(1).iPseudonym;
       
  1050 			iNotifyWlanDataChange->iReauthenticationId = iWlanData->At(1).iReauthenticationId;
       
  1051 			iNotifyWlanDataChange->iMasterKey = iWlanData->At(1).iMasterKey;
       
  1052 			iNotifyWlanDataChange->iCounter = iWlanData->At(1).iCounter;	
       
  1053 			}
       
  1054 		iPhone->ReqCompleted (iNotifyWlanDataChangeReqHandle,KErrNone);
       
  1055 		iNotifyWlanDataChangeIndex++;
       
  1056 		}
       
  1057 
       
  1058 	else if (iSetGBABootstrapParams.iNotifyPending ||
       
  1059 		  iNotifyAuthDataChange.iNotifyPending ||
       
  1060 		  iGetAuthParams.iNotifyPending)
       
  1061 		{
       
  1062 		if (iSetGBABootstrapParams.iNotifyPending)
       
  1063 			{
       
  1064 			RMobilePhone::TBsfDataV8
       
  1065 					&bsfDataV8 = *(RMobilePhone::TBsfDataV8*)iSetGBABootstrapParams.iNotifyData;
       
  1066 
       
  1067 			if ((bsfDataV8.iBtid != iGBAAuthInfoList->At(iListIndex).iBtid)||(bsfDataV8.iKeyLifetime != iGBAAuthInfoList->At(iListIndex).iKeyLifeTime))
       
  1068 				{
       
  1069 				iPhone->ReqCompleted (
       
  1070 						iSetGBABootstrapParams.iNotifyHandle,
       
  1071 						KErrAccessDenied);
       
  1072 				}
       
  1073 			else
       
  1074 				{
       
  1075 				iPhone->ReqCompleted (
       
  1076 						iSetGBABootstrapParams.iNotifyHandle,
       
  1077 						KErrNone);
       
  1078 				}
       
  1079 			iSetGBABootstrapParams.iNotifyPending = EFalse;
       
  1080 			}
       
  1081 
       
  1082 		if (iNotifyAuthDataChange.iNotifyPending)
       
  1083 			{
       
  1084 			iNotifyAuthDataChange.iNotifyPending = EFalse;
       
  1085 			RMobilePhone::TAuthInfoV8
       
  1086 					&authInfoV8 = *(RMobilePhone::TAuthInfoV8*) iNotifyAuthDataChange.iNotifyData;
       
  1087 
       
  1088 			authInfoV8.iAID = iGBAAuthInfoList->At(iListIndex).iAID;
       
  1089 
       
  1090 			if (iGBAAuthInfoList->At(iListIndex).iAppActive)
       
  1091 				{
       
  1092 				authInfoV8.iData = RMobilePhone::EGbaBootstrapParams;
       
  1093 				}
       
  1094 			else
       
  1095 				{
       
  1096 				authInfoV8.iData = RMobilePhone::EGbaNafIdList;
       
  1097 				}
       
  1098 			iPhone->ReqCompleted (iNotifyAuthDataChange.iNotifyHandle, KErrNone);
       
  1099 			}
       
  1100 		if (iGetAuthParams.iNotifyPending)
       
  1101 			{
       
  1102 			RMobilePhone::TMultimodeType
       
  1103 					&tMultimode = *(RMobilePhone::TMultimodeType*) iGetAuthParams.iNotifyData;
       
  1104 			TInt ret = iGBAAuthInfoList->At(iListIndex).iAuthErr;
       
  1105 			TInt ret1 = iMBMSInfoList->At(iListIndex).iAuthErr;
       
  1106 			if (ret == KErrNone || ret1 == KErrNone)
       
  1107 				{
       
  1108 				if (tMultimode.ExtensionId ()== RMobilePhone::KETelMobileGbaBootstrapParamsV8)
       
  1109 					{
       
  1110 					// for GBA
       
  1111 					RMobilePhone::TGbaBootstrapParamsV8
       
  1112 							&tGbaBootstrapV8 = *(RMobilePhone::TGbaBootstrapParamsV8*) iGetAuthParams.iNotifyData;
       
  1113 					tGbaBootstrapV8.iBtid = iGBAAuthInfoList->At(iListIndex).iBtid;
       
  1114 					tGbaBootstrapV8.iKeyLifetime = iGBAAuthInfoList->At(iListIndex).iKeyLifeTime;
       
  1115 					tGbaBootstrapV8.iRand = iGBAAuthInfoList->At(iListIndex).iRAND;
       
  1116 					}
       
  1117 				else
       
  1118 					if ( tMultimode.ExtensionId ()== RMobilePhone::KETelMobileMbmsUserKeyV8)
       
  1119 						{
       
  1120 						// for MBMS
       
  1121 						RMobilePhone::TMbmsUserKeyV8
       
  1122 								&tMbmsUserKeyV8 = *(RMobilePhone::TMbmsUserKeyV8*) iGetAuthParams.iNotifyData;
       
  1123 						tMbmsUserKeyV8.iMukIdi = iMBMSInfoList->At(iListIndex).iMukIdi;
       
  1124 						tMbmsUserKeyV8.iMukIdr = iMBMSInfoList->At(iListIndex).iMukIdr;
       
  1125 						tMbmsUserKeyV8.iTimeStampCounter = iMBMSInfoList->At(iListIndex).iMukTimestamp;
       
  1126 						}
       
  1127 					else
       
  1128 						{
       
  1129 						// handle error scenario.
       
  1130 						(void) tMultimode;
       
  1131 						iPhone->ReqCompleted (
       
  1132 								iGetAuthParams.iNotifyHandle,
       
  1133 								KErrCorrupt);
       
  1134 						}
       
  1135 				iPhone->ReqCompleted (iGetAuthParams.iNotifyHandle, KErrNone);
       
  1136 				}
       
  1137 			else
       
  1138 				{
       
  1139 				if (tMultimode.ExtensionId ()== RMobilePhone::KETelMobileMbmsUserKeyV8 && ret1 != KErrNone)
       
  1140 					{
       
  1141 					if (!(ret1 == KErrAccessDenied))
       
  1142 						{
       
  1143 						// for MBMS
       
  1144 						RMobilePhone::TMbmsUserKeyV8
       
  1145 								&tMbmsUserKeyV8 = *(RMobilePhone::TMbmsUserKeyV8*) iGetAuthParams.iNotifyData;
       
  1146 						tMbmsUserKeyV8.iMukIdi = iMBMSInfoList->At(iListIndex).iMukIdi;
       
  1147 						tMbmsUserKeyV8.iMukIdr = iMBMSInfoList->At(iListIndex).iMukIdr;
       
  1148 						tMbmsUserKeyV8.iTimeStampCounter = iMBMSInfoList->At(iListIndex).iMukTimestamp;
       
  1149 						}
       
  1150 					iPhone->ReqCompleted (iGetAuthParams.iNotifyHandle, ret1);
       
  1151 					}
       
  1152 				else
       
  1153 					{
       
  1154 					iPhone->ReqCompleted (iGetAuthParams.iNotifyHandle, ret);
       
  1155 					}
       
  1156 				}
       
  1157 			iGetAuthParams.iNotifyPending = EFalse;
       
  1158 			}
       
  1159 		iTimer->Start (RandTime (), this);
       
  1160 		LOGMISC1("<<CSimUsimR6::TimerCallBack - Exited ");
       
  1161 		}
       
  1162 	}
       
  1163 			
       
  1164 TInt CSimUsimR6::NotifyMailboxNumbersChange(TTsyReqHandle aReqHandle, TDes8* aMailBox)
       
  1165 /**
       
  1166  * This function member notifies the client of changes to any of the Mailbox numbers identifiers.
       
  1167  * @param aReqHandle	The request handle associated with this request.
       
  1168  * @param aMailBox		This parameter is filled with new mailbox numbers identifiers.
       
  1169  * @return TInt			Standard error value.
       
  1170  */
       
  1171 	{
       
  1172 	TPckg<RMobilePhone::TMultimodeType>* paramPckg=(TPckg<RMobilePhone::TMultimodeType>*)aMailBox;
       
  1173 	RMobilePhone::TMultimodeType& paramclass=(*paramPckg)();
       
  1174 	if(paramclass.ExtensionId() == KETelExtMultimodeV3)
       
  1175 		{
       
  1176 		__ASSERT_ALWAYS(!iMailBoxNumberChangePending,SimPanic(ENotificationReqAlreadyOutstanding));
       
  1177 		RMobilePhone::TMobilePhoneVoicemailIdsV3Pckg* voicemailPckg=(RMobilePhone::TMobilePhoneVoicemailIdsV3Pckg*)aMailBox;
       
  1178 		RMobilePhone::TMobilePhoneVoicemailIdsV3& voicemail=(*voicemailPckg)();
       
  1179 		// Check that the data structure is supported by the simulated TSY version
       
  1180 		TInt err = iPhone->CheckSimTsyVersion(voicemail);
       
  1181 		if(err != KErrNone)
       
  1182 			{
       
  1183 			iPhone->ReqCompleted(aReqHandle, err);
       
  1184 			return KErrNone;
       
  1185 			}
       
  1186 		iMailBoxNumberChangePending=ETrue;
       
  1187 		iMailBoxNumberChangeNotificationReqHandle=aReqHandle;
       
  1188 		iMailBoxNumberChange=&voicemail;
       
  1189 		}
       
  1190 	if(paramclass.ExtensionId() == KEtelExtMultimodeV8)
       
  1191 		{
       
  1192 		__ASSERT_ALWAYS(!iMailBoxNumberChangePendingV8,SimPanic(ENotificationReqAlreadyOutstanding));
       
  1193 		RMobilePhone::TMobilePhoneVoicemailIdsV8Pckg* voicemailV8Pckg=(RMobilePhone::TMobilePhoneVoicemailIdsV8Pckg*)aMailBox;
       
  1194 		RMobilePhone::TMobilePhoneVoicemailIdsV8& voicemailV8=(*voicemailV8Pckg)();
       
  1195 		// Check that the data structure is supported by the simulated TSY version
       
  1196 		TInt err = iPhone->CheckSimTsyVersion(voicemailV8);
       
  1197 		if(err != KErrNone)
       
  1198 			{
       
  1199 			iPhone->ReqCompleted(aReqHandle, err);
       
  1200 			return KErrNone;
       
  1201 			}
       
  1202 		iMailBoxNumberChangePendingV8=ETrue;
       
  1203 		iMailBoxNumberChangeNotificationReqHandleV8=aReqHandle;
       
  1204 		iMailBoxNumberChangeV8=&voicemailV8;
       
  1205 		}	
       
  1206 	else 
       
  1207 		{	
       
  1208 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);
       
  1209 		return KErrNone;
       
  1210 		}
       
  1211 	return KErrNone;
       
  1212 	}
       
  1213 
       
  1214 TInt CSimUsimR6::NotifyMailboxNumbersChangeCancel(const TTsyReqHandle aTsyReqHandle)
       
  1215 /**
       
  1216 * Cancel a previous request from an client to be notified of a change in mailbox numbers identifiers..
       
  1217 * @param aTsyReqHandle request handle
       
  1218 */
       
  1219 	{
       
  1220 	if(iMailBoxNumberChangePending && iMailBoxNumberChangeNotificationReqHandle == aTsyReqHandle)
       
  1221 		{
       
  1222 		iMailBoxNumberChangePending=EFalse;
       
  1223 		iPhone->ReqCompleted(iMailBoxNumberChangeNotificationReqHandle,KErrCancel);
       
  1224 		}
       
  1225 	else if(iMailBoxNumberChangePendingV8 && iMailBoxNumberChangeNotificationReqHandleV8 == aTsyReqHandle)
       
  1226 		{
       
  1227 		iMailBoxNumberChangePendingV8=EFalse;
       
  1228 		iPhone->ReqCompleted(iMailBoxNumberChangeNotificationReqHandleV8,KErrCancel);
       
  1229 		}
       
  1230 	return KErrNone;
       
  1231 	}
       
  1232 
       
  1233 TInt CSimUsimR6::NotifyMessageWaiting(TTsyReqHandle aReqHandle, TInt* aCount)
       
  1234 /**
       
  1235  * This function member allows a client to be notified when the phone receives 
       
  1236  * a message waiting indication from the network.
       
  1237  * @param aReqHandle	The request handle associated with this request.
       
  1238  * @param aCount		This parameter is filled with the number of voice mail messages waiting in the network. 
       
  1239  * @return TInt			Standard error value.
       
  1240  */	
       
  1241 	{
       
  1242 	__ASSERT_ALWAYS(!iMessageWaitingPending,SimPanic(ENotificationReqAlreadyOutstanding));
       
  1243 	iMessageWaitingPending=ETrue;
       
  1244 	iMessageWaitingNotificationReqHandle=aReqHandle;
       
  1245 	iMsgWaitingCount=aCount;
       
  1246 	return KErrNone;		
       
  1247 	};
       
  1248 
       
  1249 TInt CSimUsimR6::NotifyMessageWaitingCancel(const TTsyReqHandle aReqHandle)
       
  1250 	{
       
  1251 	if(iMessageWaitingPending && iMessageWaitingNotificationReqHandle == aReqHandle)
       
  1252 		{
       
  1253 		iMessageWaitingPending=EFalse;
       
  1254 		iPhone->ReqCompleted(iMessageWaitingNotificationReqHandle,KErrCancel);
       
  1255 		}
       
  1256 	return KErrNone;
       
  1257 	};
       
  1258 		
       
  1259 TInt CSimUsimR6::NotifyIccMessageWaitingIndicatorsChange(TTsyReqHandle aReqHandle, TDes8* aMsgIndicators)
       
  1260 /**
       
  1261  * This function member notifies the client if the message waiting indicators 
       
  1262  * on the current ICC change.
       
  1263  * @param aReqHandle	The request handle associated with this request.
       
  1264  * @param aMsgIndicators  This parameter is filled with the message waiting indicators infromation. 
       
  1265  * @return TInt			Standard error value.
       
  1266  */	
       
  1267 	{
       
  1268 	TPckg<RMobilePhone::TMultimodeType>* paramPckg=(TPckg<RMobilePhone::TMultimodeType>*)aMsgIndicators;
       
  1269 	RMobilePhone::TMultimodeType& paramclass=(*paramPckg) ();
       
  1270 	if ( paramclass.ExtensionId ()== KETelExtMultimodeV1)
       
  1271 		{
       
  1272 		__ASSERT_ALWAYS(!iIccMessageWaitingPending,SimPanic(ENotificationReqAlreadyOutstanding));
       
  1273 		RMobilePhone::TMobilePhoneMessageWaitingV1Pckg* messagewaitingPckg=(RMobilePhone::TMobilePhoneMessageWaitingV1Pckg*)aMsgIndicators;
       
  1274 		RMobilePhone::TMobilePhoneMessageWaitingV1& messagewaiting=(*messagewaitingPckg) ();
       
  1275 		// Check that the data structure is supported by the simulated TSY version
       
  1276 		TInt err = iPhone->CheckSimTsyVersion (messagewaiting);
       
  1277 		if ( err != KErrNone)
       
  1278 			{
       
  1279 			iPhone->ReqCompleted (aReqHandle, err);
       
  1280 			return KErrNone;
       
  1281 			}
       
  1282 		iIccMessageWaitingPending=ETrue;
       
  1283 		iIccMessageWaitingNotificationReqHandle=aReqHandle;
       
  1284 		iIccMsgWaiting=&messagewaiting;
       
  1285 		}
       
  1286 	if (paramclass.ExtensionId ()== KEtelExtMultimodeV8)
       
  1287 		{
       
  1288 		__ASSERT_ALWAYS(!iIccMessageWaitingPendingV8,SimPanic(ENotificationReqAlreadyOutstanding));
       
  1289 		RMobilePhone::TMobilePhoneMessageWaitingV8Pckg* messagewaitingPckg=(RMobilePhone::TMobilePhoneMessageWaitingV8Pckg*)aMsgIndicators;
       
  1290 		RMobilePhone::TMobilePhoneMessageWaitingV8& messagewaiting=(*messagewaitingPckg) ();
       
  1291 		// Check that the data structure is supported by the simulated TSY version
       
  1292 		TInt err = iPhone->CheckSimTsyVersion (messagewaiting);
       
  1293 		if ( err != KErrNone)
       
  1294 			{
       
  1295 			iPhone->ReqCompleted (aReqHandle, err);
       
  1296 			return KErrNone;
       
  1297 			}
       
  1298 		iIccMessageWaitingPendingV8=ETrue;
       
  1299 		iIccMessageWaitingNotificationReqHandleV8=aReqHandle;
       
  1300 		iIccMsgWaitingV8=&messagewaiting;
       
  1301 		}
       
  1302 	else
       
  1303 		{
       
  1304 		iPhone->ReqCompleted (aReqHandle, KErrNotSupported);
       
  1305 		return KErrNone;
       
  1306 		}
       
  1307 	return KErrNone;
       
  1308 	}
       
  1309 
       
  1310 TInt CSimUsimR6::NotifyIccMessageWaitingIndicatorsChangeCancel(const TTsyReqHandle aTsyReqHandle)
       
  1311 /**
       
  1312 * Cancel a previous request from an client to be notified of a change in the message waiting indicators 
       
  1313 * on the current ICC.
       
  1314 * @param aTsyReqHandle request handle
       
  1315 */
       
  1316 	{
       
  1317 	if ( iIccMessageWaitingPending && iIccMessageWaitingNotificationReqHandle == aTsyReqHandle)
       
  1318 		{
       
  1319 		iIccMessageWaitingPending=EFalse;
       
  1320 		iPhone->ReqCompleted (iIccMessageWaitingNotificationReqHandle, KErrCancel);
       
  1321 		}
       
  1322 	else
       
  1323 		if ( iIccMessageWaitingPendingV8 && iIccMessageWaitingNotificationReqHandleV8 == aTsyReqHandle)
       
  1324 			{
       
  1325 			iIccMessageWaitingPendingV8=EFalse;
       
  1326 			iPhone->ReqCompleted (iIccMessageWaitingNotificationReqHandleV8, KErrCancel);
       
  1327 			}
       
  1328 	return KErrNone;
       
  1329 	}
       
  1330 
       
  1331 TInt CSimUsimR6::GetMailboxNumbers(TTsyReqHandle aReqHandle,TDes8* aMailBox)
       
  1332 /**
       
  1333  * Retrieves the Mailbox numbers identifier information from the EF_MBI file in the USIM.
       
  1334  * @param aReqHandle	The request handle associated with this request.
       
  1335  * @param aMailBox		This will be populated with the
       
  1336  *						mailbox identifier information to be returned.
       
  1337  * @return TInt			Standard error value.
       
  1338  */
       
  1339 	{
       
  1340 	RMobilePhone::TMobilePhoneVoicemailIdsV3Pckg* voicemailPckg=(RMobilePhone::TMobilePhoneVoicemailIdsV3Pckg*)aMailBox;
       
  1341 	RMobilePhone::TMultimodeType& packagetype = (*voicemailPckg)();
       
  1342 	
       
  1343 	if(packagetype.ExtensionId() == KETelExtMultimodeV3 || packagetype.ExtensionId() == KEtelExtMultimodeV8)
       
  1344 		{	
       
  1345 		RMobilePhone::TMobilePhoneVoicemailIdsV3Pckg* voicemailPckg=(RMobilePhone::TMobilePhoneVoicemailIdsV3Pckg*)aMailBox;
       
  1346 		RMobilePhone::TMobilePhoneVoicemailIdsV3& mailbox=(*voicemailPckg)();		
       
  1347 		mailbox.iVoice = iVoiceMailIds->At(iCurrentIndex).iVoice;
       
  1348 		mailbox.iData = iVoiceMailIds->At(iCurrentIndex).iData;
       
  1349 		mailbox.iFax = iVoiceMailIds->At(iCurrentIndex).iFax;
       
  1350 		mailbox.iOther = iVoiceMailIds->At(iCurrentIndex).iOther;
       
  1351 		}
       
  1352 	if(packagetype.ExtensionId() == KEtelExtMultimodeV8)
       
  1353 		{	
       
  1354 		RMobilePhone::TMobilePhoneVoicemailIdsV8Pckg* voicemailV8Pckg=(RMobilePhone::TMobilePhoneVoicemailIdsV8Pckg*)aMailBox;
       
  1355 		RMobilePhone::TMobilePhoneVoicemailIdsV8& voicemailV8=(*voicemailV8Pckg)();		
       
  1356 		voicemailV8.iVideo = iVoiceMailIds->At(iCurrentIndex).iVideo;
       
  1357 		}
       
  1358 	iCurrentIndex++;
       
  1359 	iPhone->ReqCompleted(aReqHandle,KErrNone);
       
  1360 	return KErrNone;
       
  1361 	}
       
  1362 
       
  1363 TInt CSimUsimR6::GetIccMessageWaitingIndicators(TTsyReqHandle aReqHandle,TDes8* aMsgIndicators)
       
  1364 /**
       
  1365  * This function member retrieves the set of message waiting indicators from the 
       
  1366  * current ICC. 
       
  1367  * @param aReqHandle	        The request handle associated with this request.
       
  1368  * @param aMsgIndicators		The first parameter package.This will be populated with the
       
  1369  *						        message waiting indicators  information to be returned.
       
  1370  * @return TInt		        	Standard error value.
       
  1371  */
       
  1372 	{
       
  1373 	RMobilePhone::TMobilePhoneMessageWaitingV1Pckg* messagewaitPckg=(RMobilePhone::TMobilePhoneMessageWaitingV1Pckg*)aMsgIndicators;
       
  1374 	RMobilePhone::TMultimodeType& packagetype = (*messagewaitPckg)();
       
  1375 	
       
  1376 	if(packagetype.ExtensionId() == KETelExtMultimodeV1 || packagetype.ExtensionId() == KEtelExtMultimodeV8)
       
  1377 		{	
       
  1378 		RMobilePhone::TMobilePhoneMessageWaitingV1Pckg* messagewaitingPckg=(RMobilePhone::TMobilePhoneMessageWaitingV1Pckg*)aMsgIndicators;
       
  1379 		RMobilePhone::TMobilePhoneMessageWaitingV1& messagewaiting=(*messagewaitingPckg)();		
       
  1380 		messagewaiting.iDisplayStatus=iMessageWaiting->At(iGetIccMsgIdCurrentIndex).iDisplayStatus;
       
  1381 		messagewaiting.iVoiceMsgs=iMessageWaiting->At(iGetIccMsgIdCurrentIndex).iVoiceMsgs;
       
  1382 		messagewaiting.iAuxVoiceMsgs=iMessageWaiting->At(iGetIccMsgIdCurrentIndex).iAuxVoiceMsgs;
       
  1383 		messagewaiting.iDataMsgs =iMessageWaiting->At(iGetIccMsgIdCurrentIndex).iDataMsgs;
       
  1384 		messagewaiting.iFaxMsgs=iMessageWaiting->At(iGetIccMsgIdCurrentIndex).iFaxMsgs;
       
  1385 		messagewaiting.iEmailMsgs=iMessageWaiting->At(iGetIccMsgIdCurrentIndex).iEmailMsgs;
       
  1386 		messagewaiting.iOtherMsgs=iMessageWaiting->At(iGetIccMsgIdCurrentIndex).iOtherMsgs;
       
  1387 		}
       
  1388 	if(packagetype.ExtensionId() == KEtelExtMultimodeV8)
       
  1389 		{	
       
  1390 		RMobilePhone::TMobilePhoneMessageWaitingV8Pckg* messagewaitingV8Pckg=(RMobilePhone::TMobilePhoneMessageWaitingV8Pckg*)aMsgIndicators;
       
  1391 		RMobilePhone::TMobilePhoneMessageWaitingV8& messagewaitingV8=(*messagewaitingV8Pckg)();		
       
  1392 		messagewaitingV8.iVideoMsgs=iMessageWaiting->At(iGetIccMsgIdCurrentIndex).iVideoMsgs;
       
  1393 		iGetIccMsgIdCurrentIndex++;
       
  1394 		}
       
  1395 	else
       
  1396 		{
       
  1397 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);
       
  1398 		return KErrNone;		
       
  1399 		}
       
  1400 	iPhone->ReqCompleted(aReqHandle,KErrNone);
       
  1401 	return KErrNone;
       
  1402 	}
       
  1403 
       
  1404 TInt CSimUsimR6::SetIccMessageWaitingIndicators(TTsyReqHandle aReqHandle,TDes8* aMsgIndicators)
       
  1405 /**
       
  1406  * Sending information about the set of message waiting indicators from the 
       
  1407  * current ICC.
       
  1408  * @param aReqHandle	The request handle associated with this request.
       
  1409  * @param aMsgIndicators		The first parameter package.This contains the
       
  1410  *						message waiting indicators  information
       
  1411  * @return TInt			Standard error value.
       
  1412  */
       
  1413 	{
       
  1414 	RMobilePhone::TMobilePhoneMessageWaitingV1Pckg* messagewaitPckg=(RMobilePhone::TMobilePhoneMessageWaitingV1Pckg*)aMsgIndicators;
       
  1415 	RMobilePhone::TMultimodeType& packagetype = (*messagewaitPckg)();
       
  1416 	
       
  1417 	if(packagetype.ExtensionId() == KETelExtMultimodeV1)
       
  1418 		{	
       
  1419 		RMobilePhone::TMobilePhoneMessageWaitingV1Pckg* messagewaitingPckg=(RMobilePhone::TMobilePhoneMessageWaitingV1Pckg*)aMsgIndicators;
       
  1420 		RMobilePhone::TMobilePhoneMessageWaitingV1& messagewaiting=(*messagewaitingPckg)();		
       
  1421 
       
  1422 		if ((messagewaiting.iVoiceMsgs != iMessageWaiting->At(iSetIccMsgIdCurrentIndex).iVoiceMsgs) ||
       
  1423 			(messagewaiting.iAuxVoiceMsgs != iMessageWaiting->At(iSetIccMsgIdCurrentIndex).iAuxVoiceMsgs) ||
       
  1424 			(messagewaiting.iDataMsgs != iMessageWaiting->At(iSetIccMsgIdCurrentIndex).iDataMsgs) ||
       
  1425 			(messagewaiting.iFaxMsgs != iMessageWaiting->At(iSetIccMsgIdCurrentIndex).iFaxMsgs) ||
       
  1426 			(messagewaiting.iEmailMsgs != iMessageWaiting->At(iSetIccMsgIdCurrentIndex).iEmailMsgs)  ||
       
  1427 			(messagewaiting.iOtherMsgs != iMessageWaiting->At(iSetIccMsgIdCurrentIndex).iOtherMsgs))
       
  1428 			{
       
  1429 			iPhone->ReqCompleted(aReqHandle,KErrCorrupt); //KErrCorrupt
       
  1430 			}
       
  1431 		else
       
  1432 			{	
       
  1433 			iPhone->ReqCompleted(aReqHandle,KErrNone);
       
  1434 			}
       
  1435 		}
       
  1436 		
       
  1437 	if(packagetype.ExtensionId() == KEtelExtMultimodeV8)
       
  1438 		{	
       
  1439 		RMobilePhone::TMobilePhoneMessageWaitingV8Pckg* messagewaitingV8Pckg=(RMobilePhone::TMobilePhoneMessageWaitingV8Pckg*)aMsgIndicators;
       
  1440 		RMobilePhone::TMobilePhoneMessageWaitingV8& messagewaitingV8=(*messagewaitingV8Pckg)();		
       
  1441 
       
  1442 		if ((messagewaitingV8.iVoiceMsgs != iMessageWaiting->At(iSetIccMsgIdCurrentIndex).iVoiceMsgs) ||
       
  1443 			(messagewaitingV8.iAuxVoiceMsgs != iMessageWaiting->At(iSetIccMsgIdCurrentIndex).iAuxVoiceMsgs) ||
       
  1444 			(messagewaitingV8.iDataMsgs != iMessageWaiting->At(iSetIccMsgIdCurrentIndex).iDataMsgs) ||
       
  1445 			(messagewaitingV8.iFaxMsgs != iMessageWaiting->At(iSetIccMsgIdCurrentIndex).iFaxMsgs) ||
       
  1446 			(messagewaitingV8.iEmailMsgs != iMessageWaiting->At(iSetIccMsgIdCurrentIndex).iEmailMsgs)  ||
       
  1447 			(messagewaitingV8.iOtherMsgs != iMessageWaiting->At(iSetIccMsgIdCurrentIndex).iOtherMsgs) ||
       
  1448 			(messagewaitingV8.iVideoMsgs != iMessageWaiting->At(iSetIccMsgIdCurrentIndex).iVideoMsgs))
       
  1449 			{
       
  1450 			iPhone->ReqCompleted(aReqHandle,KErrCorrupt); //KErrCorrupt
       
  1451 			}
       
  1452 		else
       
  1453 			{	
       
  1454 			iSetIccMsgIdCurrentIndex++;
       
  1455 			iPhone->ReqCompleted(aReqHandle,KErrNone);
       
  1456 			}
       
  1457 		}
       
  1458 	else
       
  1459 		{
       
  1460 		iPhone->ReqCompleted(aReqHandle,KErrNotSupported);		
       
  1461 		}
       
  1462 	return KErrNone;	
       
  1463 	}
       
  1464 
       
  1465 //
       
  1466 // Wireless LAN (WLAN)
       
  1467 //
       
  1468 
       
  1469 TInt CSimUsimR6::NotifyWlanDataChange(const TTsyReqHandle aTsyReqHandle,TDes8* aData)
       
  1470 /**
       
  1471  * Notification request posted by the client is completed by the TSY when there is a change in 
       
  1472  * the Wlan Data. This API upon completion returns the current Wlan Data to the client.
       
  1473  * @param aReqHandle	The request handle associated with this request.
       
  1474  * @param aData			This contains the current Wlan data upon completion.
       
  1475  * @return TInt			Standard error value.
       
  1476  */
       
  1477 	{
       
  1478 	__ASSERT_ALWAYS(!iNotifyWlanDataChangePending,SimPanic(ENotificationReqAlreadyOutstanding));
       
  1479 	RMobilePhone::TUsimWlanDataV8Pckg *WlanDataV8Pckg = reinterpret_cast<RMobilePhone::TUsimWlanDataV8Pckg*> (aData);
       
  1480 	RMobilePhone::TUsimWlanDataV8 &WlanDataV8 = (*WlanDataV8Pckg)();
       
  1481 	iNotifyWlanDataChangeReqHandle=aTsyReqHandle;
       
  1482 	iNotifyWlanDataChange=&WlanDataV8;
       
  1483 	if(iIndex%2==0)
       
  1484 		{
       
  1485 		iNotifyWlanDataChangePending=ETrue;
       
  1486 		iWlanTimer->Start(KUsimRel6DurationTimeoutDefault,this,ETimerIdNotifyWlanDataEvent);
       
  1487 		}
       
  1488 	iIndex++;
       
  1489 	return KErrNone;	
       
  1490 	}
       
  1491 
       
  1492 TInt CSimUsimR6::NotifyWlanDataChangeCancel(TTsyReqHandle aTsyReqHandle)
       
  1493 /**
       
  1494  * This API is used by the TSY to cancel any pending NotifyWlanDataChange request. 
       
  1495  * @param aReqHandle	The request handle associated with this request.
       
  1496  * @return TInt			Standard error value.
       
  1497  */
       
  1498 	{
       
  1499 	if(iNotifyWlanDataChangeReqHandle==aTsyReqHandle)
       
  1500 		{
       
  1501 		iNotifyWlanDataChangePending=EFalse;
       
  1502 		iPhone->ReqCompleted(iNotifyWlanDataChangeReqHandle,KErrCancel);
       
  1503 		}
       
  1504 	return KErrNone;
       
  1505 	}
       
  1506 
       
  1507 TInt CSimUsimR6::SetWlanData(const TTsyReqHandle aTsyReqHandle,TDes8* aData)
       
  1508 /**
       
  1509  * This API is used by the TSY to receive the Wlan data sent by the client.
       
  1510  * @param aReqHandle	The request handle associated with this request.
       
  1511  * @param aData			This contains the Wlan Data.
       
  1512  * @return TInt			Standard error value.
       
  1513  */
       
  1514 	{
       
  1515 	RMobilePhone::TUsimWlanDataV8Pckg *WlanDataV8Pckg = reinterpret_cast<RMobilePhone::TUsimWlanDataV8Pckg*> (aData);
       
  1516 	RMobilePhone::TUsimWlanDataV8 &WlanDataV8 = (*WlanDataV8Pckg)();
       
  1517 	
       
  1518 	if(WlanDataV8.iPseudonym==SIMTSY_PHONE_WLAN_ACESS_DENIED)
       
  1519 		{
       
  1520 		iPhone->ReqCompleted(aTsyReqHandle,KErrAccessDenied);
       
  1521 		}
       
  1522 	else if(WlanDataV8.iFieldsUsed == iWlanData->At(0).iFieldsUsed)
       
  1523 		{
       
  1524 		if((WlanDataV8.iPseudonym != iWlanData->At(0).iPseudonym) ||
       
  1525 			(WlanDataV8.iReauthenticationId != iWlanData->At(0).iReauthenticationId))
       
  1526 			{
       
  1527 			iPhone->ReqCompleted(aTsyReqHandle,KErrCorrupt);
       
  1528 			}
       
  1529 		else
       
  1530 			{
       
  1531 			iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
       
  1532 			}
       
  1533 		}
       
  1534 	else if(WlanDataV8.iFieldsUsed == iWlanData->At(1).iFieldsUsed)
       
  1535 		{	
       
  1536 		if((WlanDataV8.iPseudonym != iWlanData->At(1).iPseudonym) ||
       
  1537 			(WlanDataV8.iReauthenticationId != iWlanData->At(1).iReauthenticationId) ||
       
  1538 			(WlanDataV8.iMasterKey != iWlanData->At(1).iMasterKey) ||
       
  1539 			(WlanDataV8.iCounter != iWlanData->At(1).iCounter))
       
  1540 			{
       
  1541 			iPhone->ReqCompleted(aTsyReqHandle,KErrCorrupt);
       
  1542 			}
       
  1543 		else
       
  1544 			{
       
  1545 			iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
       
  1546 			}		
       
  1547 		}
       
  1548 	else
       
  1549 		{
       
  1550 		iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
       
  1551 		}
       
  1552 	return KErrNone;	
       
  1553 	}
       
  1554 
       
  1555 TInt CSimUsimR6::GetWlanData(const TTsyReqHandle aTsyReqHandle,TDes8* aData)
       
  1556 /**
       
  1557  * This API is used by the TSY to send the Wlan data information requested by the client
       
  1558  * @param aReqHandle	The request handle associated with this request.
       
  1559  * @param aData			This contains the current Wlan data upon completion.
       
  1560  * @return TInt			Standard error value.
       
  1561  */
       
  1562 	{
       
  1563 	RMobilePhone::TUsimWlanDataV8Pckg *WlanDataV8Pckg = reinterpret_cast<RMobilePhone::TUsimWlanDataV8Pckg*> (aData);
       
  1564 	RMobilePhone::TUsimWlanDataV8 &WlanDataV8 = (*WlanDataV8Pckg)();
       
  1565 
       
  1566 	if(WlanDataV8.iPseudonym==SIMTSY_PHONE_WLAN_ACESS_DENIED)
       
  1567 		{
       
  1568 		iPhone->ReqCompleted(aTsyReqHandle,KErrAccessDenied);
       
  1569 		}
       
  1570 	else if(WlanDataV8.iCounter == iWlanData->At(2).iCounter)
       
  1571 		{
       
  1572 		iPhone->ReqCompleted(aTsyReqHandle,KErrNotSupported);
       
  1573 		}
       
  1574 	else if(WlanDataV8.iFieldsUsed ==iWlanData->At(0).iFieldsUsed )
       
  1575 		{
       
  1576 		WlanDataV8.iPseudonym = iWlanData->At(0).iPseudonym;
       
  1577 		WlanDataV8.iReauthenticationId = iWlanData->At(0).iReauthenticationId;
       
  1578 		iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
       
  1579 		}
       
  1580 	else if(WlanDataV8.iFieldsUsed ==iWlanData->At(1).iFieldsUsed )
       
  1581 		{
       
  1582 		WlanDataV8.iPseudonym = iWlanData->At(1).iPseudonym;
       
  1583 		WlanDataV8.iReauthenticationId = iWlanData->At(1).iReauthenticationId;
       
  1584 		WlanDataV8.iMasterKey = iWlanData->At(1).iMasterKey;
       
  1585 		WlanDataV8.iCounter = iWlanData->At(1).iCounter ;
       
  1586 		iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
       
  1587 		}
       
  1588 	else
       
  1589 		{
       
  1590 		WlanDataV8.iFieldsUsed =iWlanData->At(1).iFieldsUsed; 
       
  1591 		WlanDataV8.iPseudonym = iWlanData->At(1).iPseudonym;
       
  1592 		WlanDataV8.iReauthenticationId = iWlanData->At(1).iReauthenticationId;
       
  1593 		WlanDataV8.iMasterKey = iWlanData->At(1).iMasterKey;
       
  1594 		WlanDataV8.iCounter = iWlanData->At(1).iCounter ;
       
  1595 		iPhone->ReqCompleted(aTsyReqHandle,KErrNone);	
       
  1596 		}
       
  1597 	return KErrNone;	
       
  1598 	}
       
  1599 
       
  1600 TInt CSimUsimR6::StorePreferredWlanSIDList(const TTsyReqHandle aTsyReqHandle, TDes8* aBuffer)
       
  1601 /**
       
  1602  * This API is used by the TSY to store the Preferred Wlan SID List sent by the Client.
       
  1603  * @param aReqHandle	The request handle associated with this request.
       
  1604  * @param aBuffer		This contains the Preferred Wlan SID List.
       
  1605  * @return TInt			Standard error value.
       
  1606  */
       
  1607 	{
       
  1608 	TInt ret=KErrNone;
       
  1609 	TInt leaveCode=KErrNone;
       
  1610 	TRAP(leaveCode, ret=ProcessStorePreferredWlanSIDListL(aTsyReqHandle, aBuffer););
       
  1611 	if (leaveCode != KErrNone)
       
  1612 		{
       
  1613 		iPhone->ReqCompleted(aTsyReqHandle,leaveCode);
       
  1614 		}
       
  1615 	return ret;
       
  1616 	}
       
  1617 
       
  1618 TInt CSimUsimR6::ProcessStorePreferredWlanSIDListL(TTsyReqHandle aTsyReqHandle, TDes8* aBuffer)
       
  1619 /**
       
  1620  * This API is used by the TSY to process the Preferred Wlan SID List sent by the Client and verify it.
       
  1621  * @param aReqHandle	The request handle associated with this request.
       
  1622  * @param aBuffer		This contains the Preferred Wlan SID List.
       
  1623  * @return TInt			Standard error value.
       
  1624  */
       
  1625 	{
       
  1626 	CMobilePhoneStoredWlanSIDList* list=CMobilePhoneStoredWlanSIDList::NewL();
       
  1627 	CleanupStack::PushL(list);
       
  1628 	list->RestoreL(*aBuffer);
       
  1629 	RMobilePhone::TWlanSIDV8 entry;
       
  1630 	if (list->Enumerate() > SIMTSY_PHONE_WLAN_SIDLIST_COUNT)
       
  1631 		{
       
  1632 		iPhone->ReqCompleted(aTsyReqHandle,KErrNoMemory);
       
  1633 		CleanupStack::PopAndDestroy(); // list
       
  1634 		return KErrNone;
       
  1635 		}
       
  1636 	TInt error=KErrCorrupt;
       
  1637 	TInt ret;
       
  1638 	for (TInt i=0; i<SIMTSY_PHONE_WLAN_SIDLIST_COUNT; ++i)
       
  1639 		{
       
  1640 		TRAP(ret,entry=list->GetEntryL(i));
       
  1641 		if (ret != KErrNone)
       
  1642 			{
       
  1643 			break;
       
  1644 			}
       
  1645 		switch(i)
       
  1646 			{
       
  1647 		case 0:
       
  1648 			if((entry.iWSID == iWlanSid->At(0).iWSID||entry.iWSID != iWlanSid->At(1).iWSID ||entry.iWSID != iWlanSid->At(2).iWSID)
       
  1649 			   && (entry.iUserDefined == iWlanSid->At(0).iUserDefined || entry.iUserDefined == iWlanSid->At(1).iUserDefined || 
       
  1650 			   entry.iUserDefined == iWlanSid->At(2).iUserDefined))
       
  1651 				{
       
  1652 				error  = KErrNone;
       
  1653 				}
       
  1654 			break;
       
  1655 		case 1:
       
  1656 			if((entry.iWSID == iWlanSid->At(0).iWSID||entry.iWSID != iWlanSid->At(1).iWSID ||entry.iWSID != iWlanSid->At(2).iWSID)
       
  1657 			   && (entry.iUserDefined == iWlanSid->At(0).iUserDefined || entry.iUserDefined == iWlanSid->At(1).iUserDefined ||
       
  1658 			    entry.iUserDefined == iWlanSid->At(2).iUserDefined))
       
  1659 				{
       
  1660 				error  = KErrNone;
       
  1661 				}
       
  1662 			break;
       
  1663 		case 2:
       
  1664 		default:
       
  1665 			if((entry.iWSID == iWlanSid->At(0).iWSID||entry.iWSID != iWlanSid->At(1).iWSID ||entry.iWSID != iWlanSid->At(2).iWSID)
       
  1666 			   && (entry.iUserDefined == iWlanSid->At(0).iUserDefined || entry.iUserDefined == iWlanSid->At(1).iUserDefined ||
       
  1667 			    entry.iUserDefined == iWlanSid->At(2).iUserDefined))
       
  1668 				{
       
  1669 				error  = KErrNone;
       
  1670 				}
       
  1671 			break;
       
  1672 			}
       
  1673 		}
       
  1674 	if(error == KErrNone)	
       
  1675 		{
       
  1676 		iPhone->ReqCompleted(aTsyReqHandle,KErrNone);	
       
  1677 		}
       
  1678 	else
       
  1679 		{
       
  1680 		iPhone->ReqCompleted(aTsyReqHandle,KErrCorrupt);
       
  1681 		}
       
  1682 	CleanupStack::PopAndDestroy(); 
       
  1683 	return KErrNone;
       
  1684 	}
       
  1685 
       
  1686 TInt CSimUsimR6::NotifyPreferredWlanSIDListChange(TTsyReqHandle aTsyReqHandle)
       
  1687 /**
       
  1688  * This API is used by the TSY to complete the Preferred Wlan SID List change
       
  1689  * notification request posted by the client.
       
  1690  * 
       
  1691  * @param aReqHandle	The request handle associated with this request.
       
  1692  * @return TInt			Standard error value.
       
  1693  */
       
  1694 	{
       
  1695 	iNotifyPreferredWlanSIDListChangePending=ETrue;
       
  1696 	iNotifyPreferredWlanSIDListReqHandle=aTsyReqHandle;
       
  1697 	return KErrNone;
       
  1698 	}
       
  1699 	
       
  1700 TInt CSimUsimR6::NotifyPreferredWlanSIDListChangeCancel(TTsyReqHandle /**aTsyReqHandle*/)
       
  1701 /**
       
  1702  * This API is used by TSY to cancel any NotifyPreferredWlanSIDListChange outstanding requests 
       
  1703  * @return TInt			Standard error value.
       
  1704  */
       
  1705 	{
       
  1706 	iNotifyPreferredWlanSIDListChangePending=EFalse;
       
  1707 	iPhone->ReqCompleted(iNotifyPreferredWlanSIDListReqHandle,KErrCancel);
       
  1708 	return KErrNone;
       
  1709 	}
       
  1710 
       
  1711 TInt CSimUsimR6::GetPreferredWlanSIDsPhase1(const TTsyReqHandle aTsyReqHandle, RMobilePhone::TClientId* aClient, TInt* aBufSize)
       
  1712 /** 
       
  1713  * Tsy uses this API to retrieve the Preferred Wlan SIDs of each line from phone, 
       
  1714  * store each Preferred Wlan SID as a list entry,
       
  1715  * stream the list and then return size of this buffer to client.
       
  1716  * @param aReqHandle  Handle to the request.
       
  1717  * @param aClient     Pointer to the client.
       
  1718  * @param aBufSize    Size of the buffer the client has to allocate for the 2nd pahase.
       
  1719  */
       
  1720 	{
       
  1721 	TInt ret=KErrNone;
       
  1722 	TInt leaveCode=KErrNone;
       
  1723 	TRAP(leaveCode, ret=ProcessGetPreferredWlanSIDsPhase1L(aTsyReqHandle, aClient, aBufSize););
       
  1724 	if (leaveCode != KErrNone)
       
  1725 		{
       
  1726 		iPhone->ReqCompleted(aTsyReqHandle,leaveCode);
       
  1727 		}
       
  1728 	return ret;
       
  1729 	}	
       
  1730 	
       
  1731 TInt CSimUsimR6::ProcessGetPreferredWlanSIDsPhase1L(const TTsyReqHandle aTsyReqHandle, 
       
  1732 													 RMobilePhone::TClientId* aClient, 
       
  1733 													 TInt* aBufSize)
       
  1734 /**
       
  1735 * Retrieve stored Wlan specific IDs from USIM.
       
  1736 * Store each entry,stream the list and then return size of this buffer to client
       
  1737 * @param aReqHandle  Handle to the request.
       
  1738 * @param aClient     Pointer to the client.
       
  1739 * @param aBufSize    Size of the buffer the client has to allocate for the 2nd pahase.
       
  1740 */	
       
  1741 	{
       
  1742 	CMobilePhoneStoredWlanSIDList* list=CMobilePhoneStoredWlanSIDList::NewL();
       
  1743 	CleanupStack::PushL(list);
       
  1744 	RMobilePhone::TWlanSIDV8 entry;
       
  1745 	// fill up an example list
       
  1746 	for (TInt index=0; index < SIMTSY_PHONE_WLAN_SIDLIST_COUNT; index++)
       
  1747 		{
       
  1748 		switch (index)
       
  1749 			{
       
  1750 		case 0:
       
  1751 			entry.iWSID = iWlanSid->At(0).iWSID;
       
  1752 		    entry.iUserDefined = iWlanSid->At(0).iUserDefined;
       
  1753 			break;
       
  1754 		case 1:
       
  1755 			entry.iWSID = iWlanSid->At(1).iWSID;
       
  1756 		    entry.iUserDefined = iWlanSid->At(1).iUserDefined;
       
  1757 			break;
       
  1758 		case 2:
       
  1759 		default:
       
  1760 			entry.iWSID = iWlanSid->At(2).iWSID ;
       
  1761 		    entry.iUserDefined = iWlanSid->At(2).iUserDefined;
       
  1762 			break;
       
  1763 			}
       
  1764 		// Add the entry into the list, at the next empty location
       
  1765 		list->AddEntryL(entry);
       
  1766 		}
       
  1767 	// Store the streamed list and the client ID
       
  1768 	CListReadAllAttempt* read=CListReadAllAttempt::NewL(*aClient,aTsyReqHandle);
       
  1769 	CleanupStack::PushL(read);
       
  1770 	
       
  1771 	read->iListBuf = list->StoreLC();
       
  1772 	CleanupStack::Pop(); // pop the CBufBase allocated by StoreLC
       
  1773 	
       
  1774 	iGetWlanSIDsData->AppendL(read);
       
  1775 	CleanupStack::Pop(); // pop the CListReadAllAttempt
       
  1776 	
       
  1777 	// return the CBufBase’s size to client
       
  1778 	*aBufSize=(read->iListBuf)->Size();
       
  1779 	
       
  1780 	// Complete first phase of list retrieval
       
  1781 	iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
       
  1782 	CleanupStack::PopAndDestroy(); // pop&destroy list
       
  1783 	return KErrNone;
       
  1784 	}
       
  1785 
       
  1786 TInt CSimUsimR6::GetPreferredWlanSIDsPhase2(const TTsyReqHandle aTsyReqHandle, RMobilePhone::TClientId* aClient, TDes8* aBuf)
       
  1787 /**
       
  1788 * 2nd phase retrieval of the the Preferred Wlan SIDs list.
       
  1789 * @param aReqHandle   Handle to the request.
       
  1790 * @param aClient      Pointer to the client.
       
  1791 * @param aBuf Buffer  Containing the Preferred Wlan SIDs list.
       
  1792 */
       
  1793 	{
       
  1794 	CListReadAllAttempt* read=NULL;
       
  1795 	// Find the get preferred wlan SIDs from this client
       
  1796 	for (TInt i=0; i<iGetWlanSIDsData->Count(); ++i)
       
  1797 		{
       
  1798 		read = iGetWlanSIDsData->At(i);
       
  1799 		if ((read->iClient.iSessionHandle==aClient->iSessionHandle) &&
       
  1800 		    (read->iClient.iSubSessionHandle==aClient->iSubSessionHandle))
       
  1801 			{
       
  1802 			TPtr8 bufPtr((read->iListBuf)->Ptr(0));
       
  1803 			// Copy the streamed list to the client
       
  1804 			aBuf->Copy(bufPtr);
       
  1805 			delete read;
       
  1806 			iGetWlanSIDsData->Delete(i);
       
  1807 			iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
       
  1808 			return KErrNone;
       
  1809 			}
       
  1810 		}
       
  1811 	// Should handle error case of not finding the matching client from read all phase 1
       
  1812 	return KErrNotFound;
       
  1813 	}
       
  1814 
       
  1815 TInt CSimUsimR6::GetPreferredWlanSIDsCancel(const TTsyReqHandle aTsyReqHandle)
       
  1816 /**
       
  1817 * Cancel the request to retrieve the Preferred Wlan SIDs List.
       
  1818 * @param aTsyReqHandle handle to the request
       
  1819 */
       
  1820 	{
       
  1821 	LOGCALL1("CSimPhone::GetPreferredNetworksCancel");
       
  1822 	iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
       
  1823 	// Remove the read all attempt from iGetWlanSIDsData
       
  1824 	CListReadAllAttempt* read=NULL;
       
  1825 	for (TInt i=0; i<iGetWlanSIDsData->Count(); ++i)
       
  1826 		{
       
  1827 		read = iGetWlanSIDsData->At(i);
       
  1828 		if (read->iReqHandle == aTsyReqHandle)
       
  1829 			{
       
  1830 			delete read;
       
  1831 			iGetWlanSIDsData->Delete(i);
       
  1832 			break;
       
  1833 			}
       
  1834 		}
       
  1835 	iPhone->ReqCompleted(aTsyReqHandle,KErrCancel);
       
  1836 	LOGCALL1("CSimPhone::GetPreferredWlanSIDsCancel");
       
  1837 	return KErrNone;
       
  1838 	}
       
  1839 	
       
  1840 TInt CSimUsimR6::GetPreferredNetworksPhase1(const TTsyReqHandle aTsyReqHandle, RMobilePhone::TClientId* aClient, TInt* aBufSize)
       
  1841 /** 
       
  1842  * Tsy uses this API to retrieve the Preferred Networks of each line from phone, 
       
  1843  * store each Preferred Networks as a list entry,
       
  1844  * stream the list and then return size of this buffer to client.
       
  1845  * @param aReqHandle  Handle to the request.
       
  1846  * @param aClient     Pointer to the client.
       
  1847  * @param aBufSize    Size of the buffer the client has to allocate for the 2nd pahase.
       
  1848  */
       
  1849 	{
       
  1850 	TInt ret=KErrNone;
       
  1851 	TInt leaveCode=KErrNone;
       
  1852 	TRAP(leaveCode, ret=ProcessGetPreferredNetworksPhase1L(aTsyReqHandle, aClient, aBufSize););
       
  1853 	if (leaveCode != KErrNone)
       
  1854 		{
       
  1855 		iPhone->ReqCompleted(aTsyReqHandle,leaveCode);
       
  1856 		}
       
  1857 	return ret;
       
  1858 	}	
       
  1859 	
       
  1860 TInt CSimUsimR6::ProcessGetPreferredNetworksPhase1L(const TTsyReqHandle aTsyReqHandle, 
       
  1861 													 RMobilePhone::TClientId* aClient, 
       
  1862 													 TInt* aBufSize)
       
  1863 /**
       
  1864 * Retrieve stored Preferred Networks from USIM.
       
  1865 * Store each entry,stream the list and then return size of this buffer to client
       
  1866 * @param aReqHandle  Handle to the request.
       
  1867 * @param aClient     Pointer to the client.
       
  1868 * @param aBufSize    Size of the buffer the client has to allocate for the 2nd pahase.
       
  1869 */
       
  1870 	{
       
  1871 	CMobilePhoneStoredNetworkList* list=CMobilePhoneStoredNetworkList::NewL();
       
  1872 	CleanupStack::PushL(list);
       
  1873 	RMobilePhone::TMobilePreferredNetworkEntryV3 entry;
       
  1874 	// fill up an example list
       
  1875 	for (TInt index=0; index < SIMTSY_PHONE_NTWK_LIST_ENTRIES; index++)
       
  1876 		{
       
  1877 		switch (index)
       
  1878 			{
       
  1879 		case 0:
       
  1880 			entry.iAccess = iPreferredNetworks->At(0).iAccess;
       
  1881 			entry.iUserDefined = iPreferredNetworks->At(0).iUserDefined;
       
  1882 			entry.iCountryCode = iPreferredNetworks->At(0).iCountryCode;
       
  1883 			entry.iNetworkId = iPreferredNetworks->At(0).iNetworkId;
       
  1884 			break;
       
  1885 		case 1:
       
  1886 			entry.iAccess = iPreferredNetworks->At(1).iAccess;
       
  1887 			entry.iUserDefined = iPreferredNetworks->At(1).iUserDefined;
       
  1888 			entry.iCountryCode = iPreferredNetworks->At(1).iCountryCode;
       
  1889 			entry.iNetworkId = iPreferredNetworks->At(1).iNetworkId;
       
  1890 			break;
       
  1891 		case 2:
       
  1892 		default:
       
  1893 			entry.iAccess = iPreferredNetworks->At(2).iAccess;
       
  1894 			entry.iUserDefined = iPreferredNetworks->At(2).iUserDefined;
       
  1895 			entry.iCountryCode = iPreferredNetworks->At(2).iCountryCode;
       
  1896 			entry.iNetworkId = iPreferredNetworks->At(2).iNetworkId;
       
  1897 			break;
       
  1898 		case 3:
       
  1899 			entry.iAccess = iPreferredNetworks->At(3).iAccess;
       
  1900 			entry.iUserDefined = iPreferredNetworks->At(3).iUserDefined;
       
  1901 			entry.iCountryCode = iPreferredNetworks->At(3).iCountryCode;
       
  1902 			entry.iNetworkId = iPreferredNetworks->At(3).iNetworkId;
       
  1903 			break;
       
  1904 			}
       
  1905 		// Add the entry into the list, at the next empty location
       
  1906 		list->AddEntryL(entry);
       
  1907 		}
       
  1908 	// Store the streamed list and the client ID
       
  1909 	CListReadAllAttempt* read=CListReadAllAttempt::NewL(*aClient,aTsyReqHandle);
       
  1910 	CleanupStack::PushL(read);
       
  1911 	
       
  1912 	read->iListBuf = list->StoreLC();
       
  1913 	CleanupStack::Pop(); // pop the CBufBase allocated by StoreLC
       
  1914 	
       
  1915 	iGetPreferredNetworks->AppendL(read);
       
  1916 	CleanupStack::Pop(); // pop the CListReadAllAttempt
       
  1917 	
       
  1918 	// return the CBufBase’s size to client
       
  1919 	*aBufSize=(read->iListBuf)->Size();
       
  1920 	
       
  1921 	iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
       
  1922 	CleanupStack::PopAndDestroy(); // pop&destroy list
       
  1923 	return KErrNone;
       
  1924 	}
       
  1925 
       
  1926 TInt CSimUsimR6::GetPreferredNetworksPhase2(const TTsyReqHandle aTsyReqHandle, RMobilePhone::TClientId* aClient, TDes8* aBuf)
       
  1927 /**
       
  1928 * 2nd phase retrieval of the the Preferred Networks list.
       
  1929 * @param aReqHandle   Handle to the request.
       
  1930 * @param aClient      Pointer to the client.
       
  1931 * @param aBuf Buffer  Containing the Preferred Networks list.
       
  1932 */
       
  1933 	{
       
  1934 	CListReadAllAttempt* read=NULL;
       
  1935 	// Find the get detected network attempt from this client
       
  1936 	for (TInt i=0; i<iGetPreferredNetworks->Count(); ++i)
       
  1937 		{
       
  1938 		read = iGetPreferredNetworks->At(i);
       
  1939 		if ((read->iClient.iSessionHandle==aClient->iSessionHandle) &&
       
  1940 		    (read->iClient.iSubSessionHandle==aClient->iSubSessionHandle))
       
  1941 			{
       
  1942 			TPtr8 bufPtr((read->iListBuf)->Ptr(0));
       
  1943 			// Copy the streamed list to the client
       
  1944 			aBuf->Copy(bufPtr);
       
  1945 			delete read;
       
  1946 			iGetPreferredNetworks->Delete(i);
       
  1947 			iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
       
  1948 			return KErrNone;
       
  1949 			}
       
  1950 		}
       
  1951 	// Should handle error case of not finding the matching client from read all phase 1
       
  1952 	return KErrNotFound;
       
  1953 	}
       
  1954 
       
  1955 TInt CSimUsimR6::GetPreferredNetworksCancel(const TTsyReqHandle aTsyReqHandle)
       
  1956 /**
       
  1957 * Cancel the request to retrieve the Preferred Networks List.
       
  1958 * @param aTsyReqHandle handle to the request
       
  1959 */
       
  1960 	{
       
  1961 	LOGCALL1("CSimPhone::GetPreferredNetworksCancel");
       
  1962 	iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
       
  1963 	CListReadAllAttempt* read=NULL;
       
  1964 	for (TInt i=0; i<iGetPreferredNetworks->Count(); ++i)
       
  1965 		{
       
  1966 		read = iGetPreferredNetworks->At(i);
       
  1967 		if (read->iReqHandle == aTsyReqHandle)
       
  1968 			{
       
  1969 			delete read;
       
  1970 			iGetPreferredNetworks->Delete(i);
       
  1971 			break;
       
  1972 			}
       
  1973 		}
       
  1974 	iPhone->ReqCompleted(aTsyReqHandle,KErrCancel);
       
  1975 	LOGCALL1("CSimPhone::GetPreferredNetworksCancel");
       
  1976 	return KErrNone;
       
  1977 	}
       
  1978 		
       
  1979 TInt CSimUsimR6::StorePreferredNetworksList(const TTsyReqHandle aTsyReqHandle, TDes8* aBuffer)
       
  1980 /**
       
  1981  * This API is used by the TSY to store the Preferred Networks List sent by the Client.
       
  1982  * @param aReqHandle	The request handle associated with this request.
       
  1983  * @param aBuffer		This contains the Preferred Networks List.
       
  1984  * @return TInt			Standard error value.
       
  1985  */
       
  1986 	{
       
  1987 	TInt ret=KErrNone;
       
  1988 	TInt leaveCode=KErrNone;
       
  1989 	TRAP(leaveCode, ret=ProcessStorePreferredNetworksListL(aTsyReqHandle, aBuffer););
       
  1990 	if (leaveCode != KErrNone)
       
  1991 		{
       
  1992 		iPhone->ReqCompleted(aTsyReqHandle,leaveCode);
       
  1993 		}
       
  1994 	return ret;
       
  1995 	};
       
  1996 
       
  1997 TInt CSimUsimR6::ProcessStorePreferredNetworksListL(TTsyReqHandle aTsyReqHandle, TDes8* aBuffer)
       
  1998 /**
       
  1999  * This API is used by the TSY to process the Preferred Networks List sent by the Client and verify it.
       
  2000  * @param aReqHandle	The request handle associated with this request.
       
  2001  * @param aBuffer		This contains the Preferred Networks List.
       
  2002  * @return TInt			Standard error value.
       
  2003  */
       
  2004 	{
       
  2005 	CMobilePhoneStoredNetworkList* list=CMobilePhoneStoredNetworkList::NewL();
       
  2006 	CleanupStack::PushL(list);
       
  2007 	
       
  2008 	list->RestoreL(*aBuffer);
       
  2009 
       
  2010 	RMobilePhone::TMobilePreferredNetworkEntryV3 entry;
       
  2011 
       
  2012 	if (list->Enumerate() > SIMTSY_PHONE_NTWK_LIST_ENTRIES)
       
  2013 		{
       
  2014 		iPhone->ReqCompleted(aTsyReqHandle,KErrNoMemory);
       
  2015 		CleanupStack::PopAndDestroy(); // list
       
  2016 		return KErrNone;
       
  2017 		}
       
  2018 	TInt error=KErrCorrupt;
       
  2019 	TInt ret;
       
  2020 	for (TInt i=0; i<SIMTSY_PHONE_NTWK_LIST_ENTRIES; ++i)
       
  2021 		{
       
  2022 		TRAP(ret,entry=list->GetEntryL(i));
       
  2023 		if (ret != KErrNone)
       
  2024 			{
       
  2025 			break;
       
  2026 			}
       
  2027 			switch(i)
       
  2028 				{
       
  2029 			case 0:
       
  2030 				if((entry.iAccess == iPreferredNetworks->At(0).iAccess ||
       
  2031 				entry.iAccess == iPreferredNetworks->At(1).iAccess ||
       
  2032 				entry.iAccess == iPreferredNetworks->At(2).iAccess ||
       
  2033 				entry.iAccess == iPreferredNetworks->At(3).iAccess ) && 
       
  2034 				(entry.iUserDefined == iPreferredNetworks->At(0).iUserDefined ||
       
  2035 				entry.iUserDefined == iPreferredNetworks->At(1).iUserDefined ||
       
  2036 				entry.iUserDefined == iPreferredNetworks->At(2).iUserDefined ||
       
  2037 				entry.iUserDefined == iPreferredNetworks->At(3).iUserDefined) && 
       
  2038 			    (entry.iCountryCode == iPreferredNetworks->At(0).iCountryCode  ||
       
  2039 				entry.iCountryCode == iPreferredNetworks->At(1).iCountryCode  ||
       
  2040 				entry.iCountryCode == iPreferredNetworks->At(2).iCountryCode  ||
       
  2041 				entry.iCountryCode == iPreferredNetworks->At(3).iCountryCode ) &&
       
  2042 				(entry.iNetworkId == iPreferredNetworks->At(0).iNetworkId ||
       
  2043 				entry.iNetworkId == iPreferredNetworks->At(1).iNetworkId || 
       
  2044 				entry.iNetworkId == iPreferredNetworks->At(2).iNetworkId || 
       
  2045 				entry.iNetworkId == iPreferredNetworks->At(3).iNetworkId ))
       
  2046 					{
       
  2047 					error  = KErrNone;
       
  2048 					}
       
  2049 				break;
       
  2050 			case 1:
       
  2051 				if((entry.iAccess == iPreferredNetworks->At(0).iAccess ||
       
  2052 				entry.iAccess == iPreferredNetworks->At(1).iAccess ||
       
  2053 				entry.iAccess == iPreferredNetworks->At(2).iAccess ||
       
  2054 				entry.iAccess == iPreferredNetworks->At(3).iAccess ) && 
       
  2055 				(entry.iUserDefined == iPreferredNetworks->At(0).iUserDefined ||
       
  2056 				entry.iUserDefined == iPreferredNetworks->At(1).iUserDefined ||
       
  2057 				entry.iUserDefined == iPreferredNetworks->At(2).iUserDefined ||
       
  2058 				entry.iUserDefined == iPreferredNetworks->At(3).iUserDefined) && 
       
  2059 			    (entry.iCountryCode == iPreferredNetworks->At(0).iCountryCode  ||
       
  2060 				entry.iCountryCode == iPreferredNetworks->At(1).iCountryCode  ||
       
  2061 				entry.iCountryCode == iPreferredNetworks->At(2).iCountryCode  ||
       
  2062 				entry.iCountryCode == iPreferredNetworks->At(3).iCountryCode ) &&
       
  2063 				(entry.iNetworkId == iPreferredNetworks->At(0).iNetworkId ||
       
  2064 				entry.iNetworkId == iPreferredNetworks->At(1).iNetworkId || 
       
  2065 				entry.iNetworkId == iPreferredNetworks->At(2).iNetworkId || 
       
  2066 				entry.iNetworkId == iPreferredNetworks->At(3).iNetworkId ))
       
  2067 					{
       
  2068 					error  = KErrNone;
       
  2069 					}
       
  2070 				break;
       
  2071 			case 2:
       
  2072 				if((entry.iAccess == iPreferredNetworks->At(0).iAccess ||
       
  2073 				entry.iAccess == iPreferredNetworks->At(1).iAccess ||
       
  2074 				entry.iAccess == iPreferredNetworks->At(2).iAccess ||
       
  2075 				entry.iAccess == iPreferredNetworks->At(3).iAccess ) && 
       
  2076 				(entry.iUserDefined == iPreferredNetworks->At(0).iUserDefined ||
       
  2077 				entry.iUserDefined == iPreferredNetworks->At(1).iUserDefined ||
       
  2078 				entry.iUserDefined == iPreferredNetworks->At(2).iUserDefined ||
       
  2079 				entry.iUserDefined == iPreferredNetworks->At(3).iUserDefined) && 
       
  2080 			    (entry.iCountryCode == iPreferredNetworks->At(0).iCountryCode  ||
       
  2081 				entry.iCountryCode == iPreferredNetworks->At(1).iCountryCode  ||
       
  2082 				entry.iCountryCode == iPreferredNetworks->At(2).iCountryCode  ||
       
  2083 				entry.iCountryCode == iPreferredNetworks->At(3).iCountryCode ) &&
       
  2084 				(entry.iNetworkId == iPreferredNetworks->At(0).iNetworkId ||
       
  2085 				entry.iNetworkId == iPreferredNetworks->At(1).iNetworkId || 
       
  2086 				entry.iNetworkId == iPreferredNetworks->At(2).iNetworkId || 
       
  2087 				entry.iNetworkId == iPreferredNetworks->At(3).iNetworkId ))
       
  2088 					{
       
  2089 					error  = KErrNone;
       
  2090 					}
       
  2091 				break;
       
  2092 			case 3:
       
  2093 			default:
       
  2094 				if((entry.iAccess == iPreferredNetworks->At(0).iAccess ||
       
  2095 				entry.iAccess == iPreferredNetworks->At(1).iAccess ||
       
  2096 				entry.iAccess == iPreferredNetworks->At(2).iAccess ||
       
  2097 				entry.iAccess == iPreferredNetworks->At(3).iAccess ) && 
       
  2098 				(entry.iUserDefined == iPreferredNetworks->At(0).iUserDefined ||
       
  2099 				entry.iUserDefined == iPreferredNetworks->At(1).iUserDefined ||
       
  2100 				entry.iUserDefined == iPreferredNetworks->At(2).iUserDefined ||
       
  2101 				entry.iUserDefined == iPreferredNetworks->At(3).iUserDefined) && 
       
  2102 			    (entry.iCountryCode == iPreferredNetworks->At(0).iCountryCode  ||
       
  2103 				entry.iCountryCode == iPreferredNetworks->At(1).iCountryCode  ||
       
  2104 				entry.iCountryCode == iPreferredNetworks->At(2).iCountryCode  ||
       
  2105 				entry.iCountryCode == iPreferredNetworks->At(3).iCountryCode ) &&
       
  2106 				(entry.iNetworkId == iPreferredNetworks->At(0).iNetworkId ||
       
  2107 				entry.iNetworkId == iPreferredNetworks->At(1).iNetworkId || 
       
  2108 				entry.iNetworkId == iPreferredNetworks->At(2).iNetworkId || 
       
  2109 				entry.iNetworkId == iPreferredNetworks->At(3).iNetworkId ))
       
  2110 					{
       
  2111 					error  = KErrNone;
       
  2112 					}
       
  2113 				break;
       
  2114 			}
       
  2115 		}
       
  2116 	if(error==KErrNone)	
       
  2117 		{
       
  2118 		iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
       
  2119 		}
       
  2120 	else
       
  2121 		{
       
  2122 		iPhone->ReqCompleted(aTsyReqHandle,KErrCorrupt);
       
  2123 		}
       
  2124 	CleanupStack::PopAndDestroy(); // list
       
  2125 	return KErrNone;
       
  2126 	}
       
  2127 	
       
  2128 TInt CSimUsimR6::NotifyStorePreferredNetworksListChange(TTsyReqHandle aTsyReqHandle)
       
  2129 /**
       
  2130  * This API is used by the TSY to complete the Preferred Networks List change
       
  2131  * notification request posted by the client.
       
  2132  * 
       
  2133  * @param aReqHandle	The request handle associated with this request.
       
  2134  * @return TInt			Standard error value.
       
  2135  */
       
  2136 	{
       
  2137 	iNotifyPreferredNetworksChangePending=ETrue;
       
  2138 	iNotifyPreferredNetworksReqHandle=aTsyReqHandle;
       
  2139 	return KErrNone;
       
  2140 	}
       
  2141 	
       
  2142 TInt CSimUsimR6::NotifyStorePreferredNetworksListChangeCancel(TTsyReqHandle /**aTsyReqHandle*/)
       
  2143 /**
       
  2144  * This API is used by TSY to cancel any NotifyPreferredNetworksListChange outstanding requests 
       
  2145 
       
  2146  * @return TInt			Standard error value.
       
  2147  */
       
  2148 	{
       
  2149 	iNotifyPreferredNetworksChangePending=EFalse;
       
  2150 	iPhone->ReqCompleted(iNotifyPreferredNetworksReqHandle,KErrCancel);
       
  2151 	return KErrNone;
       
  2152 	}
       
  2153 	
       
  2154 TInt CSimUsimR6::SetGbaBootstrapParams(const TTsyReqHandle aTsyReqHandle, TDes8* aPckg, const RMobilePhone::TAID* aAID)
       
  2155 	{
       
  2156 	
       
  2157 	RMobilePhone::TBsfDataV8Pckg *bsfDataV8Pckg = reinterpret_cast<RMobilePhone::TBsfDataV8Pckg*> (aPckg);
       
  2158 	RMobilePhone::TBsfDataV8 &bsfDataV8 = (*bsfDataV8Pckg) ();
       
  2159 	if((aAID == NULL) || (*aAID == iGBAAuthInfoList->At(iListIndex).iAID))
       
  2160 		{
       
  2161 		iSetGBABootstrapParams.iNotifyPending = ETrue;
       
  2162 		iSetGBABootstrapParams.iNotifyHandle = aTsyReqHandle;
       
  2163 		iSetGBABootstrapParams.iNotifyData = &bsfDataV8;
       
  2164 		}
       
  2165 	return KErrNone;
       
  2166 	}
       
  2167 
       
  2168 TInt CSimUsimR6::SetGbaBootstrapParamsCancel(const TTsyReqHandle /**aTsyReqHandle*/)
       
  2169 	{
       
  2170 	if(iSetGBABootstrapParams.iNotifyPending)
       
  2171 		{
       
  2172 		iSetGBABootstrapParams.iNotifyPending=EFalse;
       
  2173 		iPhone->ReqCompleted(iSetGBABootstrapParams.iNotifyHandle,KErrCancel);
       
  2174 		}
       
  2175 	else
       
  2176 		{
       
  2177 		iPhone->ReqCompleted(iSetGBABootstrapParams.iNotifyHandle,KErrNone);
       
  2178 		}
       
  2179 	return KErrNone;
       
  2180 	}
       
  2181 
       
  2182 
       
  2183 TInt CSimUsimR6::NotifyAuthenticateDataChange(TTsyReqHandle aTsyReqHandle, TDes8* aPckg)
       
  2184 	{
       
  2185 	RMobilePhone::TAuthInfoV8Pckg *authInfV8Pckg = reinterpret_cast<RMobilePhone::TAuthInfoV8Pckg*> (aPckg);
       
  2186 	RMobilePhone::TAuthInfoV8 &authInfoV8 = (*authInfV8Pckg)();
       
  2187 	iNotifyAuthDataChange.iNotifyPending = ETrue;
       
  2188 	iNotifyAuthDataChange.iNotifyHandle = aTsyReqHandle;
       
  2189 	iNotifyAuthDataChange.iNotifyData = &authInfoV8;
       
  2190 	return KErrNone;
       
  2191 	}
       
  2192 
       
  2193 TInt CSimUsimR6::NotifyAuthenticateDataChangeCancel(const TTsyReqHandle /**aTsyReqHandle*/)
       
  2194 	{
       
  2195 	if(iNotifyAuthDataChange.iNotifyPending)
       
  2196 		{
       
  2197 		iNotifyAuthDataChange.iNotifyPending=EFalse;
       
  2198 		iPhone->ReqCompleted(iNotifyAuthDataChange.iNotifyHandle,KErrCancel);
       
  2199 		}
       
  2200 	else
       
  2201 		{
       
  2202 		iPhone->ReqCompleted(iNotifyAuthDataChange.iNotifyHandle,KErrNone);
       
  2203 		}
       
  2204 	return KErrNone;
       
  2205 	}
       
  2206 
       
  2207 TInt CSimUsimR6::GetAuthenticationParams(const TTsyReqHandle aTsyReqHandle, TDes8* aPckg, TDes8* aPckg2)
       
  2208 	{
       
  2209 	RMobilePhone::TAuthInfoV8Pckg *authInfoV8Pckg = reinterpret_cast<RMobilePhone::TAuthInfoV8Pckg*> (aPckg);
       
  2210 	RMobilePhone::TAuthInfoV8 &authInfoV8 = (*authInfoV8Pckg)();
       
  2211 	if ( authInfoV8.iAID == iGBAAuthInfoList->At(iListIndex).iAID ||
       
  2212 			authInfoV8.iAID == iMBMSInfoList->At(iListIndex).iAID )
       
  2213 		{
       
  2214 		iGetAuthParams.iNotifyPending = ETrue;
       
  2215 		iGetAuthParams.iNotifyHandle = aTsyReqHandle;
       
  2216 		if ( authInfoV8.iData == RMobilePhone::EGbaBootstrapParams)
       
  2217 			{
       
  2218 			RMobilePhone::TGbaBootstrapParamsV8Pckg
       
  2219 					*gbaBootstrapV8Pckg = reinterpret_cast<RMobilePhone::TGbaBootstrapParamsV8Pckg*> (aPckg2);
       
  2220 			RMobilePhone::TGbaBootstrapParamsV8 &gbaBootstrapV8 = (*gbaBootstrapV8Pckg) ();
       
  2221 			iGetAuthParams.iNotifyData = &gbaBootstrapV8;
       
  2222 			return KErrNone;
       
  2223 			}
       
  2224 		if ( authInfoV8.iData == RMobilePhone::EMbmsMuk)
       
  2225 			{
       
  2226 			RMobilePhone::TMbmsUserKeyV8Pckg
       
  2227 					*mbmsUserKeyV8Pckg = reinterpret_cast<RMobilePhone::TMbmsUserKeyV8Pckg*> (aPckg2);
       
  2228 			RMobilePhone::TMbmsUserKeyV8 &mbmsUserKeyV8 = (*mbmsUserKeyV8Pckg) ();
       
  2229 
       
  2230 			iGetAuthParams.iNotifyData = &mbmsUserKeyV8;
       
  2231 			return KErrNone;
       
  2232 			}
       
  2233 		iGetAuthParams.iNotifyData = NULL;
       
  2234 		}
       
  2235 	else
       
  2236 		{
       
  2237 		iGetAuthParams.iNotifyPending = ETrue;
       
  2238 		iGetAuthParams.iNotifyHandle = aTsyReqHandle;
       
  2239 		iGetAuthParams.iNotifyData = NULL;
       
  2240 		}
       
  2241 	return KErrNone;
       
  2242 	}
       
  2243 
       
  2244 TInt CSimUsimR6::GetAuthenticationParamsCancel(const TTsyReqHandle /**aTsyReqHandle*/)
       
  2245 	{
       
  2246 	if(iGetAuthParams.iNotifyPending)
       
  2247 		{
       
  2248 		iGetAuthParams.iNotifyPending=EFalse;
       
  2249 		iPhone->ReqCompleted(iGetAuthParams.iNotifyHandle,KErrCancel);
       
  2250 		}
       
  2251 	else
       
  2252 		{
       
  2253 		iPhone->ReqCompleted(iGetAuthParams.iNotifyHandle,KErrNone);
       
  2254 		}
       
  2255 	return KErrNone;
       
  2256 	}
       
  2257 
       
  2258 TInt CSimUsimR6::GetAuthenticationListPhase1(const TTsyReqHandle aTsyReqHandle,
       
  2259 		CRetrieveMobilePhoneAuthenticationIds::TAuthRequestData* aRequest,TInt* aBufSize)
       
  2260 	/**
       
  2261 	1st phase retrieval of the the call waiting status list
       
  2262 	@param aReqHandle Handle to the request
       
  2263 	@param aReqData information about the request
       
  2264 	@param aBufSize Size of the buffer the client has to allocate for the 2nd pahase
       
  2265   	*/
       
  2266 	{
       
  2267 	TInt ret=KErrNone;
       
  2268 	TInt leaveCode=KErrNone;
       
  2269 	if (aRequest->iAuthInfo.iData==RMobilePhone::EGbaNafIdList)
       
  2270 		{
       
  2271 		iAuthType = EGba;
       
  2272 		TRAP(leaveCode, ret=ProcessGetGbaPhase1L(aTsyReqHandle,& (aRequest->iClient),aBufSize));
       
  2273 		}
       
  2274 	else if(aRequest->iAuthInfo.iData==RMobilePhone::EMbmsMskIdList)
       
  2275 		{
       
  2276 		iAuthType = EMbms;
       
  2277 		TRAP(leaveCode, ret=ProcessGetMbmsPhase1L(aTsyReqHandle,& (aRequest->iClient),aBufSize));
       
  2278 		}
       
  2279 	else
       
  2280 		{
       
  2281 		leaveCode = KErrCorrupt;
       
  2282 		}
       
  2283 	if (leaveCode != KErrNone)
       
  2284 		{
       
  2285 		iPhone->ReqCompleted(aTsyReqHandle,leaveCode);
       
  2286 		}
       
  2287 	return ret;
       
  2288 	};
       
  2289 
       
  2290 TInt CSimUsimR6::ProcessGetGbaPhase1L(const TTsyReqHandle aTsyReqHandle,
       
  2291 		RMobilePhone::TClientId* aClientId,TInt* aBufSize)
       
  2292 /** Retrieve call waiting status of each line from phone, 
       
  2293  store each CB status response as a list entry,
       
  2294  stream the list and then return size of this buffer to client
       
  2295  @param aReqHandle Handle to the request
       
  2296  @param aReqData information about the request
       
  2297  @param aBufSize Size of the buffer the client has to allocate for the 2nd pahase
       
  2298  */
       
  2299 	{
       
  2300 	// read the list, store its content and then return size of this buffer to client
       
  2301 	CMobilePhoneGbaNafIdList* list=CMobilePhoneGbaNafIdList::NewL();
       
  2302 	CleanupStack::PushL(list);
       
  2303 	TInt maxList = iGbaNafList->Enumerate();
       
  2304 	if(maxList)
       
  2305 		{
       
  2306 		for (TInt i=0;i<maxList;i++)
       
  2307 			{
       
  2308 			list->AddEntryL(iGbaNafList->GetEntryL(i));
       
  2309 			}
       
  2310 		}
       
  2311 	else
       
  2312 		{
       
  2313 		CleanupStack::PopAndDestroy(list);
       
  2314 		*aBufSize = 10;
       
  2315 		iPhone->ReqCompleted(aTsyReqHandle,KErrCorrupt);
       
  2316 		return KErrNotFound;
       
  2317 		}
       
  2318 	// Store the streamed list and the client ID
       
  2319 	CListReadAllAttempt* read=CListReadAllAttempt::NewL(*(aClientId), aTsyReqHandle);
       
  2320 	CleanupStack::PushL(read);
       
  2321 
       
  2322 	read->iListBuf = list->StoreLC();
       
  2323 	CleanupStack::Pop(); // pop the CBufFlat allocated by StoreLC
       
  2324 
       
  2325 	iAuthListInfo->AppendL(read);
       
  2326 	CleanupStack::Pop(); // pop the CListReadAllAttempt
       
  2327 
       
  2328 	// return the CBufFlat’s size to client
       
  2329 	*aBufSize=(read->iListBuf)->Size();
       
  2330 
       
  2331 	CleanupStack::PopAndDestroy(list);
       
  2332 	
       
  2333 	iPhone->ReqCompleted(aTsyReqHandle, KErrNone);
       
  2334 	return KErrNone;
       
  2335 	}
       
  2336 
       
  2337 TInt CSimUsimR6::ProcessGetMbmsPhase1L(const TTsyReqHandle aTsyReqHandle,
       
  2338 		RMobilePhone::TClientId* aClientId,TInt* aBufSize)
       
  2339 	{
       
  2340 	CMobilePhoneMbmsMskIdList* list=CMobilePhoneMbmsMskIdList::NewL();
       
  2341 	CleanupStack::PushL(list);
       
  2342 	TInt maxList;
       
  2343 	if(iAuthType == EGba)
       
  2344 		{
       
  2345 		maxList = iGbaNafList->Enumerate();
       
  2346 		}
       
  2347 	else
       
  2348 		{
       
  2349 		maxList = iMbmsMskList->Enumerate();
       
  2350 		}
       
  2351 	if(maxList)
       
  2352 		{
       
  2353 		for (TInt i=0;i<maxList;i++)
       
  2354 			{
       
  2355 			list->AddEntryL(iMbmsMskList->GetEntryL(i));
       
  2356 			}
       
  2357 		}
       
  2358 	else
       
  2359 		{
       
  2360 		CleanupStack::PopAndDestroy(list);
       
  2361 		*aBufSize = 10;
       
  2362 		iPhone->ReqCompleted(aTsyReqHandle,KErrCorrupt);
       
  2363 		return KErrNotFound;
       
  2364 		}
       
  2365 	
       
  2366 	// Store the streamed list and the client ID
       
  2367 	CListReadAllAttempt* read=CListReadAllAttempt::NewL(*(aClientId), aTsyReqHandle);
       
  2368 	CleanupStack::PushL(read);
       
  2369 
       
  2370 	read->iListBuf = list->StoreLC();
       
  2371 	CleanupStack::Pop(); // pop the CBufFlat allocated by StoreLC
       
  2372 
       
  2373 	iAuthListInfo->AppendL(read);
       
  2374 	CleanupStack::Pop(); // pop the CListReadAllAttempt
       
  2375 
       
  2376 	// return the CBufFlat’s size to client
       
  2377 	*aBufSize=(read->iListBuf)->Size();
       
  2378 
       
  2379 	CleanupStack::PopAndDestroy(list);
       
  2380 	
       
  2381 	iPhone->ReqCompleted(aTsyReqHandle, KErrNone);
       
  2382 	return KErrNone;
       
  2383 	}
       
  2384 
       
  2385 TInt CSimUsimR6::GetAuthenticationListPhase2(const TTsyReqHandle aTsyReqHandle, RMobilePhone::TClientId* aId,TDes8* aBuf)
       
  2386 /**
       
  2387  *	 2nd phase retrieval of the the call waiting status list
       
  2388  @param aReqHandle Handle to the request
       
  2389  @param aClient Ponter to the client
       
  2390  @param aBuf Buffer containiong the call waiting status list
       
  2391  */
       
  2392 	{
       
  2393 	CListReadAllAttempt* read=NULL;
       
  2394 	TBool tPosScen = ETrue;
       
  2395 	
       
  2396 	// Find the Authentication information for the client
       
  2397 	if ( iAuthType == EGba)
       
  2398 		{
       
  2399 		for (TInt i=0; i<iAuthListInfo->Count (); ++i)
       
  2400 			{
       
  2401 			read = iAuthListInfo->At (i);
       
  2402 			if ( (read->iClient.iSessionHandle==aId->iSessionHandle)&&(read->iClient.iSubSessionHandle==aId->iSubSessionHandle))
       
  2403 				{
       
  2404 				if ( tPosScen)
       
  2405 					{
       
  2406 					TPtr8 bufPtr((read->iListBuf)->Ptr (0));
       
  2407 					// Copy the streamed list to the client
       
  2408 					aBuf->Copy (bufPtr);
       
  2409 					}
       
  2410 				delete read;
       
  2411 				iAuthListInfo->Delete (i);
       
  2412 				User::After (300000);
       
  2413 				iPhone->ReqCompleted (aTsyReqHandle, KErrNone);
       
  2414 				return KErrNone;
       
  2415 				}
       
  2416 			}
       
  2417 		}
       
  2418 	else // authtype = EMbms
       
  2419 		{
       
  2420 		for (TInt i=0; i<iAuthListInfo->Count (); ++i)
       
  2421 			{
       
  2422 			read = iAuthListInfo->At (i);
       
  2423 			if ( (read->iClient.iSessionHandle==aId->iSessionHandle)&&(read->iClient.iSubSessionHandle==aId->iSubSessionHandle))
       
  2424 				{
       
  2425 				if ( tPosScen)
       
  2426 					{
       
  2427 					TPtr8 bufPtr((read->iListBuf)->Ptr (0));
       
  2428 					// Copy the streamed list to the client
       
  2429 					aBuf->Copy (bufPtr);
       
  2430 					}
       
  2431 				delete read;
       
  2432 				iAuthListInfo->Delete (i);
       
  2433 				User::After (300000);
       
  2434 				iPhone->ReqCompleted (aTsyReqHandle, KErrNone);
       
  2435 				return KErrNone;
       
  2436 				}
       
  2437 			}
       
  2438 		}
       
  2439 	// Should handle error case of not finding the matching client from read phase 1
       
  2440 	return KErrNotFound;
       
  2441 	}
       
  2442 
       
  2443 TInt CSimUsimR6::GetAuthenticationListCancel(const TTsyReqHandle aTsyReqHandle)
       
  2444 	{
       
  2445 	// Remove the read all attempt from iAuthReadAll
       
  2446 	
       
  2447 	CListReadAllAttempt* read=NULL;
       
  2448 	for (TInt i=0; i<iAuthListInfo->Count(); ++i)
       
  2449 		{
       
  2450 		read = iAuthListInfo->At(i);
       
  2451 		if (read->iReqHandle == aTsyReqHandle)
       
  2452 			{
       
  2453 			delete read;
       
  2454 			iAuthListInfo->Delete(i);
       
  2455 			break;
       
  2456 			}
       
  2457 		}
       
  2458 	iPhone->ReqCompleted(aTsyReqHandle,KErrCancel);
       
  2459 	return KErrNone;
       
  2460 	}
       
  2461 	
       
  2462 TInt CSimUsimR6::RandTime()
       
  2463 /** Function that generates time(in seconds) at random for the SimTSY 
       
  2464  * Maximum of ten seconds; zero seconds also included just to simulate the 
       
  2465  * synchronous call scenario 
       
  2466  */
       
  2467 	{
       
  2468 	TInt ranT= Math::Random()%10; 
       
  2469 	return(ranT);
       
  2470 	}
       
  2471 
       
  2472 
       
  2473