Thursday, January 22, 2015

HOW TO RETREIVE IMSI NUMBER

Descrition:This label explains about how to retreive IMSI Number (Intenational Mobile Subcriber Indentification) Using Telephony Server.

class CIMSIApp : public CActive
{
 public:
  static CIMCIApp* NewL();
 private:
  void ConstructL();
  CIMSIApp();
 private://data 
  CTelephony* iTelephony;
  CTelephony::TSubscriberIdV1 iSubscriberIdV1;
  TDes& IMSI;
 public:
  void GetIMSI(TDes& aIMSI);
 private:
 /* These are the pure virtual methods from CActive that
  MUST be implemented by all active objects */
 void RunL();
 void DoCancel();
};

//Defenition
/* Returns pointer to CIMSIApp Class*/
static CIMCIApp* CIMSIApp::NewL()
{
 CIMSIApp* self= new (ELeave) CIMSIApp();
 CleanupStack::PushL(self);
 self->ConstructL();
 CleanupStack::PopAndDestroy(self);
}

/* This method retreive the IMSI Number
Param - reference variabl (To return the IMSI Number reterives)*/
void CIMSIApp::GetIMSI(TDes& aIMSI)
{
 IMSI = aIMSI;
 /*this is a Asynchronous call to the Telephony server - Telephony server will call the RunL method of this class after the completion of the request.*/
 iTelephony->GetSubscriberId(iStatus,iSubscriberIdV1Pckg);
 SetActive(); /*This function call initmates the Activesheduler that this active object is active to handle the asynchronous request*/ 
 CActiveScheduler::Start();
}

void CIMSIApp::ConstructL()
{
 iTelephony = CTelephony::NewL();
 CTelephony::TSubscriberIdV1Pckg iSubscriberIdV1Pckg(iSubscriberIdV1);
}

CIMSIApp:: CIMSIApp(): CActive(EPriorityStandard)
{
 CActiveScheduler::Add(this); //Add this active object in to the active scheduler list
}

/* Event handler method the CIMSIApp Active object class 
this function will be called by the Active scheduler when the Telephony server 
completes the request been raised by this active object*/
void CIMSIApp::RunL()
{
 if(iStatus==KErrNone)
 {
 IMSI = iSubscriberIdV1.iSubscriberId;
 CActiveScheduler::Stop();
 }
}

/* to cancel the outstanding request*/
void CIMSIApp::DoCancel()
{
 iTelephony->CancelAsync(CTelephony::EGetSubscriberIdCancel);
}

0 comments:

Post a Comment