|
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: 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 #include "xnuiengine.h" |
|
30 #include "xnoomsyshandler.h" |
|
31 #include "xneffectmanager.h" |
|
32 |
|
33 // SYSTEM INCLUDE FILES |
|
34 #include <gfxtranseffect/gfxtranseffect.h> |
|
35 #include <akntransitionutils.h> |
|
36 #include <aknlistquerydialog.h> |
|
37 #include <xnuiengine.rsg> |
|
38 #include <xnwallpaperview.rsg> |
|
39 #include <AknSkinsInternalCRKeys.h> |
|
40 #include <activeidle2domaincrkeys.h> |
|
41 #include <AknsWallpaperUtils.h> |
|
42 #include <imageconversion.h> |
|
43 #include <bitmaptransforms.h> |
|
44 #include <StringLoader.h> |
|
45 #include <aknnotewrappers.h> |
|
46 #include <bautils.h> |
|
47 #include <utf.h> |
|
48 |
|
49 #include <AknsUtils.h> |
|
50 #include <AknsDrawUtils.h> |
|
51 #include <AknsControlContext.h> |
|
52 #include <AknsLayeredBackgroundControlContext.h> |
|
53 #include <driveinfo.h> |
|
54 #include <layoutmetadata.cdl.h> |
|
55 |
|
56 using namespace hspswrapper; |
|
57 |
|
58 // Constants |
|
59 _LIT8( KSingle, "single" ); |
|
60 const TUid KDummyUid = { 0x0000000 }; |
|
61 const TInt KSkinGfxInnerRectShrink( 5 ); |
|
62 |
|
63 // ============================= LOCAL FUNCTIONS =============================== |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // ShowInfoNoteL |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void ShowInfoNoteL( TInt aResourceId ) |
|
70 { |
|
71 HBufC* msg( StringLoader::LoadLC( aResourceId ) ); |
|
72 |
|
73 CAknInformationNote* note = new ( ELeave ) CAknInformationNote; |
|
74 note->ExecuteLD( *msg ); |
|
75 |
|
76 CleanupStack::PopAndDestroy( msg ); |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // HandleErrorL |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 void HandleErrorL( TInt aErr ) |
|
84 { |
|
85 TInt resourceId( NULL ); |
|
86 if ( aErr == KErrTooBig || aErr == KErrNoMemory ) |
|
87 { |
|
88 resourceId = R_QTN_HS_TOO_BIG_IMAGE_NOTE; |
|
89 } |
|
90 else if ( aErr == KErrCancel || aErr == KErrCouldNotConnect || |
|
91 aErr == KErrCANoRights ) |
|
92 { |
|
93 // Ignore these |
|
94 } |
|
95 else if ( aErr != KErrNone ) |
|
96 { |
|
97 resourceId = R_QTN_HS_CORRUPTED_IMAGE_NOTE; |
|
98 } |
|
99 |
|
100 if( resourceId ) |
|
101 { |
|
102 ShowInfoNoteL( resourceId ); |
|
103 } |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CreateBitmapFromColorL |
|
108 // Creates a bitmap object with the given size and fill color |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 static CFbsBitmap* CreateBitmapFromColorL( TSize aSize, TRgb aColor ) |
|
112 { |
|
113 CFbsBitmap* newBitmap = new ( ELeave ) CFbsBitmap; |
|
114 newBitmap->Create( aSize, EColor16M ); |
|
115 CleanupStack::PushL( newBitmap ); |
|
116 |
|
117 CFbsBitmapDevice* bitmapDev = CFbsBitmapDevice::NewL( newBitmap ); |
|
118 CleanupStack::PushL( bitmapDev ); |
|
119 |
|
120 CFbsBitGc* bc = NULL; |
|
121 User::LeaveIfError( bitmapDev->CreateContext( bc ) ); |
|
122 CleanupStack::PushL( bc ); |
|
123 |
|
124 bc->SetBrushColor( aColor ); |
|
125 bc->Clear(); // area is filled with the brush color |
|
126 |
|
127 CleanupStack::PopAndDestroy( bc ); |
|
128 CleanupStack::PopAndDestroy( bitmapDev ); |
|
129 CleanupStack::Pop( newBitmap ); |
|
130 return newBitmap; |
|
131 } |
|
132 |
|
133 // ============================ MEMBER FUNCTIONS =============================== |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // C++ default constructor. |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 CXnBackgroundManager::CXnBackgroundManager( CXnViewManager& aViewManager, CHspsWrapper& aWrapper ) |
|
140 : iViewManager( aViewManager ), |
|
141 iHspsWrapper( aWrapper ), |
|
142 iStoreWallpaper( ETrue ) |
|
143 { |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // Symbian 2nd phase constructor. |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 void CXnBackgroundManager::ConstructL() |
|
151 { |
|
152 // Connect to skin server. |
|
153 User::LeaveIfError( iSkinSrv.Connect( this ) ); |
|
154 |
|
155 // Start listening for drive events. |
|
156 User::LeaveIfError( iFsSession.Connect() ); |
|
157 |
|
158 CreateWindowL(); |
|
159 |
|
160 iRect = TRect(); |
|
161 iBgContext = CAknsLayeredBackgroundControlContext::NewL( |
|
162 KAknsIIDQsnBgScreenIdle, iRect, ETrue, 1 ); |
|
163 |
|
164 TRect bgRect; |
|
165 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, bgRect ); |
|
166 SetRect( bgRect ); |
|
167 |
|
168 Window().SetOrdinalPosition( -1 ); |
|
169 |
|
170 MakeVisible( ETrue ); |
|
171 ActivateL(); |
|
172 iIntUpdate = 0; |
|
173 |
|
174 // Start listening file server notifications. |
|
175 iDiskNotifier = CDiskNotifyHandler::NewL( *this, iFsSession ); |
|
176 User::LeaveIfError( iDiskNotifier->NotifyDisk() ); |
|
177 |
|
178 // Reads from cenrep wheteher page specific wallpaper is enabled or not |
|
179 CheckFeatureTypeL(); |
|
180 |
|
181 GfxTransEffect::Register( this, KGfxContextBgAppear ); |
|
182 } |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // Two-phased constructor. |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 CXnBackgroundManager* CXnBackgroundManager::NewL( CXnViewManager& aViewManager, |
|
189 CHspsWrapper& aWrapper ) |
|
190 { |
|
191 CXnBackgroundManager* self = new (ELeave) CXnBackgroundManager( aViewManager, |
|
192 aWrapper ); |
|
193 CleanupStack::PushL( self ); |
|
194 self->ConstructL(); |
|
195 CleanupStack::Pop( self ); |
|
196 return self; |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // Destructor. |
|
201 // ----------------------------------------------------------------------------- |
|
202 // |
|
203 CXnBackgroundManager::~CXnBackgroundManager() |
|
204 { |
|
205 if ( GfxTransEffect::IsRegistered( this) ) |
|
206 { |
|
207 GfxTransEffect::Deregister( this ); |
|
208 } |
|
209 |
|
210 iSkinSrv.RemoveAllWallpapers(); |
|
211 iSkinSrv.Close(); |
|
212 delete iDiskNotifier; |
|
213 iFsSession.Close(); |
|
214 delete iBgContext; |
|
215 delete iBgImage; |
|
216 delete iBgImagePath; |
|
217 delete iSpBitmap; |
|
218 delete iSpMask; |
|
219 } |
|
220 |
|
221 // ----------------------------------------------------------------------------- |
|
222 // CXnBackgroundManager::Draw |
|
223 // ----------------------------------------------------------------------------- |
|
224 // |
|
225 void CXnBackgroundManager::Draw(const TRect& aRect) const |
|
226 { |
|
227 CFbsBitmap* wallpaper( NULL ); |
|
228 |
|
229 if( iType == EPageSpecific ) |
|
230 { |
|
231 CXnViewData& viewData( iViewManager.ActiveViewData() ); |
|
232 wallpaper = viewData.WallpaperImage(); |
|
233 } |
|
234 else if( iType == ECommon ) |
|
235 { |
|
236 wallpaper = iBgImage; |
|
237 } |
|
238 |
|
239 // Draw bg image |
|
240 if( wallpaper ) |
|
241 { |
|
242 TSize bitmapSize = wallpaper->SizeInPixels(); |
|
243 |
|
244 // If image is smaller that screen size it needs to be centralized |
|
245 if( iRect.Height() > bitmapSize.iHeight && |
|
246 iRect.Width() > bitmapSize.iWidth ) |
|
247 { |
|
248 TInt width = bitmapSize.iWidth / 2; |
|
249 TInt height = bitmapSize.iHeight / 2; |
|
250 |
|
251 TPoint point = iRect.Center(); |
|
252 point.SetXY( point.iX - width, point.iY - height ); |
|
253 |
|
254 SystemGc().SetBrushColor( KRgbBlack ); |
|
255 SystemGc().Clear( aRect ); |
|
256 SystemGc().DrawBitmap( TRect( point, bitmapSize), wallpaper ); |
|
257 } |
|
258 else |
|
259 { |
|
260 SystemGc().DrawBitmap( iRect, wallpaper ); |
|
261 } |
|
262 |
|
263 DrawStatusPaneMask(); |
|
264 } |
|
265 |
|
266 // Skin bg is used by default |
|
267 else |
|
268 { |
|
269 MAknsSkinInstance* skin( AknsUtils::SkinInstance() ); |
|
270 AknsDrawUtils::Background( skin, iBgContext, this, SystemGc(), aRect ); |
|
271 } |
|
272 |
|
273 // Draw edit mode background highlight |
|
274 if( iViewManager.UiEngine().IsEditMode() ) |
|
275 { |
|
276 DrawEditModeBackgroundSkin(); |
|
277 } |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // CXnBackgroundManager::SizeChanged |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 void CXnBackgroundManager::SizeChanged() |
|
285 { |
|
286 iRect = Rect(); |
|
287 |
|
288 if ( iType == EPageSpecific ) |
|
289 { |
|
290 TRAP_IGNORE( UpdateWallpapersL() ); |
|
291 } |
|
292 else if ( iType == ECommon ) |
|
293 { |
|
294 if( iBgImagePath ) |
|
295 { |
|
296 delete iBgImage; |
|
297 iBgImage = NULL; |
|
298 TRAP_IGNORE( iBgImage = iSkinSrv.WallpaperImageL( *iBgImagePath ) ); |
|
299 } |
|
300 } |
|
301 |
|
302 iBgContext->SetRect( iRect ); |
|
303 |
|
304 TRAPD( err, UpdateStatuspaneMaskL() ); |
|
305 if( err ) |
|
306 { |
|
307 delete iSpBitmap; |
|
308 iSpBitmap = NULL; |
|
309 delete iSpMask; |
|
310 iSpMask = NULL; |
|
311 } |
|
312 } |
|
313 |
|
314 // ----------------------------------------------------------------------------- |
|
315 // CXnBackgroundManager::MakeVisible |
|
316 // ----------------------------------------------------------------------------- |
|
317 // |
|
318 void CXnBackgroundManager::MakeVisible( TBool aVisible ) |
|
319 { |
|
320 CCoeControl::MakeVisible( aVisible ); |
|
321 |
|
322 if ( aVisible ) |
|
323 { |
|
324 DrawNow(); |
|
325 } |
|
326 } |
|
327 |
|
328 // ----------------------------------------------------------------------------- |
|
329 // Handle disk drive notifications. |
|
330 // ----------------------------------------------------------------------------- |
|
331 // |
|
332 void CXnBackgroundManager::HandleNotifyDisk( TInt /*aError*/, |
|
333 const TDiskEvent& aEvent ) |
|
334 { |
|
335 if( aEvent.iType == MDiskNotifyHandlerCallback::EDiskStatusChanged || |
|
336 aEvent.iType == MDiskNotifyHandlerCallback::EDiskAdded || |
|
337 aEvent.iType == MDiskNotifyHandlerCallback::EDiskRemoved ) |
|
338 { |
|
339 if( !( aEvent.iInfo.iDriveAtt & KDriveAttInternal ) ) |
|
340 { |
|
341 TBool diskRemoved( aEvent.iInfo.iType == EMediaNotPresent ); |
|
342 |
|
343 if( diskRemoved ) |
|
344 { |
|
345 TRAP_IGNORE( RemovableDiskRemovedL() ); |
|
346 } |
|
347 else |
|
348 { |
|
349 TRAP_IGNORE( RemovableDiskInsertedL() ); |
|
350 } |
|
351 } |
|
352 } |
|
353 } |
|
354 |
|
355 // ----------------------------------------------------------------------------- |
|
356 // CXnBackgroundManager::ConstructWallpaper |
|
357 // ----------------------------------------------------------------------------- |
|
358 // |
|
359 TInt CXnBackgroundManager::ConstructWallpaper( const TDesC& aFileName, |
|
360 CXnViewData& aViewData ) |
|
361 { |
|
362 TRAP_IGNORE( aViewData.SetWallpaperImagePathL( aFileName ) ); |
|
363 aViewData.SetWallpaperImage( NULL ); |
|
364 |
|
365 TRAPD( err, iSkinSrv.AddWallpaperL( aFileName, iRect.Size() ) ); |
|
366 if( err == KErrNone ) |
|
367 { |
|
368 UpdateViewData( aFileName, aViewData ); |
|
369 } |
|
370 |
|
371 return err; |
|
372 } |
|
373 |
|
374 // --------------------------------------------------------------------------- |
|
375 // CXnBackgroundManager::SetWallpaperL |
|
376 // --------------------------------------------------------------------------- |
|
377 // |
|
378 void CXnBackgroundManager::SetWallpaperL() |
|
379 { |
|
380 TInt selectedIndex( 0 ); |
|
381 |
|
382 CAknListQueryDialog* query = |
|
383 new ( ELeave ) CAknListQueryDialog( &selectedIndex ); |
|
384 query->PrepareLC( R_LISTQUERY_CHANGE_WALLPAPER ); |
|
385 |
|
386 if ( !query->RunLD() ) |
|
387 { |
|
388 // Query canceled |
|
389 return; |
|
390 } |
|
391 |
|
392 CXnAppUiAdapter& appui( iViewManager.AppUiAdapter() ); |
|
393 |
|
394 if ( selectedIndex == 0 ) |
|
395 { |
|
396 // Set wallpaper to default skin |
|
397 SetWallpaper( KNullDesC ); |
|
398 |
|
399 appui.EffectManager()->BgAppearEffect( this, ETrue ); |
|
400 } |
|
401 else if ( selectedIndex == 1 ) |
|
402 { |
|
403 if ( CXnOomSysHandler::HeapAvailable( CXnOomSysHandler::EMem6MB ) ) |
|
404 { |
|
405 appui.ActivateLocalViewL( KWallpaperViewUid, KDummyUid, KSingle ); |
|
406 |
|
407 appui.EffectManager()->BeginFullscreenEffectL( KGfxContextOpenWallpaperView ); |
|
408 } |
|
409 else |
|
410 { |
|
411 // Potentially not enough memory |
|
412 iViewManager.OomSysHandler().HandlePotentialOomL(); |
|
413 } |
|
414 } |
|
415 } |
|
416 |
|
417 // --------------------------------------------------------------------------- |
|
418 // CXnBackgroundManager::SetWallpaper |
|
419 // --------------------------------------------------------------------------- |
|
420 // |
|
421 TBool CXnBackgroundManager::SetWallpaper( const TDesC& aFileName ) |
|
422 { |
|
423 TInt err( KErrNone ); |
|
424 |
|
425 if ( iType == EPageSpecific ) |
|
426 { |
|
427 TRAP( err, SetPageSpecificWallpaperL( aFileName ) ); |
|
428 } |
|
429 else if ( iType == ECommon ) |
|
430 { |
|
431 TRAP( err, SetCommonWallpaperL( aFileName ) ); |
|
432 } |
|
433 |
|
434 if( err ) |
|
435 { |
|
436 TRAP_IGNORE( HandleErrorL( err ) ); |
|
437 return EFalse; |
|
438 } |
|
439 |
|
440 return ETrue; |
|
441 } |
|
442 |
|
443 // --------------------------------------------------------------------------- |
|
444 // CXnBackgroundManager::DeleteWallpaper |
|
445 // --------------------------------------------------------------------------- |
|
446 // |
|
447 void CXnBackgroundManager::DeleteWallpaper( CXnViewData& aViewData ) |
|
448 { |
|
449 if( iType == EPageSpecific ) |
|
450 { |
|
451 const TDesC& path = aViewData.WallpaperImagePath(); |
|
452 if( path != KNullDesC ) |
|
453 { |
|
454 RemoveWallpaperFromCache( path, &aViewData ); |
|
455 TRAP_IGNORE( aViewData.SetWallpaperImagePathL( KNullDesC ) ); |
|
456 aViewData.SetWallpaperImage( NULL ); |
|
457 } |
|
458 } |
|
459 else if( iType == ECommon ) |
|
460 { |
|
461 if( iBgImagePath ) |
|
462 { |
|
463 iSkinSrv.RemoveWallpaper( *iBgImagePath ); |
|
464 delete iBgImagePath; |
|
465 iBgImagePath = NULL; |
|
466 } |
|
467 delete iBgImage; |
|
468 iBgImage = NULL; |
|
469 } |
|
470 } |
|
471 |
|
472 // ----------------------------------------------------------------------------- |
|
473 // CXnBackgroundManager::ChangeWallpaper |
|
474 // ----------------------------------------------------------------------------- |
|
475 // |
|
476 void CXnBackgroundManager::ChangeWallpaper( const CXnViewData& aOldView, |
|
477 const CXnViewData& aNewView, TBool aDrawNow ) |
|
478 { |
|
479 if( iType == EPageSpecific ) |
|
480 { |
|
481 const TDesC& oldwp( aOldView.WallpaperImagePath() ); |
|
482 const TDesC& newwp( aNewView.WallpaperImagePath() ); |
|
483 |
|
484 if ( oldwp.Compare( newwp ) ) |
|
485 { |
|
486 iStoreWallpaper = ETrue; |
|
487 |
|
488 if ( aDrawNow ) |
|
489 { |
|
490 DrawNow(); |
|
491 } |
|
492 } |
|
493 } |
|
494 } |
|
495 |
|
496 // --------------------------------------------------------------------------- |
|
497 // CXnBackgroundManager::WallpaperType |
|
498 // --------------------------------------------------------------------------- |
|
499 // |
|
500 CXnBackgroundManager::WppType CXnBackgroundManager::WallpaperType() |
|
501 { |
|
502 return iType; |
|
503 } |
|
504 |
|
505 // --------------------------------------------------------------------------- |
|
506 // CXnBackgroundManager::UpdateViewData |
|
507 // --------------------------------------------------------------------------- |
|
508 // |
|
509 void CXnBackgroundManager::UpdateViewData( const TDesC& aFileName, |
|
510 CXnViewData& aViewData ) |
|
511 { |
|
512 TRAP_IGNORE( aViewData.SetWallpaperImagePathL( aFileName ) ); |
|
513 |
|
514 if( aFileName == KNullDesC ) |
|
515 { |
|
516 aViewData.SetWallpaperImage( NULL ); |
|
517 } |
|
518 else |
|
519 { |
|
520 CFbsBitmap* bitmap( NULL ); |
|
521 TRAPD( err, bitmap = iSkinSrv.WallpaperImageL( aFileName ) ); |
|
522 if( err == KErrNone && bitmap ) |
|
523 { |
|
524 aViewData.SetWallpaperImage( bitmap ); // Ownership tranferred |
|
525 } |
|
526 } |
|
527 } |
|
528 |
|
529 // --------------------------------------------------------------------------- |
|
530 // CXnBackgroundManager::SaveWallpaperL |
|
531 // --------------------------------------------------------------------------- |
|
532 // |
|
533 void CXnBackgroundManager::SaveWallpaperL() |
|
534 { |
|
535 // Save wallpaper to HSPS |
|
536 if( iType == EPageSpecific ) |
|
537 { |
|
538 CXnViewData& viewData( iViewManager.ActiveViewData() ); |
|
539 |
|
540 HBufC8* pUtf8String = CnvUtfConverter::ConvertFromUnicodeToUtf8L( viewData.WallpaperImagePath() ); |
|
541 CleanupStack::PushL( pUtf8String ); |
|
542 |
|
543 SetSettingPropertyL( viewData.PluginId(), |
|
544 KWallpaper, |
|
545 KPath, |
|
546 *pUtf8String ); |
|
547 |
|
548 CleanupStack::PopAndDestroy( pUtf8String ); |
|
549 pUtf8String = NULL; |
|
550 } |
|
551 else |
|
552 { |
|
553 CRepository* repository = CRepository::NewLC( TUid::Uid( KCRUidActiveIdleLV ) ); |
|
554 if ( repository ) |
|
555 { |
|
556 if( iBgImagePath ) |
|
557 { |
|
558 User::LeaveIfError( repository->Set( KAIWallpaperPath, |
|
559 *iBgImagePath ) ); |
|
560 } |
|
561 else |
|
562 { |
|
563 User::LeaveIfError( repository->Set( KAIWallpaperPath, |
|
564 KNullDesC ) ); |
|
565 } |
|
566 } |
|
567 CleanupStack::PopAndDestroy( repository ); |
|
568 } |
|
569 } |
|
570 |
|
571 // --------------------------------------------------------------------------- |
|
572 // CXnBackgroundManager::SetSettingPropertyL |
|
573 // --------------------------------------------------------------------------- |
|
574 // |
|
575 TInt CXnBackgroundManager::SetSettingPropertyL( const TDesC8& aPluginId, |
|
576 const TDesC8& aItemId, const TDesC8& aPropertyName, |
|
577 const TDesC8& aPropertyValue ) |
|
578 { |
|
579 if ( aPluginId == KNullDesC8() || |
|
580 aItemId == KNullDesC8() || |
|
581 aPropertyName == KNullDesC8() ) |
|
582 { |
|
583 return KErrArgument; |
|
584 } |
|
585 |
|
586 CHspsConfiguration* pluginConf( |
|
587 iHspsWrapper.GetPluginConfigurationL( aPluginId ) ); |
|
588 if ( !pluginConf ) |
|
589 { |
|
590 return KErrNotFound; |
|
591 } |
|
592 CleanupStack::PushL( pluginConf ); |
|
593 |
|
594 // Find. |
|
595 CPropertyMap* property = NULL; |
|
596 RPointerArray<CItemMap>& settings = pluginConf->Settings(); |
|
597 for( TInt i = 0; i < settings.Count(); i++ ) |
|
598 { |
|
599 CItemMap* setting = settings[i]; |
|
600 if ( !setting ) |
|
601 { |
|
602 continue; |
|
603 } |
|
604 |
|
605 if ( setting->ItemId() == aItemId ) |
|
606 { |
|
607 RPointerArray<CPropertyMap>& properties = setting->Properties(); |
|
608 for( TInt j = 0; j < properties.Count(); j++ ) |
|
609 { |
|
610 CPropertyMap* tmpProperty = properties[j]; |
|
611 if ( !tmpProperty ) |
|
612 { |
|
613 continue; |
|
614 } |
|
615 |
|
616 if ( tmpProperty->Name() == aPropertyName ) |
|
617 { |
|
618 property = tmpProperty; |
|
619 break; |
|
620 } |
|
621 } |
|
622 break; |
|
623 } |
|
624 } |
|
625 |
|
626 TInt ret = KErrNone; |
|
627 |
|
628 // Set. |
|
629 if ( property ) |
|
630 { |
|
631 property->SetValueL( aPropertyValue ); |
|
632 ret = iHspsWrapper.SetPluginSettingsL( aPluginId, settings ); |
|
633 } |
|
634 else |
|
635 { |
|
636 ret = KErrNotFound; |
|
637 } |
|
638 |
|
639 CleanupStack::PopAndDestroy( pluginConf ); |
|
640 |
|
641 return ret; |
|
642 } |
|
643 |
|
644 // --------------------------------------------------------------------------- |
|
645 // CXnBackgroundManager::SkinContentChanged |
|
646 // --------------------------------------------------------------------------- |
|
647 // |
|
648 void CXnBackgroundManager::SkinContentChanged() |
|
649 { |
|
650 TRAPD( err, UpdateStatuspaneMaskL() ); |
|
651 if( err ) |
|
652 { |
|
653 delete iSpBitmap; |
|
654 iSpBitmap = NULL; |
|
655 delete iSpMask; |
|
656 iSpMask = NULL; |
|
657 } |
|
658 } |
|
659 |
|
660 // --------------------------------------------------------------------------- |
|
661 // CXnBackgroundManager::SkinConfigurationChanged |
|
662 // --------------------------------------------------------------------------- |
|
663 // |
|
664 void CXnBackgroundManager::SkinConfigurationChanged( |
|
665 const TAknsSkinStatusConfigurationChangeReason aReason ) |
|
666 { |
|
667 if ( aReason == EAknsSkinStatusWallpaperChanged ) |
|
668 { |
|
669 if( iIntUpdate > 0 ) |
|
670 { |
|
671 iIntUpdate--; |
|
672 } |
|
673 else |
|
674 { |
|
675 TRAP_IGNORE( ReadWallpaperFromCenrepL() ); |
|
676 } |
|
677 } |
|
678 else if ( aReason == EAknsSkinStatusConfigurationDeployed ) |
|
679 { |
|
680 DrawNow(); |
|
681 } |
|
682 } |
|
683 |
|
684 // --------------------------------------------------------------------------- |
|
685 // CXnBackgroundManager::SkinPackageChanged |
|
686 // --------------------------------------------------------------------------- |
|
687 // |
|
688 void CXnBackgroundManager::SkinPackageChanged( |
|
689 const TAknsSkinStatusPackageChangeReason /*aReason*/ ) |
|
690 { |
|
691 } |
|
692 |
|
693 // ----------------------------------------------------------------------------- |
|
694 // CXnBackgroundManager::RemoveWallpaper |
|
695 // ----------------------------------------------------------------------------- |
|
696 // |
|
697 void CXnBackgroundManager::RemoveWallpaperFromCache( const TDesC& aFileName, |
|
698 CXnViewData* aViewData ) |
|
699 { |
|
700 if( aFileName == KNullDesC ) |
|
701 { |
|
702 return; |
|
703 } |
|
704 |
|
705 CXnViewData* currentViewData( aViewData ); |
|
706 if( !currentViewData ) |
|
707 { |
|
708 currentViewData = &iViewManager.ActiveViewData(); |
|
709 } |
|
710 CXnRootData& rootData = iViewManager.ActiveAppData(); |
|
711 RPointerArray<CXnPluginData>& rootDataArr = rootData.PluginData(); |
|
712 |
|
713 for( TInt i = 0; i < rootDataArr.Count(); i++ ) |
|
714 { |
|
715 CXnViewData* viewData = static_cast<CXnViewData*>( rootDataArr[i] ); |
|
716 if( currentViewData == viewData ) |
|
717 { |
|
718 continue; |
|
719 } |
|
720 else if( viewData->WallpaperImagePath() == aFileName ) |
|
721 { |
|
722 // Some other view has same wallpaper image. |
|
723 // This must not be removed from the cache. |
|
724 return; |
|
725 } |
|
726 } |
|
727 // Image is not needed anymore. Can be removed from the cache. |
|
728 iSkinSrv.RemoveWallpaper( aFileName ); |
|
729 } |
|
730 |
|
731 // ----------------------------------------------------------------------------- |
|
732 // CXnBackgroundManager::UpdateWallpapersL |
|
733 // ----------------------------------------------------------------------------- |
|
734 // |
|
735 void CXnBackgroundManager::UpdateWallpapersL() |
|
736 { |
|
737 CXnRootData& rootData = iViewManager.ActiveAppData(); |
|
738 if( !&rootData ) |
|
739 { |
|
740 return; |
|
741 } |
|
742 RPointerArray<CXnPluginData>& rootDataArr = rootData.PluginData(); |
|
743 |
|
744 for( TInt i = 0; i < rootDataArr.Count(); i++ ) |
|
745 { |
|
746 CXnViewData* viewData = static_cast<CXnViewData*>( rootDataArr[i] ); |
|
747 const TDesC& path = viewData->WallpaperImagePath(); |
|
748 if( path != KNullDesC ) |
|
749 { |
|
750 CFbsBitmap* bitmap = iSkinSrv.WallpaperImageL( path ); |
|
751 if( bitmap ) |
|
752 { |
|
753 viewData->SetWallpaperImage( bitmap ); |
|
754 } |
|
755 } |
|
756 } |
|
757 } |
|
758 |
|
759 // ----------------------------------------------------------------------------- |
|
760 // CXnBackgroundManager::RemovableDiskRemovedL |
|
761 // ----------------------------------------------------------------------------- |
|
762 // |
|
763 void CXnBackgroundManager::RemovableDiskRemovedL() |
|
764 { |
|
765 TInt drawingNeeded( EFalse ); |
|
766 RFs& fs( CEikonEnv::Static()->FsSession() ); |
|
767 |
|
768 if( iType == EPageSpecific ) |
|
769 { |
|
770 CXnRootData& rootData = iViewManager.ActiveAppData(); |
|
771 if( !&rootData ) |
|
772 { |
|
773 return; |
|
774 } |
|
775 RPointerArray<CXnPluginData>& rootDataArr = rootData.PluginData(); |
|
776 for( TInt i = 0; i < rootDataArr.Count(); i++ ) |
|
777 { |
|
778 CXnViewData* viewData = static_cast<CXnViewData*>( rootDataArr[i] ); |
|
779 const TDesC& path = viewData->WallpaperImagePath(); |
|
780 CFbsBitmap* bitmap = viewData->WallpaperImage(); |
|
781 if( path != KNullDesC && bitmap ) |
|
782 { |
|
783 if ( !BaflUtils::FileExists( fs, path ) ) |
|
784 { |
|
785 RemoveWallpaperFromCache( path, viewData ); |
|
786 viewData->SetWallpaperImage( NULL ); |
|
787 if( viewData == &iViewManager.ActiveViewData() ) |
|
788 { |
|
789 drawingNeeded = ETrue; |
|
790 } |
|
791 } |
|
792 } |
|
793 } |
|
794 } |
|
795 else |
|
796 { |
|
797 if( iBgImagePath && iBgImage ) |
|
798 { |
|
799 if ( !BaflUtils::FileExists( fs, *iBgImagePath ) ) |
|
800 { |
|
801 RemoveWallpaperFromCache( *iBgImagePath ); |
|
802 delete iBgImage; |
|
803 iBgImage = NULL; |
|
804 drawingNeeded = ETrue; |
|
805 } |
|
806 } |
|
807 } |
|
808 |
|
809 if( drawingNeeded ) |
|
810 { |
|
811 DrawNow(); |
|
812 |
|
813 iIntUpdate++; |
|
814 TInt err = AknsWallpaperUtils::SetIdleWallpaper( KNullDesC , NULL ); |
|
815 if( err ) |
|
816 { |
|
817 iIntUpdate--; |
|
818 } |
|
819 } |
|
820 } |
|
821 |
|
822 // ----------------------------------------------------------------------------- |
|
823 // CXnBackgroundManager::RemovableDiskInsertedL |
|
824 // ----------------------------------------------------------------------------- |
|
825 // |
|
826 void CXnBackgroundManager::RemovableDiskInsertedL() |
|
827 { |
|
828 RFs& fs( CEikonEnv::Static()->FsSession() ); |
|
829 |
|
830 if( iType == EPageSpecific ) |
|
831 { |
|
832 CXnRootData& rootData = iViewManager.ActiveAppData(); |
|
833 if( !&rootData ) |
|
834 { |
|
835 return; |
|
836 } |
|
837 RPointerArray<CXnPluginData>& rootDataArr = rootData.PluginData(); |
|
838 TInt drawingNeeded( EFalse ); |
|
839 for( TInt i = 0; i < rootDataArr.Count(); i++ ) |
|
840 { |
|
841 CXnViewData* viewData = static_cast<CXnViewData*>( rootDataArr[i] ); |
|
842 const TDesC& path = viewData->WallpaperImagePath(); |
|
843 CFbsBitmap* bitmap = viewData->WallpaperImage(); |
|
844 if( path != KNullDesC && !bitmap ) |
|
845 { |
|
846 if ( BaflUtils::FileExists( fs, path ) ) |
|
847 { |
|
848 TInt err = ConstructWallpaper( path, *viewData ); |
|
849 if( err == KErrNone && viewData == &iViewManager.ActiveViewData() ) |
|
850 { |
|
851 drawingNeeded = ETrue; |
|
852 } |
|
853 } |
|
854 } |
|
855 } |
|
856 if( drawingNeeded ) |
|
857 { |
|
858 DrawNow(); |
|
859 iStoreWallpaper = ETrue; |
|
860 StoreWallpaperL(); |
|
861 } |
|
862 } |
|
863 else |
|
864 { |
|
865 if( iBgImagePath && !iBgImage ) |
|
866 { |
|
867 if ( BaflUtils::FileExists( fs, *iBgImagePath ) ) |
|
868 { |
|
869 TRAPD( err, SetCommonWallpaperL( *iBgImagePath, EFalse ) ); |
|
870 if( err == KErrCANoRights ) |
|
871 { |
|
872 ShowInfoNoteL( R_QTN_HS_DRM_PROTECTED_IMAGE_NOTE ); |
|
873 delete iBgImagePath; |
|
874 iBgImagePath = NULL; |
|
875 SaveWallpaperL(); |
|
876 } |
|
877 } |
|
878 } |
|
879 } |
|
880 } |
|
881 |
|
882 // --------------------------------------------------------------------------- |
|
883 // CXnBackgroundManager::CheckFeatureTypeL |
|
884 // --------------------------------------------------------------------------- |
|
885 // |
|
886 void CXnBackgroundManager::CheckFeatureTypeL() |
|
887 { |
|
888 iType = ECommon; |
|
889 CRepository* repository = CRepository::NewL( TUid::Uid( KCRUidActiveIdleLV ) ); |
|
890 CleanupStack::PushL( repository ); |
|
891 if ( repository ) |
|
892 { |
|
893 // Get wallpaper handling type from cenrep |
|
894 TInt type; |
|
895 TInt err = repository->Get( KAIWallpaperChangeType, type ); |
|
896 if ( err == KErrNone && type == 1) |
|
897 { |
|
898 iType = EPageSpecific; |
|
899 } |
|
900 else |
|
901 { |
|
902 iStoreWallpaper = EFalse; |
|
903 |
|
904 TFileName path; |
|
905 err = repository->Get( KAIWallpaperPath, path ); |
|
906 if ( !err && path.Length()) |
|
907 { |
|
908 TRAP_IGNORE( SetCommonWallpaperL( path, EFalse, EFalse ) ); |
|
909 } |
|
910 } |
|
911 } |
|
912 CleanupStack::PopAndDestroy( repository ); |
|
913 } |
|
914 |
|
915 // --------------------------------------------------------------------------- |
|
916 // CXnBackgroundManager::SetPageSpecificWallpaperL |
|
917 // --------------------------------------------------------------------------- |
|
918 // |
|
919 void CXnBackgroundManager::SetPageSpecificWallpaperL( const TDesC& aFileName ) |
|
920 { |
|
921 CXnViewData& viewData( iViewManager.ActiveViewData() ); |
|
922 |
|
923 TInt err( KErrNone ); |
|
924 iIntUpdate++; |
|
925 |
|
926 if( aFileName == KNullDesC ) |
|
927 { |
|
928 err = AknsWallpaperUtils::SetIdleWallpaper( aFileName, NULL ); |
|
929 } |
|
930 else |
|
931 { |
|
932 // Wallpaper is also added into the cache if it is not there already. |
|
933 err = AknsWallpaperUtils::SetIdleWallpaper( aFileName, CCoeEnv::Static(), |
|
934 R_QTN_HS_PROCESSING_NOTE, R_CHANGE_WALLPAPER_WAIT_DIALOG ); |
|
935 } |
|
936 if( err == KErrNone ) |
|
937 { |
|
938 // Remove old wallpaper from the cache |
|
939 const TDesC& oldPath = viewData.WallpaperImagePath(); |
|
940 RemoveWallpaperFromCache( oldPath ); |
|
941 |
|
942 UpdateViewData( aFileName, viewData ); |
|
943 |
|
944 SaveWallpaperL(); // to HSPS |
|
945 } |
|
946 else |
|
947 { |
|
948 iIntUpdate--; |
|
949 User::Leave( err ); |
|
950 } |
|
951 } |
|
952 |
|
953 // --------------------------------------------------------------------------- |
|
954 // CXnBackgroundManager::SetCommonWallpaperL |
|
955 // --------------------------------------------------------------------------- |
|
956 // |
|
957 void CXnBackgroundManager::SetCommonWallpaperL( const TDesC& aFileName, |
|
958 TBool aSave, TBool aShowProgressBar ) |
|
959 { |
|
960 TInt err( KErrNone ); |
|
961 iIntUpdate++; |
|
962 |
|
963 if( aFileName == KNullDesC || !aShowProgressBar ) |
|
964 { |
|
965 err = AknsWallpaperUtils::SetIdleWallpaper( aFileName, NULL ); |
|
966 } |
|
967 else |
|
968 { |
|
969 // Wallpaper is also added into the cache if it is not there already. |
|
970 err = AknsWallpaperUtils::SetIdleWallpaper( aFileName, CCoeEnv::Static(), |
|
971 R_QTN_HS_PROCESSING_NOTE, R_CHANGE_WALLPAPER_WAIT_DIALOG ); |
|
972 } |
|
973 |
|
974 if( !err ) |
|
975 { |
|
976 // Remove old from the cache |
|
977 if( iBgImagePath && iBgImagePath->Compare( aFileName ) ) |
|
978 { |
|
979 iSkinSrv.RemoveWallpaper( *iBgImagePath ); |
|
980 delete iBgImagePath; |
|
981 iBgImagePath = NULL; |
|
982 } |
|
983 delete iBgImage; |
|
984 iBgImage = NULL; |
|
985 |
|
986 if( aFileName != KNullDesC ) |
|
987 { |
|
988 iBgImagePath = aFileName.AllocL(); |
|
989 |
|
990 TRAPD( err, iBgImage = iSkinSrv.WallpaperImageL( aFileName ) ); |
|
991 if( err ) |
|
992 { |
|
993 delete iBgImage; |
|
994 iBgImage = NULL; |
|
995 delete iBgImagePath; |
|
996 iBgImagePath = NULL; |
|
997 User::Leave( err ); |
|
998 } |
|
999 } |
|
1000 } |
|
1001 else |
|
1002 { |
|
1003 iIntUpdate--; |
|
1004 User::Leave( err ); |
|
1005 } |
|
1006 |
|
1007 // Update screen |
|
1008 DrawNow(); |
|
1009 |
|
1010 // Save path to cenrep |
|
1011 if( aSave ) |
|
1012 { |
|
1013 SaveWallpaperL(); |
|
1014 } |
|
1015 } |
|
1016 |
|
1017 // --------------------------------------------------------------------------- |
|
1018 // CXnBackgroundManager::ReadWallpaperFromCenrepL |
|
1019 // --------------------------------------------------------------------------- |
|
1020 // |
|
1021 void CXnBackgroundManager::ReadWallpaperFromCenrepL() |
|
1022 { |
|
1023 CRepository* repository = CRepository::NewLC( KCRUidPersonalisation ); |
|
1024 if ( repository ) |
|
1025 { |
|
1026 // Get wallpaper type from cenrep |
|
1027 TInt wallpaperType; |
|
1028 TInt err = repository->Get( KPslnWallpaperType, wallpaperType ); |
|
1029 if ( err == KErrNone ) |
|
1030 { |
|
1031 TFileName wallpaper; |
|
1032 |
|
1033 // WallpaperImage is image |
|
1034 // Get wallpaper image path from cenrep |
|
1035 if ( wallpaperType == 1 ) |
|
1036 { |
|
1037 err = repository->Get( KPslnIdleBackgroundImagePath, wallpaper ); |
|
1038 if ( err != KErrNone ) |
|
1039 { |
|
1040 return; |
|
1041 } |
|
1042 } |
|
1043 |
|
1044 if( iType == EPageSpecific ) |
|
1045 { |
|
1046 CXnViewData& viewData( iViewManager.ActiveViewData() ); |
|
1047 RemoveWallpaperFromCache( viewData.WallpaperImagePath() ); |
|
1048 viewData.SetWallpaperImagePathL( KNullDesC ); |
|
1049 viewData.SetWallpaperImage( NULL ); |
|
1050 if( wallpaperType == 1 ) |
|
1051 { |
|
1052 UpdateViewData( wallpaper, viewData ); |
|
1053 } |
|
1054 } |
|
1055 else if( iType == ECommon ) |
|
1056 { |
|
1057 if( iBgImagePath ) |
|
1058 { |
|
1059 iSkinSrv.RemoveWallpaper( *iBgImagePath ); |
|
1060 delete iBgImagePath; |
|
1061 iBgImagePath = NULL; |
|
1062 } |
|
1063 delete iBgImage; |
|
1064 iBgImage = NULL; |
|
1065 if( wallpaperType == 1 ) |
|
1066 { |
|
1067 iBgImagePath = wallpaper.AllocL(); |
|
1068 iBgImage = iSkinSrv.WallpaperImageL( wallpaper ); |
|
1069 } |
|
1070 } |
|
1071 } |
|
1072 |
|
1073 SaveWallpaperL(); |
|
1074 DrawNow(); |
|
1075 } |
|
1076 CleanupStack::PopAndDestroy( repository ); |
|
1077 } |
|
1078 |
|
1079 // ----------------------------------------------------------------------------- |
|
1080 // CXnBackgroundManager::DrawEditModeBackgroundSkin |
|
1081 // ----------------------------------------------------------------------------- |
|
1082 // |
|
1083 void CXnBackgroundManager::DrawEditModeBackgroundSkin() const |
|
1084 { |
|
1085 TRect shrunkRect = iRect; |
|
1086 |
|
1087 shrunkRect.Shrink( |
|
1088 KSkinGfxInnerRectShrink, |
|
1089 KSkinGfxInnerRectShrink ); |
|
1090 |
|
1091 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), SystemGc(), |
|
1092 iRect, shrunkRect, KAknsIIDQgnHomeEditBg, KAknsIIDDefault ); |
|
1093 } |
|
1094 |
|
1095 // ----------------------------------------------------------------------------- |
|
1096 // CXnBackgroundManager::DrawStatusPaneMask |
|
1097 // ----------------------------------------------------------------------------- |
|
1098 // |
|
1099 void CXnBackgroundManager::DrawStatusPaneMask() const |
|
1100 { |
|
1101 if( iSpBitmap && iSpMask ) |
|
1102 { |
|
1103 TSize bmpSize = iSpMask->SizeInPixels(); |
|
1104 TRect spRect( 0, 0, bmpSize.iWidth, bmpSize.iHeight ); |
|
1105 SystemGc().DrawBitmapMasked( spRect, iSpBitmap, spRect, iSpMask, ETrue ); |
|
1106 } |
|
1107 } |
|
1108 |
|
1109 // ----------------------------------------------------------------------------- |
|
1110 // CXnBackgroundManager::StoreWallpaperL |
|
1111 // ----------------------------------------------------------------------------- |
|
1112 // |
|
1113 void CXnBackgroundManager::StoreWallpaperL() |
|
1114 { |
|
1115 if ( iStoreWallpaper ) |
|
1116 { |
|
1117 iStoreWallpaper = EFalse; |
|
1118 |
|
1119 CXnViewData& activeView = iViewManager.ActiveViewData(); |
|
1120 const TDesC& path( activeView.WallpaperImagePath() ); |
|
1121 RFs& fs( CEikonEnv::Static()->FsSession() ); |
|
1122 if ( path != KNullDesC && BaflUtils::FileExists( fs, path ) ) |
|
1123 { |
|
1124 iIntUpdate++; |
|
1125 TInt err( AknsWallpaperUtils::SetIdleWallpaper( path, NULL ) ); |
|
1126 |
|
1127 if( err ) |
|
1128 { |
|
1129 iIntUpdate--; |
|
1130 |
|
1131 if ( err == KErrCANoRights ) |
|
1132 { |
|
1133 ShowInfoNoteL( R_QTN_HS_DRM_PROTECTED_IMAGE_NOTE ); |
|
1134 |
|
1135 // Change wpp to default |
|
1136 UpdateViewData( KNullDesC, iViewManager.ActiveViewData() ); |
|
1137 SaveWallpaperL(); |
|
1138 DrawNow(); |
|
1139 } |
|
1140 } |
|
1141 } |
|
1142 else |
|
1143 { |
|
1144 iIntUpdate++; |
|
1145 TInt err( AknsWallpaperUtils::SetIdleWallpaper( KNullDesC, NULL ) ); |
|
1146 if( err ) |
|
1147 { |
|
1148 iIntUpdate--; |
|
1149 } |
|
1150 } |
|
1151 } |
|
1152 } |
|
1153 |
|
1154 // ----------------------------------------------------------------------------- |
|
1155 // CXnBackgroundManager::UpdateStatuspaneMaskL |
|
1156 // ----------------------------------------------------------------------------- |
|
1157 // |
|
1158 void CXnBackgroundManager::UpdateStatuspaneMaskL() |
|
1159 { |
|
1160 if ( iSpBitmap ) |
|
1161 { |
|
1162 delete iSpBitmap; |
|
1163 iSpBitmap = NULL; |
|
1164 } |
|
1165 if ( iSpMask ) |
|
1166 { |
|
1167 delete iSpMask; |
|
1168 iSpMask = NULL; |
|
1169 } |
|
1170 |
|
1171 TRect spRect; |
|
1172 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, spRect ); |
|
1173 |
|
1174 MAknsSkinInstance* skinInstance( AknsUtils::SkinInstance() ); |
|
1175 |
|
1176 // Get Homescreen status area mask color (EAknsCIQsnOtherColorsCG23) |
|
1177 TRgb color; |
|
1178 User::LeaveIfError( AknsUtils::GetCachedColor( skinInstance, color, |
|
1179 KAknsIIDQsnOtherColors, EAknsCIQsnOtherColorsCG23 ) ); |
|
1180 |
|
1181 iSpBitmap = CreateBitmapFromColorL( spRect.Size(), color ); |
|
1182 |
|
1183 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
1184 { |
|
1185 iSpMask = AknsUtils::CreateBitmapL( skinInstance, |
|
1186 KAknsIIDQgnGrafBgLscTopMaskIcon ); |
|
1187 } |
|
1188 else |
|
1189 { |
|
1190 iSpMask = AknsUtils::CreateBitmapL( skinInstance, |
|
1191 KAknsIIDQgnGrafBgPrtTopMaskIcon ); |
|
1192 } |
|
1193 |
|
1194 if ( iSpMask ) |
|
1195 { |
|
1196 User::LeaveIfError( AknIconUtils::SetSize( |
|
1197 iSpMask, spRect.Size(), EAspectRatioNotPreserved ) ); |
|
1198 } |
|
1199 } |
|
1200 |
|
1201 // End of File |