25 #include "hspssapi.h" |
25 #include "hspssapi.h" |
26 #include "xnappuiadapter.h" |
26 #include "xnappuiadapter.h" |
27 #include "xnwallpaperview.h" |
27 #include "xnwallpaperview.h" |
28 #include "xnrootdata.h" |
28 #include "xnrootdata.h" |
29 #include "xnuiengine.h" |
29 #include "xnuiengine.h" |
|
30 #include "xneffectmanager.h" |
30 |
31 |
31 // SYSTEM INCLUDE FILES |
32 // SYSTEM INCLUDE FILES |
|
33 #include <gfxtranseffect/gfxtranseffect.h> |
|
34 #include <akntransitionutils.h> |
32 #include <aknlistquerydialog.h> |
35 #include <aknlistquerydialog.h> |
33 #include <xnuiengine.rsg> |
36 #include <xnuiengine.rsg> |
34 #include <AknSkinsInternalCRKeys.h> |
37 #include <AknSkinsInternalCRKeys.h> |
35 #include <activeidle2domaincrkeys.h> |
38 #include <activeidle2domaincrkeys.h> |
36 #include <AknsWallpaperUtils.h> |
39 #include <AknsWallpaperUtils.h> |
43 #include <AknsLayeredBackgroundControlContext.h> |
46 #include <AknsLayeredBackgroundControlContext.h> |
44 #include <driveinfo.h> |
47 #include <driveinfo.h> |
45 |
48 |
46 using namespace hspswrapper; |
49 using namespace hspswrapper; |
47 |
50 |
|
51 // Constants |
48 _LIT8( KSingle, "single" ); |
52 _LIT8( KSingle, "single" ); |
49 const TUid KDummyUid = { 0x0000000 }; |
53 const TUid KDummyUid = { 0x0000000 }; |
50 const TInt KSkinGfxInnerRectShrink = 5; |
54 const TInt KSkinGfxInnerRectShrink( 5 ); |
|
55 const TInt KCallbackDelay( 500000 ); // 500ms |
51 |
56 |
52 // ============================ MEMBER FUNCTIONS =============================== |
57 // ============================ MEMBER FUNCTIONS =============================== |
53 |
58 |
54 // ----------------------------------------------------------------------------- |
59 // ----------------------------------------------------------------------------- |
55 // C++ default constructor. |
60 // C++ default constructor. |
133 // CXnBackgroundManager::Draw |
142 // CXnBackgroundManager::Draw |
134 // ----------------------------------------------------------------------------- |
143 // ----------------------------------------------------------------------------- |
135 // |
144 // |
136 void CXnBackgroundManager::Draw(const TRect& aRect) const |
145 void CXnBackgroundManager::Draw(const TRect& aRect) const |
137 { |
146 { |
138 if( iFeatureSuppoted ) |
147 CFbsBitmap* wallpaper( NULL ); |
|
148 if( iType == EPageSpecific ) |
139 { |
149 { |
140 CXnViewData& viewData( iViewManager.ActiveViewData() ); |
150 CXnViewData& viewData( iViewManager.ActiveViewData() ); |
141 CFbsBitmap* wallpaper = viewData.WallpaperImage(); |
151 wallpaper = viewData.WallpaperImage(); |
142 if( wallpaper ) |
152 } |
143 { |
153 else if( iType == ECommon ) |
144 TSize bitmapSize = wallpaper->SizeInPixels(); |
154 { |
145 |
155 wallpaper = iBgImage; |
146 if( iRect.Height() > bitmapSize.iHeight && iRect.Width() > bitmapSize.iWidth ) |
156 } |
147 { |
157 |
148 TInt width = bitmapSize.iWidth / 2; |
158 // Draw bg image |
149 TInt height = bitmapSize.iHeight / 2; |
159 if( wallpaper ) |
150 |
160 { |
151 TPoint point = iRect.Center(); |
161 TSize bitmapSize = wallpaper->SizeInPixels(); |
152 point.SetXY( point.iX - width, point.iY - height ); |
|
153 |
|
154 SystemGc().SetBrushColor( KRgbBlack ); |
|
155 SystemGc().Clear( aRect ); |
|
156 SystemGc().DrawBitmap( TRect( point, bitmapSize), wallpaper ); |
|
157 } |
|
158 else |
|
159 { |
|
160 SystemGc().DrawBitmap( iRect, wallpaper ); |
|
161 } |
|
162 |
|
163 if( iViewManager.UiEngine().IsEditMode() ) |
|
164 { |
|
165 DrawEditModeBackgroundSkin(); |
|
166 } |
|
167 return; |
|
168 } |
|
169 } |
|
170 else if( iBgImage ) |
|
171 { |
|
172 TSize bitmapSize = iBgImage->SizeInPixels(); |
|
173 |
162 |
|
163 // If image is smaller that screen size it needs to be centralized |
174 if( iRect.Height() > bitmapSize.iHeight && iRect.Width() > bitmapSize.iWidth ) |
164 if( iRect.Height() > bitmapSize.iHeight && iRect.Width() > bitmapSize.iWidth ) |
175 { |
165 { |
176 TInt width = bitmapSize.iWidth / 2; |
166 TInt width = bitmapSize.iWidth / 2; |
177 TInt height = bitmapSize.iHeight / 2; |
167 TInt height = bitmapSize.iHeight / 2; |
178 |
168 |
179 TPoint point = iRect.Center(); |
169 TPoint point = iRect.Center(); |
180 point.SetXY( point.iX - width, point.iY - height ); |
170 point.SetXY( point.iX - width, point.iY - height ); |
181 |
171 |
182 SystemGc().SetBrushColor( KRgbBlack ); |
172 SystemGc().SetBrushColor( KRgbBlack ); |
183 SystemGc().Clear( aRect ); |
173 SystemGc().Clear( aRect ); |
184 SystemGc().DrawBitmap( TRect( point, bitmapSize ), iBgImage ); |
174 SystemGc().DrawBitmap( TRect( point, bitmapSize), wallpaper ); |
185 |
|
186 } |
175 } |
187 else |
176 else |
188 { |
177 { |
189 SystemGc().DrawBitmap( iRect, iBgImage ); |
178 SystemGc().DrawBitmap( iRect, wallpaper ); |
190 } |
179 } |
191 if( iViewManager.UiEngine().IsEditMode() ) |
180 } |
192 { |
181 |
193 DrawEditModeBackgroundSkin(); |
182 // Skin bg is used by default |
194 } |
183 else |
195 return; |
184 { |
196 } |
185 MAknsSkinInstance* skin( AknsUtils::SkinInstance() ); |
197 MAknsSkinInstance* skin( AknsUtils::SkinInstance() ); |
186 AknsDrawUtils::Background( skin, iBgContext, this, SystemGc(), aRect ); |
198 AknsDrawUtils::Background( skin, iBgContext, this, SystemGc(), aRect ); |
187 } |
199 |
188 |
|
189 // Draw edit mode background highlight |
200 if( iViewManager.UiEngine().IsEditMode() ) |
190 if( iViewManager.UiEngine().IsEditMode() ) |
201 { |
191 { |
202 DrawEditModeBackgroundSkin(); |
192 DrawEditModeBackgroundSkin(); |
203 } |
193 } |
204 } |
194 } |
205 |
195 |
206 // ----------------------------------------------------------------------------- |
196 // ----------------------------------------------------------------------------- |
207 // CXnBackgroundManager::SizeChanged |
197 // CXnBackgroundManager::SizeChanged |
208 // ----------------------------------------------------------------------------- |
198 // ----------------------------------------------------------------------------- |
209 // |
199 // |
210 void CXnBackgroundManager::SizeChanged() |
200 void CXnBackgroundManager::SizeChanged() |
211 { |
201 { |
212 iRect = Rect(); |
202 iRect = Rect(); |
213 if( iFeatureSuppoted ) |
203 if( iType == EPageSpecific ) |
214 { |
204 { |
215 TRAP_IGNORE( UpdateWallpapersL() ); |
205 TRAP_IGNORE( UpdateWallpapersL() ); |
216 } |
206 } |
217 else |
207 else if( iType == ECommon ) |
218 { |
208 { |
219 if( iBgImagePath ) |
209 if( iBgImagePath ) |
220 { |
210 { |
221 delete iBgImage; |
211 delete iBgImage; |
222 iBgImage = NULL; |
212 iBgImage = NULL; |
305 // CXnBackgroundManager::AddWallpaperL |
295 // CXnBackgroundManager::AddWallpaperL |
306 // --------------------------------------------------------------------------- |
296 // --------------------------------------------------------------------------- |
307 // |
297 // |
308 TInt CXnBackgroundManager::AddWallpaperL( const TDesC& aFileName ) |
298 TInt CXnBackgroundManager::AddWallpaperL( const TDesC& aFileName ) |
309 { |
299 { |
310 TInt retVal = KErrNone; |
300 TInt retVal( KErrNone ); |
311 if( iFeatureSuppoted ) |
301 |
|
302 GfxTransEffect::Begin( this, KGfxControlActionAppear ); |
|
303 |
|
304 if ( iType == EPageSpecific ) |
312 { |
305 { |
313 retVal = AddPageSpecificWallpaperL( aFileName ); |
306 retVal = AddPageSpecificWallpaperL( aFileName ); |
314 } |
307 } |
315 else |
308 else if ( iType == ECommon ) |
316 { |
309 { |
317 retVal = AddCommonWallpaperL( aFileName ); |
310 retVal = AddCommonWallpaperL( aFileName ); |
318 } |
311 } |
|
312 |
|
313 GfxTransEffect::SetDemarcation( this, Position() ); |
|
314 GfxTransEffect::End( this ); |
|
315 |
319 return retVal; |
316 return retVal; |
320 } |
317 } |
321 |
318 |
322 // --------------------------------------------------------------------------- |
319 // --------------------------------------------------------------------------- |
323 // CXnBackgroundManager::DeleteWallpaper |
320 // CXnBackgroundManager::DeleteWallpaper |
324 // --------------------------------------------------------------------------- |
321 // --------------------------------------------------------------------------- |
325 // |
322 // |
326 void CXnBackgroundManager::DeleteWallpaper( CXnViewData& aViewData ) |
323 void CXnBackgroundManager::DeleteWallpaper( CXnViewData& aViewData ) |
327 { |
324 { |
328 if( iFeatureSuppoted ) |
325 if( iType == EPageSpecific ) |
329 { |
326 { |
330 const TDesC& path = aViewData.WallpaperImagePath(); |
327 const TDesC& path = aViewData.WallpaperImagePath(); |
331 if( path != KNullDesC ) |
328 if( path != KNullDesC ) |
332 { |
329 { |
333 RemoveWallpaperFromCache( path, &aViewData ); |
330 RemoveWallpaperFromCache( path, &aViewData ); |
334 TRAP_IGNORE( aViewData.SetWallpaperImagePathL( KNullDesC ) ); |
331 TRAP_IGNORE( aViewData.SetWallpaperImagePathL( KNullDesC ) ); |
335 aViewData.SetWallpaperImage( NULL ); |
332 aViewData.SetWallpaperImage( NULL ); |
336 } |
333 } |
337 } |
334 } |
338 else |
335 else if( iType == ECommon ) |
339 { |
336 { |
340 if( iBgImagePath ) |
337 if( iBgImagePath ) |
341 { |
338 { |
342 iSkinSrv.RemoveWallpaper( *iBgImagePath ); |
339 iSkinSrv.RemoveWallpaper( *iBgImagePath ); |
343 delete iBgImagePath; |
340 delete iBgImagePath; |
347 iBgImage = NULL; |
344 iBgImage = NULL; |
348 } |
345 } |
349 } |
346 } |
350 |
347 |
351 // --------------------------------------------------------------------------- |
348 // --------------------------------------------------------------------------- |
352 // CXnBackgroundManager::ActivatedL |
349 // CXnBackgroundManager::WallpaperType |
353 // --------------------------------------------------------------------------- |
350 // --------------------------------------------------------------------------- |
354 // |
351 // |
355 TBool CXnBackgroundManager::ActivatedL() |
352 CXnBackgroundManager::WppType CXnBackgroundManager::WallpaperType() |
356 { |
353 { |
357 return iFeatureSuppoted; |
354 return iType; |
358 } |
355 } |
359 |
356 |
360 // ----------------------------------------------------------------------------- |
357 // ----------------------------------------------------------------------------- |
361 // CXnBackgroundManager::WallpaperChanged |
358 // CXnBackgroundManager::WallpaperChanged |
362 // ----------------------------------------------------------------------------- |
359 // ----------------------------------------------------------------------------- |
363 // |
360 // |
364 void CXnBackgroundManager::WallpaperChanged( CXnViewData& aOldView, CXnViewData& aNewView ) |
361 void CXnBackgroundManager::WallpaperChanged( const CXnViewData& aOldView, |
365 { |
362 const CXnViewData& aNewView ) |
366 if( iFeatureSuppoted && |
363 { |
|
364 if( iType == EPageSpecific && |
367 aOldView.WallpaperImagePath().Compare( aNewView.WallpaperImagePath() ) ) |
365 aOldView.WallpaperImagePath().Compare( aNewView.WallpaperImagePath() ) ) |
368 { |
366 { |
369 UpdateScreen(); |
367 UpdateScreen(); |
370 |
368 |
371 // Since AknsWallpaperUtils::SetIdleWallpaper() call is slow, it is called |
369 // Since AknsWallpaperUtils::SetIdleWallpaper() call is slow, it is called |
372 // asynchronously. In that way we can avoid it slowing down page switching. |
370 // asynchronously. In that way we can avoid it slowing down page switching. |
373 if ( iTimer->IsActive() ) |
371 if ( iTimer->IsActive() ) |
374 { |
372 { |
375 iTimer->Cancel(); |
373 iTimer->Cancel(); |
376 } |
374 } |
377 iTimer->Start( 0, 1000, TCallBack( TimerCallback, this ) ); |
375 iTimer->Start(KCallbackDelay, KCallbackDelay, TCallBack( TimerCallback, this ) ); |
378 } |
376 } |
379 } |
377 } |
380 |
378 |
381 // --------------------------------------------------------------------------- |
379 // --------------------------------------------------------------------------- |
382 // CXnBackgroundManager::SaveWallpaperL |
380 // CXnBackgroundManager::SaveWallpaperL |
383 // --------------------------------------------------------------------------- |
381 // --------------------------------------------------------------------------- |
384 // |
382 // |
385 void CXnBackgroundManager::SaveWallpaperL() |
383 void CXnBackgroundManager::SaveWallpaperL() |
386 { |
384 { |
387 // Save wallpaper to HSPS |
385 // Save wallpaper to HSPS |
388 if( iFeatureSuppoted ) |
386 if( iType == EPageSpecific ) |
389 { |
387 { |
390 TBuf8<KMaxFileName> wallpaper8; |
388 TBuf8<KMaxFileName> wallpaper8; |
391 CXnViewData& viewData( iViewManager.ActiveViewData() ); |
389 CXnViewData& viewData( iViewManager.ActiveViewData() ); |
392 wallpaper8.Copy( viewData.WallpaperImagePath() ); |
390 wallpaper8.Copy( viewData.WallpaperImagePath() ); |
393 SetSettingPropertyL( viewData.PluginId(), KWallpaper, |
391 SetSettingPropertyL( viewData.PluginId(), KWallpaper, |
683 // CXnBackgroundManager::CheckFeatureTypeL |
685 // CXnBackgroundManager::CheckFeatureTypeL |
684 // --------------------------------------------------------------------------- |
686 // --------------------------------------------------------------------------- |
685 // |
687 // |
686 void CXnBackgroundManager::CheckFeatureTypeL() |
688 void CXnBackgroundManager::CheckFeatureTypeL() |
687 { |
689 { |
688 iFeatureSuppoted = EFalse; |
690 iType = ECommon; |
689 CRepository* repository = CRepository::NewL( TUid::Uid( KCRUidActiveIdleLV ) ); |
691 CRepository* repository = CRepository::NewL( TUid::Uid( KCRUidActiveIdleLV ) ); |
690 CleanupStack::PushL( repository ); |
692 CleanupStack::PushL( repository ); |
691 if ( repository ) |
693 if ( repository ) |
692 { |
694 { |
693 // Get wallpaper handling type from cenrep |
695 // Get wallpaper handling type from cenrep |
694 TInt type; |
696 TInt type; |
695 TInt err = repository->Get( KAIWallpaperChangeType, type ); |
697 TInt err = repository->Get( KAIWallpaperChangeType, type ); |
696 if ( err == KErrNone && type == 1) |
698 if ( err == KErrNone && type == 1) |
697 { |
699 { |
698 iFeatureSuppoted = ETrue; |
700 iType = EPageSpecific; |
699 } |
701 } |
700 else |
702 else |
701 { |
703 { |
702 TFileName path; |
704 TFileName path; |
703 err = repository->Get( KAIWallpaperPath, path ); |
705 err = repository->Get( KAIWallpaperPath, path ); |
831 TInt err = repository->Get( KPslnWallpaperType, wallpaperType ); |
833 TInt err = repository->Get( KPslnWallpaperType, wallpaperType ); |
832 if ( err == KErrNone ) |
834 if ( err == KErrNone ) |
833 { |
835 { |
834 if ( wallpaperType == 0 ) |
836 if ( wallpaperType == 0 ) |
835 { |
837 { |
836 if( iFeatureSuppoted ) |
838 if( iType == EPageSpecific ) |
837 { |
839 { |
838 CXnViewData& viewData( iViewManager.ActiveViewData() ); |
840 CXnViewData& viewData( iViewManager.ActiveViewData() ); |
839 RemoveWallpaperFromCache( viewData.WallpaperImagePath() ); |
841 RemoveWallpaperFromCache( viewData.WallpaperImagePath() ); |
840 RemoveWallpaperL( viewData ); |
842 RemoveWallpaperL( viewData ); |
841 } |
843 } |
842 else |
844 else if( iType == ECommon ) |
843 { |
845 { |
844 if( iBgImagePath ) |
846 if( iBgImagePath ) |
845 { |
847 { |
846 iSkinSrv.RemoveWallpaper( *iBgImagePath ); |
848 iSkinSrv.RemoveWallpaper( *iBgImagePath ); |
847 delete iBgImagePath; |
849 delete iBgImagePath; |