Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
authorteknolog
Sat, 03 Apr 2010 21:28:44 +0100
changeset 107 af6475fdf8d6
parent 106 83752b9e3cb6
child 108 554d9980157f
Improved error handling; Implemented support for more than 2 flash drives also for import/export feeds
application/data/PodcastClient_english.rls
application/data/PodcastFeedView.ra
application/data/PodcastStrings.ra
application/inc/PodcastShowsView.h
application/src/PodcastFeedView.cpp
application/src/PodcastSettingsView.cpp
application/src/PodcastShowsView.cpp
engine/inc/ShowInfo.h
engine/src/FeedEngine.cpp
--- a/application/data/PodcastClient_english.rls	Sat Apr 03 16:03:09 2010 +0100
+++ b/application/data/PodcastClient_english.rls	Sat Apr 03 21:28:44 2010 +0100
@@ -58,7 +58,7 @@
 rls_string STRING_r_podcast_setting_alwaysask "Always ask"
 rls_string STRING_r_podcast_setting_useiap "Select access point"
 rls_string STRING_r_podcast_setting_iaplist "Access points"
-rls_string STRING_r_podcast_setting_directory "Select folder"
+rls_string STRING_r_podcast_select_folder "Select folder"
 rls_string STRING_r_on "On"
 rls_string STRING_r_off "Off"
 
@@ -100,7 +100,7 @@
 rls_string STRING_r_cancel_update_all_feeds_cmd "Cancel update"
 rls_string STRING_r_cancel_update_all_feeds_short_cmd "Cancel"
 rls_string STRING_r_podcast_feeds_status_format "%d new"
-rls_string STRING_r_podcast_shows_never_updated "Never"
+rls_string STRING_r_podcast_shows_never_updated "Never updated"
 rls_string STRING_r_view_add_feed_cmd "Add feed"
 rls_string STRING_r_view_add_feed_cmd_short "Add"
 rls_string STRING_r_view_edit_feed_cmd "Edit feed"
@@ -144,3 +144,8 @@
 rls_string STRING_r_clear_query "Clear download queue?"
 rls_string STRING_r_view_remove_download_short_cmd "Remove"
 rls_string STRING_r_view_remove_download_cmd "Remove download"
+
+rls_string STRING_r_error_notfound "Error: Not found on server"
+rls_string STRING_r_error_invalid_address "Error: Invalid address"
+rls_string STRING_r_error_general "Error: General error %d"
+rls_string STRING_r_error_http "Error: HTTP error %d"
--- a/application/data/PodcastFeedView.ra	Sat Apr 03 16:03:09 2010 +0100
+++ b/application/data/PodcastFeedView.ra	Sat Apr 03 21:28:44 2010 +0100
@@ -270,40 +270,3 @@
 				}
 		};
 	}
-
-RESOURCE FILESELECTIONDIALOG r_podcast_import_podcast
-	{
-	title = STRING_r_view_import_feeds_title;
-	root_path = "";
-	filters =
-		{
-		FILTER
-			{
-			filter_type = EFilenameFilter;
-			filter_style = EInclusiveFilter;
-			filter_data = { "*.*" };
-			}
-		};
-	}
-
-RESOURCE FILESELECTIONDIALOG r_podcast_export_feeds
-	{
-	title = STRING_r_view_export_feeds_title;
-	root_path = "";
-		filters =
-			{
-			FILTER
-				{
-				filter_type = EFilenameFilter;
-				filter_style = EInclusiveFilter;
-				filter_data = { "*.*" };
-				}
-		};
-	}
-
-RESOURCE FILENAMEPROMPTDIALOG r_podcast_filename_prompt_dialog
-{
-	filename_prompt = STRING_r_enter_filename;
-	default_filename = "feeds.opml";
-	path = "";
-}
--- a/application/data/PodcastStrings.ra	Sat Apr 03 16:03:09 2010 +0100
+++ b/application/data/PodcastStrings.ra	Sat Apr 03 21:28:44 2010 +0100
@@ -64,4 +64,10 @@
 RESOURCE TBUF r_exit_shows_downloading {buf=STRING_r_exit_shows_downloading;}
 RESOURCE TBUF r_search_results {buf=STRING_r_search_results;}
 RESOURCE TBUF r_podcast_no_feeds {buf=STRING_r_podcast_no_feeds;}
