idlehomescreen/xmluirendering/uiengine/src/xnbackgroundmanager.cpp
branchRCL_3
changeset 15 ff572dfe6d86
parent 9 f966699dea19
child 16 9674c1a575e9
equal deleted inserted replaced
9:f966699dea19 15:ff572dfe6d86
    91     // Start listening file server notifications.
    91     // Start listening file server notifications.
    92     iDiskNotifier = CDiskNotifyHandler::NewL( *this, iFsSession );
    92     iDiskNotifier = CDiskNotifyHandler::NewL( *this, iFsSession );
    93     User::LeaveIfError( iDiskNotifier->NotifyDisk() );
    93     User::LeaveIfError( iDiskNotifier->NotifyDisk() );
    94     
    94     
    95     // Reads from cenrep wheteher page specific wallpaper is enabled or not
    95     // Reads from cenrep wheteher page specific wallpaper is enabled or not
    96     CheckFeatureTypeL();
    96     CheckFeatureTypeL();   
       
    97 
       
    98     iTimer = CPeriodic::NewL( CActive::EPriorityIdle );
    97     }
    99     }
    98 
   100 
    99 // -----------------------------------------------------------------------------
   101 // -----------------------------------------------------------------------------
   100 // Two-phased constructor.
   102 // Two-phased constructor.
   101 // -----------------------------------------------------------------------------
   103 // -----------------------------------------------------------------------------
   115 // Destructor.
   117 // Destructor.
   116 // -----------------------------------------------------------------------------
   118 // -----------------------------------------------------------------------------
   117 //
   119 //
   118 CXnBackgroundManager::~CXnBackgroundManager()
   120 CXnBackgroundManager::~CXnBackgroundManager()
   119     {
   121     {
       
   122     delete iTimer;
   120     CleanCache();
   123     CleanCache();
   121     iSkinSrv.Close();
   124     iSkinSrv.Close();
   122     delete iDiskNotifier;
   125     delete iDiskNotifier;
   123     iFsSession.Close();
   126     iFsSession.Close();
   124     delete iBgContext;
   127     delete iBgContext;
   148                 TPoint point = iRect.Center();
   151                 TPoint point = iRect.Center();
   149                 point.SetXY( point.iX - width, point.iY - height );
   152                 point.SetXY( point.iX - width, point.iY - height );
   150                 
   153                 
   151                 SystemGc().SetBrushColor( KRgbBlack );
   154                 SystemGc().SetBrushColor( KRgbBlack );
   152                 SystemGc().Clear( aRect );
   155                 SystemGc().Clear( aRect );
   153                 SystemGc().BitBlt( point, wallpaper ); 
   156                 SystemGc().DrawBitmap( TRect( point, bitmapSize), wallpaper );
   154                 }
   157                 }
   155             else
   158             else
   156                 {
   159                 {
   157                 SystemGc().BitBlt( TPoint( 0, 0 ), wallpaper );
   160                 SystemGc().DrawBitmap( iRect, wallpaper );
   158                 }
   161                 }
   159 
   162 
   160             if( iViewManager.UiEngine().IsEditMode() )
   163             if( iViewManager.UiEngine().IsEditMode() )
   161                 {
   164                 {
   162                 DrawEditModeBackgroundSkin();
   165                 DrawEditModeBackgroundSkin();
   176             TPoint point = iRect.Center();
   179             TPoint point = iRect.Center();
   177             point.SetXY( point.iX - width, point.iY - height );
   180             point.SetXY( point.iX - width, point.iY - height );
   178             
   181             
   179             SystemGc().SetBrushColor( KRgbBlack );
   182             SystemGc().SetBrushColor( KRgbBlack );
   180             SystemGc().Clear( aRect );
   183             SystemGc().Clear( aRect );
   181             SystemGc().BitBlt( point, iBgImage ); 
   184             SystemGc().DrawBitmap( TRect( point, bitmapSize ), iBgImage );
       
   185 
   182             }
   186             }
   183         else
   187         else
   184             {
   188             {
   185             SystemGc().BitBlt( TPoint( 0, 0 ), iBgImage );
   189             SystemGc().DrawBitmap( iRect, iBgImage );
   186             }
   190             }
   187         if( iViewManager.UiEngine().IsEditMode() )
   191         if( iViewManager.UiEngine().IsEditMode() )
   188             {
   192             {
   189             DrawEditModeBackgroundSkin();
   193             DrawEditModeBackgroundSkin();
   190             }
   194             }
   361     {
   365     {
   362     if( iFeatureSuppoted && 
   366     if( iFeatureSuppoted && 
   363         aOldView.WallpaperImagePath().Compare( aNewView.WallpaperImagePath() ) )
   367         aOldView.WallpaperImagePath().Compare( aNewView.WallpaperImagePath() ) )
   364         {
   368         {
   365         UpdateScreen();
   369         UpdateScreen();
   366         TInt err = AknsWallpaperUtils::SetIdleWallpaper( aNewView.WallpaperImagePath(), NULL );
   370 
   367         if( err == KErrNone )
   371         // Since AknsWallpaperUtils::SetIdleWallpaper() call is slow, it is called
   368             {
   372         // asynchronously. In that way we can avoid it slowing down page switching.
   369             iIntUpdate++;
   373         if ( iTimer->IsActive() )
   370             }
   374             {
       
   375             iTimer->Cancel();
       
   376             }
       
   377         iTimer->Start( 0, 1000, TCallBack( TimerCallback, this ) );
   371         }
   378         }
   372     }
   379     }
   373 
   380 
   374 // ---------------------------------------------------------------------------
   381 // ---------------------------------------------------------------------------
   375 // CXnBackgroundManager::SaveWallpaperL
   382 // CXnBackgroundManager::SaveWallpaperL
   711     {
   718     {
   712     TInt err = KErrNone;
   719     TInt err = KErrNone;
   713     CXnViewData& viewData( iViewManager.ActiveViewData() );
   720     CXnViewData& viewData( iViewManager.ActiveViewData() );
   714     const TDesC& old = viewData.WallpaperImagePath();
   721     const TDesC& old = viewData.WallpaperImagePath();
   715 
   722 
   716     if( aFileName.Compare( old ) )
   723     // Remove old from the cache
   717         {
   724     if( old != KNullDesC )
   718         // Remove old from the cache
   725         {
   719         if( old != KNullDesC )
   726         RemoveWallpaperFromCache( old );
   720             {
   727         }
   721             RemoveWallpaperFromCache( old );
   728 
   722             }
   729     // Add new to the cache
   723 
   730     if( aFileName != KNullDesC )
   724         // Add new to the cache
   731         {
   725         if( aFileName != KNullDesC )
   732         if( CacheWallpaperL( aFileName, viewData ) == KErrNone )
   726             {
   733             {
   727             if( CacheWallpaperL( aFileName, viewData ) == KErrNone )
   734             SaveWallpaperL(); // to HSPS
   728                 {
   735             }
   729                 SaveWallpaperL(); // to HSPS
       
   730                 }
       
   731             else
       
   732                 {
       
   733                 // image is corrupted or format is not supported
       
   734                 return KErrCACorruptContent;
       
   735                 }
       
   736             }
       
   737         // WallpaperImage changed back to default. Update view data.
       
   738         else
   736         else
   739             {
   737             {
   740             viewData.SetWallpaperImagePathL( KNullDesC );
   738             // image is corrupted or format is not supported
   741             viewData.SetWallpaperImage( NULL ); 
   739             return KErrCACorruptContent;
   742             SaveWallpaperL(); // to HSPS
   740             }
   743             }
   741         }
   744 
   742     // WallpaperImage changed back to default. Update view data.
   745         // Update screen
   743     else
   746         UpdateScreen();
   744         {
       
   745         viewData.SetWallpaperImagePathL( KNullDesC );
       
   746         viewData.SetWallpaperImage( NULL ); 
       
   747         SaveWallpaperL(); // to HSPS
       
   748         }
       
   749 
       
   750     // Update screen
       
   751     UpdateScreen();
       
   752     
       
   753     err = AknsWallpaperUtils::SetIdleWallpaper( aFileName, NULL );
       
   754     if( err == KErrNone )
       
   755         {
       
   756         iIntUpdate++;
       
   757         }
   747         
   758         
   748         err = AknsWallpaperUtils::SetIdleWallpaper( aFileName, NULL );
       
   749         if( err == KErrNone )
       
   750             {
       
   751             iIntUpdate++;
       
   752             }
       
   753         }
       
   754     return err;
   759     return err;
   755     }
   760     }
   756         
   761         
   757 // ---------------------------------------------------------------------------
   762 // ---------------------------------------------------------------------------
   758 // CXnBackgroundManager::AddCommonWallpaperL
   763 // CXnBackgroundManager::AddCommonWallpaperL
   902     
   907     
   903     AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), SystemGc(), 
   908     AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), SystemGc(), 
   904             iRect, shrunkRect, KAknsIIDQgnHomeEditBg, KAknsIIDDefault );
   909             iRect, shrunkRect, KAknsIIDQgnHomeEditBg, KAknsIIDDefault );
   905     }
   910     }
   906 
   911 
       
   912 // -----------------------------------------------------------------------------
       
   913 // CXnBackgroundManager::TimerCallback
       
   914 // -----------------------------------------------------------------------------
       
   915 //
       
   916 TInt CXnBackgroundManager::TimerCallback(TAny *aPtr)
       
   917     {
       
   918     CXnBackgroundManager* bgManager = reinterpret_cast<CXnBackgroundManager*>( aPtr );    
       
   919     bgManager->iTimer->Cancel();
       
   920     
       
   921     TInt err = AknsWallpaperUtils::SetIdleWallpaper( bgManager->
       
   922         iViewManager.ActiveViewData().WallpaperImagePath(), NULL );
       
   923     if( err == KErrNone )
       
   924         {
       
   925         bgManager->iIntUpdate++;
       
   926         }   
       
   927     return EFalse;
       
   928     }
       
   929 
       
   930 
   907 //  End of File
   931 //  End of File