|
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: SysInfoPlugin implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "HtiSysInfoServicePlugin.h" |
|
21 #include "HtiLightsController.h" |
|
22 #include "HtiPropertySubscriber.h" |
|
23 #include <HtiDispatcherInterface.h> |
|
24 #include <HtiLogging.h> |
|
25 |
|
26 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 ) |
|
27 #include <aknkeylock.h> |
|
28 #include <ScreensaverInternalPSKeys.h> |
|
29 #endif |
|
30 |
|
31 #include <AknSkinsInternalCRKeys.h> |
|
32 #include <AknsSkinUID.h> |
|
33 #include <AknsSrvClient.h> |
|
34 #include <AknFepInternalCRKeys.h> |
|
35 #include <AknFepGlobalEnums.h> //For chinese input modes |
|
36 #include <CommonEngineDomainCRKeys.h> |
|
37 #include <featmgr.h> |
|
38 #include <bautils.h> |
|
39 #include <btengsettings.h> |
|
40 #include <btengdomaincrkeys.h> |
|
41 #include <bt_subscribe.h> |
|
42 #include <btmanclient.h> |
|
43 #include <centralrepository.h> |
|
44 #include <CoreApplicationUIsSDKCRKeys.h> |
|
45 #include <DRMRightsClient.h> |
|
46 #include <e32property.h> |
|
47 #include <etel.h> |
|
48 #include <etelmm.h> |
|
49 #include <hal.h> |
|
50 #include <ir_sock.h> |
|
51 #include <mmtsy_names.h> |
|
52 #include <rmmcustomapi.h> |
|
53 #include <hwrmpowerstatesdkpskeys.h> |
|
54 #include <settingsinternalcrkeys.h> |
|
55 #include <sysutil.h> |
|
56 #include <tz.h> |
|
57 |
|
58 // CONSTANTS |
|
59 const static TUid KSysInfoServiceUid = { 0x10210CC7 }; |
|
60 |
|
61 // from irinternalpskey.h |
|
62 const static TUid KPSUidIrdaActivation = { 0x2000276D }; |
|
63 |
|
64 const TInt KTimeDataLength = 7; |
|
65 const TInt KMaxBtNameLength = 30; |
|
66 const TInt KDateTimeFormatCmdLength = 6; |
|
67 |
|
68 const TInt KFepChineseInputModeLength = 10; |
|
69 |
|
70 _LIT( KTempFilePath, "\\" ); |
|
71 _LIT( KTempFileName, "HtiTempFile.tmp" ); |
|
72 _LIT( KMatchFileName, "HtiTempFile.tmp*" ); |
|
73 _LIT( KDateSeparatorChars, ".:/-" ); |
|
74 _LIT( KTimeSeparatorChars, ".:" ); |
|
75 |
|
76 _LIT8( KErrDescrArgument, "Invalid argument" ); |
|
77 _LIT8( KErrDescrNotSupported, "Command not supported" ); |
|
78 _LIT8( KErrDescrHAL, "Error retrieving HAL attribute" ); |
|
79 _LIT8( KErrDescrAttOutOfRange, "HAL attribute argument is out of range" ); |
|
80 _LIT8( KErrDescrFreeRAM, "Error retrieving the amount of free RAM" ); |
|
81 _LIT8( KErrDescrTotalRAM, "Error retrieving the amount of total RAM" ); |
|
82 _LIT8( KErrDescrAllocRAM, "Error allocating RAM" ); |
|
83 _LIT8( KErrDescrInvalidRAM, "Requested free RAM larger than currently free" ); |
|
84 _LIT8( KErrDescrVolInfo, "Error retrieving volume info" ); |
|
85 _LIT8( KErrDescrNotEnoughSpace, "Not enough disk space" ); |
|
86 _LIT8( KErrDescrCreateTempFile, "Error creating temp file" ); |
|
87 _LIT8( KErrDescrSetSizeTempFile, "Error allocating size for temp file" ); |
|
88 _LIT8( KErrDescrDeleteTempFile, "Error deleting temp file" ); |
|
89 _LIT8( KErrDescrSysUtil, "SysUtil failed" ); |
|
90 _LIT8( KErrDescrSetTime, "Setting time failed" ); |
|
91 _LIT8( KErrDescrDateTimeFormat, "Setting date and time formats failed" ); |
|
92 _LIT8( KErrDescrSetLanguage, "Setting language failed"); |
|
93 _LIT8( KErrDescrGetNetworkModes, "Getting network modes failed" ); |
|
94 _LIT8( KErrDescrSetNetworkMode, "Setting network mode failed" ); |
|
95 _LIT8( KErrDescrIrActivation, "IR activation failed" ); |
|
96 _LIT8( KErrDescrGetBtPower, "Getting BT power state failed" ); |
|
97 _LIT8( KErrDescrSetBtPower, "Setting BT power state failed" ); |
|
98 _LIT8( KErrDescrBtOnDenied, "Turning BT on not allowed (Offline mode)" ); |
|
99 _LIT8( KErrDescrBtOffDenied, "Turning BT off not allowed (active connections)" ); |
|
100 _LIT8( KErrDescrBtSettings, "Bluetooth settings failed" ); |
|
101 _LIT8( KErrDescrBtDeletePairings, "Deleting Bluetooth pairing(s) failed" ); |
|
102 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 ) |
|
103 _LIT8( KErrDescrKeyLock, "Key lock toggle failed" ); |
|
104 _LIT8( KErrDescrScreenSaver, "Setting screen saver state failed" ); |
|
105 _LIT8( KErrDescrInvalidSSTimeout, "Invalid screen saver timeout value" ); |
|
106 _LIT8( KErrDescrSSTimeoutFailed, "Setting screen saver timeout failed" ); |
|
107 #endif |
|
108 _LIT8( KErrDescrInvalidTime, "Auto key guard time value too large (max 3600)" ); |
|
109 _LIT8( KErrDescrAutoKeyGuardFailed, "Setting auto key guard time failed" ); |
|
110 _LIT8( KErrDescrDrmDbConnect, "DRM DB connect failed." ); |
|
111 _LIT8( KErrDescrDrmDbDelete, "DRM DB delete failed." ); |
|
112 _LIT8( KErrDescrBatteryLevel, "Getting battery level failed." ); |
|
113 _LIT8( KErrDescrChargingStatus, "Getting charging status failed." ); |
|
114 _LIT8( KErrDescrSignalStrength, "Getting signal strength failed." ); |
|
115 _LIT8( KErrDescrMGUpdate, "Update Media Gallery failed" ); |
|
116 _LIT8( KErrDescrActivateSkin, "Activating Skin failed" ); |
|
117 |
|
118 enum TSysInfoCommand |
|
119 { |
|
120 ESysInfoHAL = 0x01, |
|
121 ESysInfoIMEI= 0x02, |
|
122 ESysInfoSWVersion = 0x03, |
|
123 ESysInfoLangVersion = 0x04, |
|
124 ESysInfoSWLangVersion = 0x05, |
|
125 ESysInfoUserAgent = 0x06, |
|
126 EFreeRAM = 0x07, |
|
127 EUsedRAM = 0x08, |
|
128 ETotalRAM = 0x09, |
|
129 EEatRAM = 0x0A, |
|
130 EReleaseRAM = 0x0B, |
|
131 EFreeDiskSpace = 0x0C, |
|
132 EUsedDiskSpace = 0x0D, |
|
133 ETotalDiskSize = 0x0E, |
|
134 EEatDiskSpace = 0x0F, |
|
135 EReleaseDiskSpace = 0x10, |
|
136 |
|
137 ESysInfoSetHomeTime = 0x20, |
|
138 ESysInfoGetHomeTime = 0x21, |
|
139 ESetDateTimeFormat = 0x22, |
|
140 |
|
141 ESetLanguage = 0x25, |
|
142 |
|
143 ELightStatus = 0x30, |
|
144 ELightOn = 0x31, |
|
145 ELightOff = 0x32, |
|
146 ELightBlink = 0x33, |
|
147 ELightRelease = 0x3A, |
|
148 |
|
149 EScreenSaverDisable = 0x40, |
|
150 EScreenSaverEnable = 0x41, |
|
151 EScreenSaverTimeout = 0x42, |
|
152 |
|
153 ENetworkModeGet = 0x50, |
|
154 ENetworkModeSet = 0x51, |
|
155 ENetworkModeSetNoReboot = 0x52, |
|
156 EHsdpaSet = 0x53, |
|
157 |
|
158 EIrActivate = 0x5A, |
|
159 EBtPower = 0x5B, |
|
160 EBtSettings = 0x5C, |
|
161 EBtDeletePairings = 0x5D, |
|
162 |
|
163 EKeylockToggle = 0x60, |
|
164 EAutoKeyGuardTime = 0x61, |
|
165 |
|
166 EEmtpyDrmRightsDb = 0x65, |
|
167 |
|
168 EBatteryStatus = 0x70, |
|
169 ESignalStrength = 0x71, |
|
170 |
|
171 EUpdateMediaGallery = 0x7A, |
|
172 |
|
173 EActivateSkin = 0x80 |
|
174 }; |
|
175 |
|
176 enum TGSNumberModes |
|
177 { |
|
178 EGSNbrModeLatin, EGSNbrModeArabic = 1, EGSNbrModeIndic = 1 |
|
179 }; |
|
180 |
|
181 // Number mode type |
|
182 enum TGSNumberModeType |
|
183 { |
|
184 EGSNbrModeTypeArabic, EGSNbrModeTypeIndic, EGSNbrModeTypeEasternArabic |
|
185 // for Urdu & Farsi languages |
|
186 }; |
|
187 |
|
188 //------------------------------------------------------------------------------ |
|
189 // Create instance of concrete ECOM interface implementation |
|
190 //------------------------------------------------------------------------------ |
|
191 CHtiSysInfoServicePlugin* CHtiSysInfoServicePlugin::NewL() |
|
192 { |
|
193 CHtiSysInfoServicePlugin* self = new (ELeave) CHtiSysInfoServicePlugin; |
|
194 CleanupStack::PushL (self); |
|
195 self->ConstructL(); |
|
196 CleanupStack::Pop(); |
|
197 return self; |
|
198 } |
|
199 |
|
200 //------------------------------------------------------------------------------ |
|
201 // Constructor |
|
202 //------------------------------------------------------------------------------ |
|
203 CHtiSysInfoServicePlugin::CHtiSysInfoServicePlugin(): |
|
204 iMemEater( NULL ), iReply( NULL ), iGalleryUpdateSupported( ETrue ) |
|
205 { |
|
206 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 ) |
|
207 iAllowSSValue = -1; |
|
208 iAllowSSPropertyAttached = EFalse; |
|
209 #endif |
|
210 } |
|
211 |
|
212 //------------------------------------------------------------------------------ |
|
213 // Destructor |
|
214 //------------------------------------------------------------------------------ |
|
215 CHtiSysInfoServicePlugin::~CHtiSysInfoServicePlugin() |
|
216 { |
|
217 HTI_LOG_TEXT( "CHtiSysInfoServicePlugin destroy" ); |
|
218 delete iMemEater; |
|
219 delete iReply; |
|
220 |
|
221 CleanUpTempFiles(); |
|
222 delete iFileMan; |
|
223 iFs.Close(); |
|
224 delete iLightsController; |
|
225 |
|
226 if ( iAllowSSSubscriber ) |
|
227 { |
|
228 iAllowSSSubscriber->Unsubscribe(); |
|
229 } |
|
230 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 ) |
|
231 iAllowSSProperty.Close(); |
|
232 #endif |
|
233 delete iAllowSSSubscriber; |
|
234 |
|
235 FeatureManager::UnInitializeLib(); |
|
236 } |
|
237 |
|
238 //------------------------------------------------------------------------------ |
|
239 // Second phase construction |
|
240 //------------------------------------------------------------------------------ |
|
241 void CHtiSysInfoServicePlugin::ConstructL() |
|
242 { |
|
243 HTI_LOG_TEXT( "CHtiSysInfoServicePlugin::ConstructL" ); |
|
244 User::LeaveIfError( iFs.Connect() ); |
|
245 iFileMan = CFileMan::NewL( iFs ); |
|
246 |
|
247 FeatureManager::InitializeLibL(); |
|
248 } |
|
249 |
|
250 //------------------------------------------------------------------------------ |
|
251 // CHtiSysInfoServicePlugin::ProcessMessageL |
|
252 //------------------------------------------------------------------------------ |
|
253 void CHtiSysInfoServicePlugin::ProcessMessageL(const TDesC8& aMessage, |
|
254 THtiMessagePriority /*aPriority*/) |
|
255 { |
|
256 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::ProcessMessage" ); |
|
257 HTI_LOG_FORMAT( "Message length: %d", aMessage.Length() ); |
|
258 |
|
259 if ( aMessage.Length() > 0 ) |
|
260 { |
|
261 HTI_LOG_FORMAT( "Command: %d", aMessage[0] ); |
|
262 |
|
263 switch ( aMessage[0] ) |
|
264 { |
|
265 case ESysInfoHAL: |
|
266 { |
|
267 HTI_LOG_TEXT( "ESysInfoHAL" ); |
|
268 HandleGetHalAttrL( aMessage ); |
|
269 } |
|
270 break; |
|
271 case ESysInfoIMEI: |
|
272 { |
|
273 HTI_LOG_TEXT( "ESysInfoIMEI" ); |
|
274 HandleGetImeiL( aMessage ); |
|
275 } |
|
276 break; |
|
277 case ESysInfoSWVersion: |
|
278 { |
|
279 HTI_LOG_TEXT( "ESysInfoSWVersion" ); |
|
280 HandleGetSwVersionL( aMessage ); |
|
281 } |
|
282 break; |
|
283 case ESysInfoLangVersion: |
|
284 { |
|
285 HTI_LOG_TEXT( "ESysInfoLangVersion" ); |
|
286 HandleGetLangVersionL( aMessage ); |
|
287 } |
|
288 break; |
|
289 case ESysInfoSWLangVersion: |
|
290 { |
|
291 HTI_LOG_TEXT( "ESysInfoSWLangVersion" ); |
|
292 HandleGetSwLangVersionL( aMessage ); |
|
293 } |
|
294 break; |
|
295 case ESysInfoUserAgent: |
|
296 { |
|
297 HTI_LOG_TEXT( "ESysInfoUserAgent" ); |
|
298 HandleGetUserAgentStringL( aMessage ); |
|
299 } |
|
300 break; |
|
301 case EFreeRAM: |
|
302 { |
|
303 HTI_LOG_TEXT( "EFreeRAM" ); |
|
304 HandleGetFreeRamL( aMessage ); |
|
305 } |
|
306 break; |
|
307 case EUsedRAM: |
|
308 { |
|
309 HTI_LOG_TEXT( "EUsedRAM" ); |
|
310 HandleGetUsedRamL( aMessage ); |
|
311 } |
|
312 break; |
|
313 case ETotalRAM: |
|
314 { |
|
315 HTI_LOG_TEXT( "ETotalRAM" ); |
|
316 HandleGetTotalRamL( aMessage ); |
|
317 } |
|
318 break; |
|
319 case EEatRAM: |
|
320 { |
|
321 HTI_LOG_TEXT( "EEatRAM" ); |
|
322 HandleEatRamL( aMessage ); |
|
323 } |
|
324 break; |
|
325 case EReleaseRAM: |
|
326 { |
|
327 HTI_LOG_TEXT( "EReleaseRAM" ); |
|
328 HandleReleaseRamL( aMessage ); |
|
329 } |
|
330 break; |
|
331 case EFreeDiskSpace: |
|
332 { |
|
333 HTI_LOG_TEXT( "EFreeDiskSpace" ); |
|
334 HandleGetFreeDiskSpaceL( aMessage ); |
|
335 } |
|
336 break; |
|
337 case EUsedDiskSpace: |
|
338 { |
|
339 HTI_LOG_TEXT( "EUsedDiskSpace" ); |
|
340 HandleGetUsedDiskSpaceL( aMessage ); |
|
341 } |
|
342 break; |
|
343 case ETotalDiskSize: |
|
344 { |
|
345 HTI_LOG_TEXT( "ETotalDiskSize" ); |
|
346 HandleGetTotalDiskSpaceL( aMessage ); |
|
347 } |
|
348 break; |
|
349 case EEatDiskSpace: |
|
350 { |
|
351 HTI_LOG_TEXT( "EEatDiskSpace" ); |
|
352 HandleEatDiskSpaceL( aMessage ); |
|
353 } |
|
354 break; |
|
355 case EReleaseDiskSpace: |
|
356 { |
|
357 HTI_LOG_TEXT( "EReleaseDiskSpace" ); |
|
358 HandleReleaseDiskSpaceL( aMessage ); |
|
359 } |
|
360 break; |
|
361 case ESysInfoSetHomeTime: |
|
362 { |
|
363 HTI_LOG_TEXT( "ESysInfoSetHomeTime" ); |
|
364 HandleSetHomeTimeL( aMessage ); |
|
365 } |
|
366 break; |
|
367 case ESysInfoGetHomeTime: |
|
368 { |
|
369 HTI_LOG_TEXT( "ESysInfoGetHomeTime" ); |
|
370 HandleGetHomeTimeL( aMessage ); |
|
371 } |
|
372 break; |
|
373 case ESetDateTimeFormat: |
|
374 { |
|
375 HTI_LOG_TEXT( "ESetDateTimeFormat" ); |
|
376 HandleSetDateTimeFormatL( aMessage ); |
|
377 } |
|
378 break; |
|
379 case ESetLanguage: |
|
380 { |
|
381 HTI_LOG_TEXT("ESetLanguage"); |
|
382 HandleSetLanguageL( aMessage); |
|
383 } |
|
384 break; |
|
385 case ELightStatus: |
|
386 case ELightOn: |
|
387 case ELightOff: |
|
388 case ELightBlink: |
|
389 case ELightRelease: |
|
390 { |
|
391 HTI_LOG_TEXT( "ELight*" ); |
|
392 HandleLightsCommandL( aMessage ); |
|
393 } |
|
394 break; |
|
395 case EScreenSaverDisable: |
|
396 case EScreenSaverEnable: |
|
397 { |
|
398 HTI_LOG_TEXT( "EScreenSaver*" ); |
|
399 HandleScreenSaverCommandL( aMessage ); |
|
400 } |
|
401 break; |
|
402 case EScreenSaverTimeout: |
|
403 { |
|
404 HTI_LOG_TEXT( "EScreenSaverTimeout" ); |
|
405 HandleScreenSaverTimeoutCommandL( aMessage ); |
|
406 } |
|
407 break; |
|
408 case ENetworkModeSet: |
|
409 case ENetworkModeSetNoReboot: |
|
410 case ENetworkModeGet: |
|
411 { |
|
412 HTI_LOG_TEXT( "ENetworkMode*" ); |
|
413 HandleNetworkModeCommandL( aMessage ); |
|
414 } |
|
415 break; |
|
416 case EHsdpaSet: |
|
417 { |
|
418 HTI_LOG_TEXT( "EHsdpaSet" ); |
|
419 HandleHsdpaCommandL( aMessage ); |
|
420 } |
|
421 break; |
|
422 case EIrActivate: |
|
423 { |
|
424 HTI_LOG_TEXT( "EIrActivate" ); |
|
425 HandleIrActivateCommandL( aMessage ); |
|
426 } |
|
427 break; |
|
428 case EBtPower: |
|
429 { |
|
430 HTI_LOG_TEXT( "EBtPower" ); |
|
431 HandleBtPowerCommandL( aMessage ); |
|
432 } |
|
433 break; |
|
434 case EBtSettings: |
|
435 { |
|
436 HTI_LOG_TEXT( "EBtSettings" ); |
|
437 HandleBtSettingsCommandL( aMessage ); |
|
438 } |
|
439 break; |
|
440 case EBtDeletePairings: |
|
441 { |
|
442 HTI_LOG_TEXT( "EBtDeletePairings" ); |
|
443 HandleBtDeletePairingsL( aMessage ); |
|
444 } |
|
445 break; |
|
446 case EKeylockToggle: |
|
447 { |
|
448 HTI_LOG_TEXT( "EKeylockToggle" ); |
|
449 HandleKeyLockToggleL( aMessage ); |
|
450 } |
|
451 break; |
|
452 case EAutoKeyGuardTime: |
|
453 { |
|
454 HTI_LOG_TEXT( "EAutoKeyGuardTime" ); |
|
455 HandleAutoKeyGuardTimeL( aMessage ); |
|
456 } |
|
457 break; |
|
458 case EEmtpyDrmRightsDb: |
|
459 { |
|
460 HTI_LOG_TEXT( "EEmtpyDrmRightsDb" ); |
|
461 HandleEmptyDrmRightsDbL( aMessage ); |
|
462 } |
|
463 break; |
|
464 case EBatteryStatus: |
|
465 { |
|
466 HTI_LOG_TEXT( "EBatteryStatus" ); |
|
467 HandleBatteryStatusL( aMessage ); |
|
468 } |
|
469 break; |
|
470 case ESignalStrength: |
|
471 { |
|
472 HTI_LOG_TEXT( "ESignalStrength" ); |
|
473 HandleSignalStrengthL( aMessage ); |
|
474 } |
|
475 break; |
|
476 case EUpdateMediaGallery: |
|
477 { |
|
478 HTI_LOG_TEXT( "EUpdateMediaGallery" ); |
|
479 HandleUpdateMediaGalleryL( aMessage ); |
|
480 } |
|
481 break; |
|
482 case EActivateSkin: |
|
483 { |
|
484 HTI_LOG_TEXT( "EActivateSkin" ); |
|
485 HandleActivateSkinL( aMessage ); |
|
486 } |
|
487 break; |
|
488 default: |
|
489 { |
|
490 iDispatcher->DispatchOutgoingErrorMessage( |
|
491 KErrArgument, |
|
492 KErrDescrNotSupported, |
|
493 KSysInfoServiceUid ); |
|
494 } |
|
495 } |
|
496 } |
|
497 |
|
498 else // aMessage.Length() > 0 |
|
499 { |
|
500 iDispatcher->DispatchOutgoingErrorMessage( |
|
501 KErrArgument, |
|
502 KErrDescrArgument, |
|
503 KSysInfoServiceUid); |
|
504 } |
|
505 |
|
506 if ( iReply ) |
|
507 { |
|
508 TInt err = iDispatcher->DispatchOutgoingMessage( iReply, |
|
509 KSysInfoServiceUid ); |
|
510 if ( err == KErrNoMemory ) |
|
511 { |
|
512 HTI_LOG_TEXT( "KErrNoMemory" ); |
|
513 iDispatcher->AddMemoryObserver( this ); |
|
514 } |
|
515 else |
|
516 { |
|
517 iReply = NULL; |
|
518 } |
|
519 } |
|
520 |
|
521 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::ProcessMessage" ); |
|
522 } |
|
523 |
|
524 //------------------------------------------------------------------------------ |
|
525 // CHtiSysInfoServicePlugin::NotifyMemoryChange |
|
526 //------------------------------------------------------------------------------ |
|
527 void CHtiSysInfoServicePlugin::NotifyMemoryChange( TInt aAvailableMemory ) |
|
528 { |
|
529 |
|
530 if ( iReply ) |
|
531 { |
|
532 if ( aAvailableMemory >= iReply->Size() ) |
|
533 { |
|
534 TInt err = iDispatcher->DispatchOutgoingMessage( |
|
535 iReply, KSysInfoServiceUid ); |
|
536 |
|
537 if ( err == KErrNone ) |
|
538 { |
|
539 iReply = NULL; |
|
540 iDispatcher->RemoveMemoryObserver( this ); |
|
541 } |
|
542 else if ( err != KErrNoMemory ) //some other error |
|
543 { |
|
544 delete iReply; |
|
545 iReply = NULL; |
|
546 iDispatcher->RemoveMemoryObserver( this ); |
|
547 } |
|
548 } |
|
549 } |
|
550 else |
|
551 { |
|
552 // some error, should not be called |
|
553 iDispatcher->RemoveMemoryObserver( this ); |
|
554 } |
|
555 } |
|
556 |
|
557 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 ) |
|
558 //------------------------------------------------------------------------------ |
|
559 // CHtiSysInfoServicePlugin::HandleAllowSSPropertyChange |
|
560 //------------------------------------------------------------------------------ |
|
561 TInt CHtiSysInfoServicePlugin::HandleAllowSSPropertyChange( TAny* aPtr ) |
|
562 { |
|
563 HTI_LOG_TEXT( "Allow SS property was changed" ); |
|
564 TInt newValue = -1; |
|
565 TInt wantedValue = |
|
566 STATIC_CAST( CHtiSysInfoServicePlugin*, aPtr )->iAllowSSValue; |
|
567 RProperty::Get( KPSUidScreenSaver, |
|
568 KScreenSaverAllowScreenSaver, newValue ); |
|
569 HTI_LOG_FORMAT( "New value is %d", newValue ); |
|
570 |
|
571 TInt err = KErrNone; |
|
572 if ( newValue == 0 && wantedValue == 1 ) |
|
573 { |
|
574 HTI_LOG_TEXT( "Restoring the SS disabled value" ); |
|
575 err = RProperty::Set( KPSUidScreenSaver, |
|
576 KScreenSaverAllowScreenSaver, wantedValue ); |
|
577 } |
|
578 return err; |
|
579 } |
|
580 |
|
581 #endif |
|
582 /* |
|
583 * Private helper methods |
|
584 */ |
|
585 |
|
586 //------------------------------------------------------------------------------ |
|
587 // CHtiSysInfoServicePlugin::HandleGetHalAttrL |
|
588 //------------------------------------------------------------------------------ |
|
589 void CHtiSysInfoServicePlugin::HandleGetHalAttrL( const TDesC8& aMessage ) |
|
590 { |
|
591 // check the message length |
|
592 if ( aMessage.Length() != 5 ) |
|
593 { |
|
594 iDispatcher->DispatchOutgoingErrorMessage( |
|
595 KErrArgument, |
|
596 KErrDescrArgument, |
|
597 KSysInfoServiceUid ); |
|
598 return; |
|
599 } |
|
600 |
|
601 TInt att = aMessage[1] + |
|
602 ( aMessage[2] << 8 ) + |
|
603 ( aMessage[3] << 16 ) + |
|
604 ( aMessage[4] << 24 ); |
|
605 |
|
606 // check that requested HAL attribute is valid |
|
607 if ( att < 0 || att >= HALData::ENumHalAttributes ) |
|
608 { |
|
609 iDispatcher->DispatchOutgoingErrorMessage( |
|
610 KErrArgument, |
|
611 KErrDescrAttOutOfRange, |
|
612 KSysInfoServiceUid); |
|
613 return; |
|
614 } |
|
615 |
|
616 // get the HAL attribute |
|
617 TInt result; |
|
618 TInt err = HAL::Get( ( HALData::TAttribute ) att, result ); |
|
619 if ( err ) |
|
620 { |
|
621 iDispatcher->DispatchOutgoingErrorMessage( |
|
622 err, |
|
623 KErrDescrHAL, |
|
624 KSysInfoServiceUid ); |
|
625 } |
|
626 else |
|
627 { |
|
628 iReply = HBufC8::NewL( 4 ); |
|
629 iReply->Des().Append( ( TUint8* )( &result ), 4 ); |
|
630 } |
|
631 } |
|
632 |
|
633 //------------------------------------------------------------------------------ |
|
634 // CHtiSysInfoServicePlugin::HandleGetImeiL |
|
635 //------------------------------------------------------------------------------ |
|
636 void CHtiSysInfoServicePlugin::HandleGetImeiL( const TDesC8& aMessage ) |
|
637 { |
|
638 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleGetImeiL" ); |
|
639 |
|
640 if ( aMessage.Length() != 1 ) |
|
641 { |
|
642 iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, |
|
643 KErrDescrArgument, KSysInfoServiceUid ); |
|
644 return; |
|
645 } |
|
646 |
|
647 #if !defined (__WINS__) // no IMEI in emulator |
|
648 RTelServer server; |
|
649 User::LeaveIfError( server.Connect() ); |
|
650 CleanupClosePushL( server ); |
|
651 User::LeaveIfError( server.LoadPhoneModule( KMmTsyModuleName ) ); |
|
652 |
|
653 RTelServer::TPhoneInfo info; |
|
654 TInt ret = KErrNotSupported; |
|
655 TInt count; |
|
656 |
|
657 RMobilePhone mobilePhone; |
|
658 |
|
659 User::LeaveIfError( server.EnumeratePhones( count ) ); |
|
660 |
|
661 for ( TInt i = 0; i < count; i++ ) |
|
662 { |
|
663 ret = server.GetPhoneInfo( i, info ); |
|
664 if ( ret == KErrNone ) |
|
665 { |
|
666 User::LeaveIfError( mobilePhone.Open( server, info.iName ) ); |
|
667 CleanupClosePushL( mobilePhone ); |
|
668 break; |
|
669 } |
|
670 } |
|
671 |
|
672 TRequestStatus status; |
|
673 RMobilePhone::TMobilePhoneIdentityV1 identity; |
|
674 |
|
675 mobilePhone.GetPhoneId( status, identity ); |
|
676 User::WaitForRequest( status ); |
|
677 |
|
678 CleanupStack::PopAndDestroy(); // mobilePhone |
|
679 |
|
680 server.UnloadPhoneModule( KMmTsyModuleName ); |
|
681 CleanupStack::PopAndDestroy(); // server |
|
682 |
|
683 iReply = HBufC8::NewL( identity.iSerialNumber.Length() ); |
|
684 iReply->Des().Copy( identity.iSerialNumber ); |
|
685 |
|
686 #else // __WINS__ |
|
687 // no IMEI in emulator |
|
688 iDispatcher->DispatchOutgoingErrorMessage( KErrNotSupported, |
|
689 KErrDescrNotSupported, KSysInfoServiceUid ); |
|
690 #endif // __WINS__ |
|
691 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleGetImeiL" ); |
|
692 } |
|
693 |
|
694 //------------------------------------------------------------------------------ |
|
695 // CHtiSysInfoServicePlugin::HandleGetSwVersionL |
|
696 //------------------------------------------------------------------------------ |
|
697 void CHtiSysInfoServicePlugin::HandleGetSwVersionL( const TDesC8& aMessage ) |
|
698 { |
|
699 if ( aMessage.Length() != 1 ) |
|
700 { |
|
701 iDispatcher->DispatchOutgoingErrorMessage( |
|
702 KErrArgument, |
|
703 KErrDescrArgument, |
|
704 KSysInfoServiceUid); |
|
705 return; |
|
706 } |
|
707 |
|
708 TBuf<KSysUtilVersionTextLength> reply16; |
|
709 TInt err = SysUtil::GetSWVersion( reply16 ); |
|
710 if ( err ) |
|
711 { |
|
712 iDispatcher->DispatchOutgoingErrorMessage( |
|
713 err, |
|
714 KErrDescrSysUtil, |
|
715 KSysInfoServiceUid ); |
|
716 } |
|
717 else |
|
718 { |
|
719 iReply = HBufC8::NewL( reply16.Size() ); |
|
720 iReply->Des().Append( ( TUint8* )reply16.Ptr(), reply16.Size() ); |
|
721 } |
|
722 } |
|
723 |
|
724 //------------------------------------------------------------------------------ |
|
725 // CHtiSysInfoServicePlugin::HandleGetLangVersionL |
|
726 //------------------------------------------------------------------------------ |
|
727 void CHtiSysInfoServicePlugin::HandleGetLangVersionL( const TDesC8& aMessage ) |
|
728 { |
|
729 if ( aMessage.Length() != 1 ) |
|
730 { |
|
731 iDispatcher->DispatchOutgoingErrorMessage( |
|
732 KErrArgument, |
|
733 KErrDescrArgument, |
|
734 KSysInfoServiceUid ); |
|
735 return; |
|
736 } |
|
737 |
|
738 TBuf<KSysUtilVersionTextLength> reply16; |
|
739 TInt err = SysUtil::GetLangVersion( reply16 ); |
|
740 if ( err ) |
|
741 { |
|
742 iDispatcher->DispatchOutgoingErrorMessage( |
|
743 err, |
|
744 KErrDescrSysUtil, |
|
745 KSysInfoServiceUid ); |
|
746 } |
|
747 else |
|
748 { |
|
749 iReply = HBufC8::NewL( reply16.Size() ); |
|
750 iReply->Des().Append( ( TUint8* )reply16.Ptr(), reply16.Size() ); |
|
751 } |
|
752 } |
|
753 |
|
754 //------------------------------------------------------------------------------ |
|
755 // CHtiSysInfoServicePlugin::HandleGetSwLangVersionL |
|
756 //------------------------------------------------------------------------------ |
|
757 void CHtiSysInfoServicePlugin::HandleGetSwLangVersionL( const TDesC8& aMessage ) |
|
758 { |
|
759 if ( aMessage.Length() != 1 ) |
|
760 { |
|
761 iDispatcher->DispatchOutgoingErrorMessage( |
|
762 KErrArgument, |
|
763 KErrDescrArgument, |
|
764 KSysInfoServiceUid); |
|
765 return; |
|
766 } |
|
767 |
|
768 TBuf<KSysUtilVersionTextLength> reply16; |
|
769 TInt err = SysUtil::GetLangSWVersion( reply16 ); |
|
770 if ( err ) |
|
771 { |
|
772 iDispatcher->DispatchOutgoingErrorMessage( |
|
773 err, |
|
774 KErrDescrSysUtil, |
|
775 KSysInfoServiceUid ); |
|
776 } |
|
777 else |
|
778 { |
|
779 iReply = HBufC8::NewL( reply16.Size() ); |
|
780 iReply->Des().Append( ( TUint8* )reply16.Ptr(), reply16.Size() ); |
|
781 } |
|
782 } |
|
783 |
|
784 //------------------------------------------------------------------------------ |
|
785 // CHtiSysInfoServicePlugin::HandleGetUserAgentStringL |
|
786 //------------------------------------------------------------------------------ |
|
787 void CHtiSysInfoServicePlugin::HandleGetUserAgentStringL( |
|
788 const TDesC8& aMessage ) |
|
789 { |
|
790 aMessage.Length(); // get rid of compiler warning |
|
791 iDispatcher->DispatchOutgoingErrorMessage( |
|
792 KErrNotSupported, |
|
793 KErrDescrNotSupported, |
|
794 KSysInfoServiceUid); |
|
795 } |
|
796 |
|
797 //------------------------------------------------------------------------------ |
|
798 // CHtiSysInfoServicePlugin::HandleGetFreeRamL |
|
799 //------------------------------------------------------------------------------ |
|
800 void CHtiSysInfoServicePlugin::HandleGetFreeRamL( const TDesC8& aMessage ) |
|
801 { |
|
802 if ( aMessage.Length() != 1 ) |
|
803 { |
|
804 iDispatcher->DispatchOutgoingErrorMessage( |
|
805 KErrArgument, |
|
806 KErrDescrArgument, |
|
807 KSysInfoServiceUid ); |
|
808 return; |
|
809 } |
|
810 |
|
811 User::CompressAllHeaps(); |
|
812 TInt result; |
|
813 TInt err = HAL::Get( HALData::EMemoryRAMFree, result ); |
|
814 if ( err ) |
|
815 { |
|
816 iDispatcher->DispatchOutgoingErrorMessage( |
|
817 err, |
|
818 KErrDescrFreeRAM, |
|
819 KSysInfoServiceUid ); |
|
820 } |
|
821 else |
|
822 { |
|
823 iReply = HBufC8::NewL( 4 ); |
|
824 iReply->Des().Append( ( TUint8* )( &result ), 4 ); |
|
825 } |
|
826 } |
|
827 |
|
828 //------------------------------------------------------------------------------ |
|
829 // CHtiSysInfoServicePlugin::HandleGetUsedRamL |
|
830 //------------------------------------------------------------------------------ |
|
831 void CHtiSysInfoServicePlugin::HandleGetUsedRamL( const TDesC8& aMessage ) |
|
832 { |
|
833 if ( aMessage.Length() != 1 ) |
|
834 { |
|
835 iDispatcher->DispatchOutgoingErrorMessage( |
|
836 KErrArgument, |
|
837 KErrDescrArgument, |
|
838 KSysInfoServiceUid); |
|
839 return; |
|
840 } |
|
841 |
|
842 User::CompressAllHeaps(); |
|
843 |
|
844 TInt totalRam; |
|
845 TInt freeRam; |
|
846 TInt usedRam; |
|
847 |
|
848 // first get the total RAM... |
|
849 TInt err = HAL::Get( HALData::EMemoryRAM, totalRam ); |
|
850 if ( err != KErrNone ) |
|
851 { |
|
852 iDispatcher->DispatchOutgoingErrorMessage( |
|
853 err, |
|
854 KErrDescrTotalRAM, |
|
855 KSysInfoServiceUid ); |
|
856 return; |
|
857 } |
|
858 |
|
859 // ...then get the free RAM |
|
860 err = HAL::Get( HALData::EMemoryRAMFree, freeRam ); |
|
861 if ( err ) |
|
862 { |
|
863 iDispatcher->DispatchOutgoingErrorMessage( |
|
864 err, |
|
865 KErrDescrFreeRAM, |
|
866 KSysInfoServiceUid ); |
|
867 return; |
|
868 } |
|
869 |
|
870 // calculate used RAM from total and free RAM |
|
871 usedRam = totalRam - freeRam; |
|
872 iReply = HBufC8::NewL( 4 ); |
|
873 iReply->Des().Append( ( TUint8* )( &usedRam ), 4 ); |
|
874 } |
|
875 |
|
876 //------------------------------------------------------------------------------ |
|
877 // CHtiSysInfoServicePlugin::HandleGetTotalRamL |
|
878 //------------------------------------------------------------------------------ |
|
879 void CHtiSysInfoServicePlugin::HandleGetTotalRamL( const TDesC8& aMessage ) |
|
880 { |
|
881 if ( aMessage.Length() != 1 ) |
|
882 { |
|
883 iDispatcher->DispatchOutgoingErrorMessage( |
|
884 KErrArgument, |
|
885 KErrDescrArgument, |
|
886 KSysInfoServiceUid); |
|
887 return; |
|
888 } |
|
889 |
|
890 User::CompressAllHeaps(); |
|
891 |
|
892 TInt result; |
|
893 TInt err = HAL::Get( HALData::EMemoryRAM, result ); |
|
894 if ( err ) |
|
895 { |
|
896 iDispatcher->DispatchOutgoingErrorMessage( |
|
897 err, |
|
898 KErrDescrTotalRAM, |
|
899 KSysInfoServiceUid ); |
|
900 } |
|
901 else |
|
902 { |
|
903 iReply = HBufC8::NewL( 4 ); |
|
904 iReply->Des().Append( ( TUint8* )( &result ), 4 ); |
|
905 } |
|
906 } |
|
907 |
|
908 //------------------------------------------------------------------------------ |
|
909 // CHtiSysInfoServicePlugin::HandleEatRamL |
|
910 //------------------------------------------------------------------------------ |
|
911 void CHtiSysInfoServicePlugin::HandleEatRamL( const TDesC8& aMessage ) |
|
912 { |
|
913 if ( aMessage.Length() != 5 ) |
|
914 { |
|
915 iDispatcher->DispatchOutgoingErrorMessage( |
|
916 KErrArgument, |
|
917 KErrDescrArgument, |
|
918 KSysInfoServiceUid ); |
|
919 return; |
|
920 } |
|
921 |
|
922 // get the amount of memory to be left free from the message |
|
923 TInt memLeftFree = aMessage[1] + |
|
924 ( aMessage[2] << 8 ) + |
|
925 ( aMessage[3] << 16 ) + |
|
926 ( aMessage[4] << 24 ); |
|
927 |
|
928 // if there's a previous memory eater, delete it |
|
929 if ( iMemEater != NULL ) |
|
930 { |
|
931 delete iMemEater; |
|
932 iMemEater = NULL; |
|
933 } |
|
934 |
|
935 User::CompressAllHeaps(); |
|
936 |
|
937 // get the current free memory |
|
938 TInt memFree; |
|
939 TInt err = HAL::Get( HALData::EMemoryRAMFree, memFree ); |
|
940 if ( err ) |
|
941 { |
|
942 iDispatcher->DispatchOutgoingErrorMessage( |
|
943 err, |
|
944 KErrDescrFreeRAM, |
|
945 KSysInfoServiceUid ); |
|
946 return; |
|
947 } |
|
948 |
|
949 // try to eat the memory |
|
950 TInt memToBeEaten = memFree - memLeftFree; |
|
951 |
|
952 if ( memToBeEaten < 0 ) |
|
953 { |
|
954 iDispatcher->DispatchOutgoingErrorMessage( |
|
955 KErrUnderflow, |
|
956 KErrDescrInvalidRAM, |
|
957 KSysInfoServiceUid ); |
|
958 return; |
|
959 } |
|
960 |
|
961 TRAP( err, iMemEater = HBufC8::NewL( memToBeEaten ) ); |
|
962 if ( err ) |
|
963 { |
|
964 iDispatcher->DispatchOutgoingErrorMessage( |
|
965 err, |
|
966 KErrDescrAllocRAM, |
|
967 KSysInfoServiceUid ); |
|
968 return; |
|
969 } |
|
970 |
|
971 // get the amount of memory left |
|
972 err = HAL::Get( HALData::EMemoryRAMFree, memFree ); |
|
973 if ( err ) |
|
974 { |
|
975 iDispatcher->DispatchOutgoingErrorMessage( |
|
976 err, |
|
977 KErrDescrFreeRAM, |
|
978 KSysInfoServiceUid ); |
|
979 return; |
|
980 } |
|
981 |
|
982 // send the amount of memory back |
|
983 iReply = HBufC8::NewL( 4 ); |
|
984 iReply->Des().Append( ( TUint8* )( &memFree ), 4 ); |
|
985 } |
|
986 |
|
987 //------------------------------------------------------------------------------ |
|
988 // CHtiSysInfoServicePlugin::HandleReleaseRamL |
|
989 //------------------------------------------------------------------------------ |
|
990 void CHtiSysInfoServicePlugin::HandleReleaseRamL( const TDesC8& aMessage ) |
|
991 { |
|
992 if ( aMessage.Length() != 1 ) |
|
993 { |
|
994 iDispatcher->DispatchOutgoingErrorMessage( |
|
995 KErrArgument, |
|
996 KErrDescrArgument, |
|
997 KSysInfoServiceUid ); |
|
998 return; |
|
999 } |
|
1000 |
|
1001 // if there's a memory eater, delete it |
|
1002 if ( iMemEater != NULL ) |
|
1003 { |
|
1004 delete iMemEater; |
|
1005 iMemEater = NULL; |
|
1006 } |
|
1007 |
|
1008 User::CompressAllHeaps(); |
|
1009 |
|
1010 // query the amount of memory and send it back |
|
1011 TInt memFree; |
|
1012 TInt err = HAL::Get( HALData::EMemoryRAMFree, memFree ); |
|
1013 if ( err ) |
|
1014 { |
|
1015 iDispatcher->DispatchOutgoingErrorMessage( |
|
1016 err, |
|
1017 KErrDescrHAL, |
|
1018 KSysInfoServiceUid ); |
|
1019 } |
|
1020 else |
|
1021 { |
|
1022 iReply = HBufC8::NewL( 4 ); |
|
1023 iReply->Des().Append( ( TUint8* )( &memFree ), 4 ); |
|
1024 } |
|
1025 } |
|
1026 |
|
1027 //------------------------------------------------------------------------------ |
|
1028 // CHtiSysInfoServicePlugin::HandleGetFreeDiskSpaceL |
|
1029 //------------------------------------------------------------------------------ |
|
1030 void CHtiSysInfoServicePlugin::HandleGetFreeDiskSpaceL( const TDesC8& aMessage ) |
|
1031 { |
|
1032 if ( aMessage.Length() != 2 ) |
|
1033 { |
|
1034 iDispatcher->DispatchOutgoingErrorMessage( |
|
1035 KErrArgument, |
|
1036 KErrDescrArgument, |
|
1037 KSysInfoServiceUid); |
|
1038 return; |
|
1039 } |
|
1040 |
|
1041 TInt drive; |
|
1042 RFs::CharToDrive( TChar( aMessage[1] ), drive ); |
|
1043 TVolumeInfo volInfo; |
|
1044 TInt err = iFs.Volume( volInfo, drive ); |
|
1045 |
|
1046 if ( err ) |
|
1047 { |
|
1048 iDispatcher->DispatchOutgoingErrorMessage( |
|
1049 err, |
|
1050 KErrDescrVolInfo, |
|
1051 KSysInfoServiceUid ); |
|
1052 } |
|
1053 else |
|
1054 { |
|
1055 iReply = HBufC8::NewL( 8 ); |
|
1056 iReply->Des().Append( ( TUint8* )( &volInfo.iFree ), 8 ); |
|
1057 } |
|
1058 } |
|
1059 |
|
1060 //------------------------------------------------------------------------------ |
|
1061 // CHtiSysInfoServicePlugin::HandleGetUsedDiskSpaceL |
|
1062 //------------------------------------------------------------------------------ |
|
1063 void CHtiSysInfoServicePlugin::HandleGetUsedDiskSpaceL( const TDesC8& aMessage ) |
|
1064 { |
|
1065 if ( aMessage.Length() != 2 ) |
|
1066 { |
|
1067 iDispatcher->DispatchOutgoingErrorMessage( |
|
1068 KErrArgument, |
|
1069 KErrDescrArgument, |
|
1070 KSysInfoServiceUid); |
|
1071 return; |
|
1072 } |
|
1073 |
|
1074 TInt drive; |
|
1075 RFs::CharToDrive( TChar( aMessage[1] ), drive ); |
|
1076 TVolumeInfo volInfo; |
|
1077 TInt err = iFs.Volume( volInfo, drive ); |
|
1078 |
|
1079 if ( err ) |
|
1080 { |
|
1081 iDispatcher->DispatchOutgoingErrorMessage( |
|
1082 err, |
|
1083 KErrDescrVolInfo, |
|
1084 KSysInfoServiceUid ); |
|
1085 } |
|
1086 else |
|
1087 { |
|
1088 TInt64 used = volInfo.iSize - volInfo.iFree; |
|
1089 iReply = HBufC8::NewL( 8 ); |
|
1090 iReply->Des().Append( ( TUint8* )( &used ), 8 ); |
|
1091 } |
|
1092 } |
|
1093 |
|
1094 //------------------------------------------------------------------------------ |
|
1095 // CHtiSysInfoServicePlugin::HandleGetTotalDiskSpaceL |
|
1096 //------------------------------------------------------------------------------ |
|
1097 void CHtiSysInfoServicePlugin::HandleGetTotalDiskSpaceL( |
|
1098 const TDesC8& aMessage ) |
|
1099 { |
|
1100 if ( aMessage.Length() != 2 ) |
|
1101 { |
|
1102 iDispatcher->DispatchOutgoingErrorMessage( |
|
1103 KErrArgument, |
|
1104 KErrDescrArgument, |
|
1105 KSysInfoServiceUid); |
|
1106 return; |
|
1107 } |
|
1108 |
|
1109 TInt drive; |
|
1110 RFs::CharToDrive( TChar( aMessage[1] ), drive ); |
|
1111 TVolumeInfo volInfo; |
|
1112 TInt err = iFs.Volume( volInfo, drive ); |
|
1113 |
|
1114 if ( err ) |
|
1115 { |
|
1116 iDispatcher->DispatchOutgoingErrorMessage( |
|
1117 err, |
|
1118 KErrDescrVolInfo, |
|
1119 KSysInfoServiceUid ); |
|
1120 } |
|
1121 else |
|
1122 { |
|
1123 iReply = HBufC8::NewL( 8 ); |
|
1124 iReply->Des().Append( ( TUint8* )( &volInfo.iSize ), 8 ); |
|
1125 } |
|
1126 } |
|
1127 |
|
1128 //------------------------------------------------------------------------------ |
|
1129 // CHtiSysInfoServicePlugin::HandleEatDiskSpaceL |
|
1130 //------------------------------------------------------------------------------ |
|
1131 void CHtiSysInfoServicePlugin::HandleEatDiskSpaceL( const TDesC8& aMessage ) |
|
1132 { |
|
1133 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleEatDiskSpaceL" ); |
|
1134 |
|
1135 if ( aMessage.Length() != 10 ) |
|
1136 { |
|
1137 iDispatcher->DispatchOutgoingErrorMessage( |
|
1138 KErrArgument, |
|
1139 KErrDescrArgument, |
|
1140 KSysInfoServiceUid ); |
|
1141 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleEatDiskSpaceL" ); |
|
1142 return; |
|
1143 } |
|
1144 |
|
1145 TFileName commonpath; |
|
1146 commonpath.Append( aMessage[1] ); |
|
1147 commonpath.Append( _L( ":" ) ); |
|
1148 commonpath.Append( KTempFilePath ); |
|
1149 commonpath.Append( KTempFileName ); |
|
1150 TFileName path; |
|
1151 |
|
1152 // get free disk space |
|
1153 TInt drive; |
|
1154 RFs::CharToDrive( TChar( aMessage[1] ), drive ); |
|
1155 TVolumeInfo volInfo; |
|
1156 TInt err = iFs.Volume( volInfo, drive ); |
|
1157 if ( err ) |
|
1158 { |
|
1159 iDispatcher->DispatchOutgoingErrorMessage( |
|
1160 err, |
|
1161 KErrDescrVolInfo, |
|
1162 KSysInfoServiceUid ); |
|
1163 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleEatDiskSpaceL" ); |
|
1164 return; |
|
1165 } |
|
1166 |
|
1167 // calculate how much we must eat the disk space |
|
1168 TInt64 temp1 = aMessage[2] + |
|
1169 ( aMessage[3] << 8 ) + |
|
1170 ( aMessage[4] << 16 ) + |
|
1171 ( aMessage[5] << 24 ); |
|
1172 TInt64 temp2 = aMessage[6] + |
|
1173 ( aMessage[7] << 8 ) + |
|
1174 ( aMessage[8] << 16 ) + |
|
1175 ( aMessage[9] << 24 ); |
|
1176 |
|
1177 TInt64 spaceLeftFree = temp1 + ( temp2 << 32) ; |
|
1178 TInt64 spaceToEat = volInfo.iFree - spaceLeftFree; |
|
1179 |
|
1180 HTI_LOG_FORMAT( "Disk space to eat: %Ld", spaceToEat ); |
|
1181 |
|
1182 // check that there is enough free disk space |
|
1183 if ( spaceToEat < 0 ) |
|
1184 { |
|
1185 iDispatcher->DispatchOutgoingErrorMessage( |
|
1186 KErrDiskFull, |
|
1187 KErrDescrNotEnoughSpace, |
|
1188 KSysInfoServiceUid ); |
|
1189 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleEatDiskSpaceL" ); |
|
1190 return; |
|
1191 } |
|
1192 |
|
1193 // check if scaceToEat is greater than KMaxTInt |
|
1194 // --> it must be eaten in several chunks |
|
1195 // --> not yet supported. |
|
1196 |
|
1197 TInt64 size; |
|
1198 for(TInt i=1; spaceToEat>0; i++) |
|
1199 { |
|
1200 path.Zero(); |
|
1201 path.Copy(commonpath); |
|
1202 path.AppendNum(i); |
|
1203 if ( BaflUtils::FileExists( iFs, path ) ) |
|
1204 { |
|
1205 continue; |
|
1206 } |
|
1207 |
|
1208 if(spaceToEat > KMaxTInt) |
|
1209 size=KMaxTInt; |
|
1210 else |
|
1211 size=spaceToEat; |
|
1212 |
|
1213 err = CreatFileToEatDiskSpace(path, size); |
|
1214 if(err) |
|
1215 { |
|
1216 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleEatDiskSpaceL CreateFile Fail" ); |
|
1217 return; |
|
1218 } |
|
1219 |
|
1220 iFs.Volume( volInfo, drive ); |
|
1221 HTI_LOG_FORMAT( "current free space: %Ld", volInfo.iFree ); |
|
1222 spaceToEat = volInfo.iFree - spaceLeftFree; |
|
1223 } |
|
1224 |
|
1225 // all ok, send the remaining disk size back |
|
1226 iReply = HBufC8::NewL( 8 ); |
|
1227 iReply->Des().Append( ( TUint8* )( &volInfo.iFree ), 8 ); |
|
1228 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleEatDiskSpaceL" ); |
|
1229 } |
|
1230 |
|
1231 TInt CHtiSysInfoServicePlugin::CreatFileToEatDiskSpace( TFileName aPath, TInt64 aSpaceToEat ) |
|
1232 { |
|
1233 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::CreatFileToEatDiskSpace" ); |
|
1234 |
|
1235 HTI_LOG_FORMAT( "Create file: %S", &aPath ); |
|
1236 HTI_LOG_FORMAT( "file size %Ld", aSpaceToEat ); |
|
1237 |
|
1238 // create a temp file |
|
1239 RFile diskEater; |
|
1240 TInt err = diskEater.Replace( iFs, aPath, EFileWrite ); |
|
1241 if ( err ) |
|
1242 { |
|
1243 iDispatcher->DispatchOutgoingErrorMessage( |
|
1244 err, |
|
1245 KErrDescrCreateTempFile, |
|
1246 KSysInfoServiceUid ); |
|
1247 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::CreatFileToEatDiskSpace Replace error" ); |
|
1248 return err; |
|
1249 } |
|
1250 |
|
1251 // set the size for temp file |
|
1252 err = diskEater.SetSize( I64LOW( aSpaceToEat ) ); |
|
1253 if ( err ) |
|
1254 { |
|
1255 iDispatcher->DispatchOutgoingErrorMessage( |
|
1256 err, |
|
1257 KErrDescrSetSizeTempFile, |
|
1258 KSysInfoServiceUid ); |
|
1259 diskEater.Close(); |
|
1260 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::CreatFileToEatDiskSpace SetSize error" ); |
|
1261 return err; |
|
1262 } |
|
1263 diskEater.Close(); |
|
1264 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::CreatFileToEatDiskSpace" ); |
|
1265 return 0; |
|
1266 } |
|
1267 |
|
1268 //------------------------------------------------------------------------------ |
|
1269 // CHtiSysInfoServicePlugin::HandleReleaseDiskSpaceL |
|
1270 //------------------------------------------------------------------------------ |
|
1271 void CHtiSysInfoServicePlugin::HandleReleaseDiskSpaceL( const TDesC8& aMessage ) |
|
1272 { |
|
1273 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleReleaseDiskSpaceL" ); |
|
1274 if ( aMessage.Length() != 2 ) |
|
1275 { |
|
1276 iDispatcher->DispatchOutgoingErrorMessage( |
|
1277 KErrArgument, |
|
1278 KErrDescrArgument, |
|
1279 KSysInfoServiceUid); |
|
1280 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleReleaseDiskSpaceL" ); |
|
1281 return; |
|
1282 } |
|
1283 |
|
1284 TFileName path; |
|
1285 path.Append( aMessage[1] ); |
|
1286 path.Append( _L( ":" ) ); |
|
1287 path.Append(KTempFilePath); |
|
1288 path.Append(KMatchFileName); |
|
1289 TInt err = iFileMan->Delete(path); |
|
1290 if ( err ) |
|
1291 { |
|
1292 iDispatcher->DispatchOutgoingErrorMessage( |
|
1293 err, |
|
1294 KErrDescrDeleteTempFile, |
|
1295 KSysInfoServiceUid ); |
|
1296 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleReleaseDiskSpaceL" ); |
|
1297 return; |
|
1298 } |
|
1299 |
|
1300 // query the free disk space |
|
1301 TInt drive; |
|
1302 RFs::CharToDrive( TChar( aMessage[1] ), drive ); |
|
1303 TVolumeInfo volInfo; |
|
1304 err = iFs.Volume( volInfo, drive ); |
|
1305 if ( err ) |
|
1306 { |
|
1307 iDispatcher->DispatchOutgoingErrorMessage( |
|
1308 err, |
|
1309 KErrDescrVolInfo, |
|
1310 KSysInfoServiceUid ); |
|
1311 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleReleaseDiskSpaceL" ); |
|
1312 return; |
|
1313 } |
|
1314 |
|
1315 // all ok, send the free disk space back |
|
1316 iReply = HBufC8::NewL( 8 ); |
|
1317 iReply->Des().Append( ( TUint8* )( &volInfo.iFree ), 8 ); |
|
1318 |
|
1319 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleReleaseDiskSpaceL" ); |
|
1320 } |
|
1321 |
|
1322 //------------------------------------------------------------------------------ |
|
1323 // CHtiSysInfoServicePlugin::HandleSetHomeTimeL |
|
1324 //------------------------------------------------------------------------------ |
|
1325 void CHtiSysInfoServicePlugin::HandleSetHomeTimeL( const TDesC8& aMessage ) |
|
1326 { |
|
1327 TTime time; |
|
1328 TRAPD( err, ParseTimeDataL( aMessage.Mid( 1 ), time ) ); |
|
1329 if ( err ) |
|
1330 { |
|
1331 iDispatcher->DispatchOutgoingErrorMessage( err, |
|
1332 KErrDescrArgument, |
|
1333 KSysInfoServiceUid); |
|
1334 return; |
|
1335 } |
|
1336 |
|
1337 // User::SetHomeTime() does not work correctly with daylight saving time |
|
1338 // in S60 3.0 - have to use time zone server instead. |
|
1339 RTz tzServer; |
|
1340 err = tzServer.Connect(); |
|
1341 if ( err == KErrNone ) |
|
1342 { |
|
1343 err = tzServer.SetHomeTime( time ); |
|
1344 } |
|
1345 tzServer.Close(); |
|
1346 |
|
1347 if ( err ) |
|
1348 { |
|
1349 iDispatcher->DispatchOutgoingErrorMessage( err, |
|
1350 KErrDescrSetTime, |
|
1351 KSysInfoServiceUid); |
|
1352 return; |
|
1353 } |
|
1354 |
|
1355 iReply = HBufC8::NewL( 1 ); |
|
1356 iReply->Des().Append( 0 ); |
|
1357 } |
|
1358 |
|
1359 //------------------------------------------------------------------------------ |
|
1360 // CHtiSysInfoServicePlugin::HandleGetHomeTimeL |
|
1361 //------------------------------------------------------------------------------ |
|
1362 void CHtiSysInfoServicePlugin::HandleGetHomeTimeL( const TDesC8& aMessage ) |
|
1363 { |
|
1364 if ( aMessage.Length() != 1 ) |
|
1365 { |
|
1366 iDispatcher->DispatchOutgoingErrorMessage( |
|
1367 KErrArgument, |
|
1368 KErrDescrArgument, |
|
1369 KSysInfoServiceUid ); |
|
1370 |
|
1371 return; |
|
1372 } |
|
1373 |
|
1374 TTime time; |
|
1375 time.HomeTime(); |
|
1376 TDateTime dateTime = time.DateTime(); |
|
1377 TUint year = dateTime.Year(); |
|
1378 iReply = HBufC8::NewL( KTimeDataLength ); |
|
1379 iReply->Des().Append( (TUint8*)(&year), 2 ); |
|
1380 iReply->Des().Append( dateTime.Month() + 1 ); |
|
1381 iReply->Des().Append( dateTime.Day() + 1 ); |
|
1382 iReply->Des().Append( dateTime.Hour() ); |
|
1383 iReply->Des().Append( dateTime.Minute() ); |
|
1384 iReply->Des().Append( dateTime.Second() ); |
|
1385 } |
|
1386 |
|
1387 |
|
1388 //------------------------------------------------------------------------------ |
|
1389 // CHtiSysInfoServicePlugin::HandleSetDateTimeFormatL |
|
1390 //------------------------------------------------------------------------------ |
|
1391 void CHtiSysInfoServicePlugin::HandleSetDateTimeFormatL( const TDesC8& aMessage ) |
|
1392 { |
|
1393 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleSetDateTimeFormatL" ); |
|
1394 |
|
1395 if ( aMessage.Length() != KDateTimeFormatCmdLength ) |
|
1396 { |
|
1397 iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, |
|
1398 KErrDescrArgument, KSysInfoServiceUid ); |
|
1399 return; |
|
1400 } |
|
1401 |
|
1402 // Parse values from message |
|
1403 TDateFormat dateFormat = STATIC_CAST( TDateFormat, aMessage[1] ); |
|
1404 TChar dateSepar = aMessage[2]; |
|
1405 TTimeFormat timeFormat = STATIC_CAST( TTimeFormat, aMessage[3] ); |
|
1406 TChar timeSepar = aMessage[4]; |
|
1407 TClockFormat clockFormat = STATIC_CAST( TClockFormat, aMessage[5] ); |
|
1408 |
|
1409 HTI_LOG_FORMAT( "Date format : %d", dateFormat ); |
|
1410 HTI_LOG_FORMAT( "Date separator: %c", aMessage[2] ); |
|
1411 HTI_LOG_FORMAT( "Time format : %d", timeFormat ); |
|
1412 HTI_LOG_FORMAT( "Time separator: %c", aMessage[4] ); |
|
1413 HTI_LOG_FORMAT( "Clock format : %d", clockFormat ); |
|
1414 |
|
1415 // Check validity of values |
|
1416 if ( dateFormat < EDateAmerican || dateFormat > EDateJapanese || |
|
1417 timeFormat < ETime12 || timeFormat > ETime24 || |
|
1418 clockFormat < EClockAnalog || clockFormat > EClockDigital || |
|
1419 KDateSeparatorChars().Locate( dateSepar ) == KErrNotFound || |
|
1420 KTimeSeparatorChars().Locate( timeSepar ) == KErrNotFound ) |
|
1421 { |
|
1422 iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, |
|
1423 KErrDescrArgument, KSysInfoServiceUid ); |
|
1424 return; |
|
1425 } |
|
1426 |
|
1427 // Set the values |
|
1428 TLocale locale; |
|
1429 locale.SetDateFormat( dateFormat ); |
|
1430 locale.SetDateSeparator( dateSepar, 1 ); |
|
1431 locale.SetDateSeparator( dateSepar, 2 ); |
|
1432 locale.SetTimeFormat( timeFormat ); |
|
1433 locale.SetTimeSeparator( timeSepar, 1 ); |
|
1434 locale.SetTimeSeparator( timeSepar, 2 ); |
|
1435 locale.SetClockFormat( clockFormat ); |
|
1436 TInt err = locale.Set(); |
|
1437 |
|
1438 if ( err != KErrNone ) |
|
1439 { |
|
1440 iDispatcher->DispatchOutgoingErrorMessage( err, |
|
1441 KErrDescrDateTimeFormat, KSysInfoServiceUid ); |
|
1442 } |
|
1443 else |
|
1444 { |
|
1445 iReply = HBufC8::NewL( 1 ); |
|
1446 iReply->Des().Append( 0 ); |
|
1447 } |
|
1448 |
|
1449 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleSetDateTimeFormatL" ); |
|
1450 } |
|
1451 |
|
1452 |
|
1453 //------------------------------------------------------------------------------ |
|
1454 // CHtiSysInfoServicePlugin::HandleLightsCommandL |
|
1455 //------------------------------------------------------------------------------ |
|
1456 void CHtiSysInfoServicePlugin::HandleLightsCommandL( const TDesC8& aMessage ) |
|
1457 { |
|
1458 if ( aMessage[0] == ELightRelease ) |
|
1459 { |
|
1460 if ( aMessage.Length() != 1 ) |
|
1461 { |
|
1462 iDispatcher->DispatchOutgoingErrorMessage( |
|
1463 KErrArgument, |
|
1464 KErrDescrArgument, |
|
1465 KSysInfoServiceUid); |
|
1466 } |
|
1467 |
|
1468 else |
|
1469 { |
|
1470 HTI_LOG_TEXT( "ELightRelease" ); |
|
1471 delete iLightsController; |
|
1472 iLightsController = NULL; |
|
1473 iReply = HBufC8::NewL( 1 ); |
|
1474 iReply->Des().Append( 0 ); |
|
1475 } |
|
1476 } |
|
1477 |
|
1478 else |
|
1479 { |
|
1480 if ( !iLightsController ) |
|
1481 { |
|
1482 HTI_LOG_TEXT( "Creating lights controller" ); |
|
1483 iLightsController = CHtiLightsController::NewL( |
|
1484 iDispatcher ); |
|
1485 } |
|
1486 TBuf8<4> reply; |
|
1487 iLightsController->ProcessMessageL( aMessage, reply ); |
|
1488 if ( reply.Length() > 0 ) |
|
1489 { |
|
1490 iReply = HBufC8::NewL( reply.Length() ); |
|
1491 iReply->Des().Copy( reply ); |
|
1492 } |
|
1493 } |
|
1494 } |
|
1495 |
|
1496 //------------------------------------------------------------------------------ |
|
1497 // CHtiSysInfoServicePlugin::HandleScreenSaverCommandL |
|
1498 //------------------------------------------------------------------------------ |
|
1499 void CHtiSysInfoServicePlugin::HandleScreenSaverCommandL( |
|
1500 const TDesC8& aMessage ) |
|
1501 { |
|
1502 HTI_LOG_FUNC_IN( |
|
1503 "CHtiSysInfoServicePlugin::HandleScreenSaverCommandL" ); |
|
1504 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 ) |
|
1505 if ( aMessage.Length() != 1 ) |
|
1506 { |
|
1507 iDispatcher->DispatchOutgoingErrorMessage( |
|
1508 KErrArgument, |
|
1509 KErrDescrArgument, |
|
1510 KSysInfoServiceUid); |
|
1511 return; |
|
1512 } |
|
1513 |
|
1514 if ( aMessage[0] == EScreenSaverDisable ) iAllowSSValue = 1; |
|
1515 else if ( aMessage[0] == EScreenSaverEnable ) iAllowSSValue = 0; |
|
1516 else User::Leave( KErrArgument ); |
|
1517 |
|
1518 HTI_LOG_FORMAT( "Setting allow screen saver state %d", iAllowSSValue ); |
|
1519 |
|
1520 TInt err = KErrNone; |
|
1521 |
|
1522 if ( !iAllowSSPropertyAttached ) |
|
1523 { |
|
1524 HTI_LOG_TEXT( "Attaching to KScreenSaverAllowScreenSaver property" ); |
|
1525 err = iAllowSSProperty.Attach( |
|
1526 KPSUidScreenSaver, KScreenSaverAllowScreenSaver ); |
|
1527 |
|
1528 if ( err ) |
|
1529 { |
|
1530 iDispatcher->DispatchOutgoingErrorMessage( |
|
1531 err, KErrDescrScreenSaver, KSysInfoServiceUid ); |
|
1532 return; |
|
1533 } |
|
1534 |
|
1535 iAllowSSPropertyAttached = ETrue; |
|
1536 } |
|
1537 |
|
1538 if ( iAllowSSValue == 1 ) |
|
1539 { |
|
1540 iAllowSSProperty.Set( iAllowSSValue ); // ignore error |
|
1541 // Screen saver disabled. We want to keep it disabled, so |
|
1542 // subscribe to the property to get notified about changes in it. |
|
1543 if ( !iAllowSSSubscriber ) |
|
1544 { |
|
1545 iAllowSSSubscriber = new (ELeave) CHtiPropertySubscriber( |
|
1546 TCallBack( HandleAllowSSPropertyChange, this ), |
|
1547 iAllowSSProperty ); |
|
1548 iAllowSSSubscriber->Subscribe(); |
|
1549 } |
|
1550 } |
|
1551 |
|
1552 else // iAllowSSValue == 0 |
|
1553 { |
|
1554 // Enabling screen saver. Cancel possible subscription so |
|
1555 // other applications can control the property. |
|
1556 if ( iAllowSSSubscriber ) |
|
1557 { |
|
1558 iAllowSSSubscriber->Unsubscribe(); |
|
1559 } |
|
1560 iAllowSSProperty.Set( iAllowSSValue ); // ignore error |
|
1561 iAllowSSProperty.Close(); |
|
1562 iAllowSSPropertyAttached = EFalse; |
|
1563 delete iAllowSSSubscriber; |
|
1564 iAllowSSSubscriber = NULL; |
|
1565 } |
|
1566 |
|
1567 iReply = HBufC8::NewL( 1 ); |
|
1568 iReply->Des().Append( 0 ); |
|
1569 #else |
|
1570 iDispatcher->DispatchOutgoingErrorMessage(KErrArgument, |
|
1571 KErrDescrNotSupported, KSysInfoServiceUid); |
|
1572 #endif |
|
1573 HTI_LOG_FUNC_OUT( |
|
1574 "CHtiSysInfoServicePlugin::HandleScreenSaverCommandL" ); |
|
1575 } |
|
1576 |
|
1577 //------------------------------------------------------------------------------ |
|
1578 // CHtiSysInfoServicePlugin::HandleScreenSaverTimeoutCommandL |
|
1579 //------------------------------------------------------------------------------ |
|
1580 void CHtiSysInfoServicePlugin::HandleScreenSaverTimeoutCommandL( |
|
1581 const TDesC8& aMessage ) |
|
1582 { |
|
1583 HTI_LOG_FUNC_IN( |
|
1584 "CHtiSysInfoServicePlugin::HandleScreenSaverTimeoutCommandL" ); |
|
1585 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 ) |
|
1586 if ( aMessage.Length() != 2 ) |
|
1587 { |
|
1588 iDispatcher->DispatchOutgoingErrorMessage( |
|
1589 KErrArgument, |
|
1590 KErrDescrArgument, |
|
1591 KSysInfoServiceUid); |
|
1592 return; |
|
1593 } |
|
1594 |
|
1595 TInt time = aMessage[1]; |
|
1596 HTI_LOG_FORMAT( "Requested timeout %d", time ); |
|
1597 if ( time < 5 ) |
|
1598 { |
|
1599 iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, |
|
1600 KErrDescrInvalidSSTimeout, KSysInfoServiceUid ); |
|
1601 return; |
|
1602 } |
|
1603 |
|
1604 CRepository* persRep = CRepository::NewL( KCRUidPersonalizationSettings ); |
|
1605 TInt err = persRep->Set( KSettingsScreenSaverPeriod, time ); |
|
1606 |
|
1607 if ( err == KErrNone ) |
|
1608 { |
|
1609 iReply = HBufC8::NewL( 1 ); |
|
1610 iReply->Des().Append( 0 ); |
|
1611 } |
|
1612 |
|
1613 else |
|
1614 { |
|
1615 iDispatcher->DispatchOutgoingErrorMessage( err, |
|
1616 KErrDescrSSTimeoutFailed, KSysInfoServiceUid ); |
|
1617 } |
|
1618 |
|
1619 delete persRep; |
|
1620 #else |
|
1621 iDispatcher->DispatchOutgoingErrorMessage(KErrArgument, |
|
1622 KErrDescrNotSupported, KSysInfoServiceUid); |
|
1623 #endif |
|
1624 HTI_LOG_FUNC_OUT( |
|
1625 "CHtiSysInfoServicePlugin::HandleScreenSaverTimeoutCommandL" ); |
|
1626 } |
|
1627 |
|
1628 //------------------------------------------------------------------------------ |
|
1629 // CHtiSysInfoServicePlugin::HandleNetworkModeCommandL |
|
1630 //------------------------------------------------------------------------------ |
|
1631 void CHtiSysInfoServicePlugin::HandleNetworkModeCommandL( const TDesC8& aMessage ) |
|
1632 { |
|
1633 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleNetworkModeCommandL" ); |
|
1634 |
|
1635 TInt err = StartC32(); |
|
1636 if ( ( err != KErrNone ) && ( err != KErrAlreadyExists ) ) |
|
1637 { |
|
1638 HTI_LOG_FORMAT( "StartC32 failed %d", err ); |
|
1639 User::Leave( err ); |
|
1640 } |
|
1641 |
|
1642 // Connect to telephony server |
|
1643 RTelServer telServer; |
|
1644 err = telServer.Connect(); |
|
1645 if ( err != KErrNone ) |
|
1646 { |
|
1647 HTI_LOG_FORMAT( "RTelServer::Connect() failed %d", err ); |
|
1648 User::Leave( err ); |
|
1649 } |
|
1650 CleanupClosePushL( telServer ); |
|
1651 |
|
1652 // load phonetsy |
|
1653 err = telServer.LoadPhoneModule( KMmTsyModuleName ); |
|
1654 if ( err != KErrNone ) |
|
1655 { |
|
1656 HTI_LOG_FORMAT( "RTelServer::LoadPhoneModule() failed %d", err ); |
|
1657 User::Leave( err ); |
|
1658 } |
|
1659 |
|
1660 // get phones |
|
1661 TInt noOfPhones; |
|
1662 err = telServer.EnumeratePhones( noOfPhones ); |
|
1663 if ( err != KErrNone ) |
|
1664 { |
|
1665 HTI_LOG_FORMAT( "RTelServer::EnumeratePhones() failed %d", err ); |
|
1666 User::Leave( err ); |
|
1667 } |
|
1668 |
|
1669 if ( noOfPhones == 0 ) |
|
1670 { |
|
1671 HTI_LOG_TEXT( "No phones found" ); |
|
1672 User::Leave( KErrNotFound ); |
|
1673 } |
|
1674 |
|
1675 HTI_LOG_FORMAT( "noOfPhones %d", noOfPhones ); |
|
1676 |
|
1677 RTelServer::TPhoneInfo phoneInfo; |
|
1678 for ( TInt i = 0; i < noOfPhones; i++ ) |
|
1679 { |
|
1680 TName phoneTsy; |
|
1681 telServer.GetTsyName( i, phoneTsy ); |
|
1682 HTI_LOG_DES( phoneTsy ); |
|
1683 |
|
1684 err = telServer.GetPhoneInfo( i, phoneInfo ); |
|
1685 if ( err != KErrNone ) |
|
1686 { |
|
1687 HTI_LOG_FORMAT( "RTelServer::GetPhoneInfo() %d", i ); |
|
1688 HTI_LOG_FORMAT( "failed %d", err ); |
|
1689 User::Leave( err ); |
|
1690 } |
|
1691 HTI_LOG_DES( phoneInfo.iName ); |
|
1692 } |
|
1693 |
|
1694 // open phone |
|
1695 RMobilePhone phone; |
|
1696 err = phone.Open( telServer, phoneInfo.iName ); |
|
1697 if ( err != KErrNone ) |
|
1698 { |
|
1699 HTI_LOG_FORMAT( "RMobilePhone::Open() failed %d", err ); |
|
1700 User::Leave( err ); |
|
1701 } |
|
1702 CleanupClosePushL( phone ); |
|
1703 |
|
1704 err = phone.Initialise(); |
|
1705 if ( err != KErrNone ) |
|
1706 { |
|
1707 HTI_LOG_FORMAT( "RMobilePhone::Initialise() failed %d", err ); |
|
1708 User::Leave( err ); |
|
1709 } |
|
1710 |
|
1711 // Open customapi |
|
1712 RMmCustomAPI customAPI; |
|
1713 err = customAPI.Open( phone ); |
|
1714 if ( err != KErrNone ) |
|
1715 { |
|
1716 HTI_LOG_FORMAT( "RMmCustomAPI::Open() %d", err ); |
|
1717 User::LeaveIfError( err ); |
|
1718 } |
|
1719 CleanupClosePushL( customAPI ); |
|
1720 |
|
1721 switch ( aMessage[0] ) |
|
1722 { |
|
1723 case ENetworkModeGet: |
|
1724 { |
|
1725 HTI_LOG_TEXT( "ENetworkModeGet" ); |
|
1726 TUint32 networkModes = 0; |
|
1727 err = customAPI.GetCurrentSystemNetworkModes( networkModes ); |
|
1728 if ( err ) |
|
1729 { |
|
1730 HTI_LOG_FORMAT( |
|
1731 "RMmCustomAPI::GetCurrentSystemNetworkModes() failed %d", |
|
1732 err ); |
|
1733 User::LeaveIfError( |
|
1734 iDispatcher->DispatchOutgoingErrorMessage( |
|
1735 err, |
|
1736 KErrDescrGetNetworkModes, |
|
1737 KSysInfoServiceUid ) ); |
|
1738 } |
|
1739 else |
|
1740 { |
|
1741 HTI_LOG_FORMAT( "networkModes 0x%x", networkModes ); |
|
1742 TBuf8<5> okMsg; |
|
1743 okMsg.Append( ENetworkModeGet ); |
|
1744 okMsg.Append( (TUint8*) &networkModes, 4 ); |
|
1745 iReply = okMsg.AllocL(); |
|
1746 } |
|
1747 } |
|
1748 break; |
|
1749 |
|
1750 case ENetworkModeSet: |
|
1751 HTI_LOG_TEXT( "ENetworkModeSet" ); |
|
1752 if ( aMessage.Length() != 5 ) |
|
1753 { |
|
1754 HTI_LOG_TEXT( "KErrArgument" ); |
|
1755 User::LeaveIfError( |
|
1756 iDispatcher->DispatchOutgoingErrorMessage( |
|
1757 KErrArgument, |
|
1758 KErrDescrArgument, |
|
1759 KSysInfoServiceUid ) ); |
|
1760 } |
|
1761 else |
|
1762 { |
|
1763 TUint32 mode = aMessage[1] + ( aMessage[2] << 8 ) + |
|
1764 ( aMessage[3] << 16 ) + ( aMessage[4] << 24 ); |
|
1765 |
|
1766 HTI_LOG_FORMAT( "SetSystemNetworkMode 0x%x", mode ); |
|
1767 err = customAPI.SetSystemNetworkMode( |
|
1768 ( RMmCustomAPI::TNetworkModeCaps ) mode ); |
|
1769 if ( err ) |
|
1770 { |
|
1771 HTI_LOG_FORMAT( |
|
1772 "RMmCustomAPI::SetSystemNetworkMode() failed %d", err ); |
|
1773 iDispatcher->DispatchOutgoingErrorMessage( |
|
1774 err, |
|
1775 KErrDescrSetNetworkMode, |
|
1776 KSysInfoServiceUid ); |
|
1777 } |
|
1778 else |
|
1779 { |
|
1780 iDispatcher->ShutdownAndRebootDeviceL(); |
|
1781 } |
|
1782 } |
|
1783 break; |
|
1784 |
|
1785 case ENetworkModeSetNoReboot: |
|
1786 { |
|
1787 HTI_LOG_TEXT( "ENetworkModeSetNoReboot" ); |
|
1788 if ( aMessage.Length() != 5 ) |
|
1789 { |
|
1790 HTI_LOG_TEXT( "KErrArgument" ); |
|
1791 User::LeaveIfError( |
|
1792 iDispatcher->DispatchOutgoingErrorMessage( |
|
1793 KErrArgument, |
|
1794 KErrDescrArgument, |
|
1795 KSysInfoServiceUid ) ); |
|
1796 } |
|
1797 else |
|
1798 { |
|
1799 TUint32 mode = aMessage[1] + ( aMessage[2] << 8 ) + |
|
1800 ( aMessage[3] << 16 ) + ( aMessage[4] << 24 ); |
|
1801 |
|
1802 HTI_LOG_FORMAT( "SetSystemNetworkMode 0x%x", mode ); |
|
1803 err = customAPI.SetSystemNetworkMode( |
|
1804 ( RMmCustomAPI::TNetworkModeCaps ) mode ); |
|
1805 if ( err ) |
|
1806 { |
|
1807 HTI_LOG_FORMAT( |
|
1808 "RMmCustomAPI::SetSystemNetworkMode() failed %d", err ); |
|
1809 iDispatcher->DispatchOutgoingErrorMessage( |
|
1810 err, |
|
1811 KErrDescrSetNetworkMode, |
|
1812 KSysInfoServiceUid ); |
|
1813 } |
|
1814 else |
|
1815 { |
|
1816 iReply = HBufC8::NewL( 1 ); |
|
1817 iReply->Des().Append( 0 ); |
|
1818 } |
|
1819 } |
|
1820 break; |
|
1821 } |
|
1822 |
|
1823 default: |
|
1824 break; |
|
1825 } |
|
1826 |
|
1827 CleanupStack::PopAndDestroy( 3 ); // telServer, phone, customAPI |
|
1828 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleNetworkModeCommandL" ); |
|
1829 } |
|
1830 |
|
1831 //------------------------------------------------------------------------------ |
|
1832 // CHtiSysInfoServicePlugin::HandleIrActivateCommandL |
|
1833 //------------------------------------------------------------------------------ |
|
1834 void CHtiSysInfoServicePlugin::HandleIrActivateCommandL( const TDesC8& aMessage ) |
|
1835 { |
|
1836 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleIrActivateCommandL" ); |
|
1837 |
|
1838 // Message validation |
|
1839 if ( aMessage.Length() != 1 ) |
|
1840 { |
|
1841 iDispatcher->DispatchOutgoingErrorMessage( |
|
1842 KErrArgument, |
|
1843 KErrDescrArgument, |
|
1844 KSysInfoServiceUid ); |
|
1845 return; |
|
1846 } |
|
1847 |
|
1848 TInt irStatus = -1; |
|
1849 TInt err = RProperty::Get( KIrdaPropertyCategory, KIrdaStatus, irStatus ); |
|
1850 if ( err != KErrNone || irStatus < TIrdaStatusCodes::EIrLoaded |
|
1851 || irStatus > TIrdaStatusCodes::EIrDisconnected ) |
|
1852 { |
|
1853 // values from irinternalpskey.h |
|
1854 err = RProperty::Set( KPSUidIrdaActivation, 1, 1 ); |
|
1855 if ( err != KErrNone ) |
|
1856 { |
|
1857 iDispatcher->DispatchOutgoingErrorMessage( |
|
1858 err, KErrDescrIrActivation, KSysInfoServiceUid ); |
|
1859 } |
|
1860 else |
|
1861 { |
|
1862 // Activation OK |
|
1863 iReply = HBufC8::NewL( 1 ); |
|
1864 iReply->Des().Append( 0 ); |
|
1865 } |
|
1866 } |
|
1867 else |
|
1868 { |
|
1869 // Already active - just send a message |
|
1870 iReply = HBufC8::NewL( 1 ); |
|
1871 iReply->Des().Append( 1 ); |
|
1872 } |
|
1873 |
|
1874 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleIrActivateCommandL" ); |
|
1875 } |
|
1876 |
|
1877 //------------------------------------------------------------------------------ |
|
1878 // CHtiSysInfoServicePlugin::HandleBtPowerCommandL |
|
1879 //------------------------------------------------------------------------------ |
|
1880 void CHtiSysInfoServicePlugin::HandleBtPowerCommandL( const TDesC8& aMessage ) |
|
1881 { |
|
1882 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleBtPowerCommandL" ); |
|
1883 |
|
1884 // Message validation |
|
1885 if ( aMessage.Length() != 3 ) |
|
1886 { |
|
1887 iDispatcher->DispatchOutgoingErrorMessage( |
|
1888 KErrArgument, |
|
1889 KErrDescrArgument, |
|
1890 KSysInfoServiceUid ); |
|
1891 return; |
|
1892 } |
|
1893 |
|
1894 TInt err = KErrNone; |
|
1895 TBool setBtOn = aMessage[1]; |
|
1896 TBool useForce = aMessage[2]; |
|
1897 TBool isBtOn = EFalse; |
|
1898 |
|
1899 TBTPowerStateValue powerState = EBTPowerOff; |
|
1900 CBTEngSettings* btSettings = CBTEngSettings::NewLC(); |
|
1901 err = btSettings->GetPowerState( powerState ); |
|
1902 if ( err == KErrNone && powerState == EBTPowerOn ) |
|
1903 { |
|
1904 isBtOn = ETrue; |
|
1905 } |
|
1906 |
|
1907 if ( err ) |
|
1908 { |
|
1909 HTI_LOG_FORMAT( "GetPowerState error %d", err ); |
|
1910 CleanupStack::PopAndDestroy(); // btSettings |
|
1911 iDispatcher->DispatchOutgoingErrorMessage( err, KErrDescrGetBtPower, |
|
1912 KSysInfoServiceUid ); |
|
1913 return; |
|
1914 } |
|
1915 HTI_LOG_FORMAT( "Current BT power state %d", isBtOn ); |
|
1916 HTI_LOG_FORMAT( "Requested BT power state %d", setBtOn ); |
|
1917 |
|
1918 if ( setBtOn == isBtOn ) |
|
1919 { |
|
1920 // Already in requested state - just send message |
|
1921 CleanupStack::PopAndDestroy(); // btSettings |
|
1922 iReply = HBufC8::NewL( 1 ); |
|
1923 iReply->Des().Append( 1 ); |
|
1924 } |
|
1925 |
|
1926 else |
|
1927 { |
|
1928 if ( setBtOn && !CanTurnBluetoothOnL( useForce ) ) |
|
1929 { |
|
1930 iDispatcher->DispatchOutgoingErrorMessage( KErrAccessDenied, |
|
1931 KErrDescrBtOnDenied, KSysInfoServiceUid ); |
|
1932 return; |
|
1933 } |
|
1934 |
|
1935 |
|
1936 if ( !setBtOn ) |
|
1937 { |
|
1938 // If we are setting BT off, do checks for active connections. |
|
1939 TInt connCount = 0; |
|
1940 // Ignore error. |
|
1941 // If we cannot query, we act like there's no active connections. |
|
1942 RProperty::Get( KPropertyUidBluetoothCategory, |
|
1943 KPropertyKeyBluetoothGetPHYCount, |
|
1944 connCount ); |
|
1945 // Check if there's Bluetooth audio accessory connected |
|
1946 TBool isBtAacConnected = EFalse; |
|
1947 |
|
1948 // If there are connections, force flag is required in the |
|
1949 // command to turn BT off. |
|
1950 if ( ( connCount || isBtAacConnected ) && !useForce ) |
|
1951 { |
|
1952 iDispatcher->DispatchOutgoingErrorMessage( KErrInUse, |
|
1953 KErrDescrBtOffDenied, KSysInfoServiceUid ); |
|
1954 CleanupStack::PopAndDestroy(); // btMcm/btSettings |
|
1955 return; |
|
1956 } |
|
1957 } |
|
1958 |
|
1959 if ( setBtOn ) |
|
1960 { |
|
1961 err = btSettings->SetPowerState( EBTPowerOn ); |
|
1962 } |
|
1963 else |
|
1964 { |
|
1965 err = btSettings->SetPowerState( EBTPowerOff ); |
|
1966 } |
|
1967 |
|
1968 if ( err != KErrNone ) |
|
1969 { |
|
1970 HTI_LOG_FORMAT( "CBTMCMSettings::SetPowerState error %d", err ); |
|
1971 iDispatcher->DispatchOutgoingErrorMessage( err, KErrDescrSetBtPower, |
|
1972 KSysInfoServiceUid ); |
|
1973 } |
|
1974 else |
|
1975 { |
|
1976 iReply = HBufC8::NewL( 1 ); |
|
1977 iReply->Des().Append( 0 ); |
|
1978 } |
|
1979 CleanupStack::PopAndDestroy(); // btSettings |
|
1980 } |
|
1981 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleBtPowerCommandL" ); |
|
1982 } |
|
1983 |
|
1984 //------------------------------------------------------------------------------ |
|
1985 // CHtiSysInfoServicePlugin::HandleBtSettingsCommandL |
|
1986 //------------------------------------------------------------------------------ |
|
1987 void CHtiSysInfoServicePlugin::HandleBtSettingsCommandL( const TDesC8& aMessage ) |
|
1988 { |
|
1989 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleBtSettingsCommandL" ); |
|
1990 |
|
1991 // Message validation |
|
1992 if ( aMessage.Length() < 4 ) |
|
1993 { |
|
1994 iDispatcher->DispatchOutgoingErrorMessage( |
|
1995 KErrArgument, |
|
1996 KErrDescrArgument, |
|
1997 KSysInfoServiceUid ); |
|
1998 return; |
|
1999 } |
|
2000 TInt btNameLength = aMessage[3]; |
|
2001 if ( btNameLength > KMaxBtNameLength || |
|
2002 aMessage.Length() != ( btNameLength + 4 ) ) |
|
2003 { |
|
2004 iDispatcher->DispatchOutgoingErrorMessage( |
|
2005 KErrArgument, |
|
2006 KErrDescrArgument, |
|
2007 KSysInfoServiceUid ); |
|
2008 return; |
|
2009 } |
|
2010 |
|
2011 TBTVisibilityMode visibilityMode = EBTVisibilityModeGeneral; |
|
2012 if ( aMessage[1] == 0 ) |
|
2013 { |
|
2014 visibilityMode = EBTVisibilityModeHidden; |
|
2015 } |
|
2016 HTI_LOG_FORMAT( "Visibility mode = %d", visibilityMode ); |
|
2017 |
|
2018 TInt sapMode = 1; // EBTSapEnabled |
|
2019 if ( aMessage[2] == 0 ) |
|
2020 { |
|
2021 sapMode = 0; // EBTSapDisabled |
|
2022 } |
|
2023 HTI_LOG_FORMAT( "SAP mode = %d", sapMode ); |
|
2024 |
|
2025 TBuf<KMaxBtNameLength> btName; |
|
2026 if ( btNameLength > 0 ) |
|
2027 { |
|
2028 btName.Copy( aMessage.Mid( 4, btNameLength ) ); |
|
2029 } |
|
2030 HTI_LOG_FORMAT( "BT name = %S", &btName ); |
|
2031 |
|
2032 TInt err = KErrNone; |
|
2033 CBTEngSettings* btSettings = CBTEngSettings::NewLC(); |
|
2034 HTI_LOG_TEXT( "CBTEngSettings::NewLC done" ); |
|
2035 |
|
2036 HTI_LOG_TEXT( "Setting visibility mode" ); |
|
2037 err = btSettings->SetVisibilityMode( visibilityMode ); |
|
2038 if ( err == KErrNone ) |
|
2039 { |
|
2040 HTI_LOG_TEXT( "Setting SAP mode" ); |
|
2041 // CenRep UID and key value from btengprivatecrkeys.h |
|
2042 // const TUid KCRUidBTEngPrivateSettings = { 0x10204DAC } |
|
2043 // const TUint32 KBTSapEnabled = 0x00000003 |
|
2044 CRepository* btEngRep = CRepository::NewL( TUid::Uid( 0x10204DAC ) ); |
|
2045 err = btEngRep->Set( 0x00000003, sapMode ); |
|
2046 delete btEngRep; |
|
2047 btEngRep = NULL; |
|
2048 } |
|
2049 if ( err == KErrNone && btName.Length() > 0 ) |
|
2050 { |
|
2051 HTI_LOG_TEXT( "Setting BT name" ); |
|
2052 err = btSettings->SetLocalName( btName ); |
|
2053 } |
|
2054 |
|
2055 if ( err == KErrNone ) |
|
2056 { |
|
2057 HTI_LOG_TEXT( "All set successfully" ); |
|
2058 iReply = HBufC8::NewL( 1 ); |
|
2059 iReply->Des().Append( 0 ); |
|
2060 } |
|
2061 else |
|
2062 { |
|
2063 HTI_LOG_FORMAT( "Error %d", err ); |
|
2064 iDispatcher->DispatchOutgoingErrorMessage( |
|
2065 err, |
|
2066 KErrDescrBtSettings, |
|
2067 KSysInfoServiceUid ); |
|
2068 } |
|
2069 |
|
2070 CleanupStack::PopAndDestroy(); // btSettings |
|
2071 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleBtSettingsCommandL" ); |
|
2072 } |
|
2073 |
|
2074 //------------------------------------------------------------------------------ |
|
2075 // CHtiSysInfoServicePlugin::HandleBtDeletePairingsL |
|
2076 //------------------------------------------------------------------------------ |
|
2077 void CHtiSysInfoServicePlugin::HandleBtDeletePairingsL( const TDesC8& aMessage ) |
|
2078 { |
|
2079 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleBtDeletePairingsL" ); |
|
2080 |
|
2081 // Message validation |
|
2082 if ( aMessage.Length() < 3 ) |
|
2083 { |
|
2084 iDispatcher->DispatchOutgoingErrorMessage( |
|
2085 KErrArgument, |
|
2086 KErrDescrArgument, |
|
2087 KSysInfoServiceUid ); |
|
2088 return; |
|
2089 } |
|
2090 |
|
2091 TInt btNameLength = aMessage[2]; |
|
2092 if ( btNameLength > KMaxBluetoothNameLen || |
|
2093 aMessage.Length() != ( btNameLength + 3 ) ) |
|
2094 { |
|
2095 iDispatcher->DispatchOutgoingErrorMessage( |
|
2096 KErrArgument, |
|
2097 KErrDescrArgument, |
|
2098 KSysInfoServiceUid ); |
|
2099 return; |
|
2100 } |
|
2101 |
|
2102 // Message parsing |
|
2103 TBool closeConnections = aMessage[1]; |
|
2104 HTI_LOG_FORMAT( "Close connections = %d", closeConnections ); |
|
2105 TBTDeviceName8 btName8; |
|
2106 if ( btNameLength > 0 ) |
|
2107 { |
|
2108 btName8.Copy( aMessage.Mid( 3, btNameLength ) ); |
|
2109 } |
|
2110 HTI_LOG_FORMAT( "BT name = %S", |
|
2111 &( BTDeviceNameConverter::ToUnicodeL( btName8 ) ) ); |
|
2112 |
|
2113 // Action |
|
2114 TInt deleteCount = 0; |
|
2115 TInt err = KErrNone; |
|
2116 RBTRegServ regServ; |
|
2117 RBTRegistry registry; |
|
2118 User::LeaveIfError( regServ.Connect() ); |
|
2119 CleanupClosePushL( regServ ); |
|
2120 User::LeaveIfError( registry.Open( regServ ) ); |
|
2121 CleanupClosePushL( registry ); |
|
2122 TBTRegistrySearch searchPattern; |
|
2123 searchPattern.FindBonded(); |
|
2124 |
|
2125 TRequestStatus status; |
|
2126 registry.CreateView( searchPattern, status ); |
|
2127 User::WaitForRequest( status ); |
|
2128 err = status.Int(); |
|
2129 HTI_LOG_FORMAT( "RBTRegistry::CreateView returned %d", err ); |
|
2130 |
|
2131 if ( err > 0 ) |
|
2132 { |
|
2133 CBTRegistryResponse* response = CBTRegistryResponse::NewL( registry ); |
|
2134 CleanupStack::PushL( response ); |
|
2135 HTI_LOG_TEXT( "Creating AsyncWaiter" ); |
|
2136 CAsyncWaiter* waiter = CAsyncWaiter::NewLC(); |
|
2137 HTI_LOG_TEXT( "Calling response->Start()" ); |
|
2138 response->Start( waiter->iStatus ); |
|
2139 HTI_LOG_TEXT( "Calling waiter->StartAndWait()" ); |
|
2140 waiter->StartAndWait(); |
|
2141 err = waiter->Result(); |
|
2142 CleanupStack::PopAndDestroy( waiter ); |
|
2143 |
|
2144 if ( err == KErrNone ) |
|
2145 { |
|
2146 RBTDeviceArray results = response->Results(); |
|
2147 TInt count = results.Count(); |
|
2148 for ( TInt i = 0; i < count; i++ ) |
|
2149 { |
|
2150 HTI_LOG_FORMAT( "Device %d", i + 1 ); |
|
2151 CBTDevice* device = results[i]; |
|
2152 if ( btNameLength == 0 || |
|
2153 device->DeviceName().Match( btName8 ) != KErrNotFound ) |
|
2154 { |
|
2155 HTI_LOG_TEXT( "Name qualifies for deletion" ); |
|
2156 registry.UnpairDevice( device->BDAddr(), status ); |
|
2157 User::WaitForRequest( status ); |
|
2158 err = status.Int(); |
|
2159 if ( err == KErrNone ) |
|
2160 { |
|
2161 deleteCount++; // one deletion successfully done |
|
2162 } |
|
2163 } |
|
2164 if ( err != KErrNone ) |
|
2165 { |
|
2166 // Break out if any failure occurs - the command has not |
|
2167 // been able to do what it is expected to do. |
|
2168 break; |
|
2169 } |
|
2170 } |
|
2171 } |
|
2172 CleanupStack::PopAndDestroy( response ); |
|
2173 } |
|
2174 |
|
2175 CleanupStack::PopAndDestroy( ®istry ); |
|
2176 CleanupStack::PopAndDestroy( ®Serv ); |
|
2177 |
|
2178 // Create OK response or send error |
|
2179 if ( err == KErrNone ) |
|
2180 { |
|
2181 HTI_LOG_FORMAT( "%d pairings deleted successfully", deleteCount ); |
|
2182 iReply = HBufC8::NewL( 1 ); |
|
2183 iReply->Des().Append( deleteCount ); |
|
2184 } |
|
2185 else |
|
2186 { |
|
2187 HTI_LOG_FORMAT( "Error %d", err ); |
|
2188 iDispatcher->DispatchOutgoingErrorMessage( |
|
2189 err, |
|
2190 KErrDescrBtDeletePairings, |
|
2191 KSysInfoServiceUid ); |
|
2192 } |
|
2193 |
|
2194 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleBtDeletePairingsL" ); |
|
2195 } |
|
2196 |
|
2197 //------------------------------------------------------------------------------ |
|
2198 // CHtiSysInfoServicePlugin::HandleKeyLockToggleL |
|
2199 //------------------------------------------------------------------------------ |
|
2200 void CHtiSysInfoServicePlugin::HandleKeyLockToggleL( const TDesC8& aMessage ) |
|
2201 { |
|
2202 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleKeyLockToggleL" ); |
|
2203 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 ) |
|
2204 if ( aMessage.Length() != 3 ) |
|
2205 { |
|
2206 iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, |
|
2207 KErrDescrArgument, KSysInfoServiceUid ); |
|
2208 return; |
|
2209 } |
|
2210 |
|
2211 RAknKeyLock keyLock; |
|
2212 User::LeaveIfError( keyLock.Connect() ); |
|
2213 HTI_LOG_TEXT( "RAknKeyLock connect OK" ); |
|
2214 |
|
2215 TBool isKeyLockOn = keyLock.IsKeyLockEnabled(); |
|
2216 HTI_LOG_FORMAT( "Keylock status = %d", isKeyLockOn ); |
|
2217 |
|
2218 TBool requested = aMessage[1]; |
|
2219 HTI_LOG_FORMAT( "Requested status = %d", requested ); |
|
2220 |
|
2221 if ( requested == isKeyLockOn ) |
|
2222 { |
|
2223 // Already in requested state - just send message |
|
2224 iReply = HBufC8::NewL( 1 ); |
|
2225 iReply->Des().Append( 1 ); |
|
2226 } |
|
2227 |
|
2228 else |
|
2229 { |
|
2230 TBool showNote = aMessage[2]; |
|
2231 HTI_LOG_FORMAT( "Note request = %d", showNote ); |
|
2232 if ( requested ) |
|
2233 { |
|
2234 if ( showNote ) |
|
2235 { |
|
2236 keyLock.EnableKeyLock(); |
|
2237 } |
|
2238 else |
|
2239 { |
|
2240 keyLock.EnableWithoutNote(); |
|
2241 } |
|
2242 } |
|
2243 else |
|
2244 { |
|
2245 if ( showNote ) |
|
2246 { |
|
2247 keyLock.DisableKeyLock(); |
|
2248 } |
|
2249 else |
|
2250 { |
|
2251 keyLock.DisableWithoutNote(); |
|
2252 } |
|
2253 } |
|
2254 User::After( 500000 ); |
|
2255 isKeyLockOn = keyLock.IsKeyLockEnabled(); |
|
2256 HTI_LOG_FORMAT( "New keylock status = %d", isKeyLockOn ); |
|
2257 if ( isKeyLockOn == requested ) |
|
2258 { |
|
2259 iReply = HBufC8::NewL( 1 ); |
|
2260 iReply->Des().Append( 0 ); |
|
2261 } |
|
2262 else |
|
2263 { |
|
2264 iDispatcher->DispatchOutgoingErrorMessage( KErrGeneral, |
|
2265 KErrDescrKeyLock, KSysInfoServiceUid ); |
|
2266 } |
|
2267 } |
|
2268 |
|
2269 keyLock.Close(); |
|
2270 #else |
|
2271 iDispatcher->DispatchOutgoingErrorMessage(KErrArgument, |
|
2272 KErrDescrNotSupported, KSysInfoServiceUid); |
|
2273 #endif |
|
2274 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleKeyLockToggleL" ); |
|
2275 } |
|
2276 |
|
2277 //------------------------------------------------------------------------------ |
|
2278 // CHtiSysInfoServicePlugin::HandleAutoKeyGuardTimeL |
|
2279 //------------------------------------------------------------------------------ |
|
2280 void CHtiSysInfoServicePlugin::HandleAutoKeyGuardTimeL( const TDesC8& aMessage ) |
|
2281 { |
|
2282 |
|
2283 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleAutoKeyGuardTimeL" ); |
|
2284 |
|
2285 if ( aMessage.Length() != 3 ) |
|
2286 { |
|
2287 iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, |
|
2288 KErrDescrArgument, KSysInfoServiceUid ); |
|
2289 return; |
|
2290 } |
|
2291 |
|
2292 TInt time = aMessage[1] + ( aMessage[2] << 8 ); |
|
2293 HTI_LOG_FORMAT( "Requested auto key guard time %d", time ); |
|
2294 if ( time > 3600 ) |
|
2295 { |
|
2296 iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, |
|
2297 KErrDescrInvalidTime, KSysInfoServiceUid ); |
|
2298 return; |
|
2299 } |
|
2300 |
|
2301 CRepository* secRep = CRepository::NewL( KCRUidSecuritySettings ); |
|
2302 TInt err = secRep->Set( KSettingsAutomaticKeyguardTime, time ); |
|
2303 |
|
2304 if ( err == KErrNone ) |
|
2305 { |
|
2306 iReply = HBufC8::NewL( 1 ); |
|
2307 iReply->Des().Append( 0 ); |
|
2308 } |
|
2309 |
|
2310 else |
|
2311 { |
|
2312 iDispatcher->DispatchOutgoingErrorMessage( err, |
|
2313 KErrDescrAutoKeyGuardFailed, KSysInfoServiceUid ); |
|
2314 } |
|
2315 |
|
2316 delete secRep; |
|
2317 |
|
2318 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleAutoKeyGuardTimeL" ); |
|
2319 } |
|
2320 |
|
2321 |
|
2322 //------------------------------------------------------------------------------ |
|
2323 // CHtiSysInfoServicePlugin::HandleEmptyDrmRightsDbL |
|
2324 //------------------------------------------------------------------------------ |
|
2325 void CHtiSysInfoServicePlugin::HandleEmptyDrmRightsDbL( const TDesC8& aMessage ) |
|
2326 { |
|
2327 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleEmptyDrmRightsDbL" ); |
|
2328 |
|
2329 if ( aMessage.Length() != 1 ) |
|
2330 { |
|
2331 iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, |
|
2332 KErrDescrArgument, KSysInfoServiceUid ); |
|
2333 return; |
|
2334 } |
|
2335 |
|
2336 RDRMRightsClient rightsClient; |
|
2337 TInt err = rightsClient.Connect(); |
|
2338 |
|
2339 if ( err != KErrNone ) |
|
2340 { |
|
2341 HTI_LOG_FORMAT( "RDRMRightsClient connect failed %d", err ); |
|
2342 iDispatcher->DispatchOutgoingErrorMessage( err, |
|
2343 KErrDescrDrmDbConnect, KSysInfoServiceUid ); |
|
2344 } |
|
2345 |
|
2346 else |
|
2347 { |
|
2348 HTI_LOG_TEXT( "RDRMRightsClient connect OK, clearing DB..." ); |
|
2349 err = rightsClient.DeleteAll(); |
|
2350 if ( err == KErrNone ) |
|
2351 { |
|
2352 HTI_LOG_TEXT( "DB cleared OK" ); |
|
2353 iReply = HBufC8::NewL( 1 ); |
|
2354 iReply->Des().Append( 0 ); |
|
2355 } |
|
2356 else |
|
2357 { |
|
2358 HTI_LOG_FORMAT( "DB clear failed %d", err ); |
|
2359 iDispatcher->DispatchOutgoingErrorMessage( err, |
|
2360 KErrDescrDrmDbDelete, KSysInfoServiceUid ); |
|
2361 } |
|
2362 rightsClient.Close(); |
|
2363 } |
|
2364 |
|
2365 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleEmptyDrmRightsDbL" ); |
|
2366 } |
|
2367 |
|
2368 |
|
2369 //------------------------------------------------------------------------------ |
|
2370 // CHtiSysInfoServicePlugin::HandleBatteryStatusL |
|
2371 //------------------------------------------------------------------------------ |
|
2372 void CHtiSysInfoServicePlugin::HandleBatteryStatusL( const TDesC8& aMessage ) |
|
2373 { |
|
2374 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleBatteryStatusL" ); |
|
2375 |
|
2376 if ( aMessage.Length() != 1 ) |
|
2377 { |
|
2378 iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, |
|
2379 KErrDescrArgument, KSysInfoServiceUid ); |
|
2380 return; |
|
2381 } |
|
2382 |
|
2383 TInt err = KErrNone; |
|
2384 TInt batteryLevel = EBatteryLevelUnknown; |
|
2385 TInt chargingStatus = EChargingStatusError; |
|
2386 |
|
2387 err = RProperty::Get( KPSUidHWRMPowerState, |
|
2388 KHWRMBatteryLevel, batteryLevel ); |
|
2389 HTI_LOG_FORMAT( "Battery level = %d", batteryLevel ); |
|
2390 if ( err != KErrNone || batteryLevel == EBatteryLevelUnknown ) |
|
2391 { |
|
2392 if ( err == KErrNone ) err = KErrGeneral; |
|
2393 iDispatcher->DispatchOutgoingErrorMessage( err, |
|
2394 KErrDescrBatteryLevel, KSysInfoServiceUid ); |
|
2395 return; |
|
2396 } |
|
2397 |
|
2398 err = RProperty::Get( KPSUidHWRMPowerState, |
|
2399 KHWRMChargingStatus, chargingStatus ); |
|
2400 HTI_LOG_FORMAT( "Charging status = %d", chargingStatus ); |
|
2401 if ( err != KErrNone || chargingStatus == EChargingStatusError ) |
|
2402 { |
|
2403 if ( err == KErrNone ) err = KErrGeneral; |
|
2404 iDispatcher->DispatchOutgoingErrorMessage( err, |
|
2405 KErrDescrChargingStatus, KSysInfoServiceUid ); |
|
2406 return; |
|
2407 } |
|
2408 |
|
2409 iReply = HBufC8::NewL( 2 ); |
|
2410 iReply->Des().Append( batteryLevel ); |
|
2411 iReply->Des().Append( chargingStatus ); |
|
2412 |
|
2413 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleBatteryStatusL" ); |
|
2414 } |
|
2415 |
|
2416 |
|
2417 //------------------------------------------------------------------------------ |
|
2418 // CHtiSysInfoServicePlugin::HandleSignalStrengthL |
|
2419 //------------------------------------------------------------------------------ |
|
2420 void CHtiSysInfoServicePlugin::HandleSignalStrengthL( const TDesC8& aMessage ) |
|
2421 { |
|
2422 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleSignalStrengthL" ); |
|
2423 |
|
2424 if ( aMessage.Length() != 1 ) |
|
2425 { |
|
2426 iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, |
|
2427 KErrDescrArgument, KSysInfoServiceUid ); |
|
2428 return; |
|
2429 } |
|
2430 |
|
2431 #if defined(__WINS__) |
|
2432 iDispatcher->DispatchOutgoingErrorMessage( KErrNotSupported, |
|
2433 KErrDescrNotSupported, KSysInfoServiceUid ); |
|
2434 #else |
|
2435 TInt err = KErrNone; |
|
2436 TInt popCount = 0; |
|
2437 RTelServer server; |
|
2438 err = server.Connect(); |
|
2439 |
|
2440 if ( err == KErrNone ) |
|
2441 { |
|
2442 HTI_LOG_TEXT( "Connected to RTelServer" ); |
|
2443 CleanupClosePushL( server ); |
|
2444 popCount++; |
|
2445 err = server.LoadPhoneModule( KMmTsyModuleName ); |
|
2446 if ( err == KErrAlreadyExists ) err = KErrNone; // ok if already loaded |
|
2447 } |
|
2448 |
|
2449 RMobilePhone mobilePhone; |
|
2450 |
|
2451 if ( err == KErrNone ) |
|
2452 { |
|
2453 HTI_LOG_TEXT( "Phone module loaded" ); |
|
2454 err = mobilePhone.Open( server, KMmTsyPhoneName ); |
|
2455 } |
|
2456 |
|
2457 TInt8 signalBars; |
|
2458 TInt32 signalStrength; |
|
2459 |
|
2460 if ( err == KErrNone ) |
|
2461 { |
|
2462 HTI_LOG_TEXT( "RMobilePhone open" ); |
|
2463 CleanupClosePushL( mobilePhone ); |
|
2464 popCount++; |
|
2465 TRequestStatus status; |
|
2466 mobilePhone.GetSignalStrength( status, signalStrength, signalBars ); |
|
2467 User::WaitForRequest( status ); |
|
2468 HTI_LOG_FORMAT( "GetSignalStrength return value %d", status.Int() ); |
|
2469 err = status.Int(); |
|
2470 } |
|
2471 |
|
2472 if ( err == KErrNone ) |
|
2473 { |
|
2474 HTI_LOG_FORMAT( "Signal bars = %d", signalBars ); |
|
2475 HTI_LOG_FORMAT( "Signal strength = %d", signalStrength ); |
|
2476 iReply = HBufC8::NewL( 1 ); |
|
2477 iReply->Des().Append( signalBars ); |
|
2478 } |
|
2479 |
|
2480 else |
|
2481 { |
|
2482 iDispatcher->DispatchOutgoingErrorMessage( err, |
|
2483 KErrDescrSignalStrength, KSysInfoServiceUid ); |
|
2484 } |
|
2485 |
|
2486 if ( popCount > 0 ) |
|
2487 { |
|
2488 CleanupStack::PopAndDestroy( popCount ); |
|
2489 } |
|
2490 #endif // __WINS__ |
|
2491 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleSignalStrengthL" ); |
|
2492 } |
|
2493 |
|
2494 |
|
2495 //------------------------------------------------------------------------------ |
|
2496 // CHtiSysInfoServicePlugin::HandleHsdpaCommandL |
|
2497 //------------------------------------------------------------------------------ |
|
2498 void CHtiSysInfoServicePlugin::HandleHsdpaCommandL( const TDesC8& aMessage ) |
|
2499 { |
|
2500 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleHsdpaCommandL" ); |
|
2501 |
|
2502 if ( aMessage.Length() != 2 ) |
|
2503 { |
|
2504 iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, |
|
2505 KErrDescrArgument, KSysInfoServiceUid ); |
|
2506 return; |
|
2507 } |
|
2508 TBool enableHsdpa = aMessage[1]; |
|
2509 |
|
2510 RTelServer telServer; |
|
2511 RMmCustomAPI customAPI; |
|
2512 RMobilePhone mobilePhone; |
|
2513 User::LeaveIfError( telServer.Connect() ); |
|
2514 CleanupClosePushL( telServer ); |
|
2515 User::LeaveIfError( mobilePhone.Open( telServer, KMmTsyPhoneName ) ); |
|
2516 CleanupClosePushL( mobilePhone ); |
|
2517 User::LeaveIfError( customAPI.Open( mobilePhone ) ); |
|
2518 CleanupClosePushL( customAPI ); |
|
2519 |
|
2520 // Get current HSDPA status |
|
2521 TBool isHsdpaEnabled = EFalse; |
|
2522 TRequestStatus status; |
|
2523 RMmCustomAPI::THSxPAStatus hSxPAStatus; |
|
2524 customAPI.ReadHSxPAStatus( status, hSxPAStatus ); |
|
2525 User::WaitForRequest( status ); |
|
2526 HTI_LOG_FORMAT( "Reading HSxPA status returned %d", status.Int() ); |
|
2527 User::LeaveIfError( status.Int() ); |
|
2528 if ( hSxPAStatus == RMmCustomAPI::EHSxPAEnabled ) |
|
2529 { |
|
2530 isHsdpaEnabled = ETrue; |
|
2531 } |
|
2532 |
|
2533 HTI_LOG_FORMAT( "Current HSDPA status = %d", isHsdpaEnabled ); |
|
2534 HTI_LOG_FORMAT( "Requested HSDPA status = %d", enableHsdpa ); |
|
2535 |
|
2536 if ( isHsdpaEnabled == enableHsdpa ) |
|
2537 { |
|
2538 // Already in requested state - just send message |
|
2539 iReply = HBufC8::NewL( 1 ); |
|
2540 iReply->Des().Append( 1 ); |
|
2541 } |
|
2542 |
|
2543 else |
|
2544 { |
|
2545 // Try to change status |
|
2546 if ( enableHsdpa ) |
|
2547 { |
|
2548 hSxPAStatus = RMmCustomAPI::EHSxPAEnabled; |
|
2549 } |
|
2550 else |
|
2551 { |
|
2552 hSxPAStatus = RMmCustomAPI::EHSxPADisabled; |
|
2553 } |
|
2554 customAPI.WriteHSxPAStatus( status, hSxPAStatus ); |
|
2555 User::WaitForRequest( status ); |
|
2556 HTI_LOG_FORMAT( "Writing HSxPA status returned %d", status.Int() ); |
|
2557 User::LeaveIfError( status.Int() ); |
|
2558 iReply = HBufC8::NewL( 1 ); |
|
2559 iReply->Des().Append( 0 ); |
|
2560 } |
|
2561 |
|
2562 CleanupStack::PopAndDestroy( 3 ); // mobilePhone, customAPI, telServer |
|
2563 |
|
2564 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleHsdpaCommandL" ); |
|
2565 } |
|
2566 |
|
2567 //------------------------------------------------------------------------------ |
|
2568 // CHtiSysInfoServicePlugin::HandleUpdateMediaGalleryL() |
|
2569 //------------------------------------------------------------------------------ |
|
2570 void CHtiSysInfoServicePlugin::HandleUpdateMediaGalleryL( |
|
2571 const TDesC8& aMessage ) |
|
2572 { |
|
2573 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleUpdateMediaGalleryL" ); |
|
2574 |
|
2575 if ( !iGalleryUpdateSupported ) |
|
2576 { |
|
2577 HTI_LOG_TEXT( "Media Gallery update not supported" ); |
|
2578 iDispatcher->DispatchOutgoingErrorMessage( KErrNotSupported, |
|
2579 KErrDescrNotSupported, KSysInfoServiceUid ); |
|
2580 return; |
|
2581 } |
|
2582 |
|
2583 if ( aMessage.Length() < 2 ) |
|
2584 { |
|
2585 iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, |
|
2586 KErrDescrArgument, KSysInfoServiceUid ); |
|
2587 return; |
|
2588 } |
|
2589 TInt filePathLength = aMessage[1]; |
|
2590 // Check that given file path length is valid: Index 0 is the |
|
2591 // command code, index 1 is the path length -> hence the + 2 |
|
2592 if ( aMessage.Length() != filePathLength + 2 ) |
|
2593 { |
|
2594 iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, |
|
2595 KErrDescrArgument, KSysInfoServiceUid ); |
|
2596 return; |
|
2597 } |
|
2598 |
|
2599 // Try to load the Media File API DLL |
|
2600 TInt err = KErrNone; |
|
2601 RLibrary galleryUpdaterDLL; |
|
2602 err = galleryUpdaterDLL.Load( _L( "MGXMediaFileAPI.dll" ) ); |
|
2603 if ( err == KErrNotFound ) // DLL does not exist |
|
2604 { |
|
2605 HTI_LOG_TEXT( "MGXMediaFileAPI.dll file not found" ); |
|
2606 iGalleryUpdateSupported = EFalse; |
|
2607 iDispatcher->DispatchOutgoingErrorMessage( KErrNotSupported, |
|
2608 KErrDescrNotSupported, KSysInfoServiceUid ); |
|
2609 return; |
|
2610 } |
|
2611 User::LeaveIfError( err ); // Some other error in loading the DLL |
|
2612 |
|
2613 // DLL loaded successfully |
|
2614 CleanupClosePushL( galleryUpdaterDLL ); |
|
2615 |
|
2616 // Construct the CMGXFileManager object from the DLL |
|
2617 typedef CMGXFileManager* ( *TNewFileManagerFunc )( RFs& aFs ); |
|
2618 TNewFileManagerFunc newFileManFunc = |
|
2619 ( TNewFileManagerFunc ) galleryUpdaterDLL.Lookup( 1 ); |
|
2620 if ( newFileManFunc == NULL ) |
|
2621 { |
|
2622 HTI_LOG_TEXT( "Function not found from DLL" ); |
|
2623 iGalleryUpdateSupported = EFalse; |
|
2624 User::Leave( KErrNotSupported ); |
|
2625 } |
|
2626 |
|
2627 CMGXFileManager* mgManager = NULL; |
|
2628 TRAP( err, mgManager = newFileManFunc( iFs ) ); |
|
2629 HTI_LOG_FORMAT( "NewFileManagerL returned %d", err ); |
|
2630 User::LeaveIfError( err ); |
|
2631 User::LeaveIfNull( mgManager ); |
|
2632 CleanupStack::PushL( mgManager ); |
|
2633 |
|
2634 if ( filePathLength > 0 ) |
|
2635 { |
|
2636 TBuf<KMaxFileName> path; |
|
2637 path.Copy( aMessage.Mid( 2 ) ); |
|
2638 HTI_LOG_FORMAT( "Updating file %S to gallery", &path ); |
|
2639 TRAP( err, mgManager->UpdateL( path ) ); |
|
2640 } |
|
2641 else |
|
2642 { |
|
2643 HTI_LOG_TEXT( "Updating all files to gallery" ); |
|
2644 TRAP( err, mgManager->UpdateL() ); |
|
2645 } |
|
2646 |
|
2647 if ( err != KErrNone ) |
|
2648 { |
|
2649 HTI_LOG_FORMAT( "Gallery update failed with %d", err ); |
|
2650 iDispatcher->DispatchOutgoingErrorMessage( err, KErrDescrMGUpdate, |
|
2651 KSysInfoServiceUid ); |
|
2652 } |
|
2653 |
|
2654 CleanupStack::PopAndDestroy( 2 ); // mgManager, galleryUpdaterDLL |
|
2655 iReply = HBufC8::NewL( 1 ); |
|
2656 iReply->Des().Append( 0 ); |
|
2657 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleUpdateMediaGalleryL" ); |
|
2658 } |
|
2659 |
|
2660 //------------------------------------------------------------------------------ |
|
2661 // CHtiSysInfoServicePlugin::HandleActivateSkinL() |
|
2662 //------------------------------------------------------------------------------ |
|
2663 void CHtiSysInfoServicePlugin::HandleActivateSkinL( const TDesC8& aMessage ) |
|
2664 { |
|
2665 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleActivateSkinL" ); |
|
2666 |
|
2667 // Must be at least command code + name length byte |
|
2668 if ( aMessage.Length() < 2 || aMessage.Length() != aMessage[1] + 2 ) |
|
2669 { |
|
2670 iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, |
|
2671 KErrDescrArgument, KSysInfoServiceUid ); |
|
2672 return; |
|
2673 } |
|
2674 |
|
2675 TFileName skinName; |
|
2676 if ( aMessage[1] > 0 ) |
|
2677 { |
|
2678 skinName.Copy( aMessage.Mid( 2 ) ); |
|
2679 } |
|
2680 HTI_LOG_FORMAT( "Skin name: %S", &skinName ); |
|
2681 |
|
2682 // Check if we got full path to skn file |
|
2683 TParse fileParse; |
|
2684 fileParse.Set( skinName, NULL, NULL ); |
|
2685 TBool isFullPath = fileParse.DrivePresent() && fileParse.PathPresent() && |
|
2686 fileParse.NamePresent() && fileParse.ExtPresent(); |
|
2687 HTI_LOG_FORMAT( "Is full path = %d", isFullPath ); |
|
2688 |
|
2689 // Check current skin |
|
2690 TAknsPkgIDBuf pidBuf; |
|
2691 TInt currentSkinLocation; // TAknSkinSrvSkinPackageLocation |
|
2692 CRepository* repository = |
|
2693 CRepository::NewL( KCRUidPersonalisation ); |
|
2694 CleanupStack::PushL( repository ); |
|
2695 repository->Get( KPslnActiveSkinUid, pidBuf ); |
|
2696 repository->Get( KPslnActiveSkinLocation, currentSkinLocation ); |
|
2697 TAknsPkgID currentSkinPid; |
|
2698 currentSkinPid.SetFromDesL( pidBuf ); |
|
2699 HTI_LOG_FORMAT( "Current skin pkg ID buf = %S", &pidBuf ); |
|
2700 HTI_LOG_FORMAT( "Current skin location = %d", currentSkinLocation ); |
|
2701 |
|
2702 // Connect to the skins server |
|
2703 RAknsSrvSession skinsSession; |
|
2704 User::LeaveIfError( skinsSession.Connect() ); |
|
2705 CleanupClosePushL( skinsSession ); |
|
2706 |
|
2707 // Resolve the ID for the requested skin |
|
2708 TAknsPkgID requestedSkinPid = KAknsNullPkgID; |
|
2709 TInt requestedSkinLocation = EAknsSrvPhone; |
|
2710 |
|
2711 if ( skinName.Length() == 0 ) |
|
2712 { |
|
2713 // Default skin requested - resolve default skin ID |
|
2714 // Use KAknsPIDS60DefaultSkin if nothing else found from CenRep |
|
2715 requestedSkinPid.Set( KAknsPIDS60DefaultSkin ); |
|
2716 TAknsPkgID defaultSkin = KAknsNullPkgID; |
|
2717 TAknsPkgIDBuf defaultPidBuf; |
|
2718 TInt ret = repository->Get( KPslnDefaultSkinUID, defaultPidBuf ); |
|
2719 if ( ret != KErrNone || defaultPidBuf.Length() == 0 ) |
|
2720 { |
|
2721 HTI_LOG_TEXT( "KPslnDefaultSkinUID not found" ); |
|
2722 TInt defaultID = 0; |
|
2723 ret = repository->Get( KPslnDefaultSkinID, defaultID ); |
|
2724 if ( ret == KErrNone && defaultID != 0 ) |
|
2725 { |
|
2726 HTI_LOG_FORMAT( "KPslnDefaultSkinID found: %d", defaultID ); |
|
2727 defaultSkin.Set( TUid::Uid( defaultID ) ); |
|
2728 } |
|
2729 } |
|
2730 else |
|
2731 { |
|
2732 HTI_LOG_FORMAT( "KPslnDefaultSkinUID found: %S", &defaultPidBuf ); |
|
2733 TLex lexer( defaultPidBuf ); |
|
2734 TPtrC pidToken( lexer.NextToken() ); |
|
2735 TUint pid = 0; |
|
2736 TUint timeStamp = 0; |
|
2737 // as hex UID is 8 characters |
|
2738 // as decimal UID is 9 or 10 characters |
|
2739 if ( pidToken.Length() == 8 ) |
|
2740 { |
|
2741 ret = TLex( pidToken ).Val( pid, EHex ); // value is in hex |
|
2742 } |
|
2743 else |
|
2744 { |
|
2745 ret = TLex( pidToken ).Val( pid ); // value is in decimal |
|
2746 } |
|
2747 if ( ret == KErrNone ) |
|
2748 { |
|
2749 TPtrC stampToken( lexer.NextToken() ); |
|
2750 // Timestamp doesn't exist if PID is an UID |
|
2751 if ( stampToken.Length() ) |
|
2752 { |
|
2753 if ( stampToken.Length() == 8 ) |
|
2754 { |
|
2755 // value is in hex |
|
2756 ret = TLex( stampToken ).Val( timeStamp, EHex ); |
|
2757 } |
|
2758 else |
|
2759 { |
|
2760 // value is decimal |
|
2761 ret = TLex( stampToken ).Val( timeStamp ); |
|
2762 } |
|
2763 } |
|
2764 } |
|
2765 if ( ret == KErrNone ) |
|
2766 { |
|
2767 // We have found some valid values. |
|
2768 // Timestamp is 0 if pid is UID value |
|
2769 HTI_LOG_FORMAT( "PID %d", pid ); |
|
2770 HTI_LOG_FORMAT( "Timestamp %d", timeStamp ); |
|
2771 defaultSkin.Set( timeStamp, pid ); |
|
2772 } |
|
2773 } |
|
2774 // Did we find something from CenRep |
|
2775 if ( defaultSkin != KAknsNullPkgID ) |
|
2776 { |
|
2777 requestedSkinPid.Set( defaultSkin ); |
|
2778 } |
|
2779 } |
|
2780 |
|
2781 else |
|
2782 { |
|
2783 // We have skin name - try to find it |
|
2784 CArrayPtr<CAknsSrvSkinInformationPkg>* skinInfoArray = |
|
2785 skinsSession.EnumerateSkinPackagesL( EAknsSrvAll ); |
|
2786 HTI_LOG_FORMAT( "Skins found: %d", skinInfoArray->Count() ); |
|
2787 TInt i = 0; |
|
2788 for ( ; i < skinInfoArray->Count(); i++ ) |
|
2789 { |
|
2790 if ( isFullPath ) |
|
2791 { |
|
2792 if ( skinName.CompareF( |
|
2793 skinInfoArray->At( i )->FullName() ) == 0 ) |
|
2794 { |
|
2795 requestedSkinPid = skinInfoArray->At( i )->PID(); |
|
2796 } |
|
2797 } |
|
2798 else |
|
2799 { |
|
2800 if ( skinName.CompareF( skinInfoArray->At( i )->Name() ) == 0 ) |
|
2801 { |
|
2802 requestedSkinPid = skinInfoArray->At( i )->PID(); |
|
2803 } |
|
2804 } |
|
2805 if ( requestedSkinPid != KAknsNullPkgID ) |
|
2806 { |
|
2807 // Requested skin was found - check the location |
|
2808 TUint16 drive = ( skinInfoArray->At( i )->Directory() )[0]; |
|
2809 if ( drive == 'E' || drive == 'e' ) |
|
2810 { |
|
2811 requestedSkinLocation = EAknsSrvMMC; |
|
2812 } |
|
2813 else |
|
2814 { |
|
2815 requestedSkinLocation = EAknsSrvPhone; |
|
2816 } |
|
2817 break; |
|
2818 } |
|
2819 } |
|
2820 skinInfoArray->ResetAndDestroy(); // not needed anymore |
|
2821 delete skinInfoArray; |
|
2822 skinInfoArray = NULL; |
|
2823 } |
|
2824 |
|
2825 if ( requestedSkinPid != KAknsNullPkgID ) |
|
2826 { |
|
2827 // Do we need to change skin |
|
2828 if ( requestedSkinPid != currentSkinPid ) |
|
2829 { |
|
2830 HTI_LOG_FORMAT( "Activating skin %d", requestedSkinPid.iNumber ); |
|
2831 TInt err = skinsSession.SetAllDefinitionSets( requestedSkinPid ); |
|
2832 HTI_LOG_FORMAT( "Activation returned %d", err ); |
|
2833 if ( err == KErrNone ) |
|
2834 { |
|
2835 TAknsPkgIDBuf newPidBuf; |
|
2836 requestedSkinPid.CopyToDes( newPidBuf ); |
|
2837 err = repository->Set( KPslnActiveSkinUid, newPidBuf ); |
|
2838 HTI_LOG_FORMAT( "Set KPslnActiveSkinUid returned %d", err ); |
|
2839 if ( err == KErrNone && |
|
2840 requestedSkinLocation != currentSkinLocation ) |
|
2841 { |
|
2842 err = repository->Set( |
|
2843 KPslnActiveSkinLocation, requestedSkinLocation ); |
|
2844 HTI_LOG_FORMAT( "Set KPslnActiveSkinLocation returned %d", |
|
2845 err ); |
|
2846 } |
|
2847 if ( err == KErrNone ) |
|
2848 { |
|
2849 // Send OK message |
|
2850 iReply = HBufC8::NewL( 1 ); |
|
2851 iReply->Des().Append( 0 ); // 0 means OK |
|
2852 } |
|
2853 } |
|
2854 if ( err != KErrNone ) |
|
2855 { |
|
2856 HTI_LOG_FORMAT( "Skin activation failed with %d", err ); |
|
2857 iDispatcher->DispatchOutgoingErrorMessage( err, |
|
2858 KErrDescrActivateSkin, KSysInfoServiceUid ); |
|
2859 } |
|
2860 } |
|
2861 else |
|
2862 { |
|
2863 // Requested skin already active - just send message |
|
2864 HTI_LOG_TEXT( "Already active - no need to change" ); |
|
2865 iReply = HBufC8::NewL( 1 ); |
|
2866 iReply->Des().Append( 1 ); // 1 means "already active" |
|
2867 } |
|
2868 } |
|
2869 |
|
2870 else |
|
2871 { |
|
2872 // Skin was not found |
|
2873 HTI_LOG_TEXT( "Skin was not found" ); |
|
2874 iDispatcher->DispatchOutgoingErrorMessage( KErrNotFound, |
|
2875 KErrDescrActivateSkin, KSysInfoServiceUid ); |
|
2876 } |
|
2877 |
|
2878 CleanupStack::PopAndDestroy( 2 ); // skinsSession, repository |
|
2879 |
|
2880 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleActivateSkinL" ); |
|
2881 } |
|
2882 |
|
2883 //------------------------------------------------------------------------------ |
|
2884 // CHtiSysInfoServicePlugin::HandleSetLanguageL |
|
2885 //------------------------------------------------------------------------------ |
|
2886 void CHtiSysInfoServicePlugin::HandleSetLanguageL( const TDesC8& aMessage ) |
|
2887 { |
|
2888 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::HandleSetLanguageL" ); |
|
2889 if ( aMessage.Length() != 3 ) |
|
2890 { |
|
2891 iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, |
|
2892 KErrDescrArgument, KSysInfoServiceUid ); |
|
2893 return; |
|
2894 } |
|
2895 |
|
2896 TInt language = aMessage[1] + ( aMessage[2] << 8 ); |
|
2897 if(language < 0) |
|
2898 { |
|
2899 iDispatcher->DispatchOutgoingErrorMessage( KErrArgument, |
|
2900 KErrDescrSetLanguage, KSysInfoServiceUid ); |
|
2901 return; |
|
2902 } |
|
2903 HTI_LOG_FORMAT( "Set language to %d", language ); |
|
2904 |
|
2905 // Never set Language code 0 to HAL |
|
2906 if (language != 0) |
|
2907 { |
|
2908 User::LeaveIfError(HAL::Set(HAL::ELanguageIndex, language)); |
|
2909 } |
|
2910 |
|
2911 CRepository* commonEngineRepository = CRepository::NewL( |
|
2912 KCRUidCommonEngineKeys); |
|
2913 CleanupStack::PushL(commonEngineRepository); |
|
2914 |
|
2915 User::LeaveIfError(commonEngineRepository->Set(KGSDisplayTxtLang, language)); |
|
2916 |
|
2917 CleanupStack::PopAndDestroy(); |
|
2918 |
|
2919 TBool nbrModeSaved = EFalse; |
|
2920 if (language == ELangArabic || User::Language() == ELangArabic) |
|
2921 { |
|
2922 //numberMode = EGSNumberModeArabicIndic; |
|
2923 SetDefaultNumberModeL(EGSNbrModeArabic, EGSNbrModeTypeArabic); |
|
2924 nbrModeSaved = ETrue; |
|
2925 } |
|
2926 else if ((language == ELangUrdu || User::Language() == ELangUrdu) |
|
2927 || (language == ELangFarsi || User::Language() == ELangFarsi)) |
|
2928 { |
|
2929 //numberMode = EGSNumberModeEasternArabicIndic; |
|
2930 SetDefaultNumberModeL(EGSNbrModeLatin, EGSNbrModeTypeEasternArabic); |
|
2931 nbrModeSaved = ETrue; |
|
2932 } |
|
2933 else if (language == ELangHindi || User::Language() == ELangHindi |
|
2934 || language == ELangMarathi || User::Language() == ELangMarathi) |
|
2935 { |
|
2936 //numberMode = EGSNumberModeIndic; |
|
2937 SetDefaultNumberModeL(EGSNbrModeLatin, EGSNbrModeTypeIndic); |
|
2938 nbrModeSaved = ETrue; |
|
2939 } |
|
2940 |
|
2941 //if number mode is not set above, then set it to Latin with respective |
|
2942 //number mode types. This part might be executed when Automatic is |
|
2943 //selected and the SIM card does not support the language. |
|
2944 if (!nbrModeSaved) |
|
2945 { |
|
2946 TInt nbrModeType = EGSNbrModeTypeIndic; |
|
2947 if (language == ELangArabic || User::Language() == ELangArabic) |
|
2948 { |
|
2949 nbrModeType = EGSNbrModeTypeArabic; |
|
2950 } |
|
2951 else if ((language == ELangUrdu || User::Language() == ELangUrdu) |
|
2952 || (language == ELangFarsi || User::Language() == ELangFarsi)) |
|
2953 { |
|
2954 nbrModeType = EGSNbrModeTypeEasternArabic; |
|
2955 } |
|
2956 |
|
2957 //EGSNumberModeLatin is true in both cases; |
|
2958 SetDefaultNumberModeL(EGSNbrModeLatin, nbrModeType); |
|
2959 } |
|
2960 |
|
2961 // Change input language |
|
2962 CRepository* aknFepRepository = CRepository::NewL( KCRUidAknFep ); |
|
2963 CleanupStack::PushL(aknFepRepository); |
|
2964 User::LeaveIfError( aknFepRepository->Set( KAknFepInputTxtLang, |
|
2965 language )); |
|
2966 // Change input method for Chinese variants |
|
2967 if( FeatureManager::FeatureSupported( KFeatureIdChinese ) ) |
|
2968 { |
|
2969 TBuf<KFepChineseInputModeLength> conversion; |
|
2970 if( language == ELangPrcChinese ) |
|
2971 { |
|
2972 conversion.Num( EPinyin, EHex ); |
|
2973 User::LeaveIfError( aknFepRepository->Set( KAknFepChineseInputMode, conversion ) ); |
|
2974 } |
|
2975 else if( language == ELangHongKongChinese ) |
|
2976 { |
|
2977 conversion.Num( EStroke, EHex ); |
|
2978 User::LeaveIfError( aknFepRepository->Set( KAknFepChineseInputMode, conversion ) ); |
|
2979 } |
|
2980 else if( language == ELangTaiwanChinese ) |
|
2981 { |
|
2982 conversion.Num( EZhuyin, EHex ); |
|
2983 User::LeaveIfError( aknFepRepository->Set( KAknFepChineseInputMode, conversion ) ); |
|
2984 } |
|
2985 } |
|
2986 CleanupStack::PopAndDestroy(); |
|
2987 |
|
2988 iReply = HBufC8::NewL( 1 ); |
|
2989 iReply->Des().Append( 0 ); |
|
2990 HTI_LOG_FUNC_OUT( "CHtiSysInfoServicePlugin::HandleSetLanguageL" ); |
|
2991 } |
|
2992 |
|
2993 void CHtiSysInfoServicePlugin::SetDefaultNumberModeL(TInt aMode, TInt aNbrModeType) |
|
2994 { |
|
2995 |
|
2996 CRepository* localeRepository = CRepository::NewL(KCRUidLocaleSettings); |
|
2997 CleanupStack::PushL(localeRepository); |
|
2998 if (aNbrModeType == EGSNbrModeTypeArabic || aNbrModeType |
|
2999 == EGSNbrModeTypeEasternArabic) |
|
3000 { |
|
3001 localeRepository->Set(KSettingsDefaultNumberMode, aMode); |
|
3002 } |
|
3003 else |
|
3004 { |
|
3005 localeRepository->Set(KSettingsIndicDefaultNumberMode, aMode); |
|
3006 } |
|
3007 CleanupStack::PopAndDestroy(); |
|
3008 |
|
3009 TLocale locale; |
|
3010 if (aMode == EGSNbrModeLatin) |
|
3011 { |
|
3012 locale.SetDigitType(EDigitTypeWestern); |
|
3013 } |
|
3014 else |
|
3015 { |
|
3016 //if aMode <> EGSNbrModeLatin, then it should be either latin or arabic. However |
|
3017 //as EGSNbrModeArabic and EGsNbrModeIndic both have a value = 1, we can't use |
|
3018 //that constant for below comparison. Hence, need to depend on the 2nd param. |
|
3019 switch (aNbrModeType) |
|
3020 { |
|
3021 case EGSNbrModeTypeArabic: |
|
3022 locale.SetDigitType(EDigitTypeArabicIndic); |
|
3023 break; |
|
3024 case EGSNbrModeTypeIndic: |
|
3025 locale.SetDigitType(EDigitTypeDevanagari); |
|
3026 break; |
|
3027 case EGSNbrModeTypeEasternArabic: |
|
3028 locale.SetDigitType(EDigitTypeEasternArabicIndic); |
|
3029 break; |
|
3030 default: |
|
3031 break; |
|
3032 } |
|
3033 } |
|
3034 |
|
3035 locale.Set(); |
|
3036 } |
|
3037 //------------------------------------------------------------------------------ |
|
3038 // CHtiSysInfoServicePlugin::ParseTimeDataL |
|
3039 //------------------------------------------------------------------------------ |
|
3040 void CHtiSysInfoServicePlugin::ParseTimeDataL( const TDesC8& aTimeData, |
|
3041 TTime& aResult ) |
|
3042 { |
|
3043 /* |
|
3044 aTimeData = |
|
3045 bytes 0 - 1 = year |
|
3046 2 = month |
|
3047 3 = day |
|
3048 4 = hour |
|
3049 5 = minute |
|
3050 6 = second |
|
3051 */ |
|
3052 if ( aTimeData.Length() != KTimeDataLength ) |
|
3053 { |
|
3054 User::Leave( KErrBadDescriptor ); |
|
3055 } |
|
3056 |
|
3057 TInt year = aTimeData[0] + ( aTimeData[1] << 8 ); |
|
3058 TInt month = aTimeData[2]; |
|
3059 TInt day = aTimeData[3]; |
|
3060 TInt hour = aTimeData[4]; |
|
3061 TInt minute = aTimeData[5]; |
|
3062 TInt second = aTimeData[6]; |
|
3063 |
|
3064 TDateTime dateTime; |
|
3065 User::LeaveIfError( dateTime.Set( |
|
3066 year, TMonth( month - 1 ), day - 1, hour, minute, second, 0 ) ); |
|
3067 aResult = dateTime; |
|
3068 } |
|
3069 |
|
3070 //------------------------------------------------------------------------------ |
|
3071 // CHtiSysInfoServicePlugin::CleanUpTempFiles |
|
3072 //------------------------------------------------------------------------------ |
|
3073 TInt CHtiSysInfoServicePlugin::CleanUpTempFiles() |
|
3074 { |
|
3075 HTI_LOG_FUNC_IN( "CHtiSysInfoServicePlugin::CleanUpTempFiles" ); |
|
3076 TFindFile finder( iFs ); |
|
3077 CDir* dir = NULL; |
|
3078 TInt err = finder.FindWildByDir(KMatchFileName, KTempFilePath, dir); |
|
3079 TInt safeDeleteCount = 0; |
|
3080 while ( err == KErrNone && safeDeleteCount < 20) |
|
3081 { |
|
3082 safeDeleteCount++; |
|
3083 TFileName path; |
|
3084 path.Copy(finder.File()); |
|
3085 HTI_LOG_FORMAT( "found file: %S", &path ); |
|
3086 TInt ret = iFileMan->Delete(path); |
|
3087 delete dir; |
|
3088 dir = NULL; |
|
3089 if(ret != KErrNone) |
|
3090 { |
|
3091 break; |
|
3092 } |
|
3093 err = finder.FindWildByDir(KMatchFileName, KTempFilePath, dir); |
|
3094 } |
|
3095 HTI_LOG_FUNC_OUT("CHtiSysInfoServicePlugin::CleanUpTempFiles"); |
|
3096 return KErrNone; |
|
3097 } |
|
3098 |
|
3099 //------------------------------------------------------------------------------ |
|
3100 // CHtiSysInfoServicePlugin::CanTurnBluetoothOnL |
|
3101 //------------------------------------------------------------------------------ |
|
3102 TBool CHtiSysInfoServicePlugin::CanTurnBluetoothOnL( const TBool aUseForce ) |
|
3103 { |
|
3104 HTI_LOG_FUNC_IN("CHtiSysInfoServicePlugin::CanTurnBluetoothOnL"); |
|
3105 TInt isInNetwork = 0; |
|
3106 CRepository* repository = CRepository::NewL( KCRUidCoreApplicationUIs ); |
|
3107 repository->Get( KCoreAppUIsNetworkConnectionAllowed, isInNetwork ); |
|
3108 HTI_LOG_FORMAT( "isInNetwork = %d", isInNetwork ); |
|
3109 delete repository; |
|
3110 |
|
3111 if ( isInNetwork ) |
|
3112 { |
|
3113 return ETrue; |
|
3114 } |
|
3115 |
|
3116 // Phone is offline - check if it's allowed to turn BT on. |
|
3117 |
|
3118 // If the force flag was not set in command, we won't turn BT on in offline. |
|
3119 if ( !aUseForce ) |
|
3120 { |
|
3121 return EFalse; |
|
3122 } |
|
3123 |
|
3124 // Check if it's possible to turn BT on in offline mode. |
|
3125 TInt btOfflineEnabled = 0; |
|
3126 CRepository* repository2 = CRepository::NewL( KCRUidBluetoothEngine ); |
|
3127 repository2->Get( KBTEnabledInOffline, btOfflineEnabled ); |
|
3128 HTI_LOG_FORMAT( "btOfflineEnabled = %d", btOfflineEnabled ); |
|
3129 delete repository2; |
|
3130 |
|
3131 if ( btOfflineEnabled ) |
|
3132 { |
|
3133 return ETrue; |
|
3134 } |
|
3135 HTI_LOG_FUNC_OUT("CHtiSysInfoServicePlugin::CanTurnBluetoothOnL"); |
|
3136 return EFalse; |
|
3137 } |
|
3138 |
|
3139 |
|
3140 // ---------------------------------------------------------------------------- |
|
3141 CAsyncWaiter* CAsyncWaiter::NewL( TInt aPriority ) |
|
3142 { |
|
3143 CAsyncWaiter* self = new(ELeave) CAsyncWaiter( aPriority ); |
|
3144 return self; |
|
3145 } |
|
3146 |
|
3147 // ---------------------------------------------------------------------------- |
|
3148 CAsyncWaiter* CAsyncWaiter::NewLC( TInt aPriority ) |
|
3149 { |
|
3150 CAsyncWaiter* self = new ( ELeave ) CAsyncWaiter( aPriority ); |
|
3151 CleanupStack::PushL( self ); |
|
3152 return self; |
|
3153 } |
|
3154 |
|
3155 // ---------------------------------------------------------------------------- |
|
3156 CAsyncWaiter::CAsyncWaiter( TInt aPriority ) : CActive( aPriority ) |
|
3157 { |
|
3158 iWait = new CActiveSchedulerWait(); |
|
3159 CActiveScheduler::Add( this ); |
|
3160 } |
|
3161 |
|
3162 // ---------------------------------------------------------------------------- |
|
3163 CAsyncWaiter::~CAsyncWaiter() |
|
3164 { |
|
3165 Cancel(); |
|
3166 delete iWait; |
|
3167 } |
|
3168 |
|
3169 // ---------------------------------------------------------------------------- |
|
3170 void CAsyncWaiter::StartAndWait() |
|
3171 { |
|
3172 HTI_LOG_FUNC_IN( "CAsyncWaiter::StartAndWait" ); |
|
3173 iStatus = KRequestPending; |
|
3174 SetActive(); |
|
3175 iWait->Start(); |
|
3176 HTI_LOG_FUNC_OUT( "CAsyncWaiter::StartAndWait" ); |
|
3177 } |
|
3178 |
|
3179 // ---------------------------------------------------------------------------- |
|
3180 TInt CAsyncWaiter::Result() const |
|
3181 { |
|
3182 return iResult; |
|
3183 } |
|
3184 |
|
3185 // ---------------------------------------------------------------------------- |
|
3186 void CAsyncWaiter::RunL() |
|
3187 { |
|
3188 HTI_LOG_FUNC_IN( "CAsyncWaiter::RunL" ); |
|
3189 iResult = iStatus.Int(); |
|
3190 iWait->AsyncStop(); |
|
3191 HTI_LOG_FUNC_OUT( "CAsyncWaiter::RunL" ); |
|
3192 } |
|
3193 |
|
3194 // ---------------------------------------------------------------------------- |
|
3195 void CAsyncWaiter::DoCancel() |
|
3196 { |
|
3197 iResult = KErrCancel; |
|
3198 if ( iStatus == KRequestPending ) |
|
3199 { |
|
3200 TRequestStatus* status = &iStatus; |
|
3201 User::RequestComplete( status, KErrCancel ); |
|
3202 } |
|
3203 iWait->AsyncStop(); |
|
3204 } |
|
3205 |
|
3206 |
|
3207 // End of file |