您的位置:首页 > 产品设计 > UI/UE

How to retrieve the phone IMEI code on UIQ3.0

2008-08-02 17:25 477 查看
How to retrieve the phone IMEI code on UIQ3.0

Here I’ll present an approach to retrieve IMEI code by calling functions of class RMobilePhone. I have debugged these source codes on W950 (Symbian 9.1, UIQ3.0).

You can get some description of the format of IMEI code in [1]. In this paper, the PlpVariant::GetMachineIdL function is called to retrieve the phone IMEI code, but this function has been deprecated on UIQ3.0. So if you call it, you maybe will retrieve a incorrect IMEI code. I have debugged it on W950, the return is ‘14750005-630771776’. My phone IMEI code is actually ‘00440107-000879-8’.
And the link [2] provides another approach, but it’s so hard to get the mentioned .h files and librarys. I can not find them, so I did not debug it.
On UIQ 3.0, class RMobilePhone provides client access to mobile phone functionality provided by TSY. You can get the detailed description of class RMobilePhone in the help document of UIQ SDK.
My steps are as following:
1. Connect to the ETel server
2. Get the name of registered phones
3. Open mobile phone sub session
4. Check if the phone provided the capabilities to retrieve IMEI code or not
5. Retrieve the phone IMEI code
                                        
The defined parameters:

[align=left]RTelServer iTelServer;   // Root telephony server session[/align]
[align=left]RMobilePhone iMmPhone;[/align]
[align=left]TBuf< KCommsDbSvrMaxFieldLength> iPhoneName[/align]
[align=left]RMobilePhone::TMobilePhoneIdentityV1 iPhoneId;[/align]
1. Connect to the ETel server

[align=left]User::LeaveIfError(iTelServer.Connect());[/align]
2. Get the name of registered phones

[align=left]// Get the number of registered phones[/align]
[align=left]TInt numberOfPhones;[/align]
[align=left]User::LeaveIfError(aTelServer.EnumeratePhones(numberOfPhones));[/align]
[align=left]LOG("%i",numberOfPhones);[/align]
[align=left]for( TInt i = 0; i <numberOfPhones ; i++ )[/align]
[align=left]{[/align]
[align=left]RTelServer::TPhoneInfo info;[/align]
[align=left]iTelServer.GetPhoneInfo(i,info);[/align]
[align=left]LOG("NetworkTyp:[%i],Name:[%S],NumberofLines:[%i],Extensions:[%i]",             (TInt)info.iNetworkType,&info.iName,info.iNumberOfLines,info.iExtensions);[/align]
[align=left]iPhoneName.Copy(info.iName);[/align]
[align=left]}[/align]
In your smart phone, there can be several registered phones i.e. the returned value of ‘number ofPhones’ can be more than 1. hence you need to choice one directly or adopt other policy.But fortunately most of the smart phones have just one
3. Open mobile phone sub session

[align=left]// open mobile phone sub session      [/align]
[align=left]User::LeaveIfError(iMmPhone.Open(iTelServer, iPhoneName));[/align]
4. Check if the phone provided the capabilities to retrieve IMEI code or not
 And call the RMobilePhone::GetPhoneId function to retrieve IMEI.

[align=left]TUint32 lCaps = 0;[/align]
[align=left]TInt err = iMmPhone.GetIdentityCaps(lCaps);[/align]
[align=left]if(err != KErrNone && err != KErrNotSupported)[/align]
[align=left]        {[/align]
[align=left]        LOG(_L("an unexpected error occoured"));[/align]
[align=left]        }[/align]
[align=left]else if(err == KErrNotSupported)[/align]
[align=left]        {[/align]
[align=left]        LOG(_L("RMobilePhone::GetIdentityCaps() returned KErrNotSupported "));                                             [/align]
[align=left]        }[/align]
[align=left]else if (lCaps & RMobilePhone::KCapsGetSerialNumber)[/align]
[align=left]        {[/align]
[align=left]        iMmPhone.GetPhoneId(iStatus, iPhoneId); // asynchronous call[/align]
[align=left]        iActiveStatus = ST_GET_PHONE_ID;[/align]
[align=left]        SetActive();[/align]
[align=left]        return;[/align]
[align=left]        }[/align]
[align=left]// very important, Otherwise application will panic when called twice[/align]
[align=left]iMmPhone.Close();[/align]
[align=left]iTelServer.Close();[/align]
The function,RMobilePhone:: GetPhoneId, is the key function. In fact, here I introduce how to use it.
5. After returning, the value of the parameter, iPhoneId.iSerialNumber, is the phone IMEI code
6. Don't forget to close the opened handles as like:

[align=left]iMmPhone.Close();[/align]
[align=left]iTelServer.Close();[/align]
<SCRIPT type=text/javascript><!--
google_ad_client = "pub-5802524690470106";
//728x15, 创建于 07-11-13
google_ad_slot = "7233856721";
google_ad_width = 728;
google_ad_height = 15;
//--></SCRIPT>

<SCRIPT src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type=text/javascript>
</SCRIPT>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息