Monday, March 24, 2008

Getting Country Code and Operator name.

class CNetwork : public CActive
{
public:
CNetwork(CTelephony* aTelephony);

void ConstructL();

~CNetwork();

public: // New functions
void StartL(TTimeIntervalMicroSeconds32 aDelay);
void Stop();

private: // From CActive
void RunL();
void DoCancel();

public:
CTelephony* iTelephony; // telephony object we own
CTelephony::TNetworkInfoV1 iV1;
CTelephony::TNetworkInfoV1Pckg iPkg;
TTimeIntervalMicroSeconds32 iDelay;//get network interval
TNetworkInfo iNetworkInfo;
};


CNetwork::CNetwork(CTelephony* aTelephony) : CActive(EPriorityStandard)
,iTelephony(aTelephony), iPkg(iV1)
{}

void CNetwork::ConstructL()
{
CActiveScheduler::Add(this);
}

CNetwork::~CNetwork()
{
Cancel(); // Cancel any request, if outstanding
}

void CNetwork::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EGetCurrentNetworkInfoCancel);
}

void CNetwork::StartL(TTimeIntervalMicroSeconds32 aDelay)
{
Stop();
iStatus=KRequestPending;
iTelephony->GetCurrentNetworkInfo(iStatus, iPkg);
SetActive();
}

void CNetwork::Stop()
{
Cancel();
}

void CNetwork::RunL()
{
if(iStatus == KErrNone)
{
TNetworkInfo tempNetworkInfo;
TBuf<30>strTemp;
strTemp = iPkg().iCountryCode;
CAknInformationNote* note = new (ELeave) CAknInformationNote();
note->ExecuteLD(strTemp);
}
}

No comments:

stats counter