1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
|
19 * |
|
20 */ |
|
21 |
|
22 #include "cdeviceinfo.h" |
|
23 |
|
24 #include <etel3rdparty.h> |
|
25 |
|
26 CDeviceInfo* CDeviceInfo::NewL() |
|
27 { |
|
28 CDeviceInfo* self = NewLC(); |
|
29 CleanupStack::Pop( self ); |
|
30 return self; |
|
31 } |
|
32 |
|
33 CDeviceInfo* CDeviceInfo::NewLC() |
|
34 { |
|
35 CDeviceInfo* self = new ( ELeave ) CDeviceInfo(); |
|
36 CleanupStack::PushL( self ); |
|
37 self->ConstructL(); |
|
38 return self; |
|
39 } |
|
40 |
|
41 void CDeviceInfo::ConstructL() |
|
42 { |
|
43 CActiveScheduler::Add( this ); |
|
44 iTelephony = CTelephony::NewL(); |
|
45 iWait = new ( ELeave ) CActiveSchedulerWait(); |
|
46 } |
|
47 |
|
48 CDeviceInfo::CDeviceInfo() |
|
49 :CActive( EPriorityNormal ), iBatteryInfoV1Pkg( iBatteryInfoV1 ), |
|
50 iPhoneIdV1Pkg( iPhoneIdV1 ), |
|
51 iSignalStrengthV1Pckg( iSignalStrengthV1 ), |
|
52 iSubscriberIdV1Pckg( iSubscriberIdV1 ) |
|
53 { |
|
54 } |
|
55 |
|
56 CDeviceInfo::~CDeviceInfo() |
|
57 { |
|
58 Cancel(); |
|
59 delete iTelephony; |
|
60 } |
|
61 |
|
62 TBuf<CTelephony::KPhoneSerialNumberSize> CDeviceInfo::imei() |
|
63 { |
|
64 Cancel(); |
|
65 iTelephony->GetPhoneId( iStatus, iPhoneIdV1Pkg ); |
|
66 SetActive(); |
|
67 |
|
68 if ( !iWait->IsStarted() ) |
|
69 { |
|
70 iWait->Start(); |
|
71 } |
|
72 return iPhoneIdV1.iSerialNumber; |
|
73 } |
|
74 |
|
75 TBuf<CTelephony::KPhoneModelIdSize> CDeviceInfo::model() |
|
76 { |
|
77 Cancel(); |
|
78 iTelephony->GetPhoneId( iStatus, iPhoneIdV1Pkg ); |
|
79 SetActive(); |
|
80 |
|
81 if ( !iWait->IsStarted() ) |
|
82 { |
|
83 iWait->Start(); |
|
84 } |
|
85 return iPhoneIdV1.iModel; |
|
86 } |
|
87 |
|
88 TBuf<CTelephony::KPhoneManufacturerIdSize> CDeviceInfo::manufacturer() |
|
89 { |
|
90 Cancel(); |
|
91 iTelephony->GetPhoneId( iStatus, iPhoneIdV1Pkg ); |
|
92 SetActive(); |
|
93 |
|
94 if ( !iWait->IsStarted() ) |
|
95 { |
|
96 iWait->Start(); |
|
97 } |
|
98 return iPhoneIdV1.iManufacturer; |
|
99 } |
|
100 |
|
101 TBuf<CTelephony::KIMSISize> CDeviceInfo::imsi() |
|
102 { |
|
103 Cancel(); |
|
104 iTelephony->GetSubscriberId( iStatus,iSubscriberIdV1Pckg ); |
|
105 SetActive(); |
|
106 |
|
107 if (!iWait->IsStarted()) |
|
108 { |
|
109 iWait->Start(); |
|
110 } |
|
111 return iSubscriberIdV1.iSubscriberId; |
|
112 } |
|
113 |
|
114 TUint CDeviceInfo::batteryLevel() |
|
115 { |
|
116 Cancel(); |
|
117 iTelephony->GetBatteryInfo( iStatus,iBatteryInfoV1Pkg ); |
|
118 SetActive(); |
|
119 |
|
120 if ( !iWait->IsStarted() ) |
|
121 { |
|
122 iWait->Start(); |
|
123 } |
|
124 return iBatteryInfoV1.iChargeLevel; |
|
125 } |
|
126 |
|
127 TInt32 CDeviceInfo::signalStrength() |
|
128 { |
|
129 Cancel(); |
|
130 iTelephony->GetSignalStrength( iStatus, iSignalStrengthV1Pckg ); |
|
131 SetActive(); |
|
132 if ( !iWait->IsStarted() ) |
|
133 { |
|
134 iWait->Start(); |
|
135 } |
|
136 return iSignalStrengthV1.iSignalStrength; |
|
137 } |
|
138 |
|
139 void CDeviceInfo::DoCancel() |
|
140 { |
|
141 iTelephony->CancelAsync( CTelephony::EGetPhoneIdCancel ); |
|
142 } |
|
143 |
|
144 void CDeviceInfo::RunL() |
|
145 { |
|
146 iWait->AsyncStop(); |
|
147 } |
|