|
1 /* |
|
2 * Copyright (c) 2007 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 the License "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "SystemInfoMisc.h" |
|
21 #include <HWRMLight.h> |
|
22 #include <HWRMVibra.h> |
|
23 #include <hal.h> |
|
24 #include <coemain.h> |
|
25 #include "SystemInfoBeep.h" |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CSystemInfoMisc::NewL |
|
31 // Two-phased constructor. |
|
32 // ----------------------------------------------------------------------------- |
|
33 CSystemInfoMisc* CSystemInfoMisc::NewL() |
|
34 { |
|
35 CSystemInfoMisc* self = new (ELeave) CSystemInfoMisc(); |
|
36 CleanupStack::PushL( self ); |
|
37 self->ConstructL(); |
|
38 CleanupStack::Pop( self ); |
|
39 return self; |
|
40 } |
|
41 |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CSystemInfoMisc::CSystemInfoMisc |
|
45 // C++ default constructor can NOT contain any code, that |
|
46 // might leave. |
|
47 // ----------------------------------------------------------------------------- |
|
48 CSystemInfoMisc::CSystemInfoMisc() |
|
49 { |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CSystemInfoMisc::ConstructL |
|
54 // Symbian 2nd phase constructor can leave. |
|
55 // ----------------------------------------------------------------------------- |
|
56 void CSystemInfoMisc::ConstructL() |
|
57 { |
|
58 iLightControl = CHWRMLight::NewL(); |
|
59 iVibraControl = CHWRMVibra::NewL(); |
|
60 iBeeper = CSystemInfoBeep::NewL(); |
|
61 // Create the widget registryclient session |
|
62 User::LeaveIfError( iWidgetRegistryClient.Connect() ); |
|
63 iWidgetRegistryConnected = ETrue; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CSystemInfoMisc::~CSystemInfoMisc |
|
68 // Destructor |
|
69 // ----------------------------------------------------------------------------- |
|
70 CSystemInfoMisc::~CSystemInfoMisc() |
|
71 { |
|
72 delete iLightControl; |
|
73 delete iVibraControl; |
|
74 delete iBeeper; |
|
75 if ( iWidgetRegistryConnected ) |
|
76 { |
|
77 iWidgetRegistryClient.Disconnect(); |
|
78 } |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CSystemInfoMisc::Beep |
|
83 // ----------------------------------------------------------------------------- |
|
84 void CSystemInfoMisc::Beep(TInt aFrequency, TTimeIntervalMicroSeconds aDuration ) |
|
85 { |
|
86 iBeeper->Play( aFrequency, aDuration ); |
|
87 } |
|
88 |
|
89 TInt CSystemInfoMisc::LightMinIntensity() const |
|
90 { |
|
91 return KHWRMLightMinIntensity; |
|
92 } |
|
93 |
|
94 TInt CSystemInfoMisc::LightMaxIntensity() const |
|
95 { |
|
96 return KHWRMLightMaxIntensity; |
|
97 } |
|
98 TInt CSystemInfoMisc::LightDefaultIntensity() const |
|
99 { |
|
100 return KHWRMDefaultIntensity; |
|
101 } |
|
102 TInt CSystemInfoMisc::LightInfiniteDuration() const |
|
103 { |
|
104 return KHWRMInfiniteDuration; |
|
105 } |
|
106 TInt CSystemInfoMisc::LightMaxDuration() const |
|
107 { |
|
108 return KHWRMLightMaxDuration; |
|
109 } |
|
110 TInt CSystemInfoMisc::LightDefaultCycleTime() const |
|
111 { |
|
112 return KHWRMDefaultCycleTime; |
|
113 } |
|
114 TInt CSystemInfoMisc::LightTargetPrimaryDisplayAndKeyboard() const |
|
115 { |
|
116 return CHWRMLight::EPrimaryDisplayAndKeyboard; |
|
117 } |
|
118 TInt CSystemInfoMisc::LightTargetSystem() const |
|
119 { |
|
120 return CHWRMLight::ESystemTarget; |
|
121 } |
|
122 |
|
123 void CSystemInfoMisc::LightOn( TInt aLightTarget, TInt aDuration, TInt aIntensity, TInt aFadeIn ) |
|
124 { |
|
125 TRAP_IGNORE( iLightControl->LightOnL(aLightTarget, aDuration, aIntensity, aFadeIn) ) |
|
126 } |
|
127 |
|
128 void CSystemInfoMisc::LightBlink( TInt aLightTarget, TInt aDuration, |
|
129 TInt aOnDuration, TInt aOffDuration, TInt aIntensity ) |
|
130 { |
|
131 TRAP_IGNORE( iLightControl->LightBlinkL(aLightTarget, aDuration, |
|
132 aOnDuration, aOffDuration, aIntensity) ) |
|
133 } |
|
134 |
|
135 void CSystemInfoMisc::LightOff( TInt aLightTarget, TInt aDuration, TInt aFadeOut ) |
|
136 { |
|
137 TRAP_IGNORE( iLightControl->LightOffL(aLightTarget, aDuration, aFadeOut) ) |
|
138 } |
|
139 |
|
140 |
|
141 TInt CSystemInfoMisc::VibraMinIntensity() const |
|
142 { |
|
143 return KHWRMVibraMinIntensity; |
|
144 } |
|
145 |
|
146 TInt CSystemInfoMisc::VibraMaxIntensity() const |
|
147 { |
|
148 return KHWRMVibraMaxIntensity; |
|
149 } |
|
150 |
|
151 TInt CSystemInfoMisc::VibraMaxDuration() const |
|
152 { |
|
153 return KHWRMVibraMaxDuration; |
|
154 } |
|
155 |
|
156 TInt CSystemInfoMisc::VibraSettings() const |
|
157 { |
|
158 TInt s = iVibraControl->VibraSettings(); |
|
159 // explicitly map enum values in case Vibra API changes. |
|
160 switch ( s ) |
|
161 { |
|
162 case CHWRMVibra::EVibraModeUnknown: |
|
163 s = 0; |
|
164 break; |
|
165 case CHWRMVibra::EVibraModeON: |
|
166 s = 1; |
|
167 break; |
|
168 case CHWRMVibra::EVibraModeOFF: |
|
169 s = 2; |
|
170 break; |
|
171 } |
|
172 return s; |
|
173 } |
|
174 |
|
175 void CSystemInfoMisc::StartVibra( TInt aDuration, TInt aIntensity ) |
|
176 { |
|
177 TRAP_IGNORE( iVibraControl->StartVibraL( aDuration, aIntensity ) ) |
|
178 } |
|
179 |
|
180 void CSystemInfoMisc::StopVibra() |
|
181 { |
|
182 TRAP_IGNORE( iVibraControl->StopVibraL( ) ) |
|
183 } |
|
184 |
|
185 |
|
186 TInt CSystemInfoMisc::TotalRam() |
|
187 { |
|
188 TInt m = 0; |
|
189 (void) HAL::Get( HALData::EMemoryRAM, m ); |
|
190 return m; |
|
191 } |
|
192 |
|
193 TInt CSystemInfoMisc::FreeRam() |
|
194 { |
|
195 TInt m = 0; |
|
196 (void) HAL::Get( HALData::EMemoryRAMFree, m ); |
|
197 return m; |
|
198 } |
|
199 |
|
200 void CSystemInfoMisc::Language( TDes& aLangCode ) |
|
201 { |
|
202 if ( iWidgetRegistryConnected ) |
|
203 { |
|
204 iWidgetRegistryClient.GetLprojName( aLangCode ); |
|
205 } |
|
206 else |
|
207 { |
|
208 aLangCode.Copy(_L("")); |
|
209 } |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CSystemInfoPlugin::DriveList |
|
214 // |
|
215 // ----------------------------------------------------------------------------- |
|
216 void CSystemInfoMisc::DriveList( TDes8& aDriveList ) |
|
217 { |
|
218 RFs& fs = CCoeEnv::Static()->FsSession(); |
|
219 TDriveList driveList; |
|
220 TInt err = fs.DriveList( driveList ); |
|
221 TInt effectiveDriveCount = 0; |
|
222 aDriveList.SetLength( 0 ); |
|
223 |
|
224 for ( TInt i = 0; i < KMaxDrives && err == KErrNone; i++ ) |
|
225 { |
|
226 if ( driveList[i] && i != EDriveD && i != EDriveZ ) |
|
227 { |
|
228 TChar c; |
|
229 if ( fs.DriveToChar( i, c ) == KErrNone ) |
|
230 { |
|
231 if ( effectiveDriveCount ) |
|
232 { |
|
233 aDriveList.Append( ' ' ); |
|
234 } |
|
235 aDriveList.Append( (TUint)c ); |
|
236 effectiveDriveCount++; |
|
237 } |
|
238 } |
|
239 } |
|
240 } |
|
241 |
|
242 TReal CSystemInfoMisc::DriveSize( TChar c ) |
|
243 { |
|
244 RFs& fs = CCoeEnv::Static()->FsSession(); |
|
245 TInt drive; |
|
246 TVolumeInfo v; |
|
247 if ( fs.CharToDrive( c, drive ) == KErrNone ) |
|
248 { |
|
249 if ( drive != EDriveD && drive != EDriveZ ) |
|
250 { |
|
251 if ( !fs.Volume( v, drive ) ) |
|
252 { |
|
253 TInt64 si = v.iSize; |
|
254 TReal sr = si; |
|
255 return sr; |
|
256 } |
|
257 } |
|
258 } |
|
259 return 0; |
|
260 } |
|
261 |
|
262 TReal CSystemInfoMisc::DriveFree( TChar c ) |
|
263 { |
|
264 RFs& fs = CCoeEnv::Static()->FsSession(); |
|
265 TInt drive; |
|
266 TVolumeInfo v; |
|
267 if ( fs.CharToDrive( c, drive ) == KErrNone ) |
|
268 { |
|
269 if ( drive != EDriveD && drive != EDriveZ ) |
|
270 { |
|
271 if ( !fs.Volume( v, drive ) ) |
|
272 { |
|
273 TInt64 fi = v.iFree; |
|
274 TReal fr = fi; |
|
275 return fr; |
|
276 } |
|
277 } |
|
278 } |
|
279 return 0; |
|
280 } |
|
281 |
|
282 |
|
283 // End of File |