-RESOURCE TBUF r_podcast_setting_directory {buf = STRING_r_podcast_setting_directory;}
+RESOURCE TBUF r_podcast_select_folder {buf = STRING_r_podcast_select_folder;}
+RESOURCE TBUF r_podcast_select_opml {buf = STRING_r_view_import_feeds_title;}
+
+RESOURCE TBUF r_error_notfound {buf=STRING_r_error_notfound;}
+RESOURCE TBUF r_error_general {buf=STRING_r_error_general;}
+RESOURCE TBUF r_error_http {buf=STRING_r_error_http;}
+RESOURCE TBUF r_error_invalid_address {buf=STRING_r_error_invalid_address;}
--- a/application/inc/PodcastShowsView.h	Sat Apr 03 16:03:09 2010 +0100
+++ b/application/inc/PodcastShowsView.h	Sat Apr 03 21:28:44 2010 +0100
@@ -103,7 +103,7 @@
 	void DisplayShowInfoDialogL();
 	void HandleSetShowPlayedL(TBool aPlayed);
 	void HandleDeleteShowL();
-	void ImageOperationCompleteL(TInt aError, TUint aHandle, CPodcastModel& aPodcastModel) {}
+	void ImageOperationCompleteL(TInt /* aError */, TUint /* aHandle */, CPodcastModel& /* aPodcastModel */) {}
 	void HandleSetShowPlayed(TBool aPlayed);
 	void HandleDeleteShow();
 	void UpdateViewTitleL();
--- a/application/src/PodcastFeedView.cpp	Sat Apr 03 16:03:09 2010 +0100
+++ b/application/src/PodcastFeedView.cpp	Sat Apr 03 21:28:44 2010 +0100
@@ -29,10 +29,10 @@
 #include <podcast.mbg>
 #include <gulicon.h>
 #include <aknquerydialog.h>
-#include <caknmemoryselectiondialog.h> 
-#include <caknfilenamepromptdialog.h> 
 #include <BAUTILS.H> 
 #include <pathinfo.h> 
+#include <akncommondialogsdynmem.h> 
+
 
 const TInt KMaxFeedNameLength = 100;
 const TInt KMaxUnplayedFeedsLength =64;
@@ -743,114 +743,72 @@
 
 void CPodcastFeedView::HandleImportFeedsL()
 	{
-	CAknMemorySelectionDialog* memDlg = 
-		CAknMemorySelectionDialog::NewL(ECFDDialogTypeNormal, ETrue);
-	CleanupStack::PushL(memDlg);
-	CAknMemorySelectionDialog::TMemory memory = 
-		CAknMemorySelectionDialog::EPhoneMemory;
-
-	if (memDlg->ExecuteL(memory))
-		{
-		TFileName importName;
+	TFileName fileName;
+	fileName.Zero();
+	TFileName startFolder;
+	startFolder.Zero();
+	TInt types = AknCommonDialogsDynMem::EMemoryTypePhone | AknCommonDialogsDynMem::EMemoryTypeMMC |AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage| AknCommonDialogsDynMem::EMemoryTypeRemote;
 	
-		if (memory==CAknMemorySelectionDialog::EMemoryCard)
-		{
-			importName = PathInfo:: MemoryCardRootPath();
-		}
-		else
+	HBufC *title = iCoeEnv->AllocReadResourceLC(R_PODCAST_SELECT_OPML);
+	if (AknCommonDialogsDynMem::RunSelectDlgLD (types, fileName,
+			startFolder, NULL, NULL, *title))
 		{
-			importName = PathInfo:: PhoneMemoryRootPath();
-		}
-
-		CAknFileSelectionDialog* dlg = CAknFileSelectionDialog::NewL(ECFDDialogTypeNormal, R_PODCAST_IMPORT_PODCAST);
-		CleanupStack::PushL(dlg);
+		
+		if(fileName.Length()>0)
+			{
+			HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_IMPORTING);
+			iOpmlState = EOpmlImporting;
+			ShowWaitDialogL(*waitText);
+			CleanupStack::PopAndDestroy(waitText);	
 
-		dlg->SetDefaultFolderL(importName);
-		
-		if(dlg->ExecuteL(importName))
-			{
-			if(importName.Length()>0)
-				{
-				HBufC *waitText = iEikonEnv->AllocReadResourceLC(R_IMPORTING);
-				iOpmlState = EOpmlImporting;
-				ShowWaitDialogL(*waitText);
-				CleanupStack::PopAndDestroy(waitText);	
+			TRAPD(err, iPodcastModel.FeedEngine().ImportFeedsL(fileName));
+								
+			if (err != KErrNone) {
+				TBuf<KMaxMessageLength> message;
+				iEikonEnv->ReadResourceL(message, R_IMPORT_FEED_FAILURE);
+				ShowErrorMessageL(message);
+				}
+			}
 
-				TRAPD(err, iPodcastModel.FeedEngine().ImportFeedsL(importName));
-									
-				if (err != KErrNone) {
-					TBuf<KMaxMessageLength> message;
-					iEikonEnv->ReadResourceL(message, R_IMPORT_FEED_FAILURE);
-					ShowErrorMessageL(message);
-					}
-				}
-				
-			}
-		CleanupStack::PopAndDestroy(dlg);
 		}
