|
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: Monitors USB activity |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_USBBUSACTIVITYOBSERVER_H |
|
20 #define C_USBBUSACTIVITYOBSERVER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <e32property.h> |
|
24 |
|
25 /** |
|
26 * This interface has to be implemented by observer |
|
27 * to receive notifications from USB bus activity property |
|
28 */ |
|
29 NONSHARABLE_CLASS(MUsbBusActivityObserver) |
|
30 { |
|
31 public: |
|
32 |
|
33 /** |
|
34 * Called when bus turn to idle |
|
35 */ |
|
36 virtual void BusIdleL() = 0; |
|
37 |
|
38 /** |
|
39 * Called when when bus is in Idle, and some activity appears on the bus |
|
40 */ |
|
41 virtual void BusActiveL() = 0; |
|
42 |
|
43 /** |
|
44 * Called when when error happened |
|
45 * @param aError errorcode |
|
46 */ |
|
47 virtual void BusActivityErrorL(TInt aError) = 0; |
|
48 |
|
49 }; |
|
50 |
|
51 /** |
|
52 * Class observes USB OTG State property |
|
53 * |
|
54 */ |
|
55 NONSHARABLE_CLASS(CUsbBusActivityObserver) : public CActive |
|
56 { |
|
57 |
|
58 public: |
|
59 |
|
60 enum TBusActivity |
|
61 { |
|
62 EBusIdle = 0, EBusActive = 1 |
|
63 }; |
|
64 |
|
65 /** |
|
66 * Two-phased constructor. |
|
67 */ |
|
68 static CUsbBusActivityObserver* NewL(); |
|
69 |
|
70 /** |
|
71 * Destructor. |
|
72 */ |
|
73 virtual ~CUsbBusActivityObserver(); |
|
74 |
|
75 /** |
|
76 * Returns bus activity state |
|
77 * @return bus activity |
|
78 */ |
|
79 TBusActivity BusActivity(); |
|
80 |
|
81 /** |
|
82 * Adds subscriber for the notification |
|
83 * @param aObserver Observer |
|
84 */ |
|
85 void SubscribeL(MUsbBusActivityObserver* aObserver); |
|
86 |
|
87 /** |
|
88 * Removes observer |
|
89 * @param aObserver Observer |
|
90 */ |
|
91 void UnsubscribeL(MUsbBusActivityObserver* aObserver); |
|
92 |
|
93 private: |
|
94 |
|
95 // From CActive |
|
96 /** |
|
97 * Called when request on bus activity completed |
|
98 */ |
|
99 void RunL(); |
|
100 |
|
101 /** |
|
102 * Called by framwork, when canceling outstanding request |
|
103 */ |
|
104 void DoCancel(); |
|
105 |
|
106 /** |
|
107 * Called when RunL leaves |
|
108 * @param aError error code |
|
109 */ |
|
110 TInt RunError(TInt aError); |
|
111 |
|
112 private: |
|
113 |
|
114 /** |
|
115 * Default constructor |
|
116 */ |
|
117 CUsbBusActivityObserver(); |
|
118 |
|
119 /** |
|
120 * 2nd phase construction |
|
121 */ |
|
122 void ConstructL(); |
|
123 |
|
124 private: |
|
125 // data |
|
126 |
|
127 /** |
|
128 * The observer reports state changes to own observers |
|
129 * Owns |
|
130 */ |
|
131 RPointerArray<MUsbBusActivityObserver> iObservers; |
|
132 |
|
133 /** |
|
134 * The observer observes property change |
|
135 */ |
|
136 RProperty iBusActivity; |
|
137 |
|
138 }; |
|
139 |
|
140 #endif // C_USBOTGSTATEOBSERVER_H |