idlehomescreen/xmluirendering/uiengine/src/xnrootdata.cpp
branchRCL_3
changeset 9 f966699dea19
parent 0 f72a12da539e
child 15 ff572dfe6d86
equal deleted inserted replaced
5:c743ef5928ba 9:f966699dea19
    37 
    37 
    38 #include "xnplugindata.h"
    38 #include "xnplugindata.h"
    39 #include "xnrootdata.h"
    39 #include "xnrootdata.h"
    40 
    40 
    41 // Constants
    41 // Constants
    42 const TInt KScheduleInterval( 1000000 );
    42 const TInt KScheduleInterval( 2000000 );
    43 
    43 
    44 // ============================ LOCAL FUNCTIONS ================================
    44 // ============================ LOCAL FUNCTIONS ================================
    45 
    45 
    46 // ============================ MEMBER FUNCTIONS ===============================
    46 // ============================ MEMBER FUNCTIONS ===============================
    47 // -----------------------------------------------------------------------------
    47 // -----------------------------------------------------------------------------
   128     
   128     
   129     iEcomHandler = CXnEcomHandler::NewL();
   129     iEcomHandler = CXnEcomHandler::NewL();
   130     
   130     
   131     iParser = CXnODTParser::NewL( iManager, *iEcomHandler );   
   131     iParser = CXnODTParser::NewL( iManager, *iEcomHandler );   
   132     
   132     
   133     iLoadTimer = CPeriodic::NewL( CActive::EPriorityStandard );           
   133     iLoadTimer = CPeriodic::NewL( CActive::EPriorityLow );           
   134     iDestroyTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   134     iDestroyTimer = CPeriodic::NewL( CActive::EPriorityLow );
   135     }
   135     }
   136 
   136 
   137 // -----------------------------------------------------------------------------
   137 // -----------------------------------------------------------------------------
   138 // CXnRootData::LoadL()
   138 // CXnRootData::Load()
   139 // 
   139 // 
   140 // -----------------------------------------------------------------------------
   140 // -----------------------------------------------------------------------------
   141 //
   141 //
   142 void CXnRootData::LoadL()
   142 TInt CXnRootData::Load()
   143     { 
   143     { 
   144     if ( Occupied() )
   144     if ( Occupied() )
   145         {
   145         {
   146         return;
   146         return KErrInUse;
   147         }
   147         }
   148            
   148     
       
   149     TInt err( KErrNone );
       
   150         
   149     // Load application root configuration
   151     // Load application root configuration
   150     TRAPD( error,
   152     TRAP( err, iODT = iManager.Composer().ComposeRootL( *this ) );
   151             
   153     
   152         iODT = iManager.Composer().ComposeRootL( *this );
   154     if ( !iODT )
   153     
       
   154         if ( iODT )
       
   155             {
       
   156             iManager.Parser().LoadRootL( *this, iApplicationUid );
       
   157             }              
       
   158         );
       
   159     
       
   160     if ( !iODT || error || !Occupied() )
       
   161         {
       
   162         // Can't recover
       
   163         Panic( EXnInvalidConfiguration );               
       
   164         }
       
   165     
       
   166     RPointerArray< CXnViewData > failedPlugins;
       
   167     CleanupClosePushL( failedPlugins );
       
   168     
       
   169     TBool succeed( EFalse );
       
   170            
       
   171     for ( TInt i = 0; i < iPluginsData.Count(); i++ )
       
   172         {
       
   173         CXnViewData* plugin( 
       
   174                 static_cast< CXnViewData* >( iPluginsData[ i ] ) ); 
       
   175         
       
   176         if ( plugin->Initial() )
       
   177             {
       
   178             plugin->LoadL();
       
   179     
       
   180             if ( plugin->Occupied() )
       
   181                 {
       
   182                 succeed = ETrue;                
       
   183                 }
       
   184             else
       
   185                 {
       
   186                 // Failed to load
       
   187                 failedPlugins.AppendL( plugin );                
       
   188                 }
       
   189 
       
   190             break;
       
   191             }
       
   192         } 
       
   193                             
       
   194     for ( TInt i = 0; !succeed && i < iPluginsData.Count(); i++ )
       
   195         {
       
   196         CXnViewData* plugin( 
       
   197                 static_cast< CXnViewData* >( iPluginsData[ i ] ) );
       
   198         
       
   199         if ( failedPlugins.Find( plugin ) == KErrNotFound )
       
   200             {
       
   201             plugin->SetInitial();
       
   202             
       
   203             plugin->LoadL();
       
   204 
       
   205             if ( plugin->Occupied() )
       
   206                 {                                       
       
   207                 succeed = ETrue;                
       
   208                 }
       
   209             else
       
   210                 {
       
   211                 // Failed to load
       
   212                 failedPlugins.AppendL( plugin );                                                    
       
   213                 }
       
   214             }
       
   215         }    
       
   216     
       
   217     if ( !succeed )
       
   218         {
   155         {
   219         // Can't recover
   156         // Can't recover
   220         Panic( EXnInvalidConfiguration );                       
   157         Panic( EXnInvalidConfiguration );                       
   221         }
   158         }
   222     
   159        
   223     for ( TInt i = failedPlugins.Count() - 1; i >= 0; i-- )
   160     if ( !err )
   224         {        
   161         {
   225         CXnPluginData* toDestroy( failedPlugins[i] );
   162         TRAP( err, iManager.Parser().LoadRootL( *this, iApplicationUid ) );
   226         
   163         }
   227         TInt index( iPluginsData.Find( toDestroy ) );
   164     
   228         
   165     if ( !err )
   229         iPluginsData.Remove( index );
   166         {                
   230         
   167         for ( TInt i = 0; i < iPluginsData.Count(); i++ )
   231         delete toDestroy;
   168             {
   232         toDestroy = NULL;                     
   169             CXnViewData* plugin( 
   233         }
   170                 static_cast< CXnViewData* >( iPluginsData[ i ] ) ); 
   234     
   171             
   235     CleanupStack::PopAndDestroy( &failedPlugins );
   172             if ( plugin->Initial() )
       
   173                 {
       
   174                 err = plugin->Load();
       
   175                                     
       
   176                 if ( plugin->Occupied() )
       
   177                     {
       
   178                     // Initial view is succesfully composed. Some plugins
       
   179                     // may have failed but it doesn't matter as those are removed                                        
       
   180                     return KErrNone;
       
   181                     }     
       
   182                 
       
   183                 // Initial view failed, remove it
       
   184                 iPluginsData.Remove( i );
       
   185                 
       
   186                 delete plugin;
       
   187                 plugin = NULL;                                                
       
   188                 break;                             
       
   189                 }
       
   190             }
       
   191                                     
       
   192         // Initial view loading failed, fallback to load any of the views
       
   193         while( iPluginsData.Count() )
       
   194             {
       
   195             CXnViewData* plugin( 
       
   196                 static_cast< CXnViewData* >( iPluginsData[ 0 ] ) ); 
       
   197 
       
   198             // Ignore error
       
   199             plugin->Load();
       
   200                             
       
   201             if ( plugin->Occupied() )
       
   202                 {
       
   203                 // Return error because of fallback condition                                
       
   204                 return KXnErrPluginFailure;
       
   205                 }
       
   206 
       
   207             // View failed, remove it
       
   208             iPluginsData.Remove( 0 );
       
   209             
       
   210             delete plugin;
       
   211             plugin = NULL;
       
   212             }        
       
   213         }
       
   214     else if ( err == KErrNoMemory )
       
   215         {
       
   216         ShowOutOfMemError();
       
   217         }
       
   218 
       
   219     // Configuration loading failed totally
       
   220     Panic( EXnInvalidConfiguration );
       
   221     
       
   222     return err;
   236     }
   223     }
   237 
   224 
   238 // -----------------------------------------------------------------------------
   225 // -----------------------------------------------------------------------------
   239 // CXnRootData::Destroy()
   226 // CXnRootData::Destroy()
   240 // 
   227 // 
   540                 }
   527                 }
   541             }
   528             }
   542         
   529         
   543         if ( !self->AllViewsLoaded() && toLoad )
   530         if ( !self->AllViewsLoaded() && toLoad )
   544             {                       
   531             {                       
   545             toLoad->LoadL();            
   532             if ( toLoad->Load() == KErrNoMemory )
       
   533                 {
       
   534                 self->ShowOutOfMemError();
       
   535                 }
   546             }
   536             }
   547         
   537         
   548         if ( self->AllViewsLoaded() )
   538         if ( self->AllViewsLoaded() )
   549             {            
   539             {            
   550             self->iLoadTimer->Cancel();            
   540             self->iLoadTimer->Cancel();