-	CleanupStack::PopAndDestroy(memDlg);
+	CleanupStack::PopAndDestroy(title);
 	}
 
 void CPodcastFeedView::HandleExportFeedsL()
 	{
-	CAknMemorySelectionDialog* memDlg = 
-		CAknMemorySelectionDialog::NewL(ECFDDialogTypeSave, ETrue);
-	CleanupStack::PushL(memDlg);
-	CAknMemorySelectionDialog::TMemory memory = 
-		CAknMemorySelectionDialog::EPhoneMemory;
-
-	if (memDlg->ExecuteL(memory))
+	TFileName fileName;
+	fileName.Copy(_L("feeds.opml"));
+	TFileName startFolder;
+	startFolder.Zero();
+	TInt types = AknCommonDialogsDynMem::EMemoryTypePhone | AknCommonDialogsDynMem::EMemoryTypeMMC |AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage| AknCommonDialogsDynMem::EMemoryTypeRemote;
+	
+	HBufC *title = iCoeEnv->AllocReadResourceLC(R_PODCAST_SELECT_FOLDER);
+	if (AknCommonDialogsDynMem::RunSaveDlgLD (types, fileName,
+			startFolder, NULL, NULL, *title))
 		{
-		TFileName pathName;
-		
-		if (memory==CAknMemorySelectionDialog::EMemoryCard)
-		{
-			pathName = PathInfo::MemoryCardRootPath();
-		}
-		else
-		{
-			pathName = PathInfo::PhoneMemoryRootPath();
-		}
-
-		CAknFileSelectionDialog* dlg = CAknFileSelectionDialog::NewL(ECFDDialogTypeSave, R_PODCAST_EXPORT_FEEDS);
-		CleanupStack::PushL(dlg);
+			TFileName temp;
+			TRAPD(err, iPodcastModel.FeedEngine().ExportFeedsL(temp));						
+			BaflUtils::CopyFile(iEikonEnv->FsSession(), temp, fileName);
+			BaflUtils::DeleteFile(iEikonEnv->FsSession(),temp);	
+			if (err == KErrNone) 
+				{
+				UpdateListboxItemsL();
+				TInt numFeeds = iPodcastModel.FeedEngine().GetSortedFeeds().Count();
 								
-		if(dlg->ExecuteL(pathName))
-			{
-			CAknFileNamePromptDialog *fileDlg = CAknFileNamePromptDialog::NewL(R_PODCAST_FILENAME_PROMPT_DIALOG);
-			CleanupStack::PushL(fileDlg);
-			fileDlg->SetPathL(pathName);
-			TFileName fileName;
-			if (fileDlg->ExecuteL(fileName) && fileName.Length() > 0)
+				TBuf<KMaxMessageLength> message;
+				TBuf<KMaxMessageLength> templ;
+				iEikonEnv->ReadResourceL(templ, R_EXPORT_FEED_SUCCESS);
+				message.Format(templ, numFeeds);
+				ShowOkMessageL(message);
+				} 
+			else 
 				{
-				pathName.Append(fileName);
-				TFileName temp;
-				TRAPD(err, iPodcastModel.FeedEngine().ExportFeedsL(temp));						
-				BaflUtils::CopyFile(iEikonEnv->FsSession(), temp, pathName);
-				BaflUtils::DeleteFile(iEikonEnv->FsSession(),temp);	
-				if (err == KErrNone) 
-					{
-					UpdateListboxItemsL();
-					TInt numFeeds = iPodcastModel.FeedEngine().GetSortedFeeds().Count();
-									
-					TBuf<KMaxMessageLength> message;
-					TBuf<KMaxMessageLength> templ;
-					iEikonEnv->ReadResourceL(templ, R_EXPORT_FEED_SUCCESS);
-					message.Format(templ, numFeeds);
-					ShowOkMessageL(message);
-					} 
-				else 
-					{
-					TBuf<KMaxMessageLength> message;
-					iEikonEnv->ReadResourceL(message, R_EXPORT_FEED_FAILURE);
-					ShowErrorMessageL(message);
-					}
+				TBuf<KMaxMessageLength> message;
+				iEikonEnv->ReadResourceL(message, R_EXPORT_FEED_FAILURE);
+				ShowErrorMessageL(message);
 				}
-			CleanupStack::PopAndDestroy(fileDlg);
-			}
-		CleanupStack::PopAndDestroy(dlg);
-	}
-	CleanupStack::PopAndDestroy(memDlg);									
+		}
+	CleanupStack::PopAndDestroy(title);
 	}
 
 void CPodcastFeedView::CheckResumeDownloadL()
