application/src/PodcastFeedView.cpp
branch3rded
changeset 176 1c8b56cb6409
parent 175 cd124c4eb6b9
child 177 269e3f3e544a
equal deleted inserted replaced
175:cd124c4eb6b9 176:1c8b56cb6409
    29 #include <podcast.mbg>
    29 #include <podcast.mbg>
    30 #include <gulicon.h>
    30 #include <gulicon.h>
    31 #include <aknquerydialog.h>
    31 #include <aknquerydialog.h>
    32 #include <BAUTILS.H> 
    32 #include <BAUTILS.H> 
    33 #include <pathinfo.h> 
    33 #include <pathinfo.h> 
    34 #include <akncommondialogsdynmem.h> 
    34 //#include <akncommondialogsdynmem.h> 
    35 #include "Podcatcher.pan"
    35 #include "Podcatcher.pan"
    36 
    36 
    37 const TInt KMaxFeedNameLength = 100;
    37 const TInt KMaxFeedNameLength = 100;
    38 const TInt KMaxUnplayedFeedsLength =64;
    38 const TInt KMaxUnplayedFeedsLength =64;
    39 const TInt KADayInHours = 24;
    39 const TInt KADayInHours = 24;
   708 		}
   708 		}
   709 	}
   709 	}
   710 
   710 
   711 void CPodcastFeedView::HandleImportFeedsL()
   711 void CPodcastFeedView::HandleImportFeedsL()
   712 	{
   712 	{
   713 	TFileName fileName;
   713 //	TFileName fileName;
   714 	fileName.Zero();
   714 //	fileName.Zero();
   715 	TFileName startFolder;
   715 //	TFileName startFolder;
   716 	startFolder.Zero();
   716 //	startFolder.Zero();
   717 	TInt types = AknCommonDialogsDynMem::EMemoryTypePhone | AknCommonDialogsDynMem::EMemoryTypeMMC |AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage| AknCommonDialogsDynMem::EMemoryTypeRemote;
   717 //	TInt types = AknCommonDialogsDynMem::EMemoryTypePhone | AknCommonDialogsDynMem::EMemoryTypeMMC |AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage| AknCommonDialogsDynMem::EMemoryTypeRemote;
   718 	
   718 //	
   719 	HBufC *title = iCoeEnv->AllocReadResourceLC(R_PODCAST_SELECT_OPML);
   719 //	HBufC *title = iCoeEnv->AllocReadResourceLC(R_PODCAST_SELECT_OPML);
   720 	if (AknCommonDialogsDynMem::RunSelectDlgLD (types, fileName,
   720 //	if (AknCommonDialogsDynMem::RunSelectDlgLD (types, fileName,
   721 			startFolder, NULL, NULL, *title))
   721 //			startFolder, NULL, NULL, *title))
   722 		{
   722 //		{
   723 		
   723 //		
   724 		if(fileName.Length()>0)
   724 //		if(fileName.Length()>0)
   725 			{
   725 //			{
   726 			HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_IMPORTING);
   726 //			HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_IMPORTING);
   727 			iOpmlState = EOpmlImporting;
   727 //			iOpmlState = EOpmlImporting;
   728 			ShowWaitDialogL(*waitText);
   728 //			ShowWaitDialogL(*waitText);
   729 			CleanupStack::PopAndDestroy(waitText);	
   729 //			CleanupStack::PopAndDestroy(waitText);	
   730 
   730 //
   731 			TRAPD(err, iPodcastModel.FeedEngine().ImportFeedsL(fileName));
   731 //			TRAPD(err, iPodcastModel.FeedEngine().ImportFeedsL(fileName));
   732 								
   732 //								
   733 			if (err != KErrNone) {
   733 //			if (err != KErrNone) {
   734 				TBuf<KMaxMessageLength> message;
   734 //				TBuf<KMaxMessageLength> message;
   735 				iEikonEnv->ReadResourceL(message, R_IMPORT_FEED_FAILURE);
   735 //				iEikonEnv->ReadResourceL(message, R_IMPORT_FEED_FAILURE);
   736 				ShowErrorMessageL(message);
   736 //				ShowErrorMessageL(message);
   737 				}
   737 //				}
   738 			}
   738 //			}
   739 
   739 //
   740 		}
   740 //		}
   741 	CleanupStack::PopAndDestroy(title);
   741 //	CleanupStack::PopAndDestroy(title);
   742 	}
   742 	}
   743 
   743 
   744 void CPodcastFeedView::HandleExportFeedsL()
   744 void CPodcastFeedView::HandleExportFeedsL()
   745 	{
   745 	{
   746 	TFileName fileName;
   746 //	TFileName fileName;
   747 	fileName.Copy(_L("feeds.opml"));
   747 //	fileName.Copy(_L("feeds.opml"));
   748 	TFileName startFolder;
   748 //	TFileName startFolder;
   749 	startFolder.Zero();
   749 //	startFolder.Zero();
   750 	TInt types = AknCommonDialogsDynMem::EMemoryTypePhone | AknCommonDialogsDynMem::EMemoryTypeMMC |AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage| AknCommonDialogsDynMem::EMemoryTypeRemote;
   750 //	TInt types = AknCommonDialogsDynMem::EMemoryTypePhone | AknCommonDialogsDynMem::EMemoryTypeMMC |AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage| AknCommonDialogsDynMem::EMemoryTypeRemote;
   751 	
   751 //	
   752 	HBufC *title = iCoeEnv->AllocReadResourceLC(R_PODCAST_SELECT_FOLDER);
   752 //	HBufC *title = iCoeEnv->AllocReadResourceLC(R_PODCAST_SELECT_FOLDER);
   753 	if (AknCommonDialogsDynMem::RunSaveDlgLD (types, fileName,
   753 //	if (AknCommonDialogsDynMem::RunSaveDlgLD (types, fileName,
   754 			startFolder, NULL, NULL, *title))
   754 //			startFolder, NULL, NULL, *title))
   755 		{
   755 //		{
   756 			TFileName temp;
   756 //			TFileName temp;
   757 			TRAPD(err, iPodcastModel.FeedEngine().ExportFeedsL(temp));						
   757 //			TRAPD(err, iPodcastModel.FeedEngine().ExportFeedsL(temp));						
   758 			BaflUtils::CopyFile(iEikonEnv->FsSession(), temp, fileName);
   758 //			BaflUtils::CopyFile(iEikonEnv->FsSession(), temp, fileName);
   759 			BaflUtils::DeleteFile(iEikonEnv->FsSession(),temp);	
   759 //			BaflUtils::DeleteFile(iEikonEnv->FsSession(),temp);	
   760 			if (err == KErrNone) 
   760 //			if (err == KErrNone) 
   761 				{
   761 //				{
   762 				UpdateListboxItemsL();
   762 //				UpdateListboxItemsL();
   763 				TInt numFeeds = iPodcastModel.FeedEngine().GetSortedFeeds().Count();
   763 //				TInt numFeeds = iPodcastModel.FeedEngine().GetSortedFeeds().Count();
   764 								
   764 //								
   765 				TBuf<KMaxMessageLength> message;
   765 //				TBuf<KMaxMessageLength> message;
   766 				TBuf<KMaxMessageLength> templ;
   766 //				TBuf<KMaxMessageLength> templ;
   767 				iEikonEnv->ReadResourceL(templ, R_EXPORT_FEED_SUCCESS);
   767 //				iEikonEnv->ReadResourceL(templ, R_EXPORT_FEED_SUCCESS);
   768 				message.Format(templ, numFeeds);
   768 //				message.Format(templ, numFeeds);
   769 				ShowOkMessageL(message);
   769 //				ShowOkMessageL(message);
   770 				} 
   770 //				} 
   771 			else 
   771 //			else 
   772 				{
   772 //				{
   773 				TBuf<KMaxMessageLength> message;
   773 //				TBuf<KMaxMessageLength> message;
   774 				iEikonEnv->ReadResourceL(message, R_EXPORT_FEED_FAILURE);
   774 //				iEikonEnv->ReadResourceL(message, R_EXPORT_FEED_FAILURE);
   775 				ShowErrorMessageL(message);
   775 //				ShowErrorMessageL(message);
   776 				}
   776 //				}
   777 		}
   777 //		}
   778 	CleanupStack::PopAndDestroy(title);
   778 //	CleanupStack::PopAndDestroy(title);
   779 	}
   779 	}
   780 
   780 
   781 void CPodcastFeedView::CheckResumeDownloadL()
   781 void CPodcastFeedView::CheckResumeDownloadL()
   782 	{
   782 	{
   783 	// if there are shows queued for downloading, ask if we should resume now
   783 	// if there are shows queued for downloading, ask if we should resume now