32 #include <aknnotedialog.h> |
32 #include <aknnotedialog.h> |
33 #include <aknmessagequerydialog.h> |
33 #include <aknmessagequerydialog.h> |
34 |
34 |
35 #define KMaxMessageLength 200 |
35 #define KMaxMessageLength 200 |
36 |
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"); |
37 _LIT(KSizeDownloadingOf, "%.1f/%.1f MB"); |
46 _LIT(KShowsSizeFormatS60, "%.1f MB"); |
38 _LIT(KShowsSizeFormatS60, "%.1f MB"); |
47 |
39 |
48 _LIT(KShowFormat, "%d\t%S\t%S%S\t"); |
40 _LIT(KShowFormat, "%d\t%S\t%S%S\t"); |
49 _LIT(KShowErrorFormat, "%d\t%S\t%S\t"); |
41 _LIT(KShowErrorFormat, "%d\t%S\t%S\t"); |
67 EMbmPodcastAudio_downloaded_new_mask, |
59 EMbmPodcastAudio_downloaded_new_mask, |
68 EMbmPodcastAudio_failed, |
60 EMbmPodcastAudio_failed, |
69 EMbmPodcastAudio_failed_mask, |
61 EMbmPodcastAudio_failed_mask, |
70 EMbmPodcastAudio_suspended, |
62 EMbmPodcastAudio_suspended, |
71 EMbmPodcastAudio_suspended_mask, |
63 EMbmPodcastAudio_suspended_mask, |
|
64 EMbmPodcastVideo, |
|
65 EMbmPodcastVideo_mask, |
|
66 EMbmPodcastVideo_new, |
|
67 EMbmPodcastVideo_new_mask, |
|
68 EMbmPodcastVideo_queued, |
|
69 EMbmPodcastVideo_queued_mask, |
|
70 EMbmPodcastVideo_downloading, |
|
71 EMbmPodcastVideo_downloading_mask, |
|
72 EMbmPodcastVideo_downloaded, |
|
73 EMbmPodcastVideo_downloaded_mask, |
|
74 EMbmPodcastVideo_downloaded_new, |
|
75 EMbmPodcastVideo_downloaded_new_mask, |
|
76 EMbmPodcastVideo_failed, |
|
77 EMbmPodcastVideo_failed_mask, |
|
78 EMbmPodcastVideo_suspended, |
|
79 EMbmPodcastVideo_suspended_mask, |
|
80 EMbmPodcastFeed, |
|
81 EMbmPodcastFeed_mask, |
72 0, |
82 0, |
73 0 |
83 0 |
74 }; |
84 }; |
|
85 |
|
86 const TInt KVideoIconOffset = 8; |
75 |
87 |
76 CPodcastShowsView* CPodcastShowsView::NewL(CPodcastModel& aPodcastModel) |
88 CPodcastShowsView* CPodcastShowsView::NewL(CPodcastModel& aPodcastModel) |
77 { |
89 { |
78 CPodcastShowsView* self = CPodcastShowsView::NewLC(aPodcastModel); |
90 CPodcastShowsView* self = CPodcastShowsView::NewLC(aPodcastModel); |
79 CleanupStack::Pop(self); |
91 CleanupStack::Pop(self); |
118 CArrayPtr< CGulIcon>* icons = new(ELeave) CArrayPtrFlat< CGulIcon>(1); |
130 CArrayPtr< CGulIcon>* icons = new(ELeave) CArrayPtrFlat< CGulIcon>(1); |
119 CleanupStack::PushL(icons); |
131 CleanupStack::PushL(icons); |
120 TInt pos = 0; |
132 TInt pos = 0; |
121 while (KShowIconArrayIds[pos] > 0) |
133 while (KShowIconArrayIds[pos] > 0) |
122 { |
134 { |
123 // Load the bitmap for play icon |
135 // Load the icon |
124 CFbsBitmap* bitmap= NULL;//iEikonEnv->CreateBitmapL( _L("*"), KIconArrayIds[pos]); |
136 CFbsBitmap* bitmap= NULL; |
125 CFbsBitmap* mask= NULL;////iEikonEnv->CreateBitmapL( _L("*"), KIconArrayIds[pos+1] ); |
137 CFbsBitmap* mask= NULL; |
126 AknIconUtils::CreateIconL(bitmap, |
138 AknIconUtils::CreateIconL(bitmap, |
127 mask, |
139 mask, |
128 iEikonEnv->EikAppUi()->Application()->BitmapStoreName(), |
140 iEikonEnv->EikAppUi()->Application()->BitmapStoreName(), |
129 KShowIconArrayIds[pos], |
141 KShowIconArrayIds[pos], |
130 KShowIconArrayIds[pos+1]); |
142 KShowIconArrayIds[pos+1]); |
131 CleanupStack::PushL(bitmap); |
143 CleanupStack::PushL(bitmap); |
132 CleanupStack::PushL(mask); |
144 CleanupStack::PushL(mask); |
133 |
145 |
134 // Append the play icon to icon array |
146 // Append the icon to icon array |
135 icons->AppendL(CGulIcon::NewL(bitmap, mask) ); |
147 icons->AppendL(CGulIcon::NewL(bitmap, mask) ); |
136 CleanupStack::Pop(2); // bitmap, mask |
148 CleanupStack::Pop(2); // bitmap, mask |
137 pos+=2; |
149 pos+=2; |
138 } |
150 } |
139 |
151 |
201 |
213 |
202 void CPodcastShowsView::DoActivateL(const TVwsViewId& aPrevViewId, |
214 void CPodcastShowsView::DoActivateL(const TVwsViewId& aPrevViewId, |
203 TUid aCustomMessageId, const TDesC8& aCustomMessage) |
215 TUid aCustomMessageId, const TDesC8& aCustomMessage) |
204 { |
216 { |
205 DP("CPodcastShowsView::DoActivateL BEGIN"); |
217 DP("CPodcastShowsView::DoActivateL BEGIN"); |
|
218 CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage); |
|
219 |
|
220 iPreviousView = TVwsViewId(KUidPodcast, KUidPodcastFeedViewID); |
206 |
221 |
207 UpdateViewTitleL(); |
222 UpdateViewTitleL(); |
208 |
|
209 CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage); |
|
210 iPreviousView = TVwsViewId(KUidPodcast, KUidPodcastFeedViewID); |
|
211 |
|
212 UpdateFeedUpdateStateL(); |
223 UpdateFeedUpdateStateL(); |
213 UpdateToolbar(); |
224 UpdateToolbar(); |
214 DP("CPodcastShowsView::DoActivateL END"); |
225 DP("CPodcastShowsView::DoActivateL END"); |
215 } |
226 } |
216 |
227 |
217 void CPodcastShowsView::DoDeactivate() |
228 void CPodcastShowsView::DoDeactivate() |
218 { |
229 { |
219 CAknTitlePane* titlePane = static_cast<CAknTitlePane*> |
|
220 ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
221 |
|
222 // titlePane->SetSmallPicture(NULL, NULL, ETrue); |
|
223 titlePane->SetPicture(NULL, NULL); |
|
224 titlePane->SetTextToDefaultL(); |
|
225 CPodcastListView::DoDeactivate(); |
230 CPodcastListView::DoDeactivate(); |
226 } |
231 } |
227 |
232 |
228 // Engine callback when new shows are available |
233 // Engine callback when new shows are available |
229 void CPodcastShowsView::ShowListUpdatedL() |
234 void CPodcastShowsView::ShowListUpdatedL() |
437 } |
447 } |
438 |
448 |
439 if(aShowInfo.LastError() != KErrNone) |
449 if(aShowInfo.LastError() != KErrNone) |
440 { |
450 { |
441 GetShowErrorText(infoSize, aShowInfo.LastError()); |
451 GetShowErrorText(infoSize, aShowInfo.LastError()); |
442 } |
452 showDate.Zero(); |
443 |
453 } |
444 if (infoSize.Length() > 0) |
454 |
|
455 if (infoSize.Length() > 0 && showDate.Length() > 0) |
445 { |
456 { |
446 infoSize.Insert(0,_L(", ")); |
457 infoSize.Insert(0,_L(", ")); |
447 } |
458 } |
448 |
459 |
449 iListboxFormatbuffer.Format(KShowFormat(), iconIndex, &aShowInfo.Title(), &showDate, &infoSize); |
460 iListboxFormatbuffer.Format(KShowFormat(), iconIndex, &aShowInfo.Title(), &showDate, &infoSize); |
450 } |
461 } |
451 |
462 |
452 void CPodcastShowsView::GetShowErrorText(TDes &aErrorMessage, TInt aErrorCode) |
463 void CPodcastShowsView::GetShowErrorText(TDes &aErrorMessage, TInt aErrorCode) |
453 { |
464 { |
454 iEikonEnv->GetErrorText(aErrorMessage, aErrorCode); |
465 TRAP_IGNORE(((CPodcastAppUi*)AppUi())->GetErrorTextL(aErrorMessage,aErrorCode)); |
455 } |
466 } |
456 |
467 |
457 void CPodcastShowsView::UpdateShowItemDataL(CShowInfo* aShowInfo,TInt aIndex, TInt aSizeDownloaded) |
468 void CPodcastShowsView::UpdateShowItemDataL(CShowInfo* aShowInfo,TInt aIndex, TInt aSizeDownloaded) |
458 { |
469 { |
459 FormatShowInfoListBoxItemL(*aShowInfo, aSizeDownloaded); |
470 FormatShowInfoListBoxItemL(*aShowInfo, aSizeDownloaded); |
561 void CPodcastShowsView::HandleCommandL(TInt aCommand) |
572 void CPodcastShowsView::HandleCommandL(TInt aCommand) |
562 { |
573 { |
563 switch (aCommand) |
574 switch (aCommand) |
564 { |
575 { |
565 case EPodcastMarkAsPlayed: |
576 case EPodcastMarkAsPlayed: |
566 HandleSetShowPlayed(ETrue); |
577 HandleSetShowPlayedL(ETrue); |
567 break; |
578 break; |
568 case EPodcastMarkAsUnplayed: |
579 case EPodcastMarkAsUnplayed: |
569 HandleSetShowPlayed(EFalse); |
580 HandleSetShowPlayedL(EFalse); |
570 break; |
581 break; |
571 case EPodcastMarkAllPlayed: |
582 case EPodcastMarkAllPlayed: |
572 iPodcastModel.MarkSelectionPlayed(); |
583 iPodcastModel.MarkSelectionPlayedL(); |
573 UpdateListboxItemsL(); |
584 UpdateListboxItemsL(); |
574 break; |
585 break; |
575 case EPodcastDeleteShow: |
586 case EPodcastDeleteShow: |
576 HandleDeleteShow(); |
587 HandleDeleteShowL(); |
577 break; |
588 break; |
578 case EPodcastDownloadShow: |
589 case EPodcastDownloadShow: |
579 { |
590 { |
580 TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
591 TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
581 |
592 |
625 { |
636 { |
626 TBool updatingState = iPodcastModel.FeedEngine().ClientState() != EIdle && iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid(); |
637 TBool updatingState = iPodcastModel.FeedEngine().ClientState() != EIdle && iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid(); |
627 aMenuPane->SetItemDimmed(EPodcastMarkAllPlayed, updatingState); |
638 aMenuPane->SetItemDimmed(EPodcastMarkAllPlayed, updatingState); |
628 } |
639 } |
629 } |
640 } |
630 |
|
631 void CPodcastShowsView::ImageOperationCompleteL(TInt aError, TUint /*aHandle*/) |
|
632 { |
|
633 iLastImageHandlerError = aError; |
|
634 if(iSetTitlebarImage) |
|
635 { |
|
636 iSetTitlebarImage = EFalse; |
|
637 if(aError == KErrNone) |
|
638 { |
|
639 CAknTitlePane* titlePane = static_cast<CAknTitlePane*> |
|
640 ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
641 titlePane->SetSmallPicture(iPodcastModel.ImageHandler().ScaledBitmap(), NULL, ETrue); |
|
642 } |
|
643 else |
|
644 { |
|
645 iPodcastModel.ImageHandler().ScaledBitmap(); |
|
646 } |
|
647 |
|
648 } |
|
649 else |
|
650 { |
|
651 CActiveScheduler::Stop(); |
|
652 } |
|
653 } |
|
654 |
641 |
655 void CPodcastShowsView::DisplayShowInfoDialogL() |
642 void CPodcastShowsView::DisplayShowInfoDialogL() |
656 { |
643 { |
657 TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
644 TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
658 if (index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
645 if (index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
681 TBool updatingState = iPodcastModel.FeedEngine().ClientState() != EIdle && |
668 TBool updatingState = iPodcastModel.FeedEngine().ClientState() != EIdle && |
682 iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid(); |
669 iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid(); |
683 |
670 |
684 toolbar->HideItem(EPodcastUpdateFeed, updatingState, ETrue ); |
671 toolbar->HideItem(EPodcastUpdateFeed, updatingState, ETrue ); |
685 toolbar->HideItem(EPodcastCancelUpdateAllFeeds, !updatingState, ETrue ); |
672 toolbar->HideItem(EPodcastCancelUpdateAllFeeds, !updatingState, ETrue ); |
686 |
673 #ifndef SYMBIAN1_UI |
687 #ifdef SYMBIAN1_UI |
674 // there seems to be drawing bugs in the toolbar if there is only |
|
675 // one or two buttons defined in the resource, so we have download |
|
676 // there but always hidden |
|
677 toolbar->HideItem(EPodcastDownloadShow, ETrue, ETrue ); |
|
678 #else SYMBIAN1_UI |
688 RShowInfoArray &fItems = iPodcastModel.ActiveShowList(); |
679 RShowInfoArray &fItems = iPodcastModel.ActiveShowList(); |
689 TInt itemCnt = fItems.Count(); |
680 TInt itemCnt = fItems.Count(); |
690 |
681 |
691 TBool hideDownloadShowCmd = EFalse; |
682 TBool hideDownloadShowCmd = EFalse; |
692 TBool dimDownloadShowCmd = EFalse; |
683 TBool dimDownloadShowCmd = EFalse; |
746 |
737 |
747 void CPodcastShowsView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */) |
738 void CPodcastShowsView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */) |
748 { |
739 { |
749 DP("CPodcastShowsView::HandleLongTapEventL BEGIN"); |
740 DP("CPodcastShowsView::HandleLongTapEventL BEGIN"); |
750 |
741 |
751 iListContainer->SetLongTapDetected(ETrue); |
742 iListContainer->SetLongTapDetectedL(ETrue); |
752 |
743 |
753 const TInt KListboxDefaultHeight = 19; // for some reason it returns 19 for an empty listbox in S^1 |
744 const TInt KListboxDefaultHeight = 19; // for some reason it returns 19 for an empty listbox in S^1 |
754 TInt lbHeight = iListContainer->Listbox()->CalcHeightBasedOnNumOfItems( |
745 TInt lbHeight = iListContainer->Listbox()->CalcHeightBasedOnNumOfItems( |
755 iListContainer->Listbox()->Model()->NumberOfItems()) - KListboxDefaultHeight; |
746 iListContainer->Listbox()->Model()->NumberOfItems()) - KListboxDefaultHeight; |
756 |
747 |
775 iStylusPopupMenu->SetPosition(aPenEventLocation); |
766 iStylusPopupMenu->SetPosition(aPenEventLocation); |
776 } |
767 } |
777 DP("CPodcastShowsView::HandleLongTapEventL END"); |
768 DP("CPodcastShowsView::HandleLongTapEventL END"); |
778 } |
769 } |
779 |
770 |
780 void CPodcastShowsView::HandleSetShowPlayed(TBool aPlayed) |
771 void CPodcastShowsView::HandleSetShowPlayedL(TBool aPlayed) |
781 { |
772 { |
782 |
773 |
783 TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
774 TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
784 |
775 |
785 if (index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
776 if (index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
786 { |
777 { |
787 CShowInfo *info = iPodcastModel.ActiveShowList()[index]; |
778 CShowInfo *info = iPodcastModel.ActiveShowList()[index]; |
788 info->SetPlayState(aPlayed ? EPlayed : ENeverPlayed); |
779 info->SetPlayState(aPlayed ? EPlayed : ENeverPlayed); |
789 iPodcastModel.ShowEngine().UpdateShow(*info); |
780 iPodcastModel.ShowEngine().UpdateShowL(*info); |
790 UpdateShowItemDataL(iPodcastModel.ActiveShowList()[index], index, 0); |
781 UpdateShowItemDataL(iPodcastModel.ActiveShowList()[index], index, 0); |
791 iListContainer->Listbox()->DrawItem(index); |
782 iListContainer->Listbox()->DrawItem(index); |
792 } |
783 } |
793 } |
784 } |
794 |
785 |
795 void CPodcastShowsView::HandleDeleteShow() |
786 void CPodcastShowsView::HandleDeleteShowL() |
796 { |
787 { |
797 TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
788 TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
798 |
789 |
799 if (index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
790 if (index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
800 { |
791 { |
801 CShowInfo *info = iPodcastModel.ActiveShowList()[index]; |
792 CShowInfo *info = iPodcastModel.ActiveShowList()[index]; |
802 TBuf<KMaxMessageLength> msg; |
793 TBuf<KMaxMessageLength> msg; |
803 TBuf<KMaxMessageLength> templ; |
794 TBuf<KMaxMessageLength> templ; |
804 iEikonEnv->ReadResourceL(templ, R_PODCAST_DELETE_SHOW_PROMPT); |
795 iEikonEnv->ReadResourceL(templ, R_PODCAST_DELETE_SHOW_PROMPT); |
805 msg.Format(templ, &(info->Title())); |
796 msg.Format(templ, &(info->Title())); |
806 if (ShowQueryMessage(msg)) |
797 if (ShowQueryMessageL(msg)) |
807 { |
798 { |
808 iPodcastModel.ShowEngine().DeleteShowL(iPodcastModel.ActiveShowList()[index]->Uid()); |
799 iPodcastModel.ShowEngine().DeleteShowL(iPodcastModel.ActiveShowList()[index]->Uid()); |
809 |
800 |
810 // and mark as played, and not downloaded |
801 // and mark as played, and not downloaded |
811 |
802 |
812 info->SetDownloadState(ENotDownloaded); |
803 info->SetDownloadState(ENotDownloaded); |
813 info->SetPlayState(EPlayed); |
804 info->SetPlayState(EPlayed); |
814 iPodcastModel.ShowEngine().UpdateShow(*info); |
805 iPodcastModel.ShowEngine().UpdateShowL(*info); |
815 |
806 |
816 UpdateShowItemDataL(iPodcastModel.ActiveShowList()[index], index, 0); |
807 UpdateShowItemDataL(iPodcastModel.ActiveShowList()[index], index, 0); |
817 iListContainer->Listbox()->DrawItem(index); |
808 iListContainer->Listbox()->DrawItem(index); |
818 } |
809 } |
819 } |
810 } |
820 } |
811 } |
821 |
812 |
822 void CPodcastShowsView::DownloadQueueUpdatedL(TInt aDownloadingShows, TInt aQueuedShows) |
813 void CPodcastShowsView::DownloadQueueUpdatedL(TInt aDownloadingShows, TInt aQueuedShows) |
823 { |
814 { |
824 ((CPodcastAppUi*)AppUi())->UpdateQueueTab(aDownloadingShows+aQueuedShows); |
815 ((CPodcastAppUi*)AppUi())->UpdateQueueTabL(aDownloadingShows+aQueuedShows); |
825 UpdateListboxItemsL(); |
816 UpdateListboxItemsL(); |
826 } |
817 } |
827 |
818 |
828 void CPodcastShowsView::FeedUpdateAllCompleteL(TFeedState /*aState*/) |
819 void CPodcastShowsView::FeedUpdateAllCompleteL(TFeedState /*aState*/) |
829 { |
820 { |