idlehomescreen/xmluirendering/uiengine/src/xnrootdata.cpp
branchRCL_3
changeset 31 89165693e770
parent 28 d721605b30d0
equal deleted inserted replaced
28:d721605b30d0 31:89165693e770
    17 
    17 
    18 // System includes
    18 // System includes
    19 
    19 
    20 
    20 
    21 // User includes
    21 // User includes
    22 #include <xnuiengine.rsg>
       
    23 #include "xnviewmanager.h"
    22 #include "xnviewmanager.h"
    24 #include "xnviewdata.h"
    23 #include "xnviewdata.h"
    25 
    24 
    26 #include "xnappuiadapter.h"
    25 #include "xnappuiadapter.h"
    27 #include "xncontroladapter.h"
    26 #include "xncontroladapter.h"
   158     TRAP( err, iODT = iManager.Composer().ComposeRootL( *this ) );
   157     TRAP( err, iODT = iManager.Composer().ComposeRootL( *this ) );
   159     
   158     
   160     if ( !iODT )
   159     if ( !iODT )
   161         {
   160         {
   162         // Can't recover
   161         // Can't recover
   163         Panic( EXnInvalidConfiguration );                       
   162         return EXnInvalidConfiguration;                       
   164         }
   163         }
   165        
   164        
   166     if ( !err )
   165     if ( !err )
   167         {
   166         {
   168         TRAP( err, iManager.Parser().LoadRootL( *this, iApplicationUid ) );
   167         TRAP( err, iManager.Parser().LoadRootL( *this, iApplicationUid ) );
   169         }
   168         }
   170     
   169     
   171     if ( !err )
   170     if ( !err )
   172         {                
   171         {             
   173         for ( TInt i = 0; i < iPluginsData.Count(); i++ )
   172         for ( TInt i = 0; i < iPluginsData.Count(); i++ )
   174             {
   173             {
   175             CXnViewData* plugin( 
   174             CXnViewData* plugin( 
   176                 static_cast< CXnViewData* >( iPluginsData[ i ] ) ); 
   175                 static_cast< CXnViewData* >( iPluginsData[ i ] ) ); 
   177             
   176             
   178             if ( plugin->Initial() )
   177             if ( plugin->Initial() )
   179                 {
   178                 {
   180                 err = plugin->Load();
   179                 err = plugin->Load();
   181                                     
   180                                                     
   182                 if ( plugin->Occupied() )
   181                 if ( plugin->Occupied() )
   183                     {
   182                     {
   184                     // Initial view is succesfully composed. Some plugins
   183                     // Initial view is succesfully composed. Some widget plugins
   185                     // may have failed but it doesn't matter as those are removed                                        
   184                     // may have failed but it doesn't matter as those are removed.
   186                     return KErrNone;
   185                     // Rest of the views will be loaded asynchronously by the RunLoadL()
       
   186                     return err;
   187                     }     
   187                     }     
   188                 
   188                                 
   189                 // Initial view failed, remove it
   189                 // Initial view failed                
   190                 iPluginsData.Remove( i );
   190                 iManager.RemoveFaultyView( plugin );
   191                 
   191                 
   192                 delete plugin;
   192                 delete plugin;
   193                 plugin = NULL;                                                
   193                 plugin = NULL;                
   194                 break;                             
   194                 break;
   195                 }
   195                 }
   196             }
   196             }
   197                                     
   197                                                     
   198         // Initial view loading failed, fallback to load any of the views
   198         // Initial view loading failed, fallback to load any of the views
   199         while( iPluginsData.Count() )
   199         while( iPluginsData.Count() )
   200             {
   200             {
   201             CXnViewData* plugin( 
   201             CXnViewData* plugin( 
   202                 static_cast< CXnViewData* >( iPluginsData[ 0 ] ) ); 
   202                 static_cast< CXnViewData* >( iPluginsData[ 0 ] ) ); 
   203 
   203 
       
   204             plugin->SetInitial();            
       
   205             
   204             // Ignore error
   206             // Ignore error
   205             plugin->Load();
   207             plugin->Load();
   206                             
   208                             
   207             if ( plugin->Occupied() )
   209             if ( plugin->Occupied() )
   208                 {
   210                 {
   209                 // Return error because of fallback condition                                
   211                 // Return error because of fallback condition
   210                 return KXnErrPluginFailure;
   212                 return KXnErrViewPluginFailure;
   211                 }
   213                 }
   212 
   214 
   213             // View failed, remove it
   215             // View failed, remove it    
   214             iPluginsData.Remove( 0 );
   216             iManager.RemoveFaultyView( plugin );     
   215             
   217             
   216             delete plugin;
   218             delete plugin;
   217             plugin = NULL;
   219             plugin = NULL;                       
   218             }        
   220             }        
   219         }
   221         }
   220     else if ( err == KErrNoMemory )
   222     else if ( err == KErrNoMemory )
   221         {
   223         {
   222         TRAP_IGNORE( iManager.ShowErrorL( R_QTN_HS_HS_MEMORY_FULL ) );
   224         return err;
   223         }
   225         }    
   224 
   226     
   225     // Configuration loading failed totally
   227     // Configuration loading failed totally
   226     Panic( EXnInvalidConfiguration );
   228     return EXnInvalidConfiguration;
   227     
       
   228     return err;
       
   229     }
   229     }
   230 
   230 
   231 // -----------------------------------------------------------------------------
   231 // -----------------------------------------------------------------------------
   232 // CXnRootData::Destroy()
   232 // CXnRootData::Destroy()
   233 // 
   233 // 
   255     if ( iFlags.IsClear( EIsDispose ) )
   255     if ( iFlags.IsClear( EIsDispose ) )
   256         {
   256         {
   257         if ( !AllViewsLoaded() )
   257         if ( !AllViewsLoaded() )
   258             {
   258             {
   259             iLoadForward = ETrue;
   259             iLoadForward = ETrue;
       
   260             iLoadError = KErrNone;
   260             
   261             
   261             iLoadTimer->Cancel();
   262             iLoadTimer->Cancel();
   262             
   263             
   263             iLoadTimer->Start( TTimeIntervalMicroSeconds32( KScheduleInterval ),
   264             iLoadTimer->Start( TTimeIntervalMicroSeconds32( KScheduleInterval ),
   264                                TTimeIntervalMicroSeconds32( KScheduleInterval ),
   265                                TTimeIntervalMicroSeconds32( KScheduleInterval ),
   486     CXnRootData* self = static_cast< CXnRootData* >( aAny );
   487     CXnRootData* self = static_cast< CXnRootData* >( aAny );
   487     
   488     
   488     if ( self->iFlags.IsSet( EIsDispose ) )
   489     if ( self->iFlags.IsSet( EIsDispose ) )
   489         {
   490         {
   490         self->iLoadTimer->Cancel();
   491         self->iLoadTimer->Cancel();
       
   492         return KErrNone;
       
   493         }
       
   494 
       
   495     CXnPluginData& active( self->ActiveViewData() );
       
   496     
       
   497     CXnPluginData* toLoad( NULL );
       
   498                    
       
   499     TInt index( self->iPluginsData.Find( &active ) );
       
   500     TInt count( self->iPluginsData.Count() );
       
   501             
       
   502     if ( self->iLoadForward )
       
   503         {
       
   504         self->iLoadForward = EFalse;
       
   505         
       
   506         // Start from the next one
       
   507         index = index + 1;
       
   508         
       
   509         if ( index == count )
       
   510             {
       
   511             index = 0;
       
   512             }
       
   513                      
       
   514         for ( TInt i = index; i < self->iPluginsData.Count(); i++ )
       
   515             {
       
   516             if ( !self->iPluginsData[i]->Occupied() )
       
   517                 {
       
   518                 toLoad = self->iPluginsData[i];
       
   519                 break;
       
   520                 }
       
   521             }                              
   491         }
   522         }
   492     else
   523     else
   493         {               
   524         {
   494         CXnPluginData& active( self->ActiveViewData() );
   525         self->iLoadForward = ETrue;
   495         
   526         
   496         CXnPluginData* toLoad( NULL );
   527         if ( index == 0 )
   497                        
   528             {
   498         TInt index( self->iPluginsData.Find( &active ) );
   529             index = count - 1;
   499         TInt count( self->iPluginsData.Count() );
   530             }
   500                 
   531         else
   501         if ( self->iLoadForward )
   532             {
   502             {
   533             index = index - 1;
   503             self->iLoadForward = EFalse;
   534             }
   504             
   535         
   505             // Start from the next one
   536         for ( TInt i = index; i >= 0; i-- )
   506             index = index + 1;
   537             {
   507             
   538             if ( !self->iPluginsData[i]->Occupied() )
   508             if ( index == count )
       
   509                 {
   539                 {
   510                 index = 0;
   540                 toLoad = self->iPluginsData[i];
       
   541                 break;
   511                 }
   542                 }
   512                          
   543             }
   513             for ( TInt i = index; i < self->iPluginsData.Count(); i++ )
   544         }
   514                 {
   545     
   515                 if ( !self->iPluginsData[i]->Occupied() )
   546     TInt err( KErrNone );
   516                     {
   547     
   517                     toLoad = self->iPluginsData[i];
   548     if ( !self->AllViewsLoaded() && toLoad )
   518                     break;
   549         {                       
   519                     }
   550         err = toLoad->Load();
   520                 }                              
   551         
   521             }
   552         if ( err )
   522         else
       
   523             {
       
   524             self->iLoadForward = ETrue;
       
   525             
       
   526             if ( index == 0 )
       
   527                 {
       
   528                 index = count - 1;
       
   529                 }
       
   530             else
       
   531                 {
       
   532                 index = index - 1;
       
   533                 }
       
   534             
       
   535             for ( TInt i = index; i >= 0; i-- )
       
   536                 {
       
   537                 if ( !self->iPluginsData[i]->Occupied() )
       
   538                     {
       
   539                     toLoad = self->iPluginsData[i];
       
   540                     break;
       
   541                     }
       
   542                 }
       
   543             }
       
   544         
       
   545         if ( !self->AllViewsLoaded() && toLoad )
       
   546             {                       
       
   547             if ( toLoad->Load() == KErrNoMemory )
       
   548                 {
       
   549                 TRAP_IGNORE( 
       
   550                     self->iManager.ShowErrorL( R_QTN_HS_HS_MEMORY_FULL ) );                
       
   551                 }
       
   552             }
       
   553         
       
   554         if ( self->AllViewsLoaded() )
       
   555             {            
   553             {            
   556             self->iLoadTimer->Cancel();
   554             self->iLoadError = err;            
   557             self->iManager.NotifyAllViewsLoadedL();
   555             }
   558             }                    
   556         }
   559         }
   557         
   560         
   558     if ( err == KXnErrViewPluginFailure )
       
   559         {                
       
   560         // Remove the view        
       
   561         self->iManager.RemoveFaultyView( static_cast< CXnViewData* >( toLoad ) );
       
   562         
       
   563         delete toLoad;
       
   564         toLoad = NULL;        
       
   565         }
       
   566     
       
   567     if ( self->AllViewsLoaded() || err == KErrNoMemory )
       
   568         {            
       
   569         self->iLoadTimer->Cancel();
       
   570         
       
   571         // Show the error note only once
       
   572         self->iManager.HandleErrorNotes( self->iLoadError );  
       
   573         
       
   574         self->iLoadError = KErrNone;        
       
   575 		self->iManager.NotifyAllViewsLoadedL();
       
   576         }
       
   577     
   561     __PRINTS( "*** CXnRootData::RunLoadL - done" );
   578     __PRINTS( "*** CXnRootData::RunLoadL - done" );
   562     
   579     
   563     return KErrNone;
   580     return KErrNone;
   564     }
   581     }
   565 
   582