|
1 /* |
|
2 * Copyright (c) 2002 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: CSysInfoService class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <W32STD.H> |
|
20 #include <hal.h> |
|
21 #include <FeatMgr.h> |
|
22 #include <bldvariant.hrh> |
|
23 #include <PtiEngine.h> |
|
24 #include <driveinfo.h> |
|
25 |
|
26 |
|
27 #include <centralrepository.h> |
|
28 #include <HWRMVibraSDKCRKeys.h> |
|
29 #include <SettingsInternalCRKeys.h> |
|
30 #include <HWRMLightDomainCRKeys.h> |
|
31 #include <AknFepInternalCRKeys.h> |
|
32 #include <IR_SOCK.H> |
|
33 #include <btserversdkcrkeys.h> |
|
34 #include <SysUtilDomainCRKeys.h> |
|
35 |
|
36 #include <e32property.h> |
|
37 #include <HWRMDomainPSKeys.h> |
|
38 #include <NetworkHandlingDomainPSKeys.h> |
|
39 #include <HWRMPowerStateSDKPSKeys.h> |
|
40 #include <wlaninternalpskeys.h> |
|
41 #include <UikonInternalPSKeys.h> |
|
42 #include <btengsettings.h> |
|
43 |
|
44 #include <usbman.h> |
|
45 #include <AknsWallpaperUtils.h> |
|
46 |
|
47 #include "sysinfoservice.h" |
|
48 #include "sysinfo.h" |
|
49 #include "SysInfoUtils.h" |
|
50 #include "entitykeys.h" |
|
51 #include "activerequests.h" |
|
52 #include "deviceinfo.h" |
|
53 #include "sysrange.h" |
|
54 |
|
55 |
|
56 using namespace SysInfo; |
|
57 |
|
58 // CONSTANT DECLARATIONS |
|
59 const TInt KGranularity(2); |
|
60 const TInt KPhoneWlanMacAddressLength = 50; |
|
61 const TChar KPhoneWlanSeparator (':'); |
|
62 _LIT(KWLanMACDataFormat, "%02x"); |
|
63 |
|
64 // -------------------------------------------------------------------- |
|
65 // CSysInfoService::CSysInfoService() |
|
66 // C++ default constructor. |
|
67 // -------------------------------------------------------------------- |
|
68 // |
|
69 EXPORT_C CSysInfoService::CSysInfoService():iFeatureManagerInitialized(EFalse) |
|
70 { |
|
71 } |
|
72 |
|
73 // -------------------------------------------------------------------- |
|
74 // CSysInfoService::~CSysInfoService() |
|
75 // Destructor. |
|
76 // -------------------------------------------------------------------- |
|
77 // |
|
78 CSysInfoService::~CSysInfoService() |
|
79 { |
|
80 //If initialized uninitialize. |
|
81 if(iFeatureManagerInitialized) |
|
82 FeatureManager::UnInitializeLib(); |
|
83 |
|
84 delete iDeviceInfo; |
|
85 |
|
86 // Cancel any ongoing asynchronous requests and |
|
87 // Deallocate resources. |
|
88 ActiveStore::ReleaseResources(); |
|
89 } |
|
90 |
|
91 // -------------------------------------------------------------------- |
|
92 // CSysInfoService::NewL() |
|
93 // Two-phased constructor. |
|
94 // -------------------------------------------------------------------- |
|
95 // |
|
96 EXPORT_C CSysInfoService* CSysInfoService::NewL () |
|
97 { |
|
98 CSysInfoService* self = new (ELeave) CSysInfoService(); |
|
99 return self; |
|
100 } |
|
101 |
|
102 // -------------------------------------------------------------------- |
|
103 // CSysInfoService::SetInfoL() |
|
104 // Modifies the system attribute value specified in aRequest. |
|
105 // -------------------------------------------------------------------- |
|
106 // |
|
107 EXPORT_C void CSysInfoService::SetInfoL( const TDesC& aEntity, |
|
108 const TDesC& aKey, const CSysData* aInput ) |
|
109 { |
|
110 if(!aInput) |
|
111 User::Leave(KErrArgument); |
|
112 |
|
113 if( !aEntity.CompareF(KGeneral) ) |
|
114 SetGeneralInfoL(aKey,aInput); |
|
115 else if( !aEntity.CompareF(KDisplay) ) |
|
116 SetDisplayInfoL(aKey,aInput); |
|
117 // Bluetooth and IR which require WriteDeviceData are not usergratable permissions, |
|
118 // hence this funtionality is not exposed currently. |
|
119 #ifdef _REQUIRE_WRITEDEVICEDATA_ |
|
120 else if( !aEntity.CompareF(KConnectivity) ) |
|
121 SetConnectivityInfoL(aKey,aInput); |
|
122 #endif |
|
123 else |
|
124 User::Leave(KErrNotFound); |
|
125 } |
|
126 |
|
127 // -------------------------------------------------------------------- |
|
128 // CSysInfoService::Cancel() |
|
129 // Cancels any outstanding requests and releases resources owned by them. |
|
130 // -------------------------------------------------------------------- |
|
131 // |
|
132 EXPORT_C void CSysInfoService::Cancel(TInt32 aTransID) |
|
133 { |
|
134 ActiveStore::RemoveRequest(aTransID); |
|
135 } |
|
136 |
|
137 // -------------------------------------------------------------------- |
|
138 // CSysInfoService::SetConnectivityInfoL() |
|
139 // Modifies the Connectivity Entity key values. |
|
140 // -------------------------------------------------------------------- |
|
141 // |
|
142 void CSysInfoService::SetConnectivityInfoL(const TDesC& aKey, |
|
143 const CSysData* aInput) |
|
144 { |
|
145 //In Connectivity bluetooth, Infrared takes input argument of type EStatus. |
|
146 if( CSysData::EStatus != aInput->DataType() ) |
|
147 User::Leave(KErrArgument); |
|
148 |
|
149 TInt inputStatus = ((CStatus*)aInput)->Status(); |
|
150 |
|
151 if( !aKey.CompareF(KBlueTooth) ) |
|
152 { |
|
153 CBTEngSettings* BtSettings = CBTEngSettings::NewLC(); |
|
154 if( inputStatus == EOn) |
|
155 User::LeaveIfError(BtSettings->SetPowerState( EBTPowerOn )); |
|
156 else if(inputStatus == EOff) |
|
157 User::LeaveIfError(BtSettings->SetPowerState( EBTPowerOff )); |
|
158 else |
|
159 User::Leave(KErrArgument); |
|
160 CleanupStack::PopAndDestroy(BtSettings); |
|
161 } |
|
162 |
|
163 else if( !aKey.CompareF(KInfraRed) ) |
|
164 { |
|
165 if(inputStatus == EOn) |
|
166 User::LeaveIfError(RProperty::Set(KIrdaPropertyCategory, |
|
167 KIrdaStatus,TIrdaStatusCodes::EIrLoaded)); |
|
168 else if(inputStatus == EOff) |
|
169 User::LeaveIfError(RProperty::Set(KIrdaPropertyCategory, |
|
170 KIrdaStatus,TIrdaStatusCodes::EIrUnloaded)); |
|
171 else |
|
172 User::Leave(KErrArgument); |
|
173 } |
|
174 else |
|
175 User::Leave(KErrNotFound); |
|
176 } |
|
177 |
|
178 // -------------------------------------------------------------------- |
|
179 // CSysInfoService::SetGeneralInfoL() |
|
180 // Modifies the General Entity key values. |
|
181 // -------------------------------------------------------------------- |
|
182 // |
|
183 void CSysInfoService::SetGeneralInfoL(const TDesC& aKey, const CSysData* aInput) |
|
184 { |
|
185 // for all General Entity keys input must be of type EStatus. |
|
186 if( aInput->DataType() != CSysData::EStatus ) |
|
187 User::Leave(KErrArgument); |
|
188 |
|
189 TInt inStatus = ((CStatus*)aInput)->Status(); |
|
190 |
|
191 if( !aKey.CompareF(KInputLanguage) ) |
|
192 { |
|
193 CPtiEngine* PtiEngine; |
|
194 PtiEngine = CPtiEngine::NewL(); |
|
195 CleanupStack::PushL(PtiEngine); |
|
196 User::LeaveIfError(PtiEngine->ActivateLanguageL(inStatus)); |
|
197 CleanupStack::PopAndDestroy(PtiEngine); |
|
198 RepositoryUtil::SetRepositoryKeyL(KCRUidAknFep, |
|
199 KAknFepInputTxtLang,inStatus); |
|
200 } |
|
201 else if( !aKey.CompareF(KPridictiveText) ) |
|
202 { |
|
203 if( EEnabled == inStatus || EDisabled == inStatus ) |
|
204 RepositoryUtil::SetRepositoryKeyL(KCRUidAknFep, |
|
205 KAknFepPredTxtFlag,inStatus); |
|
206 else |
|
207 User::Leave(KErrArgument); |
|
208 } |
|
209 else if( !aKey.CompareF(KVibraActive) ) |
|
210 { |
|
211 if( EEnabled == inStatus || EDisabled == inStatus ) |
|
212 RepositoryUtil::SetRepositoryKeyL(KCRUidVibraCtrl, |
|
213 KVibraCtrlProfileVibraEnabled,inStatus); |
|
214 else |
|
215 User::Leave(KErrArgument); |
|
216 } |
|
217 else |
|
218 User::Leave(KErrNotFound); |
|
219 } |
|
220 |
|
221 // -------------------------------------------------------------------- |
|
222 // CSysInfoService::SetDisplayInfoL() |
|
223 // Modifies the Display Entity key values. |
|
224 // -------------------------------------------------------------------- |
|
225 // |
|
226 void CSysInfoService::SetDisplayInfoL(const TDesC& aKey, const CSysData* aInput) |
|
227 { |
|
228 // Input validation. |
|
229 // For wallpaper input type must be EStingData and |
|
230 // for others keys input type must be EStatus. |
|
231 if( !aKey.CompareF(KWallpaper) ) |
|
232 { |
|
233 if(aInput->DataType() != CSysData::EStringData) |
|
234 User::Leave(KErrArgument); |
|
235 } |
|
236 else if( aInput->DataType() != CSysData::EStatus ) |
|
237 User::Leave(KErrArgument); |
|
238 |
|
239 TInt inputStatus = 0; |
|
240 TPtrC inputString; |
|
241 //Read Input data into InputStatus, InputString. |
|
242 if( !aKey.CompareF(KWallpaper) ) |
|
243 { |
|
244 ((CStringData*)aInput)->StringData(inputString); |
|
245 } |
|
246 else |
|
247 { |
|
248 inputStatus = ((CStatus*)aInput)->Status(); |
|
249 inputStatus = inputStatus; |
|
250 } |
|
251 |
|
252 //go thru Display entity keys. |
|
253 // Display Entity keys requiring WriteDeviceData are commented currently as these are not |
|
254 // usergrantable permissions. |
|
255 #ifdef _REQUIRE_WRITEDEVICEDATA_ |
|
256 if( !aKey.CompareF(KBrightness) ) |
|
257 { |
|
258 if ( KBrightnessMax < inputStatus || KBrightnessMin > inputStatus ) |
|
259 User::Leave(KErrArgument); |
|
260 |
|
261 RepositoryUtil::SetRepositoryKeyL(KCRUidLightSettings, |
|
262 KLightIntensity,inputStatus); |
|
263 } |
|
264 else if( !aKey.CompareF(KScreenSaverTimeOut) ) |
|
265 { |
|
266 if ( KScreenSaverTimeoutMax < inputStatus || |
|
267 KScreenSaverTimeoutMin > inputStatus ) |
|
268 User::Leave(KErrArgument); |
|
269 |
|
270 RepositoryUtil::SetRepositoryKeyL(KCRUidPersonalizationSettings, |
|
271 KSettingsScreenSaverPeriod,inputStatus); |
|
272 } |
|
273 else if( !aKey.CompareF(KAutoLockTime) ) |
|
274 { |
|
275 if ( KAutoLockTimeoutMax < inputStatus || |
|
276 KAutoLockTimeoutMin > inputStatus ) |
|
277 User::Leave(KErrArgument); |
|
278 |
|
279 RepositoryUtil::SetRepositoryKeyL(KCRUidSecuritySettings, |
|
280 KSettingsAutoLockTime,inputStatus); |
|
281 } |
|
282 else if( !aKey.CompareF(KKeyGaurdTime) ) |
|
283 { |
|
284 if ( KKeyGaurdTimeoutMax < inputStatus || |
|
285 KKeyGaurdTimeoutMin > inputStatus ) |
|
286 User::Leave(KErrArgument); |
|
287 |
|
288 RepositoryUtil::SetRepositoryKeyL(KCRUidSecuritySettings, |
|
289 KSettingsAutomaticKeyguardTime,inputStatus); |
|
290 } |
|
291 else if( !aKey.CompareF(KLightTimeOut) ) |
|
292 { |
|
293 if ( KLightTimeoutMax < inputStatus || |
|
294 KLightTimeoutMin > inputStatus ) |
|
295 User::Leave(KErrArgument); |
|
296 |
|
297 RepositoryUtil::SetRepositoryKeyL(KCRUidLightSettings, |
|
298 KDisplayLightsTimeout,inputStatus); |
|
299 } |
|
300 #endif |
|
301 if( !aKey.CompareF(KWallpaper) ) |
|
302 { |
|
303 User::LeaveIfError( |
|
304 AknsWallpaperUtils::SetIdleWallpaper(inputString,NULL,0)); |
|
305 } |
|
306 else |
|
307 User::Leave(KErrNotFound); |
|
308 } |
|
309 |
|
310 // -------------------------------------------------------------------- |
|
311 // CSysInfoService::GetInfoL() SYNC |
|
312 // Retrives the specified attribute value. |
|
313 // aOutput contains attribute value. |
|
314 // -------------------------------------------------------------------- |
|
315 // |
|
316 EXPORT_C void CSysInfoService::GetInfoL( const TDesC& aEntity, const TDesC& aKey, |
|
317 CSysData*& aOutput,const CSysData* aInput ) |
|
318 { |
|
319 // retrieve data based Entity |
|
320 if( !aEntity.CompareF(KNetwork) ) |
|
321 GetNetworkInfoL(aKey,aOutput); |
|
322 |
|
323 else if( !aEntity.CompareF(KBattery) ) |
|
324 GetBatteryInfoL(aKey,aOutput); |
|
325 |
|
326 else if( !aEntity.CompareF(KConnectivity) ) |
|
327 GetConnectivittyInfoL(aKey,aOutput); |
|
328 |
|
329 else if( !aEntity.CompareF(KDisplay) ) |
|
330 GetDisplayInfoL(aKey,aOutput); |
|
331 |
|
332 else if( !aEntity.CompareF(KGeneral) ) |
|
333 GetGeneralInfoL(aKey,aOutput); |
|
334 |
|
335 else if( !aEntity.CompareF(KMemory) ) |
|
336 GetMemoryInfoL(aKey,aInput,aOutput); |
|
337 |
|
338 else if( !aEntity.CompareF(KDevice) ) |
|
339 GetDeviceInfoL(aKey,aOutput); |
|
340 |
|
341 else if( !aEntity.CompareF(KFeatures) ) |
|
342 GetFeatureInfoL(aKey,aOutput); |
|
343 |
|
344 else |
|
345 User::Leave(KErrNotFound); |
|
346 } |
|
347 |
|
348 // -------------------------------------------------------------------- |
|
349 // CSysInfoService::GetInfoL() ASYNC |
|
350 // Creates an appropriate active object to serve the purpose of the |
|
351 // specified system attribute. Adds created active object to |
|
352 // Active Store. |
|
353 // -------------------------------------------------------------------- |
|
354 // |
|
355 EXPORT_C void CSysInfoService::GetInfoL( const TDesC& aEntity, const TDesC& aKey, |
|
356 TInt32 aTransID, ISystemObserver* aCallback, |
|
357 const CSysData* aInput ) |
|
358 { |
|
359 if(!aCallback) |
|
360 User::Leave(KErrGeneral); |
|
361 |
|
362 TSysRequest systemRequest(aEntity,aKey,aInput,aTransID,aCallback, |
|
363 TSysRequest::EASyncONESHOT); |
|
364 |
|
365 CActiveRequest* activeRequestObj; |
|
366 CActiveRequest::CreateActiveRequestL(systemRequest,activeRequestObj); |
|
367 |
|
368 //place handle on cleanupstack. |
|
369 CleanupStack::PushL(activeRequestObj); |
|
370 //Add request handle to active store. |
|
371 ActiveStore::AddRequestL(activeRequestObj); |
|
372 CleanupStack::Pop(activeRequestObj); |
|
373 //Issue request. |
|
374 TInt err = activeRequestObj->Request(); |
|
375 |
|
376 if( KErrNone != err) |
|
377 { |
|
378 ActiveStore::RemoveRequest(aTransID); |
|
379 User::Leave(err); |
|
380 } |
|
381 } |
|
382 |
|
383 // -------------------------------------------------------------------- |
|
384 // CSysInfoService::GetNotificationL() ASYNC |
|
385 // Creates an appropriate active object to serve the purpose of the |
|
386 // specified system attribute. Adds created active object to |
|
387 // Active Store. |
|
388 // -------------------------------------------------------------------- |
|
389 // |
|
390 EXPORT_C void CSysInfoService::GetNotificationL( const TDesC& aEntity, |
|
391 const TDesC& aKey, TInt32 aTransID, |
|
392 ISystemObserver* aCallback, |
|
393 const CSysData* aInput ) |
|
394 { |
|
395 if(!aCallback) |
|
396 User::Leave(KErrGeneral); |
|
397 |
|
398 TSysRequest systemRequest(aEntity,aKey,aInput,aTransID,aCallback, |
|
399 TSysRequest::ENotification); |
|
400 |
|
401 CActiveRequest* activeRequestObj; |
|
402 CActiveRequest::CreateActiveRequestL(systemRequest,activeRequestObj); |
|
403 |
|
404 //place handle on cleanupstack. |
|
405 CleanupStack::PushL(activeRequestObj); |
|
406 |
|
407 //Add request handle to active store. |
|
408 ActiveStore::AddRequestL(activeRequestObj); |
|
409 |
|
410 //Issue request. |
|
411 TInt err = activeRequestObj->Request(); |
|
412 |
|
413 if( KErrNone != err) |
|
414 { |
|
415 //remove request handle on cleanup stack. |
|
416 CleanupStack::Pop(activeRequestObj); |
|
417 ActiveStore::RemoveRequest(aTransID); |
|
418 User::Leave(err); |
|
419 } |
|
420 |
|
421 //remove request handle on cleanup stack. |
|
422 CleanupStack::Pop(activeRequestObj); |
|
423 } |
|
424 |
|
425 // -------------------------------------------------------------------- |
|
426 // CSysInfoService::GetNetworkInfoL() |
|
427 // Retrives network related synchronous keys information. |
|
428 // returns CSysData. |
|
429 // -------------------------------------------------------------------- |
|
430 // |
|
431 void CSysInfoService::GetNetworkInfoL(TPtrC aKey,CSysData*& aSysData) |
|
432 { |
|
433 TInt status = 0; |
|
434 if ( !aKey.CompareF(KRegistrationStatus) ) |
|
435 { |
|
436 User::LeaveIfError(RProperty::Get(KPSUidNetworkInfo, |
|
437 KNWRegistrationStatus,status)); |
|
438 } |
|
439 else if( !aKey.CompareF(KNetworkMode) ) |
|
440 { |
|
441 User::LeaveIfError(RProperty::Get(KPSUidNetworkInfo, |
|
442 KNWTelephonyNetworkMode,status)); |
|
443 } |
|
444 else |
|
445 { |
|
446 User::Leave(KErrNotFound); |
|
447 } |
|
448 aSysData = CStatus::NewL((status-1)); |
|
449 } |
|
450 |
|
451 // -------------------------------------------------------------------- |
|
452 // CSysInfoService::GetBatteryInfoL() |
|
453 // Retrives battery related synchronous keys information. |
|
454 // On return aSysData consists of key value. |
|
455 // -------------------------------------------------------------------- |
|
456 // |
|
457 void CSysInfoService::GetBatteryInfoL(TPtrC aKey,CSysData*& aSysData) |
|
458 { |
|
459 TInt status = 0; |
|
460 if( !aKey.CompareF(KChargingStatus) ) |
|
461 { |
|
462 TInt chargeStatus = 0; |
|
463 User::LeaveIfError(RProperty::Get(KPSUidHWRMPowerState, |
|
464 KHWRMChargingStatus,chargeStatus)); |
|
465 // ChargeStatus is manupulated to give only these states Charging, |
|
466 // NotCharging and Unknown |
|
467 if ( EChargingStatusCharging == chargeStatus || |
|
468 EChargingStatusAlmostComplete == chargeStatus || |
|
469 EChargingStatusChargingContinued == chargeStatus ) |
|
470 status = ECharging; |
|
471 else if( EChargingStatusNotConnected == chargeStatus || |
|
472 EChargingStatusNotCharging == chargeStatus || |
|
473 EChargingStatusChargingComplete == chargeStatus ) |
|
474 status = ENotCharging; |
|
475 else |
|
476 status = EUnknown; |
|
477 } |
|
478 else |
|
479 User::Leave(KErrNotFound); |
|
480 aSysData = CStatus::NewL(status); |
|
481 } |
|
482 // -------------------------------------------------------------------- |
|
483 // CSysInfoService::GetMemoryInfoL() |
|
484 // Retrives memory related synchronous keys information. |
|
485 // On return aSysData consists of SA value. |
|
486 // -------------------------------------------------------------------- |
|
487 // |
|
488 void CSysInfoService::GetMemoryInfoL(const TDesC& aKey, const CSysData* aInput, |
|
489 CSysData*& aOutput) |
|
490 { |
|
491 RFs Fs; |
|
492 CleanupClosePushL(Fs); |
|
493 User::LeaveIfError(Fs.Connect()); |
|
494 |
|
495 if ( !aKey.CompareF(KListDrives) ) |
|
496 { |
|
497 TDriveList drives; |
|
498 User::LeaveIfError(Fs.DriveList(drives)); |
|
499 aOutput = CDriveList::NewL(drives); |
|
500 } |
|
501 else if( !aKey.CompareF(KDriveInfo) ) |
|
502 { |
|
503 CDriveInfo* inputDrvInfo=NULL; |
|
504 if( aInput && CSysData::EDriveInfo == aInput->DataType()) |
|
505 inputDrvInfo = (CDriveInfo*) aInput; |
|
506 else |
|
507 User::Leave(KErrArgument); |
|
508 |
|
509 TInt drvNumber = inputDrvInfo->DriveNumber(); |
|
510 if ( !Fs.IsValidDrive(drvNumber) ) |
|
511 User::Leave(KErrNotFound); |
|
512 |
|
513 TVolumeInfo volumeInfo; |
|
514 User::LeaveIfError(Fs.Volume(volumeInfo,drvNumber)); |
|
515 aOutput = CDriveInfo::NewL(drvNumber,volumeInfo); |
|
516 } |
|
517 else if( !aKey.CompareF(KMemoryCard) ) |
|
518 { |
|
519 TInt memoryCardState (-1); |
|
520 TInt defaultMemoryCard( 0 ); |
|
521 User::LeaveIfError( DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, defaultMemoryCard ) ); |
|
522 TUint driveStatus( 0 ); |
|
523 User::LeaveIfError( DriveInfo::GetDriveStatus( Fs, defaultMemoryCard, driveStatus ) ); |
|
524 if( driveStatus & DriveInfo::EDrivePresent ) |
|
525 memoryCardState = ETrue; |
|
526 else |
|
527 memoryCardState = EFalse; |
|
528 aOutput = CStatus::NewL(memoryCardState); |
|
529 |
|
530 } |
|
531 else |
|
532 User::Leave(KErrNotFound); |
|
533 |
|
534 CleanupStack::PopAndDestroy(&Fs); |
|
535 } |
|
536 |
|
537 // -------------------------------------------------------------------- |
|
538 // CSysInfoService::GetFeatureInfoL() |
|
539 // Retrives feature related synchronous keys information. |
|
540 // On return aSysData consists of key value. |
|
541 // -------------------------------------------------------------------- |
|
542 // |
|
543 void CSysInfoService::GetFeatureInfoL(TPtrC aKey,CSysData*& aSysData) |
|
544 { |
|
545 TInt featureID(0); |
|
546 |
|
547 // Get the Feature ID to query feature manager. |
|
548 if( !aKey.CompareF(KBlueTooth) ) |
|
549 featureID = KFeatureIdBt; |
|
550 else if( !aKey.CompareF(KInfraRed) ) |
|
551 featureID = KFeatureIdIrda; |
|
552 else if( !aKey.CompareF(KCamera) ) |
|
553 featureID = KFeatureIdCamera; |
|
554 else if( !aKey.CompareF(KMemoryCard) ) |
|
555 featureID = KFeatureIdMmc; |
|
556 else if( !aKey.CompareF(KFMRadio) ) |
|
557 featureID = KFeatureIdFmRadio; |
|
558 else if( !aKey.CompareF(KQwerty) ) |
|
559 featureID = KFeatureIdQwertyInput; |
|
560 else if( !aKey.CompareF(KWLan) ) |
|
561 featureID = KFeatureIdProtocolWlan; |
|
562 else if( !aKey.CompareF(KUsb) ) |
|
563 featureID = KFeatureIdUsb; |
|
564 else if( !aKey.CompareF(KPen) ) |
|
565 featureID = KFeatureIdPenSupport; |
|
566 else if( !aKey.CompareF(KLED) ) |
|
567 featureID = KFeatureIdPenSupport; |
|
568 else if( !aKey.CompareF(KCoverUI) ) |
|
569 featureID = KFeatureIdCoverDisplay; |
|
570 else if( !aKey.CompareF(KSideVolumeKeys) ) |
|
571 featureID = KFeatureIdSideVolumeKeys; |
|
572 else if( !aKey.CompareF(KVibra) ) |
|
573 featureID = KFeatureIdVibra; |
|
574 else |
|
575 User::Leave(KErrNotFound); |
|
576 |
|
577 //Initialize feature manager if not. |
|
578 if (!iFeatureManagerInitialized) |
|
579 { |
|
580 FeatureManager::InitializeLibL(); |
|
581 iFeatureManagerInitialized = ETrue; |
|
582 } |
|
583 |
|
584 TBool isSupported = ETrue; |
|
585 // LED feature is read using HAL others feature manager. |
|
586 if( !aKey.CompareF(KLED) ) |
|
587 { |
|
588 TInt NumLEDs(0); |
|
589 TInt Err = HAL::Get(HALData::ELEDs,NumLEDs); |
|
590 if( KErrNone == Err ) |
|
591 isSupported = ETrue; |
|
592 else if( KErrNotSupported == Err ) |
|
593 isSupported = EFalse; |
|
594 else |
|
595 User::Leave(Err); |
|
596 } |
|
597 else |
|
598 { |
|
599 isSupported = FeatureManager::FeatureSupported(featureID); |
|
600 } |
|
601 |
|
602 aSysData = CStatus::NewL(isSupported); |
|
603 } |
|
604 |
|
605 // -------------------------------------------------------------------- |
|
606 // CSysInfoService::GetConnectivityInfoL() |
|
607 // Retrives Connectivity related synchronous keys information. |
|
608 // On return aSysData consists of key value. |
|
609 // -------------------------------------------------------------------- |
|
610 // |
|
611 void CSysInfoService::GetConnectivittyInfoL(TPtrC aKey,CSysData*& aSysData) |
|
612 { |
|
613 if ( !aKey.CompareF(KBlueTooth) ) |
|
614 { |
|
615 TInt bTPower = 0; |
|
616 RepositoryUtil::GetRepositoryKeyL(KCRUidBluetoothPowerState, |
|
617 KBTPowerState,bTPower); |
|
618 aSysData = CStatus::NewL(bTPower); |
|
619 } |
|
620 else if( !aKey.CompareF(KInfraRed) ) |
|
621 { |
|
622 TInt IRStatus(0); |
|
623 TInt status(0); |
|
624 User::LeaveIfError(RProperty::Get(KIrdaPropertyCategory, |
|
625 KIrdaStatus,IRStatus)); |
|
626 |
|
627 // Map all possible Infra red status values to ON, OFF and UnKnown states. |
|
628 if ( TIrdaStatusCodes::EIrLoaded == IRStatus || |
|
629 TIrdaStatusCodes::EIrDiscoveredPeer == IRStatus || |
|
630 TIrdaStatusCodes::EIrBlocked == IRStatus || |
|
631 TIrdaStatusCodes::EIrLostPeer == IRStatus || |
|
632 TIrdaStatusCodes::EIrDisconnected == IRStatus ) |
|
633 status = EOn; |
|
634 else if( TIrdaStatusCodes::EIrUnloaded == IRStatus ) |
|
635 status = EOff; |
|
636 else |
|
637 status = EUnknown; |
|
638 |
|
639 aSysData = CStatus::NewL(status); |
|
640 } |
|
641 else if( !aKey.CompareF(KWLanMacAddress) ) |
|
642 { |
|
643 //result format 00:18:0f:1e:96:a2. |
|
644 TBuf8<KPSWlanMacAddressLength> DesC8AddrText; |
|
645 TBuf<KPhoneWlanMacAddressLength> FormatedMacAddress; |
|
646 |
|
647 User::LeaveIfError(RProperty::Get(KPSUidWlan, |
|
648 KPSWlanMacAddress,DesC8AddrText)); |
|
649 for ( TInt i=0; i < KPSWlanMacAddressLength; i++ ) |
|
650 { |
|
651 // Set separator |
|
652 if( i > 0 ) |
|
653 FormatedMacAddress.Append(KPhoneWlanSeparator); |
|
654 |
|
655 // Set data |
|
656 TBuf<10> FormatText; |
|
657 FormatText.Format(KWLanMACDataFormat,DesC8AddrText[i]); |
|
658 FormatedMacAddress.Append(FormatText); |
|
659 } |
|
660 aSysData = CStringData::NewL(FormatedMacAddress); |
|
661 } |
|
662 else |
|
663 User::Leave(KErrNotFound); |
|
664 } |
|
665 |
|
666 // -------------------------------------------------------------------- |
|
667 // CSysInfoService::GetGeneralInfoL() |
|
668 // Retrives General Entity related synchronous keys information. |
|
669 // On return aSysData consists of key value. |
|
670 // -------------------------------------------------------------------- |
|
671 // |
|
672 void CSysInfoService::GetGeneralInfoL(TPtrC aKey,CSysData*& aSysData) |
|
673 { |
|
674 if( !aKey.CompareF(KConnectedAccessories) ) |
|
675 { |
|
676 aSysData = CAccList::NewL(); |
|
677 } |
|
678 else if( !aKey.CompareF(KInputLanguage) ) |
|
679 { |
|
680 TInt inputLang = 0; |
|
681 RepositoryUtil::GetRepositoryKeyL(KCRUidAknFep, |
|
682 KAknFepInputTxtLang,inputLang); |
|
683 aSysData = CStatus::NewL(inputLang); |
|
684 } |
|
685 else if( !aKey.CompareF(KSupportedLanguages) ) |
|
686 { |
|
687 aSysData = CLanguageList::NewL(); |
|
688 } |
|
689 else if( !aKey.CompareF(KPridictiveText) ) |
|
690 { |
|
691 TInt pridictiveText =0; |
|
692 RepositoryUtil::GetRepositoryKeyL(KCRUidAknFep, |
|
693 KAknFepPredTxtFlag,pridictiveText); |
|
694 aSysData = CStatus::NewL(pridictiveText); |
|
695 } |
|
696 else if( !aKey.CompareF(KVibraActive) ) |
|
697 { |
|
698 TInt vibraState =0; |
|
699 RepositoryUtil::GetRepositoryKeyL(KCRUidVibraCtrl, |
|
700 KVibraCtrlProfileVibraEnabled,vibraState); |
|
701 aSysData = CStatus::NewL(vibraState); |
|
702 } |
|
703 else if( !aKey.CompareF(KFlipStatus) ) |
|
704 { |
|
705 TInt flipState = 0; |
|
706 User::LeaveIfError(RProperty::Get(KPSUidHWRM, |
|
707 KHWRMFlipStatus,flipState)); |
|
708 if (flipState == EPSHWRMFlipOpen) |
|
709 flipState = EOpen; |
|
710 else if (flipState == EPSHWRMFlipClosed) |
|
711 flipState = EClosed; |
|
712 else |
|
713 flipState = EUnknown; |
|
714 |
|
715 aSysData = CStatus::NewL(flipState); |
|
716 } |
|
717 else if( !aKey.CompareF(KGripStatus) ) |
|
718 { |
|
719 TInt gripState = 0; |
|
720 User::LeaveIfError(RProperty::Get(KPSUidHWRM, |
|
721 KHWRMGripStatus,gripState)); |
|
722 if (gripState == EPSHWRMGripOpen) |
|
723 gripState = EOpen; |
|
724 else if (gripState == EPSHWRMGripClosed) |
|
725 gripState = EClosed; |
|
726 else |
|
727 gripState = EUnknown; |
|
728 |
|
729 aSysData = CStatus::NewL(gripState); |
|
730 } |
|
731 else if( !aKey.CompareF(KAvailableUSBModes) ) |
|
732 { |
|
733 GetAvailableUsbModesL(aSysData); |
|
734 } |
|
735 else if( !aKey.CompareF(KActiveUSBMode) ) |
|
736 { |
|
737 RUsb usbsessn; |
|
738 |
|
739 CleanupClosePushL(usbsessn); |
|
740 User::LeaveIfError(usbsessn.Connect()); |
|
741 TInt activePersonality = 0; |
|
742 User::LeaveIfError(usbsessn.GetCurrentPersonalityId(activePersonality)); |
|
743 HBufC* activeUsbMode = NULL; |
|
744 User::LeaveIfError(usbsessn.GetDescription(activePersonality,activeUsbMode)); |
|
745 aSysData = CStringData::NewL(*activeUsbMode); |
|
746 CleanupStack::PopAndDestroy(&usbsessn); |
|
747 } |
|
748 else |
|
749 User::Leave(KErrNotFound); |
|
750 } |
|
751 |
|
752 // -------------------------------------------------------------------- |
|
753 // CSysInfoService::GetDisplayInfoL() |
|
754 // Retrives Display Entity related synchronous keys information. |
|
755 // On return aSysData consists of key value. |
|
756 // -------------------------------------------------------------------- |
|
757 // |
|
758 void CSysInfoService::GetDisplayInfoL(TPtrC aKey,CSysData*& aSysData) |
|
759 { |
|
760 if( !aKey.CompareF(KBrightness) ) |
|
761 { |
|
762 TInt brightness = 0; |
|
763 RepositoryUtil::GetRepositoryKeyL(KCRUidLightSettings, |
|
764 KLightIntensity,brightness); |
|
765 |
|
766 aSysData = CStatus::NewL(brightness); |
|
767 } |
|
768 else if( !aKey.CompareF(KKeyGaurdTime) ) |
|
769 { |
|
770 TInt keygaurdtime = 0; |
|
771 RepositoryUtil::GetRepositoryKeyL(KCRUidSecuritySettings, |
|
772 KSettingsAutomaticKeyguardTime,keygaurdtime); |
|
773 |
|
774 aSysData = CStatus::NewL(keygaurdtime); |
|
775 } |
|
776 else if( !aKey.CompareF(KScreenSaverTimeOut) ) |
|
777 { |
|
778 TInt screenSaverTimeOut = 0; |
|
779 RepositoryUtil::GetRepositoryKeyL(KCRUidPersonalizationSettings, |
|
780 KSettingsScreenSaverPeriod,screenSaverTimeOut); |
|
781 |
|
782 aSysData = CStatus::NewL(screenSaverTimeOut); |
|
783 } |
|
784 else if( !aKey.CompareF(KAutoLockTime) ) |
|
785 { |
|
786 TInt autoLockTime = 0; |
|
787 RepositoryUtil::GetRepositoryKeyL(KCRUidSecuritySettings, |
|
788 KSettingsAutoLockTime,autoLockTime); |
|
789 |
|
790 aSysData = CStatus::NewL(autoLockTime); |
|
791 } |
|
792 else if( !aKey.CompareF(KAutoLockStatus) ) |
|
793 { |
|
794 TInt keyLockState = 0; |
|
795 RepositoryUtil::GetRepositoryKeyL(KCRUidSecuritySettings, |
|
796 KSettingsAutolockStatus,keyLockState); |
|
797 |
|
798 aSysData = CStatus::NewL(keyLockState); |
|
799 } |
|
800 else if( !aKey.CompareF(KWallpaper) ) |
|
801 { |
|
802 User::Leave(KErrNotSupported); |
|
803 } |
|
804 else if( !aKey.CompareF(KLightTimeOut) ) |
|
805 { |
|
806 TInt lightTimeOut = 0; |
|
807 RepositoryUtil::GetRepositoryKeyL(KCRUidLightSettings, |
|
808 KDisplayLightsTimeout,lightTimeOut); |
|
809 |
|
810 aSysData = CStatus::NewL(lightTimeOut); |
|
811 } |
|
812 else if( !aKey.CompareF(KDisplayResolution) ) |
|
813 { |
|
814 TInt xPixels(0); |
|
815 TInt yPixels(0); |
|
816 User::LeaveIfError(HAL::Get(HALData::EDisplayXPixels,xPixels)); |
|
817 User::LeaveIfError(HAL::Get(HALData::EDisplayYPixels,yPixels)); |
|
818 aSysData = CResolution::NewL(xPixels,yPixels); |
|
819 } |
|
820 else if( !aKey.CompareF(KDisplayOrientation) ) |
|
821 { |
|
822 RWsSession session; |
|
823 CleanupClosePushL(session); |
|
824 User::LeaveIfError(session.Connect()); |
|
825 CWsScreenDevice *Device = new (ELeave) CWsScreenDevice(session); |
|
826 CleanupStack::PushL(Device); |
|
827 Device->Construct(); |
|
828 TPixelsTwipsAndRotation twipsRotation; |
|
829 Device->GetDefaultScreenSizeAndRotation(twipsRotation); |
|
830 aSysData = CStatus::NewL(twipsRotation.iRotation); |
|
831 CleanupStack::PopAndDestroy(2,&session); |
|
832 } |
|
833 else |
|
834 User::Leave(KErrNotFound); |
|
835 } |
|
836 |
|
837 // -------------------------------------------------------------------- |
|
838 // CSysInfoService::GetDeviceInfoL() |
|
839 // Retrives Device Entity related synchronous keys information. |
|
840 // On return aSysData consists of key value. |
|
841 // -------------------------------------------------------------------- |
|
842 // |
|
843 void CSysInfoService::GetDeviceInfoL(TPtrC aKey,CSysData*& aSysData) |
|
844 { |
|
845 //if iDeviceInfo not instantiated before. Instantiate now. |
|
846 if( !iDeviceInfo ) |
|
847 iDeviceInfo = CDeviceInfo::NewL(); |
|
848 |
|
849 // read the requested key value. |
|
850 if ( !aKey.CompareF(KFirmwareVersion) ) |
|
851 aSysData = CStringData::NewL(iDeviceInfo->FirmwareVersion()); |
|
852 |
|
853 else if( !aKey.CompareF(KProductType) ) |
|
854 aSysData = CStringData::NewL(iDeviceInfo->ProductType()); |
|
855 |
|
856 else if( !aKey.CompareF(KManufacturer) ) |
|
857 aSysData = CStringData::NewL(iDeviceInfo->Manufaturer()); |
|
858 |
|
859 else if( !aKey.CompareF(KPhoneModel) ) |
|
860 aSysData = CStringData::NewL(iDeviceInfo->Model()); |
|
861 |
|
862 else if( !aKey.CompareF(KIMEI) ) |
|
863 aSysData = CStringData::NewL(iDeviceInfo->IMEI()); |
|
864 |
|
865 else if( !aKey.CompareF(KMachineID) ) |
|
866 aSysData = CStatus::NewL(iDeviceInfo->MachineId()); |
|
867 |
|
868 else if( !aKey.CompareF(KPlatformVersion) ) |
|
869 { |
|
870 TInt majorVer(0); |
|
871 TInt minorVer(0); |
|
872 iDeviceInfo->GetPlatformVersion(majorVer,minorVer); |
|
873 aSysData = CVersion::NewL(majorVer,minorVer); |
|
874 } |
|
875 else |
|
876 User::Leave(KErrNotFound); |
|
877 } |
|
878 |
|
879 // -------------------------------------------------------------------- |
|
880 // CSysInfoService::GetAvailableUsbModesL() |
|
881 // Retrives available USB modes. |
|
882 // returns CSysData. |
|
883 // -------------------------------------------------------------------- |
|
884 // |
|
885 void CSysInfoService::GetAvailableUsbModesL(CSysData*& aSysData) |
|
886 { |
|
887 RUsb usbsessn; |
|
888 CleanupClosePushL(usbsessn); |
|
889 User::LeaveIfError(usbsessn.Connect()); |
|
890 |
|
891 RArray<TInt> usbModes; |
|
892 CleanupClosePushL(usbModes); |
|
893 |
|
894 User::LeaveIfError(usbsessn.GetPersonalityIds(usbModes)); |
|
895 |
|
896 CDesCArray* usbModesDesArray; |
|
897 usbModesDesArray = new (ELeave) CDesCArrayFlat(KGranularity); |
|
898 CleanupStack::PushL(usbModesDesArray); |
|
899 |
|
900 HBufC* modeName = NULL; |
|
901 TInt Count = usbModes.Count(); |
|
902 for (TInt i=0; i<Count; i++) |
|
903 { |
|
904 usbsessn.GetDescription(usbModes[i],modeName); |
|
905 //Creates own copy of the text. |
|
906 usbModesDesArray->AppendL(*modeName); |
|
907 // free allocated memory by GetDescription. |
|
908 delete modeName; |
|
909 } |
|
910 |
|
911 //UsbModesDesArray ownership passed to CStringList. |
|
912 aSysData = CStringList::NewL(usbModesDesArray); |
|
913 CleanupStack::Pop(usbModesDesArray); |
|
914 CleanupStack::PopAndDestroy(2,&usbsessn); |
|
915 } |
|
916 |
|
917 // End of file. |