|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Helper class to get IMEI number. |
|
15 * |
|
16 */ |
|
17 |
|
18 /** |
|
19 * Only used in CMdESessionImpl::GetImei() method. |
|
20 */ |
|
21 |
|
22 #include "mdsgetimeiao.h" |
|
23 |
|
24 CMdsGetImeiAO* CMdsGetImeiAO::NewL() |
|
25 { |
|
26 CMdsGetImeiAO *self = CMdsGetImeiAO::NewLC(); |
|
27 CleanupStack::Pop(); |
|
28 return self; |
|
29 } |
|
30 |
|
31 CMdsGetImeiAO* CMdsGetImeiAO::NewLC() |
|
32 { |
|
33 CMdsGetImeiAO *self = new (ELeave) CMdsGetImeiAO(); |
|
34 CleanupStack::PushL(self); |
|
35 self->ConstructL(); |
|
36 return self; |
|
37 } |
|
38 |
|
39 void CMdsGetImeiAO::ConstructL() |
|
40 { |
|
41 iTelephony = CTelephony::NewL(); |
|
42 CActiveScheduler::Add(this); |
|
43 } |
|
44 |
|
45 CMdsGetImeiAO::~CMdsGetImeiAO() |
|
46 { |
|
47 Cancel(); |
|
48 |
|
49 delete iTelephony; |
|
50 } |
|
51 |
|
52 TInt64 CMdsGetImeiAO::GetIMEI() |
|
53 { |
|
54 const TInt64 KRandomImei = 123456789012345; |
|
55 TInt64 serial = KRandomImei; |
|
56 |
|
57 #ifdef __ARMV5__ // skip getting IMEI for emulator |
|
58 CTelephony::TPhoneIdV1Pckg phoneIdPckg( iV1 ); |
|
59 |
|
60 iTelephony->GetPhoneId( iStatus, phoneIdPckg ); |
|
61 SetActive(); |
|
62 iAsw.Start(); |
|
63 Deque(); |
|
64 TLex imeiConverter(iImei); |
|
65 |
|
66 imeiConverter.Val(serial, EDecimal); |
|
67 #endif |
|
68 |
|
69 return serial; |
|
70 } |
|
71 |
|
72 void CMdsGetImeiAO::DoCancel() |
|
73 { |
|
74 iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel); |
|
75 } |
|
76 |
|
77 void CMdsGetImeiAO::RunL() |
|
78 { |
|
79 if(iStatus == KErrNone) |
|
80 { |
|
81 iImei = iV1.iSerialNumber; |
|
82 } |
|
83 iAsw.AsyncStop(); |
|
84 } |