|
1 /* |
|
2 * Copyright (c) 2002-2004 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 the License "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: Dialog containing the Downloads List |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CDownloadsListDlg.h" |
|
22 #include "CDownloadUtils.h" |
|
23 #include "DownloadsListDlgObserver.h" |
|
24 #include "CDownloadsListArray.h" |
|
25 #include "DownloadMgrUiLib.hrh" |
|
26 #include "DMgrUiLibPanic.h" |
|
27 #include "UiLibLogger.h" |
|
28 #include <DownloadMgrUiLib.rsg> |
|
29 #include <e32std.h> |
|
30 #include <e32def.h> |
|
31 #include <eikmenub.h> |
|
32 #include <eikfrlb.h> |
|
33 #include <eikfrlbd.h> |
|
34 #include <aknlists.h> |
|
35 #include <StringLoader.h> |
|
36 #include <eikenv.h> |
|
37 #include <DocumentHandler.h> |
|
38 |
|
39 #include "eikon.hrh" |
|
40 |
|
41 |
|
42 // ============================ MEMBER FUNCTIONS =============================== |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CDownloadsListDlg::CDownloadsListDlg |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CDownloadsListDlg::CDownloadsListDlg( MDownloadsListDlgObserver& aDlgObserver ) |
|
49 : iMyEikonEnv( *CEikonEnv::Static() ), |
|
50 iDlgObserver( aDlgObserver ), |
|
51 iProgressiveDownload( EFalse) |
|
52 { |
|
53 } |
|
54 |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CDownloadsListDlg::CDownloadsListDlg |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CDownloadsListDlg::CDownloadsListDlg( MDownloadsListDlgObserver& aDlgObserver, TBool aProgressiveFlag ) |
|
61 : iMyEikonEnv( *CEikonEnv::Static() ), |
|
62 iDlgObserver( aDlgObserver ), |
|
63 iProgressiveDownload(aProgressiveFlag) |
|
64 { |
|
65 } |
|
66 |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CDownloadsListDlg::ConstructL |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CDownloadsListDlg::ConstructL() |
|
73 { |
|
74 CLOG_ENTERFN("CDownloadsListDlg::ConstructL"); |
|
75 |
|
76 CEikFormattedCellListBox* listBox = new (ELeave) CAknDoubleLargeGraphicPopupMenuStyleListBox; |
|
77 delete iListBox; |
|
78 iListBox = listBox; |
|
79 |
|
80 iIsMSKChangeHandled = EFalse; |
|
81 |
|
82 CAknPopupList::ConstructL( iListBox, |
|
83 R_DMUL_DOWNLOADSLIST_SOFTKEYS_OPEN, |
|
84 AknPopupLayouts::EMenuDoubleLargeGraphicWindow ); |
|
85 iListBox->SetListBoxObserver(this); |
|
86 |
|
87 TInt flags = 0; |
|
88 listBox->ConstructL( this, flags ); |
|
89 listBox->CreateScrollBarFrameL( ETrue ); |
|
90 listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, |
|
91 CEikScrollBarFrame::EAuto ); |
|
92 |
|
93 HBufC* header = StringLoader::LoadLC( R_DMUL_DOWNLOADSLIST_HEADER ); |
|
94 SetTitleL( *header ); |
|
95 CleanupStack::PopAndDestroy( header ); // header |
|
96 header = NULL; |
|
97 |
|
98 // Create menu bar |
|
99 CEikMenuBar* newMenuBar = new (ELeave) CEikMenuBar(); |
|
100 CleanupStack::PushL( newMenuBar ); |
|
101 newMenuBar->ConstructL( this, NULL, R_DMUL_DOWNLOADSLIST_MENUBAR ); |
|
102 iMyEikonEnv.EikAppUi()->AddToStackL( newMenuBar, |
|
103 ECoeStackPriorityMenu, |
|
104 ECoeStackFlagRefusesFocus ); |
|
105 iMenuBar = newMenuBar; |
|
106 CleanupStack::Pop( newMenuBar ); // now owned by this. |
|
107 |
|
108 iRefreshTimer = CPeriodic::NewL( KRefreshTimerPriority ); |
|
109 CLOG_WRITE(" iRefreshTimer created"); |
|
110 |
|
111 iDownloadUtils = CDownloadUtils::NewL(); |
|
112 |
|
113 CLOG_LEAVEFN("CDownloadsListDlg::ConstructL"); |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CDownloadsListDlg::NewL |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 CDownloadsListDlg* CDownloadsListDlg::NewL( MDownloadsListDlgObserver& aDlgObserver ) |
|
121 { |
|
122 CDownloadsListDlg* self = new ( ELeave ) CDownloadsListDlg( aDlgObserver ); |
|
123 CleanupStack::PushL( self ); |
|
124 self->ConstructL(); |
|
125 CleanupStack::Pop( self ); |
|
126 return self; |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CDownloadsListDlg::NewL |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 CDownloadsListDlg* CDownloadsListDlg::NewL( MDownloadsListDlgObserver& aDlgObserver, TBool aProgressiveFlag ) |
|
134 { |
|
135 CDownloadsListDlg* self = new ( ELeave ) CDownloadsListDlg( aDlgObserver, aProgressiveFlag ); |
|
136 CleanupStack::PushL( self ); |
|
137 self->ConstructL(); |
|
138 CleanupStack::Pop( self ); |
|
139 return self; |
|
140 } |
|
141 |
|
142 // Destructor |
|
143 CDownloadsListDlg::~CDownloadsListDlg() |
|
144 { |
|
145 CLOG_ENTERFN("CDownloadsListDlg::~CDownloadsListDlg"); |
|
146 |
|
147 |
|
148 if ( iMenuBar ) |
|
149 { |
|
150 HideMenu(); |
|
151 iMyEikonEnv.EikAppUi()->RemoveFromStack( iMenuBar ); |
|
152 delete iMenuBar; |
|
153 iMenuBar = NULL; |
|
154 } |
|
155 delete iRefreshTimer; |
|
156 iRefreshTimer = 0; |
|
157 delete iListBox; |
|
158 iListBox = NULL; |
|
159 delete iDownloadUtils; |
|
160 iDownloadUtils = NULL; |
|
161 |
|
162 CLOG_LEAVEFN("CDownloadsListDlg::~CDownloadsListDlg"); |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CDownloadsListDlg::SetModelL |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 void CDownloadsListDlg::SetModelL( CDownloadsListArray& aModel ) |
|
170 { |
|
171 CLOG_ENTERFN("CDownloadsListDlg::SetModelL"); |
|
172 |
|
173 __ASSERT_DEBUG( iListBox, Panic( EUiLibPanNullListBoxInSetModel ) ); |
|
174 // Remember for the model: |
|
175 iDownloadsListArray = &aModel; |
|
176 // Set item text and icon array |
|
177 iListBox->Model()->SetItemTextArray( &aModel.ItemTextArray() ); |
|
178 iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
179 // iListBox will own the icon array - it is owned also by aModel, so... |
|
180 // Delete old icon array JIC? |
|
181 |
|
182 //delete (iListBox->ItemDrawer()->FormattedCellData()->IconArray()); |
|
183 //Above line has been changed as below to avoid code scanner error |
|
184 |
|
185 CArrayPtr<CGulIcon>* iconarray = iListBox->ItemDrawer()->FormattedCellData()->IconArray(); |
|
186 delete iconarray; |
|
187 iconarray = NULL; |
|
188 |
|
189 iListBox->ItemDrawer()->FormattedCellData()->SetIconArray( &aModel.IconArray() ); |
|
190 aModel.SetIconArrayOwnedExternally( ETrue ); |
|
191 // Enable marquee. |
|
192 iListBox->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue ); |
|
193 |
|
194 if ( aModel.Count() == 0 ) |
|
195 { |
|
196 // Disable Options softkey. |
|
197 ButtonGroupContainer()->MakeCommandVisible( EAknSoftkeyOptions, EFalse ); |
|
198 CLOG_WRITE(" aModel.Count() == 0"); |
|
199 } |
|
200 |
|
201 CLOG_LEAVEFN("CDownloadsListDlg::SetModelL"); |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CDownloadsListDlg::HandleModelChangeL |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 void CDownloadsListDlg::HandleModelChangeL( TDownloadsListDlgEvent aEvent, TInt aIndex ) |
|
209 { |
|
210 CLOG_ENTERFN("CDownloadsListDlg::HandleModelChangeL"); |
|
211 |
|
212 CLOG_WRITE_FORMAT(" aEvent: %d",aEvent); |
|
213 CLOG_WRITE_FORMAT(" aIndex: %d",aIndex); |
|
214 |
|
215 __ASSERT_DEBUG( iListBox, Panic( EUiLibPanNullListBoxInHandleModelChange ) ); |
|
216 |
|
217 if ( aEvent == EDownloadAdded ) |
|
218 { |
|
219 iListBox->HandleItemAdditionL(); |
|
220 |
|
221 // Start refresh timer, if necessary |
|
222 if ( !iRefreshTimer->IsActive() && 0 < VisibleInProgressDownloads() ) |
|
223 { |
|
224 iRefreshTimer->Start( |
|
225 KRefreshIntervalMicroSeconds, |
|
226 KRefreshIntervalMicroSeconds, |
|
227 TCallBack( RefreshTimerCallback, this ) ); |
|
228 CLOG_WRITE(" iRefreshTimer strated"); |
|
229 } |
|
230 } |
|
231 else if ( aEvent == EDownloadChanged ) |
|
232 { |
|
233 // Redraw the item, but only if it is visible in order that |
|
234 // list box does not scroll to an invisible item |
|
235 // (as it does when calling DrawItem()). |
|
236 // Highlight does not change anyway. |
|
237 if ( iListBox->View()->ItemIsVisible( aIndex ) ) |
|
238 { |
|
239 iListBox->DrawItem( aIndex ); |
|
240 |
|
241 // Start refresh timer, if necessary |
|
242 if ( !iRefreshTimer->IsActive() && 0 < VisibleInProgressDownloads() ) |
|
243 { |
|
244 iRefreshTimer->Start( |
|
245 KRefreshIntervalMicroSeconds, |
|
246 KRefreshIntervalMicroSeconds, |
|
247 TCallBack( RefreshTimerCallback, this ) ); |
|
248 CLOG_WRITE(" iRefreshTimer strated"); |
|
249 } |
|
250 } |
|
251 |
|
252 if (!iIsMSKChangeHandled) |
|
253 { |
|
254 HandleMiddleSoftKeyChangeL(); |
|
255 } |
|
256 } |
|
257 else // ( aEvent == EDownloadRemoved ) |
|
258 { |
|
259 CLOG_WRITE_FORMAT(" count: %d",iListBox->Model()->NumberOfItems()); |
|
260 if ( aIndex == 0 ) |
|
261 { |
|
262 // If there is at least one item still, then scroll to the first: |
|
263 if ( iListBox->Model()->NumberOfItems() > 0 ) |
|
264 { |
|
265 iListBox->SetCurrentItemIndex( 0 ); // "0" = first |
|
266 } |
|
267 } |
|
268 else if ( aIndex > 0 ) |
|
269 { |
|
270 iListBox->SetCurrentItemIndex( aIndex - 1 ); |
|
271 } |
|
272 iListBox->HandleItemRemovalL(); |
|
273 iListBox->DrawNow(); |
|
274 |
|
275 // Stop refresh timer, if necessary |
|
276 if ( iRefreshTimer->IsActive() && VisibleInProgressDownloads() == 0 ) |
|
277 { |
|
278 iRefreshTimer->Cancel(); |
|
279 CLOG_WRITE(" iRefreshTimer cancelled"); |
|
280 } |
|
281 } |
|
282 |
|
283 // Close the dialog, if necessary |
|
284 if ( iListBox->Model()->NumberOfItems() == 0 ) |
|
285 { |
|
286 CancelPopup(); |
|
287 } |
|
288 |
|
289 CLOG_LEAVEFN("CDownloadsListDlg::HandleModelChangeL"); |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // CDownloadsListDlg::CurrentItemIndex |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 TInt CDownloadsListDlg::CurrentItemIndex() const |
|
297 { |
|
298 return (iListBox==NULL?KErrNotFound:iListBox->CurrentItemIndex()); |
|
299 } |
|
300 |
|
301 // ----------------------------------------------------------------------------- |
|
302 // CDownloadsListDlg::DisplayMenuL |
|
303 // ----------------------------------------------------------------------------- |
|
304 // |
|
305 void CDownloadsListDlg::DisplayMenuL() |
|
306 { |
|
307 __ASSERT_DEBUG( iMenuBar, Panic( EUiLibPanNullMenuBar ) ); |
|
308 iMenuBar->TryDisplayMenuBarL(); |
|
309 } |
|
310 |
|
311 // ----------------------------------------------------------------------------- |
|
312 // CDownloadsListDlg::HideMenu |
|
313 // ----------------------------------------------------------------------------- |
|
314 // |
|
315 void CDownloadsListDlg::HideMenu() |
|
316 { |
|
317 __ASSERT_DEBUG( iMenuBar, Panic( EUiLibPanNullMenuBar ) ); |
|
318 iMenuBar->StopDisplayingMenuBar(); |
|
319 } |
|
320 |
|
321 // ----------------------------------------------------------------------------- |
|
322 // CDownloadsListDlg::MenuShowing |
|
323 // ----------------------------------------------------------------------------- |
|
324 // |
|
325 TBool CDownloadsListDlg::MenuShowing() const |
|
326 { |
|
327 __ASSERT_DEBUG( iMenuBar, Panic( EUiLibPanNullMenuBar ) ); |
|
328 return iMenuBar->IsDisplayed(); |
|
329 } |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // CDownloadsListDlg::HighlightDownload |
|
333 // ----------------------------------------------------------------------------- |
|
334 // |
|
335 void CDownloadsListDlg::HighlightDownload( RHttpDownload& aHighlightDl ) |
|
336 { |
|
337 iHighlightDownload = &aHighlightDl; |
|
338 } |
|
339 |
|
340 // ----------------------------------------------------------------------------- |
|
341 // CDownloadsListDlg::HandleMiddleSoftKeyChangeL |
|
342 // ----------------------------------------------------------------------------- |
|
343 // |
|
344 void CDownloadsListDlg::HandleMiddleSoftKeyChangeL() |
|
345 { |
|
346 |
|
347 TInt currentItemIndex = CurrentItemIndex(); |
|
348 __ASSERT_DEBUG( 0 <= currentItemIndex, Panic( EUiLibPanDLNegItemIndex ) ); |
|
349 RHttpDownload& currDownload = iDownloadsListArray->Download( currentItemIndex ); |
|
350 CLOG_WRITE_FORMAT(" currDownload: 0x%x",&currDownload); |
|
351 |
|
352 // Get the UI data for the current download |
|
353 TDownloadUiData& dlData = iDownloadsListArray->DlUiData( CurrentItemIndex() ); |
|
354 TInt32 state( dlData.iDownloadState ); |
|
355 CLOG_WRITE_FORMAT(" state: %d",state); |
|
356 |
|
357 // The moved state is only a temporary state - the server |
|
358 // sets the download's original state back right after it, |
|
359 // thus we query the state again: |
|
360 if ( state == EHttpDlMoved ) |
|
361 { |
|
362 User::LeaveIfError( currDownload.GetIntAttribute( EDlAttrState, state ) ); |
|
363 |
|
364 //Changes for the bug JERI-7P8CF2 |
|
365 //Changes made in the server side to fix the video center receiving unexpected events |
|
366 //Reassigning these events back to the changes done in server side |
|
367 if(state == EHttpDlCompleted ) |
|
368 { |
|
369 state = EHttpDlMultipleMOCompleted; |
|
370 } |
|
371 else if(state == EHttpDlFailed ) |
|
372 { |
|
373 state = EHttpDlMultipleMOFailed; |
|
374 } |
|
375 |
|
376 |
|
377 CLOG_WRITE_FORMAT(" state re-query: %d",state); |
|
378 } |
|
379 __ASSERT_DEBUG( state != EHttpDlMoved, Panic( EUiLibPanStateIsStillMoved ) ); |
|
380 |
|
381 TBool isCompleted = state == EHttpDlMultipleMOCompleted; |
|
382 TBool isDrmDownload = EFalse; |
|
383 TBool isDrmRightsOnPhone = EFalse; |
|
384 TBool isPreviewRights = EFalse; |
|
385 // OMA DRM information is used only in case of completed downloads |
|
386 if ( isCompleted ) |
|
387 { |
|
388 isDrmDownload = iDownloadUtils->DrmDownloadL( currDownload ); |
|
389 if ( isDrmDownload ) |
|
390 { |
|
391 isDrmRightsOnPhone = iDownloadUtils->DrmRightsOnThePhoneL |
|
392 ( currDownload, isPreviewRights ); |
|
393 } |
|
394 } |
|
395 TBool supported( EFalse ); |
|
396 supported = iDownloadUtils->IsContentTypeSupportedL( dlData.iContentType ); |
|
397 CLOG_WRITE_FORMAT(" supported: %d",supported); |
|
398 |
|
399 TBool isCodDownload( EFalse ); |
|
400 TInt err = currDownload.GetBoolAttribute( EDlAttrCodDownload, isCodDownload ); |
|
401 CLOG_WRITE_FORMAT(" EDlAttrCodDownload err: %d",err); |
|
402 TBool isCodPdDownload( EFalse ); |
|
403 err = currDownload.GetBoolAttribute( EDlAttrCodPdAvailable, isCodPdDownload ); |
|
404 CLOG_WRITE_FORMAT(" EDlAttrCodPdAvailable err: %d",err); |
|
405 |
|
406 // Get if it can be handled progressively |
|
407 TBool canProgHandled = EFalse; |
|
408 TUid pdPlayerUid = { 0 }; |
|
409 HBufC8* contentType = iDownloadUtils->ContentTypeL( currDownload, ETrue ); |
|
410 TDataType dataType( *contentType ); |
|
411 delete contentType; |
|
412 contentType = NULL; |
|
413 CDocumentHandler* docHandler = CDocumentHandler::NewLC(); |
|
414 canProgHandled = docHandler->CanHandleProgressivelyL( dataType, pdPlayerUid ); |
|
415 CleanupStack::PopAndDestroy( docHandler ); // docHandler |
|
416 |
|
417 if ( isCompleted ) |
|
418 { |
|
419 // If download is complete but file is not moved yet, do not show "Open" |
|
420 // menu item. Opening the file while it is being moved may result in |
|
421 // undefined behavior. |
|
422 TInt32 progressState = dlData.iProgressState; |
|
423 |
|
424 if ((progressState != EHttpProgContentFileMovedAndDestFNChanged) && |
|
425 (progressState != EHttpProgContentFileMoved)) |
|
426 { |
|
427 // Progressive downloads should open whenever user clicks on the |
|
428 // download. So return only if this download cannot be handled |
|
429 // progressively. |
|
430 if (!canProgHandled) |
|
431 { |
|
432 // Download State is complete but file is not moved yet. |
|
433 // Hide the "Open" menu item and return. |
|
434 ButtonGroupContainer()->SetCommandSetL( R_DMUL_DOWNLOADSLIST_SOFTKEYS_PLAY ); |
|
435 ButtonGroupContainer()->DrawNow(); |
|
436 ButtonGroupContainer()->MakeCommandVisible( EAknSoftkeyOpen, EFalse ); |
|
437 iIsMSKChangeHandled = EFalse; |
|
438 return; |
|
439 } |
|
440 } |
|
441 } |
|
442 |
|
443 if ( iProgressiveDownload || isCompleted ) |
|
444 { |
|
445 if ( canProgHandled && !(state == EHttpDlPaused || state == EHttpDlMultipleMOFailed) ) // it can be inprogress or completed |
|
446 { |
|
447 ButtonGroupContainer()->SetCommandSetL( R_DMUL_DOWNLOADSLIST_SOFTKEYS_PLAY ); |
|
448 ButtonGroupContainer()->DrawNow(); |
|
449 ButtonGroupContainer()->MakeCommandVisible( EAknSoftkeyOpen, ETrue ); |
|
450 iIsMSKChangeHandled = ETrue; |
|
451 if (isCodDownload && !isCompleted ) |
|
452 { |
|
453 if ( !( supported && canProgHandled && isCodPdDownload && |
|
454 ( !isDrmDownload || ( isDrmDownload && isDrmRightsOnPhone ) ) ) ) |
|
455 { |
|
456 ButtonGroupContainer()->MakeCommandVisible( EAknSoftkeyOpen, EFalse ); |
|
457 iIsMSKChangeHandled = EFalse; |
|
458 } |
|
459 } |
|
460 else |
|
461 { |
|
462 if ( !( supported && canProgHandled && |
|
463 ( !isDrmDownload || ( isDrmDownload && isDrmRightsOnPhone ) ) ) ) |
|
464 { |
|
465 ButtonGroupContainer()->MakeCommandVisible( EAknSoftkeyOpen, EFalse ); |
|
466 iIsMSKChangeHandled = EFalse; |
|
467 } |
|
468 } |
|
469 } |
|
470 else |
|
471 { |
|
472 ButtonGroupContainer()->SetCommandSetL( R_DMUL_DOWNLOADSLIST_SOFTKEYS_OPEN ); |
|
473 ButtonGroupContainer()->DrawNow(); |
|
474 ButtonGroupContainer()->MakeCommandVisible( EAknSoftkeyOpen, ETrue ); |
|
475 iIsMSKChangeHandled = ETrue; |
|
476 |
|
477 if ( !( isCompleted && supported && |
|
478 ( !isDrmDownload || ( isDrmDownload && isDrmRightsOnPhone ) ) ) ) |
|
479 { |
|
480 ButtonGroupContainer()->MakeCommandVisible( EAknSoftkeyOpen, EFalse ); |
|
481 iIsMSKChangeHandled = EFalse; |
|
482 } |
|
483 } |
|
484 } |
|
485 else // if iProgressiveDownload == EFalse |
|
486 { |
|
487 ButtonGroupContainer()->SetCommandSetL( R_DMUL_DOWNLOADSLIST_SOFTKEYS_OPEN ); |
|
488 ButtonGroupContainer()->DrawNow(); |
|
489 ButtonGroupContainer()->MakeCommandVisible( EAknSoftkeyOpen, ETrue ); |
|
490 iIsMSKChangeHandled = ETrue; |
|
491 |
|
492 if ( !( isCompleted && supported && |
|
493 ( !isDrmDownload || ( isDrmDownload && isDrmRightsOnPhone ) ) ) ) |
|
494 { |
|
495 ButtonGroupContainer()->MakeCommandVisible( EAknSoftkeyOpen, EFalse ); |
|
496 iIsMSKChangeHandled = EFalse; |
|
497 } |
|
498 } |
|
499 } |
|
500 |
|
501 // ----------------------------------------------------------------------------- |
|
502 // CDownloadsListDlg::ExecuteLD |
|
503 // ----------------------------------------------------------------------------- |
|
504 // |
|
505 TBool CDownloadsListDlg::ExecuteLD() |
|
506 { |
|
507 CLOG_ENTERFN("CDownloadsListDlg::ExecuteLD"); |
|
508 |
|
509 iDlgObserver.PreLayoutDynInitL( *this ); |
|
510 |
|
511 if ( iHighlightDownload ) |
|
512 { |
|
513 // Find the index of this download |
|
514 TInt index( KErrNotFound ); |
|
515 TInt err = iDownloadsListArray->Find( *iHighlightDownload, index ); |
|
516 if ( !err ) |
|
517 { |
|
518 iListBox->SetCurrentItemIndex( index ); |
|
519 } |
|
520 } |
|
521 |
|
522 // Start refresh timer, if there is at least one visible download in |
|
523 // EHttpDlInprogress state. |
|
524 if ( !iRefreshTimer->IsActive() && 0 < VisibleInProgressDownloads() ) |
|
525 { |
|
526 iRefreshTimer->Start( |
|
527 KRefreshIntervalMicroSeconds, |
|
528 KRefreshIntervalMicroSeconds, |
|
529 TCallBack( RefreshTimerCallback, this ) ); |
|
530 CLOG_WRITE(" iRefreshTimer strated"); |
|
531 } |
|
532 |
|
533 // Handle middle softkey |
|
534 HandleMiddleSoftKeyChangeL(); |
|
535 |
|
536 TBool popupRet = CAknPopupList::ExecuteLD(); |
|
537 |
|
538 CLOG_LEAVEFN("CDownloadsListDlg::ExecuteLD"); |
|
539 return popupRet; |
|
540 } |
|
541 |
|
542 // ----------------------------------------------------------------------------- |
|
543 // CDownloadsListDlg::ProcessCommandL |
|
544 // ----------------------------------------------------------------------------- |
|
545 // |
|
546 void CDownloadsListDlg::ProcessCommandL( TInt aCommandId ) |
|
547 { |
|
548 CLOG_ENTERFN("CDownloadsListDlg::ProcessCommandL"); |
|
549 |
|
550 HideMenu(); |
|
551 |
|
552 if ( aCommandId == EAknSoftkeyOptions ) |
|
553 { |
|
554 DisplayMenuL(); |
|
555 } |
|
556 else if ( aCommandId == EAknSoftkeyCancel ) |
|
557 { |
|
558 CancelPopup(); |
|
559 } |
|
560 else |
|
561 { |
|
562 // Cancel this control not to dim the screen, and then process the command. |
|
563 //TODO CancelPopup(); |
|
564 // Other, non-specific commands are processed by the observer. |
|
565 iDlgObserver.ProcessCommandL( *this, aCommandId ); |
|
566 } |
|
567 |
|
568 CLOG_LEAVEFN("CDownloadsListDlg::ProcessCommandL"); |
|
569 } |
|
570 |
|
571 // ----------------------------------------------------------------------------- |
|
572 // CDownloadsListDlg::SetEmphasis |
|
573 // ----------------------------------------------------------------------------- |
|
574 // |
|
575 void CDownloadsListDlg::SetEmphasis( CCoeControl* aMenuControl, TBool aEmphasis ) |
|
576 { |
|
577 CLOG_ENTERFN("CDownloadsListDlg::SetEmphasis"); |
|
578 |
|
579 // CAknDialog::SetEmphasis implements it like below. |
|
580 CEikAppUi* appUi = iMyEikonEnv.EikAppUi(); |
|
581 appUi->RemoveFromStack( aMenuControl ); |
|
582 TRAP_IGNORE( appUi->AddToStackL |
|
583 ( aMenuControl, aEmphasis ? ECoeStackPriorityDialog : ECoeStackPriorityMenu ) ); |
|
584 //appUi->UpdateStackedControlFlags |
|
585 // ( this, aEmphasis ? ECoeStackFlagRefusesFocus : 0, ECoeStackFlagRefusesFocus ); |
|
586 appUi->UpdateStackedControlFlags |
|
587 ( aMenuControl, aEmphasis ? 0 : ECoeStackFlagRefusesFocus, ECoeStackFlagRefusesFocus ); |
|
588 appUi->HandleStackChanged(); |
|
589 |
|
590 CLOG_LEAVEFN("CDownloadsListDlg::SetEmphasis"); |
|
591 } |
|
592 |
|
593 // ----------------------------------------------------------------------------- |
|
594 // CDownloadsListDlg::DynInitMenuPaneL |
|
595 // ----------------------------------------------------------------------------- |
|
596 // |
|
597 void CDownloadsListDlg::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
598 { |
|
599 iDlgObserver.DynInitMenuPaneL( *this, aResourceId, aMenuPane ); |
|
600 } |
|
601 |
|
602 |
|
603 // ----------------------------------------------------------------------------- |
|
604 // CDownloadsListDlg::HandleListBoxEventL |
|
605 // ----------------------------------------------------------------------------- |
|
606 // |
|
607 void CDownloadsListDlg::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType) |
|
608 { |
|
609 if (iListBox && aListBox == iListBox) |
|
610 { |
|
611 switch (aEventType) |
|
612 { |
|
613 case MEikListBoxObserver::EEventItemClicked: |
|
614 case MEikListBoxObserver::EEventItemDraggingActioned: |
|
615 { |
|
616 HandleMiddleSoftKeyChangeL(); |
|
617 break; |
|
618 } |
|
619 case MEikListBoxObserver::EEventItemDoubleClicked: |
|
620 { |
|
621 // If EAknSoftkeyOpen is visible, then we can activate the selected download |
|
622 if (ButtonGroupContainer()->IsCommandVisible(EAknSoftkeyOpen)) |
|
623 { |
|
624 ProcessCommandL(EAknSoftkeyOpen); |
|
625 } |
|
626 } |
|
627 default: |
|
628 { |
|
629 break; |
|
630 } |
|
631 } |
|
632 } |
|
633 } |
|
634 |
|
635 // ----------------------------------------------------------------------------- |
|
636 // CDownloadsListDlg::FocusChanged |
|
637 // ----------------------------------------------------------------------------- |
|
638 // |
|
639 void CDownloadsListDlg::FocusChanged( TDrawNow aDrawNow ) |
|
640 { |
|
641 // Focus gained or lost |
|
642 if ( IsFocused() ) |
|
643 { |
|
644 // Focus gained. Start refresh timer if needed |
|
645 // Start refresh timer, if there is at least one visible download in |
|
646 // EHttpDlInprogress state. |
|
647 if ( !iRefreshTimer->IsActive() && 0 < VisibleInProgressDownloads() ) |
|
648 { |
|
649 iRefreshTimer->Start( |
|
650 KRefreshIntervalMicroSeconds, |
|
651 KRefreshIntervalMicroSeconds, |
|
652 TCallBack( RefreshTimerCallback, this ) ); |
|
653 CLOG_WRITE(" iRefreshTimer strated"); |
|
654 } |
|
655 } |
|
656 else |
|
657 { |
|
658 // Focus lost. Cancel refresh timer |
|
659 iRefreshTimer->Cancel(); |
|
660 CLOG_WRITE(" iRefreshTimer cancelled"); |
|
661 } |
|
662 |
|
663 // Call base class' same functionality: |
|
664 // Important: CAknPopupList::FocusChanged() is private, so |
|
665 // the base class' very same method cannot be called from here. |
|
666 // It means that the functionality of that must be implemented here, |
|
667 // and meanwhile ask CAknPopupList to make it protected. |
|
668 // See SCB CR GKOA-6KPC5L. |
|
669 if ( iListBox ) |
|
670 { |
|
671 iListBox->SetFocus(IsFocused(), aDrawNow); |
|
672 } |
|
673 // We have no find box, so this part can be omitted: |
|
674 } |
|
675 |
|
676 // ----------------------------------------------------------------------------- |
|
677 // CDownloadsListDlg::HandlePointerEventL |
|
678 // ----------------------------------------------------------------------------- |
|
679 // |
|
680 void CDownloadsListDlg::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
681 { |
|
682 CAknPopupList::HandlePointerEventL(aPointerEvent); |
|
683 } |
|
684 |
|
685 // ----------------------------------------------------------------------------- |
|
686 // CDownloadsListDlg::OfferKeyEventL |
|
687 // ----------------------------------------------------------------------------- |
|
688 // |
|
689 TKeyResponse CDownloadsListDlg::OfferKeyEventL |
|
690 ( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
691 { |
|
692 TKeyResponse resp = EKeyWasNotConsumed; |
|
693 resp = iDlgObserver.OfferKeyEventL( *this, aKeyEvent, aType ); |
|
694 |
|
695 if ( resp == EKeyWasNotConsumed ) |
|
696 { |
|
697 // Handle EKeyEscape specially - for it the |
|
698 // dialog has to be closed immediately. |
|
699 if ( aType == EEventKey && aKeyEvent.iCode == EKeyEscape ) |
|
700 { |
|
701 CLOG_WRITE(" Offer: EKeyEscape - CancelPopup"); |
|
702 CancelPopup(); |
|
703 resp = EKeyWasConsumed; |
|
704 } |
|
705 } |
|
706 |
|
707 if ( 0 < KRefreshIntervalMicroSeconds ) |
|
708 { |
|
709 // Scrolling effects refresh timer |
|
710 // If a download becomes visible due to scrolling, it is immediately updated. |
|
711 TBool refreshNeeded = EFalse; |
|
712 TInt refreshIndex = 0; |
|
713 if ( aType == EEventKey |
|
714 && ( aKeyEvent.iCode == EKeyLeftUpArrow // Northwest |
|
715 || aKeyEvent.iCode == EStdKeyDevice10 // : Extra KeyEvent supports diagonal event simulator wedge |
|
716 || aKeyEvent.iCode == EKeyUpArrow // North |
|
717 || aKeyEvent.iCode == EKeyRightUpArrow // Northeast |
|
718 || aKeyEvent.iCode == EStdKeyDevice11 ) ) // : Extra KeyEvent supports diagonal event simulator wedge |
|
719 { |
|
720 if ( 0 < iListBox->TopItemIndex() ) |
|
721 { |
|
722 refreshNeeded = ETrue; |
|
723 refreshIndex = iListBox->TopItemIndex() - 1; |
|
724 } |
|
725 } |
|
726 if ( aType == EEventKey |
|
727 && ( aKeyEvent.iCode == EKeyLeftDownArrow // Southwest |
|
728 || aKeyEvent.iCode == EStdKeyDevice13 // : Extra KeyEvent supports diagonal event simulator wedge |
|
729 || aKeyEvent.iCode == EKeyDownArrow // South |
|
730 || aKeyEvent.iCode == EKeyRightDownArrow // Southeast |
|
731 || aKeyEvent.iCode == EStdKeyDevice12 ) ) // : Extra KeyEvent supports diagonal event simulator wedge |
|
732 { |
|
733 if ( iListBox->BottomItemIndex() < ( iDownloadsListArray->Count() - 1 ) ) |
|
734 { |
|
735 refreshNeeded = ETrue; |
|
736 refreshIndex = iListBox->BottomItemIndex() + 1; |
|
737 } |
|
738 } |
|
739 if ( refreshNeeded ) |
|
740 { |
|
741 // Update the invisible download if it is progressing - |
|
742 // when it becomes visible, it should show fresh information. |
|
743 TInt32 dlAttrState = 0; |
|
744 RHttpDownload& download = |
|
745 iDownloadsListArray->Download( refreshIndex ); |
|
746 User::LeaveIfError( download.GetIntAttribute( EDlAttrState, dlAttrState ) ); |
|
747 |
|
748 //Changes for the bug JERI-7P8CF2 |
|
749 //Changes made in the server side to fix the video center receiving unexpected events |
|
750 //Reassigning these events back to the changes done in server side |
|
751 if(dlAttrState == EHttpDlCompleted ) |
|
752 { |
|
753 dlAttrState = EHttpDlMultipleMOCompleted; |
|
754 } |
|
755 else if(dlAttrState == EHttpDlFailed ) |
|
756 { |
|
757 dlAttrState = EHttpDlMultipleMOFailed; |
|
758 } |
|
759 |
|
760 if ( dlAttrState == EHttpDlInprogress ) |
|
761 { |
|
762 RefreshProgressL( refreshIndex ); |
|
763 // Start refresh timer - there will be at least one visible |
|
764 // download in EHttpDlInprogress state. |
|
765 if ( !iRefreshTimer->IsActive() ) |
|
766 { |
|
767 iRefreshTimer->Start( |
|
768 KRefreshIntervalMicroSeconds, |
|
769 KRefreshIntervalMicroSeconds, |
|
770 TCallBack( RefreshTimerCallback, this ) ); |
|
771 CLOG_WRITE(" iRefreshTimer strated"); |
|
772 } |
|
773 } |
|
774 } |
|
775 } |
|
776 |
|
777 |
|
778 // Forward it to the list box: |
|
779 if ( resp == EKeyWasNotConsumed ) |
|
780 { |
|
781 // Handle Middle Softkey. If it's EKeyEscape sent by Music Player, |
|
782 // It is considered as being consumed, and no longer needs to do MSK update |
|
783 HandleMiddleSoftKeyChangeL(); |
|
784 resp = iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
785 } |
|
786 |
|
787 return resp; |
|
788 } |
|
789 |
|
790 // ----------------------------------------------------------------------------- |
|
791 // CDownloadsListDlg::VisibleInProgressDownloads |
|
792 // ----------------------------------------------------------------------------- |
|
793 // |
|
794 TInt CDownloadsListDlg::VisibleInProgressDownloads() const |
|
795 { |
|
796 TInt visibleInProgressDownloads = 0; |
|
797 |
|
798 if ( KRefreshIntervalMicroSeconds <= 0 ) |
|
799 { |
|
800 // Refresh timer solution is not used. To support this in |
|
801 // a centralized way, this function returns 0 in this case. |
|
802 } |
|
803 else |
|
804 { |
|
805 TInt topItemIndex = iListBox->TopItemIndex(); |
|
806 TInt bottomItemIndex = iListBox->BottomItemIndex(); |
|
807 TInt32 dlAttrState = 0; |
|
808 if (topItemIndex >0) |
|
809 { |
|
810 for ( TInt i = topItemIndex; i <= bottomItemIndex; ++i ) |
|
811 { |
|
812 RHttpDownload& download = iDownloadsListArray->Download(i); |
|
813 if ( download.GetIntAttribute( EDlAttrState, dlAttrState ) == KErrNone ) |
|
814 { |
|
815 if ( dlAttrState == EHttpDlInprogress ) |
|
816 { |
|
817 ++visibleInProgressDownloads; |
|
818 } |
|
819 } |
|
820 } |
|
821 } |
|
822 } |
|
823 return visibleInProgressDownloads; |
|
824 } |
|
825 |
|
826 // ----------------------------------------------------------------------------- |
|
827 // CDownloadsListDlg::RefreshProgressL |
|
828 // ----------------------------------------------------------------------------- |
|
829 // |
|
830 void CDownloadsListDlg::RefreshProgressL( TInt aIndex ) |
|
831 { |
|
832 TInt32 dlAttrState = EHttpDlInprogress; |
|
833 RHttpDownload& download = iDownloadsListArray->Download( aIndex ); |
|
834 // Create a local copy |
|
835 TDownloadUiData dlData = iDownloadsListArray->DlUiData( aIndex ); |
|
836 // Update download state - this must always be done! |
|
837 dlData.iDownloadState = dlAttrState; |
|
838 // Update the progress info. |
|
839 User::LeaveIfError( download.GetIntAttribute( EDlAttrDownloadedSize, |
|
840 dlData.iDownloadedSize ) ); |
|
841 User::LeaveIfError( download.GetIntAttribute( EDlAttrLength, |
|
842 dlData.iFullSize ) ); |
|
843 TBool updated = EFalse; |
|
844 iDownloadsListArray->UpdateIfNeededL( aIndex, dlData, updated ); |
|
845 } |
|
846 |
|
847 // ----------------------------------------------------------------------------- |
|
848 // CDownloadsListDlg::RefreshTimerCallback |
|
849 // ----------------------------------------------------------------------------- |
|
850 // |
|
851 TInt CDownloadsListDlg::RefreshTimerCallback( TAny* aPtr ) |
|
852 { |
|
853 // Avoid leaving functions in this callback! |
|
854 |
|
855 TInt err(0); |
|
856 CDownloadsListDlg* thisDialog = (CDownloadsListDlg*)aPtr; |
|
857 |
|
858 // When timer completes, the visible list box items' format string is |
|
859 // regenerated (this is relatively fast), and if it differs from the |
|
860 // current string, the list box item is updated, and then the timer is |
|
861 // restarted. This applies only for inprogress downlods. |
|
862 TInt topItemIndex = thisDialog->iListBox->TopItemIndex(); |
|
863 TInt bottomItemIndex = thisDialog->iListBox->BottomItemIndex(); |
|
864 // Count visible inprogress downloads. If there is no such, |
|
865 // timer is stopped. |
|
866 TInt visibleInProgressDownloads = 0; |
|
867 |
|
868 for ( TInt i = topItemIndex; i <= bottomItemIndex; ++i ) |
|
869 { |
|
870 TInt32 dlAttrState = 0; |
|
871 RHttpDownload& download = thisDialog->iDownloadsListArray->Download(i); |
|
872 if ( download.GetIntAttribute( EDlAttrState, dlAttrState ) == KErrNone ) |
|
873 { |
|
874 if ( dlAttrState == EHttpDlInprogress ) |
|
875 { |
|
876 ++visibleInProgressDownloads; |
|
877 TBool updated = EFalse; |
|
878 |
|
879 // Create a local copy |
|
880 TDownloadUiData dlData = |
|
881 thisDialog->iDownloadsListArray->DlUiData(i); |
|
882 // Update download state - this must always be done! |
|
883 dlData.iDownloadState = dlAttrState; |
|
884 // Update the progress info. |
|
885 err = download.GetIntAttribute( EDlAttrDownloadedSize, |
|
886 dlData.iDownloadedSize ); |
|
887 if ( !err ) |
|
888 { |
|
889 err = download.GetIntAttribute( EDlAttrLength, |
|
890 dlData.iFullSize ); |
|
891 if ( !err ) |
|
892 { |
|
893 TRAP( err, thisDialog->iDownloadsListArray->UpdateIfNeededL |
|
894 ( i, dlData, updated ) ); |
|
895 // Refresh the view |
|
896 if ( !err && updated ) |
|
897 { |
|
898 thisDialog->HandleModelChangeL( EDownloadChanged, i ); |
|
899 // HandleModelChangeL with EDownloadChanged is not leaving |
|
900 // so no nedd to trap it! |
|
901 } |
|
902 } |
|
903 } |
|
904 } |
|
905 } |
|
906 } |
|
907 |
|
908 if ( !visibleInProgressDownloads ) |
|
909 { |
|
910 thisDialog->iRefreshTimer->Cancel(); |
|
911 CLOG_WRITE(" iRefreshTimer cancelled"); |
|
912 } |
|
913 |
|
914 return KErrNone; |
|
915 } |
|
916 |
|
917 /* End of file. */ |