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: Manages notifiers |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_USBNOTIFMANAGER_H |
|
19 #define C_USBNOTIFMANAGER_H |
|
20 |
|
21 #include <e32base.h> |
|
22 |
|
23 // forward declaration |
|
24 class CUsbNotifier; |
|
25 class CUsbIndicatorNotifier; |
|
26 class CUsbOtgWatcher; |
|
27 |
|
28 // pause warning is visible for (ms) |
|
29 const TUint KPauseForWarnings = 1000000; // 1 sec |
|
30 |
|
31 /** |
|
32 * Observer has to implement this interface to get feedback on user action |
|
33 * Notification received when Whait notified completed (cancelled ot key pressed) |
|
34 */ |
|
35 NONSHARABLE_CLASS( MWaitNotifierObserver) |
|
36 { |
|
37 public: |
|
38 |
|
39 /** |
|
40 * feedback to observer |
|
41 * @param aFeedback how notifier comleted |
|
42 */ |
|
43 virtual void WaitNotifierCompletedL(TInt aFeedback) = 0; |
|
44 }; |
|
45 |
|
46 /** |
|
47 * this class contains information for wait notifier |
|
48 * once notifier gets response from user, notif manager will send feedback data to caller |
|
49 */ |
|
50 NONSHARABLE_CLASS( CWaitNotifierInfo ) : public CBase |
|
51 { |
|
52 public: |
|
53 |
|
54 /** |
|
55 * 2-phase construction |
|
56 * @param aWaitNotifier owner |
|
57 * aObserver will receive notification when completed |
|
58 */ |
|
59 static CWaitNotifierInfo* NewL(CUsbNotifier* aWaitNotifier, |
|
60 MWaitNotifierObserver& aObserver); |
|
61 |
|
62 /** |
|
63 * Destructor |
|
64 */ |
|
65 virtual ~CWaitNotifierInfo(); |
|
66 |
|
67 /** |
|
68 * gets wait notifier |
|
69 */ |
|
70 CUsbNotifier* WaitNotifier() const; |
|
71 |
|
72 /** |
|
73 * gets observer |
|
74 */ |
|
75 MWaitNotifierObserver* Observer() const; |
|
76 |
|
77 private: |
|
78 |
|
79 /** |
|
80 * Default constructor |
|
81 * @param aWaitNotifier Notifier |
|
82 * @param aObserver Observer |
|
83 */ |
|
84 CWaitNotifierInfo(CUsbNotifier* aWaitNotifier, |
|
85 MWaitNotifierObserver& aObserver); |
|
86 |
|
87 /** |
|
88 * 2nd phase construction |
|
89 */ |
|
90 void ConstructL(); |
|
91 |
|
92 private: |
|
93 |
|
94 /** |
|
95 * notifier |
|
96 * owns |
|
97 */ |
|
98 CUsbNotifier* iWaitNotifier; |
|
99 |
|
100 /** |
|
101 * observer |
|
102 * not owns |
|
103 */ |
|
104 MWaitNotifierObserver& iObserver; |
|
105 }; |
|
106 |
|
107 /** |
|
108 * Function of the class is own and share RNotifier, own list of CWaitNotifier(s), |
|
109 * show notifiers, which are synchronous, and cancel it with a delay |
|
110 */ |
|
111 class CUsbNotifManager : public CBase |
|
112 { |
|
113 friend class CUsbNotifManager; |
|
114 |
|
115 public: |
|
116 |
|
117 /** |
|
118 * 2phase construction |
|
119 * @param aOtgWatcher OtgWatcher is a parent class |
|
120 */ |
|
121 static CUsbNotifManager* NewL(CUsbOtgWatcher& aOtgWatcher); |
|
122 |
|
123 /** |
|
124 * Destructor |
|
125 */ |
|
126 virtual ~CUsbNotifManager(); |
|
127 |
|
128 /** |
|
129 * Shows notifier |
|
130 * @param aCat Category |
|
131 * @param aNotifId notifier id |
|
132 * @param aObserver will receive notifications |
|
133 */ |
|
134 void ShowNotifierL(TUid aCat, TUint aNotifId, |
|
135 MWaitNotifierObserver* aObserver); |
|
136 |
|
137 /** |
|
138 * Closes and deletes all the notifiers |
|
139 */ |
|
140 void CloseAllNotifiers(); |
|
141 |
|
142 /** |
|
143 * Calls back Notifier show is over |
|
144 * @param aWaitNotifier wait notifier |
|
145 * @param aResult result (was any errors or not) |
|
146 * @param aFeedback user press (cancel or any other) |
|
147 */ |
|
148 void NotifierShowCompletedL(CUsbNotifier& aWaitNotifier, TInt aResult, |
|
149 TInt aFeedback); |
|
150 |
|
151 private: |
|
152 |
|
153 /** |
|
154 * Default construction |
|
155 * @param aOtgWatcher otg watcher (parent class) |
|
156 */ |
|
157 CUsbNotifManager(); |
|
158 |
|
159 /** |
|
160 * Second phase construction |
|
161 */ |
|
162 void ConstructL(CUsbOtgWatcher& aOtgWatcher); |
|
163 |
|
164 private: |
|
165 // data |
|
166 |
|
167 /** |
|
168 * RNotifier API |
|
169 */ |
|
170 RNotifier iNotifier; |
|
171 |
|
172 /** |
|
173 * List of notifiers waiting for user action |
|
174 */ |
|
175 RPointerArray<CWaitNotifierInfo> iWaitNotifiers; |
|
176 |
|
177 /** |
|
178 * Own |
|
179 * USB indicator |
|
180 */ |
|
181 CUsbIndicatorNotifier* iIndicatorNotifier; |
|
182 }; |
|
183 |
|
184 #endif // C_USBNOTIFMANAGER_H |
|