|
1 /* |
|
2 * Copyright (c) 2002-2008 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: Skin server settings. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "AknsSrvSettings.h" |
|
22 #include <AknsSkinUID.h> |
|
23 |
|
24 #include "AknsDebug.h" |
|
25 |
|
26 #include <AknLayoutDef.h> |
|
27 #include <centralrepository.h> |
|
28 #include <driveinfo.h> |
|
29 #include <pathinfo.h> |
|
30 |
|
31 // CenRep keys. |
|
32 #include <AvkonInternalCRKeys.h> // KAknLayoutId |
|
33 #include <AknSkinsInternalCRKeys.h> // KPslnActiveSkinUid, ... |
|
34 #include <DRMHelperServerInternalCRKeys.h> // KDRMHelperServerNotification |
|
35 #include <pslninternalcrkeys.h> // KThemesWallpaperSlideSetType |
|
36 |
|
37 //PubSub keys. |
|
38 #include <ScreensaverInternalPSKeys.h> |
|
39 #include <UsbWatcherInternalPSKeys.h> // KPSUidUsbWatcher |
|
40 #include <usbpersonalityids.h> // KUsbPersonalityIdMS |
|
41 |
|
42 // Default theme has been configured to be different from S60 Default skin. |
|
43 _LIT( KAknSkinSrvNoDefaultThemeConfigured, "0" ); |
|
44 |
|
45 // Length of hex UID in characters (number or timestamp) |
|
46 const TInt KAknsSkinSrvUIDLength = 8; |
|
47 |
|
48 // ============================== LOCAL CLASSES ================================ |
|
49 |
|
50 NONSHARABLE_CLASS(CAknsPropertySubscriber) : public CActive |
|
51 { |
|
52 public: |
|
53 CAknsPropertySubscriber(TCallBack aCallBack, RProperty& aProperty); |
|
54 virtual ~CAknsPropertySubscriber(); |
|
55 |
|
56 public: // New functions |
|
57 void SubscribeL(); |
|
58 void StopSubscribe(); |
|
59 |
|
60 private: // from CActive |
|
61 void RunL(); |
|
62 void DoCancel(); |
|
63 |
|
64 private: |
|
65 TCallBack iCallBack; |
|
66 RProperty& iProperty; |
|
67 }; |
|
68 |
|
69 NONSHARABLE_CLASS(CAknsRepositoryWatcher) : public CBase, |
|
70 public MCenRepNotifyHandlerCallback |
|
71 { |
|
72 public: |
|
73 static CAknsRepositoryWatcher* NewL( |
|
74 const TUid aUid, const TUint32 aKey, |
|
75 CCenRepNotifyHandler::TCenRepKeyType aKeyType, |
|
76 TCallBack aCallBack, CRepository* aRepository ); |
|
77 |
|
78 static CAknsRepositoryWatcher* NewL( |
|
79 const TUid aUid, TCallBack aCallBack, CRepository* aRepository); |
|
80 |
|
81 virtual ~CAknsRepositoryWatcher(); |
|
82 |
|
83 TUint32 ChangedKey(); |
|
84 |
|
85 public: // from MCenRepNotifyHandlerCallback |
|
86 void HandleNotifyInt( |
|
87 TUint32 aKey, TInt aNewValue ); |
|
88 void HandleNotifyString( |
|
89 TUint32 aKey, const TDesC16& aNewValue ); |
|
90 void HandleNotifyGeneric( |
|
91 TUint32 aKey ); |
|
92 void HandleNotifyError( |
|
93 TUint32 aKey, TInt aError, CCenRepNotifyHandler* aHandler ); |
|
94 |
|
95 private: |
|
96 CAknsRepositoryWatcher( |
|
97 const TUid aUid, const TUint32 aKey, |
|
98 TCallBack aCallBack, CRepository* aRepository); |
|
99 |
|
100 void ConstructL(CCenRepNotifyHandler::TCenRepKeyType aKeyType); |
|
101 |
|
102 void ConstructL(); |
|
103 |
|
104 private: // Data |
|
105 TUid iUid; |
|
106 TUint32 iKey; |
|
107 TUint32 iChangedKey; |
|
108 TCallBack iCallBack; |
|
109 CRepository* iRepository; |
|
110 CCenRepNotifyHandler* iNotifyHandler; |
|
111 }; |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // C++ constructor can NOT contain any code, that might leave. |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 CAknsPropertySubscriber::CAknsPropertySubscriber( |
|
118 TCallBack aCallBack, RProperty& aProperty) |
|
119 : CActive(EPriorityNormal), iCallBack(aCallBack), iProperty(aProperty) |
|
120 { |
|
121 CActiveScheduler::Add(this); |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // Destructor. |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 CAknsPropertySubscriber::~CAknsPropertySubscriber() |
|
129 { |
|
130 Cancel(); |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // Starts to listen for changes. |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 void CAknsPropertySubscriber::SubscribeL() |
|
138 { |
|
139 if (!IsActive()) |
|
140 { |
|
141 iProperty.Subscribe(iStatus); |
|
142 SetActive(); |
|
143 } |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // Stops listening for changes. |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 void CAknsPropertySubscriber::StopSubscribe() |
|
151 { |
|
152 Cancel(); |
|
153 } |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // When active object fires, call callback and continue listening. |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 void CAknsPropertySubscriber::RunL() |
|
160 { |
|
161 if (iStatus.Int() == KErrNone) |
|
162 { |
|
163 iCallBack.CallBack(); |
|
164 SubscribeL(); |
|
165 } |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // Cancel. |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 void CAknsPropertySubscriber::DoCancel() |
|
173 { |
|
174 iProperty.Cancel(); |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // Constructor. |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 CAknsRepositoryWatcher* CAknsRepositoryWatcher::NewL( |
|
182 const TUid aUid, |
|
183 const TUint32 aKey, |
|
184 CCenRepNotifyHandler::TCenRepKeyType aKeyType, |
|
185 TCallBack aCallBack, |
|
186 CRepository* aRepository) |
|
187 { |
|
188 CAknsRepositoryWatcher* self = |
|
189 new(ELeave) CAknsRepositoryWatcher(aUid, aKey, aCallBack, aRepository); |
|
190 |
|
191 CleanupStack::PushL(self); |
|
192 self->ConstructL(aKeyType); |
|
193 CleanupStack::Pop(self); |
|
194 |
|
195 return self; |
|
196 } |
|
197 |
|
198 // ----------------------------------------------------------------------------- |
|
199 // Constructor. |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 CAknsRepositoryWatcher* CAknsRepositoryWatcher::NewL( |
|
203 const TUid aUid, |
|
204 TCallBack aCallBack, |
|
205 CRepository* aRepository) |
|
206 { |
|
207 CAknsRepositoryWatcher* self = new(ELeave) CAknsRepositoryWatcher( |
|
208 aUid, |
|
209 NCentralRepositoryConstants::KInvalidNotificationId, |
|
210 aCallBack, |
|
211 aRepository ); |
|
212 |
|
213 CleanupStack::PushL(self); |
|
214 self->ConstructL(); |
|
215 CleanupStack::Pop(self); |
|
216 |
|
217 return self; |
|
218 } |
|
219 |
|
220 // ----------------------------------------------------------------------------- |
|
221 // Destructor. |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 CAknsRepositoryWatcher::~CAknsRepositoryWatcher() |
|
225 { |
|
226 if (iNotifyHandler) |
|
227 { |
|
228 iNotifyHandler->StopListening(); |
|
229 } |
|
230 delete iNotifyHandler; |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // C++ constructor can NOT contain any code, that might leave. |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 CAknsRepositoryWatcher::CAknsRepositoryWatcher( |
|
238 const TUid aUid, |
|
239 const TUint32 aKey, |
|
240 TCallBack aCallBack, |
|
241 CRepository* aRepository) |
|
242 : iUid(aUid), iKey(aKey), iCallBack(aCallBack), iRepository(aRepository) |
|
243 { |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // 2nd phase constructor. |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 void CAknsRepositoryWatcher::ConstructL( |
|
251 CCenRepNotifyHandler::TCenRepKeyType aKeyType) |
|
252 { |
|
253 iNotifyHandler = CCenRepNotifyHandler::NewL( |
|
254 *this, *iRepository, aKeyType, iKey); |
|
255 iNotifyHandler->StartListeningL(); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // 2nd phase constructor. |
|
260 // ----------------------------------------------------------------------------- |
|
261 // |
|
262 void CAknsRepositoryWatcher::ConstructL() |
|
263 { |
|
264 iNotifyHandler = CCenRepNotifyHandler::NewL(*this, *iRepository); |
|
265 iNotifyHandler->StartListeningL(); |
|
266 } |
|
267 |
|
268 // ----------------------------------------------------------------------------- |
|
269 // Returns Uid of changed key, |
|
270 // ----------------------------------------------------------------------------- |
|
271 // |
|
272 TUint32 CAknsRepositoryWatcher::ChangedKey() |
|
273 { |
|
274 return iChangedKey; |
|
275 } |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // Repository has changed - int key. |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 void CAknsRepositoryWatcher::HandleNotifyInt(TUint32 aKey, TInt /*aNewValue*/) |
|
282 { |
|
283 iChangedKey = aKey; |
|
284 iCallBack.CallBack(); |
|
285 iChangedKey = NCentralRepositoryConstants::KInvalidNotificationId; |
|
286 } |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // Repository has changed - string key. |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 void CAknsRepositoryWatcher::HandleNotifyString( |
|
293 TUint32 aKey, const TDesC16& /*aNewValue*/) |
|
294 { |
|
295 iChangedKey = aKey; |
|
296 iCallBack.CallBack(); |
|
297 iChangedKey = NCentralRepositoryConstants::KInvalidNotificationId; |
|
298 } |
|
299 |
|
300 // ----------------------------------------------------------------------------- |
|
301 // Repository has changed - all keys. |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 void CAknsRepositoryWatcher::HandleNotifyGeneric(TUint32 aKey) |
|
305 { |
|
306 iChangedKey = aKey; |
|
307 iCallBack.CallBack(); |
|
308 iChangedKey = NCentralRepositoryConstants::KInvalidNotificationId; |
|
309 } |
|
310 |
|
311 // ----------------------------------------------------------------------------- |
|
312 // Error in repository. |
|
313 // ----------------------------------------------------------------------------- |
|
314 // |
|
315 void CAknsRepositoryWatcher::HandleNotifyError( |
|
316 TUint32 /*aKey*/, TInt /*aError*/, CCenRepNotifyHandler* /*aHandler*/) |
|
317 { |
|
318 } |
|
319 |
|
320 |
|
321 // ============================= LOCAL FUNCTIONS =============================== |
|
322 |
|
323 // ----------------------------------------------------------------------------- |
|
324 // RetrieveInt |
|
325 // Retrieves an integer (to the given reference) from shared data, or uses |
|
326 // default value if an error occured. |
|
327 // ----------------------------------------------------------------------------- |
|
328 // |
|
329 static TInt RetrieveInt( |
|
330 CRepository* aRepository, const TUint32 aKey, |
|
331 TInt& aValue, const TInt aDefaultValue ) |
|
332 { |
|
333 TInt errorCode = aRepository->Get( aKey, aValue ); |
|
334 if( errorCode != KErrNone ) |
|
335 { |
|
336 aValue = aDefaultValue; |
|
337 } |
|
338 return errorCode; |
|
339 } |
|
340 |
|
341 // ----------------------------------------------------------------------------- |
|
342 // RetrievePID |
|
343 // Retrieves a package ID (to the given reference) from shared data, or uses |
|
344 // default value if an error occured. |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 static TInt RetrievePID( |
|
348 CRepository* aRepository, const TUint32 aKey, |
|
349 TAknsPkgID& aValue, const TAknsPkgID& aDefaultValue ) |
|
350 { |
|
351 TAknsPkgIDBuf buf; |
|
352 TInt errorCode = aRepository->Get( aKey, buf ); |
|
353 if( errorCode == KErrNone ) |
|
354 { |
|
355 TRAP( errorCode, aValue.SetFromDesL(buf) ); |
|
356 } |
|
357 if( errorCode != KErrNone ) |
|
358 { |
|
359 aValue.Set(aDefaultValue); |
|
360 } |
|
361 return errorCode; |
|
362 } |
|
363 |
|
364 // ============================ MEMBER FUNCTIONS =============================== |
|
365 |
|
366 // ----------------------------------------------------------------------------- |
|
367 // C++ constructor can NOT contain any code, that might leave. |
|
368 // ----------------------------------------------------------------------------- |
|
369 // |
|
370 CAknsSrvSettings::CAknsSrvSettings( MAknsSrvSettingObserver* aObserver, RFs& aFileSystemSession ) |
|
371 : iObserver( aObserver ), iFsSession ( aFileSystemSession ) |
|
372 { |
|
373 // We need to update this, when class is completely constructed. |
|
374 iActiveSkinPID.Set( KAknsPIDProductDefaultSkin ); |
|
375 } |
|
376 |
|
377 // ----------------------------------------------------------------------------- |
|
378 // 2nd phase constructor. |
|
379 // ----------------------------------------------------------------------------- |
|
380 // |
|
381 void CAknsSrvSettings::ConstructL() |
|
382 { |
|
383 iAvkonRepository = CRepository::NewL(KCRUidAvkon); |
|
384 iSkinsRepository = CRepository::NewL(KCRUidPersonalisation); |
|
385 iDefaultSkinPID = KAknsNullPkgID; |
|
386 iThemesRepository = CRepository::NewL(KCRUidThemes); |
|
387 ReadDefaultSkinID(); |
|
388 |
|
389 ReadAHMirroringActive(); |
|
390 ReadActiveSkinPID(); |
|
391 ReadHighlightAnimEnabled(); |
|
392 |
|
393 iDriveMaster = CAknsSrvDriveMaster::NewL( this ); |
|
394 |
|
395 iIdleTime = CIdle::NewL( CActive::EPriorityIdle ); |
|
396 } |
|
397 |
|
398 // ----------------------------------------------------------------------------- |
|
399 // Destructor. |
|
400 // ----------------------------------------------------------------------------- |
|
401 // |
|
402 CAknsSrvSettings::~CAknsSrvSettings() |
|
403 { |
|
404 delete iAvkonRepositoryWatcher; |
|
405 delete iAvkonRepository; |
|
406 delete iSkinsRepositoryWatcher; |
|
407 delete iSkinsRepository; |
|
408 delete iThemesRepository; |
|
409 |
|
410 if( iUSBWatchSubscriber ) |
|
411 { |
|
412 iUSBWatchSubscriber->StopSubscribe(); |
|
413 } |
|
414 iEnableUSBWatchProperty.Close(); |
|
415 delete iUSBWatchSubscriber; |
|
416 |
|
417 if( iScreensaverActivationSubscriber ) |
|
418 { |
|
419 iScreensaverActivationSubscriber->StopSubscribe(); |
|
420 } |
|
421 iScreensaverActivationProperty.Close(); |
|
422 delete iScreensaverActivationSubscriber; |
|
423 |
|
424 if ( iIdleTime ) |
|
425 { |
|
426 iIdleTime->Cancel(); |
|
427 } |
|
428 delete iIdleTime; |
|
429 delete iDriveMaster; |
|
430 } |
|
431 |
|
432 // ----------------------------------------------------------------------------- |
|
433 // Constructor. |
|
434 // ----------------------------------------------------------------------------- |
|
435 // |
|
436 CAknsSrvSettings* CAknsSrvSettings::NewL( |
|
437 MAknsSrvSettingObserver* aObserver, RFs& aFileSystemSession ) |
|
438 { |
|
439 CAknsSrvSettings* self = new (ELeave) CAknsSrvSettings( aObserver, aFileSystemSession ); |
|
440 CleanupStack::PushL( self ); |
|
441 self->ConstructL(); |
|
442 CleanupStack::Pop( self ); |
|
443 return self; |
|
444 } |
|
445 |
|
446 // ----------------------------------------------------------------------------- |
|
447 // Callback - USB status change. |
|
448 // ----------------------------------------------------------------------------- |
|
449 // |
|
450 TInt CAknsSrvSettings::USBCallBack(TAny* aPtr) |
|
451 { |
|
452 CAknsSrvSettings* self = static_cast<CAknsSrvSettings*>(aPtr); |
|
453 if (self) |
|
454 { |
|
455 self->HandlePropertyChange(EAknsSrvSPUSBAttached); |
|
456 } |
|
457 return KErrNone; |
|
458 } |
|
459 |
|
460 // ----------------------------------------------------------------------------- |
|
461 // Callback - when screensaver state changes. |
|
462 // ----------------------------------------------------------------------------- |
|
463 // |
|
464 TInt CAknsSrvSettings::SSCallBack(TAny* aPtr) |
|
465 { |
|
466 CAknsSrvSettings* self = static_cast<CAknsSrvSettings*>(aPtr); |
|
467 if (self) |
|
468 { |
|
469 self->HandlePropertyChange( EAknsSrvSPScreensaverActivation ); |
|
470 } |
|
471 return KErrNone; |
|
472 } |
|
473 |
|
474 // ----------------------------------------------------------------------------- |
|
475 // Callback - layout changed. |
|
476 // ----------------------------------------------------------------------------- |
|
477 // |
|
478 TInt CAknsSrvSettings::LayoutCallBack(TAny* aPtr) |
|
479 { |
|
480 CAknsSrvSettings* self = static_cast<CAknsSrvSettings*>(aPtr); |
|
481 if (self) |
|
482 { |
|
483 self->HandlePropertyChange( EAknsSrvSPLayoutId ); |
|
484 } |
|
485 return KErrNone; |
|
486 } |
|
487 |
|
488 // ----------------------------------------------------------------------------- |
|
489 // Callback - skins repository. |
|
490 // ----------------------------------------------------------------------------- |
|
491 // |
|
492 TInt CAknsSrvSettings::SkinsRepositoryCallBack(TAny* aPtr) |
|
493 { |
|
494 CAknsSrvSettings* self = static_cast<CAknsSrvSettings*>(aPtr); |
|
495 if (self) |
|
496 { |
|
497 switch( self->iSkinsRepositoryWatcher->ChangedKey() ) |
|
498 { |
|
499 case KPslnActiveSkinUid: |
|
500 break; |
|
501 case KPslnWallpaperType: |
|
502 self->HandlePropertyChange( EAknsSrvSPWallpaperType ); |
|
503 break; |
|
504 }; |
|
505 } |
|
506 return KErrNone; |
|
507 } |
|
508 |
|
509 // ----------------------------------------------------------------------------- |
|
510 // Callback - Themes repository. |
|
511 // ----------------------------------------------------------------------------- |
|
512 // |
|
513 TInt CAknsSrvSettings::ThemesRepositoryCallBack(TAny* aPtr) |
|
514 { |
|
515 CAknsSrvSettings* self = static_cast<CAknsSrvSettings*>(aPtr); |
|
516 if (self) |
|
517 { |
|
518 switch( self->iThemesRepositoryWatcher->ChangedKey() ) |
|
519 { |
|
520 case KThemesWallpaperSlideSetInterval: |
|
521 self->HandlePropertyChange( EAknsSrvSPSlidesetWPTimeout ); |
|
522 break; |
|
523 case KThemesWallpaperSlideSetType: |
|
524 self->HandlePropertyChange( EAknsSrvSPSlidesetWPType ); |
|
525 break; |
|
526 case KThemesTransitionEffects: |
|
527 self->HandlePropertyChange( EAknsSrvSPTransitionFx ); |
|
528 break; |
|
529 case KThemesAnimBackgroundSupport: |
|
530 self->HandlePropertyChange( EAknsSrvSPAnimBackground ); |
|
531 break; |
|
532 default: |
|
533 break; |
|
534 }; |
|
535 } |
|
536 return KErrNone; |
|
537 } |
|
538 |
|
539 // ----------------------------------------------------------------------------- |
|
540 // Callback - DRM repository. |
|
541 // ----------------------------------------------------------------------------- |
|
542 // |
|
543 TInt CAknsSrvSettings::DRMRepositoryCallBack(TAny* aPtr) |
|
544 { |
|
545 CAknsSrvSettings* self = static_cast<CAknsSrvSettings*>(aPtr); |
|
546 if (self) |
|
547 { |
|
548 if( self->iDRMRepositoryWatcher->ChangedKey() == |
|
549 KDRMHelperServerNotification ) |
|
550 { |
|
551 self->HandlePropertyChange( EAknsSrvSPDRMHelperNotification ); |
|
552 } |
|
553 } |
|
554 return KErrNone; |
|
555 } |
|
556 |
|
557 // ----------------------------------------------------------------------------- |
|
558 // Backup operation handling. |
|
559 // ----------------------------------------------------------------------------- |
|
560 // |
|
561 void CAknsSrvSettings::HandleBackupOperationEventL( |
|
562 const TBackupOperationAttributes& aBackupOperationAttributes ) |
|
563 { |
|
564 if( aBackupOperationAttributes.iOperation == EStart ) |
|
565 { |
|
566 AKNS_TRACE_INFO("CAknsSrvSettings::HandleBackupOperationEventL Operation START"); |
|
567 iBackupOperationInProgress = ETrue; |
|
568 iObserver->NotifyBackupOperationBegin(); |
|
569 } |
|
570 else if( aBackupOperationAttributes.iOperation == EEnd || |
|
571 aBackupOperationAttributes.iOperation == EAbort ) |
|
572 { |
|
573 AKNS_TRACE_INFO("CAknsSrvSettings::HandleBackupOperationEventL Operation END/ABORT"); |
|
574 iBackupOperationInProgress = EFalse; |
|
575 iObserver->NotifyBackupOperationEnd(); |
|
576 } |
|
577 } |
|
578 |
|
579 // ----------------------------------------------------------------------------- |
|
580 // CAknsSrvSettings::NotifyDriveStatusChange |
|
581 // ----------------------------------------------------------------------------- |
|
582 // |
|
583 void CAknsSrvSettings::NotifyDriveStatusChange( |
|
584 const TInt& aDrive, const TBool& aMediaNotPresent ) |
|
585 { |
|
586 iObserver->NotifyDriveChange( aDrive, aMediaNotPresent ); |
|
587 } |
|
588 |
|
589 // ----------------------------------------------------------------------------- |
|
590 // Starts additional listeners. |
|
591 // ----------------------------------------------------------------------------- |
|
592 // |
|
593 void CAknsSrvSettings::InstallAdditionalWatchersL() |
|
594 { |
|
595 iAvkonRepositoryWatcher = CAknsRepositoryWatcher::NewL( |
|
596 KCRUidAvkon, |
|
597 KAknLayoutId, |
|
598 CCenRepNotifyHandler::EIntKey, |
|
599 TCallBack(LayoutCallBack, this), |
|
600 iAvkonRepository ); |
|
601 |
|
602 iSkinsRepositoryWatcher = CAknsRepositoryWatcher::NewL( |
|
603 KCRUidPersonalisation, |
|
604 TCallBack(SkinsRepositoryCallBack, this), |
|
605 iSkinsRepository ); |
|
606 |
|
607 iDRMRepository = CRepository::NewL(KCRUidDRMHelperServer); |
|
608 iDRMRepositoryWatcher = CAknsRepositoryWatcher::NewL( |
|
609 KCRUidDRMHelperServer, |
|
610 KDRMHelperServerNotification, |
|
611 CCenRepNotifyHandler::EStringKey, |
|
612 TCallBack(DRMRepositoryCallBack, this), |
|
613 iDRMRepository ); |
|
614 |
|
615 iThemesRepositoryWatcher = CAknsRepositoryWatcher::NewL( |
|
616 KCRUidThemes, |
|
617 TCallBack(ThemesRepositoryCallBack, this), |
|
618 iThemesRepository); |
|
619 |
|
620 User::LeaveIfError( |
|
621 iScreensaverActivationProperty.Attach( KPSUidScreenSaver, KScreenSaverOn ) ); |
|
622 iScreensaverActivationSubscriber = new (ELeave) CAknsPropertySubscriber( |
|
623 TCallBack(SSCallBack, this), iScreensaverActivationProperty ); |
|
624 |
|
625 User::LeaveIfError( iEnableUSBWatchProperty.Attach( |
|
626 KPSUidUsbWatcher, KUsbWatcherSelectedPersonality) ); |
|
627 iUSBWatchSubscriber = new (ELeave) CAknsPropertySubscriber( |
|
628 TCallBack(USBCallBack, this), iEnableUSBWatchProperty ); |
|
629 iUSBWatchSubscriber->SubscribeL(); |
|
630 } |
|
631 |
|
632 // ----------------------------------------------------------------------------- |
|
633 // Sets active skin PID. |
|
634 // ----------------------------------------------------------------------------- |
|
635 // |
|
636 void CAknsSrvSettings::SetCachedSkinPID( const TAknsPkgID aPid ) |
|
637 { |
|
638 iActiveSkinPID = aPid; |
|
639 } |
|
640 |
|
641 // ----------------------------------------------------------------------------- |
|
642 // ETrue when AH mirroring is active. |
|
643 // ----------------------------------------------------------------------------- |
|
644 // |
|
645 TBool CAknsSrvSettings::CachedAHMirroringActive() |
|
646 { |
|
647 return iAHMirroringActive; |
|
648 } |
|
649 |
|
650 // ----------------------------------------------------------------------------- |
|
651 // Returns cached skin PID. |
|
652 // ----------------------------------------------------------------------------- |
|
653 // |
|
654 TAknsPkgID CAknsSrvSettings::CachedSkinPID() |
|
655 { |
|
656 return iActiveSkinPID; |
|
657 } |
|
658 |
|
659 // ----------------------------------------------------------------------------- |
|
660 // Is cached backup operation in progress. |
|
661 // ----------------------------------------------------------------------------- |
|
662 // |
|
663 TBool CAknsSrvSettings::CachedBackupOperationInProgress() |
|
664 { |
|
665 return iBackupOperationInProgress; |
|
666 } |
|
667 |
|
668 // ----------------------------------------------------------------------------- |
|
669 // Is highlight animation enabled. |
|
670 // ----------------------------------------------------------------------------- |
|
671 // |
|
672 TBool CAknsSrvSettings::HighlightAnimEnabled() const |
|
673 { |
|
674 return iHighlightAnimEnabled; |
|
675 } |
|
676 |
|
677 // ----------------------------------------------------------------------------- |
|
678 // Type of wallpaper (none/image/slideset). |
|
679 // ----------------------------------------------------------------------------- |
|
680 // |
|
681 TInt CAknsSrvSettings::WallpaperType() |
|
682 { |
|
683 TInt value = 0; |
|
684 TInt err = iSkinsRepository->Get( KPslnWallpaperType, value ); |
|
685 if (err) |
|
686 { |
|
687 value = 0; |
|
688 } |
|
689 return value; |
|
690 } |
|
691 |
|
692 // ----------------------------------------------------------------------------- |
|
693 // Type of slide set (user defined/random). |
|
694 // ----------------------------------------------------------------------------- |
|
695 // |
|
696 TInt CAknsSrvSettings::SlideSetWPType() |
|
697 { |
|
698 TInt value = 0; |
|
699 TInt err = iThemesRepository->Get( KThemesWallpaperSlideSetType, value ); |
|
700 |
|
701 // Error cases or zero value -> use random (default) |
|
702 if( err || !value ) |
|
703 { |
|
704 value = 0; |
|
705 } |
|
706 return value; |
|
707 } |
|
708 |
|
709 // ----------------------------------------------------------------------------- |
|
710 // Starts to listen for screensaver changes. |
|
711 // ----------------------------------------------------------------------------- |
|
712 // |
|
713 void CAknsSrvSettings::StartScreenSaverListen() |
|
714 { |
|
715 if( iScreensaverActivationSubscriber ) |
|
716 { |
|
717 iPreviousScreenSaverValue = ScreensaverState(); |
|
718 iScreensaverActivationSubscriber->StopSubscribe(); |
|
719 TRAPD( err, iScreensaverActivationSubscriber->SubscribeL() ); |
|
720 if ( err == KErrNone ) |
|
721 { |
|
722 iDelayedNotification = ETrue; |
|
723 } |
|
724 } |
|
725 } |
|
726 |
|
727 // ----------------------------------------------------------------------------- |
|
728 // Stops to listen for screensaver changes. |
|
729 // ----------------------------------------------------------------------------- |
|
730 // |
|
731 void CAknsSrvSettings::StopScreenSaverListen() |
|
732 { |
|
733 if( iScreensaverActivationSubscriber ) |
|
734 { |
|
735 iScreensaverActivationSubscriber->StopSubscribe(); |
|
736 } |
|
737 iDelayedNotification = EFalse; |
|
738 } |
|
739 |
|
740 // ----------------------------------------------------------------------------- |
|
741 // Return screensaver state. |
|
742 // ----------------------------------------------------------------------------- |
|
743 // |
|
744 TInt CAknsSrvSettings::ScreensaverState() const |
|
745 { |
|
746 TInt retValue = KErrNotFound; |
|
747 if ( iScreensaverActivationSubscriber ) |
|
748 { |
|
749 iScreensaverActivationProperty.Get( |
|
750 KPSUidScreenSaver, |
|
751 KScreenSaverOn, |
|
752 retValue ); |
|
753 } |
|
754 return retValue; |
|
755 } |
|
756 |
|
757 // ----------------------------------------------------------------------------- |
|
758 // Interval of image change in slide set. |
|
759 // ----------------------------------------------------------------------------- |
|
760 // |
|
761 TInt CAknsSrvSettings::SlideSetWPTimeout() |
|
762 { |
|
763 TInt value = 0; |
|
764 TInt err = iThemesRepository->Get( KThemesWallpaperSlideSetInterval, value ); |
|
765 |
|
766 // Error cases or invalid value -> use default setting (10mins). |
|
767 if( err || value < 0 ) |
|
768 { |
|
769 return 600; |
|
770 } |
|
771 else |
|
772 { |
|
773 switch (value) |
|
774 { |
|
775 case 0: |
|
776 return 60; |
|
777 case 1: |
|
778 return 600; |
|
779 case 2: |
|
780 return 1800; |
|
781 case 3: |
|
782 return 3600; |
|
783 case 4: |
|
784 return 86400; |
|
785 default: |
|
786 return 600; |
|
787 |
|
788 } |
|
789 } |
|
790 } |
|
791 |
|
792 // ----------------------------------------------------------------------------- |
|
793 // Returns transition effects state. |
|
794 // ----------------------------------------------------------------------------- |
|
795 // |
|
796 TInt CAknsSrvSettings::TransitionFxState() |
|
797 { |
|
798 TInt value = KMaxTInt; |
|
799 TInt err = iThemesRepository->Get( KThemesTransitionEffects, value ); |
|
800 |
|
801 // Error cases, disable effects |
|
802 if( err ) |
|
803 { |
|
804 return KMaxTInt; |
|
805 } |
|
806 return value; |
|
807 } |
|
808 |
|
809 // ----------------------------------------------------------------------------- |
|
810 // Returns animation effects state. |
|
811 // ----------------------------------------------------------------------------- |
|
812 // |
|
813 TInt CAknsSrvSettings::AnimBackgroundState() |
|
814 { |
|
815 TInt value = KMaxTInt; |
|
816 TInt err = iThemesRepository->Get( KThemesAnimBackgroundSupport, value ); |
|
817 if( err != KErrNone ) |
|
818 { |
|
819 value = KMaxTInt; |
|
820 } |
|
821 return value; |
|
822 } |
|
823 |
|
824 // ----------------------------------------------------------------------------- |
|
825 // Set animation effects state. |
|
826 // ----------------------------------------------------------------------------- |
|
827 // |
|
828 void CAknsSrvSettings::SetAnimBackgroundState( TInt aValue ) |
|
829 { |
|
830 ASSERT( aValue == 0 || aValue == KMaxTInt ); |
|
831 |
|
832 iThemesRepository->Set( KThemesAnimBackgroundSupport, aValue ); |
|
833 } |
|
834 |
|
835 // ----------------------------------------------------------------------------- |
|
836 // Gives a reference to drive master. |
|
837 // ----------------------------------------------------------------------------- |
|
838 // |
|
839 CAknsSrvDriveMaster* CAknsSrvSettings::GetDriveMaster() |
|
840 { |
|
841 return iDriveMaster; |
|
842 } |
|
843 |
|
844 // ----------------------------------------------------------------------------- |
|
845 // Write all settings to defaults. |
|
846 // ----------------------------------------------------------------------------- |
|
847 // |
|
848 void CAknsSrvSettings::WriteAllToDefault(TBool aExcludeWP) |
|
849 { |
|
850 WriteSkinToDefault(); |
|
851 if (!aExcludeWP) |
|
852 { |
|
853 WriteIdleBackgroundToDefault(); |
|
854 } |
|
855 } |
|
856 |
|
857 // ----------------------------------------------------------------------------- |
|
858 // Write skin to default. |
|
859 // ----------------------------------------------------------------------------- |
|
860 // |
|
861 void CAknsSrvSettings::WriteSkinToDefault() |
|
862 { |
|
863 TAknsPkgID defaultSkin = DefaultSkinPID(); |
|
864 iActiveSkinPID.Set( defaultSkin ); |
|
865 |
|
866 TAknsPkgIDBuf buf; |
|
867 defaultSkin.CopyToDes( buf ); |
|
868 iSkinsRepository->Set(KPslnActiveSkinUid, buf); |
|
869 // Active skin location |
|
870 iSkinsRepository->Set(KPslnActiveSkinLocation, 0); |
|
871 } |
|
872 |
|
873 // ----------------------------------------------------------------------------- |
|
874 // Write skin settings. |
|
875 // ----------------------------------------------------------------------------- |
|
876 // |
|
877 void CAknsSrvSettings::WriteSkinSettings(const TAknsPkgID aPid, TBool aMMC) |
|
878 { |
|
879 iActiveSkinPID.Set( aPid ); |
|
880 TAknsPkgIDBuf buf; |
|
881 iActiveSkinPID.CopyToDes(buf); |
|
882 iSkinsRepository->Set(KPslnActiveSkinUid, buf); |
|
883 // Active skin location |
|
884 TInt location = 0; |
|
885 if (aMMC) |
|
886 { |
|
887 location = 2; |
|
888 } |
|
889 iSkinsRepository->Set(KPslnActiveSkinLocation, location); |
|
890 } |
|
891 |
|
892 // ----------------------------------------------------------------------------- |
|
893 // Write wallpaper to default. |
|
894 // ----------------------------------------------------------------------------- |
|
895 // |
|
896 void CAknsSrvSettings::WriteIdleBackgroundToDefault() |
|
897 { |
|
898 TAknsPkgIDBuf buf; |
|
899 DefaultSkinPID().CopyToDes(buf); |
|
900 iSkinsRepository->Set(KPslnIdleBackgroundImageUid, buf); |
|
901 iSkinsRepository->Set(KPslnIdleBackgroundImagePath, KNullDesC()); |
|
902 iSkinsRepository->Set(KPslnWallpaperType, 0); |
|
903 } |
|
904 |
|
905 // ----------------------------------------------------------------------------- |
|
906 // Read arabic/hebrew mirroring state. |
|
907 // ----------------------------------------------------------------------------- |
|
908 // |
|
909 TInt CAknsSrvSettings::ReadAHMirroringActive() |
|
910 { |
|
911 TInt ret(0); |
|
912 TInt value(0); |
|
913 ret = RetrieveInt( iAvkonRepository, KAknLayoutId, value, 0 ); |
|
914 if( value == EAknLayoutIdABRW ) |
|
915 { |
|
916 iAHMirroringActive = ETrue; |
|
917 } |
|
918 else |
|
919 { |
|
920 iAHMirroringActive = EFalse; |
|
921 } |
|
922 return ret; |
|
923 } |
|
924 |
|
925 // ----------------------------------------------------------------------------- |
|
926 // Read active skin's PID. |
|
927 // ----------------------------------------------------------------------------- |
|
928 // |
|
929 TInt CAknsSrvSettings::ReadActiveSkinPID() |
|
930 { |
|
931 TInt ret = RetrievePID( iSkinsRepository, KPslnActiveSkinUid, |
|
932 iActiveSkinPID, DefaultSkinPID() ); |
|
933 |
|
934 // if KPslnActiveSkinUid is 0, translate to default skin |
|
935 if( iActiveSkinPID == KAknsNullPkgID ) |
|
936 { |
|
937 iActiveSkinPID.Set( DefaultSkinPID() ); |
|
938 |
|
939 TAknsPkgIDBuf buf; |
|
940 iActiveSkinPID.CopyToDes(buf); |
|
941 iSkinsRepository->Set(KPslnActiveSkinUid, buf); |
|
942 } |
|
943 |
|
944 return ret; |
|
945 } |
|
946 |
|
947 // ----------------------------------------------------------------------------- |
|
948 // Read path to wallpaper file. |
|
949 // ----------------------------------------------------------------------------- |
|
950 // |
|
951 TInt CAknsSrvSettings::ReadIdleBackgroundFile( TPath& aPath ) |
|
952 { |
|
953 return iSkinsRepository->Get( KPslnIdleBackgroundImagePath, |
|
954 aPath ); |
|
955 } |
|
956 |
|
957 // ----------------------------------------------------------------------------- |
|
958 // Read DRM Helper server notification state. |
|
959 // ----------------------------------------------------------------------------- |
|
960 // |
|
961 TInt CAknsSrvSettings::ReadDRMHelperServerNotification( TDes& aString ) |
|
962 { |
|
963 return iDRMRepository->Get( KDRMHelperServerNotification, aString ); |
|
964 } |
|
965 |
|
966 // ----------------------------------------------------------------------------- |
|
967 // Highlight animation enabled/disable flag is read-only -> just read and cache. |
|
968 // ----------------------------------------------------------------------------- |
|
969 // |
|
970 void CAknsSrvSettings::ReadHighlightAnimEnabled() |
|
971 { |
|
972 TInt value = KErrNone; |
|
973 TInt err = iSkinsRepository->Get( KPslnHighlightAnimationEnabled, value ); |
|
974 |
|
975 // Error cases or zero value -> disabled highlight animation |
|
976 if( err || !value ) |
|
977 { |
|
978 iHighlightAnimEnabled = EFalse; |
|
979 } |
|
980 else |
|
981 { |
|
982 iHighlightAnimEnabled = ETrue; |
|
983 } |
|
984 } |
|
985 |
|
986 // ----------------------------------------------------------------------------- |
|
987 // Return default skin PID. |
|
988 // ----------------------------------------------------------------------------- |
|
989 // |
|
990 TAknsPkgID CAknsSrvSettings::DefaultSkinPID() |
|
991 { |
|
992 // If value has not been read, read it now. |
|
993 if ( iDefaultSkinPID == KAknsNullPkgID ) |
|
994 { |
|
995 ReadDefaultSkinID(); |
|
996 } |
|
997 return iDefaultSkinPID; |
|
998 } |
|
999 |
|
1000 // ----------------------------------------------------------------------------- |
|
1001 // Some PS property has changed. |
|
1002 // ----------------------------------------------------------------------------- |
|
1003 // |
|
1004 void CAknsSrvSettings::HandlePropertyChange( |
|
1005 const TAknsSrvSettingsProperty aProperty ) |
|
1006 { |
|
1007 switch( aProperty ) |
|
1008 { |
|
1009 case EAknsSrvSPUSBAttached: |
|
1010 { |
|
1011 TInt value = KErrNone; |
|
1012 iEnableUSBWatchProperty.Get(value); |
|
1013 if (value == KUsbPersonalityIdMS) |
|
1014 { |
|
1015 iObserver->NotifyUSBAttach(); |
|
1016 } |
|
1017 else |
|
1018 { |
|
1019 iObserver->NotifyUSBRemoval(); |
|
1020 } |
|
1021 } |
|
1022 break; |
|
1023 case EAknsSrvSPLayoutId: |
|
1024 { |
|
1025 ReadAHMirroringActive(); |
|
1026 iObserver->NotifyLayoutChange(); |
|
1027 } |
|
1028 break; |
|
1029 |
|
1030 case EAknsSrvSPActiveSkin: |
|
1031 { |
|
1032 TAknsPkgID oldSkin = iActiveSkinPID; |
|
1033 ReadActiveSkinPID(); |
|
1034 |
|
1035 if( oldSkin != iActiveSkinPID) |
|
1036 { |
|
1037 iObserver->NofifySkinChange(); |
|
1038 } |
|
1039 } |
|
1040 break; |
|
1041 |
|
1042 case EAknsSrvSPIdleBackground: |
|
1043 iObserver->NotifyIdleBackgroundChange(); |
|
1044 break; |
|
1045 |
|
1046 case EAknsSrvSPDRMHelperNotification: |
|
1047 iObserver->NotifyDRMChange(); |
|
1048 break; |
|
1049 case EAknsSrvSPWallpaperType: |
|
1050 iObserver->NotifyWallpaperTypeChange(); |
|
1051 break; |
|
1052 case EAknsSrvSPSlidesetWPTimeout: |
|
1053 iObserver->NotifySlideSetTimeoutChange(); |
|
1054 break; |
|
1055 case EAknsSrvSPSlidesetWPType: |
|
1056 iObserver->NotifySlideSetTypeChange(); |
|
1057 break; |
|
1058 |
|
1059 case EAknsSrvSPScreensaverActivation: |
|
1060 { |
|
1061 TInt screenSaverState = ScreensaverState(); |
|
1062 if ( ( iPreviousScreenSaverValue != screenSaverState ) && |
|
1063 ( screenSaverState == 0 ) ) |
|
1064 { |
|
1065 if ( iIdleTime ) |
|
1066 { |
|
1067 iIdleTime->Cancel(); |
|
1068 delete iIdleTime; |
|
1069 iIdleTime = NULL; |
|
1070 } |
|
1071 TRAP_IGNORE( |
|
1072 iIdleTime = CIdle::NewL( CActive::EPriorityIdle ); |
|
1073 iIdleTime->Start( TCallBack( DoHandleIdleTimeL, this ) ) ; |
|
1074 ); |
|
1075 } |
|
1076 } |
|
1077 break; |
|
1078 case EAknsSrvSPTransitionFx: |
|
1079 iObserver->NotifyTransitionFxChange(); |
|
1080 break; |
|
1081 case EAknsSrvSPAnimBackground: |
|
1082 iObserver->NotifyAnimBackgroundChange(); |
|
1083 break; |
|
1084 default: |
|
1085 break; |
|
1086 }; |
|
1087 } |
|
1088 |
|
1089 // ----------------------------------------------------------------------------- |
|
1090 // Default skin ID is read-only -> just read and cache. |
|
1091 // ----------------------------------------------------------------------------- |
|
1092 // |
|
1093 void CAknsSrvSettings::ReadDefaultSkinID() |
|
1094 { |
|
1095 // If value has already been read, ignore call. |
|
1096 if ( iDefaultSkinPID != KAknsNullPkgID ) |
|
1097 { |
|
1098 return; |
|
1099 } |
|
1100 |
|
1101 // Inquire the default theme UID/PID from CenRep. |
|
1102 TInt value = KErrNone; |
|
1103 TBuf<32> buf; |
|
1104 TInt err = iSkinsRepository->Get( KPslnDefaultSkinUID, buf ); |
|
1105 // Error case or zero value -> check the old key. |
|
1106 if ( err || !buf.CompareF( KAknSkinSrvNoDefaultThemeConfigured ) ) |
|
1107 { |
|
1108 err = iSkinsRepository->Get( KPslnDefaultSkinID, value ); |
|
1109 // Error case or zero value -> use platform default. |
|
1110 if ( err || !value ) |
|
1111 { |
|
1112 iDefaultSkinPID = KAknsPIDS60DefaultSkin; |
|
1113 } |
|
1114 else |
|
1115 { |
|
1116 iDefaultSkinPID.Set( TUid::Uid( value ) ); |
|
1117 } |
|
1118 } |
|
1119 else |
|
1120 { |
|
1121 TInt bufLength = buf.Length(); |
|
1122 // If its 8 characters long, its UID. |
|
1123 // PIDs are 16 characters (8 ID + 8 timestamp) |
|
1124 if ( bufLength == KAknsSkinSrvUIDLength ) |
|
1125 { |
|
1126 // Let's try to set it directly as Hex. |
|
1127 TLex hexLex( buf ); |
|
1128 TUint pid; |
|
1129 err = hexLex.Val( pid, EHex ); |
|
1130 if (!err) |
|
1131 { |
|
1132 // UIDs have no timestamp. |
|
1133 iDefaultSkinPID.Set( 0, pid ); |
|
1134 } |
|
1135 } |
|
1136 else |
|
1137 { |
|
1138 // The skin PID is set in CenRep in format <PID1><PID2> and |
|
1139 // values are in hex. |
|
1140 TLex lex ( buf.Left( KAknsSkinSrvUIDLength ) ); |
|
1141 TLex lex2 ( buf.Right( KAknsSkinSrvUIDLength ) ); |
|
1142 TUint pid; |
|
1143 TUint timeStamp; |
|
1144 err = lex.Val( pid, EHex ); |
|
1145 if ( !err ) |
|
1146 { |
|
1147 err = lex2.Val( timeStamp, EHex ); |
|
1148 } |
|
1149 if ( !err ) |
|
1150 { |
|
1151 iDefaultSkinPID.Set( timeStamp, pid ); |
|
1152 } |
|
1153 } |
|
1154 } |
|
1155 if ( err != KErrNone ) |
|
1156 { |
|
1157 iDefaultSkinPID = KAknsPIDS60DefaultSkin; |
|
1158 } |
|
1159 } |
|
1160 |
|
1161 // ----------------------------------------------------------------------------- |
|
1162 // Called when device is idle. |
|
1163 // ----------------------------------------------------------------------------- |
|
1164 // |
|
1165 TInt CAknsSrvSettings::DoHandleIdleTimeL( TAny* aAny ) |
|
1166 { |
|
1167 static_cast< CAknsSrvSettings* >( aAny )->HandleIdleTime(); |
|
1168 return KErrNone; |
|
1169 } |
|
1170 |
|
1171 // ----------------------------------------------------------------------------- |
|
1172 // Handle the idle object activation. |
|
1173 // If wallpaper has been changed when screensaver has been active, |
|
1174 // and screensaver is now off, change wallpaper now. |
|
1175 // ----------------------------------------------------------------------------- |
|
1176 // |
|
1177 void CAknsSrvSettings::HandleIdleTime() |
|
1178 { |
|
1179 if ( iIdleTime ) |
|
1180 { |
|
1181 iIdleTime->Cancel(); |
|
1182 delete iIdleTime; |
|
1183 } |
|
1184 iIdleTime = NULL; |
|
1185 if ( iDelayedNotification ) |
|
1186 { |
|
1187 iObserver->NotifyScreenSaverChange(); |
|
1188 } |
|
1189 iDelayedNotification = EFalse; |
|
1190 } |
|
1191 |
|
1192 // End of File |