You Are Here:

Community: Wiki

This page was last modified on 5 September 2009, at 16:15.

Reading IMSI in 3rd Edition

From Forum Nokia Wiki

Reviewer Approved   



ID - Creation date
Platform S60 3rd Edition Tested on devices E61i
Category Symbian C++ Subcategory


Keywords (APIs, classes, methods, functions): CTelephony::GetSubscriberId()


CImsiReader example illustrates how to read IMSI (SIM card's identity number, which has nearly nothing to do with the MSISDN that is the phone number used for calling) in 3rd Edition Symbian devices. Note that this code will most likely not work in the emulator, thus you should only use it in real devices.

Link against:

etel3rdparty.lib

Capability require:

CAPABILITY  ReadDeviceData

IMSI_Getter.cpp

#include "Imsi_Getter.h"  //LP: added #include for Imsi_Getter.h header file
 
CImsiReader* CImsiReader::NewL(MImsiObserver* aObserver)
{
CImsiReader* self = NewLC(aObserver);
CleanupStack::Pop(self);
return self;
}
 
 
CImsiReader* CImsiReader::NewLC(MImsiObserver* aObserver)
{
CImsiReader* self = new (ELeave) CImsiReader(aObserver);
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
 
 
CImsiReader::CImsiReader(MImsiObserver* aObserver)
:CActive(0),iObserver(aObserver),iImsiV1Pkg(iImsiV1)
{
}
 
CImsiReader::~CImsiReader()
{
Cancel();
delete iTelephony;
 
}
 
void CImsiReader::ConstructL(void)
{
CActiveScheduler::Add(this);
 
iTelephony = CTelephony::NewL();
iTelephony->GetSubscriberId(iStatus,iImsiV1Pkg);
SetActive();
}
 
void CImsiReader::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EGetSubscriberIdCancel);
}
 
 
void CImsiReader::RunL()
{
//LP: added ";" and replaced iTelephony with iObserver
iObserver->GotIMSIL(iImsiV1.iSubscriberId,iStatus.Int());
}

IMSI_Getter.h

#include <Etel3rdParty.h>
class MImsiObserver
{
public: // New methods
virtual void GotIMSIL(const TDesC& aIMSI, TInt aError) = 0;
};
 
class CImsiReader : public CActive
{
 
public:
static CImsiReader* NewL(MImsiObserver* aObserver);
static CImsiReader* NewLC(MImsiObserver* aObserver);
~CImsiReader();
protected:
void DoCancel();
void RunL();
private:
CImsiReader(MImsiObserver* aObserver);
void ConstructL(void);
private:
MImsiObserver* iObserver;
CTelephony* iTelephony;
CTelephony::TSubscriberIdV1 iImsiV1;
CTelephony::TSubscriberIdV1Pckg iImsiV1Pkg;
};

Example Code

See Also

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
User Rating: qfnZuserE5FratingQNx2E2E0000X
RDF Facets: qfnZuserE5FtagQSximsiX