×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Get MCC MNC using CTelephony

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Fix ArticleMetaData and RevieweApproval)
hamishwillee (Talk | contribs)
m (Hamishwillee - Update ArticleMetaData)
Line 1: Line 1:
 +
[[Category:Symbian C++]][[Category:S60 3rd Edition]][[Category:Code Examples]][[Category:Telephony]]
 +
{{Abstract|This code example shows how to get the MCC and MNC using the Symbian C++ {{Icode|CTelephony}} API.}}
  
__NOTOC__
 
__NOEDITSECTION__
 
 
{{ArticleMetaData <!-- v1.1 -->
 
{{ArticleMetaData <!-- v1.1 -->
 
|sourcecode= [[Media:MyTelephonyMccMnc.zip]]  
 
|sourcecode= [[Media:MyTelephonyMccMnc.zip]]  
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|devices= E61i
+
|devices= Nokia E61i
 
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|platform= S60 3rd Edition
+
|platform= S60 3rd Edition and later
 
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
 
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
 
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
+
|signing= DevCert
|capabilities= <!-- Capabilities required (e.g. Location, NetworkServices. -->)
+
|capabilities= ReadDeviceData
 
|keywords= CTelephony::GetCurrentNetworkInfo()
 
|keywords= CTelephony::GetCurrentNetworkInfo()
|id= -
 
 
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 
|translated-by= <!-- [[User:XXXX]] -->
 
|translated-by= <!-- [[User:XXXX]] -->
Line 24: Line 23:
 
|creationdate= 20090504
 
|creationdate= 20090504
 
|author= [[User:Savaj]]
 
|author= [[User:Savaj]]
<!-- The following are not in current metadata -->
 
|subcategory=
 
|category= Symbian C++
 
 
}}
 
}}
<br>
 
  
 
==Overview==
 
==Overview==
CTelephonyReader implementation illustrates how to get MCC and MNC in S60 3rd Edition devices with CTelephony API.  Basically [[IMSI]] is 15 digits long number. The first 3 digits of IMSI are the MCC, and is followed by the MNC, either 2 digits (European standard) or 3 digits (North American standard). So retriving MCC and MNC from IMSI is not always safe, thus implemented this method to get MCC MNC from CTelephony::GetCurrentNetworkInfo() API of symbian.
 
  
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.
+
The {{Icode|CTelephonyReader}} class shown below uses the CTelephony API to get MCC and MNC in S60 3rd Edition devices.  It does this by extracting them from the IMSI. The IMSI  is 15 digits long - the first 3 digits are the MCC, and these are followed by the MNC, either 2 digits (European standard) or 3 digits (North American standard).
 +
 
 +
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 {{Icode|CTelephonyReader}}.
  
 
==Headers Required==
 
==Headers Required==
Line 150: Line 146:
  
 
* [[Media:MyTelephonyMccMnc.zip|Example code]]
 
* [[Media:MyTelephonyMccMnc.zip|Example code]]
 
[[Category:Symbian C++]][[Category:S60 3rd Edition]]
 
[[Category:Code Examples]]
 

Revision as of 03:33, 10 February 2012

This code example shows how to get the MCC and MNC using the Symbian C++ CTelephony API.

Article Metadata
Code ExampleTested with
Devices(s): Nokia E61i
Compatibility
Platform(s): S60 3rd Edition and later
S60 3rd Edition (initial release)
Platform Security
Signing Required: DevCert
Capabilities: ReadDeviceData
Article
Keywords: CTelephony::GetCurrentNetworkInfo()
Created: savaj (04 May 2009)
Last edited: hamishwillee (10 Feb 2012)

Contents

Overview

The CTelephonyReader class shown below uses the CTelephony API to get MCC and MNC in S60 3rd Edition devices. It does this by extracting them from the IMSI. The IMSI is 15 digits long - the first 3 digits are the MCC, and these are followed by the MNC, either 2 digits (European standard) or 3 digits (North American standard).

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.

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 GetMccMnc(const TDesC& aMcc,const TDesC& aMnc) = 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::TNetworkInfoV1 iMCCMNCV1;
CTelephony::TNetworkInfoV1Pckg iMCCMNCV1Pkg;
 
};
 
#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),iMCCMNCV1Pkg(iMCCMNCV1)
{
}
 
CTelephonyReader::~CTelephonyReader()
{
Cancel();
}
 
void CTelephonyReader::ConstructL(void)
{
CActiveScheduler::Add(this);
 
iTelephony = CTelephony::NewL();
 
iTelephony->GetCurrentNetworkInfo(iStatus,iMCCMNCV1Pkg);
 
SetActive();
}
 
void CTelephonyReader::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EGetCurrentNetworkInfoCancel);
}
 
 
void CTelephonyReader::RunL()
{
if(iStatus == KErrNone)
{
iObserver->GetMccMnc(iMCCMNCV1.iCountryCode,iMCCMNCV1.iNetworkId);
}
}

Example Code

89 page views in the last 30 days.
×