vtengines/videoteleng/Src/State/CVtEngStateInitializing.cpp
changeset 0 ed9695c8bcbe
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     1 /*
       
     2 * Copyright (c) 2006 - 2008 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:  Initializing state
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "CVtEngStateInitializing.h"
       
    21 #include    "CVtEngOperation.h"
       
    22 #include    "CVtEngSettings.h"
       
    23 #include    "VtEngUtils.h"
       
    24 #include    "CVtEngAudioHandler.h"
       
    25 #include    "CVtEngInitializer.h"
       
    26 #include    <cvtlogger.h>
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CVtEngStateInitializing::CVtEngStateInitializing
       
    32 // C++ constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CVtEngStateInitializing::CVtEngStateInitializing( 
       
    37     CVtEngStateManager& aStateManager,
       
    38     CVtEngEventManager& aEventManager )
       
    39     : CVtEngStateBase( aStateManager, aEventManager )
       
    40     {
       
    41     }
       
    42 
       
    43 // Destructor
       
    44 CVtEngStateInitializing::~CVtEngStateInitializing()
       
    45     {
       
    46     __VTPRINT( DEBUG_DESTRUCT, "~Stateini")
       
    47     }
       
    48 
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CVtEngStateInitializing::UpdateL
       
    52 // Updates state
       
    53 // (other items were commented in a header).
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 void CVtEngStateInitializing::UpdateL()
       
    57     {
       
    58     __VTPRINTENTER( "StateInit.Update")
       
    59     const MVtCtlCallControl::TVtCtlState bearerstate = 
       
    60         SessionHandler().RealState();
       
    61 
       
    62     CVtEngStateBase* newState = NULL;
       
    63     if ( bearerstate == MVtCtlCallControl::EIdle ||
       
    64          bearerstate == MVtCtlCallControl::EDisconnecting )
       
    65         {
       
    66         newState = NewStateL( MVtEngSessionInfo::EClearing );
       
    67         // Initializer may be waiting for dataport. In that case MediaHandler 
       
    68         // has already signaled reqStatus of CVtEngInitializer which must
       
    69         // complete KVtEngInitializeEngine command in order uninitialisation to
       
    70         // finish properly. This scenario may happen in 1st call since phone
       
    71         // boot, i.e. when dataport name is not already published.
       
    72         CVtEngUtility::EngineUtils()->Initializer().CancelInit();
       
    73         }
       
    74     else if ( bearerstate == MVtCtlCallControl::EAlerting )
       
    75         {
       
    76         newState = NewStateL( MVtEngSessionInfo::ERemoteAlerting );
       
    77         }
       
    78     else
       
    79         {
       
    80         newState = NegotiatingOrConnectedStateL(); // or null
       
    81         }
       
    82     if ( newState )
       
    83         {
       
    84         newState->OpenL( this );
       
    85         }
       
    86     __VTPRINTEXIT( "StateInit.Update")
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CVtEngStateInitializing::OpenL
       
    91 // State transition to initializing.
       
    92 // (other items were commented in a header).
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 void CVtEngStateInitializing::DoOpenL()
       
    96     {
       
    97     __VTPRINTENTER( "StateInit.Open" )
       
    98     NotifyStateChange( MVtEngSessionInfo::EInitializing );
       
    99     
       
   100     // Instantiate temporary devsound for audio routing
       
   101     AudioHandler().SetRoutingEnablerL( ETrue );
       
   102     __VTPRINTEXIT( "StateInit.Open" )
       
   103     }
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // CVtEngStateInitializing::ValidateCommand
       
   107 // Returns if a command is valid in initializing state.
       
   108 // 
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 TBool CVtEngStateInitializing::ValidateCommand(
       
   112             const TVtEngCommandId aCommandId )
       
   113     {
       
   114     __VTPRINT( DEBUG_DETAIL | DEBUG_GEN, "StateInit.Validate")
       
   115     TBool okToPerform( EFalse );
       
   116     switch ( aCommandId )
       
   117         {
       
   118         case KVtEngPrepareViewFinder:        
       
   119         case KVtEngPrepareRemoteRenderDSA:
       
   120         case KVtEngPrepareRemoteRenderDP:
       
   121         case KVtEngPrepareRemoteRenderNGA:
       
   122         case KVtEngSetSource:
       
   123         case KVtEngStartViewFinder:
       
   124             okToPerform = ETrue;
       
   125             break;
       
   126         default:
       
   127             okToPerform = CVtEngStateBase::ValidateCommand( aCommandId );
       
   128             break;
       
   129         }
       
   130     return okToPerform;
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // CVtEngStateInitializing::State
       
   135 // Returns session state.
       
   136 // 
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 MVtEngSessionInfo::TSessionState CVtEngStateInitializing::State() const
       
   140     {
       
   141     return MVtEngSessionInfo::EInitializing;
       
   142     }
       
   143 
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // CVtEngStateInitializing::HandleL
       
   147 // Handles an operation when behavior is state dependent.
       
   148 // 
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 TBool CVtEngStateInitializing::HandleL( CVtEngOperation& aOp )
       
   152     {
       
   153     TBool handled( CVtEngStateBase::HandleL( aOp ));
       
   154     if ( !handled )
       
   155         {
       
   156         switch ( aOp.Command() )
       
   157             {
       
   158             case KVtEngStartRenderRemote:
       
   159                 SetVideoEnabled( ETrue );
       
   160                 handled = ETrue;
       
   161                 break;
       
   162             }
       
   163         }
       
   164     return handled;
       
   165     }
       
   166 
       
   167 // End of File