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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef COBEXUTILSDIALOG_H |
|
20 #define COBEXUTILSDIALOG_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 #include <hbdeviceprogressdialogsymbian.h> |
|
25 #include <hbdevicedialogsymbian.h> |
|
26 #include <hbdevicemessageboxsymbian.h> |
|
27 #include <hbsymbianvariant.h> |
|
28 |
|
29 class CObexUtilsDialogTimer; |
|
30 |
|
31 enum TButtonId |
|
32 { |
|
33 ECancelButton = -1, |
|
34 EYesButton, |
|
35 ENoButton |
|
36 }; |
|
37 /** |
|
38 * An observer interface for asking progress status of an operation using |
|
39 * a progress dialog. |
|
40 */ |
|
41 NONSHARABLE_CLASS( MObexUtilsProgressObserver ) |
|
42 { |
|
43 public: |
|
44 |
|
45 /** |
|
46 * Returns the progress status of the operation. |
|
47 * @since 2.6 |
|
48 * @return A progress value relative to final value. |
|
49 */ |
|
50 virtual TInt GetProgressStatus() = 0; |
|
51 }; |
|
52 |
|
53 // CLASS DECLARATION |
|
54 |
|
55 /** |
|
56 * An observer interface for informing about dialog events. |
|
57 */ |
|
58 NONSHARABLE_CLASS( MObexUtilsDialogObserver ) |
|
59 { |
|
60 public: |
|
61 |
|
62 /** |
|
63 * Informs the observer that a dialog has been dismissed. |
|
64 * @since 2.6 |
|
65 * todo check whether the parameter is required |
|
66 * @param aButtonId The button that was used to dismiss the dialog. |
|
67 */ |
|
68 virtual void DialogDismissed(TInt aButtonId) = 0; //TInt aButtonId |
|
69 }; |
|
70 |
|
71 |
|
72 // CLASS DECLARATION |
|
73 |
|
74 /** |
|
75 * A class for launching and managing dialogs. |
|
76 */ |
|
77 NONSHARABLE_CLASS( CObexUtilsDialog ) : public CBase, |
|
78 public MHbDeviceProgressDialogObserver, |
|
79 public MHbDeviceDialogObserver, |
|
80 public MHbDeviceMessageBoxObserver |
|
81 { |
|
82 public:// Constructors and destructor |
|
83 |
|
84 /** |
|
85 * Two-phased constructor. |
|
86 */ |
|
87 IMPORT_C static CObexUtilsDialog* NewL( |
|
88 MObexUtilsDialogObserver* aObserverPtr ); |
|
89 |
|
90 IMPORT_C static CObexUtilsDialog* NewLC( |
|
91 MObexUtilsDialogObserver* aObserverPtr ); |
|
92 |
|
93 /** |
|
94 * Destructor. |
|
95 */ |
|
96 virtual ~CObexUtilsDialog(); |
|
97 |
|
98 public: // New functions |
|
99 |
|
100 |
|
101 /** |
|
102 * Launches a progress dialog. |
|
103 * @param aObserverPtr A pointer to progress observer. A NULL pointer if |
|
104 the progress dialog is updated manually. |
|
105 * @param aFileCount Total number of files to be sent. |
|
106 * @param aDeviceName Device Name to which files to be sent. |
|
107 * @param aTimeoutValue A value telling how often should the dialog be |
|
108 updated. Relevant only if observer is given. |
|
109 */ |
|
110 IMPORT_C void LaunchProgressDialogL( |
|
111 MObexUtilsProgressObserver* aObserverPtr, TInt aFileCount, |
|
112 const TDesC& aDeviceName, TInt aTimeoutValue ); |
|
113 |
|
114 /** |
|
115 * Updates the progress dialog with new file information when multiples files are sent. |
|
116 * @param aFileSize Size of the file to be sent |
|
117 * @param aFileIndex Index of the file to be sent |
|
118 * @param aFileName Name of the file to be sent. |
|
119 */ |
|
120 IMPORT_C void UpdateProgressNoteL( TInt aFileSize,TInt aFileIndex, const TDesC& aFileName ); |
|
121 |
|
122 /** |
|
123 * Launches a wait dialog. |
|
124 * @param aDisplayText Text that needs to be displayed. |
|
125 */ |
|
126 IMPORT_C void LaunchWaitDialogL( const TDesC& aDisplayText ); |
|
127 |
|
128 /** |
|
129 * Cancels a wait dialog if one exists. |
|
130 * @since 2.6 |
|
131 * @return None. |
|
132 */ |
|
133 IMPORT_C void CancelWaitDialog(); |
|
134 |
|
135 /** |
|
136 * Cancels a wait progress dialog if one exists. |
|
137 * @since 2.6 |
|
138 * @return None. |
|
139 */ |
|
140 IMPORT_C void CancelProgressDialog(); |
|
141 |
|
142 /** |
|
143 * Updates a progress dialog with the latest progress value |
|
144 * @param aValue A progress value relative to final value. |
|
145 * @return None |
|
146 */ |
|
147 IMPORT_C void UpdateProgressDialogL( TInt aProgressValue ); |
|
148 |
|
149 /** |
|
150 * Show a query note |
|
151 * @param aConfirmText text for the note. |
|
152 * @return None |
|
153 */ |
|
154 IMPORT_C void LaunchQueryDialogL( const TDesC& aConfirmText ); |
|
155 |
|
156 /** |
|
157 * Shows an error note. |
|
158 * @param aTextId A resource id for the note. |
|
159 * @return None. |
|
160 */ |
|
161 IMPORT_C void ShowErrorNoteL( const TDesC& aErrorText ); |
|
162 |
|
163 /** |
|
164 * Shows an information note. |
|
165 * @param aTextId A resource id for the note. |
|
166 * @return None. |
|
167 */ |
|
168 IMPORT_C void ShowInformationNoteL( const TDesC& aInfoText ); |
|
169 |
|
170 public: // New functions (not exported) |
|
171 |
|
172 /** |
|
173 * Updates the progress dialog. |
|
174 * @return None. |
|
175 */ |
|
176 void UpdateProgressDialog(); |
|
177 |
|
178 private: // Functions from base classes |
|
179 |
|
180 /** |
|
181 * From MHbDeviceProgressDialogObserver called when dialog is closed by pressing the "cancel" button |
|
182 * @param aDialog Pointer to dialog that was cancelled. |
|
183 * @return None. |
|
184 */ |
|
185 void ProgressDialogCancelled(const CHbDeviceProgressDialogSymbian* aDialog); |
|
186 |
|
187 /** |
|
188 * From MHbDeviceProgressDialogObserver called when a device progress dialog is has closed |
|
189 * @param aDialog Pointer to dialog instance that has closed. |
|
190 * @return None. |
|
191 */ |
|
192 void ProgressDialogClosed(const CHbDeviceProgressDialogSymbian* aDialog ) ; |
|
193 |
|
194 /** |
|
195 * From MHbDeviceDialogObserver called when data is received from a device dialog |
|
196 * @param aDialog Pointer to dialog instance that has closed. |
|
197 * @return None. |
|
198 */ |
|
199 void DataReceived(CHbSymbianVariantMap& aData); |
|
200 |
|
201 /** |
|
202 * From MHbDeviceDialogObserver called when a device dialog is closed |
|
203 * @param aData contains data from the dialog plugin. |
|
204 * @return None. |
|
205 */ |
|
206 void DeviceDialogClosed(TInt aCompletionCode); |
|
207 |
|
208 /** |
|
209 * from base class MHbDeviceMessageBoxObserver |
|
210 * @param aMessageBox Pointer to dialog instance that has closed. |
|
211 * @param aButton the id of the button the user pressed |
|
212 */ |
|
213 void MessageBoxClosed(const CHbDeviceMessageBoxSymbian *aMessageBox, |
|
214 CHbDeviceMessageBoxSymbian::TButtonId aButton); |
|
215 |
|
216 private: |
|
217 |
|
218 /** |
|
219 * C++ default constructor. |
|
220 */ |
|
221 CObexUtilsDialog( MObexUtilsDialogObserver* aObserverPtr ); |
|
222 |
|
223 /** |
|
224 * By default Symbian OS constructor is private. |
|
225 */ |
|
226 void ConstructL(); |
|
227 |
|
228 /** |
|
229 * Add a data item into the given CHbSymbianVariantMap. |
|
230 * @param aMap the instance to which the data item will be added. |
|
231 * @param aKey the key of the data item. |
|
232 * @param aData the value of the data item |
|
233 * @param aDataType the data-type of the data item |
|
234 */ |
|
235 void AddDataL(CHbSymbianVariantMap* aMap, const TDesC& aKey, |
|
236 const TAny* aData, CHbSymbianVariant::TType aDataType); |
|
237 |
|
238 /** |
|
239 * Creates and shows a message box. |
|
240 * @param aType the type of the message box to create. |
|
241 * @param aText the text to be shown in the message box |
|
242 * @param aObserver the observer that receives the events from the |
|
243 * message box |
|
244 * @param aTimeout the timeout value of the message box |
|
245 */ |
|
246 CHbDeviceMessageBoxSymbian* CreateAndShowMessageBoxL( |
|
247 CHbDeviceMessageBoxSymbian::TType aType, |
|
248 const TDesC& aText, |
|
249 MHbDeviceMessageBoxObserver* aObserver, |
|
250 TInt aTimeout ); |
|
251 |
|
252 private: // Data |
|
253 |
|
254 CHbDeviceDialogSymbian *iProgressDialog; |
|
255 CHbDeviceProgressDialogSymbian* iWaitDialog; |
|
256 CHbDeviceMessageBoxSymbian* iMessageBox; |
|
257 |
|
258 CObexUtilsDialogTimer* iObexDialogTimer; |
|
259 TInt iFileIndex; |
|
260 TInt iFileCount; |
|
261 RBuf iDeviceName; |
|
262 |
|
263 // Not Owned |
|
264 // |
|
265 MObexUtilsProgressObserver* iProgressObserverPtr; |
|
266 MObexUtilsDialogObserver* iDialogObserverPtr; |
|
267 }; |
|
268 |
|
269 #endif // COBEXUTILSDIALOG_H |
|
270 |
|
271 // End of File |
|