author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 21:19:17 +0300 | |
branch | RCL_3 |
changeset 64 | 34937ec34dac |
parent 60 | 5b3385a43d68 |
child 75 | 01504893d9cb |
permissions | -rw-r--r-- |
60 | 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: Progressdialog |
|
15 |
* |
|
16 |
*/ |
|
17 |
#include "glxprogressindicator.h" |
|
18 |
#include <glxtracer.h> |
|
19 |
#include <glxlog.h> |
|
20 |
#include <StringLoader.h> |
|
21 |
#include <AknProgressDialog.h> |
|
22 |
#include <eikprogi.h> |
|
23 |
#include <e32property.h> |
|
24 |
#include <glxuiutilities.rsg> |
|
25 |
#include "glxuiutility.h" |
|
26 |
const TInt KPeriodicStartDelay = 500000; |
|
27 |
||
28 |
||
29 |
// --------------------------------------------------------- |
|
30 |
// CGlxProgressIndicator::NewL |
|
31 |
// --------------------------------------------------------- |
|
32 |
// |
|
33 |
EXPORT_C CGlxProgressIndicator* CGlxProgressIndicator::NewL( |
|
34 |
MDialogDismisedObserver& aGlxGridViewNotifyObserver) |
|
35 |
{ |
|
36 |
TRACER("CGlxProgressIndicator::NewL()"); |
|
37 |
CGlxProgressIndicator* self = CGlxProgressIndicator::NewLC( |
|
38 |
aGlxGridViewNotifyObserver); |
|
39 |
CleanupStack::Pop(self); |
|
40 |
return self; |
|
41 |
} |
|
42 |
||
43 |
// --------------------------------------------------------- |
|
44 |
// CGlxProgressIndicator::NewLC |
|
45 |
// --------------------------------------------------------- |
|
46 |
// |
|
47 |
CGlxProgressIndicator* CGlxProgressIndicator::NewLC( |
|
48 |
MDialogDismisedObserver& aGlxGridViewNotifyObserver) |
|
49 |
{ |
|
50 |
TRACER("CGlxProgressIndicator::NewLC()"); |
|
51 |
CGlxProgressIndicator* self = new (ELeave) CGlxProgressIndicator( |
|
52 |
aGlxGridViewNotifyObserver); |
|
53 |
CleanupStack::PushL(self); |
|
54 |
self->ConstructL(); |
|
55 |
return self; |
|
56 |
} |
|
57 |
||
58 |
// --------------------------------------------------------- |
|
59 |
// CGlxProgressIndicator::CGlxProgressIndicator |
|
60 |
// --------------------------------------------------------- |
|
61 |
// |
|
62 |
CGlxProgressIndicator::CGlxProgressIndicator( |
|
63 |
MDialogDismisedObserver& aGlxGridViewNotifyObserver) : |
|
64 |
iGlxGridViewNotifyObserver(aGlxGridViewNotifyObserver) |
|
65 |
{ |
|
66 |
} |
|
67 |
||
68 |
// --------------------------------------------------------- |
|
69 |
// CGlxProgressIndicator::~CGlxProgressIndicator |
|
70 |
// --------------------------------------------------------- |
|
71 |
// |
|
72 |
CGlxProgressIndicator::~CGlxProgressIndicator() |
|
73 |
{ |
|
74 |
TRACER("CGlxProgressIndicator::~CGlxProgressIndicator()"); |
|
75 |
if (iProgressbarTicker) |
|
76 |
{ |
|
77 |
iProgressbarTicker->Cancel(); |
|
78 |
delete iProgressbarTicker; |
|
79 |
iProgressbarTicker = NULL; |
|
80 |
} |
|
81 |
||
82 |
// Stop force generation of thumbnails when progress dialog is dismissed |
|
83 |
if (iUiUtility) |
|
84 |
{ |
|
85 |
iUiUtility->StopTNMDaemon(); |
|
86 |
iUiUtility->Close(); |
|
87 |
} |
|
88 |
} |
|
89 |
||
90 |
// --------------------------------------------------------- |
|
91 |
// CGlxProgressIndicator::ConstructL |
|
92 |
// --------------------------------------------------------- |
|
93 |
// |
|
94 |
void CGlxProgressIndicator::ConstructL() |
|
95 |
{ |
|
96 |
TRACER("CGlxProgressIndicator::ConstructL()"); |
|
97 |
||
98 |
iUiUtility = CGlxUiUtility::UtilityL(); |
|
99 |
||
100 |
iUiUtility->StartTNMDaemon(); |
|
101 |
||
102 |
if (!iProgressbarTicker) |
|
103 |
{ |
|
104 |
iProgressbarTicker = CPeriodic::NewL(CActive::EPriorityStandard); |
|
105 |
} |
|
106 |
||
107 |
iFinalCount = iUiUtility->GetItemsLeftCount(); |
|
108 |
GLX_LOG_INFO1("final count in viewactivate = %d",iFinalCount); |
|
109 |
} |
|
110 |
||
111 |
||
112 |
// ----------------------------------------------------------------------------- |
|
113 |
// Callback from periodic timer |
|
114 |
// ----------------------------------------------------------------------------- |
|
115 |
// |
|
116 |
TInt CGlxProgressIndicator::PeriodicCallbackL(TAny* aPtr ) |
|
117 |
{ |
|
118 |
TRACER("CGlxProgressIndicator::PeriodicCallbackL"); |
|
119 |
static_cast<CGlxProgressIndicator*> (aPtr)->DisplayProgressBarL(); |
|
120 |
return KErrNone; |
|
121 |
} |
|
122 |
||
123 |
// ----------------------------------------------------------------------------- |
|
124 |
// Callback from periodic timer-- non static |
|
125 |
// ----------------------------------------------------------------------------- |
|
126 |
// |
|
127 |
inline void CGlxProgressIndicator::DisplayProgressBarL() |
|
128 |
{ |
|
129 |
TRACER("CGlxProgressIndicator::DisplayProgressBarL"); |
|
130 |
TInt itemsLeft = iUiUtility->GetItemsLeftCount(); |
|
131 |
GLX_LOG_INFO2("DisplayProgressBarL itemsLeft (%d),iFinalCount (%d) ", |
|
132 |
itemsLeft,iFinalCount); |
|
133 |
UpdateProgressBar(); |
|
134 |
if (!itemsLeft && (itemsLeft != KErrNotReady)) |
|
135 |
{ |
|
136 |
// stop TNM daemon once all the imgs are processed. |
|
137 |
iUiUtility->StopTNMDaemon(); |
|
138 |
if (iProgressbarTicker->IsActive()) |
|
139 |
{ |
|
140 |
iProgressbarTicker->Cancel(); |
|
141 |
} |
|
142 |
StartProgressNoteL(iFinalCount, EFalse); |
|
143 |
} |
|
144 |
} |
|
145 |
||
146 |
// ----------------------------------------------------------------------------- |
|
147 |
// StartProgressNoteL |
|
148 |
// ----------------------------------------------------------------------------- |
|
149 |
// |
|
150 |
void CGlxProgressIndicator::StartProgressNoteL(TInt aFinalValue, TBool aShow) |
|
151 |
{ |
|
152 |
TRACER("CGlxProgressIndicator::StartProgressNoteL()"); |
|
153 |
//for MMC insert case need to know the count.so start Daemon. |
|
154 |
iUiUtility->StartTNMDaemon(); |
|
155 |
||
156 |
TInt itemsLeft = iUiUtility->GetItemsLeftCount(); |
|
157 |
if (aShow) |
|
158 |
{ |
|
159 |
if (!iProgressDialog) |
|
160 |
{ |
|
161 |
iProgressDialog = new (ELeave) CAknProgressDialog( |
|
162 |
(reinterpret_cast<CEikDialog**> (&iProgressDialog)), |
|
163 |
ETrue); |
|
164 |
} |
|
165 |
iProgressDialog->PrepareLC(R_PROGRESS_NOTE); |
|
166 |
||
167 |
iProgressInfo = iProgressDialog->GetProgressInfoL(); |
|
168 |
||
169 |
iProgressDialog->SetCallback(this); |
|
170 |
||
171 |
HBufC* processingInfo = StringLoader::LoadLC( |
|
172 |
R_GLX_MAIN_LIST_VIEW_PROCESSING_DIALOG); |
|
173 |
iProgressDialog->SetTextL(*processingInfo); |
|
174 |
CleanupStack::PopAndDestroy(processingInfo); |
|
175 |
iProgressInfo->SetFinalValue(aFinalValue); |
|
176 |
iProgressInfo->SetAndDraw(iFinalCount - itemsLeft); |
|
177 |
iProgressDialog->RunLD(); |
|
178 |
} |
|
179 |
else |
|
180 |
{ |
|
181 |
iProgressDialog->ProcessFinishedL(); |
|
182 |
if (iProgressDialog) |
|
183 |
{ |
|
184 |
iProgressDialog = NULL; |
|
185 |
iProgressInfo = NULL; |
|
186 |
} |
|
187 |
} |
|
188 |
} |
|
189 |
||
190 |
// ----------------------------------------------------------------------------- |
|
191 |
// UpdateProgressBar |
|
192 |
// ----------------------------------------------------------------------------- |
|
193 |
// |
|
194 |
void CGlxProgressIndicator::UpdateProgressBar() |
|
195 |
{ |
|
196 |
TRACER("CGlxProgressIndicator::UpdateProgressBar()"); |
|
197 |
if (iProgressInfo) |
|
198 |
{ |
|
199 |
/* |
|
200 |
* to show a number string in the progress bar use the below code |
|
201 |
* in rss it should have %d or %N format |
|
202 |
* TBuf<256> text; |
|
203 |
* GlxGeneralUiUtilities::FormatString(text,*processingInfo,-1,count,ETrue); |
|
204 |
* CleanupStack::PopAndDestroy(processingInfo); |
|
205 |
*/ |
|
206 |
iProgressInfo->SetAndDraw(CalculateDisplayBarIncrement()); |
|
207 |
} |
|
208 |
} |
|
209 |
||
210 |
// ----------------------------------------------------------------------------- |
|
211 |
// DialogDismissedL |
|
212 |
// ----------------------------------------------------------------------------- |
|
213 |
// |
|
214 |
void CGlxProgressIndicator::DialogDismissedL(TInt /*aButtonId*/) |
|
215 |
{ |
|
216 |
TRACER("CGlxProgressIndicator::DialogDismissedL()"); |
|
217 |
if (iProgressbarTicker) |
|
218 |
{ |
|
219 |
iProgressbarTicker->Cancel(); |
|
220 |
delete iProgressbarTicker; |
|
221 |
iProgressbarTicker = NULL; |
|
222 |
} |
|
223 |
iProgressDialog = NULL; |
|
224 |
iProgressInfo = NULL; |
|
64
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
225 |
iGlxGridViewNotifyObserver.HandleDialogDismissedL(); |
60 | 226 |
} |
227 |
||
228 |
// ----------------------------------------------------------------------------- |
|
229 |
// CalculateDisplayBarIncrement |
|
230 |
// ----------------------------------------------------------------------------- |
|
231 |
// |
|
232 |
TInt CGlxProgressIndicator::CalculateDisplayBarIncrement() |
|
233 |
{ |
|
234 |
TRACER("CGlxProgressIndicator::CalculateDisplayBarIncrement()"); |
|
235 |
||
236 |
TInt itemsLeft = iUiUtility->GetItemsLeftCount(); |
|
237 |
||
238 |
if ((iFinalCount < itemsLeft) && (itemsLeft != KErrNotReady)) |
|
239 |
{ |
|
240 |
iProgressInfo->SetFinalValue(itemsLeft); |
|
241 |
iFinalCount = itemsLeft; |
|
242 |
} |
|
243 |
GLX_LOG_INFO1("CalculateDisplayBarIncrement = %d ", |
|
244 |
(iFinalCount - itemsLeft)); |
|
245 |
// If TNM is still in harvesting mode, return 0. |
|
246 |
// When the actual count is coming return the difference to update the info-bar |
|
247 |
||
248 |
GLX_LOG_INFO1("CalculateDisplayBarIncrement = %d ",(iFinalCount - itemsLeft)); |
|
249 |
return ((itemsLeft == KErrNotReady) ? 0 :(iFinalCount - itemsLeft)); |
|
250 |
} |
|
251 |
||
252 |
// ----------------------------------------------------------------------------- |
|
253 |
// ShowProgressbar |
|
254 |
// ----------------------------------------------------------------------------- |
|
255 |
// |
|
256 |
void EXPORT_C CGlxProgressIndicator::ShowProgressbarL() |
|
257 |
{ |
|
258 |
TRACER("CGlxProgressIndicator::ShowProgressbarL"); |
|
64
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
259 |
if (iProgressDialog) |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
260 |
{ |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
261 |
GLX_DEBUG1("Glx: ShowProgressbarL() - Already displayed. No need to Re-create it!"); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
262 |
return; |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
263 |
} |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
264 |
|
60 | 265 |
TInt itemsLeft = iUiUtility->GetItemsLeftCount(); |
266 |
GLX_DEBUG3("ShowProgressbarL itemsLeft(%d), iFinalCount(%d)", itemsLeft, |
|
267 |
iFinalCount); |
|
268 |
||
269 |
if (iFinalCount < itemsLeft) |
|
270 |
{ |
|
271 |
/* |
|
272 |
*if user is in List view and inserts the MMC,update the total count |
|
273 |
*/ |
|
274 |
iFinalCount = itemsLeft; |
|
275 |
} |
|
276 |
||
277 |
if ((itemsLeft == KErrNotReady) || iFinalCount) |
|
278 |
{ |
|
279 |
StartProgressNoteL(iFinalCount, ETrue); |
|
280 |
if (!iProgressbarTicker) |
|
281 |
{ |
|
282 |
iProgressbarTicker = CPeriodic::NewL(CActive::EPriorityStandard); |
|
283 |
} |
|
284 |
if (!iProgressbarTicker->IsActive()) |
|
285 |
{ |
|
286 |
iProgressbarTicker->Start(KPeriodicStartDelay, |
|
287 |
KPeriodicStartDelay, TCallBack(&PeriodicCallbackL, |
|
288 |
static_cast<TAny*> (this))); |
|
289 |
} |
|
290 |
} |
|
291 |
else |
|
292 |
{ |
|
293 |
GLX_LOG_INFO("Reset the RProperty flag to EFalse"); |
|
294 |
iUiUtility->StopTNMDaemon(); |
|
295 |
} |
|
296 |
} |
|
297 |
||
298 |
// ----------------------------------------------------------------------------- |
|
299 |
// DismissProgressDialog |
|
300 |
// ----------------------------------------------------------------------------- |
|
301 |
// |
|
302 |
EXPORT_C void CGlxProgressIndicator::DismissProgressDialog() |
|
303 |
{ |
|
304 |
TRACER("CGlxProgressIndicator::DismissProgressDialog"); |
|
305 |
||
306 |
if (iProgressDialog) |
|
307 |
{ |
|
308 |
TRAP_IGNORE(iProgressDialog->ProcessFinishedL()); |
|
309 |
} |
|
310 |
} |
|
311 |
||
312 |
// ----------------------------------------------------------------------------- |
|
313 |
// ControlTNDaemon |
|
314 |
// ----------------------------------------------------------------------------- |
|
315 |
// |
|
316 |
EXPORT_C void CGlxProgressIndicator::ControlTNDaemon(TBool aStatus) |
|
317 |
{ |
|
318 |
TRACER("CGlxProgressIndicator::ControlTNDaemon"); |
|
319 |
GLX_DEBUG2("CGlxProgressIndicator::ControlTNDaemon(%d)", aStatus); |
|
320 |
if (aStatus) |
|
321 |
{ |
|
322 |
iUiUtility->StartTNMDaemon(); |
|
323 |
} |
|
324 |
else |
|
325 |
{ |
|
326 |
iUiUtility->StopTNMDaemon(); |
|
327 |
} |
|
328 |
} |