idlehomescreen/xmluirendering/uiengine/src/xnviewmanager.cpp
branchRCL_3
changeset 23 7be2816dbabd
parent 19 79311d856354
child 25 137ebc85284b
equal deleted inserted replaced
19:79311d856354 23:7be2816dbabd
    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>
    28 #include <gfxtranseffect/gfxtranseffect.h>
    29 #include <akntransitionutils.h>
    29 #include <akntransitionutils.h>
    30 #include <layoutmetadata.cdl.h>
       
    31 
    30 
    32 // User includes
    31 // User includes
    33 #include "xnapplication.h"
    32 #include "xnapplication.h"
    34 #include "xnuiengine.h"
    33 #include "xnuiengine.h"
    35 #include "xnproperty.h"
    34 #include "xnproperty.h"
    54 #include "xncomponentnodeimpl.h"
    53 #include "xncomponentnodeimpl.h"
    55 #include "xnnodepluginif.h"
    54 #include "xnnodepluginif.h"
    56 #include "xnoomsyshandler.h"
    55 #include "xnoomsyshandler.h"
    57 #include "xnbackgroundmanager.h"
    56 #include "xnbackgroundmanager.h"
    58 #include "xneffectmanager.h"
    57 #include "xneffectmanager.h"
       
    58 #include "xnkeyeventdispatcher.h"
    59 
    59 
    60 // Constants
    60 // Constants
    61 _LIT8( KEmptyWidgetUid, "0x2001f47f" );
    61 _LIT8( KEmptyWidgetUid, "0x2001f47f" );
    62 _LIT8( KTemplateViewUID, "0x20026f50" );
    62 _LIT8( KTemplateViewUID, "0x20026f50" );
    63 
    63 
    64 const TInt KPSCategoryUid( 0x200286E3 );
    64 const TInt KPSCategoryUid( 0x200286E3 );
    65 const TInt KPSCrashCountKey( 1 );     
    65 const TInt KPSCrashCountKey( 1 );     
    66 const TInt KStabilityInterval( 60000000 ); // 1 minute
    66 const TInt KStabilityInterval( 60000000 ); // 1 minute
       
    67 const TInt KActivationCompleteInterval( 2000000 ); // 2s
    67 const TInt KCrashRestoreDefaultThreshold( 3 );
    68 const TInt KCrashRestoreDefaultThreshold( 3 );
    68 const TInt KCrashRestoreAllTreshold( 4 );
    69 const TInt KCrashRestoreAllTreshold( 4 );
    69 
    70 
    70 // ============================ LOCAL FUNCTIONS ===============================
    71 // ============================ LOCAL FUNCTIONS ===============================
    71 // -----------------------------------------------------------------------------
    72 // -----------------------------------------------------------------------------
   276 // CXnViewManager::~CXnViewManager()
   277 // CXnViewManager::~CXnViewManager()
   277 // C++ default destructor.
   278 // C++ default destructor.
   278 // -----------------------------------------------------------------------------
   279 // -----------------------------------------------------------------------------
   279 //
   280 //
   280 CXnViewManager::~CXnViewManager()
   281 CXnViewManager::~CXnViewManager()
   281     {        
   282     {
       
   283     delete iAsyncCb;
       
   284     
   282     delete iStabilityTimer;
   285     delete iStabilityTimer;
   283     
   286     
   284     iObservers.Reset();
   287     iObservers.Reset();
   285     
   288     
   286     delete iRootData;
   289     delete iRootData;
   323     iEditor = CXnEditor::NewL( *this, uid );
   326     iEditor = CXnEditor::NewL( *this, uid );
   324 
   327 
   325     iHspsWrapper = &iEditor->HspsWrapper();
   328     iHspsWrapper = &iEditor->HspsWrapper();
   326     
   329     
   327     iComposer = CXnComposer::NewL( *iHspsWrapper );
   330     iComposer = CXnComposer::NewL( *iHspsWrapper );
   328     
   331            
   329     iIsLandscapeOrientation = Layout_Meta_Data::IsLandscapeOrientation();
   332     iAsyncCb = CPeriodic::NewL( CActive::EPriorityIdle ); 
   330     
   333                        
   331     DoRobustnessCheckL();
   334     DoRobustnessCheckL();
   332     }
   335     }
   333 
   336 
   334 // -----------------------------------------------------------------------------
   337 // -----------------------------------------------------------------------------
   335 // CXnViewManager::LoadUiL()
   338 // CXnViewManager::LoadUiL()
   346     // Load root configuration and initial view.
   349     // Load root configuration and initial view.
   347     iRootData->Load();
   350     iRootData->Load();
   348            
   351            
   349     CleanupStack::PopAndDestroy(); // DisableRenderUiLC();
   352     CleanupStack::PopAndDestroy(); // DisableRenderUiLC();
   350     
   353     
   351     // Activate initial view already here to get publishers loaded        
   354     // Load initial view publishers         
   352     ActiveViewData().SetActive( ETrue );    
   355     ActiveViewData().LoadPublishers( EAiFwSystemStartup );    
   353     }
   356     }
   354 
   357 
   355 // -----------------------------------------------------------------------------
   358 // -----------------------------------------------------------------------------
   356 // CXnViewManager::ReloadUiL()
   359 // CXnViewManager::ReloadUiL()
   357 // Reloads the application UI and initial ivew
   360 // Reloads the application UI and initial ivew
   361 #ifdef _XN_PERFORMANCE_TEST_
   364 #ifdef _XN_PERFORMANCE_TEST_
   362     RDebug::Print( _L( "CXnViewManager::ReloadUiL() - start" ) );
   365     RDebug::Print( _L( "CXnViewManager::ReloadUiL() - start" ) );
   363 #endif //_XN_PERFORMANCE_TEST_
   366 #endif //_XN_PERFORMANCE_TEST_
   364     
   367     
   365     NotifyViewDeactivatedL( ActiveViewData() );
   368     NotifyViewDeactivatedL( ActiveViewData() );
       
   369     
       
   370     if ( iAsyncCb->IsActive() )
       
   371         {
       
   372         iAsyncCb->Cancel();
       
   373         
       
   374         ContainerActivated( this );
       
   375         }
   366     
   376     
   367     delete iWidgetAmountTrigger;
   377     delete iWidgetAmountTrigger;
   368     iWidgetAmountTrigger = NULL;
   378     iWidgetAmountTrigger = NULL;
   369           
   379           
   370     // Destroy active view data
   380     // Destroy active view data
   386 #endif //_XN_PERFORMANCE_TEST_
   396 #endif //_XN_PERFORMANCE_TEST_
   387     }
   397     }
   388 
   398 
   389 // -----------------------------------------------------------------------------
   399 // -----------------------------------------------------------------------------
   390 // CXnViewManager::LoadWidgetToPluginL()
   400 // CXnViewManager::LoadWidgetToPluginL()
       
   401 //
   391 // -----------------------------------------------------------------------------
   402 // -----------------------------------------------------------------------------
   392 //
   403 //
   393 TInt CXnViewManager::LoadWidgetToPluginL( const CHsContentInfo& aContentInfo,
   404 TInt CXnViewManager::LoadWidgetToPluginL( const CHsContentInfo& aContentInfo,
   394     CXnPluginData& aPluginData )
   405     CXnPluginData& aPluginData )
   395     {
   406     {
   414         retval = iHspsWrapper->ReplacePluginL( 
   425         retval = iHspsWrapper->ReplacePluginL( 
   415             aPluginData.PluginId(), aContentInfo.Uid() );   
   426             aPluginData.PluginId(), aContentInfo.Uid() );   
   416         
   427         
   417         if( retval == KErrDiskFull )
   428         if( retval == KErrDiskFull )
   418             {
   429             {
   419             ShowDiskFullMessageL();
   430             TRAP_IGNORE( ShowErrorL( R_QTN_HS_OPERATION_FAILED_NO_DISK ) );            
   420             }
   431             }
   421         }
   432         }
   422     else
   433     else
   423         {
   434         {
   424         TInt index( viewData.PluginData().Find( &aPluginData ) );
   435         TInt index( viewData.PluginData().Find( &aPluginData ) );
   433             {
   444             {
   434             aPluginData.SetPluginIdL( result->PluginId() );
   445             aPluginData.SetPluginIdL( result->PluginId() );
   435             }
   446             }
   436         else if( retval == KErrDiskFull )
   447         else if( retval == KErrDiskFull )
   437             {
   448             {
   438             ShowDiskFullMessageL();
   449             TRAP_IGNORE( ShowErrorL( R_QTN_HS_OPERATION_FAILED_NO_DISK ) );            
   439             }        
   450             }        
   440         
   451         
   441         CleanupStack::PopAndDestroy( result ); 
   452         CleanupStack::PopAndDestroy( result ); 
   442         }
   453         }
   443              
   454              
   458             // Report widget amount in the view
   469             // Report widget amount in the view
   459             ReportWidgetAmountL( viewData );           
   470             ReportWidgetAmountL( viewData );           
   460             }  
   471             }  
   461         else if ( retval == KErrNoMemory )
   472         else if ( retval == KErrNoMemory )
   462             {
   473             {
   463             aPluginData.ShowOutOfMemError();
   474             TRAP_IGNORE( ShowErrorL( R_QTN_HS_HS_MEMORY_FULL ) );
   464             }
   475             }
   465         else if ( retval == KXnErrPluginFailure )
   476         else if ( retval == KXnErrPluginFailure )
   466             {            
   477             {            
   467             aPluginData.ShowContentRemovedError();
   478             TRAP_IGNORE( ShowErrorL( R_QTN_HS_ERROR_WIDGETS_REMOVED ) );
   468             }
   479             }
   469         
   480         
   470         CleanupStack::PopAndDestroy(); // DisableRenderUiLC
   481         CleanupStack::PopAndDestroy(); // DisableRenderUiLC
   471         }
   482         }
   472            
   483            
   473     return retval;
   484     return retval;
   474     }
   485     }
   475 
   486 
   476 // -----------------------------------------------------------------------------
   487 // -----------------------------------------------------------------------------
   477 // CXnViewManager::UnloadWidgetFromPluginL()
   488 // CXnViewManager::UnloadWidgetFromPluginL()
       
   489 //
   478 // -----------------------------------------------------------------------------
   490 // -----------------------------------------------------------------------------
   479 //
   491 //
   480 TInt CXnViewManager::UnloadWidgetFromPluginL( CXnPluginData& aPluginData, 
   492 TInt CXnViewManager::UnloadWidgetFromPluginL( CXnPluginData& aPluginData, 
   481     TBool aForce )    
   493     TBool aForce )    
   482     {                  
   494     {                  
   556     return retval;
   568     return retval;
   557     }
   569     }
   558 
   570 
   559 // -----------------------------------------------------------------------------
   571 // -----------------------------------------------------------------------------
   560 // CXnViewManager::ReplaceWidgetToPluginL
   572 // CXnViewManager::ReplaceWidgetToPluginL
       
   573 //
   561 // -----------------------------------------------------------------------------
   574 // -----------------------------------------------------------------------------
   562 //
   575 //
   563 TInt CXnViewManager::ReplaceWidgetToPluginL( const CHsContentInfo& aContentInfo,
   576 TInt CXnViewManager::ReplaceWidgetToPluginL( const CHsContentInfo& aContentInfo,
   564     CXnPluginData& aPluginData )
   577     CXnPluginData& aPluginData )
   565     {
   578     {
   604                     }
   617                     }
   605                 }            
   618                 }            
   606             }
   619             }
   607         else if ( retval == KErrNoMemory )
   620         else if ( retval == KErrNoMemory )
   608             {
   621             {
   609             aPluginData.ShowOutOfMemError();
   622             TRAP_IGNORE( ShowErrorL( R_QTN_HS_HS_MEMORY_FULL ) );            
   610             }
   623             }
   611         else if ( retval == KXnErrPluginFailure )
   624         else if ( retval == KXnErrPluginFailure )
   612             {            
   625             {            
   613             aPluginData.ShowContentRemovedError();
   626             TRAP_IGNORE( ShowErrorL( R_QTN_HS_ERROR_WIDGETS_REMOVED ) );        
   614             }
   627             }
   615                         
   628                         
   616         CleanupStack::PopAndDestroy(); // DisableRenderUiLC
   629         CleanupStack::PopAndDestroy(); // DisableRenderUiLC
   617         }
   630         }
   618     
   631     
   778     return *iResources;
   791     return *iResources;
   779     }
   792     }
   780 
   793 
   781 // -----------------------------------------------------------------------------
   794 // -----------------------------------------------------------------------------
   782 // CXnViewManager::AppearanceNodes()
   795 // CXnViewManager::AppearanceNodes()
       
   796 //
   783 // -----------------------------------------------------------------------------
   797 // -----------------------------------------------------------------------------
   784 //
   798 //
   785 RPointerArray< CXnNode >& CXnViewManager::AppearanceNodes() const
   799 RPointerArray< CXnNode >& CXnViewManager::AppearanceNodes() const
   786     {
   800     {
   787     return iAppearanceNodes;
   801     return iAppearanceNodes;
   863 void CXnViewManager::ActivateNextViewL( TInt /*aEffectId*/ )
   877 void CXnViewManager::ActivateNextViewL( TInt /*aEffectId*/ )
   864     { 
   878     { 
   865     CXnViewData& next( NextViewData() );
   879     CXnViewData& next( NextViewData() );
   866     
   880     
   867     if ( !next.Occupied() )
   881     if ( !next.Occupied() )
   868         {                
   882         {    
   869         if ( next.Load() == KErrNoMemory )
   883         TInt err( next.Load() );
   870             {
   884         
   871             next.ShowOutOfMemError();
   885         if ( err )
   872             return;
   886             {
       
   887             if ( err == KErrNoMemory )
       
   888                 {
       
   889                 TRAP_IGNORE( ShowErrorL( R_QTN_HS_HS_MEMORY_FULL ) );
       
   890                 }
       
   891             else if ( err == KXnErrPluginFailure )
       
   892                 {            
       
   893                 TRAP_IGNORE( ShowErrorL( R_QTN_HS_ERROR_WIDGETS_REMOVED ) );
       
   894                 }
       
   895             
       
   896             return;            
   873             }
   897             }
   874         }
   898         }
   875         
   899         
   876     // Activate view
   900     // Activate view
   877     if ( next.Occupied() && !next.Active() )
   901     if ( next.Occupied() && !next.Active() )
   878         {       
   902         {
   879         CXnControlAdapter* thisView( 
   903         iAppUiAdapter.ViewAdapter().ActivateContainerL( 
   880             ActiveViewData().ViewNode()->Control() );                
   904             next, EFalse, KGfxContextActivateNextView );                        
   881         
       
   882         CXnControlAdapter* nextView( 
       
   883             next.ViewNode()->Control() );
       
   884     
       
   885         GfxTransEffect::Register( thisView, KGfxContextActivateNextView );    
       
   886         GfxTransEffect::Register( nextView, KGfxContextActivateNextView );
       
   887         
       
   888         TInt ret( GfxTransEffect::BeginGroup() );
       
   889         
       
   890         CFbsBitmap* currentBg( ActiveViewData().WallpaperImage() );
       
   891         CFbsBitmap* nextBg( next.WallpaperImage() );
       
   892         
       
   893         if ( currentBg || nextBg )
       
   894             {
       
   895             CCoeControl* bg( &iAppUiAdapter.ViewAdapter().BgManager() );
       
   896             
       
   897             if ( !currentBg && nextBg )
       
   898                 {
       
   899                 GfxTransEffect::Begin( bg, KGfxControlActionBgAnimToImgAppear );
       
   900                 }
       
   901             else
       
   902                 {
       
   903                 GfxTransEffect::Begin( bg, KGfxControlActionBgImgToImgAppear );
       
   904                 }
       
   905             
       
   906             GfxTransEffect::SetDemarcation( bg, bg->Position() );
       
   907             GfxTransEffect::End( bg );
       
   908             }
       
   909         
       
   910         if ( iIsLandscapeOrientation )
       
   911             {
       
   912             GfxTransEffect::Begin( thisView, KGfxControlActionDisappearLsc );
       
   913             GfxTransEffect::Begin( nextView, KGfxControlActionAppearLsc );
       
   914             }
       
   915         else
       
   916             {
       
   917             GfxTransEffect::Begin( thisView, KGfxControlActionDisappearPrt );
       
   918             GfxTransEffect::Begin( nextView, KGfxControlActionAppearPrt );
       
   919             }
       
   920         
       
   921         TRAP_IGNORE( iAppUiAdapter.ViewAdapter().ActivateContainerL( next ) );
       
   922         
       
   923         GfxTransEffect::SetDemarcation( thisView, thisView->Position() );
       
   924         GfxTransEffect::End( thisView );
       
   925         
       
   926         GfxTransEffect::SetDemarcation( nextView, nextView->Position() );
       
   927         GfxTransEffect::End( nextView );
       
   928                                 
       
   929         GfxTransEffect::EndGroup( ret );
       
   930         
       
   931         GfxTransEffect::Deregister( thisView );
       
   932         GfxTransEffect::Deregister( nextView );
       
   933         }
   905         }
   934     }
   906     }
   935 
   907 
   936 // -----------------------------------------------------------------------------
   908 // -----------------------------------------------------------------------------
   937 // CXnViewManager::ActivatePreviousViewL()
   909 // CXnViewManager::ActivatePreviousViewL()
   942     {    
   914     {    
   943     CXnViewData& prev( PreviousViewData() );
   915     CXnViewData& prev( PreviousViewData() );
   944 
   916 
   945     if ( !prev.Occupied() )
   917     if ( !prev.Occupied() )
   946         {
   918         {
   947         if ( prev.Load() == KErrNoMemory )
   919         TInt err( prev.Load() );
   948             {
   920         
   949             prev.ShowOutOfMemError();
   921         if ( err )
   950             return;
   922             {
   951             }
   923             if ( err == KErrNoMemory )
       
   924                 {
       
   925                 TRAP_IGNORE( ShowErrorL( R_QTN_HS_HS_MEMORY_FULL ) );
       
   926                 }
       
   927             else if ( err == KXnErrPluginFailure )
       
   928                 {            
       
   929                 TRAP_IGNORE( ShowErrorL( R_QTN_HS_ERROR_WIDGETS_REMOVED ) );
       
   930                 }
       
   931             
       
   932             return;            
       
   933             }    
   952         }
   934         }
   953         
   935         
   954     // Activate view
   936     // Activate view
   955     if ( prev.Occupied() && !prev.Active() )
   937     if ( prev.Occupied() && !prev.Active() )
   956         {
   938         {
   957         CXnControlAdapter* thisView( 
   939         iAppUiAdapter.ViewAdapter().ActivateContainerL( 
   958             ActiveViewData().ViewNode()->Control() ); 
   940             prev, EFalse, KGfxContextActivatePrevView );                                
   959         
       
   960         CXnControlAdapter* prevView( 
       
   961             prev.ViewNode()->Control() );
       
   962 
       
   963         GfxTransEffect::Register( thisView, KGfxContextActivatePrevView );    
       
   964         GfxTransEffect::Register( prevView, KGfxContextActivatePrevView );
       
   965     
       
   966         TInt ret( GfxTransEffect::BeginGroup() );
       
   967         
       
   968         CFbsBitmap* currentBg( ActiveViewData().WallpaperImage() );
       
   969         CFbsBitmap* prevBg( prev.WallpaperImage() );
       
   970         
       
   971         if ( currentBg || prevBg )
       
   972             {
       
   973             CCoeControl* bg( &iAppUiAdapter.ViewAdapter().BgManager() );
       
   974             
       
   975             if ( !currentBg && prevBg )
       
   976                 {
       
   977                 GfxTransEffect::Begin( bg, KGfxControlActionBgAnimToImgAppear );
       
   978                 }
       
   979             else
       
   980                 {
       
   981                 GfxTransEffect::Begin( bg, KGfxControlActionBgImgToImgAppear );
       
   982                 }
       
   983             
       
   984             GfxTransEffect::SetDemarcation( bg, bg->Position() );
       
   985             GfxTransEffect::End( bg );
       
   986             }
       
   987         
       
   988         if ( iIsLandscapeOrientation )
       
   989             {
       
   990             GfxTransEffect::Begin( thisView, KGfxControlActionDisappearLsc );
       
   991             GfxTransEffect::Begin( prevView, KGfxControlActionAppearLsc );
       
   992             }
       
   993         else
       
   994             {
       
   995             GfxTransEffect::Begin( thisView, KGfxControlActionDisappearPrt );
       
   996             GfxTransEffect::Begin( prevView, KGfxControlActionAppearPrt );
       
   997             }
       
   998         
       
   999         TRAP_IGNORE( iAppUiAdapter.ViewAdapter().ActivateContainerL( prev ) );
       
  1000         
       
  1001         GfxTransEffect::SetDemarcation( thisView, thisView->Position() );
       
  1002         GfxTransEffect::End( thisView );
       
  1003                                       
       
  1004         GfxTransEffect::SetDemarcation( prevView, prevView->Position() );
       
  1005         GfxTransEffect::End( prevView );
       
  1006                                 
       
  1007         GfxTransEffect::EndGroup( ret );
       
  1008         
       
  1009         GfxTransEffect::Deregister( thisView );
       
  1010         GfxTransEffect::Deregister( prevView );        
       
  1011         }
   941         }
  1012     }
   942     }
  1013 
   943 
  1014 // -----------------------------------------------------------------------------
   944 // -----------------------------------------------------------------------------
  1015 // CXnViewManager::AddViewL()
   945 // CXnViewManager::AddViewL()
  1031 
   961 
  1032     TInt retval( result->Status() );
   962     TInt retval( result->Status() );
  1033     
   963     
  1034     if( retval == KErrDiskFull )
   964     if( retval == KErrDiskFull )
  1035         {
   965         {
  1036         ShowDiskFullMessageL();
   966         TRAP_IGNORE( ShowErrorL( R_QTN_HS_OPERATION_FAILED_NO_DISK ) );
  1037         }        
   967         }        
  1038     else if ( retval == KErrNone )
   968     else if ( retval == KErrNone )
  1039         {                             
   969         {                             
  1040         // Create new view        
   970         // Create new view        
  1041         CXnViewData* newView = CXnViewData::NewLC( *iRootData );    
   971         CXnViewData* newView = CXnViewData::NewLC( *iRootData );    
  1046         
   976         
  1047         retval = newView->Load();
   977         retval = newView->Load();
  1048                 
   978                 
  1049         if ( retval == KErrNoMemory )
   979         if ( retval == KErrNoMemory )
  1050             {
   980             {
  1051             newView->ShowOutOfMemError();
   981             TRAP_IGNORE( ShowErrorL( R_QTN_HS_HS_MEMORY_FULL ) );            
  1052             }
   982             }
  1053         
   983         else if ( retval == KXnErrPluginFailure )
       
   984             {            
       
   985             TRAP_IGNORE( ShowErrorL( R_QTN_HS_ERROR_WIDGETS_REMOVED ) );
       
   986             }
       
   987                 
  1054         if ( newView->Occupied() )
   988         if ( newView->Occupied() )
  1055             {
   989             {
  1056             // Load succeed, add the new view behind the current view               
   990             // Load succeed, add the new view behind the current view               
  1057             RPointerArray< CXnPluginData >& views( iRootData->PluginData() );
   991             RPointerArray< CXnPluginData >& views( iRootData->PluginData() );
  1058             
   992             
  1095 //
  1029 //
  1096 void CXnViewManager::AddViewL( TInt aEffectId )
  1030 void CXnViewManager::AddViewL( TInt aEffectId )
  1097     {
  1031     {
  1098     if ( iRootData->PluginData().Count() >= iRootData->MaxPages() ) 
  1032     if ( iRootData->PluginData().Count() >= iRootData->MaxPages() ) 
  1099         { 
  1033         { 
  1100         HBufC* msg( StringLoader::LoadLC( 
  1034         TRAP_IGNORE( ShowErrorL( R_QTN_HS_MAX_AMOUNT_OF_PAGES_NOTE ) );
  1101             R_QTN_HS_MAX_AMOUNT_OF_PAGES_NOTE ) ); 
  1035         
  1102 
  1036         return;        
  1103         CAknErrorNote* note = new ( ELeave ) CAknErrorNote; 
       
  1104         CleanupStack::PushL( note ); 
       
  1105                
       
  1106         note->ExecuteLD( *msg ); 
       
  1107                
       
  1108         CleanupStack::Pop( note ); 
       
  1109         CleanupStack::PopAndDestroy( msg ); 
       
  1110 
       
  1111         return; 
       
  1112         }
  1037         }
  1113 
  1038 
  1114     // Add new view (template view) to hsps
  1039     // Add new view (template view) to hsps
  1115     CAddPluginResult* result = iHspsWrapper->AddPluginL( 
  1040     CAddPluginResult* result = iHspsWrapper->AddPluginL( 
  1116         iRootData->ConfigurationId(), KTemplateViewUID,
  1041         iRootData->ConfigurationId(), KTemplateViewUID,
  1119         
  1044         
  1120     TInt status( result->Status() );
  1045     TInt status( result->Status() );
  1121     
  1046     
  1122     if( status == KErrDiskFull )
  1047     if( status == KErrDiskFull )
  1123         {
  1048         {
  1124         ShowDiskFullMessageL();
  1049         TRAP_IGNORE( ShowErrorL( R_QTN_HS_OPERATION_FAILED_NO_DISK ) );
  1125         }            
  1050         }            
  1126     else if ( status == KErrNone )
  1051     else if ( status == KErrNone )
  1127         {                             
  1052         {                             
  1128         // Create new view        
  1053         // Create new view        
  1129         CXnViewData* newView = CXnViewData::NewLC( *iRootData );    
  1054         CXnViewData* newView = CXnViewData::NewLC( *iRootData );    
  1134         
  1059         
  1135         status = newView->Load();
  1060         status = newView->Load();
  1136         
  1061         
  1137         if ( status == KErrNoMemory )
  1062         if ( status == KErrNoMemory )
  1138             {
  1063             {
  1139             newView->ShowOutOfMemError();
  1064             TRAP_IGNORE( ShowErrorL( R_QTN_HS_HS_MEMORY_FULL ) );
  1140             }
  1065             }        
  1141         
  1066         else if ( status == KXnErrPluginFailure )
       
  1067             {            
       
  1068             TRAP_IGNORE( ShowErrorL( R_QTN_HS_ERROR_WIDGETS_REMOVED ) );
       
  1069             }
       
  1070                 
  1142         if ( newView->Occupied() )
  1071         if ( newView->Occupied() )
  1143             {
  1072             {
  1144             // Start transition effect
  1073             // Start transition effect
  1145             if( aEffectId )
  1074             if( aEffectId )
  1146                 {
  1075                 {
  1210                 // Destroy publishers here, must be plugin shutdown
  1139                 // Destroy publishers here, must be plugin shutdown
  1211                 view->DestroyPublishers( EAiFwPluginShutdown );
  1140                 view->DestroyPublishers( EAiFwPluginShutdown );
  1212             
  1141             
  1213                 // Activate the next view, or first if in the last view 
  1142                 // Activate the next view, or first if in the last view 
  1214                 CXnViewData& next( NextViewData() );
  1143                 CXnViewData& next( NextViewData() );
       
  1144                 
  1215                 iAppUiAdapter.ViewAdapter().ActivateContainerL( next );
  1145                 iAppUiAdapter.ViewAdapter().ActivateContainerL( next );
  1216                 }
  1146                 }
  1217 
  1147 
  1218             // Remove wallpaper from cache
  1148             // Remove wallpaper from cache
  1219             iAppUiAdapter.ViewAdapter().BgManager().DeleteWallpaper( *view );
  1149             iAppUiAdapter.ViewAdapter().BgManager().DeleteWallpaper( *view );
  1220 
  1150 
  1221             retval = iHspsWrapper->RemovePluginL( view->PluginId() );
  1151             retval = iHspsWrapper->RemovePluginL( view->PluginId() );
  1222             
  1152             
  1223             // Notify observers of view list change
  1153             // Notify observers of view list change
  1224             TRAPD( err, NotifyViewRemovalL( *view ) );
  1154             TRAP_IGNORE( NotifyViewRemovalL( *view ) );
  1225             if ( err != KErrNone )
       
  1226                 {
       
  1227                 // ignored
       
  1228                 }            
       
  1229 
  1155 
  1230             iRootData->DestroyViewData( view );
  1156             iRootData->DestroyViewData( view );
  1231                                                                    
  1157                                                                    
  1232             // Need to update after view is removed
  1158             // Need to update after view is removed
  1233             UpdatePageManagementInformationL();                
  1159             UpdatePageManagementInformationL();                
  1296 
  1222 
  1297         // Remove plugin from HSPS
  1223         // Remove plugin from HSPS
  1298         iHspsWrapper->RemovePluginL( view->PluginId() );
  1224         iHspsWrapper->RemovePluginL( view->PluginId() );
  1299         
  1225         
  1300         // Notify observers of view list change
  1226         // Notify observers of view list change
  1301         TRAPD( err, NotifyViewRemovalL( *view ) );
  1227         TRAP_IGNORE( NotifyViewRemovalL( *view ) );
  1302         if ( err != KErrNone )
  1228 
  1303             {
       
  1304             // ignored
       
  1305             }   
       
  1306 
  1229 
  1307         iRootData->DestroyViewData( view );
  1230         iRootData->DestroyViewData( view );
  1308         
  1231         
  1309         // Need to update after view is removed
  1232         // Need to update after view is removed
  1310         UpdatePageManagementInformationL();        
  1233         UpdatePageManagementInformationL();        
  1311         }       
  1234         }       
  1312     }
  1235     }
  1313 
  1236 
  1314 // -----------------------------------------------------------------------------
  1237 // -----------------------------------------------------------------------------
  1315 // CXnViewManager::AddObserver()
  1238 // CXnViewManager::AddObserver()
       
  1239 //
  1316 // -----------------------------------------------------------------------------
  1240 // -----------------------------------------------------------------------------
  1317 //
  1241 //
  1318 void CXnViewManager::AddObserver( const MXnViewObserver& aObserver )
  1242 void CXnViewManager::AddObserver( const MXnViewObserver& aObserver )
  1319     {
  1243     {
  1320     TInt index( iObservers.Find( &aObserver ) );
  1244     TInt index( iObservers.Find( &aObserver ) );
  1325         }
  1249         }
  1326     }
  1250     }
  1327 
  1251 
  1328 // -----------------------------------------------------------------------------
  1252 // -----------------------------------------------------------------------------
  1329 // CXnViewManager::RemoveObserver()
  1253 // CXnViewManager::RemoveObserver()
       
  1254 //
  1330 // -----------------------------------------------------------------------------
  1255 // -----------------------------------------------------------------------------
  1331 //
  1256 //
  1332 void CXnViewManager::RemoveObserver( const MXnViewObserver& aObserver )
  1257 void CXnViewManager::RemoveObserver( const MXnViewObserver& aObserver )
  1333     {
  1258     {
  1334     TInt index( iObservers.Find( &aObserver ) );
  1259     TInt index( iObservers.Find( &aObserver ) );
  1433 
  1358 
  1434 // -----------------------------------------------------------------------------
  1359 // -----------------------------------------------------------------------------
  1435 // CXnViewManager::NotifyContainerChangedL()
  1360 // CXnViewManager::NotifyContainerChangedL()
  1436 // Notifies container is changed, this is called always by CXnViewAdapter
  1361 // Notifies container is changed, this is called always by CXnViewAdapter
  1437 // -----------------------------------------------------------------------------
  1362 // -----------------------------------------------------------------------------
       
  1363 //
  1438 void CXnViewManager::NotifyContainerChangedL( CXnViewData& aViewToActivate )
  1364 void CXnViewManager::NotifyContainerChangedL( CXnViewData& aViewToActivate )
  1439     {
  1365     {
       
  1366     iAsyncCb->Cancel();
       
  1367     
  1440     CXnViewData& viewToDeactivate( ActiveViewData() );
  1368     CXnViewData& viewToDeactivate( ActiveViewData() );
  1441     
  1369     
       
  1370     TInt err( KErrNone );
       
  1371         
  1442     if ( &aViewToActivate != &viewToDeactivate )
  1372     if ( &aViewToActivate != &viewToDeactivate )
  1443         {        
  1373         {               
  1444         NotifyViewDeactivatedL( viewToDeactivate );
  1374         NotifyViewDeactivatedL( viewToDeactivate );
  1445                       
  1375                       
  1446         viewToDeactivate.SetActive( EFalse );
  1376         err = viewToDeactivate.SetActive( EFalse );
  1447         aViewToActivate.SetActive( ETrue );
  1377         aViewToActivate.SetActive( ETrue );
  1448                              
  1378                                                         
  1449         iHspsWrapper->SetActivePluginL( aViewToActivate.PluginId() ); 
       
  1450                     
       
  1451         // Cache update is needed after view activation
  1379         // Cache update is needed after view activation
  1452         UpdateCachesL();               
  1380         UpdateCachesL();               
  1453         }
  1381         }
  1454     else
  1382     else
  1455         {
  1383         {
  1456         // Activate first view
  1384         // Activate first view
  1457         aViewToActivate.SetActive( ETrue );
  1385         err = aViewToActivate.SetActive( ETrue );
  1458 
  1386 
  1459         // Cache update is needed after view activation
  1387         // Cache update is needed after view activation
  1460         UpdateCachesL();
  1388         UpdateCachesL();
  1461         
  1389         
  1462         // Schedule remaining views loading
  1390         // Schedule remaining views loading
  1463         iRootData->LoadRemainingViews();
  1391         iRootData->LoadRemainingViews();
  1464         }
  1392         }
  1465     
  1393     
  1466     NotifyViewActivatedL( aViewToActivate );
  1394     if ( err == KErrNoMemory )
  1467     UpdatePageManagementInformationL();
  1395         {
       
  1396         TRAP_IGNORE( ShowErrorL( R_QTN_HS_HS_MEMORY_FULL ) );
       
  1397         }
       
  1398     else if ( err == KXnErrPluginFailure )
       
  1399         {
       
  1400         TRAP_IGNORE( ShowErrorL( R_QTN_HS_ERROR_WIDGETS_REMOVED ) );
       
  1401         }       
       
  1402                
       
  1403     NotifyViewActivatedL( aViewToActivate );           
       
  1404     }
       
  1405 
       
  1406 // -----------------------------------------------------------------------------
       
  1407 // CXnViewManager::PublishersReadyL()
       
  1408 // Notifies that aViewData activation is complete
       
  1409 // -----------------------------------------------------------------------------
       
  1410 //
       
  1411 void CXnViewManager::PublishersReadyL( CXnViewData& aViewData, TInt aResult )
       
  1412     {
       
  1413     if ( !aViewData.Active() )
       
  1414         {
       
  1415         return;
       
  1416         }
       
  1417            
       
  1418     iAsyncCb->Cancel();
       
  1419     
       
  1420     TCallBack cb( ContainerActivated, this ) ;
       
  1421     
       
  1422     iAsyncCb->Start( KActivationCompleteInterval, 0, cb ); 
       
  1423                      
       
  1424     if ( !iUiReady )
       
  1425         {
       
  1426         iAppUiAdapter.HandleUiReadyEventL();
       
  1427         iUiReady = ETrue;
       
  1428         }
       
  1429     
       
  1430     if ( aResult == KErrNoMemory )
       
  1431         {
       
  1432         ShowErrorL( R_QTN_HS_HS_MEMORY_FULL );
       
  1433         }
       
  1434     else if ( aResult == KXnErrPluginFailure )
       
  1435         {
       
  1436         ShowErrorL( R_QTN_HS_ERROR_WIDGETS_REMOVED );
       
  1437         }       
       
  1438     }
       
  1439 
       
  1440 // -----------------------------------------------------------------------------
       
  1441 // CXnViewManager::ContainerActivated()
       
  1442 // Notifies that a container activation is complete
       
  1443 // -----------------------------------------------------------------------------
       
  1444 //
       
  1445 /* static */ TInt CXnViewManager::ContainerActivated( TAny* aAny )
       
  1446     {
       
  1447     CXnViewManager* self = static_cast< CXnViewManager* >( aAny );
       
  1448     
       
  1449     self->iAsyncCb->Cancel();
       
  1450     
       
  1451     CXnViewData& active( self->ActiveViewData() );
       
  1452     
       
  1453     TRAP_IGNORE( self->iHspsWrapper->SetActivePluginL( active.PluginId() ) );
       
  1454 
       
  1455     CXnBackgroundManager& bg( self->iAppUiAdapter.ViewAdapter().BgManager() ); 
       
  1456         
       
  1457     TRAP_IGNORE( bg.StoreWallpaperL() );
       
  1458     
       
  1459     return KErrNone;
  1468     }
  1460     }
  1469 
  1461 
  1470 // -----------------------------------------------------------------------------
  1462 // -----------------------------------------------------------------------------
  1471 // CXnViewManager::NotifyViewActivatedL()
  1463 // CXnViewManager::NotifyViewActivatedL()
  1472 // Notifies view is activated
  1464 // Notifies view is activated
  1570         }
  1562         }
  1571     }
  1563     }
  1572 
  1564 
  1573 // -----------------------------------------------------------------------------
  1565 // -----------------------------------------------------------------------------
  1574 // CXnViewManager::UpdateCachesL()
  1566 // CXnViewManager::UpdateCachesL()
       
  1567 //
  1575 // -----------------------------------------------------------------------------
  1568 // -----------------------------------------------------------------------------
  1576 //
  1569 //
  1577 void CXnViewManager::UpdateCachesL()
  1570 void CXnViewManager::UpdateCachesL()
  1578     {
  1571     {
  1579     CXnViewData& activeViewData( ActiveViewData() );
  1572     CXnViewData& activeViewData( ActiveViewData() );
  1585     activeViewData.ResourcesL( *iResources );
  1578     activeViewData.ResourcesL( *iResources );
  1586     }
  1579     }
  1587 
  1580 
  1588 // -----------------------------------------------------------------------------
  1581 // -----------------------------------------------------------------------------
  1589 // CXnViewManager::ReportWidgetAmountL()
  1582 // CXnViewManager::ReportWidgetAmountL()
       
  1583 //
  1590 // -----------------------------------------------------------------------------
  1584 // -----------------------------------------------------------------------------
  1591 //
  1585 //
  1592 void CXnViewManager::ReportWidgetAmountL( const CXnViewData& aViewData )
  1586 void CXnViewManager::ReportWidgetAmountL( const CXnViewData& aViewData )
  1593     {
  1587     {
  1594     CXnNode* node( aViewData.ViewNode() );
  1588     CXnNode* node( aViewData.ViewNode() );
  1650 
  1644 
  1651     node->ReportXuikonEventL( *iWidgetAmountTrigger );
  1645     node->ReportXuikonEventL( *iWidgetAmountTrigger );
  1652     }
  1646     }
  1653 
  1647 
  1654 // -----------------------------------------------------------------------------
  1648 // -----------------------------------------------------------------------------
  1655 // CXnViewManager::ShowOperationFailedMessageL
  1649 // CXnViewManager::ShowErrorL
  1656 // -----------------------------------------------------------------------------
  1650 //
  1657 //
  1651 // -----------------------------------------------------------------------------
  1658 void CXnViewManager::ShowDiskFullMessageL() const
  1652 //
  1659     {
  1653 void CXnViewManager::ShowErrorL( TInt aResource ) const
  1660     HBufC* msg( StringLoader::LoadLC( R_QTN_HS_OPERATION_FAILED_NO_DISK ) ); 
  1654     {       
  1661 
  1655     if ( aResource == R_QTN_HS_HS_MEMORY_FULL )
  1662     CAknErrorNote* note = new ( ELeave ) CAknErrorNote; 
  1656         {
  1663     CleanupStack::PushL( note ); 
  1657         iOomSysHandler->HandlePotentialOomL();
  1664            
  1658         }
  1665     note->ExecuteLD( *msg );
  1659     else
  1666            
  1660         {
  1667     CleanupStack::Pop( note ); 
  1661         HBufC* msg( StringLoader::LoadLC( aResource ) ); 
  1668     CleanupStack::PopAndDestroy( msg );     
  1662     
       
  1663         CAknErrorNote* note = new ( ELeave ) CAknErrorNote;                       
       
  1664         note->ExecuteLD( *msg );
       
  1665                        
       
  1666         CleanupStack::PopAndDestroy( msg );             
       
  1667         }    
  1669     }
  1668     }
  1670 
  1669 
  1671 // -----------------------------------------------------------------------------
  1670 // -----------------------------------------------------------------------------
  1672 // CXnViewManager::OOMSysHandler
  1671 // CXnViewManager::OOMSysHandler
       
  1672 //
  1673 // -----------------------------------------------------------------------------
  1673 // -----------------------------------------------------------------------------
  1674 //
  1674 //
  1675 CXnOomSysHandler& CXnViewManager::OomSysHandler() const
  1675 CXnOomSysHandler& CXnViewManager::OomSysHandler() const
  1676     {
  1676     {
  1677     return *iOomSysHandler;
  1677     return *iOomSysHandler;
  1757     return KErrNone;    
  1757     return KErrNone;    
  1758     }
  1758     }
  1759 
  1759 
  1760 // -----------------------------------------------------------------------------
  1760 // -----------------------------------------------------------------------------
  1761 // CXnViewManager::ResetCrashCount 
  1761 // CXnViewManager::ResetCrashCount 
       
  1762 //
  1762 // -----------------------------------------------------------------------------
  1763 // -----------------------------------------------------------------------------
  1763 void CXnViewManager::ResetCrashCount()
  1764 void CXnViewManager::ResetCrashCount()
  1764     {
  1765     {
  1765     RProperty::Set( TUid::Uid( KPSCategoryUid ), KPSCrashCountKey, 0 );    
  1766     RProperty::Set( TUid::Uid( KPSCategoryUid ), KPSCrashCountKey, 0 );    
  1766     }
  1767     }
  1767 
  1768 
  1768 // -----------------------------------------------------------------------------
  1769 // -----------------------------------------------------------------------------
  1769 // CXnViewManager::ShowErrorNoteL 
  1770 // CXnViewManager::DoRobustnessCheckL
  1770 // -----------------------------------------------------------------------------
  1771 //
  1771 void CXnViewManager::ShowErrorNoteL()
       
  1772     {        
       
  1773     CAknQueryDialog* query = CAknQueryDialog::NewL();
       
  1774     query->PrepareLC( R_HS_CONTENT_REMOVED_VIEW );
       
  1775 
       
  1776     HBufC* queryText( StringLoader::LoadLC( R_HS_ERROR_CONTENT_REMOVED ) );    
       
  1777     query->SetPromptL( queryText->Des() );    
       
  1778     CleanupStack::PopAndDestroy( queryText );
       
  1779 
       
  1780     query->RunLD();   
       
  1781     }
       
  1782 
       
  1783 // -----------------------------------------------------------------------------
       
  1784 // CXnViewManager::DoRobustnessCheckL 
       
  1785 // -----------------------------------------------------------------------------
  1772 // -----------------------------------------------------------------------------
  1786 void CXnViewManager::DoRobustnessCheckL()
  1773 void CXnViewManager::DoRobustnessCheckL()
  1787     {
  1774     {
  1788     TInt crashCount = 0;
  1775     TInt crashCount = 0;
       
  1776     
  1789     RProperty::Get( TUid::Uid( KPSCategoryUid ),
  1777     RProperty::Get( TUid::Uid( KPSCategoryUid ),
  1790                     KPSCrashCountKey,
  1778                     KPSCrashCountKey,
  1791                     crashCount );    
  1779                     crashCount );    
  1792     
  1780     
  1793     if( crashCount == KCrashRestoreDefaultThreshold )
  1781     if( crashCount == KCrashRestoreDefaultThreshold )
  1794         {    
  1782         {    
  1795         TInt err = iHspsWrapper->RestoreDefaultConfL();         
  1783         iHspsWrapper->RestoreDefaultConfL();
  1796         ShowErrorNoteL();
  1784         
       
  1785         CAknQueryDialog* query = CAknQueryDialog::NewL();
       
  1786         query->PrepareLC( R_HS_CONTENT_REMOVED_VIEW );
       
  1787 
       
  1788         HBufC* queryText( StringLoader::LoadLC( R_HS_ERROR_CONTENT_REMOVED ) );    
       
  1789         query->SetPromptL( queryText->Des() );    
       
  1790         CleanupStack::PopAndDestroy( queryText );
       
  1791 
       
  1792         query->RunLD();           
  1797         }
  1793         }
  1798     else if( crashCount >= KCrashRestoreAllTreshold )
  1794     else if( crashCount >= KCrashRestoreAllTreshold )
  1799         {       
  1795         {       
  1800         TInt err = iHspsWrapper->RestoreRootL();              
  1796         iHspsWrapper->RestoreRootL();
       
  1797         
  1801         ResetCrashCount();
  1798         ResetCrashCount();
  1802         return;
  1799         return;
  1803         }
  1800         }
  1804     
  1801     
  1805     if( crashCount > 0 )
  1802     if( crashCount > 0 )
  1812                                 KStabilityInterval,
  1809                                 KStabilityInterval,
  1813                                 TCallBack( SystemStabileTimerCallback, this ) );
  1810                                 TCallBack( SystemStabileTimerCallback, this ) );
  1814         }           
  1811         }           
  1815     }
  1812     }
  1816 
  1813 
  1817 // -----------------------------------------------------------------------------
       
  1818 // CXnViewManager::OrientationChanged 
       
  1819 // -----------------------------------------------------------------------------
       
  1820 void CXnViewManager::OrientationChanged()
       
  1821     {
       
  1822     iIsLandscapeOrientation = Layout_Meta_Data::IsLandscapeOrientation();    
       
  1823     }
       
  1824 
       
  1825 // End of file
  1814 // End of file