196 pTable = NULL; |
196 pTable = NULL; |
197 LOGPHONE2("Failed to populate %s table in simtsy", &aLookup); |
197 LOGPHONE2("Failed to populate %s table in simtsy", &aLookup); |
198 } |
198 } |
199 } |
199 } |
200 |
200 |
|
201 |
|
202 |
|
203 void CSimPhone::SetTestNumberAndReadConfigurationFileL() |
|
204 { |
|
205 TInt testNumber; |
|
206 User::LeaveIfError(GetTestNumber(testNumber)); |
|
207 iSectionName.Format(KSectionNameFormat,testNumber); |
|
208 |
|
209 delete iConfigFile; |
|
210 iConfigFile = NULL; |
|
211 |
|
212 TRAPD(err, iConfigFile = CTestConfig::NewLC(iFs, KConfigFileDir, KConfigFilename); CleanupStack::Pop(iConfigFile)); |
|
213 if( err == KErrNone && iConfigFile->Section(iSectionName) != NULL ) |
|
214 { |
|
215 iConfigSection = iConfigFile->Section(iSectionName); |
|
216 } |
|
217 else |
|
218 { |
|
219 LOGPHONE2("Section for requested test number (%d) not found in the Config File",testNumber); |
|
220 delete iConfigFile; |
|
221 iConfigFile = NULL; |
|
222 |
|
223 User::Leave(KErrNotFound); |
|
224 } |
|
225 |
|
226 User::LeaveIfError(SetTestNumberInUse(testNumber)); |
|
227 } |
|
228 |
201 void CSimPhone::ConstructL() |
229 void CSimPhone::ConstructL() |
202 /** |
230 /** |
203 * 2 Phase Construction (Second phase) |
231 * 2 Phase Construction (Second phase) |
204 * Loads the WINS Physical and Logical Serial Device Drivers. C32 loads the non-WINS |
232 * Loads the WINS Physical and Logical Serial Device Drivers. C32 loads the non-WINS |
205 * serial drivers, so we don't have to worry about these. |
233 * serial drivers, so we don't have to worry about these. |
212 TInt r=User::LoadPhysicalDevice(PDD_NAME); |
240 TInt r=User::LoadPhysicalDevice(PDD_NAME); |
213 r=User::LoadLogicalDevice(LDD_NAME); |
241 r=User::LoadLogicalDevice(LDD_NAME); |
214 #endif |
242 #endif |
215 |
243 |
216 LOGPHONE1("Starting to Load and Parse the Config File"); |
244 LOGPHONE1("Starting to Load and Parse the Config File"); |
217 (void)User::LeaveIfError(iFs.Connect()); |
245 |
218 iConfigFile=CTestConfig::NewLC(iFs,KConfigFileDir,KConfigFilename); |
246 User::LeaveIfError(iFs.Connect()); |
219 |
247 |
220 TInt testNumber; |
248 SetTestNumberAndReadConfigurationFileL(); |
221 (void)User::LeaveIfError(GetTestNumber(testNumber)); |
249 |
222 iSectionName.Format(KSectionNameFormat,testNumber); |
|
223 if(iConfigFile->Section(iSectionName)==NULL) |
|
224 { |
|
225 LOGPHONE2("Section for requested test number (%d) not found in the Config File",testNumber); |
|
226 CleanupStack::Pop(); |
|
227 User::Leave(KErrNotFound); |
|
228 } |
|
229 else |
|
230 { |
|
231 (void)User::LeaveIfError(SetTestNumberInUse(testNumber)); |
|
232 } |
|
233 CleanupStack::Pop(); // iConfigFile pointer is safely stored as a member variable |
|
234 |
|
235 CSimTsyMode::InitL(this); |
250 CSimTsyMode::InitL(this); |
236 |
251 |
237 iReduceTimers = CSimReduceTimers::NewL(); |
252 iReduceTimers = CSimReduceTimers::NewL(); |
238 |
253 |
239 InitPhoneStatus(); |
254 InitPhoneStatus(); |
291 } |
306 } |
292 } |
307 } |
293 |
308 |
294 TPtrC8 IMSI; |
309 TPtrC8 IMSI; |
295 iSubscriberId.iError = KErrNone; |
310 iSubscriberId.iError = KErrNone; |
296 const CTestConfigItem* item=CfgFile()->Item(KSubscriberId); |
311 const CTestConfigItem* itemSubscriberId=CfgFile()->Item(KSubscriberId); |
297 if (item) |
312 if( itemSubscriberId != NULL ) |
298 { |
313 { |
299 TInt ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,IMSI); |
314 TInt ret=CTestConfig::GetElement(itemSubscriberId->Value(),KStdDelimiter,0,IMSI); |
300 if(ret!=KErrNone) |
315 if( ret != KErrNone ) |
|
316 { |
301 LOGPARSERR("IMSI",ret,0,&KSubscriberId); |
317 LOGPARSERR("IMSI",ret,0,&KSubscriberId); |
|
318 } |
302 // coverity[check_return] |
319 // coverity[check_return] |
303 CTestConfig::GetElement(item->Value(),KStdDelimiter,1,iSubscriberId.iError); |
320 CTestConfig::GetElement(itemSubscriberId->Value(),KStdDelimiter,1,iSubscriberId.iError); |
304 iSubscriberId.iIMSI.Copy(IMSI); |
321 iSubscriberId.iIMSI.Copy(IMSI); |
305 } |
322 } |
306 else |
323 else |
|
324 { |
307 iSubscriberId.iIMSI.Copy(KSubscriberIdDefault); |
325 iSubscriberId.iIMSI.Copy(KSubscriberIdDefault); |
|
326 } |
308 |
327 |
309 iNtwkMode=(RMobilePhone::TMobilePhoneNetworkMode)CfgFile()->ItemValue(KNetworkMode,KNetworkModeDefault); |
328 iNtwkMode=(RMobilePhone::TMobilePhoneNetworkMode)CfgFile()->ItemValue(KNetworkMode,KNetworkModeDefault); |
310 //get phone id from config file |
329 //get phone id from config file |
311 GetPhoneIdAndCaps(); |
330 GetPhoneIdAndCaps(); |
312 |
331 |
330 iPhoneScEapMan = CSimSmartCardEapManager::NewL(this); |
349 iPhoneScEapMan = CSimSmartCardEapManager::NewL(this); |
331 |
350 |
332 iNetworkModeTimer = CSimTimer::NewL(this); |
351 iNetworkModeTimer = CSimTimer::NewL(this); |
333 //< Read in all network mode data |
352 //< Read in all network mode data |
334 TInt count = CfgFile()->ItemCount(KNetworkMode); |
353 TInt count = CfgFile()->ItemCount(KNetworkMode); |
335 item = NULL; |
354 const CTestConfigItem* item = NULL; |
336 for (TInt i = 0; i < count; ++i) |
355 for (TInt i = 0; i < count; ++i) |
337 { |
356 { |
338 item = CfgFile()->Item(KNetworkMode,i); |
357 item = CfgFile()->Item(KNetworkMode,i); |
339 if (!item) |
358 if (!item) |
340 break; |
359 break; |
386 iNtwkMode = initialNetworkMode.iNetworkMode; // set to new value if NetworkMode present in config.txt file |
405 iNtwkMode = initialNetworkMode.iNetworkMode; // set to new value if NetworkMode present in config.txt file |
387 iTimerCallBackNetworkMode.SetHandle(this); |
406 iTimerCallBackNetworkMode.SetHandle(this); |
388 iNetworkModeTimer->Start(initialNetworkMode.iDuration, &iTimerCallBackNetworkMode); |
407 iNetworkModeTimer->Start(initialNetworkMode.iDuration, &iTimerCallBackNetworkMode); |
389 } |
408 } |
390 // end of network mode simulation setup |
409 // end of network mode simulation setup |
391 |
410 iTestNumberObserver = CSimTestNumberObserver::NewL(*this); |
|
411 |
392 LOGPHONE1("Completed Loading and Parsing the Config File"); |
412 LOGPHONE1("Completed Loading and Parsing the Config File"); |
393 } |
413 } |
394 |
414 |
395 CSimReduceTimers* CSimPhone::GetReduceTimersSubject() |
415 CSimReduceTimers* CSimPhone::GetReduceTimersSubject() |
396 { |
416 { |
477 if (iSIMServiceTable != NULL) |
498 if (iSIMServiceTable != NULL) |
478 delete(iSIMServiceTable); |
499 delete(iSIMServiceTable); |
479 if (iUSIMServiceTableV8 != NULL) |
500 if (iUSIMServiceTableV8 != NULL) |
480 delete(iUSIMServiceTableV8); |
501 delete(iUSIMServiceTableV8); |
481 |
502 |
482 |
503 if( iPhBkStores != NULL ) |
483 if(iPhBkStores) |
|
484 { |
504 { |
485 TInt storeCount=iPhBkStores->Count(); |
505 TInt storeCount=iPhBkStores->Count(); |
486 for(TInt i=0;i<storeCount;i++) |
506 for(TInt i=0;i<storeCount;i++) |
487 { |
507 { |
488 iPhBkStores->At(i)->Close(); |
508 iPhBkStores->At(i)->Close(); |
489 } |
509 } |
490 delete iPhBkStores; |
510 delete iPhBkStores; |
491 } |
511 } |
492 |
512 if( iPhBkUSimStores != NULL ) |
493 if(iPhBkUSimStores) |
513 { |
494 { |
|
495 TInt storeCount=iPhBkUSimStores->Count(); |
514 TInt storeCount=iPhBkUSimStores->Count(); |
496 for(TInt i=0;i<storeCount;i++) |
515 for(TInt i=0;i<storeCount;i++) |
497 { |
516 { |
498 iPhBkUSimStores->At(i)->Close(); |
517 iPhBkUSimStores->At(i)->Close(); |
499 } |
518 } |
503 if(iONStore) |
522 if(iONStore) |
504 { |
523 { |
505 iONStore->Close(); |
524 iONStore->Close(); |
506 iONStore = NULL; |
525 iONStore = NULL; |
507 } |
526 } |
508 |
527 if( iNetworkModeArray != NULL ) |
509 |
|
510 if (iNetworkModeArray != NULL) |
|
511 { |
528 { |
512 iNetworkModeArray->Delete(0,iNetworkModeArray->Count()); |
529 iNetworkModeArray->Delete(0,iNetworkModeArray->Count()); |
513 delete iNetworkModeArray; |
530 delete iNetworkModeArray; |
514 } |
531 } |
515 |
532 if( iPacketService!= NULL ) |
516 |
533 { |
517 if(iPacketService) |
|
518 iPacketService->Close(); |
534 iPacketService->Close(); |
519 |
535 } |
520 if(iSat) |
536 if( iSat != NULL ) |
|
537 { |
521 iSat->Close(); |
538 iSat->Close(); |
522 if(iConfigFile) |
539 } |
523 delete iConfigFile; |
540 if( iConfigFile == NULL) |
524 if(iCallBarring) |
541 { |
525 delete iCallBarring; |
542 // In this case if iConfigSection exists then it is not owned |
526 if (iCallForwarding) |
543 // by iConfigFile - this is cos there was no config file for |
527 delete iCallForwarding; |
544 // this SIM TSY. |
528 if (iCallWaiting) |
545 delete iConfigSection; |
529 delete iCallWaiting; |
546 } |
|
547 delete iConfigFile; |
|
548 delete iCallBarring; |
|
549 delete iCallForwarding; |
|
550 delete iCallWaiting; |
530 |
551 |
531 if (iSetCallProcessingSuspendStateTimer) |
552 if (iSetCallProcessingSuspendStateTimer) |
532 { |
553 { |
533 iSetCallProcessingSuspendStateTimer->Cancel(); |
554 iSetCallProcessingSuspendStateTimer->Cancel(); |
534 delete iSetCallProcessingSuspendStateTimer; |
555 delete iSetCallProcessingSuspendStateTimer; |
535 } |
556 } |
536 delete iSimPhoneInitialise; |
557 delete iSimPhoneInitialise; |
537 |
558 |
538 delete iReduceTimers; |
559 delete iReduceTimers; |
539 |
560 delete iTestNumberObserver; |
|
561 |
540 CSimTsyMode::FreeMode(); |
562 CSimTsyMode::FreeMode(); |
541 LOGPHONE1("CSimPhone Destroyed"); |
563 LOGPHONE1("CSimPhone Destroyed"); |
542 } |
564 } |
543 |
565 |
544 void CSimPhone::InitPhoneStatus() |
566 void CSimPhone::InitPhoneStatus() |
2172 RMobilePhone::TMobilePhoneSubscriberId& subscribe=(*subscribePckg)(); |
2194 RMobilePhone::TMobilePhoneSubscriberId& subscribe=(*subscribePckg)(); |
2173 TInt ret = KErrNone; |
2195 TInt ret = KErrNone; |
2174 if (iSubscriberId.iError == KErrNone) |
2196 if (iSubscriberId.iError == KErrNone) |
2175 { |
2197 { |
2176 if(iSubscriberId.iIMSI.Length()>RMobilePhone::KIMSISize) |
2198 if(iSubscriberId.iIMSI.Length()>RMobilePhone::KIMSISize) |
|
2199 { |
2177 subscribe.Copy(iSubscriberId.iIMSI.Left(RMobilePhone::KIMSISize)); |
2200 subscribe.Copy(iSubscriberId.iIMSI.Left(RMobilePhone::KIMSISize)); |
|
2201 } |
2178 else |
2202 else |
|
2203 { |
2179 subscribe.Copy(iSubscriberId.iIMSI); |
2204 subscribe.Copy(iSubscriberId.iIMSI); |
|
2205 } |
2180 } |
2206 } |
2181 else |
2207 else |
|
2208 { |
2182 ret = iSubscriberId.iError; |
2209 ret = iSubscriberId.iError; |
|
2210 } |
2183 ReqCompleted(aReqHandle,ret); |
2211 ReqCompleted(aReqHandle,ret); |
2184 return KErrNone; |
2212 return KErrNone; |
2185 } |
2213 } |
2186 |
2214 |
2187 const CTestConfigSection* CSimPhone::CfgFile() |
2215 const CTestConfigSection* CSimPhone::CfgFile() |
2189 * Return a pointer to the Configuration File Section |
2217 * Return a pointer to the Configuration File Section |
2190 * |
2218 * |
2191 * @return CTestConfigSection pointer to the configuration file section |
2219 * @return CTestConfigSection pointer to the configuration file section |
2192 */ |
2220 */ |
2193 { |
2221 { |
2194 return iConfigFile->Section(iSectionName); |
2222 return iConfigSection; |
2195 } |
2223 } |
2196 |
2224 |
2197 const CTestConfigSection* CSimPhone::DefaultCfgFile() |
2225 const CTestConfigSection* CSimPhone::DefaultCfgFile() |
2198 /** |
2226 /** |
2199 * Return a pointer to the Default Configuration File Section |
2227 * Return a pointer to the Default Configuration File Section |
2200 * |
2228 * |
2201 * @return CTestConfigSection pointer to the default configuration file section |
2229 * @return CTestConfigSection pointer to the default configuration file section |
2202 */ |
2230 */ |
2203 { |
2231 { |
|
2232 if( iConfigFile == NULL ) |
|
2233 { |
|
2234 return NULL; |
|
2235 } |
2204 return iConfigFile->Section(KScriptDefaults); |
2236 return iConfigFile->Section(KScriptDefaults); |
2205 } |
2237 } |
2206 |
2238 |
2207 TInt CSimPhone::ValidateChangeState(CSimLine* aOriginatingLine, RMobileCall::TMobileCallStatus aState) |
2239 TInt CSimPhone::ValidateChangeState(CSimLine* aOriginatingLine, RMobileCall::TMobileCallStatus aState) |
2208 /** |
2240 /** |
2946 ReqCompleted(aReqHandle,KErrNone); |
2978 ReqCompleted(aReqHandle,KErrNone); |
2947 return KErrNone; |
2979 return KErrNone; |
2948 } |
2980 } |
2949 |
2981 |
2950 /** |
2982 /** |
|
2983 * Callback function invoked by the observer object when test number property is changed. |
|
2984 * This function is supposed to reset SIMTSY. Currently only SMS messaging part of SIMTSY |
|
2985 * is re-started with the new test number. |
|
2986 */ |
|
2987 void CSimPhone::HandleTestNumberChangedL() |
|
2988 { |
|
2989 SetTestNumberAndReadConfigurationFileL(); |
|
2990 iSmsMessaging->ReloadConfigurationSettingsL(); |
|
2991 } |
|
2992 |
|
2993 TInt CSimPhone::CheckConfigFile() |
|
2994 { |
|
2995 TInt testNumber; |
|
2996 User::LeaveIfError(GetTestNumber(testNumber)); |
|
2997 iSectionName.Format(KSectionNameFormat,testNumber); |
|
2998 |
|
2999 CTestConfig* configFile = NULL; |
|
3000 |
|
3001 TRAPD(err, configFile = CTestConfig::NewLC(iFs, KConfigFileDir, KConfigFilename); CleanupStack::Pop(configFile)); |
|
3002 CleanupStack::PushL(configFile); |
|
3003 if( err != KErrNone || configFile->Section(iSectionName) != NULL ) |
|
3004 { |
|
3005 err = KErrNone; |
|
3006 } |
|
3007 else |
|
3008 { |
|
3009 err = KErrNotFound; |
|
3010 } |
|
3011 CleanupStack::PopAndDestroy(configFile); |
|
3012 return err; |
|
3013 } |
|
3014 /** |
2951 Constructor for suspend call processing timer |
3015 Constructor for suspend call processing timer |
2952 */ |
3016 */ |
2953 CSimPhone::CSetCallProcessingSuspendStateTimerCallBack::CSetCallProcessingSuspendStateTimerCallBack() |
3017 CSimPhone::CSetCallProcessingSuspendStateTimerCallBack::CSetCallProcessingSuspendStateTimerCallBack() |
2954 {} |
3018 {} |
2955 |
3019 |
3046 *(RMobilePhone::TMobilePhoneNetworkMode*)iNotifyNetworkModeChange.iNotifyData = (RMobilePhone::TMobilePhoneNetworkMode)iNtwkMode; |
3110 *(RMobilePhone::TMobilePhoneNetworkMode*)iNotifyNetworkModeChange.iNotifyData = (RMobilePhone::TMobilePhoneNetworkMode)iNtwkMode; |
3047 ReqCompleted(iNotifyNetworkModeChange.iNotifyHandle,KErrNone); |
3111 ReqCompleted(iNotifyNetworkModeChange.iNotifyHandle,KErrNone); |
3048 } |
3112 } |
3049 |
3113 |
3050 iNetworkModeTimer->Start(iNetworkModeArray->At(iNetworkModeIndex).iDuration, &iTimerCallBackNetworkMode); |
3114 iNetworkModeTimer->Start(iNetworkModeArray->At(iNetworkModeIndex).iDuration, &iTimerCallBackNetworkMode); |
3051 } |
|
3052 |
|
3053 |
|
3054 void CSimPhone::ResetTestNumber() |
|
3055 { |
|
3056 TInt testNumber; |
|
3057 GetTestNumber(testNumber); |
|
3058 iSectionName.Format(KSectionNameFormat,testNumber); |
|
3059 } |
3115 } |
3060 |
3116 |
3061 TInt CSimPhone::CheckSimTsyVersion(RMobilePhone::TMultimodeType& aDataStruct) // overload this for other types of structures |
3117 TInt CSimPhone::CheckSimTsyVersion(RMobilePhone::TMultimodeType& aDataStruct) // overload this for other types of structures |
3062 /** |
3118 /** |
3063 * Checks the version of a data structure against the (simulated) version of SIMTSY, in order |
3119 * Checks the version of a data structure against the (simulated) version of SIMTSY, in order |
3245 ret = KErrNotSupported; |
3301 ret = KErrNotSupported; |
3246 } |
3302 } |
3247 |
3303 |
3248 return ret; |
3304 return ret; |
3249 } |
3305 } |
|
3306 //////////////////// |
|
3307 // CSimTestNumberObserver |
|
3308 //////////////////// |
|
3309 |
|
3310 CSimPhone::CSimTestNumberObserver::CSimTestNumberObserver(CSimPhone& aSimPhone) |
|
3311 : CActive(CActive::EPriorityStandard), |
|
3312 iSimPhone(aSimPhone) |
|
3313 { |
|
3314 CActiveScheduler::Add(this); |
|
3315 } |
|
3316 |
|
3317 CSimPhone::CSimTestNumberObserver::~CSimTestNumberObserver() |
|
3318 { |
|
3319 Cancel(); |
|
3320 iProperty.Close(); |
|
3321 } |
|
3322 |
|
3323 CSimPhone::CSimTestNumberObserver* CSimPhone::CSimTestNumberObserver::NewL(CSimPhone& aSimPhone) |
|
3324 { |
|
3325 CSimPhone::CSimTestNumberObserver* self = new(ELeave)CSimPhone::CSimTestNumberObserver(aSimPhone); |
|
3326 CleanupStack::PushL(self); |
|
3327 self->ConstructL(); |
|
3328 CleanupStack::Pop(self); |
|
3329 return self; |
|
3330 } |
|
3331 |
|
3332 void CSimPhone::CSimTestNumberObserver::ConstructL() |
|
3333 { |
|
3334 LOGPHONE1("CSimPhone::CSimPhoneObserver::ConstructL"); |
|
3335 User::LeaveIfError(iProperty.Attach(KUidPSSimTsyCategory, KPSSimTsyTestNumber)); |
|
3336 Start(); |
|
3337 } |
|
3338 |
|
3339 void CSimPhone::CSimTestNumberObserver::Start() |
|
3340 { |
|
3341 LOGPHONE1("CSimPhone::CSimPhoneObserver::Start"); |
|
3342 iProperty.Subscribe(iStatus); |
|
3343 SetActive(); |
|
3344 } |
|
3345 |
|
3346 void CSimPhone::CSimTestNumberObserver::RunL() |
|
3347 { |
|
3348 LOGPHONE2("CSimPhone::CSimPhoneObserver::RunL [iStatus=%d]", iStatus.Int()); |
|
3349 TInt err = iSimPhone.CheckConfigFile(); |
|
3350 if( err == KErrNone ) |
|
3351 { |
|
3352 iSimPhone.HandleTestNumberChangedL(); |
|
3353 } |
|
3354 |
|
3355 Start(); |
|
3356 } |
|
3357 |
|
3358 void CSimPhone::CSimTestNumberObserver::DoCancel() |
|
3359 { |
|
3360 LOGPHONE1("CSimPhone::CSimPhoneObserver::DoCancel"); |
|
3361 iProperty.Cancel(); |
|
3362 } |
|
3363 |