vtengines/videoteleng/Src/State/CVtEngStateAlerting.cpp
changeset 18 d9b6a8729acd
parent 4 6dc066157ed4
child 23 c378a0498b84
child 27 dcbddbbaf8fd
equal deleted inserted replaced
4:6dc066157ed4 18:d9b6a8729acd
     1 /*
       
     2 * Copyright (c) 2004-2006 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:  Base class for states
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "CVtEngStateAlerting.h"
       
    21 #include    <cvtlogger.h>
       
    22 #include    "CVtEngOperation.h"
       
    23 #include    "CVtEngSettings.h"
       
    24 #include    "VtEngUtils.h"
       
    25 #include    "CVtEngAudioHandler.h"
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CVtEngStateAlerting::CVtEngStateAlerting
       
    31 // C++ constructor can NOT contain any code, that
       
    32 // might leave.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CVtEngStateAlerting::CVtEngStateAlerting( 
       
    36     CVtEngStateManager& aStateManager,
       
    37     CVtEngEventManager& aEventManager )
       
    38     : CVtEngStateBase( aStateManager, aEventManager )
       
    39     {
       
    40     }
       
    41 
       
    42 // Destructor
       
    43 CVtEngStateAlerting::~CVtEngStateAlerting()
       
    44     {
       
    45     __VTPRINT( DEBUG_DESTRUCT, "~StateAlrt")
       
    46     }
       
    47 
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CVtEngStateAlerting::UpdateL
       
    51 // Updates state.
       
    52 // 
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 void CVtEngStateAlerting::UpdateL()
       
    56     {
       
    57     __VTPRINTENTER(  "StateAlert.Update" )
       
    58     const MVtCtlCallControl::TVtCtlState bearerstate = 
       
    59         SessionHandler().RealState();
       
    60     CVtEngStateBase* newState = NULL;
       
    61     if ( bearerstate == MVtCtlCallControl::EIdle ||
       
    62          bearerstate == MVtCtlCallControl::EDisconnecting )
       
    63         {
       
    64         newState = NewStateL( MVtEngSessionInfo::EIdle );
       
    65         }
       
    66     else
       
    67         {
       
    68         newState = NegotiatingOrConnectedStateL(); // or null
       
    69         }
       
    70     if ( newState )
       
    71         {
       
    72         newState->OpenL( this );
       
    73         }
       
    74     __VTPRINTEXIT( "StateAlert.Update")
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CVtEngStateAlerting::OpenL
       
    79 // State transition to alerting state.
       
    80 // 
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 void CVtEngStateAlerting::DoOpenL()
       
    84     {
       
    85     __VTPRINTENTER( "StateAlert.Open" )
       
    86     NotifyStateChange( MVtEngSessionInfo::ERemoteAlerting );
       
    87     
       
    88     // Instantiate temporary devsound for audio routing
       
    89     AudioHandler().SetRoutingEnablerL( ETrue );
       
    90     __VTPRINTEXIT( "StateAlert.Open" )
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CVtEngStateAlerting::ValidateCommand
       
    95 // Returns if a command is valid in idle state.
       
    96 // 
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 TBool CVtEngStateAlerting::ValidateCommand(
       
   100     const TVtEngCommandId aCommandId )
       
   101     {
       
   102     __VTPRINT( DEBUG_DETAIL |DEBUG_GEN, "StateAlert.Validate" )
       
   103     TBool okToPerform( EFalse );
       
   104     switch ( aCommandId )
       
   105         {
       
   106         case KVtEngInitializeEngine:
       
   107         case KVtEngInitializeEngineDiag:
       
   108         case KVtEngInitializeEngineTest:
       
   109         case KVtEngSetSource:
       
   110         case KVtEngPrepareViewFinder:
       
   111         case KVtEngPrepareViewFinderDSA:
       
   112         case KVtEngPrepareViewFinderDP:
       
   113         case KVtEngStartViewFinder:
       
   114         case KVtEngPauseViewFinder:
       
   115         case KVtEngPrepareRemoteRenderDSA:
       
   116         case KVtEngPrepareRemoteRenderDP:
       
   117         case KVtEngPrepareRemoteRenderNGA:
       
   118             okToPerform = ETrue;
       
   119             break;
       
   120         default:
       
   121             okToPerform = CVtEngStateBase::ValidateCommand( aCommandId );
       
   122             break;
       
   123         }
       
   124     return okToPerform;
       
   125     }
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CVtEngStateAlerting::State
       
   129 // Returns session state.
       
   130 // 
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 MVtEngSessionInfo::TSessionState CVtEngStateAlerting::State() const
       
   134     {
       
   135     return MVtEngSessionInfo::ERemoteAlerting;
       
   136     }
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CVtEngStateAlerting::HandleL
       
   140 // Handles an operation when behavior is state dependent.
       
   141 // 
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 TBool CVtEngStateAlerting::HandleL( 
       
   145     CVtEngOperation& aOp )
       
   146     {
       
   147     TBool handled( CVtEngStateBase::HandleL( aOp ));
       
   148     return handled;
       
   149     }
       
   150 
       
   151 // End of File