usbengines/usbotgwatcher/src/cusbstatehosthandle.cpp
changeset 0 1e05558e2206
child 1 705ec7b86991
equal deleted inserted replaced
-1:000000000000 0:1e05558e2206
       
     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 <usbuinotif.h>
       
    20 
       
    21 #include "cusbstatehosthandle.h"
       
    22 #ifndef STIF
       
    23 #include "cusbnotifmanager.h"
       
    24 #else
       
    25 #include "mockcusbnotifmanager.h"
       
    26 #endif
       
    27 
       
    28 #include "errors.h"
       
    29 #include "debug.h"
       
    30 #include "panic.h"
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // 
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 CUsbStateHostHandle::CUsbStateHostHandle(CUsbOtgWatcher* aWatcher) :
       
    37     CUsbState(aWatcher)
       
    38     {
       
    39     }
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // 
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CUsbStateHostHandle* CUsbStateHostHandle::NewL(CUsbOtgWatcher* aWatcher)
       
    46     {
       
    47         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::NewL" ) );
       
    48 
       
    49     CUsbStateHostHandle* self = new (ELeave) CUsbStateHostHandle(aWatcher);
       
    50     CleanupStack::PushL(self);
       
    51     self->ConstructL();
       
    52     CleanupStack::Pop(self);
       
    53     return self;
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // 
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 void CUsbStateHostHandle::ConstructL()
       
    61     {
       
    62         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::ConstructL" ) );
       
    63 
       
    64     iTooMuchPowerTimer = CUsbTimer::NewL(this, ETooMuchPowerRequiredTimer);
       
    65 
       
    66     }
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // 
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 CUsbStateHostHandle::~CUsbStateHostHandle()
       
    73     {
       
    74         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::~CUsbStateHostHandle" ) );
       
    75 
       
    76     delete iTooMuchPowerTimer;
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // 
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 TUsbStateIds CUsbStateHostHandle::Id()
       
    84     {
       
    85         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::Id" ) );
       
    86 
       
    87     return EUsbStateHostHandle;
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // 
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 void CUsbStateHostHandle::JustAdvancedToThisStateL()
       
    95     {
       
    96         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::JustAdvancedToThisStateL" ) );
       
    97     iWatcher->PrintStateToLog();
       
    98 
       
    99     DoHandleL();
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // 
       
   104 // ---------------------------------------------------------------------------
       
   105 //
       
   106 void CUsbStateHostHandle::JustBeforeLeavingThisStateL()
       
   107     {
       
   108     iTooMuchPowerTimer->Cancel();
       
   109     iWatcher->NotifManager()->CloseAllNotifiers();
       
   110     }
       
   111 // ---------------------------------------------------------------------------
       
   112 // 
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 void CUsbStateHostHandle::SetWhat(TInt aWhat)
       
   116     {
       
   117     iWhat = aWhat;
       
   118     }
       
   119 
       
   120 // this means only one wait notifier at a time can be shown by this state
       
   121 // ---------------------------------------------------------------------------
       
   122 // 
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 void CUsbStateHostHandle::WaitNotifierCompletedL(TInt /*aFeedback*/)
       
   126     {
       
   127         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL" ) );
       
   128     switch (iWhat)
       
   129         {
       
   130         case EUsbWatcherErrDriversNotFound:
       
   131             {
       
   132                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL DriversNotFound" ) );
       
   133             ChangeHostStateL(EUsbStateHostAInitiate);
       
   134             break;
       
   135             }
       
   136         case EUsbWatcherHubsNotSupported:
       
   137             {
       
   138                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherHubsNotSupported" ) );
       
   139             ChangeHostStateL(EUsbStateHostAInitiate);
       
   140             break;
       
   141             }
       
   142         case EUsbWatcherErrDeviceRequiresTooMuchPower:
       
   143             {
       
   144                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherErrDeviceRequiresTooMuchPower" ) );
       
   145             ChangeHostStateL(EUsbStateHostAInitiate);
       
   146             break;
       
   147             }
       
   148         case EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration:
       
   149             {
       
   150                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration" ) );
       
   151             ChangeHostStateL(EUsbStateHostAInitiate);
       
   152             break;
       
   153             }
       
   154         case EUsbWatcherErrUnsupportedDevice:
       
   155             {
       
   156                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherErrUnsupportedDevice" ) );
       
   157             ChangeHostStateL(EUsbStateHostAInitiate);
       
   158             break;
       
   159             }
       
   160         case EUsbWatcherConnectedToOTG:
       
   161             {
       
   162                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherConnectedToOTG" ) );
       
   163             ChangeHostStateL(EUsbStateHostAInitiate);
       
   164             break;
       
   165             }
       
   166         case EUsbWatcherErrDandlingCable:
       
   167             {
       
   168                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherErrDandlingCable" ) );
       
   169             ChangeHostStateL(EUsbStateHostAInitiate);
       
   170             break;
       
   171             }
       
   172         case EUsbWatcherNoActivity:
       
   173             {
       
   174                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherNoActivity" ) );
       
   175             ChangeHostStateL(EUsbStateHostAInitiate);
       
   176             break;
       
   177             }
       
   178         case EUsbWatcherErrorInConnection:
       
   179             {
       
   180                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherErrorInConnection" ) );
       
   181             ChangeHostStateL(EUsbStateHostAInitiate);
       
   182             break;
       
   183             }
       
   184         case EUsbWatcherCanNotStartUsbServices:
       
   185             {
       
   186             FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL EUsbWatcherCanNotStartUsbServices" ) );
       
   187             
       
   188             break;                     
       
   189             }
       
   190         // errors from observers mapped to one
       
   191         case EUsbWatcherIdPinError:
       
   192         case EUsbWatcherVBusObserverError:
       
   193         case EUsbWatcherHostEventNotificationError:
       
   194         case EUsbWatcherOtgStateError:
       
   195         case EUsbWatcherMessageNotificationError:
       
   196             {
       
   197             // try to restore
       
   198             FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL Error in observer" ) );
       
   199             ChangeHostStateL(EUsbStateHostAInitiate);
       
   200             break;
       
   201             }
       
   202         default:
       
   203             {
       
   204                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL Unexpected situation to be handled" ) );
       
   205             Panic(EUnexpectedSituationToHandle);
       
   206             break;
       
   207             }
       
   208 
       
   209         }
       
   210     }
       
   211 
       
   212 // ---------------------------------------------------------------------------
       
   213 // 
       
   214 // ---------------------------------------------------------------------------
       
   215 //
       
   216 void CUsbStateHostHandle::DoHandleL()
       
   217     {
       
   218         FTRACE( FPrint(_L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL iWhat = %d" ), iWhat));
       
   219 
       
   220     if (iTooMuchPowerTimer)
       
   221         iTooMuchPowerTimer->Cancel();
       
   222 
       
   223     switch (iWhat)
       
   224         {
       
   225         case EUsbWatcherErrDriversNotFound:
       
   226             {
       
   227                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL DriversNotFound" ) );
       
   228             // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped 
       
   229             iWatcher->Usb().BusDrop();
       
   230             iWatcher->NotifManager()->ShowIndicatorL(EFalse);
       
   231             iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
       
   232                     EUsbOtgUnsupportedDevice, this);
       
   233 
       
   234             break;
       
   235             }
       
   236         case EUsbWatcherHubsNotSupported:
       
   237             {
       
   238                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherHubsNotSupported" ) );
       
   239             // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped 
       
   240             iWatcher->Usb().BusDrop();
       
   241             iWatcher->NotifManager()->ShowIndicatorL(EFalse);
       
   242             iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
       
   243                     EUsbOtgHubUnsupported, this);
       
   244             break;
       
   245             }
       
   246         case EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration:
       
   247             {
       
   248                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration" ) );
       
   249 
       
   250             iTooMuchPowerTimer->After(KTimeTooMuchPowerRequired);
       
   251             break;
       
   252             }
       
   253         case EUsbWatcherErrDeviceRequiresTooMuchPower:
       
   254             {
       
   255                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherErrDeviceRequiresTooMuchPower" ) );
       
   256             // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped 
       
   257             iWatcher->Usb().BusDrop();
       
   258             iWatcher->NotifManager()->ShowIndicatorL(EFalse);
       
   259             iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
       
   260                     EUsbOtgTooMuchPower, this);
       
   261             break;
       
   262             }
       
   263         case EUsbWatcherErrUnsupportedDevice:
       
   264             {
       
   265                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherErrUnsupportedDevice" ) );
       
   266             // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped 
       
   267             iWatcher->Usb().BusDrop();
       
   268             iWatcher->NotifManager()->ShowIndicatorL(EFalse);
       
   269             iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
       
   270                     EUsbOtgUnsupportedDevice, this);
       
   271             break;
       
   272             }
       
   273         case EUsbWatcherConnectedToOTG:
       
   274             {
       
   275                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherConnectedToOTG" ) );
       
   276                 
       
   277             // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped
       
   278             iWatcher->Usb().BusDrop();
       
   279             iWatcher->NotifManager()->ShowIndicatorL(EFalse);
       
   280             iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
       
   281                     EUsbOtgUnsupportedDevice, this);
       
   282             break;
       
   283             }
       
   284         case EUsbWatcherErrDandlingCable:
       
   285             {
       
   286                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherErrDandlingCable" ) );
       
   287             // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped 
       
   288             iWatcher->Usb().BusDrop();
       
   289             iWatcher->NotifManager()->ShowIndicatorL(EFalse);
       
   290             iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
       
   291                     EUsbOtgErrorAttachTimedOut, this);
       
   292             break;
       
   293             }
       
   294         case EUsbWatcherNoActivity:
       
   295             {
       
   296                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherNoActivity" ) );
       
   297             // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped 
       
   298             iWatcher->Usb().BusDrop();
       
   299             iWatcher->NotifManager()->ShowIndicatorL(EFalse);
       
   300             iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
       
   301                     EUsbOtgUnsupportedDevice, this);
       
   302 
       
   303             break;
       
   304             }
       
   305         case EUsbWatcherErrorInConnection:
       
   306             {
       
   307                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherErrorInConnection" ) );
       
   308             // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped 
       
   309             iWatcher->Usb().BusDrop();
       
   310             iWatcher->NotifManager()->ShowIndicatorL(EFalse);
       
   311             iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
       
   312                     EUsbOtgErrorInConnection, this);
       
   313             break;
       
   314             }
       
   315         case EUsbWatcherCanNotStartUsbServices:
       
   316             {
       
   317             FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherCanNotStartUsbServices" ) );
       
   318             iWatcher->NotifManager()->ShowIndicatorL(EFalse);
       
   319             iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
       
   320                 EUsbOtgErrorInConnection, this);
       
   321             break;           
       
   322             }
       
   323         // errors from observers mapped to one
       
   324         case EUsbWatcherIdPinError:
       
   325         case EUsbWatcherVBusObserverError:
       
   326         case EUsbWatcherHostEventNotificationError:
       
   327         case EUsbWatcherOtgStateError:
       
   328         case EUsbWatcherMessageNotificationError:
       
   329             {
       
   330             FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL Error from observer" ) );
       
   331         // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped 
       
   332         iWatcher->Usb().BusDrop();
       
   333         iWatcher->NotifManager()->ShowIndicatorL(EFalse);
       
   334         iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
       
   335                 EUsbOtgErrorInConnection, this);
       
   336             break;
       
   337             }
       
   338         default:
       
   339             {
       
   340                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::WaitNotifierCompletedL Unexpected situation to be handled" ) );
       
   341             Panic(EUnexpectedSituationToHandle);
       
   342             break;
       
   343             }
       
   344         }
       
   345     }
       
   346 
       
   347 /////////////////////////////////////////////////////////////////////////////////////
       
   348 // just ignore all the events		
       
   349 // From VBus observer
       
   350 void CUsbStateHostHandle::VBusDownL()
       
   351     {
       
   352         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::VBusDownL" ) );
       
   353     }
       
   354 
       
   355 // From OTG state observer
       
   356 // ---------------------------------------------------------------------------
       
   357 // 
       
   358 // ---------------------------------------------------------------------------
       
   359 //
       
   360 void CUsbStateHostHandle::AIdleL()
       
   361     {
       
   362         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::AIdleL" ) );
       
   363 
       
   364     }
       
   365 
       
   366 // ---------------------------------------------------------------------------
       
   367 // 
       
   368 // ---------------------------------------------------------------------------
       
   369 //
       
   370 void CUsbStateHostHandle::AHostL()
       
   371     {
       
   372         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::AHostL" ) );
       
   373     }
       
   374 
       
   375 // ---------------------------------------------------------------------------
       
   376 // 
       
   377 // ---------------------------------------------------------------------------
       
   378 //
       
   379 void CUsbStateHostHandle::APeripheralL()
       
   380     {
       
   381         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::APeripheralL" ) );
       
   382 
       
   383     }
       
   384 
       
   385 // ---------------------------------------------------------------------------
       
   386 // 
       
   387 // ---------------------------------------------------------------------------
       
   388 //
       
   389 void CUsbStateHostHandle::AVBusErrorL()
       
   390     {
       
   391         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::AVBusErrorL" ) );
       
   392 
       
   393     }
       
   394 
       
   395 // ---------------------------------------------------------------------------
       
   396 // 
       
   397 // ---------------------------------------------------------------------------
       
   398 //
       
   399 void CUsbStateHostHandle::BIdleL()
       
   400     {
       
   401         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BIdleL" ) );
       
   402 
       
   403     }
       
   404 
       
   405 // ---------------------------------------------------------------------------
       
   406 // 
       
   407 // ---------------------------------------------------------------------------
       
   408 //
       
   409 void CUsbStateHostHandle::BPeripheralL()
       
   410     {
       
   411         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BPeripheralL" ) );
       
   412 
       
   413     }
       
   414 
       
   415 // ---------------------------------------------------------------------------
       
   416 // 
       
   417 // ---------------------------------------------------------------------------
       
   418 //
       
   419 void CUsbStateHostHandle::BHostL()
       
   420     {
       
   421         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BHostL" ) );
       
   422 
       
   423     }
       
   424 
       
   425 // From bus activity observer
       
   426 // ---------------------------------------------------------------------------
       
   427 // 
       
   428 // ---------------------------------------------------------------------------
       
   429 //
       
   430 void CUsbStateHostHandle::BusIdleL()
       
   431     {
       
   432         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BusIdleL" ) );
       
   433 
       
   434     }
       
   435 
       
   436 // ---------------------------------------------------------------------------
       
   437 // 
       
   438 // ---------------------------------------------------------------------------
       
   439 //
       
   440 void CUsbStateHostHandle::BusActiveL()
       
   441     {
       
   442         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BusActiveL" ) );
       
   443 
       
   444     }
       
   445 
       
   446 // From Host Event notification observer
       
   447 // ---------------------------------------------------------------------------
       
   448 // 
       
   449 // ---------------------------------------------------------------------------
       
   450 //
       
   451 void CUsbStateHostHandle::DeviceAttachedL(
       
   452         TDeviceEventInformation aDevEventInfo)
       
   453     {
       
   454         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DeviceAttachedL" ) );
       
   455 
       
   456     if (iTooMuchPowerTimer->IsActive())
       
   457         {
       
   458         ChangeHostStateL(EUsbStateHostAInitiate);
       
   459         iWatcher->DeviceAttachedL(aDevEventInfo);
       
   460         }
       
   461     else
       
   462         {
       
   463             FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DeviceAttachedL Unexpected situation" ) );
       
   464         }
       
   465     }
       
   466 
       
   467 // ---------------------------------------------------------------------------
       
   468 // 
       
   469 // ---------------------------------------------------------------------------
       
   470 //
       
   471 void CUsbStateHostHandle::DeviceDetachedL(TDeviceEventInformation)
       
   472     {
       
   473         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DeviceDetachedL" ) );
       
   474 
       
   475     }
       
   476 
       
   477 // ---------------------------------------------------------------------------
       
   478 // 
       
   479 // ---------------------------------------------------------------------------
       
   480 //
       
   481 void CUsbStateHostHandle::DriverLoadSuccessL(TDeviceEventInformation)
       
   482     {
       
   483         FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DriverLoadSuccessL" ) );
       
   484     
       
   485     }
       
   486 
       
   487 // ---------------------------------------------------------------------------
       
   488 // 
       
   489 // ---------------------------------------------------------------------------
       
   490 //
       
   491 void CUsbStateHostHandle::DriverLoadPartialSuccessL(TDeviceEventInformation)
       
   492     {
       
   493         FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DriverLoadPartialSuccessL" ) );
       
   494     
       
   495     }
       
   496 
       
   497 // ---------------------------------------------------------------------------
       
   498 // 
       
   499 // ---------------------------------------------------------------------------
       
   500 //
       
   501 void CUsbStateHostHandle::DriverLoadFailureL(TDeviceEventInformation)
       
   502     {
       
   503         FLOG( _L( "[USBOTGWATCHER]\tCUsbState::DriverLoadFailureL" ) );
       
   504     
       
   505     }
       
   506 
       
   507 // ---------------------------------------------------------------------------
       
   508 // 
       
   509 // ---------------------------------------------------------------------------
       
   510 //
       
   511 void CUsbStateHostHandle::BadHubPositionL()
       
   512     {
       
   513         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::BadHubPositionL" ) );
       
   514 
       
   515     if (iTooMuchPowerTimer->IsActive())
       
   516         {
       
   517         ChangeHostStateL(EUsbStateHostAInitiate);
       
   518         iWatcher->BadHubPositionL();
       
   519         }
       
   520     else
       
   521         {
       
   522             FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DeviceAttachedL Unexpected situation" ) );
       
   523         }
       
   524     }
       
   525 
       
   526 // ---------------------------------------------------------------------------
       
   527 // 
       
   528 // ---------------------------------------------------------------------------
       
   529 //
       
   530 void CUsbStateHostHandle::VBusErrorL()
       
   531     {
       
   532         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::VBusErrorL" ) );
       
   533 
       
   534     iWatcher->Usb().BusClearError();
       
   535     FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::VBusErrorL Unexpected situation" ) );
       
   536     }
       
   537 
       
   538 // ---------------------------------------------------------------------------
       
   539 // 
       
   540 // ---------------------------------------------------------------------------
       
   541 //
       
   542 void CUsbStateHostHandle::MessageNotificationReceivedL(TInt)
       
   543     {
       
   544         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::MessageNotificationReceivedL" ) );
       
   545 
       
   546     }
       
   547 
       
   548 // ---------------------------------------------------------------------------
       
   549 // 
       
   550 // ---------------------------------------------------------------------------
       
   551 //
       
   552 void CUsbStateHostHandle::SrpReceivedL()
       
   553     {
       
   554     FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::SrpReceivedL" ) );
       
   555         
       
   556     if (CUsbVBusObserver::EVBusUp != iWatcher->VBusObserver()->VBus())
       
   557         {
       
   558         TInt err = iWatcher->Usb().BusRespondSrp();
       
   559         if (KErrNone != err)
       
   560             {
       
   561             FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::SrpReceivedL BusRespondSrp error" ) );
       
   562             iWatcher->HandleHostProblemL(EUsbWatcherErrorInConnection);
       
   563             }
       
   564         else
       
   565             {
       
   566             ChangeHostStateL(EUsbStateHostAInitiate);
       
   567             }
       
   568         }
       
   569 
       
   570     }
       
   571 
       
   572 // ---------------------------------------------------------------------------
       
   573 // 
       
   574 // ---------------------------------------------------------------------------
       
   575 //
       
   576 void CUsbStateHostHandle::SessionRequestedL()
       
   577     {
       
   578         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::SessionRequestedL" ) );
       
   579 
       
   580     }
       
   581 
       
   582 // From TimerObserver
       
   583 // ---------------------------------------------------------------------------
       
   584 // 
       
   585 // ---------------------------------------------------------------------------
       
   586 //
       
   587 void CUsbStateHostHandle::TimerElapsedL(TUsbTimerId aTimerId)
       
   588     {
       
   589     switch (aTimerId)
       
   590         {
       
   591         case ETooMuchPowerRequiredTimer:
       
   592             {
       
   593                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::TimerElapsedL - ETooMuchPowerRequiredTimer" ) );
       
   594             iWatcher->Usb().BusDrop();
       
   595             iWatcher->NotifManager()->ShowIndicatorL(EFalse);
       
   596             iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
       
   597                     EUsbOtgTooMuchPowerRequired, this);
       
   598             break;
       
   599             }
       
   600         default:
       
   601             {
       
   602                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::TimerElapsedL - Unknown timer" ) );
       
   603             Panic(EWrongTimerId);
       
   604             }
       
   605         }
       
   606     }