126 iPodcastModel.FeedEngine().RemoveObserver(this); |
125 iPodcastModel.FeedEngine().RemoveObserver(this); |
127 delete iFeedsFormat; |
126 delete iFeedsFormat; |
128 delete iNeverUpdated; |
127 delete iNeverUpdated; |
129 delete iStylusPopupMenu; |
128 delete iStylusPopupMenu; |
130 delete iUpdater; |
129 delete iUpdater; |
|
130 iFeedIdForIconArray.Close(); |
131 } |
131 } |
132 |
132 |
133 void CPodcastFeedView::UpdateItemL(TInt aIndex) |
133 void CPodcastFeedView::UpdateItemL(TInt aIndex) |
134 { |
134 { |
135 _LIT(KPanicCategory, "CPodcastFeedView::UpdateItemL"); |
135 __ASSERT_DEBUG(iListContainer->IsVisible(), Panic(EPodcatcherPanicFeedView)); |
136 __ASSERT_DEBUG(iListContainer->IsVisible(), User::Panic(KPanicCategory, 0)); |
136 __ASSERT_ALWAYS(iItemIdArray.Count() > aIndex, Panic(EPodcatcherPanicFeedView)); |
137 __ASSERT_ALWAYS(iItemIdArray.Count() > aIndex, User::Panic(KPanicCategory, 1)); |
|
138 |
137 |
139 const RFeedInfoArray& sortedItems = iPodcastModel.FeedEngine().GetSortedFeeds(); |
138 const RFeedInfoArray& sortedItems = iPodcastModel.FeedEngine().GetSortedFeeds(); |
140 __ASSERT_ALWAYS(sortedItems.Count() > aIndex, User::Panic(KPanicCategory, 2)); |
139 __ASSERT_ALWAYS(sortedItems.Count() > aIndex, Panic(EPodcatcherPanicFeedView)); |
141 |
140 |
142 // Update UID of for the feed at aIndex |
141 // Update UID of for the feed at aIndex |
143 iItemIdArray[aIndex] = sortedItems[aIndex]->Uid(); |
142 iItemIdArray[aIndex] = sortedItems[aIndex]->Uid(); |
144 |
143 |
145 // Prepare data to update the listbox item with |
144 // Prepare data to update the listbox item with |
210 { |
201 { |
211 DP("CPodcastFeedView::HandleListBoxEventL BEGIN"); |
202 DP("CPodcastFeedView::HandleListBoxEventL BEGIN"); |
212 |
203 |
213 switch(aEventType) |
204 switch(aEventType) |
214 { |
205 { |
215 case EEventPenDownOnItem: |
206 #ifndef SYMBIAN1_UI |
216 DP("PEN DOWN"); |
|
217 break; |
|
218 |
|
219 //#ifndef SYMBIAN1_UI |
|
220 case EEventItemClicked: |
207 case EEventItemClicked: |
221 DP("SINGLE TAP"); |
208 #endif |
222 break; |
|
223 //#endif |
|
224 case EEventEnterKeyPressed: |
209 case EEventEnterKeyPressed: |
225 case EEventItemDoubleClicked: |
210 case EEventItemDoubleClicked: |
226 case EEventItemActioned: |
211 case EEventItemActioned: |
227 DP("DOUBLE TAP"); |
|
228 { |
212 { |
229 const RFeedInfoArray* sortedItems = NULL; |
213 const RFeedInfoArray* sortedItems = NULL; |
230 TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
214 TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
231 sortedItems = &iPodcastModel.FeedEngine().GetSortedFeeds(); |
215 sortedItems = &iPodcastModel.FeedEngine().GetSortedFeeds(); |
232 |
216 |
233 if(index >= 0 && index < sortedItems->Count()) |
217 if(index >= 0 && index < sortedItems->Count()) |
234 { |
218 { |
235 iPodcastModel.ActiveShowList().Reset(); |
|
236 iPodcastModel.SetActiveFeedInfo((*sortedItems)[index]); |
219 iPodcastModel.SetActiveFeedInfo((*sortedItems)[index]); |
237 iViewingShows = ETrue; |
220 iViewingShows = ETrue; |
238 AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID, TUid::Uid(0), KNullDesC8()); |
221 AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID, TUid::Uid(0), KNullDesC8()); |
239 } |
222 } |
240 } |
223 } |
374 } |
358 } |
375 |
359 |
376 if(aFeedInfo.LastError() != KErrNone) |
360 if(aFeedInfo.LastError() != KErrNone) |
377 { |
361 { |
378 GetFeedErrorText(unplayedShows, aFeedInfo.LastError()); |
362 GetFeedErrorText(unplayedShows, aFeedInfo.LastError()); |
|
363 updatedDate.Zero(); |
379 } |
364 } |
380 } |
365 } |
381 CArrayPtr<CGulIcon>* icons = iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->IconArray(); |
366 CArrayPtr<CGulIcon>* icons = iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->IconArray(); |
382 |
367 iconIndex = iFeedIdForIconArray.Find(aFeedInfo.Uid()); |
383 if (aFeedInfo.FeedIconIndex() != -1) { |
368 if(iconIndex == KErrNotFound && aFeedInfo.FeedIcon() != NULL && aFeedInfo.ImageFileName().Length() > 0 && |
384 iconIndex = aFeedInfo.FeedIconIndex(); |
369 aFeedInfo.FeedIcon()->SizeInPixels().iHeight > 0 && |
385 } else { |
370 aFeedInfo.FeedIcon()->SizeInPixels().iWidth > 0) |
386 if(aFeedInfo.FeedIcon() != NULL && |
371 { |
387 aFeedInfo.FeedIcon()->SizeInPixels().iHeight > 0 && |
372 // Hopefully temporary haxx to prevent double delete. I would prefer if |
388 aFeedInfo.FeedIcon()->SizeInPixels().iWidth > 0) |
373 // this could be solved with a little better design. |
389 { |
374 CFbsBitmap* bmpCopy = new (ELeave) CFbsBitmap; |
390 // Hopefully temporary haxx to prevent double delete. I would prefer if |
375 CleanupStack::PushL(bmpCopy); |
391 // this could be solved with a little better design. |
376 bmpCopy->Duplicate(aFeedInfo.FeedIcon()->Handle()); |
392 CFbsBitmap* bmpCopy = new (ELeave) CFbsBitmap; |
377 icons->AppendL( CGulIcon::NewL(bmpCopy, NULL)); |
393 CleanupStack::PushL(bmpCopy); |
378 iFeedIdForIconArray.Append(aFeedInfo.Uid()); |
394 bmpCopy->Duplicate(aFeedInfo.FeedIcon()->Handle()); |
379 CleanupStack::Pop(bmpCopy); |
395 icons->AppendL( CGulIcon::NewL(bmpCopy, NULL)); |
380 iconIndex = icons->Count()-1; |
396 CleanupStack::Pop(bmpCopy); |
381 } |
397 iconIndex = icons->Count()-1; |
382 else |
398 aFeedInfo.SetFeedIconIndex(iconIndex); |
383 { |
399 } |
384 iconIndex++; |
400 else { |
385 } |
401 if(BaflUtils::FileExists(iEikonEnv->FsSession(), aFeedInfo.ImageFileName())) |
386 |
402 { |
387 if (unplayedShows.Length() > 0 && updatedDate.Length() > 0) { |
403 // If this fails, no reason to worry |
|
404 TRAP_IGNORE(iPodcastModel.ImageHandler().LoadFileAndScaleL(aFeedInfo.FeedIcon(), aFeedInfo.ImageFileName(), TSize(64,56), *this, aFeedInfo.Uid())); |
|
405 } |
|
406 } |
|
407 } |
|
408 |
|
409 if (unplayedShows.Length() > 0) { |
|
410 unplayedShows.Insert(0,_L(", ")); |
388 unplayedShows.Insert(0,_L(", ")); |
411 } |
389 } |
412 |
390 |
413 iListboxFormatbuffer.Format(KFeedFormat(), iconIndex, &(aFeedInfo.Title()), &updatedDate, &unplayedShows); |
391 iListboxFormatbuffer.Format(KFeedFormat(), iconIndex, &(aFeedInfo.Title()), &updatedDate, &unplayedShows); |
414 } |
392 } |
415 |
393 |
416 void CPodcastFeedView::ImageOperationCompleteL(TInt aError, TUint aHandle) |
394 void CPodcastFeedView::ImageOperationCompleteL(TInt aError, TUint aHandle, CPodcastModel& /*aPodcastModel*/) |
417 { |
395 { |
418 if (aError == KErrNone) { |
396 if (aError == KErrNone) { |
419 UpdateFeedInfoStatusL(aHandle, EFalse); |
397 UpdateFeedInfoStatusL(aHandle, EFalse); |
420 } |
398 } |
421 } |
399 } |
422 |
400 |
423 void CPodcastFeedView::UpdateFeedInfoDataL(CFeedInfo* aFeedInfo, TInt aIndex, TBool aIsUpdating ) |
401 void CPodcastFeedView::UpdateFeedInfoDataL(CFeedInfo* aFeedInfo, TInt aIndex, TBool aIsUpdating ) |
424 { |
402 { |
425 TListItemProperties itemProps; |
403 TListItemProperties itemProps; |
629 UpdateListboxItemsL(); |
607 UpdateListboxItemsL(); |
630 |
608 |
631 // ask if users wants to update it now |
609 // ask if users wants to update it now |
632 TBuf<KMaxMessageLength> message; |
610 TBuf<KMaxMessageLength> message; |
633 iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS); |
611 iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS); |
634 if(ShowQueryMessage(message)) |
612 if(ShowQueryMessageL(message)) |
635 { |
613 { |
636 CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newFeedInfo->Uid()); |
614 CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newFeedInfo->Uid()); |
637 |
615 |
638 iPodcastModel.ActiveShowList().Reset(); |
|
639 iPodcastModel.SetActiveFeedInfo(info); |
616 iPodcastModel.SetActiveFeedInfo(info); |
640 AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID, TUid::Uid(0), KNullDesC8()); |
617 AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID, TUid::Uid(0), KNullDesC8()); |
641 iPodcastModel.FeedEngine().UpdateFeedL(newFeedInfo->Uid()); |
618 iPodcastModel.FeedEngine().UpdateFeedL(newFeedInfo->Uid()); |
642 } |
619 } |
643 } |
620 } |
644 else |
621 else |
645 { |
622 { |
646 TBuf<KMaxMessageLength> message; |
623 TBuf<KMaxMessageLength> message; |
647 iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS); |
624 iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS); |
648 ShowErrorMessage(message); |
625 ShowErrorMessageL(message); |
649 } |
626 } |
650 |
627 |
651 CleanupStack::PopAndDestroy(newFeedInfo); |
628 CleanupStack::PopAndDestroy(newFeedInfo); |
652 } |
629 } |
653 } |
630 } |
758 } |
735 } |
759 } |
736 } |
760 |
737 |
761 void CPodcastFeedView::HandleImportFeedsL() |
738 void CPodcastFeedView::HandleImportFeedsL() |
762 { |
739 { |
763 CAknMemorySelectionDialog* memDlg = |
740 TFileName fileName; |
764 CAknMemorySelectionDialog::NewL(ECFDDialogTypeNormal, ETrue); |
741 fileName.Zero(); |
765 CleanupStack::PushL(memDlg); |
742 TFileName startFolder; |
766 CAknMemorySelectionDialog::TMemory memory = |
743 startFolder.Zero(); |
767 CAknMemorySelectionDialog::EPhoneMemory; |
744 TInt types = AknCommonDialogsDynMem::EMemoryTypePhone | AknCommonDialogsDynMem::EMemoryTypeMMC |AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage| AknCommonDialogsDynMem::EMemoryTypeRemote; |
768 |
745 |
769 if (memDlg->ExecuteL(memory)) |
746 HBufC *title = iCoeEnv->AllocReadResourceLC(R_PODCAST_SELECT_OPML); |
770 { |
747 if (AknCommonDialogsDynMem::RunSelectDlgLD (types, fileName, |
771 TFileName importName; |
748 startFolder, NULL, NULL, *title)) |
772 |
749 { |
773 if (memory==CAknMemorySelectionDialog::EMemoryCard) |
|
774 { |
|
775 importName = PathInfo:: MemoryCardRootPath(); |
|
776 } |
|
777 else |
|
778 { |
|
779 importName = PathInfo:: PhoneMemoryRootPath(); |
|
780 } |
|
781 |
|
782 CAknFileSelectionDialog* dlg = CAknFileSelectionDialog::NewL(ECFDDialogTypeNormal, R_PODCAST_IMPORT_PODCAST); |
|
783 CleanupStack::PushL(dlg); |
|
784 |
|
785 dlg->SetDefaultFolderL(importName); |
|
786 |
750 |
787 if(dlg->ExecuteL(importName)) |
751 if(fileName.Length()>0) |
788 { |
752 { |
789 if(importName.Length()>0) |
753 HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_IMPORTING); |
790 { |
754 iOpmlState = EOpmlImporting; |
791 HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_IMPORTING); |
755 ShowWaitDialogL(*waitText); |
792 iOpmlState = EOpmlImporting; |
756 CleanupStack::PopAndDestroy(waitText); |
793 ShowWaitDialogL(*waitText); |
757 |
794 CleanupStack::PopAndDestroy(waitText); |
758 TRAPD(err, iPodcastModel.FeedEngine().ImportFeedsL(fileName)); |
795 |
759 |
796 TRAPD(err, iPodcastModel.FeedEngine().ImportFeedsL(importName)); |
760 if (err != KErrNone) { |
797 |
761 TBuf<KMaxMessageLength> message; |
798 if (err != KErrNone) { |
762 iEikonEnv->ReadResourceL(message, R_IMPORT_FEED_FAILURE); |
799 TBuf<KMaxMessageLength> message; |
763 ShowErrorMessageL(message); |
800 iEikonEnv->ReadResourceL(message, R_IMPORT_FEED_FAILURE); |
764 } |
801 ShowErrorMessage(message); |
765 } |
802 } |
766 |
803 } |
767 } |
804 |
768 CleanupStack::PopAndDestroy(title); |
805 } |
|
806 CleanupStack::PopAndDestroy(dlg); |
|
807 } |
|
808 CleanupStack::PopAndDestroy(memDlg); |
|
809 } |
769 } |
810 |
770 |
811 void CPodcastFeedView::HandleExportFeedsL() |
771 void CPodcastFeedView::HandleExportFeedsL() |
812 { |
772 { |
813 CAknMemorySelectionDialog* memDlg = |
773 TFileName fileName; |
814 CAknMemorySelectionDialog::NewL(ECFDDialogTypeSave, ETrue); |
774 fileName.Copy(_L("feeds.opml")); |
815 CleanupStack::PushL(memDlg); |
775 TFileName startFolder; |
816 CAknMemorySelectionDialog::TMemory memory = |
776 startFolder.Zero(); |
817 CAknMemorySelectionDialog::EPhoneMemory; |
777 TInt types = AknCommonDialogsDynMem::EMemoryTypePhone | AknCommonDialogsDynMem::EMemoryTypeMMC |AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage| AknCommonDialogsDynMem::EMemoryTypeRemote; |
818 |
778 |
819 if (memDlg->ExecuteL(memory)) |
779 HBufC *title = iCoeEnv->AllocReadResourceLC(R_PODCAST_SELECT_FOLDER); |
820 { |
780 if (AknCommonDialogsDynMem::RunSaveDlgLD (types, fileName, |
821 TFileName pathName; |
781 startFolder, NULL, NULL, *title)) |
822 |
782 { |
823 if (memory==CAknMemorySelectionDialog::EMemoryCard) |
783 TFileName temp; |
824 { |
784 TRAPD(err, iPodcastModel.FeedEngine().ExportFeedsL(temp)); |
825 pathName = PathInfo::MemoryCardRootPath(); |
785 BaflUtils::CopyFile(iEikonEnv->FsSession(), temp, fileName); |
826 } |
786 BaflUtils::DeleteFile(iEikonEnv->FsSession(),temp); |
827 else |
787 if (err == KErrNone) |
828 { |
788 { |
829 pathName = PathInfo::PhoneMemoryRootPath(); |
789 UpdateListboxItemsL(); |
830 } |
790 TInt numFeeds = iPodcastModel.FeedEngine().GetSortedFeeds().Count(); |
831 |
|
832 CAknFileSelectionDialog* dlg = CAknFileSelectionDialog::NewL(ECFDDialogTypeSave, R_PODCAST_EXPORT_FEEDS); |
|
833 CleanupStack::PushL(dlg); |
|
834 |
791 |
835 if(dlg->ExecuteL(pathName)) |
792 TBuf<KMaxMessageLength> message; |
836 { |
793 TBuf<KMaxMessageLength> templ; |
837 CAknFileNamePromptDialog *fileDlg = CAknFileNamePromptDialog::NewL(R_PODCAST_FILENAME_PROMPT_DIALOG); |
794 iEikonEnv->ReadResourceL(templ, R_EXPORT_FEED_SUCCESS); |
838 CleanupStack::PushL(fileDlg); |
795 message.Format(templ, numFeeds); |
839 fileDlg->SetPathL(pathName); |
796 ShowOkMessageL(message); |
840 TFileName fileName; |
797 } |
841 if (fileDlg->ExecuteL(fileName) && fileName.Length() > 0) |
798 else |
842 { |
799 { |
843 pathName.Append(fileName); |
800 TBuf<KMaxMessageLength> message; |
844 TFileName temp; |
801 iEikonEnv->ReadResourceL(message, R_EXPORT_FEED_FAILURE); |
845 TRAPD(err, iPodcastModel.FeedEngine().ExportFeedsL(temp)); |
802 ShowErrorMessageL(message); |
846 BaflUtils::CopyFile(iEikonEnv->FsSession(), temp, pathName); |
803 } |
847 BaflUtils::DeleteFile(iEikonEnv->FsSession(),temp); |
804 } |
848 if (err == KErrNone) |
805 CleanupStack::PopAndDestroy(title); |
849 { |
806 } |
850 UpdateListboxItemsL(); |
807 |
851 TInt numFeeds = iPodcastModel.FeedEngine().GetSortedFeeds().Count(); |
808 void CPodcastFeedView::CheckResumeDownloadL() |
852 |
|
853 TBuf<KMaxMessageLength> message; |
|
854 TBuf<KMaxMessageLength> templ; |
|
855 iEikonEnv->ReadResourceL(templ, R_EXPORT_FEED_SUCCESS); |
|
856 message.Format(templ, numFeeds); |
|
857 ShowOkMessage(message); |
|
858 } |
|
859 else |
|
860 { |
|
861 TBuf<KMaxMessageLength> message; |
|
862 iEikonEnv->ReadResourceL(message, R_EXPORT_FEED_FAILURE); |
|
863 ShowErrorMessage(message); |
|
864 } |
|
865 } |
|
866 CleanupStack::PopAndDestroy(fileDlg); |
|
867 } |
|
868 CleanupStack::PopAndDestroy(dlg); |
|
869 } |
|
870 CleanupStack::PopAndDestroy(memDlg); |
|
871 } |
|
872 |
|
873 void CPodcastFeedView::CheckResumeDownload() |
|
874 { |
809 { |
875 // if there are shows queued for downloading, ask if we should resume now |
810 // if there are shows queued for downloading, ask if we should resume now |
876 RShowInfoArray showsDownloading; |
811 RShowInfoArray showsDownloading; |
877 iPodcastModel.ShowEngine().GetShowsDownloadingL(showsDownloading); |
812 iPodcastModel.ShowEngine().GetShowsDownloadingL(showsDownloading); |
878 |
813 |
879 if (showsDownloading.Count() > 0) |
814 if (showsDownloading.Count() > 0) |
880 { |
815 { |
881 TBuf<KMaxMessageLength> msg; |
816 TBuf<KMaxMessageLength> msg; |
882 iEikonEnv->ReadResourceL(msg, R_PODCAST_ENABLE_DOWNLOADS_PROMPT); |
817 iEikonEnv->ReadResourceL(msg, R_PODCAST_ENABLE_DOWNLOADS_PROMPT); |
883 |
818 |
884 if (ShowQueryMessage(msg)) |
819 if (ShowQueryMessageL(msg)) |
885 { |
820 { |
886 // need to suspend downloads before ResumeDownloadL will work :) |
821 // need to suspend downloads before ResumeDownloadL will work :) |
887 iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue); |
822 iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue); |
888 // resume downloading if user says yes |
823 // resume downloading if user says yes |
889 iPodcastModel.ShowEngine().ResumeDownloadsL(); |
824 iPodcastModel.ShowEngine().ResumeDownloadsL(); |