×
Namespaces

Variants
Actions
Revision as of 01:12, 9 June 2009 by JOM (Talk | contribs)

Archived:Get Network Name using CTelephony

From Nokia Developer Wiki
Jump to: navigation, search


Article Metadata
Tested with
Devices(s): E61i
Compatibility
Platform(s): S60 3rd Edition
S60 3rd Edition (initial release)
Article
Keywords: CTelephony::GetCurrentNetworkName()
Created: (08 May 2009)
Last edited: JOM (09 Jun 2009)


Overview

CTelephonyReader implementation illustrates how to get Network Name in S60 3rd Edition Device with CTelephony API.

The implementation is pretty simple, and when using this one only thing to do in calling class is to implement the callback interface and then to construct an instance of the CTelephonyReader.

Note: this code will most likely not work in the emulator, thus you should only use it in real devices.

Headers Required

#include <Etel3rdParty.h>

Library Needed

LIBRARY   etel3rdparty.lib

Capability Required

Capability  ReadDeviceData

TelephonyReader.h

#ifndef __TELEPHONYREADER_h__
#define __TELEPHONYREADER_h__
 
#include <Etel3rdParty.h>
class MTelephonyObserver
{
public:
virtual void GetCurrentNetworkName(const TDesC& aNetworkName) = 0;
 
};
 
class CTelephonyReader : public CActive
{
public:
static CTelephonyReader* NewL(MTelephonyObserver* aObserver);
static CTelephonyReader* NewLC(MTelephonyObserver* aObserver);
void ConstructL(void);
~CTelephonyReader();
protected:
void DoCancel();
void RunL();
 
private:
CTelephonyReader(MTelephonyObserver* aObserver);
 
private:
MTelephonyObserver* iObserver;
CTelephony* iTelephony;
CTelephony::TNetworkNameV1 iNetworkNameV1;
CTelephony::TNetworkNameV1Pckg iNetworkNameV1Pckg;
};
 
#endif //__TELEPHONYREADER_h__

TelephonyReader.cpp

#include "TelephonyReader.h" 
 
CTelephonyReader* CTelephonyReader::NewL(MTelephonyObserver* aObserver)
{
CTelephonyReader* self = NewLC(aObserver);
CleanupStack::Pop(self);
return self;
}
 
 
CTelephonyReader* CTelephonyReader::NewLC(MTelephonyObserver* aObserver)
{
CTelephonyReader* self = new (ELeave) CTelephonyReader(aObserver);
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
 
 
CTelephonyReader::CTelephonyReader(MTelephonyObserver* aObserver)
:CActive(0),iObserver(aObserver),iNetworkNameV1Pckg(iNetworkNameV1)
{
}
 
CTelephonyReader::~CTelephonyReader()
{
Cancel();
delete iTelephony;
}
 
void CTelephonyReader::ConstructL(void)
{
CActiveScheduler::Add(this);
 
iTelephony = CTelephony::NewL();
 
iTelephony->GetCurrentNetworkName(iStatus,iNetworkNameV1Pckg);
 
SetActive();
}
 
void CTelephonyReader::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EGetCurrentNetworkNameCancel );
}
 
 
void CTelephonyReader::RunL()
{
if(iStatus == KErrNone)
{
iObserver->GetCurrentNetworkName(iNetworkNameV1.iNetworkName);
}
}

Example Code

Related Link

54 page views in the last 30 days.
×