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