#include
#include
#include
#include
#include
#include
#include "SystemManager.h"
CSystemManager::CSystemManager () : CActive(EPriorityStandard), iPhoneInfoType(EHandsetIMEI),
iState(EStart),
iTelephony(NULL),
iSubscriberIdV1Pckg(iSubscriberIdV1),
iPhoneIdV1Pckg(iPhoneIdV1),
iNetworkInfoV1Pckg(iNetworkInfoV1) { }
CSystemManager* CSystemManager::NewLC()
{
CSystemManager* self = new ( ELeave ) CSystemManager();
CleanupStack::PushL( self );
self->ConstructL();
return self;
}
CSystemManager* CSystemManager::NewL()
{
CSystemManager* self = CSystemManager::NewLC();
CleanupStack::Pop(); // self;
return self;
}
void CSystemManager::ConstructL()
{
User::LeaveIfError( iTimer.CreateLocal() ); // Initialize timer
CActiveScheduler::Add( this ); // Add to scheduler
iTelephony = CTelephony::NewL();
}
CSystemManager::~CSystemManager()
{
Cancel(); // Cancel any request, if outstanding
delete iTelephony;
iTimer.Close(); // Destroy the RTimer object
// Delete instance variables if any
}
void CSystemManager::DoCancel()
{
switch(iPhoneInfoType)
{
case EHandsetIMEI:
iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel);
break;
case EHandsetIMSI:
iTelephony->CancelAsync(CTelephony::EGetSubscriberIdCancel);
break;
default:
iTelephony->CancelAsync(CTelephony::EGetCurrentNetworkInfoCancel);
break;
}
}
void CSystemManager::StartL()
{
Cancel(); // Cancel any request, just to be sure
//iState = EUninitialized;
//iTimer.After( iStatus, aDelay ); // Set for later
iState = EGetPhoneInfo;
switch(iPhoneInfoType)
{
case EHandsetIMEI:
{
iTelephony->GetPhoneId(iStatus, iPhoneIdV1Pckg);
break;
}
case EHandsetIMSI:
{
iTelephony->GetSubscriberId(iStatus, iSubscriberIdV1Pckg);
break;
}
case EHandsetNetworkInfo:
{
iTelephony->GetCurrentNetworkInfo(iStatus, iNetworkInfoV1Pckg);
break;
}
}
SetActive();
iActiveSchedulerWait.Start();
}
void CSystemManager::RunL()
{
iState = EDone;
if ( iActiveSchedulerWait.IsStarted() )
{
iActiveSchedulerWait.AsyncStop();
if(iStatus == KErrNone)
{
switch(iPhoneInfoType)
{
case EHandsetIMEI:
{
iIMEI = iPhoneIdV1.iSerialNumber;
}
break;
case EHandsetIMSI:
{
iIMSI = iSubscriberIdV1.iSubscriberId;
}
break;
case EHandsetNetworkInfo:
{
iLocationAreaCode = iNetworkInfoV1.iLocationAreaCode;
iCellId = iNetworkInfoV1.iCellId;
iOperatorName = iNetworkInfoV1.iLongName;
iCountryCode = iNetworkInfoV1.iCountryCode;
iNetworkId = iNetworkInfoV1.iNetworkId;
}
break;
}
}
else
{
// Do nothing
}
}
}
TDesC& CSystemManager::GetIMEI()
{
iPhoneInfoType = EHandsetIMEI;
iIMEI.Zero();
StartL();
return iIMEI;
}
TDesC& CSystemManager::GetIMSI()
{
iPhoneInfoType = EHandsetIMSI;
iIMSI.Zero();
StartL();
return iIMSI;
}
TUint CSystemManager::GetLocationAreaCode() {
iPhoneInfoType = EHandsetNetworkInfo;
iLocationAreaCode = 0;
StartL();
return iLocationAreaCode;
}
TUint CSystemManager::GetCellID() {
iPhoneInfoType = EHandsetNetworkInfo;
iCellId = 0;
StartL();
return iCellId;
}
TDesC& CSystemManager::GetOperatorName()
{
iPhoneInfoType = EHandsetNetworkInfo;
iOperatorName.Zero();
StartL();
return iOperatorName;
}
TDesC& CSystemManager::GetCountryCode()
{
iPhoneInfoType = EHandsetNetworkInfo;
iCountryCode.Zero();
StartL();
return iCountryCode;
}
TDesC& CSystemManager::GetNetworkID()
{
iPhoneInfoType = EHandsetNetworkInfo;
iNetworkId.Zero();
StartL();
return iNetworkId;
}
TInt CSystemManager::RunError( TInt aError )
{
return aError;
}
[/code]
Actually parts of the code are from sonyericsson and developer.symbian and the uiq 3 documentation the .chm file. I've just paste them together :-).