@@ -948,7 +906,39 @@
 
 void CPodcastFeedView::GetFeedErrorText(TDes &aErrorMessage, TInt aErrorCode)
 	{
-	iEikonEnv->GetErrorText(aErrorMessage, aErrorCode);
+	switch (aErrorCode)
+		{
+		case -1:
+			{
+			HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_INVALID_ADDRESS);
+			aErrorMessage.Copy(*error);
+			CleanupStack::PopAndDestroy(error);
+			}
+			break;
+		case 404:
+			{
+			HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_NOTFOUND);
+			aErrorMessage.Copy(*error);
+			CleanupStack::PopAndDestroy(error);
+			}
+			break;
+		default:
+			{
+			if (aErrorCode > 200)
+				{
+				HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_HTTP);
+				aErrorMessage.Format(*error, aErrorCode);
+				CleanupStack::PopAndDestroy(error);
+				}
+			else
+				{
+				HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_GENERAL);
+				aErrorMessage.Format(*error, aErrorCode);
+				CleanupStack::PopAndDestroy(error);
+				}
+			}
+			break;
+		}
 	}
 
 void CPodcastFeedView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */)
--- a/application/src/PodcastSettingsView.cpp	Sat Apr 03 16:03:09 2010 +0100
+++ b/application/src/PodcastSettingsView.cpp	Sat Apr 03 21:28:44 2010 +0100
@@ -25,8 +25,6 @@
 #include <podcast.rsg>
 #include "SettingsEngine.h"
 
-//#include <caknfileselectiondialog.h> 
-//#include <caknmemoryselectiondialogmultidrive.h> 
 #include <akncommondialogsdynmem.h> 
 #include <pathinfo.h>
 
@@ -296,7 +294,7 @@
 			startFolder.Zero();
 			TInt types = AknCommonDialogsDynMem::EMemoryTypePhone | AknCommonDialogsDynMem::EMemoryTypeMMC |AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage| AknCommonDialogsDynMem::EMemoryTypeRemote;
 			
-			HBufC *title = iCoeEnv->AllocReadResourceLC(R_PODCAST_SETTING_DIRECTORY);
+			HBufC *title = iCoeEnv->AllocReadResourceLC(R_PODCAST_SELECT_FOLDER);
 			if (AknCommonDialogsDynMem::RunFolderSelectDlgLD (types, selectedFolder,
 					startFolder, NULL, NULL, *title))
 				{
--- a/application/src/PodcastShowsView.cpp	Sat Apr 03 16:03:09 2010 +0100
+++ b/application/src/PodcastShowsView.cpp	Sat Apr 03 21:28:44 2010 +0100
@@ -444,7 +444,39 @@
 
 void CPodcastShowsView::GetShowErrorText(TDes &aErrorMessage, TInt aErrorCode)
 	{
-	iEikonEnv->GetErrorText(aErrorMessage, aErrorCode);
+	switch (aErrorCode)
+		{
+		case -1:
+			{
+			HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_INVALID_ADDRESS);
+			aErrorMessage.Copy(*error);
+			CleanupStack::PopAndDestroy(error);
+			}
+			break;
+		case 404:
+			{
+			HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_NOTFOUND);
+			aErrorMessage.Copy(*error);
+			CleanupStack::PopAndDestroy(error);
+			}
+			break;
+		default:
+			{
+			if (aErrorCode > 200)
+				{
+				HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_HTTP);
+				aErrorMessage.Format(*error, aErrorCode);
+				CleanupStack::PopAndDestroy(error);
+				}
+			else
+				{
+				HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_GENERAL);
+				aErrorMessage.Format(*error, aErrorCode);
+				CleanupStack::PopAndDestroy(error);
+				}
+			}
+			break;
+		}
 	}
 
 void CPodcastShowsView::UpdateShowItemDataL(CShowInfo* aShowInfo,TInt aIndex, TInt aSizeDownloaded)
--- a/engine/inc/ShowInfo.h	Sat Apr 03 16:03:09 2010 +0100
+++ b/engine/inc/ShowInfo.h	Sat Apr 03 21:28:44 2010 +0100
@@ -42,7 +42,8 @@
 
 enum TShowType {
 	EAudioPodcast = 0,
-	EVideoPodcast
+	EVideoPodcast,
+	EOtherPodcast
 };
 
 class CShowInfo: public CBase {
--- a/engine/src/FeedEngine.cpp	Sat Apr 03 16:03:09 2010 +0100
+++ b/engine/src/FeedEngine.cpp	Sat Apr 03 21:28:44 2010 +0100
@@ -599,7 +599,7 @@
 				iCancelRequested = EFalse;
 				}break;
 			}
-		
+			DBUpdateFeedL(*iActiveFeed);
 			NotifyFeedUpdateComplete(iActiveFeed->Uid(), aError);
 
 			// we will wait until the image has been downloaded to start the next feed update.