|
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: Manages notifiers |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_USBNOTIFMANAGER_H |
|
20 #define C_USBNOTIFMANAGER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 // forward declaration |
|
25 class CUsbNotifier; |
|
26 class CUsbIndicatorNotifier; |
|
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 */ |
|
120 static CUsbNotifManager* NewL(); |
|
121 |
|
122 /** |
|
123 * Destructor |
|
124 */ |
|
125 virtual ~CUsbNotifManager(); |
|
126 |
|
127 /** |
|
128 * Shows notifier |
|
129 * @param aCat Category |
|
130 * @param aNotifId notifier id |
|
131 * @param aObserver will receive notifications |
|
132 */ |
|
133 void ShowNotifierL(TUid aCat, TUint aNotifId, |
|
134 MWaitNotifierObserver* aObserver = NULL); |
|
135 |
|
136 /** |
|
137 * Changes USB indicator to blink or not |
|
138 * @param aBlinking ETrue if want to make it blinking, EFalse otherwise |
|
139 */ |
|
140 void BlinkIndicatorL(TBool aBlinking); |
|
141 |
|
142 /** |
|
143 * Shows or hides usb indicator |
|
144 * @param aVisible ETRue is show, EFalse id hide |
|
145 */ |
|
146 void ShowIndicatorL(TBool aVisible); |
|
147 |
|
148 /** |
|
149 * Closes and deletes all the notifiers |
|
150 */ |
|
151 void CloseAllNotifiers(); |
|
152 |
|
153 /** |
|
154 * Calls back Notifier show is over |
|
155 * @param aWaitNotifier wait notifier |
|
156 * @param aResult result (was any errors or not) |
|
157 * @param aFeedback user press (cancel or any other) |
|
158 */ |
|
159 void NotifierShowCompletedL(CUsbNotifier* aWaitNotifier, TInt aResult, |
|
160 TInt aFeedback); |
|
161 |
|
162 private: |
|
163 |
|
164 /** |
|
165 * Default construction |
|
166 */ |
|
167 CUsbNotifManager(); |
|
168 |
|
169 /** |
|
170 * Second phase construction |
|
171 */ |
|
172 void ConstructL(); |
|
173 |
|
174 private: |
|
175 // data |
|
176 |
|
177 /** |
|
178 * RNotifier API |
|
179 */ |
|
180 RNotifier iNotifier; |
|
181 |
|
182 /** |
|
183 * List of notifiers waiting for user action |
|
184 */ |
|
185 RPointerArray<CWaitNotifierInfo> iWaitNotifiers; |
|
186 |
|
187 /** |
|
188 * Own |
|
189 * Notifier for showing or blinking Usb indicator |
|
190 */ |
|
191 CUsbIndicatorNotifier* iIndicatorNotifier; |
|
192 }; |
|
193 |
|
194 #endif // C_USBNOTIFMANAGER_H |