|
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 the License "Symbian Foundation License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Background manager. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "xnbackgroundmanager.h" |
|
21 #include "hspswrapper.h" |
|
22 #include "xnviewmanager.h" |
|
23 #include "xnviewdata.h" |
|
24 #include "xnplugindefs.h" |
|
25 #include "hspssapi.h" |
|
26 #include "xnappuiadapter.h" |
|
27 #include "xnwallpaperview.h" |
|
28 #include "xnrootdata.h" |
|
29 |
|
30 // SYSTEM INCLUDE FILES |
|
31 #include <aknlistquerydialog.h> |
|
32 #include <xnuiengine.rsg> |
|
33 #include <aknskinsinternalcrkeys.h> |
|
34 #include <activeidle2domaincrkeys.h> |
|
35 #include <aknswallpaperutils.h> |
|
36 #include <imageconversion.h> |
|
37 #include <bitmaptransforms.h> |
|
38 |
|
39 #include <aknsutils.h> |
|
40 #include <aknsdrawutils.h> |
|
41 #include <aknscontrolcontext.h> |
|
42 #include <aknslayeredbackgroundcontrolcontext.h> |
|
43 #include <driveinfo.h> |
|
44 |
|
45 using namespace hspswrapper; |
|
46 |
|
47 _LIT8( KSingle, "single" ); |
|
48 const TUid KDummyUid = { 0x0000000 }; |
|
49 |
|
50 // ============================ MEMBER FUNCTIONS =============================== |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // C++ default constructor. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CXnBackgroundManager::CXnBackgroundManager( CXnViewManager& aViewManager, CHspsWrapper& aWrapper ) |
|
57 : iViewManager( aViewManager ), |
|
58 iHspsWrapper( aWrapper ), |
|
59 iTransparencyEnabled( ETrue ) |
|
60 { |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // Symbian 2nd phase constructor. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 void CXnBackgroundManager::ConstructL() |
|
68 { |
|
69 // Register for view activation & deactivation |
|
70 iViewManager.AppUiAdapter().AddViewActivationObserverL( this ); |
|
71 |
|
72 CreateWindowL(); |
|
73 |
|
74 iBgContext = CAknsLayeredBackgroundControlContext::NewL( |
|
75 KAknsIIDQsnBgScreenIdle, TRect(), ETrue, 1 ); |
|
76 |
|
77 TRect bgRect; |
|
78 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, bgRect ); |
|
79 SetRect( bgRect ); |
|
80 |
|
81 Window().SetOrdinalPosition( -1 ); |
|
82 |
|
83 MakeVisible( ETrue ); |
|
84 ActivateL(); |
|
85 iIntUpdate = 0; |
|
86 User::LeaveIfError( iSkinSrv.Connect( this ) ); |
|
87 iSkinSrv.EnableSkinChangeNotify(); |
|
88 |
|
89 // Start listening for drive events. |
|
90 User::LeaveIfError( iFsSession.Connect() ); |
|
91 |
|
92 // Start listening file server notifications. |
|
93 iDiskNotifier = CDiskNotifyHandler::NewL( *this, iFsSession ); |
|
94 User::LeaveIfError( iDiskNotifier->NotifyDisk() ); |
|
95 |
|
96 // Reads from cenrep wheteher page specific wallpaper is enabled or not |
|
97 CheckFeatureTypeL(); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // Two-phased constructor. |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 CXnBackgroundManager* CXnBackgroundManager::NewL( CXnViewManager& aViewManager, |
|
105 CHspsWrapper& aWrapper ) |
|
106 { |
|
107 CXnBackgroundManager* self = new (ELeave) CXnBackgroundManager( aViewManager, |
|
108 aWrapper ); |
|
109 CleanupStack::PushL( self ); |
|
110 self->ConstructL(); |
|
111 CleanupStack::Pop( self ); |
|
112 return self; |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // Destructor. |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 CXnBackgroundManager::~CXnBackgroundManager() |
|
120 { |
|
121 CleanCache(); |
|
122 iSkinSrv.Close(); |
|
123 delete iDiskNotifier; |
|
124 iFsSession.Close(); |
|
125 delete iBgContext; |
|
126 delete iBgImage; |
|
127 delete iBgImagePath; |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CXnBackgroundManager::Draw |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CXnBackgroundManager::Draw(const TRect& aRect) const |
|
135 { |
|
136 if( iTransparencyEnabled ) |
|
137 { |
|
138 if( iFeatureSuppoted ) |
|
139 { |
|
140 CXnViewData& viewData( iViewManager.ActiveViewData() ); |
|
141 CFbsBitmap* wallpaper = viewData.WallpaperImage(); |
|
142 if( wallpaper ) |
|
143 { |
|
144 SystemGc().BitBlt( TPoint(0, 0), wallpaper ); |
|
145 return; |
|
146 } |
|
147 } |
|
148 else if( iBgImage ) |
|
149 { |
|
150 SystemGc().BitBlt( TPoint(0, 0), iBgImage ); |
|
151 return; |
|
152 } |
|
153 } |
|
154 MAknsSkinInstance* skin( AknsUtils::SkinInstance() ); |
|
155 AknsDrawUtils::Background( skin, iBgContext, this, |
|
156 SystemGc(), aRect ); |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CXnBackgroundManager::SizeChanged |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 void CXnBackgroundManager::SizeChanged() |
|
164 { |
|
165 iRect = Rect(); |
|
166 if( iFeatureSuppoted ) |
|
167 { |
|
168 TRAP_IGNORE( UpdateWallpapersL() ); |
|
169 } |
|
170 else |
|
171 { |
|
172 if( iBgImagePath ) |
|
173 { |
|
174 delete iBgImage; |
|
175 iBgImage = NULL; |
|
176 TRAP_IGNORE( iBgImage = iSkinSrv.WallpaperImageL( *iBgImagePath ) ); |
|
177 } |
|
178 } |
|
179 iBgContext->SetRect( iRect ); |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // Handle disk drive notifications. |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 void CXnBackgroundManager::HandleNotifyDisk( |
|
187 TInt /*aError*/, |
|
188 const TDiskEvent& aEvent ) |
|
189 { |
|
190 if( aEvent.iType == MDiskNotifyHandlerCallback::EDiskStatusChanged ) |
|
191 { |
|
192 if( !( aEvent.iInfo.iDriveAtt & KDriveAttInternal ) ) |
|
193 { |
|
194 TBool diskRemoved( aEvent.iInfo.iType == EMediaNotPresent ); |
|
195 if( diskRemoved ) |
|
196 { |
|
197 // TODO: |
|
198 //TRAP_IGNORE( RemovableDiskRemovedL() ); |
|
199 } |
|
200 else |
|
201 { |
|
202 TRAP_IGNORE( RemovableDiskInsertedL() ); |
|
203 } |
|
204 } |
|
205 } |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CXnBackgroundManager::CacheWallpaperL |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 TInt CXnBackgroundManager::CacheWallpaperL( const TDesC& aFileName, CXnViewData& aViewData ) |
|
213 { |
|
214 if( aFileName == KNullDesC ) |
|
215 { |
|
216 return KErrArgument; |
|
217 } |
|
218 |
|
219 aViewData.SetWallpaperImagePathL( aFileName ); |
|
220 aViewData.SetWallpaperImage( NULL ); |
|
221 |
|
222 TBool err( KErrNone ); |
|
223 TRAP( err, iSkinSrv.AddWallpaperL( aFileName, iRect.Size() ) ); |
|
224 if( err == KErrNone ) |
|
225 { |
|
226 CFbsBitmap* bitmap( NULL ); |
|
227 CleanupStack::PushL( bitmap ); |
|
228 TRAP( err, bitmap = iSkinSrv.WallpaperImageL( aFileName ) ); |
|
229 if( err == KErrNone && bitmap ) |
|
230 { |
|
231 aViewData.SetWallpaperImage( bitmap ); // Ownership tranferred |
|
232 } |
|
233 else |
|
234 { |
|
235 iSkinSrv.RemoveWallpaper( aFileName ); |
|
236 } |
|
237 CleanupStack::Pop(); |
|
238 } |
|
239 return err; |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // CXnBackgroundManager::AddWallpaperL |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 void CXnBackgroundManager::AddWallpaperL( const TDesC& aFileName ) |
|
247 { |
|
248 if( iFeatureSuppoted ) |
|
249 { |
|
250 AddPageSpecificWallpaperL( aFileName ); |
|
251 } |
|
252 else |
|
253 { |
|
254 AddCommonWallpaperL( aFileName ); |
|
255 } |
|
256 } |
|
257 |
|
258 // --------------------------------------------------------------------------- |
|
259 // CXnBackgroundManager::ActivatedL |
|
260 // --------------------------------------------------------------------------- |
|
261 // |
|
262 TBool CXnBackgroundManager::ActivatedL() |
|
263 { |
|
264 return iFeatureSuppoted; |
|
265 } |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // CXnBackgroundManager::WallpaperChanged |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 void CXnBackgroundManager::WallpaperChanged( CXnViewData& aOldView, CXnViewData& aNewView ) |
|
272 { |
|
273 if( iFeatureSuppoted && |
|
274 aOldView.WallpaperImagePath().Compare( aNewView.WallpaperImagePath() ) ) |
|
275 { |
|
276 DrawNow(); |
|
277 TInt err = AknsWallpaperUtils::SetIdleWallpaper( aNewView.WallpaperImagePath(), NULL ); |
|
278 if( err == KErrNone ) |
|
279 { |
|
280 iIntUpdate++; |
|
281 } |
|
282 } |
|
283 } |
|
284 |
|
285 // --------------------------------------------------------------------------- |
|
286 // CXnBackgroundManager::SaveWallpaperL |
|
287 // --------------------------------------------------------------------------- |
|
288 // |
|
289 void CXnBackgroundManager::SaveWallpaperL() |
|
290 { |
|
291 // Save wallpaper to HSPS |
|
292 if( iFeatureSuppoted ) |
|
293 { |
|
294 TBuf8<KMaxFileName> wallpaper8; |
|
295 CXnViewData& viewData( iViewManager.ActiveViewData() ); |
|
296 wallpaper8.Copy( viewData.WallpaperImagePath() ); |
|
297 SetSettingPropertyL( viewData.PluginId(), KWallpaper, |
|
298 KPath, wallpaper8 ); |
|
299 } |
|
300 else |
|
301 { |
|
302 CRepository* repository = CRepository::NewLC( TUid::Uid( KCRUidActiveIdleLV ) ); |
|
303 if ( repository ) |
|
304 { |
|
305 if( iBgImagePath ) |
|
306 { |
|
307 User::LeaveIfError( repository->Set( KAIWallpaperPath, |
|
308 *iBgImagePath ) ); |
|
309 } |
|
310 else |
|
311 { |
|
312 User::LeaveIfError( repository->Set( KAIWallpaperPath, |
|
313 KNullDesC ) ); |
|
314 } |
|
315 } |
|
316 CleanupStack::PopAndDestroy( repository ); |
|
317 } |
|
318 } |
|
319 |
|
320 // --------------------------------------------------------------------------- |
|
321 // CXnBackgroundManager::SetSettingPropertyL |
|
322 // --------------------------------------------------------------------------- |
|
323 // |
|
324 TInt CXnBackgroundManager::SetSettingPropertyL( const TDesC8& aPluginId, |
|
325 const TDesC8& aItemId, const TDesC8& aPropertyName, |
|
326 const TDesC8& aPropertyValue ) |
|
327 { |
|
328 if ( aPluginId == KNullDesC8() || |
|
329 aItemId == KNullDesC8() || |
|
330 aPropertyName == KNullDesC8() ) |
|
331 { |
|
332 return KErrArgument; |
|
333 } |
|
334 |
|
335 CHspsConfiguration* pluginConf( |
|
336 iHspsWrapper.GetPluginConfigurationL( aPluginId ) ); |
|
337 if ( !pluginConf ) |
|
338 { |
|
339 return KErrNotFound; |
|
340 } |
|
341 CleanupStack::PushL( pluginConf ); |
|
342 |
|
343 // Find. |
|
344 CPropertyMap* property = NULL; |
|
345 RPointerArray<CItemMap>& settings = pluginConf->Settings(); |
|
346 for( TInt i = 0; i < settings.Count(); i++ ) |
|
347 { |
|
348 CItemMap* setting = settings[i]; |
|
349 if ( !setting ) |
|
350 { |
|
351 continue; |
|
352 } |
|
353 |
|
354 if ( setting->ItemId() == aItemId ) |
|
355 { |
|
356 RPointerArray<CPropertyMap>& properties = setting->Properties(); |
|
357 for( TInt j = 0; j < properties.Count(); j++ ) |
|
358 { |
|
359 CPropertyMap* tmpProperty = properties[j]; |
|
360 if ( !tmpProperty ) |
|
361 { |
|
362 continue; |
|
363 } |
|
364 |
|
365 if ( tmpProperty->Name() == aPropertyName ) |
|
366 { |
|
367 property = tmpProperty; |
|
368 break; |
|
369 } |
|
370 } |
|
371 break; |
|
372 } |
|
373 } |
|
374 |
|
375 TInt ret = KErrNone; |
|
376 |
|
377 // Set. |
|
378 if ( property ) |
|
379 { |
|
380 property->SetValueL( aPropertyValue ); |
|
381 ret = iHspsWrapper.SetPluginSettingsL( aPluginId, settings ); |
|
382 } |
|
383 else |
|
384 { |
|
385 ret = KErrNotFound; |
|
386 } |
|
387 |
|
388 CleanupStack::PopAndDestroy( pluginConf ); |
|
389 |
|
390 return ret; |
|
391 } |
|
392 |
|
393 // --------------------------------------------------------------------------- |
|
394 // CXnBackgroundManager::SetWallpaperL |
|
395 // --------------------------------------------------------------------------- |
|
396 // |
|
397 void CXnBackgroundManager::SetWallpaperL() |
|
398 { |
|
399 TInt selectedIndex( 0 ); |
|
400 |
|
401 CAknListQueryDialog* query = |
|
402 new ( ELeave ) CAknListQueryDialog( &selectedIndex ); |
|
403 CleanupStack::PushL( query ); |
|
404 query->PrepareLC( R_LISTQUERY_CHANGE_WALLPAPER ); |
|
405 |
|
406 if ( query->RunLD() ) |
|
407 { |
|
408 if ( selectedIndex == 0 ) |
|
409 { |
|
410 AddWallpaperL( KNullDesC ); |
|
411 } |
|
412 else if ( selectedIndex == 1 ) |
|
413 { |
|
414 iViewManager.AppUiAdapter().ActivateLocalViewL( KWallpaperViewUid, |
|
415 KDummyUid, KSingle ); |
|
416 } |
|
417 } |
|
418 CleanupStack::Pop( query ); |
|
419 } |
|
420 |
|
421 // --------------------------------------------------------------------------- |
|
422 // CXnBackgroundManager::SkinContentChanged |
|
423 // --------------------------------------------------------------------------- |
|
424 // |
|
425 void CXnBackgroundManager::SkinContentChanged() |
|
426 { |
|
427 } |
|
428 |
|
429 // --------------------------------------------------------------------------- |
|
430 // CXnBackgroundManager::SkinConfigurationChanged |
|
431 // --------------------------------------------------------------------------- |
|
432 // |
|
433 void CXnBackgroundManager::SkinConfigurationChanged( |
|
434 const TAknsSkinStatusConfigurationChangeReason aReason ) |
|
435 { |
|
436 if ( aReason == EAknsSkinStatusWallpaperChanged ) |
|
437 { |
|
438 if( iIntUpdate > 0 ) |
|
439 { |
|
440 iIntUpdate--; |
|
441 } |
|
442 else |
|
443 { |
|
444 TRAP_IGNORE( ReadWallpaperFromCenrepL() ); |
|
445 } |
|
446 } |
|
447 else if ( aReason == EAknsSkinStatusConfigurationDeployed ) |
|
448 { |
|
449 DrawNow(); |
|
450 } |
|
451 } |
|
452 |
|
453 // --------------------------------------------------------------------------- |
|
454 // CXnBackgroundManager::SkinPackageChanged |
|
455 // --------------------------------------------------------------------------- |
|
456 // |
|
457 void CXnBackgroundManager::SkinPackageChanged( |
|
458 const TAknsSkinStatusPackageChangeReason /*aReason*/ ) |
|
459 { |
|
460 } |
|
461 |
|
462 // ---------------------------------------------------------------------------- |
|
463 // CXnBackgroundManager::HandleViewActivation() |
|
464 // ---------------------------------------------------------------------------- |
|
465 // |
|
466 void CXnBackgroundManager::HandleViewActivation( |
|
467 const TVwsViewId& aNewlyActivatedViewId, |
|
468 const TVwsViewId& aViewIdToBeDeactivated ) |
|
469 { |
|
470 TVwsViewId viewId( iViewManager.AppUiAdapter().View().ViewId() ); |
|
471 if ( viewId == aNewlyActivatedViewId && !iTransparencyEnabled ) |
|
472 { |
|
473 iTransparencyEnabled = ETrue; |
|
474 DrawNow(); |
|
475 } |
|
476 else if ( viewId == aViewIdToBeDeactivated && iTransparencyEnabled ) |
|
477 { |
|
478 iTransparencyEnabled = EFalse; |
|
479 DrawNow(); |
|
480 } |
|
481 } |
|
482 |
|
483 // ----------------------------------------------------------------------------- |
|
484 // CXnBackgroundManager::CleanCache |
|
485 // ----------------------------------------------------------------------------- |
|
486 // |
|
487 void CXnBackgroundManager::CleanCache() |
|
488 { |
|
489 iSkinSrv.RemoveAllWallpapers(); |
|
490 } |
|
491 |
|
492 // ----------------------------------------------------------------------------- |
|
493 // CXnBackgroundManager::RemoveWallpaper |
|
494 // ----------------------------------------------------------------------------- |
|
495 // |
|
496 void CXnBackgroundManager::RemoveWallpaperFromCache( const TDesC& aFileName ) |
|
497 { |
|
498 CXnViewData& activeViewData( iViewManager.ActiveViewData() ); |
|
499 CXnRootData& rootData = iViewManager.ActiveAppData(); |
|
500 RPointerArray<CXnPluginData>& rootDataArr = rootData.PluginData(); |
|
501 |
|
502 for( TInt i = 0; i < rootDataArr.Count(); i++ ) |
|
503 { |
|
504 CXnViewData* viewData = static_cast<CXnViewData*>( rootDataArr[i] ); |
|
505 if( viewData == &activeViewData ) |
|
506 { |
|
507 continue; |
|
508 } |
|
509 else if( viewData->WallpaperImagePath() == aFileName ) |
|
510 { |
|
511 // Some other view has same wallpaper image. |
|
512 // This must not be removed from the cache. |
|
513 return; |
|
514 } |
|
515 } |
|
516 // Image is not needed anymore. Can be removed from the cache. |
|
517 iSkinSrv.RemoveWallpaper( aFileName ); |
|
518 } |
|
519 |
|
520 // ----------------------------------------------------------------------------- |
|
521 // CXnBackgroundManager::RemoveWallpaper |
|
522 // ----------------------------------------------------------------------------- |
|
523 // |
|
524 void CXnBackgroundManager::RemoveWallpaperL( CXnViewData& aViewData ) |
|
525 { |
|
526 aViewData.SetWallpaperImagePathL( KNullDesC ); |
|
527 aViewData.SetWallpaperImage( NULL ); |
|
528 SetSettingPropertyL( aViewData.PluginId(), KWallpaper, KPath, KNullDesC8 ); |
|
529 } |
|
530 |
|
531 // ----------------------------------------------------------------------------- |
|
532 // CXnBackgroundManager::UpdateWallpapersL |
|
533 // ----------------------------------------------------------------------------- |
|
534 // |
|
535 void CXnBackgroundManager::UpdateWallpapersL() |
|
536 { |
|
537 CXnRootData& rootData = iViewManager.ActiveAppData(); |
|
538 if( !&rootData ) |
|
539 { |
|
540 return; |
|
541 } |
|
542 RPointerArray<CXnPluginData>& rootDataArr = rootData.PluginData(); |
|
543 |
|
544 for( TInt i = 0; i < rootDataArr.Count(); i++ ) |
|
545 { |
|
546 CXnViewData* viewData = static_cast<CXnViewData*>( rootDataArr[i] ); |
|
547 const TDesC& path = viewData->WallpaperImagePath(); |
|
548 if( path != KNullDesC ) |
|
549 { |
|
550 CFbsBitmap* bitmap = iSkinSrv.WallpaperImageL( path ); |
|
551 if( bitmap ) |
|
552 { |
|
553 viewData->SetWallpaperImage( bitmap ); |
|
554 } |
|
555 } |
|
556 } |
|
557 } |
|
558 |
|
559 // ----------------------------------------------------------------------------- |
|
560 // CXnBackgroundManager::RemovableDiskInsertedL |
|
561 // ----------------------------------------------------------------------------- |
|
562 // |
|
563 void CXnBackgroundManager::RemovableDiskInsertedL() |
|
564 { |
|
565 if( iFeatureSuppoted ) |
|
566 { |
|
567 CXnRootData& rootData = iViewManager.ActiveAppData(); |
|
568 if( !&rootData ) |
|
569 { |
|
570 return; |
|
571 } |
|
572 RPointerArray<CXnPluginData>& rootDataArr = rootData.PluginData(); |
|
573 TInt drawingNeeded( EFalse ); |
|
574 for( TInt i = 0; i < rootDataArr.Count(); i++ ) |
|
575 { |
|
576 CXnViewData* viewData = static_cast<CXnViewData*>( rootDataArr[i] ); |
|
577 const TDesC& path = viewData->WallpaperImagePath(); |
|
578 CFbsBitmap* bitmap = viewData->WallpaperImage(); |
|
579 if( path != KNullDesC && !bitmap ) |
|
580 { |
|
581 TInt err = CacheWallpaperL( path, *viewData ); |
|
582 if( err == KErrNone ) |
|
583 { |
|
584 drawingNeeded = ETrue; |
|
585 } |
|
586 } |
|
587 } |
|
588 if( drawingNeeded ) |
|
589 { |
|
590 DrawNow(); |
|
591 } |
|
592 } |
|
593 else |
|
594 { |
|
595 if( iBgImagePath ) |
|
596 { |
|
597 AddCommonWallpaperL( *iBgImagePath, EFalse ); |
|
598 } |
|
599 } |
|
600 } |
|
601 |
|
602 // --------------------------------------------------------------------------- |
|
603 // CXnBackgroundManager::CheckFeatureTypeL |
|
604 // --------------------------------------------------------------------------- |
|
605 // |
|
606 void CXnBackgroundManager::CheckFeatureTypeL() |
|
607 { |
|
608 iFeatureSuppoted = EFalse; |
|
609 CRepository* repository = CRepository::NewL( TUid::Uid( KCRUidActiveIdleLV ) ); |
|
610 CleanupStack::PushL( repository ); |
|
611 if ( repository ) |
|
612 { |
|
613 // Get wallpaper handling type from cenrep |
|
614 TInt type; |
|
615 TInt err = repository->Get( KAIWallpaperChangeType, type ); |
|
616 if ( err == KErrNone && type == 1) |
|
617 { |
|
618 iFeatureSuppoted = ETrue; |
|
619 } |
|
620 else |
|
621 { |
|
622 TFileName path; |
|
623 err = repository->Get( KAIWallpaperPath, path ); |
|
624 if ( !err && path.Length()) |
|
625 { |
|
626 AddCommonWallpaperL( path, EFalse ); |
|
627 } |
|
628 } |
|
629 } |
|
630 CleanupStack::PopAndDestroy( repository ); |
|
631 } |
|
632 |
|
633 // --------------------------------------------------------------------------- |
|
634 // CXnBackgroundManager::AddPageSpecificWallpaperL |
|
635 // --------------------------------------------------------------------------- |
|
636 // |
|
637 void CXnBackgroundManager::AddPageSpecificWallpaperL( const TDesC& aFileName ) |
|
638 { |
|
639 CXnViewData& viewData( iViewManager.ActiveViewData() ); |
|
640 const TDesC& old = viewData.WallpaperImagePath(); |
|
641 |
|
642 if( aFileName.Compare( old ) ) |
|
643 { |
|
644 // Remove old from the cache |
|
645 if( old != KNullDesC ) |
|
646 { |
|
647 RemoveWallpaperFromCache( old ); |
|
648 } |
|
649 |
|
650 // Add new to the cache |
|
651 if( aFileName != KNullDesC ) |
|
652 { |
|
653 if( CacheWallpaperL( aFileName, viewData ) == KErrNone ) |
|
654 { |
|
655 SaveWallpaperL(); // to HSPS |
|
656 } |
|
657 else |
|
658 { |
|
659 return; |
|
660 } |
|
661 } |
|
662 |
|
663 // WallpaperImage changed back to default. Update view data. |
|
664 else |
|
665 { |
|
666 viewData.SetWallpaperImagePathL( KNullDesC ); |
|
667 viewData.SetWallpaperImage( NULL ); |
|
668 } |
|
669 |
|
670 // Update screen |
|
671 DrawNow(); |
|
672 |
|
673 TInt err = AknsWallpaperUtils::SetIdleWallpaper( aFileName, NULL ); |
|
674 if( err == KErrNone ) |
|
675 { |
|
676 iIntUpdate++; |
|
677 } |
|
678 } |
|
679 } |
|
680 |
|
681 // --------------------------------------------------------------------------- |
|
682 // CXnBackgroundManager::AddCommonWallpaperL |
|
683 // --------------------------------------------------------------------------- |
|
684 // |
|
685 void CXnBackgroundManager::AddCommonWallpaperL( const TDesC& aFileName, |
|
686 TBool aSave ) |
|
687 { |
|
688 // Remove old from the cache |
|
689 if( iBgImagePath ) |
|
690 { |
|
691 iSkinSrv.RemoveWallpaper( aFileName ); |
|
692 delete iBgImagePath; |
|
693 iBgImagePath = NULL; |
|
694 } |
|
695 delete iBgImage; |
|
696 iBgImage = NULL; |
|
697 |
|
698 if( aFileName != KNullDesC ) |
|
699 { |
|
700 iBgImagePath = aFileName.AllocL(); |
|
701 |
|
702 TBool err( KErrNone ); |
|
703 TRAP( err, iSkinSrv.AddWallpaperL( aFileName, iRect.Size() ) ); |
|
704 if( err ) |
|
705 { |
|
706 return; |
|
707 } |
|
708 TRAP( err, iBgImage = iSkinSrv.WallpaperImageL( aFileName ) ); |
|
709 if( err ) |
|
710 { |
|
711 iSkinSrv.RemoveWallpaper( aFileName ); |
|
712 delete iBgImage; |
|
713 iBgImage = NULL; |
|
714 return; |
|
715 } |
|
716 } |
|
717 |
|
718 // Update screen |
|
719 DrawNow(); |
|
720 |
|
721 // Save path to cenrep |
|
722 if( aSave ) |
|
723 { |
|
724 SaveWallpaperL(); |
|
725 } |
|
726 |
|
727 TInt err = AknsWallpaperUtils::SetIdleWallpaper( aFileName, NULL ); |
|
728 if( !err ) |
|
729 { |
|
730 iIntUpdate++; |
|
731 } |
|
732 } |
|
733 |
|
734 // --------------------------------------------------------------------------- |
|
735 // CXnBackgroundManager::ReadWallpaperFromCenrepL |
|
736 // --------------------------------------------------------------------------- |
|
737 // |
|
738 void CXnBackgroundManager::ReadWallpaperFromCenrepL() |
|
739 { |
|
740 CRepository* repository = CRepository::NewLC( KCRUidPersonalisation ); |
|
741 if ( repository ) |
|
742 { |
|
743 // Get wallpaper type from cenrep |
|
744 TInt wallpaperType; |
|
745 TInt err = repository->Get( KPslnWallpaperType, wallpaperType ); |
|
746 if ( err == KErrNone ) |
|
747 { |
|
748 if ( wallpaperType == 0 ) |
|
749 { |
|
750 if( iFeatureSuppoted ) |
|
751 { |
|
752 CXnViewData& viewData( iViewManager.ActiveViewData() ); |
|
753 RemoveWallpaperFromCache( viewData.WallpaperImagePath() ); |
|
754 RemoveWallpaperL( viewData ); |
|
755 } |
|
756 else |
|
757 { |
|
758 if( iBgImagePath ) |
|
759 { |
|
760 iSkinSrv.RemoveWallpaper( *iBgImagePath ); |
|
761 delete iBgImagePath; |
|
762 iBgImagePath = NULL; |
|
763 } |
|
764 delete iBgImage; |
|
765 iBgImage = NULL; |
|
766 SaveWallpaperL(); |
|
767 } |
|
768 } |
|
769 else if ( wallpaperType == 1 ) |
|
770 { |
|
771 // WallpaperImage is image |
|
772 // Get wallpaper image path from cenrep and save it |
|
773 TFileName wallpaper; |
|
774 err = repository->Get( KPslnIdleBackgroundImagePath, wallpaper ); |
|
775 if ( err == KErrNone ) |
|
776 { |
|
777 if( iFeatureSuppoted ) |
|
778 { |
|
779 AddPageSpecificWallpaperL( wallpaper ); |
|
780 } |
|
781 else |
|
782 { |
|
783 AddCommonWallpaperL( wallpaper, EFalse ); |
|
784 } |
|
785 } |
|
786 } |
|
787 DrawNow(); |
|
788 } |
|
789 |
|
790 CleanupStack::PopAndDestroy( repository ); |
|
791 } |
|
792 } |
|
793 |
|
794 // End of File |