vtengines/videoteleng/Src/State/CVtEngStateConnected.cpp
changeset 0 ed9695c8bcbe
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     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    "CVtEngStateConnected.h"
       
    21 #include    <cvtlogger.h>
       
    22 #include    "CVtEngOperation.h"
       
    23 #include    "CVtEngSettings.h"
       
    24 #include    "VtEngUtils.h"
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CVtEngStateConnected::CVtEngStateConnected
       
    30 // C++ constructor can NOT contain any code, that
       
    31 // might leave.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CVtEngStateConnected::CVtEngStateConnected( 
       
    35     CVtEngStateManager& aStateManager,
       
    36     CVtEngEventManager& aEventManager )
       
    37     : CVtEngStateBase( aStateManager, aEventManager )
       
    38     {
       
    39     }
       
    40 
       
    41 // Destructor
       
    42 CVtEngStateConnected::~CVtEngStateConnected()
       
    43     {
       
    44     __VTPRINT( DEBUG_DESTRUCT, "~StateConnected")
       
    45     }
       
    46 
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CVtEngStateConnected::UpdateL
       
    50 // Updates state.
       
    51 // 
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 void CVtEngStateConnected::UpdateL()
       
    55     {
       
    56     __VTPRINTENTER( "StateConnected.Update")
       
    57     const MVtCtlCallControl::TVtCtlState bearerstate = 
       
    58         SessionHandler().RealState();
       
    59     MVtProtocolCommand::TVtProtocolState state( MediaHandler().ProtoState() );
       
    60     
       
    61         
       
    62     CVtEngStateBase* newState = NULL;
       
    63     if ( bearerstate != MVtCtlCallControl::EConnected )
       
    64         {
       
    65         // we've lost bearer connection, go to idle
       
    66         newState = NewStateL( MVtEngSessionInfo::EIdle );
       
    67         }
       
    68     else if ( state == MVtProtocolCommand::EConnected )
       
    69         {
       
    70         // protocol is open (should always go through neg.state but just in case)
       
    71         // change to open state
       
    72         newState = NewStateL( MVtEngSessionInfo::EOpen );
       
    73         }
       
    74     else if ( state == MVtProtocolCommand::EDisconnecting ||
       
    75               state == MVtProtocolCommand::EResetting )
       
    76         {
       
    77         // change to clearing state
       
    78         newState = NewStateL( MVtEngSessionInfo::EClearing );
       
    79         }
       
    80     else
       
    81         {
       
    82         // protocol is set up so connect now if ready
       
    83         newState = NegotiatingOrConnectedStateL( ETrue );
       
    84         }
       
    85     if ( newState )
       
    86         {
       
    87         newState->OpenL( this );
       
    88         }
       
    89     __VTPRINTEXIT( "StateConnected.Update")
       
    90     }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // CVtEngStateConnected::DoOpenL
       
    94 // State transition to connected state.
       
    95 // 
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 void CVtEngStateConnected::DoOpenL()
       
    99     {
       
   100     __VTPRINTENTER( "StateConnected.Open")
       
   101     NotifyStateChange( MVtEngSessionInfo::EConnected );
       
   102     //start monitor incoming call
       
   103     __VTPRINTEXIT( "StateConnected.Open")
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CVtEngStateConnected::ValidateCommand
       
   108 // Returns if a command is valid in idle state.
       
   109 // 
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 TBool CVtEngStateConnected::ValidateCommand(
       
   113             const TVtEngCommandId aCommandId )
       
   114     {
       
   115     __VTPRINT( DEBUG_DETAIL |DEBUG_GEN, "StateConnected.Validate")
       
   116     TBool okToPerform( EFalse );
       
   117     switch ( aCommandId )
       
   118         {
       
   119         case KVtEngSetSource:
       
   120         case KVtEngPrepareViewFinder:
       
   121         case KVtEngStartViewFinder:
       
   122         case KVtEngPauseViewFinder:
       
   123         case KVtEngStopViewFinder:
       
   124         case KVtEngPrepareRemoteRenderDSA:
       
   125         case KVtEngPrepareRemoteRenderDP:
       
   126         case KVtEngPrepareRemoteRenderNGA:
       
   127             okToPerform = ETrue;
       
   128             break;
       
   129         default:
       
   130             okToPerform = CVtEngStateBase::ValidateCommand( aCommandId );
       
   131             break;
       
   132         }
       
   133     return okToPerform;
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // CVtEngStateConnected::State
       
   138 // Returns session state.
       
   139 // 
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 MVtEngSessionInfo::TSessionState CVtEngStateConnected::State() const
       
   143     {
       
   144     return MVtEngSessionInfo::EConnected;
       
   145     }
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // CVtEngStateConnected::HandleL
       
   149 // Handles an operation when behavior is state dependent.
       
   150 // 
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 TBool CVtEngStateConnected::HandleL( CVtEngOperation& aOp )
       
   154     {
       
   155     TBool handled( CVtEngStateBase::HandleL( aOp ));
       
   156     return handled;
       
   157     }
       
   158 
       
   159 // End of File