--- a/usbengines/usbotgwatcher/src/cusbstatehostdelayhandle.cpp Fri Feb 19 23:50:33 2010 +0200
+++ b/usbengines/usbotgwatcher/src/cusbstatehostdelayhandle.cpp Fri Mar 12 15:48:40 2010 +0200
@@ -1,29 +1,21 @@
/*
-* 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
+ * 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".
*
-*/
-
-
-#include <usbuinotif.h>
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Implementation
+ *
+ */
#include "cusbstatehostdelayhandle.h"
-#ifndef STIF
-#include "cusbnotifmanager.h"
-#else
-#include "mockcusbnotifmanager.h"
-#endif
#include "errors.h"
#include "debug.h"
@@ -33,7 +25,7 @@
//
// ---------------------------------------------------------------------------
//
-CUsbStateHostDelayHandle::CUsbStateHostDelayHandle(CUsbOtgWatcher* aWatcher) :
+CUsbStateHostDelayHandle::CUsbStateHostDelayHandle(CUsbOtgWatcher& aWatcher) :
CUsbStateHostHandle(aWatcher)
{
}
@@ -42,28 +34,11 @@
//
// ---------------------------------------------------------------------------
//
-CUsbStateHostDelayHandle* CUsbStateHostDelayHandle::NewL(CUsbOtgWatcher* aWatcher)
- {
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::NewL" ) );
-
- CUsbStateHostDelayHandle* self = new (ELeave) CUsbStateHostDelayHandle(aWatcher);
- CleanupStack::PushL(self);
- self->ConstructL();
- CleanupStack::Pop(self);
- return self;
- }
-
-// ---------------------------------------------------------------------------
-//
-// ---------------------------------------------------------------------------
-//
void CUsbStateHostDelayHandle::ConstructL()
{
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::ConstructL" ) );
+ LOG_FUNC
- iTooMuchPowerTimer = CUsbTimer::NewL(this, ETooMuchPowerRequiredTimer);
- iDriversNotFoundTimer = CUsbTimer::NewL(this, EDriversNotFoundTimer);
-
+ CUsbStateHostHandle::ConstructL();
}
// ---------------------------------------------------------------------------
@@ -72,84 +47,7 @@
//
CUsbStateHostDelayHandle::~CUsbStateHostDelayHandle()
{
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::~CUsbStateHostDelayHandle" ) );
-
- delete iTooMuchPowerTimer;
- delete iDriversNotFoundTimer;
- }
-
-// ---------------------------------------------------------------------------
-//
-// ---------------------------------------------------------------------------
-//
-TUsbStateIds CUsbStateHostDelayHandle::Id()
- {
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::Id" ) );
-
- return EUsbStateHostDelayHandle;
- }
-
-// ---------------------------------------------------------------------------
-//
-// ---------------------------------------------------------------------------
-//
-void CUsbStateHostDelayHandle::JustAdvancedToThisStateL()
- {
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::JustAdvancedToThisStateL" ) );
- // first do something specific to entering this state
- // nothing by now, but something in the future
-
- // then do general things, defined in superclass
- CUsbStateHostHandle::JustAdvancedToThisStateL();
- }
-
-// ---------------------------------------------------------------------------
-//
-// ---------------------------------------------------------------------------
-//
-void CUsbStateHostDelayHandle::JustBeforeLeavingThisStateL()
- {
- iTooMuchPowerTimer->Cancel();
- iDriversNotFoundTimer->Cancel();
-
- // do general things for error handling
- CUsbStateHostHandle::JustBeforeLeavingThisStateL();
- }
-
-// ---------------------------------------------------------------------------
-//
-// ---------------------------------------------------------------------------
-//
-void CUsbStateHostDelayHandle::DoHandleL()
- {
- FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::DoHandleL iWhat = %d" ), iWhat));
-
- switch (iWhat)
- {
- case EUsbWatcherErrDriversNotFound:
- {
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::DoHandleL DriversNotFound" ) );
-
- iDriversNotFoundTimer->After(KTimeDriversNotFound);
- break;
-
- }
-
- case EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration:
- {
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::DoHandleL EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration" ) );
-
- iTooMuchPowerTimer->After(KTimeTooMuchPowerRequired);
- break;
- }
-
- default:
- {
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::DoHandleL Pass request to CUsbStateHostHandle" ) );
- Panic(EUnexpectedSituationToHandle);
- break;
- }
- }
+ LOG_FUNC
}
/////////////////////////////////////////////////////////////////////////////////////
@@ -160,42 +58,9 @@
//
void CUsbStateHostDelayHandle::VBusUpL()
{
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::VBusUpL" ) );
- // this is not expected, due to in this state vbus already up, since entering the state
- Panic(EVBusUpNotExpected);
- }
-
-// ---------------------------------------------------------------------------
-//
-// ---------------------------------------------------------------------------
-//
-void CUsbStateHostDelayHandle::VBusDownL()
- {
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::VBusDownL" ) );
- // this is not expected, due to in this state vbus up during all the lifetime
- Panic(EVBusDownNotExpected);
- }
-
-// ---------------------------------------------------------------------------
-//
-// ---------------------------------------------------------------------------
-//
-void CUsbStateHostDelayHandle::VBusErrorL()
- {
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::VBusErrorL" ) );
- iWatcher->Usb().BusClearError();
- HandleL(EUsbWatcherErrDeviceRequiresTooMuchPower, EUsbStateHostHandle);
- }
-
-// ---------------------------------------------------------------------------
-// this will drop VBus in a while =>
-// handle it in another state
-// ---------------------------------------------------------------------------
-//
-void CUsbStateHostDelayHandle::AVBusErrorL()
- {
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::AVBusErrorL" ) );
- HandleL(EUsbWatcherErrDeviceRequiresTooMuchPower, EUsbStateHostHandle);
+ LOG_FUNC
+ // this is not expected, due to in this state vbus already up, since entering the state
+ Panic( EVBusUpNotExpected);
}
// From Host Event notification observer
@@ -206,71 +71,8 @@
void CUsbStateHostDelayHandle::DeviceAttachedL(
TDeviceEventInformation aDevEventInfo)
{
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::DeviceAttachedL" ) );
-
- ChangeHostStateL(EUsbStateHostAInitiate);
- iWatcher->DeviceAttachedL(aDevEventInfo);
- }
-
-// ---------------------------------------------------------------------------
-//
-// ---------------------------------------------------------------------------
-//
-void CUsbStateHostDelayHandle::DeviceDetachedL(TDeviceEventInformation)
- {
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::DeviceDetachedL" ) );
- ChangeHostStateL(EUsbStateHostAInitiate);
- }
-
-// ---------------------------------------------------------------------------
-//
-// ---------------------------------------------------------------------------
-//
-void CUsbStateHostDelayHandle::BadHubPositionL()
- {
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::BadHubPositionL" ) );
-
- HandleL(EUsbWatcherHubsNotSupported, EUsbStateHostHandle);
- }
-
+ LOG_FUNC
-// ---------------------------------------------------------------------------
-//
-// ---------------------------------------------------------------------------
-//
-void CUsbStateHostDelayHandle::SrpReceivedL()
- {
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::SrpReceivedL" ) );
- // srp is not expected due to vbus is up in thes state
- Panic(ESrpNotExpected);
+ ChangeHostStateL( EUsbStateHostAInitiate);
+ iWatcher.DeviceAttachedL(aDevEventInfo);
}
-
-// From TimerObserver
-// ---------------------------------------------------------------------------
-//
-// ---------------------------------------------------------------------------
-//
-void CUsbStateHostDelayHandle::TimerElapsedL(TUsbTimerId aTimerId)
- {
- switch (aTimerId)
- {
- case ETooMuchPowerRequiredTimer:
- {
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::TimerElapsedL - ETooMuchPowerRequiredTimer" ) );
- HandleL(EUsbWatcherErrDeviceRequiresTooMuchPower, EUsbStateHostHandle);
- break;
- }
- case EDriversNotFoundTimer:
- {
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::TimerElapsedL - EDriversNotFoundTimer" ) );
- HandleL(EUsbWatcherErrUnsupportedDevice, EUsbStateHostHandle);
-
- break;
- }
- default:
- {
- FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostDelayHandle::TimerElapsedL - Unknown timer" ) );
- Panic(EWrongTimerId);
- }
- }
- }