×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Get MCC MNC using CTelephony

From Nokia Developer Wiki
Jump to: navigation, search
debjit.roy (Talk | contribs)
(Debjit.roy -)
hamishwillee (Talk | contribs)
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
[[Category:Symbian C++]][[Category:S60 3rd Edition]][[Category:Code Examples]][[Category:Telephony]]
+
{{Archived|timestamp=20120313100118|user=roy.debjit| }}
 +
[[Category:Symbian C++]][[Category:S60 3rd Edition (initial release)]][[Category:Code Examples]][[Category:Telephony]]
 
{{Abstract|This code example shows how to get the MCC and MNC using the Symbian C++ {{Icode|CTelephony}} API.}}
 
{{Abstract|This code example shows how to get the MCC and MNC using the Symbian C++ {{Icode|CTelephony}} API.}}
  
{{ArticleMetaData <!-- v1.1 -->
+
{{ArticleMetaData <!-- v1.2 -->
|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= Nokia E61i
 
|devices= Nokia E61i
Line 24: Line 25:
 
|author= [[User:Savaj]]
 
|author= [[User:Savaj]]
 
}}
 
}}
{{Archived|timestamp=20120313100118|user=roy.debjit| }}
 
 
    
 
    
  
 
==Overview==
 
==Overview==
  
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 {{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}}.
 
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}}.
Line 40: Line 40:
 
==Library Needed==
 
==Library Needed==
 
<code cpp>
 
<code cpp>
LIBRARY   etel3rdparty.lib
+
LIBRARY etel3rdparty.lib
 
</code>
 
</code>
  
 
==Capability Required==
 
==Capability Required==
 
<code cpp>
 
<code cpp>
Capability ReadDeviceData
+
Capability ReadDeviceData
 
</code>
 
</code>
  
Line 81: Line 81:
 
CTelephony* iTelephony;
 
CTelephony* iTelephony;
 
CTelephony::TNetworkInfoV1 iMCCMNCV1;
 
CTelephony::TNetworkInfoV1 iMCCMNCV1;
CTelephony::TNetworkInfoV1Pckg iMCCMNCV1Pkg;
+
CTelephony::TNetworkInfoV1Pckg iMCCMNCV1Pkg;
 
 
 
};
 
};

Latest revision as of 04:51, 19 June 2012

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}}.

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 (19 Jun 2012)


Contents

[edit] 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.

[edit] Headers Required

#include <Etel3rdParty.h>

[edit] Library Needed

LIBRARY etel3rdparty.lib

[edit] Capability Required

Capability ReadDeviceData

[edit] 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__

[edit] 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);
}
}

[edit] Example Code

This page was last modified on 19 June 2012, at 04:51.
78 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×