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