|
1 /* |
|
2 * Copyright (c) 2007-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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef USBTESTCONSOLE_H |
|
19 #define USBTESTCONSOLE_H |
|
20 |
|
21 #include <e32cmn.h> |
|
22 #include <e32base.h> |
|
23 #include <usbman.h> |
|
24 #include <e32property.h> |
|
25 |
|
26 class CConsoleBase; |
|
27 |
|
28 class CUsbTestConsoleKeys; |
|
29 |
|
30 class CServiceStateWatcher; |
|
31 class CDeviceStateWatcher; |
|
32 class CConnectionIdleWatcher; |
|
33 class CIdPinWatcher; |
|
34 class CVBusWatcher; |
|
35 class CHostEventWatcher; |
|
36 class CMessageWatcher; |
|
37 class COtgStateWatcher; |
|
38 |
|
39 class CUsbManStarter; |
|
40 class CUsbManStoper; |
|
41 class CUsbManTryStarter; |
|
42 class CUsbManTryStoper; |
|
43 class CUsbTestTimer; |
|
44 |
|
45 _LIT(KUsbTestConsoleTitle, "USB Test Console"); |
|
46 |
|
47 |
|
48 NONSHARABLE_STRUCT(XUsbTestConsoleEvent) |
|
49 { |
|
50 ~XUsbTestConsoleEvent(); |
|
51 TDblQueLink iLink; |
|
52 RBuf iEvent; |
|
53 }; |
|
54 |
|
55 |
|
56 NONSHARABLE_CLASS(CUsbTestConsole) : public CActive |
|
57 { |
|
58 friend class CUsbTestConsoleKeys; |
|
59 |
|
60 public: |
|
61 static CUsbTestConsole* NewLC(); |
|
62 ~CUsbTestConsole(); |
|
63 |
|
64 public: |
|
65 void StartL(); |
|
66 void Stop() const; |
|
67 |
|
68 RUsb& Usb(); |
|
69 CUsbTestTimer* Timer() const; |
|
70 |
|
71 public: |
|
72 enum TFdfDriverLoadingState |
|
73 { |
|
74 EUnknown, |
|
75 EDisabled, |
|
76 EEnabled |
|
77 }; |
|
78 |
|
79 enum TDeviceType |
|
80 { |
|
81 ENoDevice, |
|
82 EGenericDevice, |
|
83 ELogitechHeadset |
|
84 }; |
|
85 |
|
86 public: // Callbacks |
|
87 void SetServiceState(TUsbServiceState aServiceState); |
|
88 void SetDeviceState(TUsbDeviceState aDeviceState); |
|
89 void SetIdPin(TInt aIdPin); |
|
90 void SetConnectionIdle(TInt aConnectionIdle); |
|
91 void SetVBus(TInt aVBus); |
|
92 void SetOtgState(TInt aOtgState); |
|
93 void SetDriverLoading(TFdfDriverLoadingState aDriverLoading); |
|
94 void SetAttachedDevices(TUint aAttachedDevices); |
|
95 void SetControlSession(TBool aControl); |
|
96 void SetDeviceType(TDeviceType aDeviceType); |
|
97 |
|
98 void NotifyEvent(XUsbTestConsoleEvent* aEvent); |
|
99 |
|
100 TBool GetAutoSrpResponseState(); |
|
101 void SetAutoSrpResponseState(TBool aAutoSrpResponse); |
|
102 |
|
103 private: |
|
104 CUsbTestConsole(); |
|
105 void ConstructL(); |
|
106 void Draw(); |
|
107 |
|
108 void DoCancel(); |
|
109 void RunL(); |
|
110 void ScheduleDraw(TUint aKey); |
|
111 |
|
112 TBool iHelp; |
|
113 TBool iAutoSrpResponse; |
|
114 TDeviceType iDeviceType; |
|
115 |
|
116 private: |
|
117 CConsoleBase* iConsole; |
|
118 RUsb iUsb; |
|
119 |
|
120 CUsbTestConsoleKeys* iKeys; |
|
121 |
|
122 private: |
|
123 CServiceStateWatcher* iServiceStateWatcher; |
|
124 CDeviceStateWatcher* iDeviceStateWatcher; |
|
125 CIdPinWatcher* iIdPinWatcher; |
|
126 CConnectionIdleWatcher* iConnectionIdleWatcher; |
|
127 CVBusWatcher* iVBusWatcher; |
|
128 COtgStateWatcher* iOtgStateWatcher; |
|
129 CHostEventWatcher* iHostEventWatcher; |
|
130 CMessageWatcher* iMessageWatcher; |
|
131 CUsbTestTimer* iTimer; |
|
132 |
|
133 private: // Display variables |
|
134 TVersion iVersion; |
|
135 TBuf<9> iControlSession; |
|
136 TBuf<11> iServStatus; // Needs Trailing Space |
|
137 TBuf<11> iDevStatus; // Needs Trailing Space |
|
138 TBuf<5> iIdPin; // Needs Trailing Space |
|
139 TBuf<5> iConnectionIdle; // Needs Trailing Space |
|
140 TBuf<5> iVBus; // Needs Trailing Space |
|
141 TBuf<3> iDriverLoading; |
|
142 TBuf<3> iAttachedDevices; |
|
143 TBuf<14> iOtgState; // Needs Trailing Space |
|
144 TBuf<5> iAttachedDevice; |
|
145 TBuf<5> iSrpState; |
|
146 |
|
147 public: |
|
148 // H4 screen can have 22 lines of text on it at once |
|
149 // H4 screen can have 53 characters per line. |
|
150 static const TInt KNumCharactersOnLine = 53; |
|
151 |
|
152 private: |
|
153 static const TInt KNumEventsOnScreen = 15; |
|
154 |
|
155 private: // Event list |
|
156 TDblQue<XUsbTestConsoleEvent> iEventList; |
|
157 }; |
|
158 |
|
159 |
|
160 NONSHARABLE_CLASS(CUsbTestConsoleTextEntryBase) : public CActive |
|
161 { |
|
162 public: |
|
163 ~CUsbTestConsoleTextEntryBase(); |
|
164 |
|
165 protected: |
|
166 CUsbTestConsoleTextEntryBase(); |
|
167 void ConstructL(const TDesC& aEntryField); |
|
168 |
|
169 private: |
|
170 void DoCancel(); |
|
171 void RunL(); |
|
172 |
|
173 virtual void ConvertAndSetL() = 0; |
|
174 |
|
175 private: |
|
176 static const TInt KMaxNumOfChars = 255; |
|
177 CConsoleBase* iEntryConsole; |
|
178 protected: |
|
179 RBuf iChars; |
|
180 public: |
|
181 TDblQueLink iLink; |
|
182 }; |
|
183 |
|
184 NONSHARABLE_CLASS(CUsbTestConsoleKeys) : public CActive |
|
185 { |
|
186 public: |
|
187 static CUsbTestConsoleKeys* NewL(CUsbTestConsole& aUsb); |
|
188 ~CUsbTestConsoleKeys(); |
|
189 |
|
190 private: |
|
191 CUsbTestConsoleKeys(CUsbTestConsole& aUsb); |
|
192 void ConstructL(); |
|
193 void DoCancel(); |
|
194 void RunL(); |
|
195 XUsbTestConsoleEvent* NewConsoleEventL(); |
|
196 |
|
197 private: |
|
198 CUsbTestConsole& iTestConsole; |
|
199 |
|
200 private: // Async Utilities |
|
201 CUsbManStarter* iUsbManStarter; |
|
202 CUsbManStoper* iUsbManStoper; |
|
203 CUsbManTryStarter* iUsbManTryStarter; |
|
204 CUsbManTryStoper* iUsbManTryStoper; |
|
205 |
|
206 private: |
|
207 TDblQue<CUsbTestConsoleTextEntryBase> iEntryConsoles; |
|
208 |
|
209 private: // configured variables |
|
210 TInt iPersonalityId; |
|
211 TBool iControlSession; |
|
212 TBool iFunctionDriverLoading; |
|
213 }; |
|
214 |
|
215 |
|
216 template<typename T> |
|
217 NONSHARABLE_CLASS(CUsbTestConsoleTextEntry) : public CUsbTestConsoleTextEntryBase |
|
218 { |
|
219 public: |
|
220 static CUsbTestConsoleTextEntry* NewL(T& aValue, const TDesC& aEntryField); |
|
221 ~CUsbTestConsoleTextEntry(); |
|
222 |
|
223 private: |
|
224 CUsbTestConsoleTextEntry(T& aValue); |
|
225 void ConvertAndSetL(); |
|
226 |
|
227 private: |
|
228 T& iValue; |
|
229 }; |
|
230 |
|
231 |
|
232 |
|
233 NONSHARABLE_CLASS(CEventNotifier) : public CActive |
|
234 { |
|
235 protected: |
|
236 CEventNotifier(TInt aPriority); |
|
237 XUsbTestConsoleEvent* NewConsoleEventL(); |
|
238 virtual void DoRunL(XUsbTestConsoleEvent* aEvent) = 0; |
|
239 private: |
|
240 void RunL(); |
|
241 }; |
|
242 |
|
243 |
|
244 |
|
245 NONSHARABLE_CLASS(CServiceStateWatcher) : public CEventNotifier |
|
246 { |
|
247 public: |
|
248 static CServiceStateWatcher* NewL(CUsbTestConsole& aUsb); |
|
249 ~CServiceStateWatcher(); |
|
250 |
|
251 private: |
|
252 CServiceStateWatcher(CUsbTestConsole& aUsb); |
|
253 void ConstructL(); |
|
254 |
|
255 void DoCancel(); |
|
256 void DoRunL(XUsbTestConsoleEvent* aEvent); |
|
257 |
|
258 private: |
|
259 CUsbTestConsole& iTestConsole; |
|
260 TUsbServiceState iServiceState; |
|
261 }; |
|
262 |
|
263 |
|
264 NONSHARABLE_CLASS(CDeviceStateWatcher) : public CEventNotifier |
|
265 { |
|
266 public: |
|
267 static CDeviceStateWatcher* NewL(CUsbTestConsole& aUsb); |
|
268 ~CDeviceStateWatcher(); |
|
269 |
|
270 private: |
|
271 CDeviceStateWatcher(CUsbTestConsole& aUsb); |
|
272 void ConstructL(); |
|
273 |
|
274 void DoCancel(); |
|
275 void DoRunL(XUsbTestConsoleEvent* aEvent); |
|
276 |
|
277 private: |
|
278 CUsbTestConsole& iTestConsole; |
|
279 TUsbDeviceState iDeviceState; |
|
280 }; |
|
281 |
|
282 |
|
283 NONSHARABLE_CLASS(CIdPinWatcher) : public CEventNotifier |
|
284 { |
|
285 public: |
|
286 static CIdPinWatcher* NewL(CUsbTestConsole& aUsb); |
|
287 ~CIdPinWatcher(); |
|
288 |
|
289 private: |
|
290 CIdPinWatcher(CUsbTestConsole& aUsb); |
|
291 void ConstructL(); |
|
292 |
|
293 void DoCancel(); |
|
294 void DoRunL(XUsbTestConsoleEvent* aEvent); |
|
295 |
|
296 private: |
|
297 CUsbTestConsole& iTestConsole; |
|
298 RProperty iIdPinProp; |
|
299 }; |
|
300 |
|
301 NONSHARABLE_CLASS(CConnectionIdleWatcher) : public CEventNotifier |
|
302 { |
|
303 public: |
|
304 static CConnectionIdleWatcher* NewL(CUsbTestConsole& aUsb); |
|
305 ~CConnectionIdleWatcher(); |
|
306 |
|
307 private: |
|
308 CConnectionIdleWatcher(CUsbTestConsole& aUsb); |
|
309 void ConstructL(); |
|
310 |
|
311 void DoCancel(); |
|
312 void DoRunL(XUsbTestConsoleEvent* aEvent); |
|
313 |
|
314 private: |
|
315 CUsbTestConsole& iTestConsole; |
|
316 RProperty iConnectionIdleProp; |
|
317 }; |
|
318 |
|
319 |
|
320 NONSHARABLE_CLASS(CVBusWatcher) : public CEventNotifier |
|
321 { |
|
322 public: |
|
323 static CVBusWatcher* NewL(CUsbTestConsole& aUsb); |
|
324 ~CVBusWatcher(); |
|
325 |
|
326 private: |
|
327 CVBusWatcher(CUsbTestConsole& aUsb); |
|
328 void ConstructL(); |
|
329 |
|
330 void DoCancel(); |
|
331 void DoRunL(XUsbTestConsoleEvent* aEvent); |
|
332 |
|
333 private: |
|
334 CUsbTestConsole& iTestConsole; |
|
335 RProperty iVBusProp; |
|
336 }; |
|
337 |
|
338 NONSHARABLE_CLASS(COtgStateWatcher) : public CEventNotifier |
|
339 { |
|
340 public: |
|
341 static COtgStateWatcher* NewL(CUsbTestConsole& aUsb); |
|
342 ~COtgStateWatcher(); |
|
343 |
|
344 private: |
|
345 COtgStateWatcher(CUsbTestConsole& aUsb); |
|
346 void ConstructL(); |
|
347 |
|
348 void DoCancel(); |
|
349 void DoRunL(XUsbTestConsoleEvent* aEvent); |
|
350 |
|
351 private: |
|
352 CUsbTestConsole& iTestConsole; |
|
353 RProperty iOtgStateProp; |
|
354 }; |
|
355 |
|
356 |
|
357 NONSHARABLE_CLASS(CHostEventWatcher) : public CEventNotifier |
|
358 { |
|
359 public: |
|
360 static CHostEventWatcher* NewL(CUsbTestConsole& aUsb); |
|
361 ~CHostEventWatcher(); |
|
362 |
|
363 private: |
|
364 CHostEventWatcher(CUsbTestConsole& aUsb); |
|
365 void ConstructL(); |
|
366 |
|
367 void DoCancel(); |
|
368 void DoRunL(XUsbTestConsoleEvent* aEvent); |
|
369 |
|
370 private: |
|
371 CUsbTestConsole& iTestConsole; |
|
372 TDeviceEventInformation iDeviceInfo; |
|
373 RArray<TUint> iAttachedDevices; |
|
374 }; |
|
375 |
|
376 |
|
377 NONSHARABLE_CLASS(CMessageWatcher) : public CEventNotifier |
|
378 { |
|
379 public: |
|
380 static CMessageWatcher* NewL(CUsbTestConsole& aUsb); |
|
381 ~CMessageWatcher(); |
|
382 |
|
383 private: |
|
384 CMessageWatcher(CUsbTestConsole& aUsb); |
|
385 void ConstructL(); |
|
386 |
|
387 void DoCancel(); |
|
388 void DoRunL(XUsbTestConsoleEvent* aEvent); |
|
389 |
|
390 private: |
|
391 CUsbTestConsole& iTestConsole; |
|
392 TInt iMessage; |
|
393 }; |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 NONSHARABLE_CLASS(CUsbManStarter) : public CEventNotifier |
|
402 { |
|
403 public: |
|
404 static void NewL(CUsbManStarter*& aSelf, CUsbTestConsole& aUsb); |
|
405 void DestroyL(); |
|
406 ~CUsbManStarter(); |
|
407 |
|
408 private: |
|
409 CUsbManStarter(CUsbManStarter*& aSelf, CUsbTestConsole& aUsb); |
|
410 void ConstructL(); |
|
411 |
|
412 void DoCancel(); |
|
413 void DoRunL(XUsbTestConsoleEvent* aEvent); |
|
414 |
|
415 private: |
|
416 CUsbManStarter*& iSelf; |
|
417 CUsbTestConsole& iTestConsole; |
|
418 }; |
|
419 |
|
420 |
|
421 NONSHARABLE_CLASS(CUsbManStoper) : public CEventNotifier |
|
422 { |
|
423 public: |
|
424 static void NewL(CUsbManStoper*& aSelf, CUsbTestConsole& aUsb); |
|
425 void DestroyL(); |
|
426 ~CUsbManStoper(); |
|
427 |
|
428 private: |
|
429 CUsbManStoper(CUsbManStoper*& aSelf, CUsbTestConsole& aUsb); |
|
430 void ConstructL(); |
|
431 |
|
432 void DoCancel(); |
|
433 void DoRunL(XUsbTestConsoleEvent* aEvent); |
|
434 |
|
435 private: |
|
436 CUsbManStoper*& iSelf; |
|
437 CUsbTestConsole& iTestConsole; |
|
438 }; |
|
439 |
|
440 |
|
441 |
|
442 NONSHARABLE_CLASS(CUsbManTryStarter) : public CEventNotifier |
|
443 { |
|
444 public: |
|
445 static void NewL(CUsbManTryStarter*& aSelf, CUsbTestConsole& aUsb, TInt aPersonalityId); |
|
446 void DestroyL(); |
|
447 ~CUsbManTryStarter(); |
|
448 |
|
449 private: |
|
450 CUsbManTryStarter(CUsbManTryStarter*& aSelf, CUsbTestConsole& aUsb, TInt aPersonalityId); |
|
451 void ConstructL(); |
|
452 |
|
453 void DoCancel(); |
|
454 void DoRunL(XUsbTestConsoleEvent* aEvent); |
|
455 |
|
456 private: |
|
457 CUsbManTryStarter*& iSelf; |
|
458 CUsbTestConsole& iTestConsole; |
|
459 TInt iPersonalityId; |
|
460 }; |
|
461 |
|
462 |
|
463 NONSHARABLE_CLASS(CUsbManTryStoper) : public CEventNotifier |
|
464 { |
|
465 public: |
|
466 static void NewL(CUsbManTryStoper*& aSelf, CUsbTestConsole& aUsb); |
|
467 void DestroyL(); |
|
468 ~CUsbManTryStoper(); |
|
469 |
|
470 private: |
|
471 CUsbManTryStoper(CUsbManTryStoper*& aSelf, CUsbTestConsole& aUsb); |
|
472 void ConstructL(); |
|
473 |
|
474 void DoCancel(); |
|
475 void DoRunL(XUsbTestConsoleEvent* aEvent); |
|
476 |
|
477 private: |
|
478 CUsbManTryStoper*& iSelf; |
|
479 CUsbTestConsole& iTestConsole; |
|
480 }; |
|
481 |
|
482 NONSHARABLE_CLASS(CUsbTestTimer) : public CTimer |
|
483 { |
|
484 public: |
|
485 static CUsbTestTimer* NewL(CUsbTestConsole& aUsb); |
|
486 ~CUsbTestTimer(); |
|
487 void Start(TTimeIntervalMicroSeconds32 aTime); |
|
488 |
|
489 private: |
|
490 CUsbTestTimer(CUsbTestConsole& aUsb); |
|
491 void ConstructL(); |
|
492 void DoCancel(); |
|
493 void RunL(); |
|
494 |
|
495 private: |
|
496 TTimeIntervalMicroSeconds32 iTime; |
|
497 CUsbTestConsole& iTestConsole; |
|
498 }; |
|
499 #endif // USBTESTCONSOLE_H |