usbengines/usbotgwatcher/src/cusbstatehostahost.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 <e32base.h>
       
    20 #include <UsbWatcherInternalPSKeys.h>
       
    21 
       
    22 #include "cusbstatehostahost.h"
       
    23 #include "cusbnotifmanager.h"
       
    24 
       
    25 #ifndef STIF
       
    26 #include "cusbtimer.h"
       
    27 #else
       
    28 #include "mockcusbtimer.h"
       
    29 #endif
       
    30 #include "definitions.h"
       
    31 
       
    32 #include "errors.h"
       
    33 
       
    34 #include "debug.h"
       
    35 #include "panic.h"
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // 
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 CUsbStateHostAHost::CUsbStateHostAHost(CUsbOtgWatcher* aWatcher) :
       
    42     CUsbStateHostABase(aWatcher)
       
    43     {
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // 
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 void CUsbStateHostAHost::ConstructL()
       
    51     {
       
    52         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::ConstructL" ) );
       
    53 
       
    54     CUsbStateHostABase::ConstructL();
       
    55 
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // 
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CUsbStateHostAHost* CUsbStateHostAHost::NewL(CUsbOtgWatcher* aWatcher)
       
    63     {
       
    64         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::NewL" ) );
       
    65 
       
    66     CUsbStateHostAHost* self = new (ELeave) CUsbStateHostAHost(aWatcher);
       
    67     CleanupStack::PushL(self);
       
    68     self->ConstructL();
       
    69     CleanupStack::Pop(self);
       
    70     return self;
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // 
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 CUsbStateHostAHost::~CUsbStateHostAHost()
       
    78     {
       
    79         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::~CUsbStateHostAHost" ) );
       
    80 
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // 
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 TUsbStateIds CUsbStateHostAHost::Id()
       
    88     {
       
    89         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::Id" ) );
       
    90 
       
    91     return EUsbStateHostAHost;
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // 
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 void CUsbStateHostAHost::JustAdvancedToThisStateL()
       
    99     {
       
   100         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::JustAdvancedToThisStateL" ) );
       
   101     
       
   102     User::LeaveIfError( RProperty::Set( KPSUidUsbWatcher,
       
   103                 KUsbWatcherIsPeripheralConnected,
       
   104                 KUsbWatcherPeripheralIsConnected ) );
       
   105     
       
   106     iWatcher->NotifManager()->ShowIndicatorL(ETrue);
       
   107     
       
   108     iWatcher->PrintStateToLog();
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // 
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 void CUsbStateHostAHost::JustBeforeLeavingThisStateL()
       
   116     {
       
   117         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::JustBeforeLeavingThisStateL" ) );
       
   118         
       
   119         User::LeaveIfError( RProperty::Set( KPSUidUsbWatcher,
       
   120                     KUsbWatcherIsPeripheralConnected,
       
   121                     KUsbWatcherPeripheralIsNotConnected ) );
       
   122         
       
   123         iWatcher->NotifManager()->ShowIndicatorL(EFalse);
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // 
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 void CUsbStateHostAHost::AHostL()
       
   131     {
       
   132         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::AHostL" ) );
       
   133     // do nothing
       
   134     }
       
   135 
       
   136 // ---------------------------------------------------------------------------
       
   137 // 
       
   138 // ---------------------------------------------------------------------------
       
   139 //
       
   140 void CUsbStateHostAHost::APeripheralL()
       
   141     {
       
   142         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::AHostL" ) );
       
   143     ChangeHostStateL(EUsbStateHostAPeripheral);
       
   144     }
       
   145 
       
   146 // ---------------------------------------------------------------------------
       
   147 // 
       
   148 // ---------------------------------------------------------------------------
       
   149 //
       
   150 void CUsbStateHostAHost::DeviceDetachedL(TDeviceEventInformation)
       
   151     {
       
   152         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::DeviceDetachedL" ) );
       
   153     ChangeHostStateL(EUsbStateHostAInitiate);
       
   154     }
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // 
       
   158 // ---------------------------------------------------------------------------
       
   159 //
       
   160 void CUsbStateHostAHost::BadHubPositionL()
       
   161     {
       
   162         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::BadHubPositionL" ) );
       
   163     Panic(EBadHubPositionEventNotExpected);
       
   164     }