1 /* |
|
2 * Copyright (c) 2008 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: Observes OTG states |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_USBOTGSTATEOBSERVER_H |
|
19 #define C_USBOTGSTATEOBSERVER_H |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <e32property.h> |
|
23 #include <usbotgdefs.h> |
|
24 |
|
25 /** |
|
26 * Observer need to implement this interface to get OTG state change notifications |
|
27 */ |
|
28 NONSHARABLE_CLASS( MUsbOtgStateObserver) |
|
29 { |
|
30 public: |
|
31 |
|
32 /** |
|
33 * Local device is A, and get to Idle state |
|
34 */ |
|
35 virtual void AIdleL() = 0; |
|
36 |
|
37 /** |
|
38 * Local device is A, and get to Host state |
|
39 */ |
|
40 virtual void AHostL() = 0; |
|
41 |
|
42 /** |
|
43 * Local device is A, and get to Peripheral state |
|
44 */ |
|
45 virtual void APeripheralL() = 0; |
|
46 |
|
47 /** |
|
48 * Local device is A, and get VBus error |
|
49 */ |
|
50 virtual void AVBusErrorL() = 0; |
|
51 |
|
52 /** |
|
53 * Local device is B, and get to Idle state |
|
54 */ |
|
55 virtual void BIdleL() = 0; |
|
56 |
|
57 /** |
|
58 * Local device is B, and get to Peripheral state |
|
59 */ |
|
60 virtual void BPeripheralL() = 0; |
|
61 |
|
62 /** |
|
63 * Local device is B, and get to Host state |
|
64 */ |
|
65 virtual void BHostL() = 0; |
|
66 |
|
67 /** |
|
68 * Error handler |
|
69 * @param aError error code |
|
70 */ |
|
71 virtual void OtgStateErrorL(TInt aError) = 0; |
|
72 }; |
|
73 |
|
74 /** |
|
75 * Class observes OTG State property |
|
76 * |
|
77 */ |
|
78 NONSHARABLE_CLASS( CUsbOtgStateObserver ) : public CActive |
|
79 { |
|
80 |
|
81 public: |
|
82 |
|
83 /** |
|
84 * Two-phased constructor. |
|
85 */ |
|
86 static CUsbOtgStateObserver* NewL(); |
|
87 |
|
88 /** |
|
89 * Destructor. |
|
90 */ |
|
91 virtual ~CUsbOtgStateObserver(); |
|
92 |
|
93 /** |
|
94 * Gets current OTG state |
|
95 * @return OTG state |
|
96 */ |
|
97 TUsbOtgState OtgState(); |
|
98 |
|
99 /** |
|
100 * Subscribes for getting notifications |
|
101 * @param aObserver Observer |
|
102 */ |
|
103 void SubscribeL(MUsbOtgStateObserver& aObserver); |
|
104 |
|
105 /** |
|
106 * Unsubscribes from getting notifications |
|
107 * @param aObserver Observer |
|
108 */ |
|
109 void UnsubscribeL(MUsbOtgStateObserver& aObserver); |
|
110 |
|
111 private: |
|
112 |
|
113 // From CActive |
|
114 /** |
|
115 * Called when outstanding request completed |
|
116 * |
|
117 */ |
|
118 void RunL(); |
|
119 |
|
120 /** |
|
121 * Called when outstanding request is cancelled |
|
122 * |
|
123 */ |
|
124 void DoCancel(); |
|
125 |
|
126 /** |
|
127 * Called when RunL leaves |
|
128 * |
|
129 * @param errorcode |
|
130 * @return errorcode |
|
131 */ |
|
132 TInt RunError(TInt aError); |
|
133 |
|
134 private: |
|
135 |
|
136 /** |
|
137 * Default constructor |
|
138 * |
|
139 */ |
|
140 CUsbOtgStateObserver(); |
|
141 |
|
142 /** |
|
143 * Second phase construction |
|
144 * |
|
145 */ |
|
146 void ConstructL(); |
|
147 |
|
148 private: |
|
149 // data |
|
150 |
|
151 /** |
|
152 * The observer reports state changes to own observers |
|
153 * Not owns |
|
154 */ |
|
155 RPointerArray<MUsbOtgStateObserver> iObservers; |
|
156 |
|
157 /** |
|
158 * The observer observes property change |
|
159 */ |
|
160 RProperty iOtgState; |
|
161 |
|
162 }; |
|
163 |
|
164 #endif // C_USBOTGSTATEOBSERVER_H |
|