author | teknolog |
Thu, 25 Feb 2010 17:56:45 +0000 | |
changeset 10 | 121100939521 |
parent 8 | aab3aa4acdd6 |
child 13 | f58e3c482bd9 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
2 |
* Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB |
|
3 |
* |
|
4 |
* All rights reserved. |
|
5 |
* This component and the accompanying materials are made available |
|
6 |
* under the terms of the License "Eclipse Public License v1.0" |
|
7 |
* which accompanies this distribution, and is available |
|
8 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 |
* |
|
10 |
* Initial Contributors: |
|
11 |
* EmbedDev AB - initial contribution. |
|
12 |
* |
|
13 |
* Contributors: |
|
14 |
* |
|
15 |
* Description: |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
#include "PodcastShowsView.h" |
|
20 |
#include "PodcastAppUi.h" |
|
21 |
#include "ShowEngine.h" |
|
22 |
#include "SettingsEngine.h" |
|
23 |
#include "PodcastApp.h" |
|
24 |
#include "imagehandler.h" |
|
25 |
#include "constants.h" |
|
26 |
||
27 |
#include <akntitle.h> |
|
28 |
#include <podcast.rsg> |
|
29 |
#include <podcast.mbg> |
|
30 |
#include <gulicon.h> |
|
31 |
#include <barsread.h> |
|
32 |
#include <aknnotedialog.h> |
|
33 |
#include <aknmessagequerydialog.h> |
|
34 |
||
35 |
#define KMaxMessageLength 200 |
|
36 |
||
37 |
#define KPodcastImageWidth 160 |
|
38 |
#define KPodcastImageHeight 120 |
|
39 |
#define KPodcastDialogOffset 2 |
|
40 |
||
41 |
#define KOneHundredPercent 100 |
|
42 |
||
43 |
const TInt KSizeBufLen = 64; |
|
44 |
const TInt KDefaultGran = 5; |
|
45 |
_LIT(KSizeDownloadingOf, "%.1f/%.1f MB"); |
|
46 |
_LIT(KShowsSizeFormatS60, "%.1f MB"); |
|
47 |
||
5 | 48 |
_LIT(KShowFormat, "%d\t%S\t%S%S\t"); |
2 | 49 |
_LIT(KShowErrorFormat, "%d\t%S\t%S\t"); |
50 |
_LIT(KShowQueueFormat, "%d\t%S\t%S%S\t"); |
|
51 |
||
52 |
// these must correspond with TShowsIconIndex |
|
53 |
||
54 |
const TUint KShowIconArrayIds[] = |
|
55 |
{ |
|
56 |
EMbmPodcastAudio, |
|
57 |
EMbmPodcastAudio_mask, |
|
58 |
EMbmPodcastAudio_new, |
|
59 |
EMbmPodcastAudio_new_mask, |
|
60 |
EMbmPodcastAudio_queued, |
|
61 |
EMbmPodcastAudio_queued_mask, |
|
62 |
EMbmPodcastAudio_downloading, |
|
63 |
EMbmPodcastAudio_downloading_mask, |
|
64 |
EMbmPodcastAudio_downloaded, |
|
65 |
EMbmPodcastAudio_downloaded_mask, |
|
66 |
EMbmPodcastAudio_downloaded_new, |
|
67 |
EMbmPodcastAudio_downloaded_new_mask, |
|
68 |
EMbmPodcastAudio_failed, |
|
69 |
EMbmPodcastAudio_failed_mask, |
|
70 |
EMbmPodcastAudio_suspended, |
|
71 |
EMbmPodcastAudio_suspended_mask, |
|
72 |
0, |
|
73 |
0 |
|
74 |
}; |
|
75 |
||
76 |
/** |
|
77 |
* This is an interal class to display a message query dialog with an image at the bottm |
|
78 |
*/ |
|
79 |
class CPodcastImageMessageQueryDialog:public CAknMessageQueryDialog |
|
80 |
{ |
|
81 |
public: |
|
82 |
/** |
|
83 |
* C++ default constructor. |
|
84 |
* |
|
85 |
* @param aMessage Dialog box text. |
|
86 |
* @param aHeader Header for the dialog. |
|
87 |
* @deprecated |
|
88 |
*/ |
|
89 |
CPodcastImageMessageQueryDialog(TDesC* aMessage, TDesC* aHeader):CAknMessageQueryDialog(aMessage, aHeader) |
|
90 |
{ |
|
91 |
||
92 |
} |
|
93 |
||
94 |
~CPodcastImageMessageQueryDialog() |
|
95 |
{ |
|
96 |
||
97 |
} |
|
98 |
||
99 |
void SetSizeAndPosition(const TSize& aSize) |
|
100 |
{ |
|
101 |
CAknMessageQueryDialog::SetSizeAndPosition(aSize); |
|
102 |
||
103 |
TPoint pos = Position(); |
|
104 |
TSize size = Size(); |
|
105 |
||
106 |
CAknDialog::SetSizeAndPosition(aSize); |
|
107 |
||
108 |
pos.iY-=((aSize.iHeight-size.iHeight)-KPodcastDialogOffset); |
|
109 |
SetPosition(pos); |
|
110 |
SetSize(aSize); |
|
111 |
} |
|
112 |
||
113 |
}; |
|
114 |
||
115 |
CPodcastShowsView* CPodcastShowsView::NewL(CPodcastModel& aPodcastModel) |
|
116 |
{ |
|
117 |
CPodcastShowsView* self = CPodcastShowsView::NewLC(aPodcastModel); |
|
118 |
CleanupStack::Pop(self); |
|
119 |
return self; |
|
120 |
} |
|
121 |
||
122 |
CPodcastShowsView* CPodcastShowsView::NewLC(CPodcastModel& aPodcastModel) |
|
123 |
{ |
|
124 |
CPodcastShowsView* self = new ( ELeave ) CPodcastShowsView(aPodcastModel); |
|
125 |
CleanupStack::PushL(self); |
|
126 |
self->ConstructL(); |
|
127 |
return self; |
|
128 |
} |
|
129 |
||
130 |
CPodcastShowsView::CPodcastShowsView(CPodcastModel& aPodcastModel) : |
|
131 |
iPodcastModel(aPodcastModel) |
|
132 |
{ |
|
133 |
} |
|
134 |
||
135 |
void CPodcastShowsView::ConstructL() |
|
136 |
{ |
|
137 |
BaseConstructL(R_PODCAST_SHOWSVIEW); |
|
138 |
CPodcastListView::ConstructL(); |
|
139 |
||
140 |
CreateIconsL(); |
|
141 |
||
142 |
iListContainer->Listbox()->SetListBoxObserver(this); |
|
143 |
||
144 |
iPodcastModel.FeedEngine().AddObserver(this); |
|
145 |
iPodcastModel.ShowEngine().AddObserver(this); |
|
146 |
||
147 |
iStylusPopupMenu = CAknStylusPopUpMenu::NewL( this , TPoint(0,0)); |
|
148 |
TResourceReader reader; |
|
149 |
iCoeEnv->CreateResourceReaderLC(reader,R_SHOWVIEW_POPUP_MENU); |
|
150 |
iStylusPopupMenu->ConstructFromResourceL(reader); |
|
151 |
||
152 |
CleanupStack::PopAndDestroy(); |
|
153 |
} |
|
154 |
||
155 |
void CPodcastShowsView::CreateIconsL() |
|
156 |
{ |
|
157 |
CArrayPtr< CGulIcon>* icons = new(ELeave) CArrayPtrFlat< CGulIcon>(1); |
|
158 |
CleanupStack::PushL(icons); |
|
159 |
TInt pos = 0; |
|
160 |
while (KShowIconArrayIds[pos] > 0) |
|
161 |
{ |
|
162 |
// Load the bitmap for play icon |
|
163 |
CFbsBitmap* bitmap= NULL;//iEikonEnv->CreateBitmapL( _L("*"), KIconArrayIds[pos]); |
|
164 |
CFbsBitmap* mask= NULL;////iEikonEnv->CreateBitmapL( _L("*"), KIconArrayIds[pos+1] ); |
|
165 |
AknIconUtils::CreateIconL(bitmap, |
|
166 |
mask, |
|
167 |
iEikonEnv->EikAppUi()->Application()->BitmapStoreName(), |
|
168 |
KShowIconArrayIds[pos], |
|
169 |
KShowIconArrayIds[pos+1]); |
|
170 |
CleanupStack::PushL(bitmap); |
|
171 |
CleanupStack::PushL(mask); |
|
172 |
||
173 |
// Append the play icon to icon array |
|
174 |
icons->AppendL(CGulIcon::NewL(bitmap, mask) ); |
|
175 |
CleanupStack::Pop(2); // bitmap, mask |
|
176 |
pos+=2; |
|
177 |
} |
|
178 |
||
179 |
iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons); |
|
180 |
CleanupStack::Pop(icons); // icons |
|
181 |
} |
|
182 |
||
183 |
TKeyResponse CPodcastShowsView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
184 |
{ |
|
185 |
if (aType == EEventKey) |
|
186 |
{ |
|
187 |
CShowInfo *activeShow = NULL; |
|
188 |
||
189 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
190 |
if(index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
|
191 |
{ |
|
192 |
activeShow = iPodcastModel.ActiveShowList()[index]; |
|
193 |
} |
|
194 |
||
195 |
if (activeShow != NULL) { |
|
196 |
DP1("aKeyEvent.iCode=%d", aKeyEvent.iCode); |
|
197 |
switch (aKeyEvent.iCode) { |
|
198 |
case 117: |
|
199 |
case '*': |
|
200 |
case EKeySpace: |
|
201 |
if (activeShow->PlayState() == EPlayed) { |
|
202 |
HandleCommandL(EPodcastMarkAsUnplayed); |
|
203 |
} else { |
|
204 |
HandleCommandL(EPodcastMarkAsPlayed); |
|
205 |
} |
|
206 |
break; |
|
207 |
case 106: |
|
208 |
case '#': |
|
209 |
if (activeShow->DownloadState() == ENotDownloaded) { |
|
210 |
HandleCommandL(EPodcastDownloadShow); |
|
211 |
} |
|
212 |
break; |
|
213 |
case EKeyBackspace: |
|
214 |
case EKeyDelete: |
|
215 |
HandleCommandL(EPodcastDeleteShow); |
|
216 |
break; |
|
217 |
default: |
|
218 |
break; |
|
219 |
} |
|
220 |
UpdateToolbar(); |
|
221 |
} |
|
222 |
} |
|
223 |
return CPodcastListView::OfferKeyEventL(aKeyEvent, aType); |
|
224 |
} |
|
225 |
||
226 |
CPodcastShowsView::~CPodcastShowsView() |
|
227 |
{ |
|
228 |
iPodcastModel.ShowEngine().RemoveObserver(this); |
|
229 |
iPodcastModel.FeedEngine().RemoveObserver(this); |
|
230 |
||
231 |
if(iStylusPopupMenu) |
|
232 |
delete iStylusPopupMenu, iStylusPopupMenu = NULL; |
|
233 |
} |
|
234 |
||
235 |
||
236 |
TUid CPodcastShowsView::Id() const |
|
237 |
{ |
|
238 |
return KUidPodcastShowsViewID; |
|
239 |
} |
|
240 |
||
241 |
void CPodcastShowsView::DoActivateL(const TVwsViewId& aPrevViewId, |
|
242 |
TUid aCustomMessageId, const TDesC8& aCustomMessage) |
|
243 |
{ |
|
244 |
DP("CPodcastShowsView::DoActivateL BEGIN"); |
|
245 |
||
246 |
UpdateViewTitleL(); |
|
247 |
||
248 |
CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage); |
|
249 |
iPreviousView = TVwsViewId(KUidPodcast, KUidPodcastFeedViewID); |
|
250 |
||
251 |
UpdateFeedUpdateStateL(); |
|
252 |
UpdateToolbar(); |
|
253 |
DP("CPodcastShowsView::DoActivateL END"); |
|
254 |
} |
|
255 |
||
256 |
void CPodcastShowsView::DoDeactivate() |
|
257 |
{ |
|
258 |
CAknTitlePane* titlePane = static_cast<CAknTitlePane*> |
|
259 |
( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
260 |
||
261 |
// titlePane->SetSmallPicture(NULL, NULL, ETrue); |
|
262 |
titlePane->SetPicture(NULL, NULL); |
|
263 |
titlePane->SetTextToDefaultL(); |
|
264 |
CPodcastListView::DoDeactivate(); |
|
265 |
} |
|
266 |
||
267 |
// Engine callback when new shows are available |
|
268 |
void CPodcastShowsView::ShowListUpdatedL() |
|
269 |
{ |
|
270 |
UpdateListboxItemsL(); |
|
271 |
} |
|
272 |
||
273 |
void CPodcastShowsView::ShowDownloadUpdatedL(TInt aBytesOfCurrentDownload, TInt /*aBytesTotal*/) |
|
274 |
{ |
|
275 |
if (!iListContainer->IsVisible()) |
|
276 |
{ |
|
277 |
return; |
|
278 |
} |
|
279 |
||
280 |
CShowInfo *info = iPodcastModel.ShowEngine().ShowDownloading(); |
|
281 |
if (info) |
|
282 |
{ |
|
283 |
UpdateShowItemL(info->Uid(), aBytesOfCurrentDownload); |
|
284 |
} |
|
285 |
} |
|
286 |
||
287 |
void CPodcastShowsView::ShowDownloadFinishedL(TUint /*aShowUid*/, TInt aError) |
|
288 |
{ |
|
289 |
iProgressAdded = EFalse; |
|
290 |
||
291 |
switch(aError) |
|
292 |
{ |
|
293 |
case KErrCouldNotConnect: |
|
294 |
{ |
|
295 |
TBuf<KMaxMessageLength> message; |
|
296 |
iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR); |
|
297 |
ShowErrorMessage(message); |
|
298 |
} |
|
299 |
break; |
|
6 | 300 |
default: |
2 | 301 |
break; |
302 |
} |
|
6 | 303 |
UpdateListboxItemsL(); |
2 | 304 |
} |
305 |
||
306 |
||
307 |
void CPodcastShowsView::FeedDownloadStartedL(TFeedState /*aState*/, TUint aFeedUid) |
|
308 |
{ |
|
309 |
// TODO make use of the fact that we know that the feed download is |
|
310 |
// started instead of checking feed engine states in UpdateFeedUpdateStateL. |
|
311 |
if (iPodcastModel.ActiveFeedInfo() != NULL |
|
312 |
&& iPodcastModel.ActiveFeedInfo()->Uid() == aFeedUid) |
|
313 |
{ |
|
8 | 314 |
UpdateFeedUpdateStateL(); |
2 | 315 |
UpdateToolbar(); |
316 |
} |
|
317 |
} |
|
318 |
||
319 |
void CPodcastShowsView::FeedDownloadFinishedL(TFeedState /*aState*/, TUint aFeedUid, TInt /*aError*/) |
|
320 |
{ |
|
321 |
DP("CPodcastShowsView::FeedDownloadFinishedL BEGIN"); |
|
322 |
// TODO make use of the fact that we know that the feed download is |
|
323 |
// finished instead of checking feed engine states in UpdateFeedUpdateStateL. |
|
324 |
if (iPodcastModel.ActiveFeedInfo() != NULL |
|
325 |
&& iPodcastModel.ActiveFeedInfo()->Uid() == aFeedUid) |
|
326 |
{ |
|
8 | 327 |
UpdateFeedUpdateStateL(); |
328 |
UpdateViewTitleL(); |
|
2 | 329 |
} |
330 |
DP("CPodcastShowsView::FeedDownloadFinishedL END"); |
|
331 |
} |
|
332 |
||
333 |
void CPodcastShowsView::HandleListBoxEventL(CEikListBox* /*aListBox*/, |
|
334 |
TListBoxEvent aEventType) |
|
335 |
{ |
|
336 |
switch (aEventType) |
|
337 |
{ |
|
338 |
case EEventEnterKeyPressed: |
|
339 |
case EEventItemActioned: |
|
340 |
case EEventItemDoubleClicked: |
|
341 |
{ |
|
342 |
RShowInfoArray &fItems = iPodcastModel.ActiveShowList(); |
|
343 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
344 |
if (index>=0 && index< fItems.Count()) |
|
345 |
{ |
|
346 |
DP2("Handle event for podcast %S, downloadState is %d", &(fItems[index]->Title()), fItems[index]->DownloadState()); |
|
347 |
CShowInfo *showInfo = fItems[index]; |
|
348 |
||
349 |
switch (showInfo->DownloadState()) { |
|
350 |
case ENotDownloaded: |
|
351 |
HandleCommandL(EPodcastDownloadShow); |
|
352 |
break; |
|
353 |
case EQueued: |
|
354 |
AppUi()->ActivateLocalViewL(KUidPodcastQueueViewID, TUid::Uid(0), KNullDesC8()); |
|
355 |
((CPodcastAppUi*)AppUi())->SetActiveTab(KTabIdQueue); |
|
356 |
break; |
|
357 |
case EDownloaded: |
|
358 |
#pragma message("LAPER Replace activate playview with activate playback in mpx") |
|
359 |
break; |
|
360 |
default: |
|
361 |
break; |
|
362 |
} |
|
363 |
} |
|
364 |
} |
|
365 |
break; |
|
366 |
default: |
|
367 |
break; |
|
368 |
} |
|
369 |
UpdateToolbar(); |
|
370 |
} |
|
371 |
||
372 |
void CPodcastShowsView::GetShowIcons(CShowInfo* aShowInfo, TInt& aIconIndex) |
|
373 |
{ |
|
374 |
TBool dlStop = iPodcastModel.SettingsEngine().DownloadSuspended(); |
|
375 |
TUint showDownloadingUid = iPodcastModel.ShowEngine().ShowDownloading() ? iPodcastModel.ShowEngine().ShowDownloading()->Uid() : 0; |
|
376 |
||
377 |
if (showDownloadingUid == aShowInfo->Uid()) |
|
378 |
{ |
|
379 |
aIconIndex = dlStop ? ESuspendedShowIcon : EDownloadingShowIcon; |
|
380 |
} |
|
381 |
else |
|
382 |
{ |
|
383 |
switch (aShowInfo->DownloadState()) |
|
384 |
{ |
|
385 |
case EDownloaded: |
|
386 |
if (aShowInfo->PlayState() == ENeverPlayed) { |
|
387 |
aIconIndex = EDownloadedNewShowIcon; |
|
388 |
} else { |
|
389 |
aIconIndex = EDownloadedShowIcon; |
|
390 |
} |
|
391 |
break; |
|
392 |
case ENotDownloaded: |
|
393 |
if (aShowInfo->PlayState() == ENeverPlayed) { |
|
394 |
aIconIndex = ENewShowIcon; |
|
395 |
} else { |
|
396 |
aIconIndex = EShowIcon; |
|
397 |
} |
|
398 |
break; |
|
399 |
case EQueued: |
|
400 |
aIconIndex = dlStop ? ESuspendedShowIcon : EQuedShowIcon; |
|
401 |
break; |
|
402 |
case EDownloading: |
|
403 |
aIconIndex = dlStop ? ESuspendedShowIcon : EDownloadingShowIcon; |
|
404 |
break; |
|
405 |
case EFailedDownload: |
|
406 |
aIconIndex = EFailedShowIcon; |
|
407 |
break; |
|
408 |
} |
|
409 |
} |
|
410 |
} |
|
411 |
||
412 |
||
413 |
void CPodcastShowsView::UpdateFeedUpdateStateL() |
|
414 |
{ |
|
415 |
TBool listboxDimmed = EFalse; |
|
416 |
||
417 |
if (iPodcastModel.FeedEngine().ClientState() != EIdle && iPodcastModel.ActiveFeedInfo() |
|
418 |
!= NULL && iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid()) |
|
419 |
{ |
|
420 |
listboxDimmed = ETrue; |
|
421 |
} |
|
422 |
||
423 |
if ((iListContainer->Listbox()->IsDimmed() && !listboxDimmed) || (!iListContainer->Listbox()->IsDimmed() && listboxDimmed)) |
|
424 |
{ |
|
425 |
iListContainer->Listbox()->SetDimmed(listboxDimmed); |
|
426 |
} |
|
427 |
UpdateListboxItemsL(); |
|
428 |
UpdateToolbar(); |
|
429 |
} |
|
430 |
||
431 |
void CPodcastShowsView::FormatShowInfoListBoxItemL(CShowInfo& aShowInfo, TInt aSizeDownloaded) |
|
432 |
{ |
|
433 |
TBuf<32> infoSize; |
|
434 |
TInt iconIndex = 0; |
|
435 |
TBuf<KMaxShortDateFormatSpec*2> showDate; |
|
436 |
GetShowIcons(&aShowInfo, iconIndex); |
|
437 |
||
438 |
if(aSizeDownloaded > 0) |
|
439 |
{ |
|
440 |
if (aShowInfo.ShowSize() > 0) |
|
441 |
{ |
|
442 |
infoSize.Format(KSizeDownloadingOf(), ((float) aSizeDownloaded / (float) KSizeMb), |
|
443 |
((float)aShowInfo.ShowSize() / (float)KSizeMb)); |
|
444 |
} |
|
445 |
else |
|
446 |
{ |
|
447 |
infoSize.Format(KShowsSizeFormatS60(), (float)aSizeDownloaded / (float)KSizeMb); |
|
448 |
} |
|
449 |
} |
|
450 |
else if (aShowInfo.ShowSize() > 0) |
|
451 |
{ |
|
452 |
infoSize.Format(KShowsSizeFormatS60(), (float)aShowInfo.ShowSize() / (float)KSizeMb); |
|
453 |
} |
|
454 |
else { |
|
455 |
infoSize = KNullDesC(); |
|
456 |
} |
|
457 |
||
458 |
if (aShowInfo.PubDate().Int64() == 0) |
|
459 |
{ |
|
460 |
showDate = KNullDesC(); |
|
461 |
} |
|
462 |
else |
|
463 |
{ |
|
464 |
aShowInfo.PubDate().FormatL(showDate, KDateFormatShort()); |
|
465 |
} |
|
466 |
||
467 |
if(aShowInfo.LastError() != KErrNone) |
|
468 |
{ |
|
6 | 469 |
GetShowErrorText(infoSize, aShowInfo.LastError()); |
2 | 470 |
} |
6 | 471 |
|
472 |
if (infoSize.Length() > 0) |
|
2 | 473 |
{ |
6 | 474 |
infoSize.Insert(0,_L(", ")); |
2 | 475 |
} |
476 |
||
6 | 477 |
iListboxFormatbuffer.Format(KShowFormat(), iconIndex, &aShowInfo.Title(), &showDate, &infoSize); |
2 | 478 |
} |
479 |
||
480 |
void CPodcastShowsView::GetShowErrorText(TDes &aErrorMessage, TInt aErrorCode) |
|
481 |
{ |
|
482 |
iEikonEnv->GetErrorText(aErrorMessage, aErrorCode); |
|
483 |
} |
|
484 |
||
485 |
void CPodcastShowsView::UpdateShowItemDataL(CShowInfo* aShowInfo,TInt aIndex, TInt aSizeDownloaded) |
|
486 |
{ |
|
487 |
FormatShowInfoListBoxItemL(*aShowInfo, aSizeDownloaded); |
|
488 |
iItemArray->Delete(aIndex); |
|
489 |
if(aIndex>= iItemArray->MdcaCount()) |
|
490 |
{ |
|
491 |
iItemArray->AppendL(iListboxFormatbuffer); |
|
492 |
} |
|
493 |
else |
|
494 |
{ |
|
495 |
iItemArray->InsertL(aIndex, iListboxFormatbuffer); |
|
496 |
} |
|
497 |
} |
|
498 |
||
499 |
void CPodcastShowsView::UpdateShowItemL(TUint aUid, TInt aSizeDownloaded) |
|
500 |
{ |
|
501 |
RShowInfoArray& array = iPodcastModel.ActiveShowList(); |
|
502 |
||
503 |
for (int i=0;i<array.Count();i++) { |
|
504 |
if (array[i]->Uid() == aUid) { |
|
505 |
UpdateShowItemDataL(array[i], i, aSizeDownloaded); |
|
506 |
if (iListContainer->Listbox()->TopItemIndex() <= i && |
|
507 |
iListContainer->Listbox()->BottomItemIndex() >= i) { |
|
508 |
iListContainer->Listbox()->DrawItem(i); |
|
509 |
} |
|
510 |
} |
|
511 |
} |
|
512 |
} |
|
513 |
||
514 |
void CPodcastShowsView::UpdateListboxItemsL() |
|
515 |
{ |
|
516 |
if (iListContainer->IsVisible()) |
|
517 |
{ |
|
518 |
TListItemProperties itemProps; |
|
519 |
TInt len = 0; |
|
520 |
||
8 | 521 |
iPodcastModel.GetShowsByFeedL(iPodcastModel.ActiveFeedInfo()->Uid()); |
2 | 522 |
|
523 |
RShowInfoArray &fItems = iPodcastModel.ActiveShowList(); |
|
524 |
len = fItems.Count(); |
|
525 |
||
526 |
if (iListContainer->Listbox() != NULL) |
|
527 |
{ |
|
528 |
TBool allUidsMatch = EFalse; |
|
529 |
||
530 |
if (len == iListContainer->Listbox()->Model()->NumberOfItems()) |
|
531 |
{ |
|
532 |
allUidsMatch = ETrue; |
|
533 |
TUint itemId = 0; |
|
534 |
for (TInt loop = 0; loop< len; loop++) |
|
535 |
{ |
|
536 |
itemId = iItemIdArray[loop]; |
|
537 |
if (fItems[loop]->Uid() != itemId) |
|
538 |
{ |
|
539 |
allUidsMatch = EFalse; |
|
540 |
break; |
|
541 |
} |
|
542 |
} |
|
543 |
} |
|
544 |
||
545 |
if (allUidsMatch && len > 0) |
|
546 |
{ |
|
547 |
for (TInt loop = 0; loop< len; loop++) |
|
548 |
{ |
|
6 | 549 |
UpdateShowItemDataL(fItems[loop], loop); |
10 | 550 |
//iListContainer->Listbox()->DrawItem(loop); |
2 | 551 |
} |
552 |
} |
|
553 |
else |
|
554 |
{ |
|
555 |
iListContainer->Listbox()->ItemDrawer()->ClearAllPropertiesL(); |
|
556 |
iListContainer->Listbox()->Reset(); |
|
557 |
iItemIdArray.Reset(); |
|
558 |
iItemArray->Reset(); |
|
559 |
||
560 |
if (len > 0) |
|
561 |
{ |
|
562 |
for (TInt i=0; i<len; i++) |
|
563 |
{ |
|
564 |
CShowInfo *si = fItems[i]; |
|
565 |
FormatShowInfoListBoxItemL(*si); |
|
566 |
iItemIdArray.Append(si->Uid()); |
|
567 |
iItemArray->AppendL(iListboxFormatbuffer); |
|
568 |
} |
|
569 |
} |
|
570 |
else |
|
571 |
{ |
|
572 |
iItemArray->Reset(); |
|
573 |
iItemIdArray.Reset(); |
|
574 |
||
575 |
itemProps.SetDimmed(ETrue); |
|
576 |
itemProps.SetHiddenSelection(ETrue); |
|
577 |
} |
|
578 |
iListContainer->Listbox()->HandleItemAdditionL(); |
|
579 |
} |
|
580 |
} |
|
581 |
} |
|
582 |
} |
|
583 |
||
584 |
/** |
|
585 |
* Command handling function intended for overriding by sub classes. |
|
586 |
* Default implementation is empty. |
|
587 |
* @param aCommand ID of the command to respond to. |
|
588 |
*/ |
|
589 |
void CPodcastShowsView::HandleCommandL(TInt aCommand) |
|
590 |
{ |
|
591 |
switch (aCommand) |
|
592 |
{ |
|
593 |
case EPodcastMarkAsPlayed: |
|
5 | 594 |
HandleSetShowPlayed(ETrue); |
2 | 595 |
break; |
596 |
case EPodcastMarkAsUnplayed: |
|
5 | 597 |
HandleSetShowPlayed(EFalse); |
2 | 598 |
break; |
599 |
case EPodcastMarkAllPlayed: |
|
600 |
iPodcastModel.MarkSelectionPlayed(); |
|
601 |
UpdateListboxItemsL(); |
|
602 |
break; |
|
603 |
case EPodcastDeleteShow: |
|
5 | 604 |
HandleDeleteShow(); |
2 | 605 |
break; |
606 |
case EPodcastDownloadShow: |
|
607 |
{ |
|
608 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
609 |
if (index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
|
610 |
{ |
|
611 |
iPodcastModel.ShowEngine().AddDownloadL(*iPodcastModel.ActiveShowList()[index]); |
|
612 |
UpdateShowItemL(iPodcastModel.ActiveShowList()[index]->Uid(),-1); |
|
613 |
} |
|
614 |
} |
|
615 |
break; |
|
616 |
case EPodcastUpdateFeed: |
|
617 |
{ |
|
618 |
||
619 |
if (iPodcastModel.ActiveFeedInfo()->Url().Length()>0) |
|
620 |
{ |
|
621 |
TRAPD(error, iPodcastModel.FeedEngine().UpdateFeedL(iPodcastModel.ActiveFeedInfo()->Uid())); |
|
622 |
||
623 |
if (error != KErrNone) |
|
624 |
{ |
|
5 | 625 |
HBufC* str = |
2 | 626 |
iEikonEnv->AllocReadResourceLC(R_PODCAST_FEEDS_UPDATE_ERROR); |
627 |
User::InfoPrint(*str); |
|
628 |
CleanupStack::PopAndDestroy(str); |
|
629 |
} |
|
630 |
} |
|
631 |
} |
|
632 |
break; |
|
633 |
case EPodcastCancelUpdateAllFeeds: |
|
634 |
iPodcastModel.FeedEngine().CancelUpdateAllFeeds(); |
|
635 |
break; |
|
636 |
case EPodcastShowInfo: |
|
637 |
{ |
|
638 |
DisplayShowInfoDialogL(); |
|
639 |
}break; |
|
640 |
default: |
|
641 |
CPodcastListView::HandleCommandL(aCommand); |
|
642 |
break; |
|
643 |
} |
|
644 |
UpdateToolbar(); |
|
645 |
} |
|
646 |
||
647 |
void CPodcastShowsView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) |
|
648 |
{ |
|
649 |
if(aResourceId == R_PODCAST_SHOWSVIEW_MENU) |
|
650 |
{ |
|
651 |
TBool updatingState = iPodcastModel.FeedEngine().ClientState() != EIdle && iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid(); |
|
652 |
aMenuPane->SetItemDimmed(EPodcastMarkAllPlayed, updatingState); |
|
653 |
} |
|
654 |
} |
|
655 |
||
656 |
void CPodcastShowsView::ImageOperationCompleteL(TInt aError) |
|
657 |
{ |
|
658 |
iLastImageHandlerError = aError; |
|
659 |
if(iSetTitlebarImage) |
|
660 |
{ |
|
661 |
iSetTitlebarImage = EFalse; |
|
662 |
if(aError == KErrNone) |
|
663 |
{ |
|
664 |
CAknTitlePane* titlePane = static_cast<CAknTitlePane*> |
|
665 |
( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
666 |
titlePane->SetSmallPicture(iPodcastModel.ImageHandler().ScaledBitmap(), NULL, ETrue); |
|
667 |
} |
|
668 |
else |
|
669 |
{ |
|
670 |
iPodcastModel.ImageHandler().ScaledBitmap(); |
|
671 |
} |
|
672 |
||
673 |
} |
|
674 |
else |
|
675 |
{ |
|
676 |
CActiveScheduler::Stop(); |
|
677 |
} |
|
678 |
} |
|
679 |
||
680 |
void CPodcastShowsView::DisplayShowInfoDialogL() |
|
681 |
{ |
|
682 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
683 |
if (index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
|
684 |
{ |
|
685 |
CShowInfo* info = iPodcastModel.ActiveShowList()[index]; |
|
686 |
TUint32 feedUid = info->FeedUid(); |
|
10 | 687 |
// CFeedInfo* feedInfo = iPodcastModel.FeedEngine().GetFeedInfoByUid(feedUid); |
2 | 688 |
|
689 |
CPodcastImageMessageQueryDialog* note = new ( ELeave ) CPodcastImageMessageQueryDialog( (TDesC*)&info->Description(), (TDesC*)&info->Title() ); |
|
690 |
||
691 |
note->PrepareLC( R_SHOW_INFO_NOTE ); // Adds to CleanupStack |
|
692 |
||
3 | 693 |
// if(feedInfo && feedInfo->ImageFileName().Length()>0) |
694 |
// { |
|
695 |
// CFbsBitmap * bitmap = new (ELeave) CFbsBitmap; |
|
696 |
// CleanupStack::PushL(bitmap); |
|
697 |
// |
|
698 |
// TRAPD(loaderror, iPodcastModel.ImageHandler().LoadFileAndScaleL(bitmap, feedInfo->ImageFileName(), TSize(KPodcastImageWidth, KPodcastImageHeight), *this)); |
|
699 |
// |
|
700 |
// if(loaderror == KErrNone) |
|
701 |
// { |
|
702 |
// CActiveScheduler::Start(); |
|
703 |
// if(iLastImageHandlerError == KErrNone) |
|
704 |
// { |
|
705 |
// CEikImage* image = static_cast<CEikImage*>(note->ControlOrNull(EPodcastShowInfoImage)); |
|
706 |
// image->SetBitmap(bitmap); |
|
707 |
// CleanupStack::Pop(bitmap); |
|
708 |
// bitmap = NULL; |
|
709 |
// } |
|
710 |
// else |
|
711 |
// { |
|
712 |
// CleanupStack::PopAndDestroy(bitmap); |
|
713 |
// bitmap = NULL; |
|
714 |
// } |
|
715 |
// } |
|
716 |
// else |
|
717 |
// { |
|
718 |
// CleanupStack::PopAndDestroy(bitmap); |
|
719 |
// bitmap = NULL; |
|
720 |
// } |
|
721 |
// } |
|
2 | 722 |
|
723 |
note->RunLD(); |
|
724 |
} |
|
725 |
} |
|
726 |
||
727 |
void CPodcastShowsView::UpdateToolbar() |
|
728 |
{ |
|
729 |
CAknToolbar* toolbar = Toolbar(); |
|
730 |
||
731 |
RShowInfoArray &fItems = iPodcastModel.ActiveShowList(); |
|
732 |
TInt itemCnt = fItems.Count(); |
|
733 |
||
734 |
TBool hideDownloadShowCmd = EFalse; |
|
735 |
TBool dimDownloadShowCmd = EFalse; |
|
736 |
TBool hideSetPlayed = EFalse; |
|
737 |
TBool updatingState = iPodcastModel.FeedEngine().ClientState() != EIdle && |
|
738 |
iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid(); |
|
739 |
||
740 |
if(iListContainer->Listbox() != NULL) |
|
741 |
{ |
|
742 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
743 |
||
744 |
if(index>= 0 && index < itemCnt) |
|
745 |
{ |
|
746 |
switch(fItems[index]->DownloadState()) |
|
747 |
{ |
|
748 |
case ENotDownloaded: |
|
749 |
case EFailedDownload: |
|
750 |
hideDownloadShowCmd = EFalse; |
|
751 |
dimDownloadShowCmd = EFalse; |
|
752 |
break; |
|
753 |
case EQueued: |
|
754 |
case EDownloading: |
|
755 |
hideDownloadShowCmd = EFalse; |
|
756 |
dimDownloadShowCmd = ETrue; |
|
757 |
break; |
|
758 |
case EDownloaded: |
|
759 |
hideDownloadShowCmd = ETrue; |
|
760 |
break; |
|
761 |
} |
|
762 |
||
763 |
if(fItems[index]->PlayState() == EPlayed) { |
|
764 |
hideSetPlayed = ETrue; |
|
765 |
} |
|
766 |
} |
|
767 |
} |
|
768 |
||
769 |
toolbar->HideItem(EPodcastUpdateFeed, updatingState, ETrue ); |
|
770 |
toolbar->HideItem(EPodcastCancelUpdateAllFeeds, !updatingState, ETrue ); |
|
771 |
||
772 |
if (hideDownloadShowCmd) { |
|
773 |
toolbar->HideItem(EPodcastDownloadShow, ETrue, ETrue ); |
|
774 |
toolbar->HideItem(EPodcastDeleteShow, EFalse, ETrue); |
|
775 |
toolbar->SetItemDimmed(EPodcastDeleteShow, updatingState, ETrue); |
|
776 |
} else { |
|
777 |
toolbar->HideItem(EPodcastDownloadShow, EFalse, ETrue ); |
|
778 |
toolbar->HideItem(EPodcastDeleteShow, ETrue, ETrue); |
|
779 |
toolbar->SetItemDimmed(EPodcastDownloadShow, updatingState || dimDownloadShowCmd, ETrue); |
|
780 |
} |
|
781 |
||
782 |
if (hideSetPlayed) { |
|
783 |
toolbar->HideItem(EPodcastMarkAsPlayed, ETrue, ETrue ); |
|
784 |
toolbar->HideItem(EPodcastMarkAsUnplayed, EFalse, ETrue ); |
|
785 |
toolbar->SetItemDimmed(EPodcastMarkAsUnplayed, updatingState, ETrue); |
|
786 |
} else { |
|
787 |
toolbar->HideItem(EPodcastMarkAsPlayed, EFalse, ETrue ); |
|
788 |
toolbar->HideItem(EPodcastMarkAsUnplayed, ETrue, ETrue ); |
|
789 |
toolbar->SetItemDimmed(EPodcastMarkAsPlayed, updatingState, ETrue); |
|
790 |
} |
|
791 |
} |
|
792 |
||
793 |
void CPodcastShowsView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */) |
|
794 |
{ |
|
795 |
DP("CPodcastShowsView::HandleLongTapEventL BEGIN"); |
|
796 |
||
4
be243543a361
Added primitive detection if long tap is on a listbox item or not. Could use a better version of this going forward.
teknolog
parents:
3
diff
changeset
|
797 |
const TInt KListboxDefaultHeight = 19; // for some reason it returns 19 for an empty listbox in S^1 |
be243543a361
Added primitive detection if long tap is on a listbox item or not. Could use a better version of this going forward.
teknolog
parents:
3
diff
changeset
|
798 |
TInt lbHeight = iListContainer->Listbox()->CalcHeightBasedOnNumOfItems( |
be243543a361
Added primitive detection if long tap is on a listbox item or not. Could use a better version of this going forward.
teknolog
parents:
3
diff
changeset
|
799 |
iListContainer->Listbox()->Model()->NumberOfItems()) - KListboxDefaultHeight; |
be243543a361
Added primitive detection if long tap is on a listbox item or not. Could use a better version of this going forward.
teknolog
parents:
3
diff
changeset
|
800 |
|
be243543a361
Added primitive detection if long tap is on a listbox item or not. Could use a better version of this going forward.
teknolog
parents:
3
diff
changeset
|
801 |
if(iStylusPopupMenu && aPenEventLocation.iY < lbHeight) |
2 | 802 |
{ |
803 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
804 |
if (index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
|
805 |
{ |
|
806 |
CShowInfo *info = iPodcastModel.ActiveShowList()[index]; |
|
807 |
TBool hideDownloadShowCmd = info->DownloadState() != ENotDownloaded; |
|
808 |
TBool hideDeleteShowCmd = info->DownloadState() != EDownloaded; |
|
809 |
TBool hideMarkOld = info->PlayState() == EPlayed; |
|
810 |
||
811 |
iStylusPopupMenu->SetItemDimmed(EPodcastMarkAsPlayed, hideMarkOld); |
|
812 |
iStylusPopupMenu->SetItemDimmed(EPodcastMarkAsUnplayed, !hideMarkOld); |
|
813 |
||
814 |
iStylusPopupMenu->SetItemDimmed(EPodcastDownloadShow, hideDownloadShowCmd); |
|
815 |
iStylusPopupMenu->SetItemDimmed(EPodcastDeleteShow, hideDeleteShowCmd); |
|
816 |
} |
|
817 |
||
818 |
iStylusPopupMenu->ShowMenu(); |
|
819 |
iStylusPopupMenu->SetPosition(aPenEventLocation); |
|
820 |
} |
|
821 |
DP("CPodcastShowsView::HandleLongTapEventL END"); |
|
822 |
} |
|
823 |
||
5 | 824 |
void CPodcastShowsView::HandleSetShowPlayed(TBool aPlayed) |
2 | 825 |
{ |
826 |
||
827 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
828 |
||
829 |
if (index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
|
830 |
{ |
|
831 |
CShowInfo *info = iPodcastModel.ActiveShowList()[index]; |
|
832 |
info->SetPlayState(aPlayed ? EPlayed : ENeverPlayed); |
|
833 |
iPodcastModel.ShowEngine().UpdateShow(*info); |
|
834 |
UpdateShowItemDataL(iPodcastModel.ActiveShowList()[index], index, 0); |
|
835 |
iListContainer->Listbox()->DrawItem(index); |
|
836 |
} |
|
837 |
} |
|
838 |
||
5 | 839 |
void CPodcastShowsView::HandleDeleteShow() |
2 | 840 |
{ |
841 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
842 |
||
843 |
if (index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
|
844 |
{ |
|
845 |
CShowInfo *info = iPodcastModel.ActiveShowList()[index]; |
|
846 |
TBuf<KMaxMessageLength> msg; |
|
847 |
TBuf<KMaxMessageLength> templ; |
|
848 |
iEikonEnv->ReadResourceL(templ, R_PODCAST_DELETE_SHOW_PROMPT); |
|
849 |
msg.Format(templ, &(info->Title())); |
|
850 |
if (ShowQueryMessage(msg)) |
|
851 |
{ |
|
852 |
iPodcastModel.ShowEngine().DeleteShowL(iPodcastModel.ActiveShowList()[index]->Uid()); |
|
853 |
||
854 |
// and mark as played, and not downloaded |
|
855 |
||
856 |
info->SetDownloadState(ENotDownloaded); |
|
857 |
info->SetPlayState(EPlayed); |
|
858 |
iPodcastModel.ShowEngine().UpdateShow(*info); |
|
859 |
||
860 |
UpdateShowItemDataL(iPodcastModel.ActiveShowList()[index], index, 0); |
|
861 |
iListContainer->Listbox()->DrawItem(index); |
|
862 |
} |
|
863 |
} |
|
864 |
} |
|
865 |
||
866 |
void CPodcastShowsView::DownloadQueueUpdatedL(TInt /*aDownloadingShows*/, TInt /*aQueuedShows*/) |
|
867 |
{ |
|
868 |
//((CPodcastAppUi*)AppUi())->UpdateQueueTab(aDownloadingShows+aQueuedShows); |
|
869 |
} |
|
870 |
||
871 |
void CPodcastShowsView::FeedUpdateAllCompleteL(TFeedState /*aState*/) |
|
872 |
{ |
|
873 |
UpdateListboxItemsL(); |
|
874 |
UpdateToolbar(); |
|
875 |
} |
|
876 |
||
877 |
void CPodcastShowsView::UpdateViewTitleL() |
|
878 |
{ |
|
879 |
DP("CPodcastShowsView::UpdateViewTitleL BEGIN"); |
|
880 |
CAknTitlePane* titlePane = static_cast<CAknTitlePane*> |
|
881 |
( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
882 |
||
883 |
TBool updatingState = iPodcastModel.FeedEngine().ClientState() != EIdle && |
|
884 |
iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid(); |
|
885 |
||
886 |
if (updatingState) { |
|
887 |
SetEmptyTextL(R_PODCAST_EMPTY_LIST_UPDATING); |
|
888 |
} else { |
|
889 |
SetEmptyTextL(R_PODCAST_EMPTY_LIST); |
|
890 |
} |
|
891 |
||
892 |
if(iPodcastModel.ActiveFeedInfo()) |
|
893 |
{ |
|
894 |
if (iPodcastModel.ActiveFeedInfo()->Title() != KNullDesC) |
|
895 |
{ |
|
896 |
titlePane->SetTextL( iPodcastModel.ActiveFeedInfo()->Title(), ETrue ); |
|
897 |
} |
|
898 |
} |
|
899 |
else |
|
900 |
{ |
|
901 |
titlePane->SetPicture(NULL, NULL); |
|
902 |
titlePane->SetTextToDefaultL(); |
|
903 |
} |
|
904 |
||
905 |
DP("CPodcastShowsView::UpdateViewTitleL END"); |
|
906 |
} |