|
1 /** |
|
2 * Copyright (c) 1997-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 * Adheres to the UsbMan USB Class Controller API. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 /** |
|
23 @file |
|
24 */ |
|
25 |
|
26 #ifndef CUSBDUMMYCLASSCONTROLLER_H__ |
|
27 #define CUSBDUMMYCLASSCONTROLLER_H__ |
|
28 |
|
29 #include <cusbclasscontrollerbase.h> |
|
30 |
|
31 class CIniFile; |
|
32 |
|
33 NONSHARABLE_CLASS(CUsbDummyClassController) : public CUsbClassControllerBase |
|
34 /** |
|
35 * A test utility which, depending on the contents of c:\\dummy.ini, displays |
|
36 * different start up and shutdown behaviour. |
|
37 * The USB manager can instantiate a number of instances of this class |
|
38 * controller. Each one reads its behaviour from a section of dummy.ini. The |
|
39 * options are, for each of startup and shutdown: (a) synchronous or |
|
40 * asynchronous, (b) completing after a variable amount of time, or |
|
41 * immediately, or never, and (c) completing with a given error code. |
|
42 * NB This class controller is a dummy- it does not communicate with a class |
|
43 * implementation. It registers no USB interfaces. |
|
44 * Note that for each of startup and shutdown, Type, Time and Error *must* be |
|
45 * filled in, even if one or more are irrelevant. They are applied in the |
|
46 * following order: Type, Time, Error. That is, if Type is 'never', the CC |
|
47 * never completes, but it does this asynchronously, i.e. without blocking the |
|
48 * CC's (=USBMAN's) thread. If Time is '0', it completes after a synchronous |
|
49 * or asynchronous wait for 0 microseconds (as determined by the Type). |
|
50 * Note that the ini file is re-read whenever Start or Stop is requested. |
|
51 * Otherwise, a CC which is set to not Stop would stop us being able to Stop, |
|
52 * ever, or shut down USBMAN, which would make wrapping up the test framework |
|
53 * impossible. |
|
54 * Note that we inherit the TUsbServiceState iState member of |
|
55 * CUsbClassControllerBase. We only use this to mark whether we're currently |
|
56 * starting or stopping, or doing nothing. Requests from the device may come |
|
57 * in at any point- the only proviso is that we are always Cancelled before |
|
58 * another Start or Stop comes in first (this is enforced by us through |
|
59 * iReportStatus). It happens that it's useless to assert our iState in Start |
|
60 * and Stop. |
|
61 */ |
|
62 { |
|
63 public: |
|
64 static CUsbDummyClassController* NewL(MUsbClassControllerNotify& aOwner, TUint aIndex); |
|
65 static CUsbDummyClassController* NewL(MUsbClassControllerNotify& aOwner, TUint aIndex, TInt aPriority); |
|
66 ~CUsbDummyClassController(); |
|
67 |
|
68 private: |
|
69 CUsbDummyClassController(MUsbClassControllerNotify& aOwner, TUint aIndex); |
|
70 CUsbDummyClassController(MUsbClassControllerNotify& aOwner,TUint aIndex, TInt aPriority); |
|
71 void ConstructL(); |
|
72 |
|
73 private: // from CActive |
|
74 void RunL(); |
|
75 void DoCancel(); |
|
76 TInt RunError(TInt aError); |
|
77 |
|
78 private: // from CUsbClassControllerBase |
|
79 void Start(TRequestStatus& aStatus); |
|
80 void Stop(TRequestStatus& aStatus); |
|
81 void GetDescriptorInfo(TUsbDescriptor& aDescriptorInfo) const; |
|
82 |
|
83 private: |
|
84 enum TSynchronicity |
|
85 { |
|
86 EUndefined = 0, |
|
87 ESynchronous, |
|
88 EAsynchronous, |
|
89 ENever, |
|
90 }; |
|
91 |
|
92 NONSHARABLE_STRUCT( TBehaviour ) |
|
93 /** |
|
94 * Defines the behaviour for a startup or a shutdown. |
|
95 */ |
|
96 { |
|
97 TSynchronicity iSynchronicity; |
|
98 TTimeIntervalMicroSeconds32 iDelay; |
|
99 TInt iErrorCode; |
|
100 }; |
|
101 |
|
102 private: // utility |
|
103 void GetConfig(); |
|
104 void GetBehaviour(CIniFile& aInifile, |
|
105 const TDesC& aSection, |
|
106 TBehaviour& aBehaviour); |
|
107 void DoGetConfigL(); |
|
108 |
|
109 private: // unowned |
|
110 TRequestStatus* iReportStatus; |
|
111 |
|
112 private: // owned |
|
113 RTimer iTimer; |
|
114 // The index of this instance (USBMAN may have more than one, and this is |
|
115 // used to get the required behaviour for this instance from the ini |
|
116 // file). |
|
117 const TUint iIndex; |
|
118 |
|
119 TBehaviour iStartupBehaviour; |
|
120 TBehaviour iShutdownBehaviour; |
|
121 }; |
|
122 |
|
123 #endif // CUSBDUMMYCLASSCONTROLLER_H__ |