vtengines/videoteleng/Src/State/CVtEngStateClearing.cpp
changeset 0 ed9695c8bcbe
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     1 /*
       
     2 * Copyright (c) 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    "CVtEngStateClearing.h"
       
    21 #include    <cvtlogger.h>
       
    22 #include    "CVtEngOperation.h"
       
    23 #include    "CVtEngSettings.h"
       
    24 #include    "VtEngUtils.h"
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CVtEngStateClearing::CVtEngStateClearing
       
    30 // C++ constructor can NOT contain any code, that
       
    31 // might leave.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CVtEngStateClearing::CVtEngStateClearing( 
       
    35     CVtEngStateManager& aStateManager,
       
    36     CVtEngEventManager& aEventManager )
       
    37     : CVtEngStateBase( aStateManager, aEventManager )
       
    38     {
       
    39     }
       
    40 
       
    41 // Destructor
       
    42 CVtEngStateClearing::~CVtEngStateClearing()
       
    43     {
       
    44     __VTPRINT( DEBUG_DESTRUCT, "~StateClr")
       
    45     }
       
    46 
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CVtEngStateClearing::UpdateL
       
    50 // Updates state.
       
    51 // 
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 void CVtEngStateClearing::UpdateL()
       
    55     {
       
    56     __VTPRINTENTER( "StateClr.Update" )
       
    57     const MVtCtlCallControl::TVtCtlState bearerstate = 
       
    58         SessionHandler().RealState();
       
    59     const MVtProtocolCommand::TVtProtocolState protostate( MediaHandler().ProtoState() );
       
    60 
       
    61     __VTPRINT2( DEBUG_GEN, "StateClr.bearerState=%d", bearerstate )
       
    62     __VTPRINT2( DEBUG_GEN, "StateClr.protoState=%d", protostate )
       
    63 
       
    64     if ( bearerstate == MVtCtlCallControl::EIdle ||
       
    65          bearerstate == MVtCtlCallControl::EDisconnecting ||
       
    66          bearerstate == MVtCtlCallControl::EUnknown ||
       
    67          protostate == MVtProtocolCommand::EIdle || 
       
    68          protostate == MVtProtocolCommand::ESetup )
       
    69         {
       
    70         CVtEngStateBase* idleState = NewStateL( MVtEngSessionInfo::EIdle );
       
    71         idleState->OpenL( this );
       
    72         }
       
    73     __VTPRINTEXIT( "StateClr.Update" )
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CVtEngStateClearing::OpenL
       
    78 // State transition to clearing state.
       
    79 // 
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 void CVtEngStateClearing::DoOpenL()
       
    83     {
       
    84     __VTPRINTENTER( "StateClr.Open")
       
    85     
       
    86     // Do disconnect on Protocol, it is possible that disconnect is already
       
    87     // ongoing and we get error and that's fine.
       
    88     TInt err( MediaHandler().Disconnect() );
       
    89     if ( err != KErrNone && err != KErrAlreadyExists )
       
    90         {
       
    91         __VTPRINT2( DEBUG_GEN, "StateClr.OpenL disconnect fail=%d", err)
       
    92         }
       
    93     // Reset settings
       
    94     CVtEngSettings& settings = CVtEngUtility::Settings();
       
    95     settings.ResetAll();
       
    96     NotifyStateChange( MVtEngSessionInfo::EClearing );
       
    97     __VTPRINTEXIT( "StateClr.Open")
       
    98     }
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CVtEngStateClearing::ValidateCommand
       
   102 // Returns if a command is valid in idle state.
       
   103 // 
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 TBool CVtEngStateClearing::ValidateCommand(
       
   107             const TVtEngCommandId aCommandId )
       
   108     {
       
   109     TBool okToPerform( EFalse );
       
   110     switch ( aCommandId )
       
   111         {
       
   112         case KVtEngTerminateSession:
       
   113             break;
       
   114         default:
       
   115             okToPerform = CVtEngStateBase::ValidateCommand( aCommandId );
       
   116             break;
       
   117         }
       
   118     return okToPerform;
       
   119     }
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // CVtEngStateClearing::State
       
   123 // Returns session state.
       
   124 // 
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 MVtEngSessionInfo::TSessionState CVtEngStateClearing::State() const
       
   128     {
       
   129     return MVtEngSessionInfo::EClearing;
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CVtEngStateClearing::HandleL
       
   134 // Handles an operation when behavior is state dependent.
       
   135 // 
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 TBool CVtEngStateClearing::HandleL( CVtEngOperation& aOp )
       
   139     {
       
   140     TBool handled( CVtEngStateBase::HandleL( aOp ));
       
   141     return handled;
       
   142     }
       
   143 
       
   144 // End of File