idlefw/src/framework/aifw.cpp
branchRCL_3
changeset 18 bd874ee5e5e2
parent 9 d0529222e3f0
child 59 a0713522ab97
equal deleted inserted replaced
9:d0529222e3f0 18:bd874ee5e5e2
    62 //
    62 //
    63 // ----------------------------------------------------------------------------
    63 // ----------------------------------------------------------------------------
    64 //
    64 //
    65 void CAiFw::ConstructL()
    65 void CAiFw::ConstructL()
    66     {
    66     {
       
    67     __PRINTS( "*** CAiFw::ConstructL" );
       
    68     __TIME_MARK( time );
    67 #if 0
    69 #if 0
    68     // For AI3_test    
    70     // For AI3_test    
    69     RProcess proc;
    71     RProcess proc;
    70     // 0x102750F0 in AI3, 0x2001CB4F in AI3_Test
    72     // 0x102750F0 in AI3, 0x2001CB4F in AI3_Test
    71     TSecureId secId( proc.SecureId() ); 
    73     TSecureId secId( proc.SecureId() ); 
   100     iUiControllerManager = CAiUiControllerManager::NewL( this );
   102     iUiControllerManager = CAiUiControllerManager::NewL( this );
   101     
   103     
   102     iFactory = CAiPluginFactory::NewL( *iUiControllerManager );
   104     iFactory = CAiPluginFactory::NewL( *iUiControllerManager );
   103     
   105     
   104     iStateManager = CAiStateManager::NewL( *iFactory );
   106     iStateManager = CAiStateManager::NewL( *iFactory );
   105                  
   107                
   106     iEventHandler = CAiEventHandler::NewL( *iFactory );                                                                   
   108     iStateProvider = CAiStateProvider::NewL( *iStateManager );
       
   109     
       
   110     iEventHandler = CAiEventHandler::NewL( *iFactory );
       
   111     
       
   112     iUiControllerManager->SetStateHandler( *iStateProvider );
       
   113     
       
   114     __TIME_ENDMARK( "CAiFw::ConstructL, done", time );
   107     }
   115     }
   108 
   116 
   109 // ----------------------------------------------------------------------------
   117 // ----------------------------------------------------------------------------
   110 // CAiFw::NewLC()
   118 // CAiFw::NewLC()
   111 //
   119 //
   112 // ----------------------------------------------------------------------------
   120 // ----------------------------------------------------------------------------
   113 //
   121 //
   114 EXPORT_C CAiFw* CAiFw::NewLC()
   122 EXPORT_C CAiFw* CAiFw::NewLC()
   115     {
   123     {
       
   124     __TICK( "CAiFw::NewLC" );
       
   125     
   116     CAiFw* self = new ( ELeave ) CAiFw;
   126     CAiFw* self = new ( ELeave ) CAiFw;
   117     CleanupStack::PushL( self );
   127     CleanupStack::PushL( self );
   118     
   128     
   119     self->ConstructL();
   129     self->ConstructL();
   120 
   130 
   121     __TICK( "FW: Core FW constructed" );
   131     __PRINTS( "*** CAiFw::NewLC - done" );
   122     __HEAP( "FW: Core FW constructed" );
       
   123     
   132     
   124     return self;
   133     return self;
   125     }
   134     }
   126 
   135 
   127 // ----------------------------------------------------------------------------
   136 // ----------------------------------------------------------------------------
   181 //
   190 //
   182 // ----------------------------------------------------------------------------
   191 // ----------------------------------------------------------------------------
   183 //
   192 //
   184 EXPORT_C void CAiFw::RunL()
   193 EXPORT_C void CAiFw::RunL()
   185     {
   194     {
   186     CAiIdleAppRegister* idleReg = CAiIdleAppRegister::NewLC();
   195     __TICK( "CAiFw::RunL" );
   187     idleReg->RegisterL();
   196         
   188     CleanupStack::PopAndDestroy( idleReg );
   197     __PRINTS( "*** CAiFw::RunL - CAiIdleAppRegister::NewLC" );
   189 
   198     __TIME_MARK( time );
       
   199             
       
   200     CAiIdleAppRegister* registry = CAiIdleAppRegister::NewLC();
       
   201     registry->RegisterL();
       
   202     CleanupStack::PopAndDestroy( registry );
       
   203 
       
   204     __TIME_ENDMARK( "CAiFw::RunL - CAiIdleAppRegister::NewLC, done", time );
       
   205         
   190     // Tell UI controller manager to start application framework and event loop.
   206     // Tell UI controller manager to start application framework and event loop.
   191     // This function returns only when the application is shut down.
   207     // This function returns only when the application is shut down.    
   192     // See in CAiFw::HandleUiReadyEventL how the framework initialization continues.
       
   193     iUiControllerManager->RunApplicationL();
   208     iUiControllerManager->RunApplicationL();
       
   209     
       
   210     __PRINTS( "*** CAiFw::RunL - done" );
   194     }
   211     }
   195 
   212 
   196 // ----------------------------------------------------------------------------
   213 // ----------------------------------------------------------------------------
   197 // CAiFw::AppEnvReadyL()
   214 // CAiFw::AppEnvReadyL()
   198 //
   215 //
   199 // ----------------------------------------------------------------------------
   216 // ----------------------------------------------------------------------------
   200 //
   217 //
   201 void CAiFw::AppEnvReadyL()
   218 void CAiFw::AppEnvReadyL()
   202     {
   219     {
       
   220     __TICK( "CAiFw::AppEnvReadyL" );
       
   221     __TIME_MARK( time );
       
   222     
   203     // Initialize members which need to be connected to the app environment's
   223     // Initialize members which need to be connected to the app environment's
   204     // active scheduler or depend on the app environment being initialized.
   224     // active scheduler or depend on the app environment being initialized.
   205 
   225 
   206     CCoeEnv& env( iUiControllerManager->CoeEnv() );
   226     CCoeEnv& env( iUiControllerManager->CoeEnv() );
   207 
   227 
   208     // Create WS pluign manager
   228     // Create WS pluign manager
   209     iWsPluginManager = CAiWsPluginManager::NewL( env );
   229     iWsPluginManager = CAiWsPluginManager::NewL( env );
   210     
   230     
   211     iStateProvider = CAiStateProvider::NewL( *iStateManager, env );
   231     // Start state provider
   212     
   232     iStateProvider->StartL( env );
   213     iUiControllerManager->SetStateHandler( *iStateProvider );
   233                
   214         
       
   215     // CenRep notifier to listen key changes in cenrep. 
   234     // CenRep notifier to listen key changes in cenrep. 
   216     // Application is restarted if key value is changed.
   235     // Application is restarted if key value is changed.
   217     iNotifyHandler = CCenRepNotifyHandler::NewL( *this, *iRepository,  
   236     iNotifyHandler = CCenRepNotifyHandler::NewL( *this, *iRepository,  
   218         CCenRepNotifyHandler::EIntKey, KAiMainUIController );
   237         CCenRepNotifyHandler::EIntKey, KAiMainUIController );
   219                                                                                                                                                   
   238                                                                                                                                                   
   225                                                      
   244                                                      
   226     iNotifyHandlerESS->StartListeningL();
   245     iNotifyHandlerESS->StartListeningL();
   227 
   246 
   228     iIdleRestartObserver = AiUtility::CreatePSPropertyObserverL(
   247     iIdleRestartObserver = AiUtility::CreatePSPropertyObserverL(
   229         TCallBack( HandleRestartEvent, this ), 
   248         TCallBack( HandleRestartEvent, this ), 
   230         KPSUidAiInformation, KActiveIdleRestartAI2 );                                                      
   249         KPSUidAiInformation, KActiveIdleRestartAI2 );
       
   250     
       
   251     __PRINTS( "*** CAiFw::AppEnvReadyL - done" );
   231     }
   252     }
   232 
   253 
   233 // ----------------------------------------------------------------------------
   254 // ----------------------------------------------------------------------------
   234 // CAiFw::HandleUiReadyEventL()
   255 // CAiFw::HandleUiReadyEventL()
   235 //
   256 //
   236 // ----------------------------------------------------------------------------
   257 // ----------------------------------------------------------------------------
   237 //
   258 //
   238 void CAiFw::HandleUiReadyEventL( CAiUiController& aUiController )
   259 void CAiFw::HandleUiReadyEventL( CAiUiController& aUiController )
   239     {         
   260     {         
       
   261     __TICK( "CAiFw::HandleUiReadyEventL" );
       
   262     
   240     if ( iUiControllerManager->IsMainUiController( aUiController ) )
   263     if ( iUiControllerManager->IsMainUiController( aUiController ) )
   241         {                      
   264         {    
   242         TInt value( EIdlePhase1Ok );
   265         TInt value( EIdlePhase1Ok );
   243         
   266         
   244         RProperty::Get( KPSUidStartup, 
   267         RProperty::Get( KPSUidStartup, KPSIdlePhase1Ok, value ); 
   245                         KPSIdlePhase1Ok, 
   268                                                                                               
   246                         value );
       
   247                                                       
       
   248         if ( value == EIdlePhase1NOK )
   269         if ( value == EIdlePhase1NOK )
   249             {
   270             {
   250             RProperty::Set( KPSUidStartup, 
   271             __TICK( "CAiFw::HandleUiReadyEventL - Setting EIdlePhase1Ok" );
   251                             KPSIdlePhase1Ok, 
   272             
   252                             EIdlePhase1Ok );                                                          
   273             RProperty::Set( KPSUidStartup, KPSIdlePhase1Ok, EIdlePhase1Ok );                                                                                                          
   253             }    
   274             }                      
   254         
   275     
   255         if ( !iLibrariesLoaded )
   276         if ( !iLibrariesLoaded )
   256             {
   277             {
       
   278             __PRINTS( "*** CAiFw::HandleUiReadyEventL - load libraries" );
       
   279             __TIME_MARK( time );
       
   280             
   257             _LIT( KAIVoiceUIDialer, "VoiceUiNameDialer.dll" );
   281             _LIT( KAIVoiceUIDialer, "VoiceUiNameDialer.dll" );
   258             _LIT( KAIVoiceUIRecog, "VoiceUiRecognition.dll" );
   282             _LIT( KAIVoiceUIRecog, "VoiceUiRecognition.dll" );
   259             _LIT( KAIVCommandHandler, "vcommandhandler.dll" );
   283             _LIT( KAIVCommandHandler, "vcommandhandler.dll" );
   260             
   284             
   261             iLibrary1.Load( KAIVoiceUIDialer );
   285             iLibrary1.Load( KAIVoiceUIDialer );
   262             iLibrary2.Load( KAIVoiceUIRecog );
   286             iLibrary2.Load( KAIVoiceUIRecog );
   263             iLibrary3.Load( KAIVCommandHandler );        
   287             iLibrary3.Load( KAIVCommandHandler );        
   264             
   288             
   265             iLibrariesLoaded = ETrue;
   289             iLibrariesLoaded = ETrue;
   266             }
   290             
   267         
   291             __TIME_ENDMARK( "CAiFw::HandleUiReadyEventL - load libraries, done", time );            
   268         iUiControllerManager->LoadUIDefinition();
   292             }             
   269         }
   293         }
       
   294     
       
   295     __PRINTS( "*** CAiFw::HandleUiReadyEventL - done" );
   270     }
   296     }
   271 
   297 
   272 // ---------------------------------------------------------------------------
   298 // ---------------------------------------------------------------------------
   273 // CAiFw::HandleActivateUI()
   299 // CAiFw::HandleActivateUI()
   274 //
   300 //
   275 // ----------------------------------------------------------------------------
   301 // ----------------------------------------------------------------------------
   276 //
   302 //
   277 void CAiFw::HandleActivateUI()
   303 void CAiFw::HandleActivateUI()
   278     {
   304     {
   279     iUiControllerManager->ActivateUI();         
   305     __PRINTS( "*** CAiFw::HandleActivateUI" );
       
   306     __TIME_MARK( time );
       
   307     
       
   308     iUiControllerManager->LoadUIDefinition();
       
   309     
       
   310     iUiControllerManager->ActivateUI();     
       
   311     
       
   312     __TIME_ENDMARK( "CAiFw::HandleActivateUI, done", time );
   280     }
   313     }
   281 
   314 
   282 // ---------------------------------------------------------------------------
   315 // ---------------------------------------------------------------------------
   283 // CAiFw::HandleUiShutdown()
   316 // CAiFw::HandleUiShutdown()
   284 //
   317 //
   310         iWsPluginManager = NULL;
   343         iWsPluginManager = NULL;
   311         
   344         
   312         Release( iIdleRestartObserver );
   345         Release( iIdleRestartObserver );
   313         iIdleRestartObserver = NULL;
   346         iIdleRestartObserver = NULL;
   314         
   347         
   315         delete iStateProvider;
   348         iStateProvider->Stop();
   316         iStateProvider = NULL;
       
   317         }
   349         }
   318     }
   350     }
   319 
   351 
   320 // ----------------------------------------------------------------------------
   352 // ----------------------------------------------------------------------------
   321 // CAiFw::HandlePluginEvent()
   353 // CAiFw::HandlePluginEvent()