vtengines/videoteleng/Src/State/CVtEngStateNegotiating.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:  Negotiating state
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "CVtEngStateNegotiating.h"
       
    21 #include    <cvtlogger.h>
       
    22 
       
    23 
       
    24 // ============================ MEMBER FUNCTIONS ===============================
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // CVtEngStateNegotiating::CVtEngStateNegotiating
       
    28 // C++ constructor can NOT contain any code, that
       
    29 // might leave.
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 CVtEngStateNegotiating::CVtEngStateNegotiating( 
       
    33     CVtEngStateManager& aStateManager,
       
    34     CVtEngEventManager& aEventManager )
       
    35     : CVtEngStateBase( aStateManager, aEventManager )
       
    36     {
       
    37     }
       
    38 
       
    39 // Destructor
       
    40 CVtEngStateNegotiating::~CVtEngStateNegotiating()
       
    41     {
       
    42     __VTPRINT( DEBUG_DESTRUCT, "~Stateneg")
       
    43     }
       
    44 
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CVtEngStateNegotiating::UpdateL
       
    48 // Updates state
       
    49 // (other items were commented in a header).
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 void CVtEngStateNegotiating::UpdateL()
       
    53     {
       
    54     __VTPRINTENTER( "StateNegotiate.Update" )
       
    55     const MVtCtlCallControl::TVtCtlState bearerstate = 
       
    56         SessionHandler().RealState();
       
    57     const MVtProtocolCommand::TVtProtocolState state( MediaHandler().ProtoState() );
       
    58     CVtEngStateBase* newState = NULL;
       
    59 
       
    60     if ( bearerstate != MVtCtlCallControl::EConnected ||
       
    61          state == MVtProtocolCommand::ESetup ) // <- connect failed
       
    62         {
       
    63         newState = NewStateL( MVtEngSessionInfo::EClearing );
       
    64         }
       
    65     else if ( state == MVtProtocolCommand::EConnected )
       
    66         {
       
    67         // change to open state
       
    68         newState = NewStateL( MVtEngSessionInfo::EOpen );
       
    69         }
       
    70     else if ( state == MVtProtocolCommand::ESetup )
       
    71         {
       
    72         // should not usually happen unless connect fails
       
    73         newState = NewStateL( MVtEngSessionInfo::EConnected );
       
    74         }
       
    75     if ( newState )
       
    76         {
       
    77         newState->OpenL( this );
       
    78         }
       
    79     __VTPRINTEXIT( "StateNegotiate.Update" )
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CVtEngStateNegotiating::OpenL
       
    84 // State transition to negotiating.
       
    85 // (other items were commented in a header).
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 void CVtEngStateNegotiating::DoOpenL( )
       
    89     {
       
    90     __VTPRINTENTER( "StateNegotiate.Open" )
       
    91     NotifyStateChange( MVtEngSessionInfo::ENegotiating);
       
    92     __VTPRINTEXIT( "StateNegotiate.Open" )
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CVtEngStateNegotiating::ValidateCommand
       
    97 // Returns if a command is valid in negotiating state.
       
    98 // 
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 TBool CVtEngStateNegotiating::ValidateCommand(
       
   102     const TVtEngCommandId aCommandId )
       
   103     {
       
   104     __VTPRINT( DEBUG_DETAIL | DEBUG_GEN, "StateNegotiate.Validate")
       
   105     TBool okToPerform( EFalse );
       
   106     switch ( aCommandId )
       
   107         {
       
   108         case KVtEngPrepareViewFinder:        
       
   109         case KVtEngPrepareRemoteRenderDSA:
       
   110         case KVtEngPrepareRemoteRenderDP:
       
   111         case KVtEngPrepareRemoteRender:
       
   112         case KVtEngPrepareRemoteRenderNGA:
       
   113         case KVtEngStartRenderRemote: // cached to settings
       
   114         case KVtEngSetSource:
       
   115         case KVtEngPrepareCamera:
       
   116         case KVtEngSetZoomStep:
       
   117         case KVtEngStartViewFinder:
       
   118         case KVtEngStopViewFinder:
       
   119         case KVtEngTerminateSession:
       
   120             okToPerform = ETrue;
       
   121             break;
       
   122         default:
       
   123             okToPerform = CVtEngStateBase::ValidateCommand( aCommandId );
       
   124             break;
       
   125         }
       
   126     return okToPerform;
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CVtEngStateNegotiating::State
       
   131 // Returns session state.
       
   132 // 
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 MVtEngSessionInfo::TSessionState CVtEngStateNegotiating::State() const
       
   136     {
       
   137     return MVtEngSessionInfo::ENegotiating;
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CVtEngStateNegotiating::HandleL
       
   142 // Handles an operation when behavior is state dependent.
       
   143 // 
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 TBool CVtEngStateNegotiating::HandleL( CVtEngOperation& aOp )
       
   147     {
       
   148     __VTPRINTENTER( "StateNegotiate.HandleL" )
       
   149     TBool handled( CVtEngStateBase::HandleL( aOp ) );
       
   150     if ( !handled )
       
   151         {
       
   152         switch ( aOp.Command() )
       
   153             {
       
   154             case KVtEngStartRenderRemote:
       
   155                 SetVideoEnabled( ETrue );
       
   156                 handled = ETrue;
       
   157                 break;
       
   158             case KVtEngTerminateSession:
       
   159                 TerminateSessionL( aOp );
       
   160                 break;
       
   161             }
       
   162         }
       
   163     __VTPRINTEXITR( "StateNegotiate.HandleL %d", handled )
       
   164     return handled;
       
   165     }
       
   166 
       
   167 // End of File