idlehomescreen/xmluirendering/uiengine/src/xnappuiadapterimpl.cpp
changeset 0 f72a12da539e
child 9 f966699dea19
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation for Avkon adapter
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <hsccproviderclient.h>
       
    20 #include <hscontentcontroller.h>
       
    21 #include <hscontentcontrolui.h>
       
    22 #include <bautils.h>
       
    23 #include <data_caging_path_literals.hrh>
       
    24 
       
    25 // User includes
       
    26 #include "xnappuiadapter.h"
       
    27 #include "xnuiengine.h"
       
    28 #include "xnviewmanager.h"
       
    29 #include "xnviewadapter.h"
       
    30 #include "xnuistatelistener.h"
       
    31 #include "hscontentcontrolfactory.h"
       
    32 #include "xneditor.h"
       
    33 #include "xnwallpaperview.h"
       
    34 #include "xneffectmanager.h"
       
    35 
       
    36 #include "xnappuiadapterimpl.h"
       
    37 
       
    38 // Constants
       
    39 _LIT( KResourceDrive, "z:" );
       
    40 _LIT( KResourceFile, "xnuiengine.rsc" );
       
    41 
       
    42 // ============================= LOCAL FUNCTIONS ===============================
       
    43 
       
    44 // ============================ MEMBER FUNCTIONS ===============================
       
    45 // -----------------------------------------------------------------------------
       
    46 // CXnAppUiAdapterImpl::NewL()
       
    47 // Two-phased constructor.
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 CXnAppUiAdapterImpl* CXnAppUiAdapterImpl::NewL( TUid aApplicationUid,    
       
    51     CXnAppUiAdapter& aAdapter )
       
    52     {    
       
    53     return new ( ELeave ) CXnAppUiAdapterImpl( aApplicationUid, aAdapter );
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CXnAppUiAdapterImpl::CXnAppUiAdapterImpl
       
    58 // C++ default constructor can NOT contain any code, that
       
    59 // might leave.
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 CXnAppUiAdapterImpl::CXnAppUiAdapterImpl( TUid aApplicationUid,    
       
    63     CXnAppUiAdapter& aAdapter )
       
    64     : iAdapter( aAdapter ), iApplicationUid( aApplicationUid )
       
    65     {
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CXnAppUiAdapterImpl::ConstructL
       
    70 // Second-phase constructor
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 void CXnAppUiAdapterImpl::ConstructL()
       
    74     {       
       
    75 #ifdef _XN_PERFORMANCE_TEST_
       
    76     RDebug::Print( _L( "CXnAppUiAdapterImpl::ConstructL() - start" ) );
       
    77 #endif //_XN_PERFORMANCE_TEST_
       
    78     
       
    79     TFileName resFile;
       
    80     resFile.Append( KResourceDrive );
       
    81     resFile.Append( KDC_APP_RESOURCE_DIR );
       
    82     resFile.Append( KResourceFile );
       
    83     BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(),
       
    84             resFile );      
       
    85     
       
    86     iResourceOffset = CCoeEnv::Static()->AddResourceFileL( resFile );
       
    87         
       
    88     iContentControlFactory = CHsContentControlFactory::NewL();    
       
    89     
       
    90     iUiStateListener = CXnUiStateListener::NewL( iAdapter );
       
    91             
       
    92     iViewManager = CXnViewManager::NewL( iAdapter );
       
    93     
       
    94     iUiEngine = CXnUiEngine::NewL( iAdapter );
       
    95 
       
    96     iViewManager->SetUiEngine( *iUiEngine );
       
    97     
       
    98     // iViewAdapter is owned by CAknViewAppUi
       
    99     iViewAdapter = CXnViewAdapter::NewL( iAdapter );
       
   100        
       
   101     iViewManager->LoadUiL();
       
   102     
       
   103     iCcProviderClient = CHsCcProviderClient::NewL( iViewManager->Editor() );
       
   104     
       
   105     CXnWallpaperView* wallpaper = CXnWallpaperView::NewL( *iUiEngine );
       
   106     iAdapter.AddViewL( wallpaper );
       
   107            
       
   108     iEffectManager = CXnEffectManager::NewL();    
       
   109     
       
   110 #ifdef _XN_PERFORMANCE_TEST_
       
   111     RDebug::Print( _L( "CXnAppUiAdapterImpl::ConstructL() - end" ) );
       
   112 #endif //_XN_PERFORMANCE_TEST_    
       
   113     }
       
   114 
       
   115 // -----------------------------------------------------------------------------
       
   116 // CXnAppUiAdapterImpl::ReloadUiL
       
   117 // Reloads UI when application root configuration is changed
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 void CXnAppUiAdapterImpl::ReloadUiL()
       
   121     {
       
   122 #ifdef _XN_PERFORMANCE_TEST_
       
   123     RDebug::Print( _L( "CXnAppUiAdapterImpl::ReloadUiL() - start" ) );
       
   124 #endif //_XN_PERFORMANCE_TEST_
       
   125 
       
   126     iViewAdapter->ReloadUiL();
       
   127            
       
   128     iViewManager->ReloadUiL();
       
   129           
       
   130 #ifdef _XN_PERFORMANCE_TEST_
       
   131     RDebug::Print( _L( "CXnAppUiAdapterImpl::ReloadUiL() - end" ) );
       
   132 #endif //_XN_PERFORMANCE_TEST_
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // Destructor
       
   137 //
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 CXnAppUiAdapterImpl::~CXnAppUiAdapterImpl()
       
   141     {  
       
   142     if ( iViewAdapter )
       
   143         {
       
   144         iViewAdapter->PrepareDestroy();
       
   145         }
       
   146     
       
   147     delete iContentControlFactory;    
       
   148             
       
   149     delete iUiEngine;
       
   150     
       
   151     delete iUiStateListener;
       
   152            
       
   153     delete iViewManager;
       
   154     
       
   155     delete iCcProviderClient;
       
   156 
       
   157     delete iEffectManager;
       
   158     
       
   159     CCoeEnv::Static()->DeleteResourceFile( iResourceOffset ) ;        
       
   160     }
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CXnAppUiAdapterImpl::UiEngine
       
   164 // Gets UI engine
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 CXnUiEngine& CXnAppUiAdapterImpl::UiEngine() const
       
   168     {
       
   169     return *iUiEngine;
       
   170     }
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // CXnAppUiAdapterImpl::ViewAdapter
       
   174 // Gets view adapter
       
   175 // -----------------------------------------------------------------------------
       
   176 //
       
   177 CXnViewAdapter& CXnAppUiAdapterImpl::ViewAdapter() const
       
   178     {
       
   179     return *iViewAdapter;
       
   180     }
       
   181 
       
   182 // -----------------------------------------------------------------------------
       
   183 // CXnAppUiAdapterImpl::ViewManager
       
   184 // Gets view manager
       
   185 // -----------------------------------------------------------------------------
       
   186 //
       
   187 CXnViewManager& CXnAppUiAdapterImpl::ViewManager() const
       
   188     {
       
   189     return *iViewManager;
       
   190     }
       
   191 
       
   192 // -----------------------------------------------------------------------------
       
   193 // CXnAppUiAdapterImpl::UiStateListener
       
   194 // Gets UI state listener
       
   195 // -----------------------------------------------------------------------------
       
   196 //
       
   197 CXnUiStateListener& CXnAppUiAdapterImpl::UiStateListener() const
       
   198     {
       
   199     return *iUiStateListener;
       
   200     }
       
   201 
       
   202 
       
   203 // -----------------------------------------------------------------------------
       
   204 // CXnAppUiAdapterImpl::HsContentController
       
   205 // Gets Content control UI interface
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 MHsContentControlUi* CXnAppUiAdapterImpl::HsContentController( 
       
   209     const TDesC8& aType ) const
       
   210     {
       
   211     return iContentControlFactory->GetHsContentController( aType );
       
   212     }
       
   213 
       
   214 // -----------------------------------------------------------------------------
       
   215 // CXnAppUiAdapterImpl::EffectManager
       
   216 // Get effect manager.
       
   217 // -----------------------------------------------------------------------------
       
   218 //
       
   219 CXnEffectManager* CXnAppUiAdapterImpl::EffectManager() const
       
   220     {
       
   221     return iEffectManager;
       
   222     }
       
   223 
       
   224 // -----------------------------------------------------------------------------
       
   225 // CXnAppUiAdapterImpl::HsContentControlSrv
       
   226 // Gets Content control server interface
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 MHsContentControl* CXnAppUiAdapterImpl::HsContentControlSrv() const
       
   230     {
       
   231     return iCcProviderClient;
       
   232     }
       
   233 
       
   234 // -----------------------------------------------------------------------------
       
   235 // CXnAppUiAdapterImpl::HandleResourceChangeL
       
   236 // Handles resource changes
       
   237 // -----------------------------------------------------------------------------
       
   238 //
       
   239 void CXnAppUiAdapterImpl::HandleResourceChangeL( TInt aType )
       
   240     {
       
   241     iUiStateListener->HandleResourceChangeL( aType );    
       
   242     }
       
   243 
       
   244 // End of file