usbengines/usbotgwatcher/src/cusbstatehostaidle.cpp
branchRCL_3
changeset 67 56303587e92f
parent 66 3cb82e326395
child 68 165aafcbb3d8
equal deleted inserted replaced
66:3cb82e326395 67:56303587e92f
     1 /*
       
     2 * Copyright (c) 2008-2009 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:  Implementation
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include "cusbstatehostaidle.h"
       
    20 #include "cusbnotifmanager.h"
       
    21 
       
    22 #ifndef STIF
       
    23 #include "cusbtimer.h"
       
    24 #else
       
    25 #include "mockcusbtimer.h"
       
    26 #endif
       
    27 #include "definitions.h"
       
    28 
       
    29 #include "errors.h"
       
    30 #include "debug.h"
       
    31 #include "panic.h"
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // 
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CUsbStateHostAIdle::CUsbStateHostAIdle(CUsbOtgWatcher* aWatcher) :
       
    38     CUsbStateHostAInitiateBase(aWatcher)
       
    39     {
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // 
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 void CUsbStateHostAIdle::ConstructL()
       
    47     {
       
    48         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::ConstructL" ) );
       
    49 
       
    50     CUsbStateHostAInitiateBase::ConstructL();
       
    51     }
       
    52 // ---------------------------------------------------------------------------
       
    53 // 
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 
       
    57 CUsbStateHostAIdle* CUsbStateHostAIdle::NewL(CUsbOtgWatcher* aWatcher)
       
    58     {
       
    59         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::NewL" ) );
       
    60 
       
    61     CUsbStateHostAIdle* self = new (ELeave) CUsbStateHostAIdle(aWatcher);
       
    62     CleanupStack::PushL(self);
       
    63     self->ConstructL();
       
    64     CleanupStack::Pop(self);
       
    65     return self;
       
    66     }
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // 
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 CUsbStateHostAIdle::~CUsbStateHostAIdle()
       
    73     {
       
    74         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::~CUsbStateHostAIdle" ) );
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // 
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 TUsbStateIds CUsbStateHostAIdle::Id()
       
    82     {
       
    83         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::Id" ) );
       
    84 
       
    85     return EUsbStateHostAIdle;
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // 
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 void CUsbStateHostAIdle::JustAdvancedToThisStateL()
       
    93     {
       
    94         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAIdle::JustAdvancedToThisStateL" ) );
       
    95 
       
    96     iWatcher->PrintStateToLog();
       
    97     
       
    98     // do BusDrop, if Up
       
    99     if (CUsbVBusObserver::EVBusUp == iWatcher->VBusObserver()->VBus())
       
   100         {
       
   101         TInt err = iWatcher->Usb().BusDrop();
       
   102         if (err != KErrNone)
       
   103             {
       
   104             err = iWatcher->Usb().BusClearError();
       
   105             if (KErrNone != err)
       
   106                 {
       
   107                 iWatcher->HandleHostProblemL(EUsbWatcherErrorInConnection, EUsbStateHostHandle);
       
   108                 }
       
   109             }
       
   110         }
       
   111     }