Added "Reset database" option in settings. Further robustness fixes for Feeds.
authorteknolog
Sun, 04 Apr 2010 16:23:10 +0100
changeset 110 403412eb5292
parent 109 223f270fa7ff
child 111 12c59f14a031
Added "Reset database" option in settings. Further robustness fixes for Feeds.
application/data/PodcastClient_english.rls
application/data/PodcastSettingsView.ra
application/data/PodcastStrings.ra
application/inc/Podcast.hrh
application/src/PodcastSettingsView.cpp
engine/inc/PodcastModel.h
engine/src/FeedEngine.cpp
engine/src/PodcastModel.cpp
--- a/application/data/PodcastClient_english.rls	Sun Apr 04 15:54:17 2010 +0100
+++ b/application/data/PodcastClient_english.rls	Sun Apr 04 16:23:10 2010 +0100
@@ -61,6 +61,9 @@
 rls_string STRING_r_podcast_select_folder "Select folder"
 rls_string STRING_r_on "On"
 rls_string STRING_r_off "Off"
+rls_string STRING_r_podcast_setting_reset_db "Reset database"
+rls_string STRING_r_podcast_setting_reset_db_query "Reset database? All data will be lost!"
+
 
 
 // Choicelist for autodownload
--- a/application/data/PodcastSettingsView.ra	Sun Apr 04 15:54:17 2010 +0100
+++ b/application/data/PodcastSettingsView.ra	Sun Apr 04 16:23:10 2010 +0100
@@ -30,9 +30,14 @@
         {        
 		MENU_ITEM
 			{
+			command = EPodcastResetDb;
+			txt = STRING_r_podcast_setting_reset_db;
+			},
+		MENU_ITEM
+			{
 			command = EPodcastHelp;
 			txt = STRING_r_view_help;
-			}		
+			}
 		};
     }
 
--- a/application/data/PodcastStrings.ra	Sun Apr 04 15:54:17 2010 +0100
+++ b/application/data/PodcastStrings.ra	Sun Apr 04 16:23:10 2010 +0100
@@ -71,3 +71,5 @@
 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;}
+
+RESOURCE TBUF r_reset_db_query {buf = STRING_r_podcast_setting_reset_db_query;}
--- a/application/inc/Podcast.hrh	Sun Apr 04 15:54:17 2010 +0100
+++ b/application/inc/Podcast.hrh	Sun Apr 04 16:23:10 2010 +0100
@@ -59,7 +59,8 @@
 	EPodcastHide,
 	EPodcastHelp,
 	EPodcastSearch,
-	EPodcastAddSearchResult
+	EPodcastAddSearchResult,
+	EPodcastResetDb
 };
 
 enum TPodcastControl
--- a/application/src/PodcastSettingsView.cpp	Sun Apr 04 15:54:17 2010 +0100
+++ b/application/src/PodcastSettingsView.cpp	Sun Apr 04 16:23:10 2010 +0100
@@ -27,6 +27,7 @@
 
 #include <akncommondialogsdynmem.h> 
 #include <pathinfo.h>
+#include <aknquerydialog.h>
 
 
 class CIapSetting: public CAknEnumeratedTextPopupSettingItem 
@@ -540,7 +541,21 @@
 		iListbox->StoreSettings();
 		AppUi()->ActivateViewL(iPreviousView);
 		}
-		break;	
+		break;
+	case EPodcastResetDb:
+		CAknQueryDialog* dlg= new(ELeave) CAknQueryDialog();
+		
+		CleanupStack::PushL(dlg);
+		HBufC *text = iCoeEnv->AllocReadResourceLC(R_RESET_DB_QUERY);
+		dlg->SetPromptL(*text);
+		CleanupStack::PopAndDestroy(text);
+		CleanupStack::Pop(dlg);
+		if(dlg->ExecuteLD(R_QUERYDLG))
+			{
+			iPodcastModel.DropDB();
+			AppUi()->Exit();
+			}
+		break;
 	default:
 		AppUi()->HandleCommandL(aCommand);
 		break;
--- a/engine/inc/PodcastModel.h	Sun Apr 04 15:54:17 2010 +0100
+++ b/engine/inc/PodcastModel.h	Sun Apr 04 16:23:10 2010 +0100
@@ -85,6 +85,7 @@
 	TInt GetIapId();
 	
 	sqlite3* DB();
+	void DropDB();
 	void ResetDB();
 	
 	IMPORT_C void GetAllShowsL();
--- a/engine/src/FeedEngine.cpp	Sun Apr 04 15:54:17 2010 +0100
+++ b/engine/src/FeedEngine.cpp	Sun Apr 04 16:23:10 2010 +0100
@@ -623,7 +623,9 @@
 				{
 				// now the image has been downloaded, so we set it again in the FeedInfo to start
 				// converting it
-				TRAP_IGNORE(iActiveFeed->SetImageFileNameL(iActiveFeed->ImageFileName(), &iPodcastModel));
+				HBufC *fileNameCopy = iActiveFeed->ImageFileName().AllocLC();
+				TRAP_IGNORE(iActiveFeed->SetImageFileNameL(*fileNameCopy, &iPodcastModel));
+				CleanupStack::PopAndDestroy(fileNameCopy);
 				}
 			DBUpdateFeedL(*iActiveFeed);
 			NotifyFeedUpdateComplete(iActiveFeed->Uid(), aError);
--- a/engine/src/PodcastModel.cpp	Sun Apr 04 15:54:17 2010 +0100
+++ b/engine/src/PodcastModel.cpp	Sun Apr 04 16:23:10 2010 +0100
@@ -253,10 +253,8 @@
 	}
 }
 
-void CPodcastModel::ResetDB()
+void CPodcastModel::DropDB()
 	{
-	DP("CPodcastModel::ResetDB BEGIN");
-	
 	if (iDB != NULL)
 		{
 		sqlite3_close(iDB);
@@ -272,6 +270,23 @@
 		{
 		BaflUtils::DeleteFile(iFsSession, dbFileName);
 		}
+	}
+
+void CPodcastModel::ResetDB()
+	{
+	DP("CPodcastModel::ResetDB BEGIN");
+	
+	DropDB();
+	
+	TFileName dbFileName;
+	dbFileName.Copy(iSettingsEngine->PrivatePath());
+	dbFileName.Append(KDBFileName);
+
+	// remove the old DB file
+	if (BaflUtils::FileExists(iFsSession, dbFileName))
+		{
+		BaflUtils::DeleteFile(iFsSession, dbFileName);
+		}
 
 	// copy template to new DB
 	TFileName dbTemplate;