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