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