application/src/PodcastFeedView.cpp
branch3rded
changeset 177 269e3f3e544a
parent 176 1c8b56cb6409
child 206 9c3ebab9d24f
equal deleted inserted replaced
176:1c8b56cb6409 177:269e3f3e544a
    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 <caknmemoryselectiondialog.h> 
       
    35 #include <caknmemoryselectiondialog.h> 
       
    36 #include <caknfilenamepromptdialog.h> 
    35 #include "Podcatcher.pan"
    37 #include "Podcatcher.pan"
    36 
    38 
    37 const TInt KMaxFeedNameLength = 100;
    39 const TInt KMaxFeedNameLength = 100;
    38 const TInt KMaxUnplayedFeedsLength =64;
    40 const TInt KMaxUnplayedFeedsLength =64;
    39 const TInt KADayInHours = 24;
    41 const TInt KADayInHours = 24;
   708 		}
   710 		}
   709 	}
   711 	}
   710 
   712 
   711 void CPodcastFeedView::HandleImportFeedsL()
   713 void CPodcastFeedView::HandleImportFeedsL()
   712 	{
   714 	{
   713 //	TFileName fileName;
   715 	CAknMemorySelectionDialog* memDlg = 
   714 //	fileName.Zero();
   716 		CAknMemorySelectionDialog::NewL(ECFDDialogTypeNormal, ETrue);
   715 //	TFileName startFolder;
   717 	CleanupStack::PushL(memDlg);
   716 //	startFolder.Zero();
   718 	CAknMemorySelectionDialog::TMemory memory = 
   717 //	TInt types = AknCommonDialogsDynMem::EMemoryTypePhone | AknCommonDialogsDynMem::EMemoryTypeMMC |AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage| AknCommonDialogsDynMem::EMemoryTypeRemote;
   719 		CAknMemorySelectionDialog::EPhoneMemory;
   718 //	
   720 
   719 //	HBufC *title = iCoeEnv->AllocReadResourceLC(R_PODCAST_SELECT_OPML);
   721 	if (memDlg->ExecuteL(memory))
   720 //	if (AknCommonDialogsDynMem::RunSelectDlgLD (types, fileName,
   722 		{
   721 //			startFolder, NULL, NULL, *title))
   723 		TFileName importName;
   722 //		{
   724 	
   723 //		
   725 		if (memory==CAknMemorySelectionDialog::EMemoryCard)
   724 //		if(fileName.Length()>0)
   726 		{
   725 //			{
   727 			importName = PathInfo:: MemoryCardRootPath();
   726 //			HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_IMPORTING);
   728 		}
   727 //			iOpmlState = EOpmlImporting;
   729 		else
   728 //			ShowWaitDialogL(*waitText);
   730 		{
   729 //			CleanupStack::PopAndDestroy(waitText);	
   731 			importName = PathInfo:: PhoneMemoryRootPath();
   730 //
   732 		}
   731 //			TRAPD(err, iPodcastModel.FeedEngine().ImportFeedsL(fileName));
   733 
   732 //								
   734 		CAknFileSelectionDialog* dlg = CAknFileSelectionDialog::NewL(ECFDDialogTypeNormal, R_PODCAST_IMPORT_PODCAST);
   733 //			if (err != KErrNone) {
   735 		CleanupStack::PushL(dlg);
   734 //				TBuf<KMaxMessageLength> message;
   736 
   735 //				iEikonEnv->ReadResourceL(message, R_IMPORT_FEED_FAILURE);
   737 		dlg->SetDefaultFolderL(importName);
   736 //				ShowErrorMessageL(message);
   738 		
   737 //				}
   739 		if(dlg->ExecuteL(importName))
   738 //			}
   740 			{
   739 //
   741 			if(importName.Length()>0)
   740 //		}
   742 				{
   741 //	CleanupStack::PopAndDestroy(title);
   743 				iPodcastModel.FeedEngine().ImportFeedsL(importName);
       
   744 				UpdateListboxItemsL();
       
   745 				}
       
   746 			}
       
   747 		CleanupStack::PopAndDestroy(dlg);
       
   748 		}
       
   749 	CleanupStack::PopAndDestroy(memDlg);								
   742 	}
   750 	}
   743 
   751 
   744 void CPodcastFeedView::HandleExportFeedsL()
   752 void CPodcastFeedView::HandleExportFeedsL()
   745 	{
   753 	{
   746 //	TFileName fileName;
   754 	CAknMemorySelectionDialog* memDlg = 
   747 //	fileName.Copy(_L("feeds.opml"));
   755 		CAknMemorySelectionDialog::NewL(ECFDDialogTypeSave, ETrue);
   748 //	TFileName startFolder;
   756 	CleanupStack::PushL(memDlg);
   749 //	startFolder.Zero();
   757 	CAknMemorySelectionDialog::TMemory memory = 
   750 //	TInt types = AknCommonDialogsDynMem::EMemoryTypePhone | AknCommonDialogsDynMem::EMemoryTypeMMC |AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage| AknCommonDialogsDynMem::EMemoryTypeRemote;
   758 		CAknMemorySelectionDialog::EPhoneMemory;
   751 //	
   759 
   752 //	HBufC *title = iCoeEnv->AllocReadResourceLC(R_PODCAST_SELECT_FOLDER);
   760 	if (memDlg->ExecuteL(memory))
   753 //	if (AknCommonDialogsDynMem::RunSaveDlgLD (types, fileName,
   761 		{
   754 //			startFolder, NULL, NULL, *title))
   762 		TFileName pathName;
   755 //		{
   763 		
   756 //			TFileName temp;
   764 		if (memory==CAknMemorySelectionDialog::EMemoryCard)
   757 //			TRAPD(err, iPodcastModel.FeedEngine().ExportFeedsL(temp));						
   765 		{
   758 //			BaflUtils::CopyFile(iEikonEnv->FsSession(), temp, fileName);
   766 			pathName = PathInfo::MemoryCardRootPath();
   759 //			BaflUtils::DeleteFile(iEikonEnv->FsSession(),temp);	
   767 		}
   760 //			if (err == KErrNone) 
   768 		else
   761 //				{
   769 		{
   762 //				UpdateListboxItemsL();
   770 			pathName = PathInfo::PhoneMemoryRootPath();
   763 //				TInt numFeeds = iPodcastModel.FeedEngine().GetSortedFeeds().Count();
   771 		}
   764 //								
   772 
   765 //				TBuf<KMaxMessageLength> message;
   773 		CAknFileSelectionDialog* dlg = CAknFileSelectionDialog::NewL(ECFDDialogTypeSave, R_PODCAST_EXPORT_FEEDS);
   766 //				TBuf<KMaxMessageLength> templ;
   774 		CleanupStack::PushL(dlg);
   767 //				iEikonEnv->ReadResourceL(templ, R_EXPORT_FEED_SUCCESS);
   775 								
   768 //				message.Format(templ, numFeeds);
   776 		if(dlg->ExecuteL(pathName))
   769 //				ShowOkMessageL(message);
   777 			{
   770 //				} 
   778 			CAknFileNamePromptDialog *fileDlg = CAknFileNamePromptDialog::NewL(R_PODCAST_FILENAME_PROMPT_DIALOG);
   771 //			else 
   779 			CleanupStack::PushL(fileDlg);
   772 //				{
   780 			fileDlg->SetPathL(pathName);
   773 //				TBuf<KMaxMessageLength> message;
   781 			TFileName fileName;
   774 //				iEikonEnv->ReadResourceL(message, R_EXPORT_FEED_FAILURE);
   782 			if (fileDlg->ExecuteL(fileName) && fileName.Length() > 0)
   775 //				ShowErrorMessageL(message);
   783 				{
   776 //				}
   784 				pathName.Append(fileName);
   777 //		}
   785 				TFileName temp;
   778 //	CleanupStack::PopAndDestroy(title);
   786 				iPodcastModel.FeedEngine().ExportFeedsL(temp);
       
   787 				RFs fs;
       
   788 				fs.Connect();
       
   789 				BaflUtils::CopyFile(fs, temp, pathName);
       
   790 				BaflUtils::DeleteFile(fs,temp);
       
   791 				fs.Close();
       
   792 				}
       
   793 			CleanupStack::PopAndDestroy(fileDlg);
       
   794 			}
       
   795 		CleanupStack::PopAndDestroy(dlg);
       
   796 	}
       
   797 	CleanupStack::PopAndDestroy(memDlg);									
   779 	}
   798 	}
   780 
   799 
   781 void CPodcastFeedView::CheckResumeDownloadL()
   800 void CPodcastFeedView::CheckResumeDownloadL()
   782 	{
   801 	{
   783 	// if there are shows queued for downloading, ask if we should resume now
   802 	// if there are shows queued for downloading, ask if we should resume now
   885 
   904 
   886 TBool CPodcastFeedView::ViewingShows()
   905 TBool CPodcastFeedView::ViewingShows()
   887 	{
   906 	{
   888 	return iViewingShows;
   907 	return iViewingShows;
   889 	}
   908 	}
       
   909 
       
   910 void CPodcastFeedView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
       
   911 	{
       
   912 	if(aResourceId == R_PODCAST_FEEDVIEW_MENU)
       
   913 		{
       
   914 		aMenuPane->SetItemDimmed(EPodcastUpdateAllFeeds, iUpdatingRunning);
       
   915 		aMenuPane->SetItemDimmed(EPodcastCancelUpdateAllFeeds, !iUpdatingRunning);
       
   916 		aMenuPane->SetItemDimmed(EPodcastSettings, iUpdatingRunning);
       
   917 		aMenuPane->SetItemDimmed(EPodcastFeedFeedMenu, iUpdatingRunning);
       
   918 //		aMenuPane->SetItemDimmed(EPodcastImportExportFeeds, iUpdatingRunning);
       
   919 		}
       
   920 	}
       
   921 
       
   922 TKeyResponse CPodcastFeedView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
   923 	{
       
   924 	if (aType == EEventKey)
       
   925 		{
       
   926 			switch (aKeyEvent.iCode) {
       
   927 			case EKeyBackspace:
       
   928 			case EKeyDelete:
       
   929 				HandleCommandL(EPodcastDeleteFeedHardware);
       
   930 				break;
       
   931 			default:
       
   932 				break;
       
   933 			}
       
   934 		}
       
   935 		return CPodcastListView::OfferKeyEventL(aKeyEvent, aType);
       
   936 	}
       
   937