idlefw/src/framework/aiuicontrollermanager.cpp
branchRCL_3
changeset 9 d0529222e3f0
parent 0 79c6a41cd166
equal deleted inserted replaced
4:1a2a00e78665 9:d0529222e3f0
    13 *
    13 *
    14 * Description:  UI controller manager class
    14 * Description:  UI controller manager class
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 // System includes
    19 #include "aiuicontrollermanager.h"
    19 #include <centralrepository.h>
       
    20 
       
    21 // User includes
       
    22 #include <aisystemuids.hrh>
    20 #include "aiuicontroller.h"
    23 #include "aiuicontroller.h"
    21 #include "aicontentpublisher.h"
       
    22 #include "aicontentobserver.h"
    24 #include "aicontentobserver.h"
    23 #include "activeidle2domaincrkeys.h"
    25 #include "activeidle2domaincrkeys.h"
       
    26 #include "aifw.h"
       
    27 
       
    28 #include "aiuicontrollermanager.h"
       
    29 
    24 #include "aifwpanic.h"
    30 #include "aifwpanic.h"
    25 #include <ecom/ecom.h>
       
    26 #include <ecom/implementationinformation.h>
       
    27 #include <centralrepository.h>
       
    28 
       
    29 #include <aisystemuids.hrh>
       
    30 
    31 
    31 #include "debug.h"
    32 #include "debug.h"
    32 
    33 
    33 // ======== MEMBER FUNCTIONS ========
    34 // ======== MEMBER FUNCTIONS ========
    34 
    35 
    35 // ----------------------------------------------------------------------------
    36 // ----------------------------------------------------------------------------
    36 // CAiUiControllerManager::CAiUiControllerManager()
    37 // CAiUiControllerManager::CAiUiControllerManager()
       
    38 //
    37 // ----------------------------------------------------------------------------
    39 // ----------------------------------------------------------------------------
    38 //
    40 //
    39 CAiUiControllerManager::CAiUiControllerManager()
    41 CAiUiControllerManager::CAiUiControllerManager()
    40     {
    42     {
    41     }
    43     }
    42 
    44 
    43 // ----------------------------------------------------------------------------
    45 // ----------------------------------------------------------------------------
    44 // CAiUiControllerManager::LoadMainControllerL()
    46 // CAiUiControllerManager::LoadMainControllerL()
    45 // ----------------------------------------------------------------------------
    47 //
    46 //
    48 // ----------------------------------------------------------------------------
    47 void CAiUiControllerManager::LoadMainControllerL(
    49 //
    48     CRepository& aCenRepConfig )
    50 void CAiUiControllerManager::LoadMainControllerL( CRepository& aRepository )    
    49     {
    51     {
    50     TInt value( 0 );
    52     TInt value( 0 );
    51     
    53     
    52     // Main UI Controller must be configured correctly
    54     // Main UI Controller must be configured correctly
    53     User::LeaveIfError( aCenRepConfig.Get( KAiMainUIController, value ) );
    55     User::LeaveIfError( aRepository.Get( KAiMainUIController, value ) );
    54     
    56     
    55     CAiUiController* controller = CAiUiController::NewL( TUid::Uid( value ) );
    57     CAiUiController* controller = CAiUiController::NewL( TUid::Uid( value ) );
    56     
    58     
    57     iCreatedUICList.Append( value );
    59     iCreatedUICList.Append( value );
    58     CleanupStack::PushL( controller );
    60     CleanupStack::PushL( controller );
    65         __PRINT( __DBG_FORMAT("Main UI controller interface not found from controller 0x%x"), value );
    67         __PRINT( __DBG_FORMAT("Main UI controller interface not found from controller 0x%x"), value );
    66         User::Leave( KErrNotFound );
    68         User::Leave( KErrNotFound );
    67         }
    69         }
    68     
    70     
    69     iUiControllerArray.AppendL( controller );
    71     iUiControllerArray.AppendL( controller );
    70     CleanupStack::Pop( controller );
    72     CleanupStack::Pop( controller );    
    71     
       
    72     // Register this as a UI framework observer of the main UI controller
       
    73     iMainUiController->SetUiFrameworkObserver( *this );
       
    74     }
    73     }
    75 
    74 
    76 // ----------------------------------------------------------------------------
    75 // ----------------------------------------------------------------------------
    77 // CAiUiControllerManager::LoadSecondaryControllersL()
    76 // CAiUiControllerManager::LoadSecondaryControllersL()
       
    77 //
    78 // ----------------------------------------------------------------------------
    78 // ----------------------------------------------------------------------------
    79 //
    79 //
    80 void CAiUiControllerManager::LoadSecondaryControllersL(
    80 void CAiUiControllerManager::LoadSecondaryControllersL(
    81     CRepository& aCenRepConfig )
    81     CRepository& aRepository )
    82     {
    82     {
    83     TInt value( 0 );
    83     TInt value( 0 );
    84     
    84     
    85     // Instantiate rest of the UI controllers.
    85     // Instantiate rest of the UI controllers.
    86     for( TInt key = KAiFirstUIController; 
    86     for( TInt key = KAiFirstUIController; 
    87          key <= KAiLastUIController && aCenRepConfig.Get( key, value ) == KErrNone;
    87          key <= KAiLastUIController && aRepository.Get( key, value ) == KErrNone;
    88         ++key )
    88         ++key )
    89         {
    89         {
    90         // skip empty entries
    90         // skip empty entries
    91         if( value == 0 )
    91         if( value == 0 )
    92             {
    92             {
   104             CAiUiController::NewL( TUid::Uid( value ) );
   104             CAiUiController::NewL( TUid::Uid( value ) );
   105         
   105         
   106         CleanupStack::PushL( controller );
   106         CleanupStack::PushL( controller );
   107         
   107         
   108         iUiControllerArray.AppendL( controller );
   108         iUiControllerArray.AppendL( controller );
   109         CleanupStack::Pop( controller );
   109         CleanupStack::Pop( controller );        
   110         
       
   111         // Get the secondary interface
       
   112         MAiSecondaryUiController* secController( 
       
   113                     controller->SecondaryInterface() ); 
       
   114                         
       
   115         if( secController )
       
   116             {
       
   117             MAiUiFrameworkObserver* uiFwObserver(
       
   118                     secController->UiFrameworkObserver() );
       
   119         
       
   120             if( uiFwObserver )
       
   121                 {
       
   122                 // Add secondary controller as UI framework event observer. 
       
   123                 User::LeaveIfError( 
       
   124                         iUiFrameworkObservers.InsertInAddressOrder( uiFwObserver ) );
       
   125                 }
       
   126             }
       
   127         }
   110         }
   128     }
   111     }
   129 
   112 
   130 // ----------------------------------------------------------------------------
   113 // ----------------------------------------------------------------------------
   131 // CAiUiControllerManager::ConstructL()
   114 // CAiUiControllerManager::ConstructL()
   132 // ----------------------------------------------------------------------------
   115 //
   133 //
   116 // ----------------------------------------------------------------------------
   134 void CAiUiControllerManager::ConstructL()
   117 //
       
   118 void CAiUiControllerManager::ConstructL( CAiFw* aAiFw )
   135     {
   119     {
   136     __HEAP("FW: Init - Create UI Ctrls");
   120     __HEAP("FW: Init - Create UI Ctrls");
   137     __TIME_MARK(t);
   121     __TIME_MARK(t);
   138 
   122    
   139     CRepository* cenRep( NULL );
   123     CRepository& repository( aAiFw->Repository() );
   140 
   124     
   141 #if 0
   125     LoadMainControllerL( repository );
   142     // For AI3_test    
       
   143     RProcess proc;
       
   144     // 0x102750F0 in AI3, 0x2001CB4F in AI3_Test
       
   145     TSecureId secId( proc.SecureId() ); 
       
   146                                            
       
   147     if( secId == 0x2001CB4F )
       
   148         {
       
   149         cenRep = CRepository::NewL( TUid::Uid( 0x2001952B ) );
       
   150         }   
       
   151     else
       
   152         {
       
   153         cenRep = CRepository::NewL( TUid::Uid( KCRUidActiveIdleLV ) );
       
   154         }
       
   155 #else
       
   156     cenRep = CRepository::NewLC( TUid::Uid( KCRUidActiveIdleLV ) );
       
   157 #endif
       
   158 
       
   159     LoadMainControllerL( *cenRep );
       
   160     
   126     
   161     // Failing on secondary is not fatal. Ignore leaves.
   127     // Failing on secondary is not fatal. Ignore leaves.
   162     TRAP_IGNORE( LoadSecondaryControllersL( *cenRep ) );
   128     TRAP_IGNORE( LoadSecondaryControllersL( repository ) );
   163                        
   129                            
   164     CleanupStack::PopAndDestroy( cenRep );
   130     for ( TInt i = 0; i < iUiControllerArray.Count(); i++ )
   165     
   131         {
       
   132         iUiControllerArray[i]->SetEventHandler( *aAiFw );
       
   133         }
       
   134         
   166     __TIME_ENDMARK("FW: Create UI Ctrls", t);
   135     __TIME_ENDMARK("FW: Create UI Ctrls", t);
   167     __HEAP("FW: Done - Create UI Ctrls");
   136     __HEAP("FW: Done - Create UI Ctrls");
   168     }
   137     }
   169 
   138 
   170 // ----------------------------------------------------------------------------
   139 // ----------------------------------------------------------------------------
   171 // CAiUiControllerManager::NewL()
   140 // CAiUiControllerManager::NewL()
   172 // ----------------------------------------------------------------------------
   141 //
   173 //
   142 // ----------------------------------------------------------------------------
   174 CAiUiControllerManager* CAiUiControllerManager::NewL()
   143 //
   175     {
   144 CAiUiControllerManager* CAiUiControllerManager::NewL( CAiFw* aAiFw )
   176     CAiUiControllerManager* self = new (ELeave) CAiUiControllerManager;
   145     {
       
   146     CAiUiControllerManager* self = 
       
   147         new ( ELeave ) CAiUiControllerManager;
   177     
   148     
   178     CleanupStack::PushL( self );
   149     CleanupStack::PushL( self );
   179     self->ConstructL();
   150     self->ConstructL( aAiFw );
   180     CleanupStack::Pop( self ); // self
   151     CleanupStack::Pop( self ); // self
   181     
   152     
   182     return self;
   153     return self;
   183     }
   154     }
   184 
   155 
   185 // ----------------------------------------------------------------------------
   156 // ----------------------------------------------------------------------------
   186 // CAiUiControllerManager::~CAiUiControllerManager()
   157 // CAiUiControllerManager::~CAiUiControllerManager()
       
   158 //
   187 // ----------------------------------------------------------------------------
   159 // ----------------------------------------------------------------------------
   188 //
   160 //
   189 CAiUiControllerManager::~CAiUiControllerManager()
   161 CAiUiControllerManager::~CAiUiControllerManager()
   190     {
   162     {
   191     iUiControllerArray.ResetAndDestroy();
   163     iUiControllerArray.ResetAndDestroy();
   192     
   164            
   193     iUiFrameworkObservers.Reset();
       
   194     
       
   195     iCreatedUICList.Reset();
   165     iCreatedUICList.Reset();
   196     }
   166     }
   197 
   167 
   198 // ----------------------------------------------------------------------------
   168 // ----------------------------------------------------------------------------
   199 // CAiUiControllerManager::UiControllers() 
   169 // CAiUiControllerManager::UiControllers()
       
   170 //
   200 // ----------------------------------------------------------------------------
   171 // ----------------------------------------------------------------------------
   201 //
   172 //
   202 RPointerArray< CAiUiController >& CAiUiControllerManager::UiControllers() const
   173 RPointerArray< CAiUiController >& CAiUiControllerManager::UiControllers() const
   203     {
   174     {
   204     return iUiControllerArray;
   175     return iUiControllerArray;
   205     }
   176     }
   206 
   177 
   207 // ----------------------------------------------------------------------------
   178 // ----------------------------------------------------------------------------
   208 // CAiUiControllerManager::IsMainUiController()
   179 // CAiUiControllerManager::IsMainUiController()
       
   180 //
   209 // ----------------------------------------------------------------------------
   181 // ----------------------------------------------------------------------------
   210 //
   182 //
   211 TBool CAiUiControllerManager::IsMainUiController(
   183 TBool CAiUiControllerManager::IsMainUiController(
   212     CAiUiController& aUiController ) const
   184     CAiUiController& aUiController ) const
   213     {
   185     {
   214     return ( aUiController.MainInterface() == iMainUiController );
   186     return ( aUiController.MainInterface() == iMainUiController );
   215     }
   187     }
   216 
   188 
   217 // ----------------------------------------------------------------------------
   189 // ----------------------------------------------------------------------------
   218 // CAiUiControllerManager::SetEventHandler()
       
   219 // ----------------------------------------------------------------------------
       
   220 //
       
   221 void CAiUiControllerManager::SetEventHandler(
       
   222     MAiFwEventHandler& aEventHandler )
       
   223     {
       
   224     for ( TInt i = 0; i < iUiControllerArray.Count(); i++ )
       
   225         {
       
   226         iUiControllerArray[i]->SetEventHandler( aEventHandler );
       
   227         }
       
   228     }
       
   229 
       
   230 // ----------------------------------------------------------------------------
       
   231 // CAiUiControllerManager::RunApplicationL()
   190 // CAiUiControllerManager::RunApplicationL()
       
   191 //
   232 // ----------------------------------------------------------------------------
   192 // ----------------------------------------------------------------------------
   233 //
   193 //
   234 void CAiUiControllerManager::RunApplicationL()
   194 void CAiUiControllerManager::RunApplicationL()
   235     {
   195     {
   236     iMainUiController->RunApplicationL();
   196     iMainUiController->RunApplicationL();
   237     }
   197     }
   238 
   198 
   239 // ----------------------------------------------------------------------------
   199 // ----------------------------------------------------------------------------
   240 // CAiUiControllerManager::ActivateUI()
   200 // CAiUiControllerManager::ActivateUI()
       
   201 //
   241 // ----------------------------------------------------------------------------
   202 // ----------------------------------------------------------------------------
   242 //
   203 //
   243 void CAiUiControllerManager::ActivateUI()
   204 void CAiUiControllerManager::ActivateUI()
   244     {
   205     {
   245     for( TInt i = 0; i < iUiControllerArray.Count(); i++ )
   206     for( TInt i = 0; i < iUiControllerArray.Count(); i++ )
   248         }
   209         }
   249     }
   210     }
   250     
   211     
   251 // ----------------------------------------------------------------------------
   212 // ----------------------------------------------------------------------------
   252 // CAiUiControllerManager::LoadUIDefinition()
   213 // CAiUiControllerManager::LoadUIDefinition()
       
   214 //
   253 // ----------------------------------------------------------------------------
   215 // ----------------------------------------------------------------------------
   254 //
   216 //
   255 void CAiUiControllerManager::LoadUIDefinition()
   217 void CAiUiControllerManager::LoadUIDefinition()
   256     {       
   218     {       
   257     for( TInt i = 0; i < iUiControllerArray.Count(); i++ )
   219     for( TInt i = 0; i < iUiControllerArray.Count(); i++ )
   288         }
   250         }
   289     }
   251     }
   290 
   252 
   291 // ----------------------------------------------------------------------------
   253 // ----------------------------------------------------------------------------
   292 // CAiUiControllerManager::CoeEnv()
   254 // CAiUiControllerManager::CoeEnv()
       
   255 //
   293 // ----------------------------------------------------------------------------
   256 // ----------------------------------------------------------------------------
   294 //
   257 //
   295 CCoeEnv& CAiUiControllerManager::CoeEnv() const
   258 CCoeEnv& CAiUiControllerManager::CoeEnv() const
   296     {
   259     {
   297     return iMainUiController->CoeEnv();
   260     return iMainUiController->CoeEnv();
   298     }
   261     }
   299 
   262 
   300 // ----------------------------------------------------------------------------
   263 // ----------------------------------------------------------------------------
   301 // CAiUiControllerManager::MainUiController()
   264 // CAiUiControllerManager::MainUiController()
       
   265 //
   302 // ----------------------------------------------------------------------------
   266 // ----------------------------------------------------------------------------
   303 //
   267 //
   304 MAiMainUiController& CAiUiControllerManager::MainUiController() const
   268 MAiMainUiController& CAiUiControllerManager::MainUiController() const
   305     {
   269     {
   306     return *iMainUiController;
   270     return *iMainUiController;
   307     }
   271     }
   308 
   272 
   309 // ----------------------------------------------------------------------------
   273 // ----------------------------------------------------------------------------
   310 // CAiUiControllerManager::DestroySecondaryUiControllers()
   274 // CAiUiControllerManager::DestroySecondaryUiControllers()
       
   275 //
   311 // ----------------------------------------------------------------------------
   276 // ----------------------------------------------------------------------------
   312 //
   277 //
   313 void CAiUiControllerManager::DestroySecondaryUiControllers()
   278 void CAiUiControllerManager::DestroySecondaryUiControllers()
   314     {
   279     {
   315     for( TInt i = iUiControllerArray.Count() - 1; i >= 0; --i )
   280     for( TInt i = iUiControllerArray.Count() - 1; i >= 0; --i )
   326         }
   291         }
   327     }
   292     }
   328 
   293 
   329 // ----------------------------------------------------------------------------
   294 // ----------------------------------------------------------------------------
   330 // CAiUiControllerManager::ExitMainController()
   295 // CAiUiControllerManager::ExitMainController()
       
   296 //
   331 // ----------------------------------------------------------------------------
   297 // ----------------------------------------------------------------------------
   332 //
   298 //
   333 void CAiUiControllerManager::ExitMainController()
   299 void CAiUiControllerManager::ExitMainController()
   334     {
   300     {
   335     iMainUiController->Exit();
   301     iMainUiController->Exit();
   336     }
   302     }
   337 
   303     
   338 // ----------------------------------------------------------------------------
   304 // ----------------------------------------------------------------------------
   339 // CAiUiControllerManager::AddObserverL()
   305 // CAiUiControllerManager::SetStateHandler()
   340 // ----------------------------------------------------------------------------
   306 //
   341 //
   307 // ----------------------------------------------------------------------------
   342 void CAiUiControllerManager::AddObserverL( 
   308 //
   343     MAiUiFrameworkObserver& aUiFwObserver )
   309 void CAiUiControllerManager::SetStateHandler( MAiFwStateHandler& aHandler )
   344     {
   310     {
   345     User::LeaveIfError( 
   311     for ( TInt i = 0; i < iUiControllerArray.Count(); i++ )
   346             iUiFrameworkObservers.InsertInAddressOrder( &aUiFwObserver ) );
   312         {
   347     }
   313         iUiControllerArray[i]->SetStateHandler( aHandler );
   348 
   314         }    
   349 // ----------------------------------------------------------------------------
   315     }
   350 // CAiUiControllerManager::RemoveObserver()
   316 
   351 // ----------------------------------------------------------------------------
       
   352 //
       
   353 void CAiUiControllerManager::RemoveObserver( 
       
   354     MAiUiFrameworkObserver& aUiFwObserver )
       
   355     {
       
   356     TInt index( iUiFrameworkObservers.FindInAddressOrder( &aUiFwObserver ) );
       
   357     
       
   358     if( index != KErrNotFound )
       
   359         {
       
   360         iUiFrameworkObservers.Remove( index );
       
   361         }
       
   362     }
       
   363 
       
   364 // ----------------------------------------------------------------------------
       
   365 // CAiUiControllerManager::RemovePluginFromUI()
       
   366 // ----------------------------------------------------------------------------
       
   367 //
       
   368 void CAiUiControllerManager::RemovePluginFromUI( CAiContentPublisher& aPlugin )
       
   369     {
       
   370     // Get MAiPropertyExtension from plugin
       
   371     MAiPropertyExtension* plugin =
       
   372         static_cast< MAiPropertyExtension* >( 
       
   373                 aPlugin.Extension( KExtensionUidProperty ) );
       
   374     
       
   375     // Inform all UI controller that this plugin need to be removed from UI.
       
   376     if( plugin )
       
   377         {
       
   378         for ( TInt i = 0; i < iUiControllerArray.Count(); i++ )
       
   379             {
       
   380             iUiControllerArray[i]->RemovePluginFromUI( *plugin );
       
   381             }
       
   382         }
       
   383     }
       
   384 
       
   385 // ----------------------------------------------------------------------------
       
   386 // CAiUiControllerManager::HandleResourceChange()
       
   387 // ----------------------------------------------------------------------------
       
   388 //
       
   389 void CAiUiControllerManager::HandleResourceChange( TInt aType )
       
   390     {
       
   391     for( TInt i = 0; i < iUiFrameworkObservers.Count(); i++ )
       
   392         {
       
   393         iUiFrameworkObservers[i]->HandleResourceChange( aType );
       
   394         }
       
   395     }
       
   396 
       
   397 // ----------------------------------------------------------------------------
       
   398 // CAiUiControllerManager::HandleForegroundEvent()
       
   399 // ----------------------------------------------------------------------------
       
   400 //
       
   401 void CAiUiControllerManager::HandleForegroundEvent( TBool aForeground )
       
   402     {
       
   403     for( TInt i = 0; i < iUiFrameworkObservers.Count(); i++ )
       
   404         {
       
   405         iUiFrameworkObservers[i]->HandleForegroundEvent( aForeground );
       
   406         }
       
   407     }
       
   408     
       
   409 // End of file
   317 // End of file