You Are Here:

Community: Wiki

This page was last modified on 3 August 2009, at 06:06.

Reading IMEI in 3rd edition -Synchronously

From Forum Nokia Wiki

IMEI stands for "International Mobile Equipment Identity". There is a frequent use of reading IMEI in mobile phone development. People generally use IMEI for license/full version support of an application.


IMEIApp.h

#include <e32base.h>
#include <Etel3rdParty.h>
 
class CIMEIApp : public CActive
{
private:
void ConstructL();
CTelephony* iTelephony;
CTelephony::TPhoneIdV1 iPhoneIdV1;
CTelephony::TPhoneIdV1Pckg iPhoneIdV1Pckg;
 
public:
CIMEIApp(TDes& aIMEI);
~CIMEIApp();
static void GetIMEI(TDes& aIMEI);
TDes& IMEI;
 
private:
/*
These are the pure virtual methods from CActive that
MUST be implemented by all active objects
*/

void RunL();
void DoCancel();
};

IMEIApp.cpp

#include "IMEIApp.h"
 
void CIMEIApp::GetIMEI(TDes& aIMEI)
{
CIMEIApp* self= new (ELeave) CIMEIApp(aIMEI);
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::PopAndDestroy(self);
}
 
void CIMEIApp::ConstructL()
{
iTelephony = CTelephony::NewL();
CActiveScheduler::Add(this);
 
iTelephony->GetPhoneId(iStatus, iPhoneIdV1Pckg);
SetActive();
CActiveScheduler::Start();
}
 
CIMEIApp:: CIMEIApp(TDes& imei): CActive(EPriorityStandard),IMEI(imei),iPhoneIdV1Pckg(iPhoneIdV1)
{
//default constructor
}
 
CIMEIApp::~CIMEIApp()
{
delete iTelephony;
iTelephony = NULL;
}
 
void CIMEIApp::RunL()
{
if(iStatus==KErrNone)
{
IMEI= iPhoneIdV1.iSerialNumber;
CActiveScheduler::Stop();
}
}
 
void CIMEIApp::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel);
}

Now do the following steps:
1) Create a sample "Hello World" type application.
2) Put IMEIApp.h file in your application's inc folder.
3) Put IMEIApp.cpp file in your application's src folder.
4) Open .mmp file and add entry SOURCE IMEIApp.cpp.
5) Open .mmp file and add entry LIBRARY etel3rdparty.lib.
7) Now you need to include following header in your class to read IMEI:
#include "IMEIApp.h". Let's say in for e.g.: "CYrAppUi.h"
8) You can then call the static function from any of your Commands.
For ex: in your CYrAppUi.h you need to include "IMEIApp.h"
And Call it like:

case EReadIMEICommand1:
{
TBuf<25> iIMEI;
CIMEIApp::GetIMEI(iIMEI);
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(iIMEI);
}

You can find a working application which can be built with Carbide.c++.
Here it goes: [Read IMEI]

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 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fTalkE3aE4cargeE5fscreenE5fsaverX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ
User Rating: qfnZuserE5FratingQNx5E2E0000X