|
1 /* |
|
2 * Copyright (c) 1997-2010 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 * Implements part of UsbMan USB Class Framework. |
|
16 * |
|
17 */ |
|
18 |
|
19 /** |
|
20 @file |
|
21 */ |
|
22 |
|
23 #include <usb_std.h> |
|
24 #include <cusbclasscontrolleriterator.h> |
|
25 #include <musbclasscontrollernotify.h> |
|
26 #include "CUsbDummyClassControllerLdd.h" |
|
27 #include "OstTraceDefinitions.h" |
|
28 #ifdef OST_TRACE_COMPILER_IN_USE |
|
29 #include "CUsbDummyClassControllerLddTraces.h" |
|
30 #endif |
|
31 |
|
32 |
|
33 |
|
34 const TInt32 KDummyLDDTestServUid = 0x20031D88; |
|
35 const TUint KCCErrorTestStepPublishedDeviceEventKey = 0x20031D6F; |
|
36 // Panic codes |
|
37 enum |
|
38 { |
|
39 // Bad value for the iSynchronicity member. |
|
40 EDummyPanicBadSynchronicity = 0, |
|
41 |
|
42 // Used for environment errors we do not handle. |
|
43 EDummyPanicUnhandledError = 1, |
|
44 |
|
45 // Used for bad iStatus and other state errors. |
|
46 EDummyPanicBadState = 2, |
|
47 |
|
48 // Error reading ini file. |
|
49 EDummyPanicBadIniFile = 3, |
|
50 |
|
51 // We already have our async request active. |
|
52 EDummyPanicAlreadyActive = 4, |
|
53 |
|
54 // We already have a request outstanding from the device class. |
|
55 EDummyPanicOutstandingRequestFromDevice = 5, |
|
56 |
|
57 // Attempt to call Start() when in illegal state |
|
58 EDummyPanicBadApiCallStart = 6, |
|
59 |
|
60 // Attempt to call Stop() when in illegal state |
|
61 EDummyPanicBadApiCallStop = 7, |
|
62 }; |
|
63 |
|
64 const TInt KDummyClassPriority = 1; |
|
65 |
|
66 |
|
67 |
|
68 CUsbDummyClassControllerLdd* CUsbDummyClassControllerLdd::NewL( |
|
69 MUsbClassControllerNotify& aOwner, |
|
70 TUint aIndex) |
|
71 |
|
72 /** |
|
73 * Constructs a CUsbDummyClassControllerLdd object. |
|
74 * |
|
75 * @param aOwner USB Device that owns and manages the class |
|
76 * @param aIndex The index number of the instance |
|
77 * @return Ownership of a new CUsbDummyClassControllerLdd object |
|
78 */ |
|
79 |
|
80 { |
|
81 CUsbDummyClassControllerLdd* self = new(ELeave) CUsbDummyClassControllerLdd(aOwner, aIndex); |
|
82 CleanupStack::PushL(self); |
|
83 self->ConstructL(); |
|
84 CleanupStack::Pop(self); |
|
85 return self; |
|
86 } |
|
87 |
|
88 |
|
89 CUsbDummyClassControllerLdd::CUsbDummyClassControllerLdd( |
|
90 MUsbClassControllerNotify& aOwner, |
|
91 TUint aIndex) |
|
92 /** |
|
93 * Constructor. |
|
94 * |
|
95 * @param aOwner USB Device that owns and manages the class |
|
96 * @param aIndex The index number of the instance |
|
97 */ |
|
98 : CUsbClassControllerPlugIn(aOwner, KDummyClassPriority), |
|
99 iIndex(aIndex) |
|
100 { |
|
101 iState = EUsbServiceIdle; // needs explicit initialisation as non-zero |
|
102 iPropertyExist = EFalse; |
|
103 } |
|
104 |
|
105 CUsbDummyClassControllerLdd::CUsbDummyClassControllerLdd( |
|
106 MUsbClassControllerNotify& aOwner, |
|
107 TUint aIndex, TInt aPriority) |
|
108 |
|
109 /** |
|
110 * Constructor. |
|
111 * |
|
112 * @param aOwner USB Device that owns and manages the class |
|
113 * @param aIndex The index number of the instance |
|
114 * @param aPriority a startup priority for the class controller |
|
115 */ |
|
116 : CUsbClassControllerPlugIn(aOwner, aPriority), |
|
117 iIndex(aIndex) |
|
118 { |
|
119 iState = EUsbServiceIdle; // needs explicit initialisation as non-zero |
|
120 iPropertyExist = EFalse; |
|
121 } |
|
122 |
|
123 void CUsbDummyClassControllerLdd::ConstructL() |
|
124 /** |
|
125 * Method to perform second phase construction. |
|
126 */ |
|
127 { |
|
128 OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLERLDD_CONSTRUCTL_ENTRY ); |
|
129 |
|
130 OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLERLDD_CONSTRUCTL_EXIT ); |
|
131 } |
|
132 |
|
133 CUsbDummyClassControllerLdd::~CUsbDummyClassControllerLdd() |
|
134 /** |
|
135 * Destructor. |
|
136 */ |
|
137 { |
|
138 OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLERLDD_CUSBDUMMYCLASSCONTROLLERLDD_ENTRY ); |
|
139 |
|
140 Cancel(); |
|
141 iPropertyExist = EFalse; |
|
142 OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLERLDD_CUSBDUMMYCLASSCONTROLLERLDD_EXIT ); |
|
143 } |
|
144 |
|
145 void CUsbDummyClassControllerLdd::DoGetConfigL() |
|
146 /** |
|
147 * Reads the config from the ini file. |
|
148 */ |
|
149 { |
|
150 |
|
151 |
|
152 } |
|
153 |
|
154 void CUsbDummyClassControllerLdd::GetConfig() |
|
155 /** |
|
156 * Reads the config from the ini file. |
|
157 * Note that this is assumed to succeed. Any failure will break the test and |
|
158 * it's much cleaner to panic out of the test entirely rather than leave it to |
|
159 * the user to figure out what's gone wrong. |
|
160 */ |
|
161 { |
|
162 |
|
163 |
|
164 |
|
165 } |
|
166 |
|
167 void CUsbDummyClassControllerLdd::Start(TRequestStatus& aStatus) |
|
168 /** |
|
169 * Called by UsbMan to start this class. |
|
170 * |
|
171 * @param aStatus Will be completed with success or failure. |
|
172 */ |
|
173 { |
|
174 OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLERLDD_START_ENTRY ); |
|
175 |
|
176 CUsbClassControllerIterator *iterator = NULL; |
|
177 TRAPD(ret,iterator = Owner().UccnGetClassControllerIteratorL()); |
|
178 if(ret == KErrNone) |
|
179 { |
|
180 delete iterator; |
|
181 } |
|
182 TRequestStatus* tmp = &aStatus; |
|
183 User::RequestComplete(tmp, KErrNone); |
|
184 if(!iPropertyExist) |
|
185 { |
|
186 TInt err = iProperty.Attach(TUid::Uid(KDummyLDDTestServUid), |
|
187 KCCErrorTestStepPublishedDeviceEventKey); |
|
188 |
|
189 |
|
190 iProperty.Subscribe(iStatus); |
|
191 SetActive(); |
|
192 iPropertyExist = ETrue; |
|
193 } |
|
194 |
|
195 OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLERLDD_START_EXIT ); |
|
196 } |
|
197 |
|
198 void CUsbDummyClassControllerLdd::Stop(TRequestStatus& aStatus) |
|
199 /** |
|
200 * Called by UsbMan to stop this class. |
|
201 * |
|
202 * @param aStatus Will be completed with success or failure. |
|
203 */ |
|
204 { |
|
205 OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLERLDD_STOP_ENTRY ); |
|
206 |
|
207 TRequestStatus* tmp = &aStatus; |
|
208 User::RequestComplete(tmp, KErrNone); |
|
209 |
|
210 OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLERLDD_STOP_EXIT ); |
|
211 } |
|
212 |
|
213 void CUsbDummyClassControllerLdd::GetDescriptorInfo(TUsbDescriptor& aDescriptorInfo) const |
|
214 /** |
|
215 * Returns information about the interfaces supported by this class. |
|
216 * |
|
217 * @param aDescriptorInfo Will be filled in with interface information. |
|
218 */ |
|
219 { |
|
220 aDescriptorInfo.iNumInterfaces = 0; |
|
221 aDescriptorInfo.iLength = 0; |
|
222 } |
|
223 |
|
224 void CUsbDummyClassControllerLdd::RunL() |
|
225 /** |
|
226 * Standard active object RunL. |
|
227 */ |
|
228 { |
|
229 OstTraceFunctionEntry0( CUSBDUMMYCLASSCONTROLLERLDD_RUNL_ENTRY ); |
|
230 TInt num; |
|
231 iProperty.Get(num); |
|
232 if(num < 0) |
|
233 User::Leave(num); |
|
234 iProperty.Subscribe(iStatus); |
|
235 SetActive(); |
|
236 OstTraceFunctionExit0( CUSBDUMMYCLASSCONTROLLERLDD_RUNL_EXIT ); |
|
237 } |
|
238 |
|
239 void CUsbDummyClassControllerLdd::DoCancel() |
|
240 /** |
|
241 * Standard active object cancellation function. |
|
242 */ |
|
243 { |
|
244 iProperty.Cancel(); |
|
245 } |
|
246 |
|
247 TInt CUsbDummyClassControllerLdd::RunError(TInt aError) |
|
248 /** |
|
249 * Standard active object error-handling function. |
|
250 * |
|
251 * Should return KErrNone to avoid an active scheduler panic. This function |
|
252 * should never be called as there is another mechanism for catching errors. |
|
253 */ |
|
254 { |
|
255 Owner().UccnError(KErrNone); |
|
256 return KErrNone; |
|
257 } |
|
258 |
|
259 // |
|
260 // End of file |