×
Namespaces

Variants
Actions

Archived:Get Network Name using CTelephony

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
Code ExampleTested with
Devices(s): E61i
Compatibility
Platform(s): S60 3rd Edition
S60 3rd Edition (initial release)
Platform Security
Capabilities: ReadDeviceData
Article
Keywords: CTelephony::GetCurrentNetworkName()
Created: savaj (08 May 2009)
Last edited: hamishwillee (18 Sep 2012)

Needs-update.pngThis article needs to be updated: If you found this article useful, please fix the problems below then delete the {{ArticleNeedsUpdate}} template from the article to remove this warning.

Reasons: hamishwillee (21 Dec 2011)
Needs to be merged with near duplicate article Archived:Get Network Name using CTelephony


Contents

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

This page was last modified on 18 September 2012, at 09:00.
49 page views in the last 30 days.