vtengines/videoteleng/Src/State/CVtEngStateIdle.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 02 Sep 2010 20:28:30 +0300
changeset 36 f5f903566743
parent 0 ed9695c8bcbe
permissions -rw-r--r--
Revision: 201033 Kit: 201035

/*
* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Idle state
*
*/


// INCLUDE FILES
#include    "CVtEngStateIdle.h"
#include    <cvtlogger.h>


// ============================ MEMBER FUNCTIONS ===============================

// -----------------------------------------------------------------------------
// CVtEngStateIdle::CVtEngStateIdle
// C++ constructor can NOT contain any code, that
// might leave.
// -----------------------------------------------------------------------------
//
CVtEngStateIdle::CVtEngStateIdle( 
    CVtEngStateManager& aStateManager,
    CVtEngEventManager& aEventManager )
    : CVtEngStateBase( aStateManager, aEventManager )
    {
    }

// Destructor
CVtEngStateIdle::~CVtEngStateIdle()
    {
    __VTPRINT( DEBUG_DESTRUCT, "~Stateidl")
    }


// -----------------------------------------------------------------------------
// CVtEngStateIdle::UpdateL
// Updates state
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CVtEngStateIdle::UpdateL()
    {
    __VTPRINTENTER( "StateIdle.Update")
   
    const MVtCtlCallControl::TVtCtlState state = SessionHandler().RealState();
    CVtEngStateBase* newState = NULL;
    
    if( iStateManager.PreviousSessionState() == MVtEngSessionInfo::EUnknown )
        {
        switch ( state )
            {
            case MVtCtlCallControl::EInitializing:
                newState = NewStateL( MVtEngSessionInfo::EInitializing );
                break;
            case MVtCtlCallControl::EAlerting:
                newState = NewStateL( MVtEngSessionInfo::ERemoteAlerting );
                break;
            case MVtCtlCallControl::ERinging:
                newState = NewStateL( MVtEngSessionInfo::EReceiving );
                break;
            case MVtCtlCallControl::EConnected:
                newState = NegotiatingOrConnectedStateL();
                break;
            default:
                break;
            }
        if ( newState )
            {
            CVtEngUtility* utils = CVtEngUtility::EngineUtils();
            
            // Notify UI about initial autolock state. UI must have this
            // information early enough to deduce if it is allowed to 
            // go to foreground.
            utils->NotifyLockState();            
            utils->StartSATListenL();
            newState->OpenL( this );
            }
        }
    else
        {
        __VTPRINT( DEBUG_GEN, "StateIdle.Update wrong previous state, ignoring")        
        }
    __VTPRINTEXIT( "StateIdle.Update")
    }

// -----------------------------------------------------------------------------
// CVtEngStateIdle::OpenL
// State transition to idle.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CVtEngStateIdle::DoOpenL()
    {
    __VTPRINTENTER( "StateIdle.Open")
    // Reset settings
    CVtEngSettings& settings = CVtEngUtility::Settings();
    settings.ResetAll();
    
    NotifyStateChange( MVtEngSessionInfo::EIdle );
    __VTPRINTEXIT( "StateIdle.Open")
    }

// -----------------------------------------------------------------------------
// CVtEngStateIdle::ValidateCommand
// Returns if a command is valid in idle state.
// 
// -----------------------------------------------------------------------------
//
TBool CVtEngStateIdle::ValidateCommand(
            const TVtEngCommandId aCommandId )
    {
    __VTPRINT( DEBUG_DETAIL | DEBUG_GEN, "StateIdle.Validate")
    TBool okToPerform( EFalse );
    switch ( aCommandId )
        {
        case KVtEngPrepareViewFinder:        
        case KVtEngPrepareRemoteRenderDSA:
        case KVtEngPrepareRemoteRenderDP:
        case KVtEngPrepareRemoteRender:
        case KVtEngPrepareRemoteRenderNGA:
            okToPerform = ETrue;
            break;
        default:
            okToPerform = CVtEngStateBase::ValidateCommand( aCommandId );
            break;
        }
    return okToPerform;
    }

// -----------------------------------------------------------------------------
// CVtEngStateIdle::State
// Returns session state.
// 
// -----------------------------------------------------------------------------
//
MVtEngSessionInfo::TSessionState CVtEngStateIdle::State() const
    {
    return MVtEngSessionInfo::EIdle;
    }


// End of File