usbengines/usbotgwatcher/src/cusbstatehostahost.cpp
branchRCL_3
changeset 20 a15c582fbf97
parent 1 705ec7b86991
child 21 ff9df6630274
equal deleted inserted replaced
13:7068aba64af5 20:a15c582fbf97
     1 /*
     1 /*
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     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  *
     8  *
    16 */
     9  * Initial Contributors:
    17 
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:  Implementation
       
    15  *
       
    16  */
    18 
    17 
    19 #include <e32base.h>
    18 #include <e32base.h>
    20 #include <UsbWatcherInternalPSKeys.h>
    19 #include <UsbWatcherInternalPSKeys.h>
    21 
    20 
    22 #include "cusbstatehostahost.h"
    21 #include "cusbstatehostahost.h"
    23 #include "cusbnotifmanager.h"
    22 #include "cusbnotifmanager.h"
    24 
    23 
    25 #ifndef STIF
       
    26 #include "cusbtimer.h"
       
    27 #else
       
    28 #include "mockcusbtimer.h"
       
    29 #endif
       
    30 #include "definitions.h"
    24 #include "definitions.h"
    31 
       
    32 #include "errors.h"
    25 #include "errors.h"
    33 
       
    34 #include "debug.h"
    26 #include "debug.h"
    35 #include "panic.h"
    27 #include "panic.h"
    36 
    28 
    37 // ---------------------------------------------------------------------------
    29 // ---------------------------------------------------------------------------
    38 // 
    30 // 
    39 // ---------------------------------------------------------------------------
    31 // ---------------------------------------------------------------------------
    40 //
    32 //
    41 CUsbStateHostAHost::CUsbStateHostAHost(CUsbOtgWatcher* aWatcher) :
    33 CUsbStateHostAHost::CUsbStateHostAHost(CUsbOtgWatcher& aWatcher) :
    42     CUsbStateHostABase(aWatcher)
    34     CUsbStateHostABase(aWatcher)
    43     {
    35     {
    44     }
    36     }
    45 
    37 
    46 // ---------------------------------------------------------------------------
    38 // ---------------------------------------------------------------------------
    47 // 
    39 // 
    48 // ---------------------------------------------------------------------------
    40 // ---------------------------------------------------------------------------
    49 //
    41 //
    50 void CUsbStateHostAHost::ConstructL()
    42 void CUsbStateHostAHost::ConstructL()
    51     {
    43     {
    52         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::ConstructL" ) );
    44     LOG_FUNC
    53 
    45 
    54     CUsbStateHostABase::ConstructL();
    46     CUsbStateHostABase::ConstructL();
    55 
    47 
    56     }
    48     }
    57 
    49 
    58 // ---------------------------------------------------------------------------
    50 // ---------------------------------------------------------------------------
    59 // 
    51 // 
    60 // ---------------------------------------------------------------------------
    52 // ---------------------------------------------------------------------------
    61 //
    53 //
    62 CUsbStateHostAHost* CUsbStateHostAHost::NewL(CUsbOtgWatcher* aWatcher)
    54 CUsbStateHostAHost* CUsbStateHostAHost::NewL(CUsbOtgWatcher& aWatcher)
    63     {
    55     {
    64         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::NewL" ) );
    56     LOG_FUNC
    65 
    57 
    66     CUsbStateHostAHost* self = new (ELeave) CUsbStateHostAHost(aWatcher);
    58     CUsbStateHostAHost* self = new (ELeave) CUsbStateHostAHost(aWatcher);
    67     CleanupStack::PushL(self);
    59     CleanupStack::PushL(self);
    68     self->ConstructL();
    60     self->ConstructL();
    69     CleanupStack::Pop(self);
    61     CleanupStack::Pop(self);
    74 // 
    66 // 
    75 // ---------------------------------------------------------------------------
    67 // ---------------------------------------------------------------------------
    76 //
    68 //
    77 CUsbStateHostAHost::~CUsbStateHostAHost()
    69 CUsbStateHostAHost::~CUsbStateHostAHost()
    78     {
    70     {
    79         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::~CUsbStateHostAHost" ) );
    71     LOG_FUNC
    80 
    72 
    81     }
    73     }
    82 
    74 
    83 // ---------------------------------------------------------------------------
    75 // ---------------------------------------------------------------------------
    84 // 
    76 // 
    85 // ---------------------------------------------------------------------------
    77 // ---------------------------------------------------------------------------
    86 //
    78 //
    87 TUsbStateIds CUsbStateHostAHost::Id()
    79 TUsbStateIds CUsbStateHostAHost::Id()
    88     {
    80     {
    89         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::Id" ) );
       
    90 
       
    91     return EUsbStateHostAHost;
    81     return EUsbStateHostAHost;
    92     }
    82     }
    93 
    83 
    94 // ---------------------------------------------------------------------------
    84 // ---------------------------------------------------------------------------
    95 // 
    85 // 
    96 // ---------------------------------------------------------------------------
    86 // ---------------------------------------------------------------------------
    97 //
    87 //
    98 void CUsbStateHostAHost::JustAdvancedToThisStateL()
    88 void CUsbStateHostAHost::JustAdvancedToThisStateL()
    99     {
    89     {
   100         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::JustAdvancedToThisStateL" ) );
    90     LOG_FUNC
   101     
    91 
   102     User::LeaveIfError( RProperty::Set( KPSUidUsbWatcher,
    92     // do general things 
   103                 KUsbWatcherIsPeripheralConnected,
    93     CUsbStateHostABase::JustAdvancedToThisStateL();
   104                 KUsbWatcherPeripheralIsConnected ) );
    94 
   105     
    95     User::LeaveIfError(RProperty::Set(KPSUidUsbWatcher,
   106     iWatcher->PrintStateToLog();
    96             KUsbWatcherIsPeripheralConnected,
       
    97             KUsbWatcherPeripheralIsConnected));
       
    98 
   107     }
    99     }
   108 
   100 
   109 // ---------------------------------------------------------------------------
   101 // ---------------------------------------------------------------------------
   110 // 
   102 // 
   111 // ---------------------------------------------------------------------------
   103 // ---------------------------------------------------------------------------
   112 //
   104 //
   113 void CUsbStateHostAHost::JustBeforeLeavingThisStateL()
   105 void CUsbStateHostAHost::JustBeforeLeavingThisStateL()
   114     {
   106     {
   115         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::JustBeforeLeavingThisStateL" ) );
   107     LOG_FUNC
   116         
       
   117         User::LeaveIfError( RProperty::Set( KPSUidUsbWatcher,
       
   118                     KUsbWatcherIsPeripheralConnected,
       
   119                     KUsbWatcherPeripheralIsNotConnected ) );
       
   120     }
       
   121 
   108 
   122 // ---------------------------------------------------------------------------
   109     User::LeaveIfError(RProperty::Set(KPSUidUsbWatcher,
   123 // 
   110             KUsbWatcherIsPeripheralConnected,
   124 // ---------------------------------------------------------------------------
   111             KUsbWatcherPeripheralIsNotConnected));
   125 //
       
   126 void CUsbStateHostAHost::AHostL()
       
   127     {
       
   128         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::AHostL" ) );
       
   129     // do nothing
       
   130     }
       
   131 
   112 
   132 // ---------------------------------------------------------------------------
   113     // do general things 
   133 // 
   114     CUsbStateHostABase::JustBeforeLeavingThisStateL();
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 void CUsbStateHostAHost::APeripheralL()
       
   137     {
       
   138         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostABase::AHostL" ) );
       
   139     ChangeHostStateL(EUsbStateHostAPeripheral);
       
   140     }
   115     }
   141 
   116 
   142 // ---------------------------------------------------------------------------
   117 // ---------------------------------------------------------------------------
   143 // 
   118 // 
   144 // ---------------------------------------------------------------------------
   119 // ---------------------------------------------------------------------------
   145 //
   120 //
   146 void CUsbStateHostAHost::DeviceDetachedL(TDeviceEventInformation)
   121 void CUsbStateHostAHost::DeviceDetachedL(TDeviceEventInformation)
   147     {
   122     {
   148         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::DeviceDetachedL" ) );
   123     LOG_FUNC
   149     ChangeHostStateL(EUsbStateHostAInitiate);
   124     ChangeHostStateL( EUsbStateHostAInitiate);
   150     }
   125     }
   151 
   126 
   152 // ---------------------------------------------------------------------------
   127 // ---------------------------------------------------------------------------
   153 // 
   128 // 
   154 // ---------------------------------------------------------------------------
   129 // ---------------------------------------------------------------------------
   155 //
   130 //
   156 void CUsbStateHostAHost::BadHubPositionL()
   131 void CUsbStateHostAHost::BadHubPositionL()
   157     {
   132     {
   158         FLOG( _L( "[USBOTGWATCHER]\tCUsbStateHostAHost::BadHubPositionL" ) );
   133     LOG_FUNC
   159     Panic(EBadHubPositionEventNotExpected);
   134     Panic( EBadHubPositionEventNotExpected);
   160     }
   135     }