|
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: Monitors host events |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_USBHOSTEVENTNOTIFICATIONOBSERVER_H |
|
19 #define C_USBHOSTEVENTNOTIFICATIONOBSERVER_H |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <e32property.h> |
|
23 #include <usbotgdefs.h> |
|
24 #include <usbhostdefs.h> |
|
25 |
|
26 class RUsb; |
|
27 |
|
28 /** |
|
29 * Observer must implement this interface to get notifications |
|
30 * |
|
31 */ |
|
32 NONSHARABLE_CLASS( MUsbHostEventNotificationObserver) |
|
33 { |
|
34 public: |
|
35 |
|
36 /** |
|
37 * Called when device is attached |
|
38 * @param aInfo additional information |
|
39 */ |
|
40 virtual void DeviceAttachedL(TDeviceEventInformation aInfo) = 0; |
|
41 |
|
42 /** |
|
43 * Called when device is detached |
|
44 * @param aInfo additional information |
|
45 */ |
|
46 virtual void DeviceDetachedL(TDeviceEventInformation aInfo) = 0; |
|
47 |
|
48 /** |
|
49 * Called when drivers are loaded |
|
50 * @param aInfo additional information |
|
51 */ |
|
52 virtual void DriverLoadSuccessL(TDeviceEventInformation aInfo) = 0; |
|
53 |
|
54 /** |
|
55 * Called when drivers are loaded partially |
|
56 * @param aInfo additional information |
|
57 */ |
|
58 virtual void DriverLoadPartialSuccessL(TDeviceEventInformation aInfo) = 0; |
|
59 |
|
60 /** |
|
61 * Called when drivers loading failed |
|
62 * @param aInfo additional information |
|
63 */ |
|
64 virtual void DriverLoadFailureL(TDeviceEventInformation aInfo) = 0; |
|
65 |
|
66 /** |
|
67 * Called when error happens while observing |
|
68 * @param aError error code |
|
69 */ |
|
70 virtual void HostEventNotificationErrorL(TInt aError) = 0; |
|
71 |
|
72 }; |
|
73 |
|
74 /** |
|
75 * Class observes USB Notifications |
|
76 */ |
|
77 NONSHARABLE_CLASS( CUsbHostEventNotificationObserver ) : public CActive |
|
78 { |
|
79 |
|
80 public: |
|
81 |
|
82 /** |
|
83 * Two-phased constructor. |
|
84 * @param aUsb usbman |
|
85 * @return this class instance |
|
86 */ |
|
87 static CUsbHostEventNotificationObserver* NewL(RUsb* aUsb); |
|
88 |
|
89 /** |
|
90 * Destructor. |
|
91 */ |
|
92 virtual ~CUsbHostEventNotificationObserver(); |
|
93 |
|
94 /** |
|
95 * Add observer to list of observers |
|
96 * @param aObserver observer |
|
97 */ |
|
98 void SubscribeL(MUsbHostEventNotificationObserver& aObserver); |
|
99 |
|
100 /** |
|
101 * Removes observer from list of observers |
|
102 * @param aObserver Observer |
|
103 */ |
|
104 void UnsubscribeL(MUsbHostEventNotificationObserver& aObserver); |
|
105 |
|
106 private: |
|
107 |
|
108 // From CActive |
|
109 /** |
|
110 * Called when request completed |
|
111 */ |
|
112 void RunL(); |
|
113 |
|
114 /** |
|
115 * Called when outstanding request cancelled |
|
116 */ |
|
117 void DoCancel(); |
|
118 |
|
119 /** |
|
120 * Called when RunL leaves |
|
121 * @param aError errorcode from RunL |
|
122 * @return aError errorcode |
|
123 */ |
|
124 TInt RunError(TInt aError); |
|
125 |
|
126 private: |
|
127 |
|
128 /** |
|
129 * Default constructor. |
|
130 * @param aUsb usbman |
|
131 */ |
|
132 CUsbHostEventNotificationObserver(RUsb* aUsb); |
|
133 |
|
134 /** |
|
135 * 2nd phase constructor. |
|
136 */ |
|
137 void ConstructL(); |
|
138 |
|
139 private: |
|
140 // data |
|
141 |
|
142 /** |
|
143 * The observer reports changes to own observers |
|
144 * Not owns |
|
145 */ |
|
146 RPointerArray<MUsbHostEventNotificationObserver> iObservers; |
|
147 |
|
148 /** |
|
149 * Notifications come from USB |
|
150 * Not own |
|
151 */ |
|
152 RUsb* iUsb; |
|
153 |
|
154 /** |
|
155 * Info from notification comes to this member |
|
156 */ |
|
157 TDeviceEventInformation iEventInfo; |
|
158 |
|
159 }; |
|
160 |
|
161 #endif // C_USBHOSTEVENTNOTIFICATIONOBSERVER_H |