×
Namespaces

Variants
Actions

Reading IMSI in 3rd Edition

From Nokia Developer Wiki
Jump to: navigation, search


Article Metadata
Tested with
Devices(s): E61i
Compatibility
Platform(s): S60 3rd Edition
Platform Security
Signing Required: DevCert
Capabilities: ReadDeviceData
Article
Keywords: CTelephony::GetSubscriberId()
Created: symbianyucca (20 Mar 2007)
Last edited: hamishwillee (11 Jan 2012)

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

[show details]
This page was last modified on 11 January 2012, at 09:46.
122 page views in the last 30 days.
×