Network name with CTelephony
The CNwNameCheck class illustrates how to read the current network's name using the CTelephony API. Note that this example is intended to be used only with S60 3rd Edition devices, and does not work with pre-3rd Edition devices.
Article Metadata
Code Example
Source file: Media:MyTelephonyNetworkName.zip
Article
Created: symbianyucca
(27 Mar 2007)
Last edited: hamishwillee
(12 Jan 2012)
To use this example implement the callback interface function in the implementing class and then construct an instance of the CNwNameCheck. The callback function will be then called with the current networks name.
GetNetWorkName.cpp
CNwNameCheck::~CNwNameCheck()
{
Cancel();
delete iTelephony;
}
void CNwNameCheck::ConstructL(void)
{
iTelephony = CTelephony::NewL();
iTelephony->GetCurrentNetworkName(iStatus, iIdV1Pkg);
SetActive();
}
CNwNameCheck::CNwNameCheck(MNwNameObserver& aObserver)
: CActive(EPriorityNormal),iObserver(aObserver),iIdV1Pkg(iIdV1)
{
CActiveScheduler::Add(this);
}
void CNwNameCheck::RunL()
{
iObserver.NetworkNameL(iIdV1.iNetworkName);
}
void CNwNameCheck::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EGetCurrentNetworkNameCancel);
}
GetNetWorkName.h
#include <Etel3rdParty.h>
class MNwNameObserver
{
public:
virtual void NetworkNameL(const TDesC& aNwName) = 0;
};
class CNwNameCheck : public CActive
{
public:
CNwNameCheck(MNwNameObserver& aObserver);
void ConstructL(void);
~CNwNameCheck();
private:
void RunL();
void DoCancel();
private:
MNwNameObserver& iObserver;
CTelephony* iTelephony;
CTelephony::TNetworkNameV1 iIdV1;
CTelephony::TNetworkNameV1Pckg iIdV1Pkg;
};

