idlehomescreen/xmluirendering/uiengine/src/xnviewadapter.cpp
branchRCL_3
changeset 11 ff572dfe6d86
parent 9 f966699dea19
child 12 9674c1a575e9
equal deleted inserted replaced
9:f966699dea19 11:ff572dfe6d86
    16 */
    16 */
    17 
    17 
    18 // System includes
    18 // System includes
    19 #include <aknViewAppUi.h>
    19 #include <aknViewAppUi.h>
    20 #include <eikbtgpc.h>
    20 #include <eikbtgpc.h>
       
    21 #include <avkon.rsg>
    21 
    22 
    22 // User includes
    23 // User includes
    23 #include "xnappuiadapter.h"
    24 #include "xnappuiadapter.h"
    24 #include "xnviewmanager.h"
    25 #include "xnviewmanager.h"
    25 #include "xnviewdata.h"
    26 #include "xnviewdata.h"
    42 #include "xnbackgroundmanager.h"
    43 #include "xnbackgroundmanager.h"
    43 
    44 
    44 #include "xnviewadapter.h"
    45 #include "xnviewadapter.h"
    45 #include "xnmenu.h"
    46 #include "xnmenu.h"
    46 #include "xneditmode.h"
    47 #include "xneditmode.h"
       
    48 #include "xnrootdata.h"
       
    49 
       
    50 #include "debug.h"
    47 
    51 
    48 // Constants
    52 // Constants
    49 const TUid KXmlViewUid = { 1 };
    53 const TUid KXmlViewUid = { 1 };
       
    54 _LIT8( KActivateDefaultView, "activatedefault" );
    50 
    55 
    51 // Data types
    56 // Data types
    52 enum 
    57 enum 
    53     {
    58     {
    54     EIsActivated,
    59     EIsActivated,
       
    60     EIsFirstActivation,
    55     EIsInCall,
    61     EIsInCall,
    56     EIsLightsOn,
    62     EIsLightsOn,
    57     EIsForeground,    
    63     EIsForeground,    
    58     EIsControlsAwake,    
    64     EIsControlsAwake,    
    59     EIsDestructionRunning
    65     EIsDestructionRunning
    60     };
    66     };
    61 
    67 
    62 // ============================= LOCAL FUNCTIONS ===============================
    68 // ============================= LOCAL FUNCTIONS ===============================
       
    69 // -----------------------------------------------------------------------------
       
    70 // DetermineStatusPaneLayout
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 static TInt DetermineStatusPaneLayout( CXnProperty* aProperty )
       
    74     {
       
    75     TInt spane( KErrNotFound );
       
    76 
       
    77     if ( aProperty )
       
    78         {
       
    79         const TDesC8& value( aProperty->StringValue() );
       
    80 
       
    81         // Currently supported status pane layout
       
    82         if ( value == XnPropertyNames::view::statuspanelayout::KNone )
       
    83             {
       
    84             spane = R_AVKON_STATUS_PANE_LAYOUT_EMPTY;
       
    85             }
       
    86         if ( value == XnPropertyNames::view::statuspanelayout::KBasic )
       
    87             {
       
    88             spane = R_AVKON_STATUS_PANE_LAYOUT_IDLE;
       
    89             }
       
    90         else if ( value == XnPropertyNames::view::statuspanelayout::KBasicFlat )
       
    91             {
       
    92             spane = R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT;
       
    93             }
       
    94         else if ( value ==
       
    95                   XnPropertyNames::view::statuspanelayout::KWideScreen )
       
    96             {
       
    97             spane = R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE;
       
    98             }
       
    99         else if ( value ==
       
   100                   XnPropertyNames::view::statuspanelayout::KWideScreenFlat )
       
   101             {
       
   102             spane = R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT;
       
   103             }
       
   104         else if ( value ==
       
   105                   XnPropertyNames::view::statuspanelayout::
       
   106                   KWideScreenFlat3Softkeys )
       
   107             {
       
   108             spane = R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT_NO_SOFTKEYS;
       
   109             }
       
   110         }
       
   111 
       
   112     return spane;
       
   113     }
       
   114 
    63 // -----------------------------------------------------------------------------
   115 // -----------------------------------------------------------------------------
    64 // BuildTriggerL
   116 // BuildTriggerL
    65 // -----------------------------------------------------------------------------
   117 // -----------------------------------------------------------------------------
    66 //
   118 //
    67 static CXnNode* BuildTriggerL(
   119 static CXnNode* BuildTriggerL(
   153 // CXnViewAdapter::~CXnViewAdapter
   205 // CXnViewAdapter::~CXnViewAdapter
   154 // Destructor.
   206 // Destructor.
   155 // -----------------------------------------------------------------------------
   207 // -----------------------------------------------------------------------------
   156 //
   208 //
   157 CXnViewAdapter::~CXnViewAdapter()
   209 CXnViewAdapter::~CXnViewAdapter()
   158     {           
   210     {
       
   211     delete iTimer;
   159     delete iActivate;
   212     delete iActivate;
   160     delete iDeactivate;
   213     delete iDeactivate;
   161     delete iEditState;
   214     delete iEditState;
   162     delete iBgControl;
   215     delete iBgControl;
   163     delete iBgManager;
   216     delete iBgManager;
   185 //
   238 //
   186 void CXnViewAdapter::ConstructL()
   239 void CXnViewAdapter::ConstructL()
   187     {
   240     {
   188     BaseConstructL();
   241     BaseConstructL();
   189     
   242     
       
   243     iTimer = CPeriodic::NewL( CActive::EPriorityIdle );
       
   244     
       
   245     iFlags.Set( EIsFirstActivation );
       
   246     
   190     // Base class CAknViewAppUi takes ownership of iViewAdapter
   247     // Base class CAknViewAppUi takes ownership of iViewAdapter
   191     iAppUiAdapter.AddViewL( this );    
   248     iAppUiAdapter.AddViewL( this );    
   192     iAppUiAdapter.SetDefaultViewL( *this );
   249     iAppUiAdapter.SetDefaultViewL( *this );
   193 
   250 
   194     iBgControl = CXnBgControl::NewL();
   251     iBgControl = CXnBgControl::NewL();
   239         iAppUiAdapter.AddToStackL( *this, iEventDispatcher );
   296         iAppUiAdapter.AddToStackL( *this, iEventDispatcher );
   240         }
   297         }
   241     }
   298     }
   242 
   299 
   243 // -----------------------------------------------------------------------------
   300 // -----------------------------------------------------------------------------
   244 // CXnViewAdapter::PrepareDestroy
   301 // CXnViewAdapter::PrepareToExit
   245 // Sets view to be destroyed
   302 // Sets view to be destroyed
   246 // -----------------------------------------------------------------------------
   303 // -----------------------------------------------------------------------------
   247 //
   304 //
   248 void CXnViewAdapter::PrepareDestroy()
   305 void CXnViewAdapter::PrepareToExit()
   249     {
   306     {                
   250     iAppUiAdapter.UiStateListener().RemoveObserver( *this );
       
   251     iBgControl->PrepareDestroy();
       
   252     
       
   253     TRAP_IGNORE( DeactivateContainerL() );
       
   254     
       
   255     iAppUiAdapter.RemoveFromStack( iEventDispatcher );
   307     iAppUiAdapter.RemoveFromStack( iEventDispatcher );
   256     delete iEventDispatcher;
   308     delete iEventDispatcher;
   257     iEventDispatcher = NULL;
   309     iEventDispatcher = NULL;
   258     
   310     
       
   311     iAppUiAdapter.UiEngine().SetEventDispatcher( NULL );
       
   312     
   259     iContainer = NULL;
   313     iContainer = NULL;
   260     
   314     
   261     iFlags.Set( EIsDestructionRunning );    
   315     iFlags.Set( EIsDestructionRunning );    
   262     }
   316     }
   263 
   317 
   316 // Activates view.
   370 // Activates view.
   317 // -----------------------------------------------------------------------------
   371 // -----------------------------------------------------------------------------
   318 //
   372 //
   319 void CXnViewAdapter::DoActivateL( const TVwsViewId& /*aPrevViewId*/,    
   373 void CXnViewAdapter::DoActivateL( const TVwsViewId& /*aPrevViewId*/,    
   320     TUid /*aCustomMessageId*/,
   374     TUid /*aCustomMessageId*/,
   321     const TDesC8& /*aCustomMessage*/ )
   375     const TDesC8& aCustomMessage )
   322     {
   376     {
   323     if ( iFlags.IsSet( EIsDestructionRunning ) )
   377     if ( iFlags.IsSet( EIsDestructionRunning ) )
   324         {
   378         {
   325         return;
   379         return;
   326         }
   380         }
       
   381 
       
   382     __TICK( "CXnViewAdapter::DoActivateL" );
       
   383     __TIME_MARK( time );
   327     
   384     
   328     iFlags.Set( EIsActivated );
   385     iFlags.Set( EIsActivated );
   329     
   386     
   330     iAppUiAdapter.AddToStackL( *this, iEventDispatcher );
   387     iAppUiAdapter.AddToStackL( *this, iEventDispatcher );
   331 
   388 
   340         iAppUiAdapter.RemoveFromStack( cba );        
   397         iAppUiAdapter.RemoveFromStack( cba );        
   341         }
   398         }
   342     
   399     
   343     iBgControl->MakeVisible( ETrue );
   400     iBgControl->MakeVisible( ETrue );
   344     iBgManager->MakeVisible( ETrue );
   401     iBgManager->MakeVisible( ETrue );
   345     
   402 
   346     // Set the active container
   403     // Set status pane layout
   347     ActivateContainerL( iAppUiAdapter.ViewManager().ActiveViewData() );             
   404     CXnViewData& viewData( iAppUiAdapter.ViewManager().ActiveViewData() );
       
   405     CXnProperty* prop( viewData.Node()->LayoutNode()->GetPropertyL( 
       
   406         XnPropertyNames::view::KStatusPaneLayout ) );
       
   407 
       
   408     // Is there status pane declaration available
       
   409     TInt spane( DetermineStatusPaneLayout( prop ) );
       
   410 
       
   411     if ( spane != KErrNotFound )
       
   412         {
       
   413         CEikStatusPane* sp( iAppUiAdapter.StatusPane() );
       
   414 
       
   415         if ( sp && sp->CurrentLayoutResId() != spane )
       
   416             {
       
   417             sp->SwitchLayoutL( spane );
       
   418             sp->ApplyCurrentSettingsL();
       
   419             }
       
   420         }    
       
   421                 
       
   422     if ( iFlags.IsSet( EIsFirstActivation ) )
       
   423         {                             
       
   424         // Set the active container
       
   425         ActivateContainerL( iAppUiAdapter.ViewManager().ActiveViewData() );
       
   426         
       
   427         __TICK( "CXnViewAdapter::DoActivateL - Calling UiActivated" );
       
   428         __TIME_MARK( time2 );
       
   429     
       
   430         iFlags.Clear( EIsFirstActivation );
       
   431         
       
   432         iAppUiAdapter.UiActivated();
       
   433         
       
   434         __TIME_ENDMARK( "CXnViewAdapter::DoActivateL - Calling UiActivated", time );        
       
   435         }
       
   436     else
       
   437         {
       
   438 	    // Set the active container
       
   439 	    if ( aCustomMessage == KActivateDefaultView )
       
   440 	        {
       
   441             __PRINTS( "*** CXnViewAdapter::DoActivateL - activating default container" );
       
   442 	    
       
   443 	        ActivateDefaultContainerL();
       
   444         
       
   445 	        iTimer->Cancel();
       
   446 	        iTimer->Start( 1000, 1000, TCallBack( TimerCallback, this ) );
       
   447 	        }
       
   448 	    else
       
   449 	        {
       
   450             __PRINTS( "*** CXnViewAdapter::DoActivateL - activating container" );
       
   451 	    
       
   452 	        ActivateContainerL( viewData );
       
   453 	        }
       
   454         }
       
   455 			  
       
   456     __TIME_ENDMARK( "CXnViewAdapter::DoActivateL, done", time );
       
   457     
       
   458     __TICK( "CXnViewAdapter::DoActivateL - HS UI Ready" );
       
   459     }
       
   460 
       
   461 // -----------------------------------------------------------------------------
       
   462 // CXnViewAdapter::TimerCallback
       
   463 // 
       
   464 // -----------------------------------------------------------------------------
       
   465 //
       
   466 TInt CXnViewAdapter::TimerCallback( TAny *aPtr )
       
   467     {
       
   468     __PRINTS( "*** CXnViewAdapter::TimerCallback" );
       
   469     
       
   470     CXnViewAdapter* self = reinterpret_cast< CXnViewAdapter* >( aPtr );
       
   471     self->iTimer->Cancel();
       
   472     
       
   473     self->iCoeEnv->WsSession().SetWindowGroupOrdinalPosition(
       
   474             self->iCoeEnv->RootWin().Identifier(), 0 );
       
   475 
       
   476     __PRINTS( "*** CXnViewAdapter::TimerCallback, done" );
       
   477     
       
   478     return KErrNone;
   348     }
   479     }
   349 
   480 
   350 // -----------------------------------------------------------------------------
   481 // -----------------------------------------------------------------------------
   351 // CXnViewAdapter::DoDeactivate
   482 // CXnViewAdapter::DoDeactivate
   352 // Deactivates view.
   483 // Deactivates view.
   357     if ( iFlags.IsSet( EIsDestructionRunning ) )
   488     if ( iFlags.IsSet( EIsDestructionRunning ) )
   358         {
   489         {
   359         return;
   490         return;
   360         }
   491         }
   361     
   492     
       
   493     __PRINTS( "*** CXnViewAdapter::DoDeactivate" );
       
   494     __TIME_MARK( time );
       
   495     
   362     iAppUiAdapter.RemoveFromStack( iEventDispatcher );
   496     iAppUiAdapter.RemoveFromStack( iEventDispatcher );
   363 
   497 
   364     TRAP_IGNORE( DeactivateContainerL() );
   498     TRAP_IGNORE( DeactivateContainerL() );
   365     
   499     
   366     iBgControl->MakeVisible( EFalse );
   500     iBgControl->MakeVisible( EFalse );
   367     iBgManager->MakeVisible( EFalse );
   501     iBgManager->MakeVisible( EFalse );
   368     
   502     
   369     iFocusControl->MakeVisible( EFalse );
   503     iFocusControl->MakeVisible( EFalse );
   370     
   504     
   371     iFlags.Clear( EIsActivated );
   505     iFlags.Clear( EIsActivated );
       
   506     
       
   507     __TIME_ENDMARK( "CXnViewAdapter::DoDeactivate, done", time );
   372     }
   508     }
   373 
   509 
   374 // -----------------------------------------------------------------------------
   510 // -----------------------------------------------------------------------------
   375 // CXnViewAdapter::ActivateContainerL
   511 // CXnViewAdapter::ActivateContainerL
   376 // Activates container
   512 // Activates container
   377 // -----------------------------------------------------------------------------
   513 // -----------------------------------------------------------------------------
   378 //
   514 //
   379 void CXnViewAdapter::ActivateContainerL( CXnViewData& aContainer, 
   515 void CXnViewAdapter::ActivateContainerL( CXnViewData& aContainer, 
   380     TBool aEnterEditState )
   516     TBool aEnterEditState )
   381     {                       
   517     {                       
   382     if ( iContainer == &aContainer )    
   518     if ( iContainer == &aContainer || iFlags.IsSet( EIsDestructionRunning ) )    
   383         {            
   519         {            
   384         return;
   520         return;
   385         }
   521         }
   386 
   522 
   387     // Deactivate previous
   523     // Deactivate previous
   420         NotifyInCallStateChaged( ETrue );        
   556         NotifyInCallStateChaged( ETrue );        
   421         }
   557         }
   422                  
   558                  
   423     iAppUiAdapter.ViewManager().NotifyContainerChangedL( aContainer );
   559     iAppUiAdapter.ViewManager().NotifyContainerChangedL( aContainer );
   424     
   560     
       
   561     if ( aEnterEditState || iAppUiAdapter.UiEngine().IsEditMode() )
       
   562         {
       
   563         EnterEditStateL( aContainer, ETrue );                        
       
   564         }
       
   565     else
       
   566         {
       
   567         EnterEditStateL( aContainer, EFalse );                                
       
   568         }
       
   569     
       
   570     CXnControlAdapter* adapter( node->Control() );
       
   571     
       
   572     iBgControl->SetCompoundControl( adapter );
       
   573             
       
   574     iAppUiAdapter.UiEngine().RenderUIL();
       
   575     
       
   576     CleanupStack::PopAndDestroy(); // DisableRenderUiLC        
       
   577     }
       
   578 
       
   579 // -----------------------------------------------------------------------------
       
   580 // CXnViewAdapter::ActivateDefaultContainerL
       
   581 // Activates default container
       
   582 // -----------------------------------------------------------------------------
       
   583 //
       
   584 void CXnViewAdapter::ActivateDefaultContainerL( TBool aEnterEditState )
       
   585     {
       
   586     CXnRootData& rootData( iAppUiAdapter.ViewManager().ActiveAppData() );
       
   587     
       
   588     RPointerArray< CXnPluginData >& views( rootData.PluginData() );
       
   589     
       
   590     if ( !views.Count() )
       
   591         {
       
   592         return;
       
   593         }    
       
   594     
       
   595     // Deactivate container even though it hasn't changed to close all popups
       
   596     // and other windows
       
   597     DeactivateContainerL();
       
   598     
       
   599     // first view is default
       
   600     CXnViewData* viewData = static_cast<CXnViewData*>( views[0] );
       
   601     
       
   602     if ( viewData )
       
   603         {
       
   604         EnterEditStateL( *viewData, aEnterEditState );
       
   605         ActivateContainerL( *viewData, aEnterEditState );
       
   606         }
       
   607     }
       
   608 
       
   609 // -----------------------------------------------------------------------------
       
   610 // CXnViewAdapter::EnterEditStateL
       
   611 // Sets edit state property
       
   612 // -----------------------------------------------------------------------------
       
   613 //
       
   614 void CXnViewAdapter::EnterEditStateL( CXnViewData& aView, TBool aEnter )
       
   615     {
   425     if ( !iEditState )
   616     if ( !iEditState )
   426         {
   617         {
   427         iEditState = BuildEditStateTriggerL( iAppUiAdapter.UiEngine() ); 
   618         iEditState = BuildEditStateTriggerL( iAppUiAdapter.UiEngine() ); 
   428         }
   619         }
   429     
   620     
   430     CXnProperty* prop( iEditState->GetPropertyL( 
   621     CXnProperty* prop( iEditState->GetPropertyL( 
   431         XnPropertyNames::action::KValue ) );
   622         XnPropertyNames::action::KValue ) );
   432     
   623     
   433     if ( aEnterEditState || iAppUiAdapter.UiEngine().IsEditMode() )
   624     if ( !prop )
       
   625         {
       
   626         return;
       
   627         }
       
   628     
       
   629     if ( aEnter )
   434         {
   630         {
   435         static_cast< CXnDomPropertyValue* >(
   631         static_cast< CXnDomPropertyValue* >(
   436             prop->Property()->PropertyValueList().Item( 0 ) )
   632             prop->Property()->PropertyValueList().Item( 0 ) )
   437             ->SetStringValueL( CXnDomPropertyValue::EString,
   633             ->SetStringValueL( CXnDomPropertyValue::EString,
   438             XnPropertyNames::action::trigger::name::editmode::KEnter() );                        
   634             XnPropertyNames::action::trigger::name::editmode::KEnter() );
   439         }
   635         }
   440     else
   636     else
   441         {
   637         {
   442         static_cast< CXnDomPropertyValue* >(
   638         static_cast< CXnDomPropertyValue* >(
   443             prop->Property()->PropertyValueList().Item( 0 ) )
   639             prop->Property()->PropertyValueList().Item( 0 ) )
   444             ->SetStringValueL( CXnDomPropertyValue::EString,
   640             ->SetStringValueL( CXnDomPropertyValue::EString,
   445             XnPropertyNames::action::trigger::name::editmode::KExit() );                                
   641             XnPropertyNames::action::trigger::name::editmode::KExit() );
   446         }
   642         }
   447     
   643     
   448     node->ReportXuikonEventL( *iEditState );
   644     if ( aView.Node() && aView.Node()->LayoutNode() )
   449     
   645         {
   450     CXnControlAdapter* adapter( node->Control() );
   646         aView.Node()->LayoutNode()->ReportXuikonEventL( *iEditState );
   451     
   647         }
   452     iBgControl->SetCompoundControl( adapter );
       
   453             
       
   454     iAppUiAdapter.UiEngine().RenderUIL();
       
   455     
       
   456     CleanupStack::PopAndDestroy(); // DisableRenderUiLC        
       
   457     }
   648     }
   458 
   649 
   459 // -----------------------------------------------------------------------------
   650 // -----------------------------------------------------------------------------
   460 // CXnViewAdapter::DeactivateContainerL
   651 // CXnViewAdapter::DeactivateContainerL
   461 // Deactivates current container
   652 // Deactivates current container
   462 // -----------------------------------------------------------------------------
   653 // -----------------------------------------------------------------------------
   463 //
   654 //
   464 void CXnViewAdapter::DeactivateContainerL()
   655 void CXnViewAdapter::DeactivateContainerL()
   465     {
   656     {
   466     if ( !iContainer )    
   657     if ( !iContainer || iFlags.IsSet( EIsDestructionRunning ) )    
   467         {
   658         {
   468         return;
   659         return;
   469         }
   660         }
       
   661     
       
   662     CloseAllPopupsL();
   470     
   663     
   471     // Run controls to powersave mode
   664     // Run controls to powersave mode
   472     ChangeControlsStateL( EFalse );
   665     ChangeControlsStateL( EFalse );
   473 
   666 
   474     if ( !iDeactivate )
   667     if ( !iDeactivate )
   676                 }
   869                 }
   677             }
   870             }
   678         }
   871         }
   679     }
   872     }
   680 
   873 
       
   874 // -----------------------------------------------------------------------------
       
   875 // CXnViewAdapter::CloseAllPopupsL()
       
   876 // 
       
   877 // -----------------------------------------------------------------------------
       
   878 //
       
   879 void CXnViewAdapter::CloseAllPopupsL()
       
   880     {
       
   881     if ( !iContainer )
       
   882         {
       
   883         return;
       
   884         }
       
   885     
       
   886     RPointerArray< CXnNode > popups;
       
   887     CleanupClosePushL( popups );
       
   888     
       
   889     iContainer->PopupNodesL( popups );
       
   890     
       
   891     for ( TInt i = 0; i < popups.Count(); i++ )
       
   892         {
       
   893         CXnProperty* display = CXnProperty::NewL(
       
   894             XnPropertyNames::style::common::KDisplay,
       
   895             XnPropertyNames::style::common::display::KNone,
       
   896             CXnDomPropertyValue::EString,
       
   897             *iAppUiAdapter.UiEngine().ODT()->DomDocument().StringPool() );
       
   898         
       
   899         CleanupStack::PushL( display );         
       
   900         popups[i]->SetPropertyL(display);             
       
   901         CleanupStack::Pop( display );
       
   902         }
       
   903         
       
   904     CleanupStack::PopAndDestroy( &popups );
       
   905     }
       
   906 
   681 
   907 
   682 // End of file
   908 // End of file