×
Namespaces

Variants
Actions

Retrieving device IMEI number synchronously using Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search



Article Metadata
Compatibility
Platform(s): S60 3rd Edition
S60 3rd Edition (initial release)
Article
Created: User:Technical writer 2 (22 Nov 2006)
Last edited: hamishwillee (14 Jun 2012)

Overview

Retrieving phone's IMEI number synchronously

Description

Currently on S60 3rd Edition the only method to retrieve the IMEI number is via "CTelephony". However, it does not provide a synchronous method to retrieve the IMEI number of the mobile phone.
The following method does not work:
CTelephony::TPhoneIdV1Pckg phoneIdPckg;
TRequestStatus status;
 iTel = CTelephony::NewL();
 iTel->GetPhoneId( status, phoneIdPckg );
User::WaitForRequest( status );
Although a developer can use an asynchronous method to retrieve the IMEI by using an active object, it is still not convenient in practice.

Solution

Design an active object to retrieve the IMEI synchronously:
void CPhoneInfo::GetPhoneIdL( )
    {
    if ( IsActive() )
    {
    return;
    }

    iTelApiCmd = EGetPhoneId;

#if !defined(__WINS__)  && !defined(__WINSCW__)
iTel->GetPhoneId( iStatus, iPhoneIdPckg );
SetActive();
iWait.Start();
#endif
    }
Define "iWait" as follows:
        CActiveSchedulerWait iWait;
in the "RunL" method of the active object:
void CPhoneInfo::RunL()
    {
    if ( iTelApiCmd != EAsyncEvent )
        {
     iWait.AsyncStop();
        }
  
    switch( iTelApiCmd )
        {
        case EGetPhoneId :
            {
            iNotify.GetPhoneIdApiCompleteL( iStatus.Int(), iPhoneId );
            }
            break;
                         
      default :
            break;
        }
    return;
    }

This page was last modified on 14 June 2012, at 10:13.
29 page views in the last 30 days.