application/src/PodcastSettingsView.cpp
changeset 60 4d230e702aa3
parent 2 29cda98b007e
child 65 bcd88ba95046
--- a/application/src/PodcastSettingsView.cpp	Thu Mar 11 20:53:00 2010 +0100
+++ b/application/src/PodcastSettingsView.cpp	Tue Apr 27 19:26:48 2010 +0100
@@ -25,9 +25,9 @@
 #include <podcast.rsg>
 #include "SettingsEngine.h"
 
-#include <caknfileselectiondialog.h> 
-#include <caknmemoryselectiondialog.h> 
+#include <akncommondialogsdynmem.h> 
 #include <pathinfo.h>
+#include <aknquerydialog.h>
 
 
 class CIapSetting: public CAknEnumeratedTextPopupSettingItem 
@@ -289,42 +289,33 @@
 		{
 		DP("EditItemL BEGIN");
 		if (aIndex == 0) {
-			CAknMemorySelectionDialog* memDlg = 
-				CAknMemorySelectionDialog::NewL(ECFDDialogTypeNormal, ETrue);
-			CleanupStack::PushL(memDlg);
-			CAknMemorySelectionDialog::TMemory memory = 
-				CAknMemorySelectionDialog::EPhoneMemory;
-	
-			if (memDlg->ExecuteL(memory))
+			TFileName selectedFolder;
+			selectedFolder.Copy(iShowDir);
+			TFileName startFolder;
+			startFolder.Zero();
+			TInt types = AknCommonDialogsDynMem::EMemoryTypePhone | AknCommonDialogsDynMem::EMemoryTypeMMC |AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage| AknCommonDialogsDynMem::EMemoryTypeRemote;
+			
+			HBufC *title = iCoeEnv->AllocReadResourceLC(R_PODCAST_SELECT_FOLDER);
+			if (AknCommonDialogsDynMem::RunFolderSelectDlgLD (types, selectedFolder,
+					startFolder, NULL, NULL, *title))
 				{
-				TFileName importName;
-			
-				if (memory==CAknMemorySelectionDialog::EMemoryCard)
-				{
-					importName = PathInfo:: MemoryCardRootPath();
-				}
-				else
-				{
-					importName = PathInfo:: PhoneMemoryRootPath();
+				_LIT(KPodcastsDir, "Podcasts");
+				TInt pos = selectedFolder.Find(KPodcastsDir);
+				if (pos == KErrNotFound || pos != selectedFolder.Length()-9)
+					{
+					// append "Podcasts" if the folder isn't already called this
+					selectedFolder.Append(KPodcastsDir);
+					}
+				
+				if (selectedFolder[selectedFolder.Length()-1] != '\\')
+					{
+					selectedFolder.Append(_L("\\"));
+					}
+				
+				iShowDir.Copy(selectedFolder);
+				LoadSettingsL();
 				}
-	
-				CAknFileSelectionDialog* dlg = CAknFileSelectionDialog::NewL(ECFDDialogTypeSave, R_PODCAST_SHOWDIR_SELECTOR);
-				HBufC* select = iEikonEnv->AllocReadResourceLC(R_PODCAST_SOFTKEY_SELECT);
-				dlg->SetLeftSoftkeyFileL(*select);
-				CleanupStack::PopAndDestroy(select);
-				CleanupStack::PushL(dlg);
-	
-				dlg->SetDefaultFolderL(importName);
-				
-				if(dlg->ExecuteL(importName))
-					{
-					importName.Append(_L("Podcasts"));
-					iShowDir.Copy(importName);
-					LoadSettingsL();
-					}
-				CleanupStack::PopAndDestroy(dlg);
-				}
-			CleanupStack::PopAndDestroy(memDlg);								
+			CleanupStack::PopAndDestroy(title);
 			}
 		else {
 			CAknSettingItemList::EditItemL(aIndex,aCalledFromMenu);
@@ -511,6 +502,7 @@
 		{
 		iNaviPane->PushL(*iNaviDecorator);
 		}
+
 	DP("CPodcastSettingsView::DoActivateL END");
 }
 
@@ -549,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;