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 notifications from usb |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_USBMESSAGENOTIFICATIONOBSERVER_H |
|
19 #define C_USBMESSAGENOTIFICATIONOBSERVER_H |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <e32property.h> |
|
23 #include <usbotgdefs.h> |
|
24 |
|
25 class RUsb; |
|
26 |
|
27 /** |
|
28 * Class implements functionality of showing/blinking usb indicator |
|
29 * Class does not provide method to get response from the user |
|
30 */ |
|
31 NONSHARABLE_CLASS( MUsbMessageNotificationObserver) |
|
32 { |
|
33 public: |
|
34 |
|
35 /** |
|
36 * Call back on message notification |
|
37 * @param aMessage Message id |
|
38 */ |
|
39 virtual void MessageNotificationReceivedL(TInt aMessage) = 0; |
|
40 |
|
41 /** |
|
42 * Called when BadHubPosition error happen |
|
43 */ |
|
44 virtual void BadHubPositionL() = 0; |
|
45 |
|
46 /** |
|
47 * Callen if VBus error happen |
|
48 */ |
|
49 virtual void VBusErrorL() = 0; |
|
50 |
|
51 /** |
|
52 * Called when SRP request received |
|
53 */ |
|
54 virtual void SrpReceivedL() = 0; |
|
55 |
|
56 /** |
|
57 * Called when session requested |
|
58 */ |
|
59 virtual void SessionRequestedL() = 0; |
|
60 |
|
61 /** |
|
62 * Called when error happened |
|
63 * @param aError error code |
|
64 */ |
|
65 virtual void MessageNotificationErrorL(TInt aError) = 0; |
|
66 }; |
|
67 |
|
68 /** |
|
69 * Class observes USB Notifications |
|
70 * |
|
71 */ |
|
72 NONSHARABLE_CLASS( CUsbMessageNotificationObserver ) : public CActive |
|
73 { |
|
74 |
|
75 public: |
|
76 |
|
77 /** |
|
78 * Two-phased constructor. |
|
79 * @param aUsb usbman |
|
80 */ |
|
81 static CUsbMessageNotificationObserver* NewL(RUsb* aUsb); |
|
82 |
|
83 /** |
|
84 * Destructor. |
|
85 */ |
|
86 virtual ~CUsbMessageNotificationObserver(); |
|
87 |
|
88 /** |
|
89 * Subscribes for notifications |
|
90 * @param aObserver observer |
|
91 */ |
|
92 void SubscribeL(MUsbMessageNotificationObserver& aObserver); |
|
93 |
|
94 /** |
|
95 * Unsubscribe from notifications |
|
96 * @param aObserver Observer |
|
97 */ |
|
98 void UnsubscribeL(MUsbMessageNotificationObserver& aObserver); |
|
99 |
|
100 private: |
|
101 |
|
102 // From CActive |
|
103 /** |
|
104 * Called by framework when outstanding request completed |
|
105 * |
|
106 */ |
|
107 void RunL(); |
|
108 |
|
109 /** |
|
110 * Called when outstanding request camcelled |
|
111 * |
|
112 */ |
|
113 void DoCancel(); |
|
114 |
|
115 /** |
|
116 * Called when RunL leaves |
|
117 * |
|
118 * @param aError error id |
|
119 * @return error id |
|
120 */ |
|
121 TInt RunError(TInt aError); |
|
122 |
|
123 private: |
|
124 |
|
125 /** |
|
126 * Default constructor |
|
127 * @param aUsb usbman |
|
128 */ |
|
129 CUsbMessageNotificationObserver(RUsb* aUsb); |
|
130 |
|
131 /** |
|
132 * Second phase construction |
|
133 */ |
|
134 void ConstructL(); |
|
135 |
|
136 private: |
|
137 // data |
|
138 |
|
139 /** |
|
140 * The observer reports to own observers |
|
141 * Not owns |
|
142 */ |
|
143 RPointerArray<MUsbMessageNotificationObserver> iObservers; |
|
144 |
|
145 /** |
|
146 * Notifications come from USB |
|
147 * Not own |
|
148 */ |
|
149 RUsb* iUsb; |
|
150 |
|
151 /** |
|
152 * Info from notification comes to this member |
|
153 */ |
|
154 TInt iMessage; |
|
155 |
|
156 }; |
|
157 |
|
158 #endif // C_USBMESSAGENOTIFICATIONOBSERVER_H |
|