idlehomescreen/xmluirendering/uiengine/src/xnviewmanager.cpp
branchRCL_3
changeset 12 9674c1a575e9
parent 11 ff572dfe6d86
child 17 b8fae6b8a148
equal deleted inserted replaced
11:ff572dfe6d86 12:9674c1a575e9
    23 #include <StringLoader.h>
    23 #include <StringLoader.h>
    24 #include <xnuiengine.rsg>
    24 #include <xnuiengine.rsg>
    25 #include <aknnotewrappers.h>
    25 #include <aknnotewrappers.h>
    26 #include <AknsConstants.h>
    26 #include <AknsConstants.h>
    27 #include <aifwdefs.h>
    27 #include <aifwdefs.h>
       
    28 #include <gfxtranseffect/gfxtranseffect.h>
       
    29 #include <akntransitionutils.h>
    28 
    30 
    29 // User includes
    31 // User includes
    30 #include "xnapplication.h"
    32 #include "xnapplication.h"
    31 #include "xnuiengine.h"
    33 #include "xnuiengine.h"
    32 #include "xnproperty.h"
    34 #include "xnproperty.h"
    56 
    58 
    57 // Constants
    59 // Constants
    58 _LIT8( KEmptyWidgetUid, "0x2001f47f" );
    60 _LIT8( KEmptyWidgetUid, "0x2001f47f" );
    59 _LIT8( KTemplateViewUID, "0x20026f50" );
    61 _LIT8( KTemplateViewUID, "0x20026f50" );
    60 
    62 
    61 const TInt KPSCategoryUid = 0x200286E3;
    63 const TInt KPSCategoryUid( 0x200286E3 );
    62 const TInt KPSCrashCountKey = 1;     
    64 const TInt KPSCrashCountKey( 1 );     
    63 const TInt KStabilityInterval = 60000000; // 1 minute
    65 const TInt KStabilityInterval( 60000000 ); // 1 minute
    64 const TInt KCrashRestoreThreshold = 3;
    66 const TInt KCrashRestoreThreshold( 3 );
    65 
    67 
    66 // ============================ LOCAL FUNCTIONS ===============================
    68 // ============================ LOCAL FUNCTIONS ===============================
    67 // -----------------------------------------------------------------------------
    69 // -----------------------------------------------------------------------------
    68 // BuildTriggerL
    70 // BuildTriggerL
    69 // Builds a trigger node
    71 // Builds a trigger node
   275 //
   277 //
   276 CXnViewManager::~CXnViewManager()
   278 CXnViewManager::~CXnViewManager()
   277     {
   279     {
   278     delete iUiStartupPhase;
   280     delete iUiStartupPhase;
   279     
   281     
   280     if( iStabilityTimer )
   282     delete iStabilityTimer;
   281         {
       
   282         iStabilityTimer->Cancel();
       
   283         delete iStabilityTimer;
       
   284         iStabilityTimer = NULL;
       
   285         }
       
   286     
   283     
   287     iObservers.Reset();
   284     iObservers.Reset();
   288     
   285     
   289     delete iRootData;
   286     delete iRootData;
   290     
   287     
   312 //
   309 //
   313 void CXnViewManager::PropertyChangedL( const TUint32 aKey, const TInt aValue )
   310 void CXnViewManager::PropertyChangedL( const TUint32 aKey, const TInt aValue )
   314     {
   311     {
   315     if ( aKey == KPSStartupUiPhase && aValue == EStartupUiPhaseAllDone )
   312     if ( aKey == KPSStartupUiPhase && aValue == EStartupUiPhaseAllDone )
   316         {
   313         {
   317         if ( iRootData )
   314 	    iUiStartupPhaseAllDone = ETrue;
   318             {
   315 				
   319             iRootData->LoadRemainingViews();
   316         iAppUiAdapter.ViewAdapter().ActivateContainerL( ActiveViewData() );    
   320             }
   317         }
   321         }
   318     
   322     }
   319     iUiStartupPhaseAllDone = ETrue;
   323 
   320     }
       
   321 
       
   322 // -----------------------------------------------------------------------------
       
   323 // CXnViewManager::UiStartupPhaseAllDone()
       
   324 // 
       
   325 // -----------------------------------------------------------------------------
       
   326 //
       
   327 TBool CXnViewManager::UiStartupPhaseAllDone() const
       
   328     {
       
   329     return iUiStartupPhaseAllDone;        
       
   330     }
       
   331     
   324 // -----------------------------------------------------------------------------
   332 // -----------------------------------------------------------------------------
   325 // CXnViewManager::ConstructL()
   333 // CXnViewManager::ConstructL()
   326 // 2nd phase constructor
   334 // 2nd phase constructor
   327 // -----------------------------------------------------------------------------
   335 // -----------------------------------------------------------------------------
   328 //
   336 //
   348     // Robustness checks.
   356     // Robustness checks.
   349     TInt crashCount = 0;
   357     TInt crashCount = 0;
   350     RProperty::Get( TUid::Uid( KPSCategoryUid ),
   358     RProperty::Get( TUid::Uid( KPSCategoryUid ),
   351                     KPSCrashCountKey,
   359                     KPSCrashCountKey,
   352                     crashCount );    
   360                     crashCount );    
   353     
   361             
   354     if( crashCount >= KCrashRestoreThreshold )
   362     if( crashCount >= KCrashRestoreThreshold )
   355         {
   363         {
   356         iHspsWrapper->RestoreRootL();
   364         iHspsWrapper->RestoreRootL();
   357         ResetCrashCount();        
   365         ResetCrashCount();        
   358         ShowErrorNoteL( R_QTN_HS_ERROR_WIDGETS_REMOVED );        
   366         ShowErrorNoteL( R_QTN_HS_ERROR_WIDGETS_REMOVED );        
   364         // then crash count is reset to 0. 
   372         // then crash count is reset to 0. 
   365         iStabilityTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   373         iStabilityTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   366         iStabilityTimer->Start( KStabilityInterval,
   374         iStabilityTimer->Start( KStabilityInterval,
   367                                 KStabilityInterval,
   375                                 KStabilityInterval,
   368                                 TCallBack( SystemStabileTimerCallback, this ) );
   376                                 TCallBack( SystemStabileTimerCallback, this ) );
   369         }
   377         }       
   370     }
   378     }
   371 
   379 
   372 // -----------------------------------------------------------------------------
   380 // -----------------------------------------------------------------------------
   373 // CXnViewManager::LoadUiL()
   381 // CXnViewManager::LoadUiL()
   374 // Loads the application UI and initial view
   382 // Loads the application UI and initial view
   387     CleanupStack::PopAndDestroy(); // DisableRenderUiLC();
   395     CleanupStack::PopAndDestroy(); // DisableRenderUiLC();
   388     
   396     
   389     // Determine UI startup phase
   397     // Determine UI startup phase
   390     delete iUiStartupPhase;
   398     delete iUiStartupPhase;
   391     iUiStartupPhase = NULL;
   399     iUiStartupPhase = NULL;
       
   400     
       
   401     iUiStartupPhaseAllDone = EFalse;
   392                    
   402                    
   393     iUiStartupPhase = CXnPropertySubscriber::NewL( 
   403     iUiStartupPhase = CXnPropertySubscriber::NewL( 
   394         KPSUidStartup, KPSStartupUiPhase, *this );
   404         KPSUidStartup, KPSStartupUiPhase, *this );
   395     }
   405     }
   396 
   406 
   894 //
   904 //
   895 CXnViewData& CXnViewManager::NextViewData() const
   905 CXnViewData& CXnViewManager::NextViewData() const
   896     {
   906     {
   897     return iRootData->NextViewData();
   907     return iRootData->NextViewData();
   898     }
   908     }
   899 
   909     
   900 // -----------------------------------------------------------------------------
   910 // -----------------------------------------------------------------------------
   901 // CXnViewManager::ActivateNextViewL()
   911 // CXnViewManager::ActivateNextViewL()
   902 // Activates the next view
   912 // Activates the next view
   903 // -----------------------------------------------------------------------------
   913 // -----------------------------------------------------------------------------
   904 //
   914 //
   905 void CXnViewManager::ActivateNextViewL( TInt aEffectId )
   915 void CXnViewManager::ActivateNextViewL( TInt /*aEffectId*/ )
   906     {    
   916     { 
   907     CXnViewData& next( NextViewData() );
   917     CXnViewData& next( NextViewData() );
   908     
   918     
   909     if ( !next.Occupied() )
   919     if ( !next.Occupied() )
   910         {                
   920         {                
   911         if ( next.Load() == KErrNoMemory )
   921         if ( next.Load() == KErrNoMemory )
   912             {
   922             {
   913             next.ShowOutOfMemError();
   923             next.ShowOutOfMemError();
       
   924             
       
   925             return;
   914             }
   926             }
   915         }
   927         }
   916         
   928         
   917     // Activate view
   929     // Activate view
   918     if ( next.Occupied() && !next.Active() )
   930     if ( next.Occupied() && !next.Active() )
   919         {       
   931         {       
   920         if( aEffectId )
   932         CXnControlAdapter* thisView( 
   921             {
   933             ActiveViewData().ViewNode()->Control() );                
   922             iUiEngine->AppUiAdapter().EffectManager()->BeginFullscreenEffectL(
   934         
   923                     aEffectId, iUiEngine->ViewManager()->ActiveViewData() );        
   935         CXnControlAdapter* nextView( 
   924             }
   936             next.ViewNode()->Control() );
   925         iAppUiAdapter.ViewAdapter().ActivateContainerL( next );                
   937     
       
   938         GfxTransEffect::Register( thisView, KGfxContextActivateNextView );    
       
   939         GfxTransEffect::Register( nextView, KGfxContextActivateNextView );
       
   940         
       
   941         TInt ret( GfxTransEffect::BeginGroup() );
       
   942         
       
   943         CCoeControl* bg( &iAppUiAdapter.ViewAdapter().BgManager() );
       
   944         
       
   945         GfxTransEffect::Begin( bg, KGfxControlActionAppear );
       
   946 
       
   947         GfxTransEffect::SetDemarcation( bg, bg->Position() );
       
   948         GfxTransEffect::End( bg );        
       
   949         
       
   950         GfxTransEffect::Begin( thisView, KGfxControlActionDisappear );
       
   951         
       
   952         iAppUiAdapter.ViewAdapter().ActivateContainerL( next );
       
   953         
       
   954         GfxTransEffect::SetDemarcation( thisView, thisView->Position() );
       
   955         GfxTransEffect::End( thisView );
       
   956                 
       
   957         GfxTransEffect::Begin( nextView, KGfxControlActionAppear );
       
   958         GfxTransEffect::SetDemarcation( nextView, nextView->Position() );
       
   959         GfxTransEffect::End( nextView );
       
   960                                 
       
   961         GfxTransEffect::EndGroup( ret );
       
   962         
       
   963         GfxTransEffect::Deregister( thisView );
       
   964         GfxTransEffect::Deregister( nextView );
   926         }
   965         }
   927     }
   966     }
   928 
   967 
   929 // -----------------------------------------------------------------------------
   968 // -----------------------------------------------------------------------------
   930 // CXnViewManager::ActivatePreviousViewL()
   969 // CXnViewManager::ActivatePreviousViewL()
   931 // Activates the previous view
   970 // Activates the previous view
   932 // -----------------------------------------------------------------------------
   971 // -----------------------------------------------------------------------------
   933 //
   972 //
   934 void CXnViewManager::ActivatePreviousViewL( TInt aEffectId )
   973 void CXnViewManager::ActivatePreviousViewL( TInt /*aEffectId*/ )
   935     {    
   974     {    
   936     CXnViewData& prev( PreviousViewData() );
   975     CXnViewData& prev( PreviousViewData() );
   937 
   976 
   938     if ( !prev.Occupied() )
   977     if ( !prev.Occupied() )
   939         {
   978         {
   940         if ( prev.Load() == KErrNoMemory )
   979         if ( prev.Load() == KErrNoMemory )
   941             {
   980             {
   942             prev.ShowOutOfMemError();
   981             prev.ShowOutOfMemError();
       
   982             
       
   983             return;
   943             }
   984             }
   944         }
   985         }
   945         
   986         
   946     // Activate view
   987     // Activate view
   947     if ( prev.Occupied() && !prev.Active() )
   988     if ( prev.Occupied() && !prev.Active() )
   948         {
   989         {
   949         if( aEffectId  )
   990         CXnControlAdapter* thisView( 
   950             {
   991             ActiveViewData().ViewNode()->Control() ); 
   951             iUiEngine->AppUiAdapter().EffectManager()->BeginFullscreenEffectL(
   992         
   952                     aEffectId, iUiEngine->ViewManager()->ActiveViewData() );        
   993         CXnControlAdapter* prevView( 
   953             }
   994             prev.ViewNode()->Control() );
       
   995 
       
   996         GfxTransEffect::Register( thisView, KGfxContextActivatePrevView );    
       
   997         GfxTransEffect::Register( prevView, KGfxContextActivatePrevView );
       
   998     
       
   999         TInt ret( GfxTransEffect::BeginGroup() );
       
  1000             
       
  1001         CCoeControl* bg( &iAppUiAdapter.ViewAdapter().BgManager() );
       
  1002         
       
  1003         GfxTransEffect::Begin( bg, KGfxControlActionAppear );
       
  1004     
       
  1005         GfxTransEffect::SetDemarcation( bg, bg->Position() );
       
  1006         GfxTransEffect::End( bg );        
       
  1007         
       
  1008         GfxTransEffect::Begin( thisView, KGfxControlActionDisappear );
       
  1009         
   954         iAppUiAdapter.ViewAdapter().ActivateContainerL( prev );
  1010         iAppUiAdapter.ViewAdapter().ActivateContainerL( prev );
       
  1011         
       
  1012         GfxTransEffect::SetDemarcation( thisView, thisView->Position() );
       
  1013         GfxTransEffect::End( thisView );
       
  1014                 
       
  1015         GfxTransEffect::Begin( prevView, KGfxControlActionAppear );
       
  1016                               
       
  1017         GfxTransEffect::SetDemarcation( prevView, prevView->Position() );
       
  1018         GfxTransEffect::End( prevView );
       
  1019                                 
       
  1020         GfxTransEffect::EndGroup( ret );
       
  1021         
       
  1022         GfxTransEffect::Deregister( thisView );
       
  1023         GfxTransEffect::Deregister( prevView );        
   955         }
  1024         }
   956     }
  1025     }
   957 
  1026 
   958 // -----------------------------------------------------------------------------
  1027 // -----------------------------------------------------------------------------
   959 // CXnViewManager::AddViewL()
  1028 // CXnViewManager::AddViewL()
  1086         if ( newView->Occupied() )
  1155         if ( newView->Occupied() )
  1087             {
  1156             {
  1088             // Start transition effect
  1157             // Start transition effect
  1089             if( aEffectId )
  1158             if( aEffectId )
  1090                 {
  1159                 {
  1091                 iUiEngine->AppUiAdapter().EffectManager()->BeginFullscreenEffectL(
  1160                 iAppUiAdapter.EffectManager()->BeginFullscreenEffectL(
  1092                         aEffectId, iUiEngine->ViewManager()->ActiveViewData() );        
  1161                         aEffectId, ActiveViewData() );        
  1093                 }
  1162                 }
  1094 
  1163 
  1095             // Load succeed, add the new view behind the current view               
  1164             // Load succeed, add the new view behind the current view               
  1096             RPointerArray< CXnPluginData >& views( iRootData->PluginData() );
  1165             RPointerArray< CXnPluginData >& views( iRootData->PluginData() );
  1097             
  1166             
  1210     if ( query->RunLD() )
  1279     if ( query->RunLD() )
  1211         { 
  1280         { 
  1212         // Start transition effect
  1281         // Start transition effect
  1213         if( aEffectId )
  1282         if( aEffectId )
  1214             {
  1283             {
  1215             iUiEngine->AppUiAdapter().EffectManager()->BeginFullscreenEffectL(
  1284             iAppUiAdapter.EffectManager()->BeginFullscreenEffectL(
  1216                     aEffectId, iUiEngine->ViewManager()->ActiveViewData() );        
  1285                     aEffectId, ActiveViewData() );        
  1217             }
  1286             }
  1218 
  1287 
  1219         // Activate the next view, or first if in the last view 
  1288         // Activate the next view, or first if in the last view 
  1220         CXnViewData& next( NextViewData() );
  1289         CXnViewData& next( NextViewData() );
  1221 
  1290 
  1371 // CXnViewManager::NotifyContainerChangedL()
  1440 // CXnViewManager::NotifyContainerChangedL()
  1372 // Notifies container is changed, this is called always by CXnViewAdapter
  1441 // Notifies container is changed, this is called always by CXnViewAdapter
  1373 // -----------------------------------------------------------------------------
  1442 // -----------------------------------------------------------------------------
  1374 void CXnViewManager::NotifyContainerChangedL( CXnViewData& aViewToActivate )
  1443 void CXnViewManager::NotifyContainerChangedL( CXnViewData& aViewToActivate )
  1375     {
  1444     {
  1376 #ifdef _XN_PERFORMANCE_TEST_
       
  1377     RDebug::Print( _L( "CXnViewManager::NotifyContainerChangedL - start" ) );
       
  1378 #endif //_XN_PERFORMANCE_TEST_        
       
  1379                      
       
  1380     CXnViewData& viewToDeactivate( ActiveViewData() );
  1445     CXnViewData& viewToDeactivate( ActiveViewData() );
  1381     
  1446     
  1382     if ( &aViewToActivate != &viewToDeactivate )
  1447     if ( &aViewToActivate != &viewToDeactivate )
  1383         {        
  1448         {        
  1384         NotifyViewDeactivatedL( viewToDeactivate );
  1449         NotifyViewDeactivatedL( viewToDeactivate );
  1385                       
  1450                       
  1386         viewToDeactivate.SetActive( EFalse );
  1451         viewToDeactivate.SetActive( EFalse );
  1387         aViewToActivate.SetActive( ETrue );
  1452         aViewToActivate.SetActive( ETrue );
  1388         
  1453                              
  1389         iHspsWrapper->SetActivePluginL( aViewToActivate.PluginId() );
  1454         iHspsWrapper->SetActivePluginL( aViewToActivate.PluginId() ); 
  1390 
  1455                     
  1391         // Cache update is needed after view activation
  1456         // Cache update is needed after view activation
  1392         UpdateCachesL();       
  1457         UpdateCachesL();               
  1393         UpdateWallpaperL( viewToDeactivate, aViewToActivate );
       
  1394         }
  1458         }
  1395     else
  1459     else
  1396         {
  1460         {
  1397         // Activate first view
  1461         // Activate first view
  1398         aViewToActivate.SetActive( ETrue );
  1462         aViewToActivate.SetActive( ETrue );
  1399 
  1463 
  1400         // Cache update is needed after view activation
  1464         // Cache update is needed after view activation
  1401         UpdateCachesL();
  1465         UpdateCachesL();
       
  1466         
       
  1467         // Schedule remaining views loading
       
  1468         iRootData->LoadRemainingViews();
  1402         }
  1469         }
  1403     
  1470     
  1404     NotifyViewActivatedL( aViewToActivate );
  1471     NotifyViewActivatedL( aViewToActivate );
  1405     UpdatePageManagementInformationL();
  1472     UpdatePageManagementInformationL();
  1406     
       
  1407     #ifdef _XN_PERFORMANCE_TEST_
       
  1408     RDebug::Print( _L( "CXnViewManager::NotifyContainerChangedL - end" ) );
       
  1409 #endif //_XN_PERFORMANCE_TEST_
       
  1410     }
  1473     }
  1411 
  1474 
  1412 // -----------------------------------------------------------------------------
  1475 // -----------------------------------------------------------------------------
  1413 // CXnViewManager::NotifyViewActivatedL()
  1476 // CXnViewManager::NotifyViewActivatedL()
  1414 // Notifies view is activated
  1477 // Notifies view is activated
  1589                 ->SetStringValueL( CXnDomPropertyValue::EString, value );
  1652                 ->SetStringValueL( CXnDomPropertyValue::EString, value );
  1590             }
  1653             }
  1591         }
  1654         }
  1592 
  1655 
  1593     node->ReportXuikonEventL( *iWidgetAmountTrigger );
  1656     node->ReportXuikonEventL( *iWidgetAmountTrigger );
  1594     }
       
  1595 
       
  1596 // -----------------------------------------------------------------------------
       
  1597 // CXnViewManager::UpdateWallpaperL
       
  1598 // -----------------------------------------------------------------------------
       
  1599 //
       
  1600 void CXnViewManager::UpdateWallpaperL( CXnViewData& aCurrent, CXnViewData& aNew )
       
  1601     {
       
  1602     iAppUiAdapter.ViewAdapter().BgManager().WallpaperChanged( aCurrent, aNew );
       
  1603     }
  1657     }
  1604 
  1658 
  1605 // -----------------------------------------------------------------------------
  1659 // -----------------------------------------------------------------------------
  1606 // CXnViewManager::ShowOperationFailedMessageL
  1660 // CXnViewManager::ShowOperationFailedMessageL
  1607 // -----------------------------------------------------------------------------
  1661 // -----------------------------------------------------------------------------