usbengines/usbotgwatcher/src/cusbstatehostaidle.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 07 Jan 2010 13:25:34 +0200
changeset 1 705ec7b86991
parent 0 1e05558e2206
child 5 7068aba64af5
permissions -rw-r--r--
Revision: 200951 Kit: 201001

/*
* Copyright (c) 2008-2009 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:  Implementation
 *
*/


#include "cusbstatehostaidle.h"
#include "cusbnotifmanager.h"

#ifndef STIF
#include "cusbtimer.h"
#else
#include "mockcusbtimer.h"
#endif
#include "definitions.h"

#include "errors.h"
#include "debug.h"
#include "panic.h"

// ---------------------------------------------------------------------------
// 
// ---------------------------------------------------------------------------
//
CUsbStateHostAIdle::CUsbStateHostAIdle(CUsbOtgWatcher* aWatcher) :
    CUsbStateHostAInitiateBase(aWatcher)
    {
    }

// ---------------------------------------------------------------------------
// 
// ---------------------------------------------------------------------------
//
void CUsbStateHostAIdle::ConstructL()
    {
        FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::ConstructL" ) );

    CUsbStateHostAInitiateBase::ConstructL();
    }
// ---------------------------------------------------------------------------
// 
// ---------------------------------------------------------------------------
//

CUsbStateHostAIdle* CUsbStateHostAIdle::NewL(CUsbOtgWatcher* aWatcher)
    {
        FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::NewL" ) );

    CUsbStateHostAIdle* self = new (ELeave) CUsbStateHostAIdle(aWatcher);
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop(self);
    return self;
    }

// ---------------------------------------------------------------------------
// 
// ---------------------------------------------------------------------------
//
CUsbStateHostAIdle::~CUsbStateHostAIdle()
    {
        FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::~CUsbStateHostAIdle" ) );
    }

// ---------------------------------------------------------------------------
// 
// ---------------------------------------------------------------------------
//
TUsbStateIds CUsbStateHostAIdle::Id()
    {
        FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::Id" ) );

    return EUsbStateHostAIdle;
    }

// ---------------------------------------------------------------------------
// 
// ---------------------------------------------------------------------------
//
void CUsbStateHostAIdle::JustAdvancedToThisStateL()
    {
        FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::JustAdvancedToThisStateL" ) );

    iWatcher->PrintStateToLog();
    
    // do BusDrop, if Up
    if (CUsbVBusObserver::EVBusUp == iWatcher->VBusObserver()->VBus())
        {
        TInt err = iWatcher->Usb().BusDrop();
        if (err != KErrNone)
            {
            err = iWatcher->Usb().BusClearError();
            if (KErrNone != err)
                {
                iWatcher->HandleHostProblemL(EUsbWatcherErrorInConnection);
                }
            }
        }
    }