|
1 /* |
|
2 * Copyright (c) 2002-2007 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: Uses notification framework to show a global progress dialog. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __AKNGLOBALPROGRESSDIALOG_H__ |
|
19 #define __AKNGLOBALPROGRESSDIALOG_H__ |
|
20 |
|
21 #include <AknNotify.h> |
|
22 #include <AknNotifyStd.h> |
|
23 #include <AknProgressDialog.h> |
|
24 #include <AknsItemID.h> |
|
25 |
|
26 class CAknSDData; |
|
27 |
|
28 /** |
|
29 * CAknGlobalProgressDialog |
|
30 * Uses notification framework to show a global progress dialog. |
|
31 * Usage: |
|
32 * Create an active object, start it and pass its TRequestStatus as a |
|
33 * parameter to ShowProgressDialogL. After the dialog gets dismissed, |
|
34 * the request status will hold the id of the pressed softkey. E.g. |
|
35 * If the user selected Cancel, the request status will hold -1. |
|
36 * |
|
37 * Example 1. Construct global progress dialog and set icon and image. |
|
38 * |
|
39 * iGlobalProgressDialog = CAknGlobalProgressDialog::NewL(); |
|
40 * iGlobalProgressDialog->SetIconL( |
|
41 * iIconText, |
|
42 * iIconFile, |
|
43 * iIconId, |
|
44 * iIconMaskId); |
|
45 * |
|
46 * iGlobalProgressDialog->SetImageL( |
|
47 * iImageFile, |
|
48 * iImageId, |
|
49 * iImageMaskId); |
|
50 * |
|
51 * Example 2. Show the global progress dialog: |
|
52 * |
|
53 * iGlobalProgressDialog->ShowMsgQueryL( |
|
54 * iObserver->iStatus, |
|
55 * iPrompt, |
|
56 * R_AVKON_SOFTKEYS_OK_CANCEL, |
|
57 * iFinalValue, |
|
58 * CAknQueryDialog::EConfirmationTone ); |
|
59 * |
|
60 * Example 3. Update the progress (current and final value of the process). |
|
61 * |
|
62 * iGlobalProgressDialog->UpdateProgressDialog( 100, 500 ); |
|
63 * |
|
64 * Example 4. Finish the progress |
|
65 * Needs to be called everytime the process has finished. |
|
66 * Dismisses the dialog. |
|
67 * |
|
68 * iGlobalProgressDialog->ProcessFinished(); |
|
69 * |
|
70 * Example 5. Get and handle the result in active object. |
|
71 * |
|
72 * void CMyActiveObject::RunL() |
|
73 * { |
|
74 * TBuf<120> msg = _L("Received: "); |
|
75 * // iStatus.Int() holds the return value |
|
76 * msg.AppendNum( iStatus.Int() ); |
|
77 * iEnv->InfoMsg(msg); // Show infomsg |
|
78 * Cancel(); |
|
79 * } |
|
80 * |
|
81 * Example 6. Cancel the progress dialog |
|
82 * |
|
83 * iGlobalProgressDialog->CancelProgressDialog(); |
|
84 */ |
|
85 |
|
86 NONSHARABLE_CLASS(CAknGlobalProgressDialog) : public CBase |
|
87 { |
|
88 public: |
|
89 IMPORT_C static CAknGlobalProgressDialog* NewL(); |
|
90 IMPORT_C static CAknGlobalProgressDialog* NewLC(); |
|
91 IMPORT_C ~CAknGlobalProgressDialog(); |
|
92 |
|
93 /** |
|
94 * Set icon for the progress dialog |
|
95 * Must be called before ShowProgressDialogL. |
|
96 * |
|
97 * @param aIconText Icon text |
|
98 * @param aIconFile Icon file |
|
99 * @param aIconId Icon id |
|
100 * @param aIconMaskId Mask id for icon |
|
101 */ |
|
102 IMPORT_C void SetIconL( const TDesC& aIconText, |
|
103 const TDesC& aIconFile, |
|
104 TInt aIconId = 0, |
|
105 TInt aIconMaskId = -1 ); |
|
106 |
|
107 /** |
|
108 * Set image for the progress dialog |
|
109 * Must be called before ShowProgressDialogL. |
|
110 * If not set, default image will be used, |
|
111 * i.e. EMbmAvkonQgn_note_progress |
|
112 * |
|
113 * @param aImageFile Image file |
|
114 * @param aImageId Image id |
|
115 * @param aImageMaskId Mask id for Image |
|
116 */ |
|
117 IMPORT_C void SetImageL( |
|
118 const TDesC& aImageFile, |
|
119 TInt aImageId = 0, |
|
120 TInt aImageMaskId = -1 ); |
|
121 |
|
122 /** |
|
123 * Shows global progress dialog asynchronously |
|
124 * |
|
125 * @param aStatus TRequestStatus which will be completed |
|
126 * when the dialog gets dismissed |
|
127 * @param aPrompt Prompt text |
|
128 * @param aSoftkeys Softkeys resource id |
|
129 * If not set default softkeys are used. |
|
130 * i.e. R_AVKON_SOFTKEYS_CANCEL |
|
131 * @param aFinalValue Final value of the process |
|
132 * @param aTone Tone to be played after completion |
|
133 */ |
|
134 IMPORT_C void ShowProgressDialogL( |
|
135 TRequestStatus& aStatus, |
|
136 const TDesC& aPrompt, |
|
137 TInt aSoftkeys = 0, |
|
138 TInt aFinalValue = 0, |
|
139 CAknNoteDialog::TTone aTone = CAknNoteDialog::ENoTone ); |
|
140 |
|
141 /** |
|
142 * Update Progress dialog with new progress values. |
|
143 * |
|
144 * @param aValue Current value of the process. |
|
145 * @param aFinalValue Final value of the process. If not given the |
|
146 * existing value is used. |
|
147 */ |
|
148 IMPORT_C void UpdateProgressDialog( |
|
149 TInt aValue, |
|
150 TInt aFinalValue = -1 ); |
|
151 |
|
152 /** |
|
153 * ProcessFinished. |
|
154 * Dismisses the dialog. Needs to be called after the |
|
155 * process has finished. |
|
156 */ |
|
157 IMPORT_C void ProcessFinished(); |
|
158 |
|
159 /** |
|
160 * Cancel the progress dialog. |
|
161 * Cancels the request and deletes the dialog. |
|
162 */ |
|
163 IMPORT_C void CancelProgressDialog(); |
|
164 |
|
165 /** |
|
166 * @since S60 2.6 |
|
167 * Set Skin ids for note image and icon. Must be called before ShowProgressDialogL in order |
|
168 * to have effect. No need to use this method if image from avkon.mbm is used. |
|
169 * |
|
170 * @aparam aImageId SkinId for image in query. If image not found from active skin, |
|
171 * default image / SetImageL definitions used instead. |
|
172 * |
|
173 * @aparam aIconId SkinId for icon in query. If image not found from active skin, |
|
174 * default icon / SetIconL definitions used instead. |
|
175 */ |
|
176 IMPORT_C void SetImageSkinIds( TAknsItemID& aImageId, TAknsItemID& aIconId ); |
|
177 |
|
178 /** |
|
179 * @since S60 3.1 |
|
180 * Sets additional information to be sent to secondary display. |
|
181 * Takes ownership of object. |
|
182 * Must be called before sending data to notifier to have effect. |
|
183 * @internal to S60 |
|
184 * |
|
185 * @aparam aData Data to be sent to cover UI. |
|
186 */ |
|
187 IMPORT_C void SetSecondaryDisplayData(CAknSDData* aData); |
|
188 |
|
189 private: |
|
190 /** |
|
191 * Default constructor. |
|
192 */ |
|
193 CAknGlobalProgressDialog(); |
|
194 |
|
195 /** |
|
196 * ConstructL. |
|
197 */ |
|
198 void ConstructL(); |
|
199 |
|
200 /** |
|
201 * Update notifier. |
|
202 */ |
|
203 void UpdateNotifier(); |
|
204 |
|
205 private: |
|
206 // Command send to server. |
|
207 TAknGlobalQueryCmd iCmd; |
|
208 // Final value of the process. |
|
209 TInt iFinalValue; |
|
210 // Current value of the process. |
|
211 TInt iValue; |
|
212 // Handle to session with notify server. |
|
213 RNotifier iNotify; |
|
214 // Buffer used to pass parameters to server. |
|
215 CBufFlat *iBuffer; |
|
216 // Pointer to iBuffer |
|
217 TPtrC8 iBufferPtr; |
|
218 |
|
219 // Id of the image. |
|
220 TInt iImageId; |
|
221 // Id of the image's mask. |
|
222 TInt iImageMaskId; |
|
223 // Id of the icon. |
|
224 TInt iIconId; |
|
225 // Id of the icon's mask. |
|
226 TInt iIconMaskId; |
|
227 |
|
228 // Icon's text. |
|
229 HBufC* iIconText; |
|
230 // Icon file name. |
|
231 HBufC* iIconFile; |
|
232 // Image file name. |
|
233 HBufC* iImageFile; |
|
234 |
|
235 TInt iImageSkinsMajorId; |
|
236 TInt iImageSkinsMinorId; |
|
237 |
|
238 TInt iIconSkinsMajorId; |
|
239 TInt iIconSkinsMinorId; |
|
240 CAknSDData* iAknSDData; |
|
241 TBuf8<1> iResultBuf; // Not really used, but needed to prevent buffer handling errors. |
|
242 }; |
|
243 |
|
244 #endif // __AKNGLOBALPROGRESSDIALOG_H__ |