usbengines/usbotgwatcher/src/cusbstatehosthandle.cpp
changeset 3 47c263f7e521
parent 1 705ec7b86991
child 5 7068aba64af5
equal deleted inserted replaced
2:468cfcb53fd1 3:47c263f7e521
    60 void CUsbStateHostHandle::ConstructL()
    60 void CUsbStateHostHandle::ConstructL()
    61     {
    61     {
    62         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::ConstructL" ) );
    62         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::ConstructL" ) );
    63 
    63 
    64     iTooMuchPowerTimer = CUsbTimer::NewL(this, ETooMuchPowerRequiredTimer);
    64     iTooMuchPowerTimer = CUsbTimer::NewL(this, ETooMuchPowerRequiredTimer);
       
    65     iDriversNotFoundTimer = CUsbTimer::NewL(this, EDriversNotFoundTimer);
    65 
    66 
    66     }
    67     }
    67 
    68 
    68 // ---------------------------------------------------------------------------
    69 // ---------------------------------------------------------------------------
    69 // 
    70 // 
    72 CUsbStateHostHandle::~CUsbStateHostHandle()
    73 CUsbStateHostHandle::~CUsbStateHostHandle()
    73     {
    74     {
    74         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::~CUsbStateHostHandle" ) );
    75         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::~CUsbStateHostHandle" ) );
    75 
    76 
    76     delete iTooMuchPowerTimer;
    77     delete iTooMuchPowerTimer;
       
    78     delete iDriversNotFoundTimer;
    77     }
    79     }
    78 
    80 
    79 // ---------------------------------------------------------------------------
    81 // ---------------------------------------------------------------------------
    80 // 
    82 // 
    81 // ---------------------------------------------------------------------------
    83 // ---------------------------------------------------------------------------
   104 // ---------------------------------------------------------------------------
   106 // ---------------------------------------------------------------------------
   105 //
   107 //
   106 void CUsbStateHostHandle::JustBeforeLeavingThisStateL()
   108 void CUsbStateHostHandle::JustBeforeLeavingThisStateL()
   107     {
   109     {
   108     iTooMuchPowerTimer->Cancel();
   110     iTooMuchPowerTimer->Cancel();
       
   111     iDriversNotFoundTimer->Cancel();
       
   112     
   109     iWatcher->NotifManager()->CloseAllNotifiers();
   113     iWatcher->NotifManager()->CloseAllNotifiers();
   110     }
   114     }
   111 // ---------------------------------------------------------------------------
   115 // ---------------------------------------------------------------------------
   112 // 
   116 // 
   113 // ---------------------------------------------------------------------------
   117 // ---------------------------------------------------------------------------
   222 
   226 
   223     switch (iWhat)
   227     switch (iWhat)
   224         {
   228         {
   225         case EUsbWatcherErrDriversNotFound:
   229         case EUsbWatcherErrDriversNotFound:
   226             {
   230             {
   227                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL DriversNotFound" ) );
   231             FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL DriversNotFound" ) );
   228             // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped 
   232                 
   229             iWatcher->Usb().BusDrop();
   233             iDriversNotFoundTimer->After(KTimeDriversNotFound);
   230             iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
   234             break;
   231                     EUsbOtgUnsupportedDevice, this);
   235                 
   232 
       
   233             break;
       
   234             }
   236             }
   235         case EUsbWatcherHubsNotSupported:
   237         case EUsbWatcherHubsNotSupported:
   236             {
   238             {
   237                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherHubsNotSupported" ) );
   239                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DoHandleL EUsbWatcherHubsNotSupported" ) );
   238             // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped 
   240             // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped 
   441 void CUsbStateHostHandle::DeviceAttachedL(
   443 void CUsbStateHostHandle::DeviceAttachedL(
   442         TDeviceEventInformation aDevEventInfo)
   444         TDeviceEventInformation aDevEventInfo)
   443     {
   445     {
   444         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DeviceAttachedL" ) );
   446         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DeviceAttachedL" ) );
   445 
   447 
   446     if (iTooMuchPowerTimer->IsActive())
   448     if (iTooMuchPowerTimer->IsActive() || iDriversNotFoundTimer->IsActive())
   447         {
   449         {
   448         ChangeHostStateL(EUsbStateHostAInitiate);
   450         ChangeHostStateL(EUsbStateHostAInitiate);
   449         iWatcher->DeviceAttachedL(aDevEventInfo);
   451         iWatcher->DeviceAttachedL(aDevEventInfo);
       
   452         return;
   450         }
   453         }
   451     else
   454      FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DeviceAttachedL Unexpected situation" ) );
   452         {
       
   453             FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::DeviceAttachedL Unexpected situation" ) );
       
   454         }
       
   455     }
   455     }
   456 
   456 
   457 // ---------------------------------------------------------------------------
   457 // ---------------------------------------------------------------------------
   458 // 
   458 // 
   459 // ---------------------------------------------------------------------------
   459 // ---------------------------------------------------------------------------
   584             iWatcher->Usb().BusDrop();
   584             iWatcher->Usb().BusDrop();
   585             iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
   585             iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
   586                     EUsbOtgTooMuchPowerRequired, this);
   586                     EUsbOtgTooMuchPowerRequired, this);
   587             break;
   587             break;
   588             }
   588             }
       
   589         case EDriversNotFoundTimer:
       
   590             {
       
   591             FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::TimerElapsedL - EDriversNotFoundTimer" ) );
       
   592             // Ignore any errors when calling BusDrop(). Those indicate that VBus already dropped 
       
   593             iWatcher->Usb().BusDrop();
       
   594             iWatcher->NotifManager()->ShowNotifierL(KUsbUiNotifOtgError,
       
   595                     EUsbOtgUnsupportedDevice, this);
       
   596 
       
   597             break;
       
   598             }
   589         default:
   599         default:
   590             {
   600             {
   591                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::TimerElapsedL - Unknown timer" ) );
   601                 FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostHandle::TimerElapsedL - Unknown timer" ) );
   592             Panic(EWrongTimerId);
   602             Panic(EWrongTimerId);
   593             }
   603             }