idlehomescreen/xmluirendering/uiengine/src/xnviewmanager.cpp
branchRCL_3
changeset 9 f966699dea19
parent 5 c743ef5928ba
child 15 ff572dfe6d86
equal deleted inserted replaced
5:c743ef5928ba 9:f966699dea19
    20 #include <AknsWallpaperUtils.h>
    20 #include <AknsWallpaperUtils.h>
    21 #include <AknSkinsInternalCRKeys.h>
    21 #include <AknSkinsInternalCRKeys.h>
    22 #include <StringLoader.h>
    22 #include <StringLoader.h>
    23 #include <xnuiengine.rsg>
    23 #include <xnuiengine.rsg>
    24 #include <aknnotewrappers.h>
    24 #include <aknnotewrappers.h>
    25 
       
    26 #include <AknsConstants.h>
    25 #include <AknsConstants.h>
    27 
    26 
    28 // User includes
    27 // User includes
    29 #include "xnapplication.h"
    28 #include "xnapplication.h"
    30 #include "xnuiengine.h"
    29 #include "xnuiengine.h"
    49 #include "xnmenuadapter.h"
    48 #include "xnmenuadapter.h"
    50 #include "xncomponentnodeimpl.h"
    49 #include "xncomponentnodeimpl.h"
    51 #include "xnnodepluginif.h"
    50 #include "xnnodepluginif.h"
    52 #include "xnoomsyshandler.h"
    51 #include "xnoomsyshandler.h"
    53 #include "xnbackgroundmanager.h"
    52 #include "xnbackgroundmanager.h"
       
    53 #include "xneffectmanager.h"
    54 
    54 
    55 // Constants
    55 // Constants
    56 _LIT8( KEmptyWidgetUid, "0x2001f47f" );
    56 _LIT8( KEmptyWidgetUid, "0x2001f47f" );
    57 _LIT8( KStateError, "Error" );
       
    58 
       
    59 
       
    60 _LIT8( KTemplateViewUID, "0x20026f50" );
    57 _LIT8( KTemplateViewUID, "0x20026f50" );
    61 
    58 
    62 enum
    59 const TInt KPSCategoryUid = 0x200286E3;
    63     {
    60 const TInt KPSCrashCountKey = 1;     
    64     EFirstPassDrawComplete,
    61 const TInt KStabilityInterval = 60000000; // 1 minute
    65     EDataPluginsComplete,
    62 const TInt KCrashRestoreThreshold = 3;
    66     EViewIsValid,       
       
    67     };
       
    68 
       
    69 
       
    70 /*
       
    71 const TAknsItemID KSkinIds[] = {
       
    72         KAknsIIDQgnHomePage11,
       
    73         KAknsIIDQgnHomePage21,
       
    74         KAknsIIDQgnHomePage22,
       
    75         KAknsIIDQgnHomePage31,
       
    76         KAknsIIDQgnHomePage32,
       
    77         KAknsIIDQgnHomePage33,
       
    78         KAknsIIDQgnHomePage41,
       
    79         KAknsIIDQgnHomePage42,
       
    80         KAknsIIDQgnHomePage43,
       
    81         KAknsIIDQgnHomePage44,
       
    82         KAknsIIDQgnHomePage51,
       
    83         KAknsIIDQgnHomePage52,
       
    84         KAknsIIDQgnHomePage53,
       
    85         KAknsIIDQgnHomePage54,
       
    86         KAknsIIDQgnHomePage55,
       
    87         KAknsIIDQgnHomePage61,
       
    88         KAknsIIDQgnHomePage62,
       
    89         KAknsIIDQgnHomePage63,
       
    90         KAknsIIDQgnHomePage64,
       
    91         KAknsIIDQgnHomePage65,
       
    92         KAknsIIDQgnHomePage66
       
    93         }; 
       
    94 */        
       
    95 
       
    96 // ============================ LOCAL FUNCTIONS ===============================
    63 // ============================ LOCAL FUNCTIONS ===============================
    97 
       
    98 
       
    99 // -----------------------------------------------------------------------------
    64 // -----------------------------------------------------------------------------
   100 // BuildTriggerL
    65 // BuildTriggerL
   101 // Builds a trigger node
    66 // Builds a trigger node
   102 // -----------------------------------------------------------------------------
    67 // -----------------------------------------------------------------------------
   103 //
    68 //
   135     CleanupStack::Pop( value );
   100     CleanupStack::Pop( value );
   136 
   101 
   137     CleanupStack::Pop( node ); 
   102     CleanupStack::Pop( node ); 
   138 
   103 
   139     return node;
   104     return node;
   140     }
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // SetOnlineStateL
       
   144 // 
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 static void SetOnlineStateL( CXnAppUiAdapter& aAdapter, 
       
   148     CXnViewData& aViewData )
       
   149     {
       
   150     if( !aViewData.Active() )
       
   151         {
       
   152         // Only active view can change online/offline state
       
   153         return;
       
   154         }
       
   155     
       
   156     RPointerArray< CXnNode > nodes;
       
   157     CleanupClosePushL( nodes );
       
   158 
       
   159     RPointerArray< CXnNodeAppIf > list;
       
   160     CleanupClosePushL( list );
       
   161 
       
   162     aViewData.ContentSourceNodesL( nodes );
       
   163 
       
   164     for ( TInt i = 0; i < nodes.Count(); i++ )
       
   165         {
       
   166         list.AppendL( &nodes[i]->AppIfL() );
       
   167         }
       
   168 
       
   169     aAdapter.SetOnlineStateL( list );
       
   170 
       
   171     CleanupStack::PopAndDestroy( 2, &nodes ); // &list                                                 
       
   172     }
   105     }
   173 
   106 
   174 // -----------------------------------------------------------------------------
   107 // -----------------------------------------------------------------------------
   175 // resolveIconId
   108 // resolveIconId
   176 // -----------------------------------------------------------------------------
   109 // -----------------------------------------------------------------------------
   337 // C++ default destructor.
   270 // C++ default destructor.
   338 // -----------------------------------------------------------------------------
   271 // -----------------------------------------------------------------------------
   339 //
   272 //
   340 CXnViewManager::~CXnViewManager()
   273 CXnViewManager::~CXnViewManager()
   341     {
   274     {
       
   275     if( iStabilityTimer )
       
   276         {
       
   277         iStabilityTimer->Cancel();
       
   278         delete iStabilityTimer;
       
   279         iStabilityTimer = NULL;
       
   280         }
       
   281     
   342     iObservers.Reset();
   282     iObservers.Reset();
   343     
   283     
   344     delete iRootData;
   284     delete iRootData;
   345     
   285     
   346     delete iWidgetAmountTrigger;       
   286     delete iWidgetAmountTrigger;       
   352     
   292     
   353     delete iResources;
   293     delete iResources;
   354 
   294 
   355     iControls.Reset();
   295     iControls.Reset();
   356     iAppearanceNodes.Reset();
   296     iAppearanceNodes.Reset();
   357        
   297               
   358     iFailedPlugins.Reset();
       
   359     
       
   360     delete iComposer;
   298     delete iComposer;
   361     delete iEditor;
   299     delete iEditor;
   362     delete iOomSysHandler;
   300     delete iOomSysHandler;
   363     }
   301     }
   364 
   302 
   383     iEditor = CXnEditor::NewL( *this, uid );
   321     iEditor = CXnEditor::NewL( *this, uid );
   384 
   322 
   385     iHspsWrapper = &iEditor->HspsWrapper();
   323     iHspsWrapper = &iEditor->HspsWrapper();
   386     
   324     
   387     iComposer = CXnComposer::NewL( *iHspsWrapper );
   325     iComposer = CXnComposer::NewL( *iHspsWrapper );
       
   326     
       
   327     // Robustness checks.
       
   328     TInt crashCount = 0;
       
   329     RProperty::Get( TUid::Uid( KPSCategoryUid ),
       
   330                     KPSCrashCountKey,
       
   331                     crashCount );    
       
   332     
       
   333     if( crashCount >= KCrashRestoreThreshold )
       
   334         {
       
   335         iHspsWrapper->RestoreRootL();
       
   336         ResetCrashCount();        
       
   337         ShowErrorNoteL( R_QTN_HS_ERROR_WIDGETS_REMOVED );        
       
   338         }
       
   339     else if( crashCount > 0 )
       
   340         {
       
   341         // Start stability timer to ensure that
       
   342         // if system is stabile at least KStabilityInterval
       
   343         // then crash count is reset to 0. 
       
   344         iStabilityTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
   345         iStabilityTimer->Start( KStabilityInterval,
       
   346                                 KStabilityInterval,
       
   347                                 TCallBack( SystemStabileTimerCallback, this ) );
       
   348         }
   388     }
   349     }
   389 
   350 
   390 // -----------------------------------------------------------------------------
   351 // -----------------------------------------------------------------------------
   391 // CXnViewManager::LoadUiL()
   352 // CXnViewManager::LoadUiL()
   392 // Loads the application UI and initial view
   353 // Loads the application UI and initial view
   398     
   359     
   399     // Load application root configuration
   360     // Load application root configuration
   400     iRootData = CXnRootData::NewL( *this, iApplicationUid );
   361     iRootData = CXnRootData::NewL( *this, iApplicationUid );
   401            
   362            
   402     // Load root configuration and initial view.
   363     // Load root configuration and initial view.
   403     iRootData->LoadL();
   364     iRootData->Load();
   404     
   365            
   405     CleanupStack::PopAndDestroy(); // DisableRenderUiLC();
   366     CleanupStack::PopAndDestroy(); // DisableRenderUiLC();
   406     }
   367     }
   407 
   368 
   408 // -----------------------------------------------------------------------------
   369 // -----------------------------------------------------------------------------
   409 // CXnViewManager::ReloadUiL()
   370 // CXnViewManager::ReloadUiL()
   424     ActiveViewData().Destroy();
   385     ActiveViewData().Destroy();
   425          
   386          
   426     // Schedule application configuration destroyal
   387     // Schedule application configuration destroyal
   427     iRootData->Destroy();
   388     iRootData->Destroy();
   428     iRootData = NULL;
   389     iRootData = NULL;
   429     
   390        
   430     iFlags.ClearAll();
       
   431     
       
   432     User::Heap().Compress();
   391     User::Heap().Compress();
   433     
   392     
   434     LoadUiL();
   393     LoadUiL();
   435     
   394     
   436     // Activate first view from the new configuration
   395     // Activate first view from the new configuration
   500         {              
   459         {              
   501         iUiEngine->DisableRenderUiLC();
   460         iUiEngine->DisableRenderUiLC();
   502                                      
   461                                      
   503         NotifyConfigureWidgetL( aContentInfo, aPluginData );
   462         NotifyConfigureWidgetL( aContentInfo, aPluginData );
   504     
   463     
   505         aPluginData.LoadL();
   464         retval = aPluginData.Load();
   506                    
   465         
   507         UpdateCachesL();
   466         if ( retval == KErrNone )
   508     
   467             {
   509         NotifyWidgetAdditionL( aPluginData );
   468             UpdateCachesL();
   510 
   469         
   511         // Report widget amount in the view
   470             NotifyWidgetAdditionL( aPluginData );
   512         ReportWidgetAmountL( viewData );
   471 
       
   472             // Report widget amount in the view
       
   473             ReportWidgetAmountL( viewData );           
       
   474             }  
       
   475         else if ( retval == KErrNoMemory )
       
   476             {
       
   477             aPluginData.ShowOutOfMemError();
       
   478             }
       
   479         else if ( retval == KXnErrPluginFailure )
       
   480             {            
       
   481             aPluginData.ShowContentRemovedError();
       
   482             }
   513         
   483         
   514         CleanupStack::PopAndDestroy(); // DisableRenderUiLC
   484         CleanupStack::PopAndDestroy(); // DisableRenderUiLC
   515         }
   485         }
   516            
   486            
   517     return retval;
   487     return retval;
   519 
   489 
   520 // -----------------------------------------------------------------------------
   490 // -----------------------------------------------------------------------------
   521 // CXnViewManager::UnloadWidgetFromPluginL()
   491 // CXnViewManager::UnloadWidgetFromPluginL()
   522 // -----------------------------------------------------------------------------
   492 // -----------------------------------------------------------------------------
   523 //
   493 //
   524 TInt CXnViewManager::UnloadWidgetFromPluginL( CXnPluginData& aPluginData )    
   494 TInt CXnViewManager::UnloadWidgetFromPluginL( CXnPluginData& aPluginData, 
   525     {          
   495     TBool aForce )    
   526     TBool error( aPluginData.PluginState().CompareF( KStateError ) == 0 );
   496     {                  
   527     
   497     if ( !aForce && !aPluginData.Occupied() )
   528     // Plugins in error state are always removed
       
   529     if ( !error && !aPluginData.Occupied() )
       
   530         {
   498         {
   531         // Plugin must have widget when about to remove
   499         // Plugin must have widget when about to remove
   532         return KErrNotFound;            
   500         return KErrNotFound;            
   533         }
   501         }
   534     
   502     
   583         // Report widget amount in the view 
   551         // Report widget amount in the view 
   584         ReportWidgetAmountL( viewData );
   552         ReportWidgetAmountL( viewData );
   585         
   553         
   586         if ( active )
   554         if ( active )
   587             {            
   555             {            
   588             iUiEngine->RenderUIL();
   556             iUiEngine->RenderUIL();            
   589             SetOnlineStateL( iAppUiAdapter, ActiveViewData() );
       
   590             }
   557             }
   591                
   558                
   592         CleanupStack::PopAndDestroy(); // DisableRenderUiLC               
   559         CleanupStack::PopAndDestroy(); // DisableRenderUiLC               
   593         }
   560         }
   594 
   561 
   600 // -----------------------------------------------------------------------------
   567 // -----------------------------------------------------------------------------
   601 //
   568 //
   602 TInt CXnViewManager::ReplaceWidgetToPluginL( CHsContentInfo& aContentInfo,
   569 TInt CXnViewManager::ReplaceWidgetToPluginL( CHsContentInfo& aContentInfo,
   603     CXnPluginData& aPluginData, TBool aUseHsps )
   570     CXnPluginData& aPluginData, TBool aUseHsps )
   604     {
   571     {
   605     TInt ret = KErrNone;
   572     TInt retval( KErrNone );
   606     
   573     
   607     // if aUseHsps is false, the plugin was already replaced by
   574     // if aUseHsps is false, the plugin was already replaced by
   608     // another process
   575     // another process
   609     if( aUseHsps )
   576     if( aUseHsps )
   610         {
   577         {
   611         ret = iHspsWrapper->ReplacePluginL( aPluginData.PluginId(),
   578         retval = iHspsWrapper->ReplacePluginL( aPluginData.PluginId(),
   612                                            aContentInfo.Uid() );
   579                                            aContentInfo.Uid() );
   613         }
   580         }
   614 
   581 
   615     if ( ret == KErrNone )
   582     if ( retval == KErrNone )
   616         {
   583         {
   617         iUiEngine->DisableRenderUiLC();
   584         iUiEngine->DisableRenderUiLC();
   618         
   585         
   619         NotifyWidgetRemovalL( aPluginData );
   586         NotifyWidgetRemovalL( aPluginData );
   620 
   587 
   626         UpdateCachesL();
   593         UpdateCachesL();
   627         aPluginData.SetPluginIdL( id );
   594         aPluginData.SetPluginIdL( id );
   628         
   595         
   629         NotifyConfigureWidgetL( aContentInfo, aPluginData );
   596         NotifyConfigureWidgetL( aContentInfo, aPluginData );
   630         
   597         
   631         aPluginData.LoadL();
   598         retval = aPluginData.Load();
   632                                                                   
   599         
   633         UpdateCachesL();
   600         if ( retval == KErrNone )
   634         
   601             {
   635         // notify addition if not replaced with empty widget
   602             UpdateCachesL();
   636         // NotifyWidgetAdditionL will call RenderUIL()
   603             
   637         if( uid != KEmptyWidgetUid )
   604             // notify addition if not replaced with empty widget
   638             {
   605             // NotifyWidgetAdditionL will call RenderUIL()
   639             NotifyWidgetAdditionL( aPluginData );
   606             if( uid != KEmptyWidgetUid )
   640             }
       
   641         else
       
   642             {
       
   643             if( aPluginData.Active() )
       
   644                 {
   607                 {
   645                 iUiEngine->RenderUIL();
   608                 NotifyWidgetAdditionL( aPluginData );
   646                 }
   609                 }
   647             }
   610             else
   648         
   611                 {
       
   612                 if( aPluginData.Active() )
       
   613                     {
       
   614                     iUiEngine->RenderUIL();
       
   615                     }
       
   616                 }            
       
   617             }
       
   618         else if ( retval == KErrNoMemory )
       
   619             {
       
   620             aPluginData.ShowOutOfMemError();
       
   621             }
       
   622         else if ( retval == KXnErrPluginFailure )
       
   623             {            
       
   624             aPluginData.ShowContentRemovedError();
       
   625             }
       
   626                         
   649         CleanupStack::PopAndDestroy(); // DisableRenderUiLC
   627         CleanupStack::PopAndDestroy(); // DisableRenderUiLC
   650         }
   628         }
   651     
   629     
   652     return ret;
   630     return retval;
   653     }
   631     }
   654 
   632 
   655 // -----------------------------------------------------------------------------
   633 // -----------------------------------------------------------------------------
   656 // CXnViewManager::ODT()
   634 // CXnViewManager::ODT()
   657 // Get the ODT
   635 // Get the ODT
   856 // -----------------------------------------------------------------------------
   834 // -----------------------------------------------------------------------------
   857 // CXnViewManager::ActivateNextViewL()
   835 // CXnViewManager::ActivateNextViewL()
   858 // Activates the next view
   836 // Activates the next view
   859 // -----------------------------------------------------------------------------
   837 // -----------------------------------------------------------------------------
   860 //
   838 //
   861 void CXnViewManager::ActivateNextViewL()
   839 void CXnViewManager::ActivateNextViewL( TInt aEffectId )
   862     {
   840     {    
   863     CXnViewData& current( ActiveViewData() );
       
   864     CXnViewData& next( NextViewData() );
   841     CXnViewData& next( NextViewData() );
   865 
   842     
   866     if ( !next.Occupied() )
   843     if ( !next.Occupied() )
   867         {
   844         {                
   868         next.LoadL();
   845         if ( next.Load() == KErrNoMemory )
       
   846             {
       
   847             next.ShowOutOfMemError();
       
   848             }
   869         }
   849         }
   870         
   850         
   871     // Activate view
   851     // Activate view
   872     if ( next.Occupied() && !next.Active() )
   852     if ( next.Occupied() && !next.Active() )
   873         {            
   853         {       
       
   854         if( aEffectId )
       
   855             {
       
   856             iUiEngine->AppUiAdapter().EffectManager()->BeginFullscreenEffectL(
       
   857                     aEffectId, iUiEngine->ViewManager()->ActiveViewData() );        
       
   858             }
   874         iAppUiAdapter.ViewAdapter().ActivateContainerL( next );                
   859         iAppUiAdapter.ViewAdapter().ActivateContainerL( next );                
   875         }
   860         }
   876     }
   861     }
   877 
   862 
   878 // -----------------------------------------------------------------------------
   863 // -----------------------------------------------------------------------------
   879 // CXnViewManager::ActivatePreviousViewL()
   864 // CXnViewManager::ActivatePreviousViewL()
   880 // Activates the previous view
   865 // Activates the previous view
   881 // -----------------------------------------------------------------------------
   866 // -----------------------------------------------------------------------------
   882 //
   867 //
   883 void CXnViewManager::ActivatePreviousViewL()
   868 void CXnViewManager::ActivatePreviousViewL( TInt aEffectId )
   884     {
   869     {    
   885     CXnViewData& current( ActiveViewData() );
       
   886     CXnViewData& prev( PreviousViewData() );
   870     CXnViewData& prev( PreviousViewData() );
   887 
   871 
   888     if ( !prev.Occupied() )
   872     if ( !prev.Occupied() )
   889         {
   873         {
   890         prev.LoadL();
   874         if ( prev.Load() == KErrNoMemory )
       
   875             {
       
   876             prev.ShowOutOfMemError();
       
   877             }
   891         }
   878         }
   892         
   879         
   893     // Activate view
   880     // Activate view
   894     if ( prev.Occupied() && !prev.Active() )
   881     if ( prev.Occupied() && !prev.Active() )
   895         {   
   882         {
       
   883         if( aEffectId  )
       
   884             {
       
   885             iUiEngine->AppUiAdapter().EffectManager()->BeginFullscreenEffectL(
       
   886                     aEffectId, iUiEngine->ViewManager()->ActiveViewData() );        
       
   887             }
   896         iAppUiAdapter.ViewAdapter().ActivateContainerL( prev );
   888         iAppUiAdapter.ViewAdapter().ActivateContainerL( prev );
   897         }
   889         }
   898     }
   890     }
   899 
   891 
   900 // -----------------------------------------------------------------------------
   892 // -----------------------------------------------------------------------------
   928         
   920         
   929         newView->SetPluginIdL( result->PluginId() );
   921         newView->SetPluginIdL( result->PluginId() );
   930         
   922         
   931         newView->SetOwner( iRootData->Node() );
   923         newView->SetOwner( iRootData->Node() );
   932         
   924         
   933         newView->LoadL();
   925         retval = newView->Load();
   934                 
   926                 
       
   927         if ( retval == KErrNoMemory )
       
   928             {
       
   929             newView->ShowOutOfMemError();
       
   930             }
       
   931         
   935         if ( newView->Occupied() )
   932         if ( newView->Occupied() )
   936             {
   933             {
   937             // Load succeed, add the new view behind the current view               
   934             // Load succeed, add the new view behind the current view               
   938             RPointerArray< CXnPluginData >& views( iRootData->PluginData() );
   935             RPointerArray< CXnPluginData >& views( iRootData->PluginData() );
   939             
   936             
   972 // -----------------------------------------------------------------------------
   969 // -----------------------------------------------------------------------------
   973 // CXnViewManager::AddViewL()
   970 // CXnViewManager::AddViewL()
   974 // Adds a new view
   971 // Adds a new view
   975 // -----------------------------------------------------------------------------
   972 // -----------------------------------------------------------------------------
   976 //
   973 //
   977 void CXnViewManager::AddViewL()
   974 void CXnViewManager::AddViewL( TInt aEffectId )
   978     {
   975     {
   979     if ( iRootData->PluginData().Count() >= iRootData->MaxPages() ) 
   976     if ( iRootData->PluginData().Count() >= iRootData->MaxPages() ) 
   980         { 
   977         { 
   981         HBufC* msg( StringLoader::LoadLC( 
   978         HBufC* msg( StringLoader::LoadLC( 
   982             R_QTN_HS_MAX_AMOUNT_OF_PAGES_NOTE ) ); 
   979             R_QTN_HS_MAX_AMOUNT_OF_PAGES_NOTE ) ); 
  1011         
  1008         
  1012         newView->SetPluginIdL( result->PluginId() );
  1009         newView->SetPluginIdL( result->PluginId() );
  1013         
  1010         
  1014         newView->SetOwner( iRootData->Node() );
  1011         newView->SetOwner( iRootData->Node() );
  1015         
  1012         
  1016         newView->LoadL();
  1013         status = newView->Load();
  1017                 
  1014         
       
  1015         if ( status == KErrNoMemory )
       
  1016             {
       
  1017             newView->ShowOutOfMemError();
       
  1018             }
       
  1019         
  1018         if ( newView->Occupied() )
  1020         if ( newView->Occupied() )
  1019             {
  1021             {
       
  1022             // Start transition effect
       
  1023             if( aEffectId )
       
  1024                 {
       
  1025                 iUiEngine->AppUiAdapter().EffectManager()->BeginFullscreenEffectL(
       
  1026                         aEffectId, iUiEngine->ViewManager()->ActiveViewData() );        
       
  1027                 }
       
  1028 
  1020             // Load succeed, add the new view behind the current view               
  1029             // Load succeed, add the new view behind the current view               
  1021             RPointerArray< CXnPluginData >& views( iRootData->PluginData() );
  1030             RPointerArray< CXnPluginData >& views( iRootData->PluginData() );
  1022             
  1031             
  1023             TInt index( views.Find( &ActiveViewData() ) );
  1032             TInt index( views.Find( &ActiveViewData() ) );
  1024             
  1033             
  1104 // -----------------------------------------------------------------------------
  1113 // -----------------------------------------------------------------------------
  1105 // CXnViewManager::RemoveViewL()
  1114 // CXnViewManager::RemoveViewL()
  1106 // Removes active view if more than one view.
  1115 // Removes active view if more than one view.
  1107 // -----------------------------------------------------------------------------
  1116 // -----------------------------------------------------------------------------
  1108 //
  1117 //
  1109 void CXnViewManager::RemoveViewL()
  1118 void CXnViewManager::RemoveViewL( TInt aEffectId )
  1110     {   
  1119     {   
  1111     if ( iRootData->PluginData().Count() <= 1 || 
  1120     if ( iRootData->PluginData().Count() <= 1 || 
  1112         !ActiveViewData().Removable() )
  1121         !ActiveViewData().Removable() )
  1113         {
  1122         {
  1114         // Only one page left, this should not happen,  
  1123         // Only one page left, this should not happen,  
  1129     
  1138     
  1130     CleanupStack::PopAndDestroy( queryText );
  1139     CleanupStack::PopAndDestroy( queryText );
  1131 
  1140 
  1132     if ( query->RunLD() )
  1141     if ( query->RunLD() )
  1133         { 
  1142         { 
       
  1143         // Start transition effect
       
  1144         if( aEffectId )
       
  1145             {
       
  1146             iUiEngine->AppUiAdapter().EffectManager()->BeginFullscreenEffectL(
       
  1147                     aEffectId, iUiEngine->ViewManager()->ActiveViewData() );        
       
  1148             }
       
  1149 
  1134         // Activate the next view, or first if in the last view 
  1150         // Activate the next view, or first if in the last view 
  1135         CXnViewData& next( NextViewData() );
  1151         CXnViewData& next( NextViewData() );
       
  1152 
       
  1153         if ( !next.Occupied() )
       
  1154             {
       
  1155             next.Load();
       
  1156             }
  1136 
  1157 
  1137         iAppUiAdapter.ViewAdapter().ActivateContainerL( next );
  1158         iAppUiAdapter.ViewAdapter().ActivateContainerL( next );
  1138                 
  1159                 
  1139         CXnViewData* view( static_cast< CXnViewData* >( views[ index ] ) );
  1160         CXnViewData* view( static_cast< CXnViewData* >( views[ index ] ) );
  1140 
  1161 
  1248 // -----------------------------------------------------------------------------
  1269 // -----------------------------------------------------------------------------
  1249 TInt CXnViewManager::ViewAmount() const
  1270 TInt CXnViewManager::ViewAmount() const
  1250     {
  1271     {
  1251     return iRootData->PluginData().Count();
  1272     return iRootData->PluginData().Count();
  1252     }
  1273     }
  1253 
       
  1254 
  1274 
  1255 // -----------------------------------------------------------------------------
  1275 // -----------------------------------------------------------------------------
  1256 // CXnViewManager::ViewIndex()
  1276 // CXnViewManager::ViewIndex()
  1257 // Gets index of current view
  1277 // Gets index of current view
  1258 // -----------------------------------------------------------------------------
  1278 // -----------------------------------------------------------------------------
  1264     index = views.Find( view );
  1284     index = views.Find( view );
  1265     return index;
  1285     return index;
  1266     }
  1286     }
  1267 
  1287 
  1268 // -----------------------------------------------------------------------------
  1288 // -----------------------------------------------------------------------------
       
  1289 // CXnViewManager::MaxPages()
       
  1290 // Gets the maximum allowed page count for this app configuration
       
  1291 // -----------------------------------------------------------------------------
       
  1292 //
       
  1293 TInt CXnViewManager::MaxPages() const
       
  1294     {
       
  1295     return iRootData->MaxPages();
       
  1296     }
       
  1297 
       
  1298 // -----------------------------------------------------------------------------
  1269 // CXnViewManager::NotifyContainerChangedL()
  1299 // CXnViewManager::NotifyContainerChangedL()
  1270 // Notifies container is changed, this is called always by CXnViewAdapter
  1300 // Notifies container is changed, this is called always by CXnViewAdapter
  1271 // -----------------------------------------------------------------------------
  1301 // -----------------------------------------------------------------------------
  1272 void CXnViewManager::NotifyContainerChangedL( CXnViewData& aViewToActivate )
  1302 void CXnViewManager::NotifyContainerChangedL( CXnViewData& aViewToActivate )
  1273     {
  1303     {
  1274 #ifdef _XN_PERFORMANCE_TEST_
  1304 #ifdef _XN_PERFORMANCE_TEST_
  1275     RDebug::Print( _L( "CXnViewManager::NotifyContainerChangedL - start" ) );
  1305     RDebug::Print( _L( "CXnViewManager::NotifyContainerChangedL - start" ) );
  1276 #endif //_XN_PERFORMANCE_TEST_        
  1306 #endif //_XN_PERFORMANCE_TEST_        
  1277               
  1307                      
  1278     InvalidateActiveView();
       
  1279     
       
  1280     CXnViewData& viewToDeactivate( ActiveViewData() );
  1308     CXnViewData& viewToDeactivate( ActiveViewData() );
  1281     
  1309     
  1282     if ( &aViewToActivate != &viewToDeactivate )
  1310     if ( &aViewToActivate != &viewToDeactivate )
  1283         {
  1311         {        
  1284         // Store focus
       
  1285         CXnNode* focused( iUiEngine->FocusedNode() );
       
  1286         
       
  1287         if ( focused )
       
  1288             {
       
  1289             viewToDeactivate.SetFocusedNode( focused );
       
  1290             }
       
  1291         
       
  1292         NotifyViewDeactivatedL( viewToDeactivate );
  1312         NotifyViewDeactivatedL( viewToDeactivate );
  1293 
  1313                       
  1294         // Switch active view data
  1314         viewToDeactivate.SetActive( EFalse );
  1295         iAppUiAdapter.HandlePageSwitch();
  1315         aViewToActivate.SetActive( ETrue );
  1296         
       
  1297         viewToDeactivate.SetActiveL( EFalse );
       
  1298         aViewToActivate.SetActiveL( ETrue );
       
  1299         
  1316         
  1300         iHspsWrapper->SetActivePluginL( aViewToActivate.PluginId() );
  1317         iHspsWrapper->SetActivePluginL( aViewToActivate.PluginId() );
  1301 
  1318 
  1302         // Cache update is needed after view activation
  1319         // Cache update is needed after view activation
  1303         UpdateCachesL();       
  1320         UpdateCachesL();       
  1304         UpdateWallpaperL( viewToDeactivate, aViewToActivate );
  1321         UpdateWallpaperL( viewToDeactivate, aViewToActivate );
  1305         }
  1322         }
  1306     else
  1323     else
  1307         {
  1324         {
  1308         // Activate first view
  1325         // Activate first view
  1309         aViewToActivate.SetActiveL( ETrue );
  1326         aViewToActivate.SetActive( ETrue );
  1310 
  1327 
  1311         // Cache update is needed after view activation
  1328         // Cache update is needed after view activation
  1312         UpdateCachesL();
  1329         UpdateCachesL();
       
  1330         
       
  1331         // Schedule remainngs views load
       
  1332         iRootData->LoadRemainingViews();
  1313         }
  1333         }
  1314     
  1334     
  1315     NotifyViewActivatedL( aViewToActivate );
  1335     NotifyViewActivatedL( aViewToActivate );
  1316     UpdatePageManagementInformationL();
  1336     UpdatePageManagementInformationL();
  1317     
  1337     
  1384     CXnPluginData& aPluginData )
  1404     CXnPluginData& aPluginData )
  1385     {
  1405     {
  1386     for ( TInt i = 0; i < iObservers.Count(); i++ )
  1406     for ( TInt i = 0; i < iObservers.Count(); i++ )
  1387         {
  1407         {
  1388         iObservers[i]->NotifyConfigureWidgetL( aContentInfo, aPluginData );
  1408         iObservers[i]->NotifyConfigureWidgetL( aContentInfo, aPluginData );
  1389         }
       
  1390     
       
  1391     if ( aPluginData.Active() )
       
  1392         {
       
  1393         // Active view configuration is about to change
       
  1394         InvalidateActiveView();
       
  1395         }    
  1409         }    
  1396     }
  1410     }
  1397 
  1411 
  1398 // -----------------------------------------------------------------------------
  1412 // -----------------------------------------------------------------------------
  1399 // CXnViewManager::NotifyWidgetAdditionL()
  1413 // CXnViewManager::NotifyWidgetAdditionL()
  1440     activeViewData.ControlsL( iControls );
  1454     activeViewData.ControlsL( iControls );
  1441     iAppearanceNodes.Reset();
  1455     iAppearanceNodes.Reset();
  1442     activeViewData.AppearanceNodesL( iAppearanceNodes );
  1456     activeViewData.AppearanceNodesL( iAppearanceNodes );
  1443     iResources->Reset();
  1457     iResources->Reset();
  1444     activeViewData.ResourcesL( *iResources );
  1458     activeViewData.ResourcesL( *iResources );
  1445     }
       
  1446 
       
  1447 // -----------------------------------------------------------------------------
       
  1448 // CXnViewManager::SetFirstPassDrawCompleteL()
       
  1449 // -----------------------------------------------------------------------------
       
  1450 //
       
  1451 void CXnViewManager::SetFirstPassDrawCompleteL()
       
  1452     {
       
  1453     if ( iFlags.IsClear( EFirstPassDrawComplete ) )
       
  1454         {
       
  1455         iFlags.Set( EFirstPassDrawComplete );
       
  1456         
       
  1457         ValidateActiveViewL();
       
  1458         }    
       
  1459     }
       
  1460 
       
  1461 // -----------------------------------------------------------------------------
       
  1462 // CXnViewManager::SetDataPluginLoadCompleteL()
       
  1463 // -----------------------------------------------------------------------------
       
  1464 //
       
  1465 void CXnViewManager::SetDataPluginLoadCompleteL( 
       
  1466     const CXnPluginData& aPluginData )
       
  1467     {                             
       
  1468     if ( !aPluginData.Active() )
       
  1469         {
       
  1470         // Not interested
       
  1471         return;
       
  1472         }
       
  1473     
       
  1474     if ( ActiveViewData().DataPluginsLoaded() )
       
  1475         {
       
  1476         if ( iFlags.IsClear( EDataPluginsComplete ) )
       
  1477             {
       
  1478             iFlags.Set( EDataPluginsComplete );
       
  1479             
       
  1480             ValidateActiveViewL();
       
  1481             }
       
  1482         }
       
  1483     }
       
  1484 
       
  1485 // -----------------------------------------------------------------------------
       
  1486 // CXnViewManager::ValidateActiveViewL()
       
  1487 // -----------------------------------------------------------------------------
       
  1488 //
       
  1489 void CXnViewManager::ValidateActiveViewL()
       
  1490     {
       
  1491     if ( iFlags.IsSet( EViewIsValid ) )
       
  1492         {
       
  1493         // Already ok
       
  1494         return;
       
  1495         }
       
  1496     
       
  1497     if ( iFlags.IsClear( EFirstPassDrawComplete ) || 
       
  1498          iFlags.IsClear( EDataPluginsComplete ) )
       
  1499         {
       
  1500         // Not able to confirm yet
       
  1501         return;        
       
  1502         }
       
  1503 
       
  1504     RPointerArray< CXnPluginData >& plugins( ActiveViewData().PluginData() );
       
  1505 
       
  1506     TInt count( iFailedPlugins.Count() );
       
  1507         
       
  1508     for ( TInt i = 0; i < plugins.Count(); i++ )
       
  1509         {
       
  1510         CXnPluginData* plugin( plugins[i] );
       
  1511                 
       
  1512         const TDesC8& state( plugin->PluginState() );
       
  1513         
       
  1514         if ( state.CompareF( KStateError ) == 0 && plugin->Removable() )
       
  1515             {
       
  1516             if ( iFailedPlugins.Find( plugin ) == KErrNotFound )
       
  1517                 {
       
  1518                 iFailedPlugins.AppendL( plugin );
       
  1519                 }
       
  1520             }            
       
  1521         }
       
  1522 
       
  1523     // This condition prevents recursion
       
  1524     if ( iFailedPlugins.Count() > 0 && count == 0 )
       
  1525         {
       
  1526         // Disable layout and redraw until all plugins are removed
       
  1527         iUiEngine->DisableRenderUiLC();
       
  1528         
       
  1529         for ( TInt i = 0; i < iFailedPlugins.Count(); i++ )
       
  1530             {
       
  1531             UnloadWidgetFromPluginL( *iFailedPlugins[i] );
       
  1532             }        
       
  1533         
       
  1534         HBufC* msg( StringLoader::LoadLC( R_QTN_HS_ERROR_WIDGETS_REMOVED ) );
       
  1535             
       
  1536         CAknErrorNote* note = new ( ELeave ) CAknErrorNote;
       
  1537         CleanupStack::PushL( note );
       
  1538         
       
  1539         note->ExecuteLD( *msg );
       
  1540         
       
  1541         CleanupStack::Pop( note );
       
  1542         CleanupStack::PopAndDestroy( msg );
       
  1543         
       
  1544         iUiEngine->RenderUIL();
       
  1545 
       
  1546         CleanupStack::PopAndDestroy(); // DisableRenderUiLC()
       
  1547         
       
  1548         iFailedPlugins.Reset();               
       
  1549         }
       
  1550     
       
  1551     // All failed plugins are handled
       
  1552     if( iFailedPlugins.Count() == 0 )
       
  1553         {
       
  1554         iFlags.Set( EViewIsValid );
       
  1555         
       
  1556         SetOnlineStateL( iAppUiAdapter, ActiveViewData() );
       
  1557         
       
  1558         // Remaining views can be now loaded
       
  1559         iRootData->LoadRemainingViews();        
       
  1560         }       
       
  1561     }
       
  1562 
       
  1563 // -----------------------------------------------------------------------------
       
  1564 // CXnViewManager::InvalidateActiveView()
       
  1565 // -----------------------------------------------------------------------------
       
  1566 //
       
  1567 void CXnViewManager::InvalidateActiveView()
       
  1568     {
       
  1569     // Need to cancel async activities while view is invalidated
       
  1570     iRootData->CancelLoadRemainingViews();
       
  1571 
       
  1572     iFlags.Clear( EFirstPassDrawComplete );
       
  1573     iFlags.Clear( EDataPluginsComplete );
       
  1574     iFlags.Clear( EViewIsValid );
       
  1575     }
  1459     }
  1576 
  1460 
  1577 // -----------------------------------------------------------------------------
  1461 // -----------------------------------------------------------------------------
  1578 // CXnViewManager::ReportWidgetAmountL()
  1462 // CXnViewManager::ReportWidgetAmountL()
  1579 // -----------------------------------------------------------------------------
  1463 // -----------------------------------------------------------------------------
  1674     {
  1558     {
  1675     return *iOomSysHandler;
  1559     return *iOomSysHandler;
  1676     }
  1560     }
  1677 
  1561 
  1678 // -----------------------------------------------------------------------------
  1562 // -----------------------------------------------------------------------------
  1679 // CXnViewManager::UpdateViewSwitcherInformationL()
  1563 // CXnViewManager::UpdatePageManagementInformationL()
  1680 // -----------------------------------------------------------------------------
  1564 // -----------------------------------------------------------------------------
  1681 //
  1565 //
  1682 void CXnViewManager::UpdatePageManagementInformationL()
  1566 void CXnViewManager::UpdatePageManagementInformationL()
  1683     {
  1567     {
  1684     // Update MSK info
  1568     // Update MSK info
  1718             }
  1602             }
  1719         }
  1603         }
  1720     }
  1604     }
  1721 
  1605 
  1722 // -----------------------------------------------------------------------------
  1606 // -----------------------------------------------------------------------------
  1723 // CXnViewManager::UpdatePluginStateL()
       
  1724 // -----------------------------------------------------------------------------
       
  1725 //
       
  1726 void CXnViewManager::UpdatePluginStateL( CXnPluginData& aPluginData )
       
  1727     {
       
  1728     if ( aPluginData.ConfigurationId().Length() == 0 && 
       
  1729          aPluginData.PluginId().Length() )
       
  1730         {
       
  1731         CHspsConfiguration* configuration( 
       
  1732             iHspsWrapper->GetPluginConfigurationL( aPluginData.PluginId() ) );
       
  1733         CleanupStack::PushL( configuration );
       
  1734         aPluginData.SetConfigurationIdL( configuration->ConfId() );
       
  1735         CleanupStack::PopAndDestroy( configuration );
       
  1736         }
       
  1737 
       
  1738     if ( aPluginData.ConfigurationId().Length() && 
       
  1739          aPluginData.PluginId().Length() )
       
  1740         {
       
  1741         iHspsWrapper->SetConfStateL( 
       
  1742                 aPluginData.ConfigurationId(), aPluginData.PluginState() );        
       
  1743         }
       
  1744     }
       
  1745 
       
  1746 // -----------------------------------------------------------------------------
       
  1747 // CXnViewManager::MaxPages()
       
  1748 // 
       
  1749 // -----------------------------------------------------------------------------
       
  1750 //
       
  1751 TInt32 CXnViewManager::MaxPages()
       
  1752     {
       
  1753     return iRootData->MaxPages();
       
  1754     }
       
  1755 
       
  1756 // -----------------------------------------------------------------------------
       
  1757 // CXnViewManager::ResolveIconIndex
  1607 // CXnViewManager::ResolveIconIndex
  1758 // 
  1608 // 
  1759 // -----------------------------------------------------------------------------
  1609 // -----------------------------------------------------------------------------
  1760 TInt CXnViewManager::ResolveIconIndex( TInt aPageCount, TInt aPageNum ) const
  1610 TInt CXnViewManager::ResolveIconIndex( TInt aPageCount, TInt aPageNum ) const
  1761     {
  1611     {
  1769 
  1619 
  1770     TInt index( iconCount - aPageCount + aPageNum - 1 );
  1620     TInt index( iconCount - aPageCount + aPageNum - 1 );
  1771 
  1621 
  1772     return index;
  1622     return index;
  1773     }
  1623     }
       
  1624 
       
  1625 // -----------------------------------------------------------------------------
       
  1626 // CXnViewManager::SystemStabileTimerCallback 
       
  1627 // -----------------------------------------------------------------------------
       
  1628 TInt CXnViewManager::SystemStabileTimerCallback( TAny* aAny )
       
  1629     {
       
  1630     CXnViewManager* self = static_cast<CXnViewManager*>( aAny );
       
  1631     
       
  1632     self->ResetCrashCount();
       
  1633 
       
  1634     if( self->iStabilityTimer )
       
  1635         {
       
  1636         self->iStabilityTimer->Cancel();
       
  1637         }    
       
  1638     
       
  1639     return KErrNone;    
       
  1640     }
       
  1641 
       
  1642 // -----------------------------------------------------------------------------
       
  1643 // CXnViewManager::ResetCrashCount 
       
  1644 // -----------------------------------------------------------------------------
       
  1645 void CXnViewManager::ResetCrashCount()
       
  1646     {
       
  1647     RProperty::Set( TUid::Uid( KPSCategoryUid ), KPSCrashCountKey, 0 );    
       
  1648     }
       
  1649 
       
  1650 // -----------------------------------------------------------------------------
       
  1651 // CXnViewManager::ShowErrorNoteL 
       
  1652 // -----------------------------------------------------------------------------
       
  1653 void CXnViewManager::ShowErrorNoteL( const TInt aResourceId )
       
  1654     {        
       
  1655     HBufC* msg( StringLoader::LoadLC( aResourceId ) );
       
  1656         
       
  1657     CAknErrorNote* note = new ( ELeave ) CAknErrorNote;
       
  1658     CleanupStack::PushL( note );
       
  1659     
       
  1660     note->ExecuteLD( *msg );
       
  1661     
       
  1662     CleanupStack::Pop( note );
       
  1663     CleanupStack::PopAndDestroy( msg );    
       
  1664     }
       
  1665 
  1774 // End of file
  1666 // End of file