|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef USBVIEWER_H |
|
19 #define USBVIEWER_H |
|
20 |
|
21 #include <e32cmn.h> |
|
22 #include <e32base.h> |
|
23 #include <usbman.h> |
|
24 #include <e32property.h> |
|
25 #include "e32msgqueue.h" |
|
26 |
|
27 #include "usbcontrolappshared.h" |
|
28 |
|
29 class CConsoleBase; |
|
30 |
|
31 class CUserMsgQWatcher; |
|
32 class CServiceStateWatcher; |
|
33 class CDeviceStateWatcher; |
|
34 class CIdPinWatcher; |
|
35 class CVBusWatcher; |
|
36 class CConnectionIdleWatcher; |
|
37 class CHostEventWatcher; |
|
38 class CMessageWatcher; |
|
39 class COtgStateWatcher; |
|
40 |
|
41 class CShutdownMonitor; |
|
42 |
|
43 _LIT(KUsbViewerTitle, "USB Viewer"); |
|
44 |
|
45 |
|
46 NONSHARABLE_STRUCT(XUsbViewerEvent) |
|
47 { |
|
48 ~XUsbViewerEvent(); |
|
49 TDblQueLink iLink; |
|
50 RBuf iEvent; |
|
51 }; |
|
52 |
|
53 |
|
54 NONSHARABLE_CLASS(MShutdownInterface) |
|
55 { |
|
56 public: |
|
57 virtual void Stop() const = 0; |
|
58 }; |
|
59 |
|
60 |
|
61 NONSHARABLE_CLASS(CUsbViewer) : public CActive, public MShutdownInterface |
|
62 { |
|
63 public: |
|
64 static CUsbViewer* NewLC(); |
|
65 ~CUsbViewer(); |
|
66 |
|
67 public: |
|
68 void Start(); |
|
69 void Stop() const; |
|
70 |
|
71 RUsb& Usb(); |
|
72 RMsgQueue<TBuf<KViewerNumCharactersOnLine> >& UserMsgQ(); |
|
73 |
|
74 public: |
|
75 enum TFdfDriverLoadingState |
|
76 { |
|
77 EUnknown, |
|
78 EDisabled, |
|
79 EEnabled |
|
80 }; |
|
81 |
|
82 enum TDeviceType |
|
83 { |
|
84 ENoDevice, |
|
85 EGenericDevice, |
|
86 ELogitechHeadset |
|
87 }; |
|
88 |
|
89 public: // Callbacks |
|
90 void SetServiceState(TUsbServiceState aServiceState); |
|
91 void SetDeviceState(TUsbDeviceState aDeviceState); |
|
92 void SetIdPin(TInt aIdPin); |
|
93 void SetVBus(TInt aVBus); |
|
94 void SetConnectionIdle(TInt aConnIdle); |
|
95 void SetOtgState(TInt aOtgState); |
|
96 void SetDriverLoading(TFdfDriverLoadingState aDriverLoading); |
|
97 void SetAttachedDevices(TUint aAttachedDevices); |
|
98 void SetDeviceType(TDeviceType aDeviceType); |
|
99 |
|
100 void NotifyEvent(XUsbViewerEvent* aEvent); |
|
101 |
|
102 private: |
|
103 CUsbViewer(); |
|
104 void ConstructL(); |
|
105 void Move(TInt aX, TInt aY); |
|
106 void Draw(); |
|
107 |
|
108 void DoCancel(); |
|
109 void RunL(); |
|
110 void ScheduleDraw(); |
|
111 |
|
112 TBool iAutoSrpResponse; |
|
113 TDeviceType iDeviceType; |
|
114 |
|
115 private: |
|
116 CConsoleBase* iConsole; |
|
117 RUsb iUsb; |
|
118 CShutdownMonitor* iShutdownMonitor; |
|
119 |
|
120 private: |
|
121 CUserMsgQWatcher* iUserMsgQWatcher; |
|
122 CServiceStateWatcher* iServiceStateWatcher; |
|
123 CDeviceStateWatcher* iDeviceStateWatcher; |
|
124 CIdPinWatcher* iIdPinWatcher; |
|
125 CVBusWatcher* iVBusWatcher; |
|
126 CConnectionIdleWatcher* iConnIdleWatcher; |
|
127 COtgStateWatcher* iOtgStateWatcher; |
|
128 CHostEventWatcher* iHostEventWatcher; |
|
129 CMessageWatcher* iMessageWatcher; |
|
130 |
|
131 private: // Display variables |
|
132 TVersion iVersion; |
|
133 TBuf<11> iServStatus; // Needs Trailing Space |
|
134 TBuf<11> iDevStatus; // Needs Trailing Space |
|
135 TBuf<5> iIdPin; // Needs Trailing Space |
|
136 TBuf<5> iVBus; // Needs Trailing Space |
|
137 TBuf<5> iConnIdle; // Needs Trailing Space |
|
138 TBuf<3> iDriverLoading; |
|
139 TBuf<3> iAttachedDevices; |
|
140 TBuf<14> iOtgState; // Needs Trailing Space |
|
141 TBuf<5> iAttachedDevice; |
|
142 |
|
143 private: |
|
144 static const TInt KNumEventsInWindow = 7; |
|
145 // H4 screen can have 22 lines of text on it at once |
|
146 static const TInt KNumLinesInWindow = 14; |
|
147 |
|
148 private: // Event list |
|
149 TDblQue<XUsbViewerEvent> iEventList; |
|
150 // RMsgQueue between exampleusbcontrolapp.exe & usbviewer.exe for displaying user messages |
|
151 RMsgQueue<TBuf<KViewerNumCharactersOnLine> > iUserMsgQ; |
|
152 }; |
|
153 |
|
154 |
|
155 NONSHARABLE_CLASS(CShutdownMonitor) : public CActive |
|
156 { |
|
157 public: |
|
158 static CShutdownMonitor* NewL(MShutdownInterface& aParentUsbViewer); |
|
159 ~CShutdownMonitor(); |
|
160 private: |
|
161 CShutdownMonitor(MShutdownInterface& aParentUsbViewer); |
|
162 void ConstructL(); |
|
163 // From CActive |
|
164 void DoCancel(); |
|
165 void RunL(); |
|
166 private: |
|
167 RProperty iShutdownProp; |
|
168 MShutdownInterface& iParentUsbViewer; |
|
169 }; |
|
170 |
|
171 |
|
172 NONSHARABLE_CLASS(CEventNotifier) : public CActive |
|
173 { |
|
174 protected: |
|
175 CEventNotifier(TInt aPriority); |
|
176 XUsbViewerEvent* NewViewerEventL(); |
|
177 virtual void DoRunL(XUsbViewerEvent* aEvent) = 0; |
|
178 private: |
|
179 void RunL(); |
|
180 }; |
|
181 |
|
182 |
|
183 NONSHARABLE_CLASS(CServiceStateWatcher) : public CEventNotifier |
|
184 { |
|
185 public: |
|
186 static CServiceStateWatcher* NewL(CUsbViewer& aUsb); |
|
187 ~CServiceStateWatcher(); |
|
188 |
|
189 private: |
|
190 CServiceStateWatcher(CUsbViewer& aUsb); |
|
191 void ConstructL(); |
|
192 |
|
193 void DoCancel(); |
|
194 void DoRunL(XUsbViewerEvent* aEvent); |
|
195 |
|
196 private: |
|
197 CUsbViewer& iUsbViewer; |
|
198 TUsbServiceState iServiceState; |
|
199 }; |
|
200 |
|
201 |
|
202 NONSHARABLE_CLASS(CDeviceStateWatcher) : public CEventNotifier |
|
203 { |
|
204 public: |
|
205 static CDeviceStateWatcher* NewL(CUsbViewer& aUsb); |
|
206 ~CDeviceStateWatcher(); |
|
207 |
|
208 private: |
|
209 CDeviceStateWatcher(CUsbViewer& aUsb); |
|
210 void ConstructL(); |
|
211 |
|
212 void DoCancel(); |
|
213 void DoRunL(XUsbViewerEvent* aEvent); |
|
214 |
|
215 private: |
|
216 CUsbViewer& iUsbViewer; |
|
217 TUsbDeviceState iDeviceState; |
|
218 }; |
|
219 |
|
220 |
|
221 NONSHARABLE_CLASS(CIdPinWatcher) : public CEventNotifier |
|
222 { |
|
223 public: |
|
224 static CIdPinWatcher* NewL(CUsbViewer& aUsb); |
|
225 ~CIdPinWatcher(); |
|
226 |
|
227 private: |
|
228 CIdPinWatcher(CUsbViewer& aUsb); |
|
229 void ConstructL(); |
|
230 |
|
231 void DoCancel(); |
|
232 void DoRunL(XUsbViewerEvent* aEvent); |
|
233 |
|
234 private: |
|
235 CUsbViewer& iUsbViewer; |
|
236 RProperty iIdPinProp; |
|
237 }; |
|
238 |
|
239 |
|
240 NONSHARABLE_CLASS(CVBusWatcher) : public CEventNotifier |
|
241 { |
|
242 public: |
|
243 static CVBusWatcher* NewL(CUsbViewer& aUsb); |
|
244 ~CVBusWatcher(); |
|
245 |
|
246 private: |
|
247 CVBusWatcher(CUsbViewer& aUsb); |
|
248 void ConstructL(); |
|
249 |
|
250 void DoCancel(); |
|
251 void DoRunL(XUsbViewerEvent* aEvent); |
|
252 |
|
253 private: |
|
254 CUsbViewer& iUsbViewer; |
|
255 RProperty iVBusProp; |
|
256 }; |
|
257 |
|
258 |
|
259 NONSHARABLE_CLASS(CConnectionIdleWatcher) : public CEventNotifier |
|
260 { |
|
261 public: |
|
262 static CConnectionIdleWatcher* NewL(CUsbViewer& aUsb); |
|
263 ~CConnectionIdleWatcher(); |
|
264 |
|
265 private: |
|
266 CConnectionIdleWatcher(CUsbViewer& aUsb); |
|
267 void ConstructL(); |
|
268 |
|
269 void DoCancel(); |
|
270 void DoRunL(XUsbViewerEvent* aEvent); |
|
271 |
|
272 private: |
|
273 CUsbViewer& iUsbViewer; |
|
274 RProperty iConnIdleProp; |
|
275 }; |
|
276 |
|
277 |
|
278 NONSHARABLE_CLASS(COtgStateWatcher) : public CEventNotifier |
|
279 { |
|
280 public: |
|
281 static COtgStateWatcher* NewL(CUsbViewer& aUsb); |
|
282 ~COtgStateWatcher(); |
|
283 |
|
284 private: |
|
285 COtgStateWatcher(CUsbViewer& aUsb); |
|
286 void ConstructL(); |
|
287 |
|
288 void DoCancel(); |
|
289 void DoRunL(XUsbViewerEvent* aEvent); |
|
290 |
|
291 private: |
|
292 CUsbViewer& iUsbViewer; |
|
293 RProperty iOtgStateProp; |
|
294 }; |
|
295 |
|
296 |
|
297 NONSHARABLE_CLASS(CHostEventWatcher) : public CEventNotifier |
|
298 { |
|
299 public: |
|
300 static CHostEventWatcher* NewL(CUsbViewer& aUsb); |
|
301 ~CHostEventWatcher(); |
|
302 |
|
303 private: |
|
304 CHostEventWatcher(CUsbViewer& aUsb); |
|
305 void ConstructL(); |
|
306 |
|
307 void DoCancel(); |
|
308 void DoRunL(XUsbViewerEvent* aEvent); |
|
309 |
|
310 private: |
|
311 CUsbViewer& iUsbViewer; |
|
312 TDeviceEventInformation iDeviceInfo; |
|
313 RArray<TUint> iAttachedDevices; |
|
314 }; |
|
315 |
|
316 |
|
317 NONSHARABLE_CLASS(CMessageWatcher) : public CEventNotifier |
|
318 { |
|
319 public: |
|
320 static CMessageWatcher* NewL(CUsbViewer& aUsb); |
|
321 ~CMessageWatcher(); |
|
322 |
|
323 private: |
|
324 CMessageWatcher(CUsbViewer& aUsb); |
|
325 void ConstructL(); |
|
326 |
|
327 void DoCancel(); |
|
328 void DoRunL(XUsbViewerEvent* aEvent); |
|
329 |
|
330 private: |
|
331 CUsbViewer& iUsbViewer; |
|
332 TInt iMessage; |
|
333 }; |
|
334 |
|
335 |
|
336 NONSHARABLE_CLASS(CUserMsgQWatcher) : public CEventNotifier |
|
337 { |
|
338 public: |
|
339 static CUserMsgQWatcher* NewL(CUsbViewer& aUsb); |
|
340 ~CUserMsgQWatcher(); |
|
341 |
|
342 private: |
|
343 CUserMsgQWatcher(CUsbViewer& aUsb); |
|
344 void ConstructL(); |
|
345 |
|
346 void DoCancel(); |
|
347 void DoRunL(XUsbViewerEvent* aEvent); |
|
348 |
|
349 private: |
|
350 CUsbViewer& iUsbViewer; |
|
351 TBuf<KViewerNumCharactersOnLine> iUserMsgLine; |
|
352 }; |
|
353 |
|
354 |
|
355 #endif // USBVIEWER_H |