|
1 /* |
|
2 * Copyright (c) 2007 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: Takes control over the EP0 vendor specific messages, and process requests |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CUSBDEVCON_H |
|
20 #define CUSBDEVCON_H |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 #include <d32usbc.h> |
|
25 #include <usbman.h> |
|
26 #include <usbwatcher.h> |
|
27 |
|
28 class CUsbStateWatcher; // watches device's USB states |
|
29 class CStateMachine; // state-machine |
|
30 class CRequestsHandler; // contains actual requests handlers |
|
31 |
|
32 static const TUint KSetupPacketLength = 8; // 8 bytes, always |
|
33 static const TUint KInactiveTimeForShutDown = 10000000; // microseconds |
|
34 |
|
35 /** |
|
36 * USB Device Controller |
|
37 * Contains all needed subclasses, to |
|
38 * take control over EP0 vendor specific messages |
|
39 * and processing requests |
|
40 * |
|
41 * |
|
42 * @lib usbdevcon.lib |
|
43 * @since S60 v.5.0 |
|
44 */ |
|
45 |
|
46 class CUsbDevCon : public CActive |
|
47 { |
|
48 |
|
49 public: |
|
50 |
|
51 /** |
|
52 * Two-phased constructor. |
|
53 * |
|
54 * @since S60 v.5.0 |
|
55 * @return Constructed instance |
|
56 */ |
|
57 static CUsbDevCon* NewL(); |
|
58 |
|
59 /** |
|
60 * Two-phased constructor. |
|
61 * |
|
62 * @since S60 v.5.0 |
|
63 * @return Constructed instance |
|
64 */ |
|
65 static CUsbDevCon* NewLC(); |
|
66 |
|
67 /** |
|
68 * Destructor. |
|
69 * |
|
70 * @since S60 v.5.0 |
|
71 */ |
|
72 virtual ~CUsbDevCon(); |
|
73 |
|
74 /** |
|
75 * Performs action needed by specific usb state |
|
76 * |
|
77 * @since S60 v.5.0 |
|
78 * @param aUsbState USB state |
|
79 */ |
|
80 void ActAccordinglyToUsbStateL(TUsbcDeviceState aUsbState); |
|
81 |
|
82 private: |
|
83 |
|
84 /** |
|
85 * Default construction |
|
86 * |
|
87 * @since S60 v.5.0 |
|
88 */ |
|
89 CUsbDevCon(); |
|
90 |
|
91 /** |
|
92 * Two-phased constructor. |
|
93 * |
|
94 * @since S60 v.5.0 |
|
95 */ |
|
96 void ConstructL(); |
|
97 |
|
98 /** |
|
99 * Take needed actions on starting services |
|
100 * |
|
101 * @since S60 v.5.0 |
|
102 */ |
|
103 void StartL(); |
|
104 |
|
105 /** |
|
106 * Take needed actions on stopping services |
|
107 * |
|
108 * @since S60 v.5.0 |
|
109 */ |
|
110 void StopL(); |
|
111 |
|
112 /** |
|
113 * Take needed actions on resuming services |
|
114 * |
|
115 * @since S60 v.5.0 |
|
116 */ |
|
117 void ResumeL(); |
|
118 |
|
119 // from CActive |
|
120 |
|
121 /** |
|
122 * From CActive |
|
123 * |
|
124 */ |
|
125 void RunL(); |
|
126 |
|
127 /** |
|
128 * From CActive |
|
129 * |
|
130 */ |
|
131 void DoCancel(); |
|
132 |
|
133 /** |
|
134 * From CActive. |
|
135 * |
|
136 */ |
|
137 TInt RunError( TInt /*aError*/ ); |
|
138 |
|
139 private: // data |
|
140 |
|
141 /** |
|
142 * USB state watcher |
|
143 * Own |
|
144 */ |
|
145 CUsbStateWatcher* iUsbStateWatcher; |
|
146 |
|
147 /** |
|
148 * CStateMachine |
|
149 * Own |
|
150 */ |
|
151 CStateMachine* iStateMachine; |
|
152 |
|
153 /** |
|
154 * Requests handler |
|
155 * Own |
|
156 */ |
|
157 CRequestsHandler* iRequestsHandler; |
|
158 |
|
159 /** |
|
160 * USB client |
|
161 * Need to take control over EP0 |
|
162 * Also reference to it will be provided to handlers |
|
163 */ |
|
164 RDevUsbcClient iLdd; |
|
165 |
|
166 /** |
|
167 * USB Watcher |
|
168 * Need to handle some requests (like GetPersonalities) |
|
169 * Reference to it will be provided to handlers |
|
170 */ |
|
171 RUsbWatcher iUsbWatcher; |
|
172 |
|
173 /** |
|
174 * USB Manager |
|
175 * Need to handle some requests (like SetPersonality) |
|
176 * Reference to it will be provided to handlers |
|
177 */ |
|
178 RUsb iUsbManager; |
|
179 |
|
180 /** |
|
181 * Previous USB state |
|
182 */ |
|
183 TInt iPrevUsbState; |
|
184 |
|
185 /** |
|
186 * Shuts down if USB inactive for specified period of time |
|
187 */ |
|
188 RTimer iShutdownTimer; |
|
189 |
|
190 }; |
|
191 |
|
192 #endif // USBDEVCON_H |