1 /* |
|
2 * Copyright (c) 2010 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: Class for managing an actual user notification or query. |
|
15 * It hides UI framework-specifics in a private class. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef BLUETOOTHNOTIFICATION_H |
|
20 #define BLUETOOTHNOTIFICATION_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <hb/hbcore/hbdevicedialogsymbian.h> |
|
24 #include "bluetoothdevicedialogs.h" |
|
25 #include "btnotificationresult.h" |
|
26 #include "bluetoothtrace.h" |
|
27 |
|
28 class CBTNotificationManager; |
|
29 class CHbSymbianVariantMap; |
|
30 |
|
31 /** |
|
32 * CBluetoothNotification manages and controls notifications. |
|
33 * |
|
34 * @since Symbian^4 |
|
35 */ |
|
36 NONSHARABLE_CLASS( CBluetoothNotification ) : public CBase, |
|
37 public MHbDeviceDialogObserver |
|
38 { |
|
39 |
|
40 |
|
41 public: |
|
42 |
|
43 /** |
|
44 * Two-phased constructor. |
|
45 * @param aManager Reference to the notification manager. |
|
46 * @param aObserver Reference to our observer. |
|
47 */ |
|
48 static CBluetoothNotification* NewL( CBTNotificationManager* aManager ); |
|
49 |
|
50 /** |
|
51 * Destructor. |
|
52 */ |
|
53 virtual ~CBluetoothNotification(); |
|
54 |
|
55 /** |
|
56 * Sets the receiver of callbacks. |
|
57 * |
|
58 * @since Symbian^4 |
|
59 * @param aObserver Pointer to the callback interface. |
|
60 */ |
|
61 inline void SetObserver( MBTNotificationResult* aObserver ) |
|
62 { iObserver = aObserver; } |
|
63 |
|
64 /** |
|
65 * Clears the receiver of callbacks. |
|
66 * |
|
67 * @since Symbian^4 |
|
68 */ |
|
69 inline void RemoveObserver() |
|
70 { iObserver = NULL; } |
|
71 |
|
72 /** |
|
73 * Getter for the notification type. |
|
74 * |
|
75 * @since Symbian^4 |
|
76 * @return Notification type. |
|
77 */ |
|
78 inline TBluetoothDialogParams::TBTDialogType NotificationType() |
|
79 { return iType; } |
|
80 |
|
81 /** |
|
82 * Getter for the resource id. |
|
83 * |
|
84 * @since Symbian^4 |
|
85 * @return Resource identifier. |
|
86 */ |
|
87 inline TBTDialogResourceId ResourceId() |
|
88 { return iResourceId; } |
|
89 |
|
90 inline CHbSymbianVariantMap* Data() |
|
91 { return iNotificationData; } |
|
92 |
|
93 /** |
|
94 * Sets the type of notification (query, note, etc). |
|
95 * |
|
96 * @since Symbian^4 |
|
97 * @param aType The type of the notification. |
|
98 * @param aResourceId The id of the resource to be shown. |
|
99 * @return Error code |
|
100 */ |
|
101 inline void SetNotificationType( TBluetoothDialogParams::TBTDialogType aType, |
|
102 TBTDialogResourceId aResourceId ) |
|
103 { iType = aType; iResourceId = aResourceId; } |
|
104 |
|
105 /** |
|
106 * Sets the data to be shown to the user. |
|
107 * |
|
108 * @since Symbian^4 |
|
109 * @param aType Identifies the type of data parameter to be set. |
|
110 * @param aData Additional descriptor data to be shown in the dialog. |
|
111 * @return Error code |
|
112 */ |
|
113 TInt SetData( TInt aDataType, const TDesC& aData ); |
|
114 |
|
115 /** |
|
116 * Sets the data to be shown to the user. |
|
117 * |
|
118 * @since Symbian^4 |
|
119 * @param aType Identifies the type of data parameter to be set. |
|
120 * @param aData Additional integer data to be shown in the dialog. |
|
121 * @return Error code |
|
122 */ |
|
123 TInt SetData( TInt aDataType, TInt aData ); |
|
124 |
|
125 /** |
|
126 * Updates the data to be shown to the user. |
|
127 * |
|
128 * @since Symbian^4 |
|
129 * @param ?arg1 ?description |
|
130 * @return Error code |
|
131 */ |
|
132 TInt Update( const TDesC& aData =KNullDesC ); |
|
133 |
|
134 /** |
|
135 * Show the notification, which means that it |
|
136 * is added to the queue. |
|
137 * |
|
138 * @since Symbian^4 |
|
139 * @param ?arg1 ?description |
|
140 * @return Error code |
|
141 */ |
|
142 void ShowL(); |
|
143 |
|
144 /** |
|
145 * Stop showing the notification. |
|
146 * |
|
147 * @since Symbian^4 |
|
148 * @param ?arg1 ?description |
|
149 * @return Error code |
|
150 */ |
|
151 TInt Close(); |
|
152 |
|
153 |
|
154 private: |
|
155 |
|
156 CBluetoothNotification( CBTNotificationManager* aManager ); |
|
157 |
|
158 void ConstructL(); |
|
159 |
|
160 /** |
|
161 * Sets the data to be shown to the user, leaves on error. |
|
162 * |
|
163 * @since Symbian^4 |
|
164 * @param aType Identifies the type of data parameter to be set. |
|
165 * @param aData Additional descriptor data to be shown in the dialog. |
|
166 */ |
|
167 void SetDataL( TInt aType, const TDesC& aData ); |
|
168 |
|
169 /** |
|
170 * Sets the data to be shown to the user, leaves on error. |
|
171 * |
|
172 * @since Symbian^4 |
|
173 * @param aType Identifies the type of data parameter to be set. |
|
174 * @param aData Additional integer data to be shown in the dialog. |
|
175 */ |
|
176 void SetDataL( TInt aType, TInt aData ); |
|
177 |
|
178 /** |
|
179 * From MHbDeviceDialogObserver. |
|
180 * This callback is called when data is received from a device dialog. |
|
181 * |
|
182 * @since Symbian^4 |
|
183 * @param aData contains data from the dialog plugin. |
|
184 */ |
|
185 virtual void DataReceived( CHbSymbianVariantMap& aData ); |
|
186 |
|
187 /** |
|
188 * From MHbDeviceDialogObserver. |
|
189 * This callback is called when a device dialog is closed. Any data sent by |
|
190 * the dialog is indicated by the dataReceived() callback. If no observer is |
|
191 * set in CHbDeviceDialogSymbian::Show the latest data can be retrieved with |
|
192 * CHbDeviceDialogSymbian::receivedData(). |
|
193 * |
|
194 * @since Symbian^4 |
|
195 * @param aCompletionCode gives the result of the dialog completion. Code can be |
|
196 * either Symbian error code or device dialog error code. |
|
197 */ |
|
198 virtual void DeviceDialogClosed( TInt aCompletionCode ); |
|
199 |
|
200 #ifdef BLUETOOTHTRACE_ENABLED |
|
201 void debugHbSymbianVariantMap( CHbSymbianVariantMap& aData); |
|
202 #endif // BLUETOOTHTRACE_ENABLED |
|
203 |
|
204 private: // data |
|
205 |
|
206 /** |
|
207 * The type of notification currently showing. |
|
208 */ |
|
209 TBluetoothDialogParams::TBTDialogType iType; |
|
210 |
|
211 /** |
|
212 * The id of the resource (string identifier) |
|
213 * of the currently showing notification. |
|
214 */ |
|
215 TBTDialogResourceId iResourceId; |
|
216 |
|
217 /** |
|
218 * Reference to the queue manager. |
|
219 * Not own. |
|
220 */ |
|
221 CBTNotificationManager* iManager; |
|
222 |
|
223 /** |
|
224 * Reference to the receiver of the results. |
|
225 * Not own. |
|
226 */ |
|
227 MBTNotificationResult* iObserver; |
|
228 |
|
229 /** |
|
230 * The data to be shown to the user in a device dialog. |
|
231 * Own. |
|
232 */ |
|
233 CHbSymbianVariantMap* iNotificationData; |
|
234 |
|
235 /** |
|
236 * Buffer for receiving return data from the notifier. |
|
237 */ |
|
238 CHbSymbianVariantMap* iReturnData; |
|
239 |
|
240 /** |
|
241 * Session object with the notification server. |
|
242 * Own. |
|
243 */ |
|
244 CHbDeviceDialogSymbian *iDialog; |
|
245 |
|
246 BTUNITTESTHOOK |
|
247 |
|
248 }; |
|
249 |
|
250 #endif // BLUETOOTHNOTIFICATION_H |
|