|
1 /* |
|
2 * Copyright (c) 2008 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 #include "cusbstatehostdelaynotattachedhandle.h" |
|
19 |
|
20 #include "errors.h" |
|
21 #include "debug.h" |
|
22 #include "panic.h" |
|
23 |
|
24 // --------------------------------------------------------------------------- |
|
25 // |
|
26 // --------------------------------------------------------------------------- |
|
27 // |
|
28 CUsbStateHostDelayNotAttachedHandle::CUsbStateHostDelayNotAttachedHandle( |
|
29 CUsbOtgWatcher& aWatcher) : |
|
30 CUsbStateHostDelayHandle(aWatcher) |
|
31 { |
|
32 } |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 CUsbStateHostDelayNotAttachedHandle* CUsbStateHostDelayNotAttachedHandle::NewL( |
|
39 CUsbOtgWatcher& aWatcher) |
|
40 { |
|
41 LOG_FUNC |
|
42 |
|
43 CUsbStateHostDelayNotAttachedHandle* self = |
|
44 new (ELeave) CUsbStateHostDelayNotAttachedHandle(aWatcher); |
|
45 CleanupStack::PushL(self); |
|
46 self->ConstructL(); |
|
47 CleanupStack::Pop(self); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 void CUsbStateHostDelayNotAttachedHandle::ConstructL() |
|
56 { |
|
57 LOG_FUNC |
|
58 |
|
59 CUsbStateHostDelayHandle::ConstructL(); |
|
60 |
|
61 iTooMuchPowerTimer = CUsbTimer::NewL(*this, ETooMuchPowerRequiredTimer); |
|
62 |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 CUsbStateHostDelayNotAttachedHandle::~CUsbStateHostDelayNotAttachedHandle() |
|
70 { |
|
71 LOG_FUNC |
|
72 |
|
73 delete iTooMuchPowerTimer; |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 TUsbStateIds CUsbStateHostDelayNotAttachedHandle::Id() |
|
81 { |
|
82 return EUsbStateHostDelayNotAttachedHandle; |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 void CUsbStateHostDelayNotAttachedHandle::JustBeforeLeavingThisStateL() |
|
90 { |
|
91 LOG_FUNC |
|
92 |
|
93 iTooMuchPowerTimer->Cancel(); |
|
94 |
|
95 // do general things |
|
96 CUsbStateHostDelayHandle::JustBeforeLeavingThisStateL(); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 void CUsbStateHostDelayNotAttachedHandle::DoHandleL() |
|
104 { |
|
105 LOG_FUNC |
|
106 LOG1( "iWhat = %d" , iWhat); |
|
107 |
|
108 switch (iWhat) |
|
109 { |
|
110 case EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration: |
|
111 { |
|
112 LOG("EUsbWatcherErrDeviceRequiresTooMuchPowerOnEnumeration" ); |
|
113 |
|
114 iTooMuchPowerTimer->After(KTimeTooMuchPowerRequired); |
|
115 break; |
|
116 } |
|
117 |
|
118 default: |
|
119 { |
|
120 LOG1("Unexpected request id = %d", iWhat); |
|
121 PANIC( EUnexpectedSituationToHandle); |
|
122 break; |
|
123 } |
|
124 } |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 void CUsbStateHostDelayNotAttachedHandle::AIdleL() |
|
132 { |
|
133 LOG_FUNC |
|
134 |
|
135 // Exit on AIdle, due to Detachment not comes, |
|
136 // because no corresponding attachment with err == KErrNone |
|
137 ChangeHostStateL( EUsbStateHostAInitiate); |
|
138 |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 void CUsbStateHostDelayNotAttachedHandle::DeviceDetachedL( |
|
146 TDeviceEventInformation) |
|
147 { |
|
148 LOG_FUNC |
|
149 PANIC( EDeviceDetachedNotExpected); |
|
150 |
|
151 } |
|
152 |
|
153 // From TimerObserver |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 void CUsbStateHostDelayNotAttachedHandle::TimerElapsedL(TUsbTimerId aTimerId) |
|
159 { |
|
160 LOG_FUNC |
|
161 switch (aTimerId) |
|
162 { |
|
163 case ETooMuchPowerRequiredTimer: |
|
164 { |
|
165 LOG("ETooMuchPowerRequiredTimer" ); |
|
166 HandleL(EUsbWatcherErrUnsupportedDevice, |
|
167 EUsbStateHostHandleDropping); |
|
168 break; |
|
169 } |
|
170 default: |
|
171 { |
|
172 LOG1("Unknown timer id = %d", aTimerId ); |
|
173 PANIC( EWrongTimerId); |
|
174 } |
|
175 } |
|
176 } |