idlehomescreen/xmluirendering/uiengine/src/xnviewmanager.cpp
branchRCL_3
changeset 88 3321d3e205b6
parent 83 5456b4e8b3a8
child 102 ba63c83f4716
equal deleted inserted replaced
83:5456b4e8b3a8 88:3321d3e205b6
    58 #include "xneffectmanager.h"
    58 #include "xneffectmanager.h"
    59 #include "xnkeyeventdispatcher.h"
    59 #include "xnkeyeventdispatcher.h"
    60 
    60 
    61 // Constants
    61 // Constants
    62 _LIT8( KEmptyWidgetUid, "0x2001f47f" );
    62 _LIT8( KEmptyWidgetUid, "0x2001f47f" );
    63 _LIT8( KTemplateViewUID, "0x20026f50" );
       
    64 
    63 
    65 const TInt KPSCategoryUid( 0x200286E3 );
    64 const TInt KPSCategoryUid( 0x200286E3 );
    66 const TInt KPSCrashCountKey( 1 );     
    65 const TInt KPSCrashCountKey( 1 );     
    67 const TInt KStabilityInterval( 60000000 ); // 1 minute
    66 const TInt KStabilityInterval( 60000000 ); // 1 minute
    68 const TInt KActivationCompleteInterval( 2000000 ); // 2s
    67 const TInt KActivationCompleteInterval( 2000000 ); // 2s
   890 // -----------------------------------------------------------------------------
   889 // -----------------------------------------------------------------------------
   891 // CXnViewManager::ActivateNextViewL()
   890 // CXnViewManager::ActivateNextViewL()
   892 // Activates the next view
   891 // Activates the next view
   893 // -----------------------------------------------------------------------------
   892 // -----------------------------------------------------------------------------
   894 //
   893 //
   895 void CXnViewManager::ActivateNextViewL( TInt /*aEffectId*/ )
   894 void CXnViewManager::ActivateNextViewL()
   896     { 
   895     { 
   897     CXnViewData& next( NextViewData() );
   896     CXnViewData& next( NextViewData() );
   898     
   897     ActivateViewL( next, KGfxContextActivateNextView );
   899     if ( !next.Occupied() )
       
   900         {    
       
   901         TInt err( next.Load() );
       
   902         
       
   903         if ( err )
       
   904             {
       
   905             HandleErrorNotes( err );            
       
   906             return;            
       
   907             }
       
   908         }
       
   909         
       
   910     // Activate view
       
   911     if ( next.Occupied() && !next.Active() )
       
   912         {
       
   913         iAppUiAdapter.ViewAdapter().ActivateContainerL( 
       
   914             next, EFalse, KGfxContextActivateNextView );                        
       
   915         }
       
   916     }
   898     }
   917 
   899 
   918 // -----------------------------------------------------------------------------
   900 // -----------------------------------------------------------------------------
   919 // CXnViewManager::ActivatePreviousViewL()
   901 // CXnViewManager::ActivatePreviousViewL()
   920 // Activates the previous view
   902 // Activates the previous view
   921 // -----------------------------------------------------------------------------
   903 // -----------------------------------------------------------------------------
   922 //
   904 //
   923 void CXnViewManager::ActivatePreviousViewL( TInt /*aEffectId*/ )
   905 void CXnViewManager::ActivatePreviousViewL()
   924     {    
   906     {    
   925     CXnViewData& prev( PreviousViewData() );
   907     CXnViewData& prev( PreviousViewData() );
   926 
   908     ActivateViewL( prev, KGfxContextActivatePrevView );
   927     if ( !prev.Occupied() )
   909     }
   928         {
   910 
   929         TInt err( prev.Load() );
   911 // -----------------------------------------------------------------------------
       
   912 // CXnViewManager::ActivatePreviousViewL()
       
   913 // Activates the previous view
       
   914 // -----------------------------------------------------------------------------
       
   915 //
       
   916 void CXnViewManager::ActivateViewL( CXnViewData& aViewData, TUid aEffect, 
       
   917     TBool aUpdateBg )
       
   918     {    
       
   919     if ( !aViewData.Occupied() )
       
   920         {
       
   921         TInt err( aViewData.Load() );
   930         
   922         
   931         if ( err )
   923         if ( err )
   932             {
   924             {
   933             HandleErrorNotes( err );            
   925             HandleErrorNotes( err );            
   934             return;            
   926             return;            
   935             }    
   927             }    
   936         }
   928         }
   937         
   929         
   938     // Activate view
   930     // Activate view
   939     if ( prev.Occupied() && !prev.Active() )
   931     if ( aViewData.Occupied() && !aViewData.Active() )
   940         {
   932         {
   941         iAppUiAdapter.ViewAdapter().ActivateContainerL( 
   933         iAppUiAdapter.ViewAdapter().ActivateContainerL( 
   942             prev, EFalse, KGfxContextActivatePrevView );                                
   934             aViewData, EFalse, aEffect, aUpdateBg );
   943         }
   935         }
   944     }
   936     }
   945 
   937 
   946 // -----------------------------------------------------------------------------
   938 // -----------------------------------------------------------------------------
   947 // CXnViewManager::AddViewL()
   939 // CXnViewManager::AddViewL()
   952     {    
   944     {    
   953     if ( iRootData->PluginData().Count() >= iRootData->MaxPages() )
   945     if ( iRootData->PluginData().Count() >= iRootData->MaxPages() )
   954         {
   946         {
   955         return KErrGeneral;
   947         return KErrGeneral;
   956         }
   948         }
   957 
   949     
       
   950     // If phone layout is mirrored new view needs to be added to left. Other right.
       
   951     TInt mirror = AknLayoutUtils::LayoutMirrored() ? 0 : 1;
       
   952     
   958     // Add new view (template view) to hsps
   953     // Add new view (template view) to hsps
   959     CAddPluginResult* result = iHspsWrapper->AddPluginL( 
   954     CAddPluginResult* result = iHspsWrapper->AddPluginL( 
   960         iRootData->ConfigurationId(), aInfo.Uid(),
   955         iRootData->ConfigurationId(), aInfo.Uid(),
   961         ViewIndex() + 1 ); 
   956         ViewIndex() + mirror ); 
   962     CleanupStack::PushL( result );
   957     CleanupStack::PushL( result );
   963 
   958 
   964     TInt retval( result->Status() );
   959     TInt retval( result->Status() );
   965     
   960     
   966     if( retval == KErrDiskFull )
   961     if( retval == KErrDiskFull )
   985             // Load succeed, add the new view behind the current view               
   980             // Load succeed, add the new view behind the current view               
   986             RPointerArray< CXnPluginData >& views( iRootData->PluginData() );
   981             RPointerArray< CXnPluginData >& views( iRootData->PluginData() );
   987             
   982             
   988             TInt index( views.Find( &ActiveViewData() ) );
   983             TInt index( views.Find( &ActiveViewData() ) );
   989             
   984             
   990             views.InsertL( newView, index + 1 );
   985             views.InsertL( newView, index + mirror );
   991             
   986             
   992             // Root data owns the new view now
   987             // Root data owns the new view now
   993             CleanupStack::Pop( newView );            
   988             CleanupStack::Pop( newView );            
   994 
   989 
   995             // Inform observers about added view
   990             // Inform observers about added view
  1028         { 
  1023         { 
  1029         TRAP_IGNORE( ShowErrorL( R_QTN_HS_MAX_AMOUNT_OF_PAGES_NOTE ) );
  1024         TRAP_IGNORE( ShowErrorL( R_QTN_HS_MAX_AMOUNT_OF_PAGES_NOTE ) );
  1030         
  1025         
  1031         return;        
  1026         return;        
  1032         }
  1027         }
  1033 
  1028     
       
  1029     // If phone layout is mirrored new view needs to be added to left. Other right.
       
  1030     TInt mirror = AknLayoutUtils::LayoutMirrored() ? 0 : 1;
       
  1031     
  1034     // Add new view (template view) to hsps
  1032     // Add new view (template view) to hsps
  1035     CAddPluginResult* result = iHspsWrapper->AddPluginL( 
  1033     CAddPluginResult* result = iHspsWrapper->AddPluginL( 
  1036         iRootData->ConfigurationId(), KTemplateViewUID,
  1034         iRootData->ConfigurationId(), iRootData->TemplateViewUid(),
  1037         ViewIndex() + 1 ); 
  1035         ViewIndex() + mirror ); 
  1038     CleanupStack::PushL( result );
  1036     CleanupStack::PushL( result );
  1039         
  1037         
  1040     TInt status( result->Status() );
  1038     TInt status( result->Status() );
  1041     
  1039     
  1042     if( status == KErrDiskFull )
  1040     if( status == KErrDiskFull )
  1068             // Load succeed, add the new view behind the current view               
  1066             // Load succeed, add the new view behind the current view               
  1069             RPointerArray< CXnPluginData >& views( iRootData->PluginData() );
  1067             RPointerArray< CXnPluginData >& views( iRootData->PluginData() );
  1070             
  1068             
  1071             TInt index( views.Find( &ActiveViewData() ) );
  1069             TInt index( views.Find( &ActiveViewData() ) );
  1072             
  1070             
  1073             views.InsertL( newView, index + 1 );
  1071             views.InsertL( newView, index + mirror );
  1074             
  1072             
  1075             // Root data owns the new view now
  1073             // Root data owns the new view now
  1076             CleanupStack::Pop( newView );
  1074             CleanupStack::Pop( newView );
  1077             
  1075             
  1078             // Activate view
       
  1079             iAppUiAdapter.ViewAdapter().ActivateContainerL( *newView, ETrue );
       
  1080             
       
  1081             // Inform observers about added view
  1076             // Inform observers about added view
  1082             NotifyViewAdditionL( *newView );
  1077             NotifyViewAdditionL( *newView );
       
  1078 
       
  1079             // Activate view
       
  1080             iAppUiAdapter.ViewAdapter().ActivateContainerL( *newView, ETrue );            
  1083             }
  1081             }
  1084         else
  1082         else
  1085             {                      
  1083             {                      
  1086             // creation failed, remove it from hsps
  1084             // creation failed, remove it from hsps
  1087             iHspsWrapper->RemovePluginL( result->PluginId() );
  1085             iHspsWrapper->RemovePluginL( result->PluginId() );
  1409 
  1407 
  1410         // Cache update is needed after view activation
  1408         // Cache update is needed after view activation
  1411         UpdateCachesL();
  1409         UpdateCachesL();
  1412         
  1410         
  1413         // Schedule remaining views loading
  1411         // Schedule remaining views loading
  1414         iRootData->LoadRemainingViews();
  1412         iRootData->LoadRemainingViewsL();
  1415         }
  1413         }
  1416     
  1414     
  1417     HandleErrorNotes( err );         
  1415     HandleErrorNotes( err );         
  1418                
  1416                
  1419     NotifyViewActivatedL( aViewToActivate );           
  1417     NotifyViewActivatedL( aViewToActivate );           
  1483 
  1481 
  1484     CXnBackgroundManager& bg( self->iAppUiAdapter.ViewAdapter().BgManager() ); 
  1482     CXnBackgroundManager& bg( self->iAppUiAdapter.ViewAdapter().BgManager() ); 
  1485         
  1483         
  1486     TRAP_IGNORE( bg.StoreWallpaperL() );
  1484     TRAP_IGNORE( bg.StoreWallpaperL() );
  1487 
  1485 
  1488     self->NotifyContainerActivatedL( active );
  1486     TRAP_IGNORE( self->NotifyContainerActivatedL( active ) );
  1489     
  1487     
  1490     return KErrNone;
  1488     return KErrNone;
  1491     }
  1489     }
  1492 
  1490 
  1493 // -----------------------------------------------------------------------------
  1491 // -----------------------------------------------------------------------------
  1501     ReportWidgetAmountL( aViewData );
  1499     ReportWidgetAmountL( aViewData );
  1502 
  1500 
  1503     for ( TInt i = 0; i < iObservers.Count(); i++ )
  1501     for ( TInt i = 0; i < iObservers.Count(); i++ )
  1504         {
  1502         {
  1505         iObservers[i]->NotifyViewActivatedL( aViewData );
  1503         iObservers[i]->NotifyViewActivatedL( aViewData );
       
  1504         }
       
  1505     }
       
  1506 
       
  1507 // -----------------------------------------------------------------------------
       
  1508 // CXnViewManager::NotifyViewLoadedL()
       
  1509 // Notifies view is activated
       
  1510 // -----------------------------------------------------------------------------
       
  1511 //
       
  1512 void CXnViewManager::NotifyViewLoadedL( const CXnViewData& aViewData )
       
  1513     {
       
  1514     for ( TInt i = 0; i < iObservers.Count(); i++ )
       
  1515         {
       
  1516         iObservers[i]->NotifyViewLoadedL( aViewData );
  1506         }
  1517         }
  1507     }
  1518     }
  1508 
  1519 
  1509 // -----------------------------------------------------------------------------
  1520 // -----------------------------------------------------------------------------
  1510 // CXnViewManager::NotifyViewDeactivatedL()
  1521 // CXnViewManager::NotifyViewDeactivatedL()