Added auto delete feature newlist
authorSebastian Brannstrom <sebastianb@symbian.org>
Mon, 15 Nov 2010 13:59:40 +0000
branchnewlist
changeset 349 4538abb763e4
parent 348 bd7f3de17443
child 350 9c4fd008e20f
Added auto delete feature
application/data/PodcastClient_english.rls
application/data/PodcastSettingsView.ra
application/data/PodcastShowsView.ra
application/inc/Podcast.hrh
application/inc/PodcastSettingsView.h
application/src/PodcastFeedView.cpp
application/src/PodcastSettingsView.cpp
engine/inc/SettingsEngine.h
engine/inc/ShowEngine.h
engine/inc/ShowInfo.h
engine/src/FeedEngine.cpp
engine/src/PodcastModel.cpp
engine/src/SettingsEngine.cpp
engine/src/ShowEngine.cpp
engine/src/ShowInfo.cpp
--- a/application/data/PodcastClient_english.rls	Sun Nov 14 13:06:35 2010 +0000
+++ b/application/data/PodcastClient_english.rls	Mon Nov 15 13:59:40 2010 +0000
@@ -162,3 +162,9 @@
 rls_string STRING_r_download_queue "Download queue"
 rls_string STRING_r_mark_all_old_query "Mark all shows old?"
 rls_string STRING_r_download_all_query "Add all shows to download queue?"
+rls_string STRING_r_podcast_setting_autodelete "Automatic delete old"
+
+rls_string STRING_podcast_autodelete_option1 "Off"
+rls_string STRING_podcast_autodelete_option2 "After 1 day"
+rls_string STRING_podcast_autodelete_option3 "After 7 days"
+
--- a/application/data/PodcastSettingsView.ra	Sun Nov 14 13:06:35 2010 +0000
+++ b/application/data/PodcastSettingsView.ra	Mon Nov 15 13:59:40 2010 +0000
@@ -28,11 +28,6 @@
     {
     items =
         {        
-		/*MENU_ITEM
-			{
-			command = EPodcastResetDb;
-			txt = STRING_r_podcast_setting_reset_db;
-			},*/
 		MENU_ITEM
 			{
 			command = EPodcastHelp;
@@ -41,7 +36,6 @@
 		};
     }
 
-
 RESOURCE AVKON_VIEW r_podcast_settingsview
 {
 	menubar = r_podcast_settingsview_menubar;
@@ -75,6 +69,13 @@
 				},
 			AVKON_SETTING_ITEM
 			{
+				identifier = EPodcastSettingAutoDelete;
+				setting_page_resource = r_podcast_autodelete_page_resource;
+				associated_resource = r_podcast_autodelete_texts;
+				name = STRING_r_podcast_setting_autodelete;
+			},
+			AVKON_SETTING_ITEM
+			{
 				identifier = EPodcastSettingConnection;
 				setting_page_resource = r_podcast_connection_page_resource;
 				associated_resource = r_podcast_connection_texts;
@@ -173,6 +174,44 @@
     };
 }
 
+RESOURCE AVKON_SETTING_PAGE r_podcast_autodelete_page_resource
+{
+    label= STRING_r_podcast_setting_autodelete;
+    type = EAknCtPopupSettingList;
+    editor_resource_id = r_setting_autodelete_popup_list_entry;
+}
+
+RESOURCE POPUP_SETTING_LIST r_setting_autodelete_popup_list_entry
+{
+}
+
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_podcast_autodelete_texts
+{
+    flags = 0;
+    setting_texts_resource = r_podcast_autodelete_closed;
+    popped_up_texts_resource = r_podcast_autodelete_opened;
+}
+
+RESOURCE ARRAY r_podcast_autodelete_closed
+{
+    items =
+    {
+	AVKON_ENUMERATED_TEXT { value=0; text=STRING_podcast_autodelete_option1; },
+    AVKON_ENUMERATED_TEXT { value=1; text=STRING_podcast_autodelete_option2; },
+    AVKON_ENUMERATED_TEXT { value=2; text=STRING_podcast_autodelete_option3; }   
+    };
+}
+
+RESOURCE ARRAY r_podcast_autodelete_opened
+{
+    items =
+    {
+        LBUF { txt=STRING_podcast_autodelete_option1; },
+        LBUF { txt=STRING_podcast_autodelete_option2; },
+        LBUF { txt=STRING_podcast_autodelete_option3; }
+    };
+}
+
 RESOURCE AVKON_SETTING_PAGE r_podcast_autoupdate_page_resource
 {
     label= STRING_r_podcast_setting_autoupdate;
--- a/application/data/PodcastShowsView.ra	Sun Nov 14 13:06:35 2010 +0000
+++ b/application/data/PodcastShowsView.ra	Mon Nov 15 13:59:40 2010 +0000
@@ -40,12 +40,6 @@
 			command = EPodcastMarkAllPlayed;
 			txt = STRING_r_view_mark_all_played_cmd;
 			},
-//		MENU_ITEM
-//			{
-//			command = EPodcastFilterShows;
-//			txt = STRING_r_view_filter_shows_cmd;
-//			cascade = r_filtershows_menu;
-//			},
 		MENU_ITEM
 			{
 			command = EPodcastAbout;
@@ -64,32 +58,6 @@
         };
     }
 
-RESOURCE MENU_PANE r_filtershows_menu
-	{
-	items =	{
-		MENU_ITEM
-			{
-			command = EPodcastFilterShowsAll;
-			txt = STRING_r_view_filter_all_shows_cmd;
-			},
-/*		MENU_ITEM
-			{
-			command = EPodcastFilterShowsNew;
-			txt = STRING_r_view_filter_new_shows_cmd;
-			},
-		MENU_ITEM
-			{
-			command = EPodcastFilterShowsDownloaded;
-			txt = STRING_r_view_filter_downloaded_shows_cmd;
-			},*/
-		MENU_ITEM
-			{
-			command = EPodcastFilterShowsNewAndDownloaded;
-			txt = STRING_r_view_filter_downloaded_new_shows_cmd;
-			}
-	};	
-	}
-
 RESOURCE AVKON_TOOLBAR r_showsview_toolbar
     {
     flags = KAknToolbarFixed;
--- a/application/inc/Podcast.hrh	Sun Nov 14 13:06:35 2010 +0000
+++ b/application/inc/Podcast.hrh	Mon Nov 15 13:59:40 2010 +0000
@@ -74,6 +74,7 @@
 	EPodcastSettingShowDir,
 	EPodcastSettingAutoDownload,
 	EPodcastSettingAutoUpdate,
+	EPodcastSettingAutoDelete,
 	EPodcastSettingMaxsimdls,
 	EPodcastSettingConnection,
 	EPodcastSettingIAPList,
--- a/application/inc/PodcastSettingsView.h	Sun Nov 14 13:06:35 2010 +0000
+++ b/application/inc/PodcastSettingsView.h	Mon Nov 15 13:59:40 2010 +0000
@@ -74,7 +74,6 @@
 		CPodcastModel& iPodcastModel;
 		 /** Previous activated view */
 		 TVwsViewId iPreviousView;
-		 TInt iAutoDownloadValue;
 		 CAknNavigationDecorator* iNaviDecorator;
 		 CAknNavigationControlContainer* iNaviPane;
 		 CPodcastSettingItemList  * iListbox;
--- a/application/src/PodcastFeedView.cpp	Sun Nov 14 13:06:35 2010 +0000
+++ b/application/src/PodcastFeedView.cpp	Mon Nov 15 13:59:40 2010 +0000
@@ -180,6 +180,7 @@
 	DP("CPodcastFeedView::DoActivateL BEGIN");
 	CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage);
 	
+	iPodcastModel.ShowEngine().ExpireOldShows();
 	if (aPrevViewId.iViewUid == KUidPodcastShowsViewID)
 		{
 		// back key from shows view
--- a/application/src/PodcastSettingsView.cpp	Sun Nov 14 13:06:35 2010 +0000
+++ b/application/src/PodcastSettingsView.cpp	Mon Nov 15 13:59:40 2010 +0000
@@ -257,6 +257,9 @@
 		
 		DP1("Download automatically: %d", iAutoDownload);
 		se.SetDownloadAutomatically(iAutoDownload);
+
+		DP1("Delete automatically: %d", iAutoDownload);
+		se.SetDeleteAutomatically((TAutoDeleteSetting)iAutoDelete);
 		se.SaveSettingsL();
 		DP("StoreSettings END");
 	}
@@ -376,6 +379,7 @@
 			}
 									
 		iAutoDownload = se.DownloadAutomatically();
+		iAutoDelete = se.DeleteAutomatically();
 			
 		switch(aSettingId)
 			{
@@ -402,6 +406,11 @@
 				iSettingAutoDownload = new (ELeave) CAknBinaryPopupSettingItem (aSettingId, iAutoDownload);
 				return iSettingAutoDownload;
 				break;
+			case EPodcastSettingAutoDelete:
+				DP("EPodcastSettingAutoDelete");
+				iSettingAutoDelete = new (ELeave) CAknEnumeratedTextPopupSettingItem (aSettingId, iAutoDelete);
+				return iSettingAutoDelete;
+				break;
 			default:
 				return CAknSettingItemList::CreateSettingItemL(aSettingId);
 				break;
@@ -418,6 +427,9 @@
 	TInt iAutoDownload;
 	CAknSettingItem *iSettingAutoDownload; 
 
+	TInt iAutoDelete;
+	CAknSettingItem *iSettingAutoDelete; 
+
 	TInt iConnection;
 	
 	TInt iIap;
--- a/engine/inc/SettingsEngine.h	Sun Nov 14 13:06:35 2010 +0000
+++ b/engine/inc/SettingsEngine.h	Mon Nov 15 13:59:40 2010 +0000
@@ -48,6 +48,14 @@
 	EAutoUpdatePeriod4=1440
 	};
 
+enum TAutoDeleteSetting
+	{
+	EAutoDeleteOff,
+	EAutoDeleteAfter1Day,	
+	EAutoDeleteAfter7Days,
+	EAutoDeleteAfter3Days
+	};
+
 class CSettingsEngine : public CBase
 	{
 	public:
@@ -87,6 +95,9 @@
 			
 		IMPORT_C void SaveSettingsL();
 
+		IMPORT_C TAutoDeleteSetting DeleteAutomatically();
+		IMPORT_C void SetDeleteAutomatically(TAutoDeleteSetting aAutoDeleteOn);
+
 	private:
 		CSettingsEngine(CPodcastModel& aPodcastModel);
 		void ConstructL();
@@ -104,7 +115,8 @@
 		TInt iMaxListItems;
 		TTime iUpdateFeedTime;
 		TBool iDownloadSuspended;
-
+		TAutoDeleteSetting iDeleteAutomatically;
+		
 		// Other member variables		
 		CPodcastModel &iPodcastModel; 	// reference to the model
 	};
--- a/engine/inc/ShowEngine.h	Sun Nov 14 13:06:35 2010 +0000
+++ b/engine/inc/ShowEngine.h	Mon Nov 15 13:59:40 2010 +0000
@@ -80,7 +80,9 @@
 	IMPORT_C CMetaDataReader& MetaDataReader();
 	IMPORT_C void MoveDownloadUpL(TUint aUid);
 	IMPORT_C void MoveDownloadDownL(TUint aUid);
+	IMPORT_C void PostPlayHandling(CShowInfo *aShow);
 
+	IMPORT_C void ExpireOldShows();
 private:
 	// from HttpClientObserver, dont have to be public
 	void Connected(CHttpClient* aClient);
@@ -131,6 +133,7 @@
 	void DBAddDownloadL(TUint aUid);
 	CShowInfo* DBGetNextDownloadL();
 	void DBSwapDownloadsL(TDownload aFirstDL, TDownload aSecondDL);
+	void DBGetOldShowsL(RShowInfoArray& aShowArray);
 	
 private:
 	CHttpClient* iShowClient;			
--- a/engine/inc/ShowInfo.h	Sun Nov 14 13:06:35 2010 +0000
+++ b/engine/inc/ShowInfo.h	Mon Nov 15 13:59:40 2010 +0000
@@ -98,6 +98,11 @@
 	
 	IMPORT_C void SetLastError(TInt aLastError);
 	IMPORT_C TInt LastError() const;
+
+	IMPORT_C const TTime DeleteDate() const;
+	IMPORT_C void SetDeleteDate(TTime aDeleteDate);
+	
+	
 private:
 	CShowInfo();
 	void ConstructL();
@@ -119,6 +124,7 @@
 	TBool iDelete;
 	TShowType iShowType;
 	TInt  iLastError;
+	TTime iDeleteDate;
 };
 
 typedef RPointerArray<CShowInfo> RShowInfoArray;
--- a/engine/src/FeedEngine.cpp	Sun Nov 14 13:06:35 2010 +0000
+++ b/engine/src/FeedEngine.cpp	Mon Nov 15 13:59:40 2010 +0000
@@ -749,6 +749,17 @@
 		CleanupStack::PopAndDestroy(); // st
 		}
 
+	rc = sqlite3_prepare_v2(&iDB,"alter table shows add column deletedate int" , -1, &st, (const char**) NULL);
+	DP1("    rc=%d", rc);
+	 
+	if( rc==SQLITE_OK )
+		{
+		Cleanup_sqlite3_finalize_PushL(st);
+		rc = sqlite3_step(st);
+		DP1("    rc=%d", rc);
+		CleanupStack::PopAndDestroy(); // st
+		}
+	
 	DP("DBEnsureFileSizeFieldExists END");
 	}
 
--- a/engine/src/PodcastModel.cpp	Sun Nov 14 13:06:35 2010 +0000
+++ b/engine/src/PodcastModel.cpp	Mon Nov 15 13:59:40 2010 +0000
@@ -239,8 +239,7 @@
 	
 	if (err == KErrNone)
 		{
-		aPodcast->SetPlayState(EPlayed);
-		iShowEngine->UpdateShowL(*aPodcast);
+		iShowEngine->PostPlayHandling(aPodcast);
 		}
 	else
 		{
--- a/engine/src/SettingsEngine.cpp	Sun Nov 14 13:06:35 2010 +0000
+++ b/engine/src/SettingsEngine.cpp	Mon Nov 15 13:59:40 2010 +0000
@@ -159,8 +159,9 @@
 		TInt low = stream.ReadInt32L();
 		TInt high = stream.ReadInt32L();
 		iUpdateFeedTime = MAKE_TINT64(high, low);
+		
+		iDeleteAutomatically = (TAutoDeleteSetting) stream.ReadInt32L();
 		TInt dummy;		
-		dummy = stream.ReadInt32L(); // was iSelectOnlyUnplayed
 		dummy = stream.ReadInt32L(); // was iSeekStepTime
 				
 		CleanupStack::PopAndDestroy(1); // readStream and iniFile
@@ -192,7 +193,7 @@
 	
 	stream.WriteInt32L(I64LOW(iUpdateFeedTime.Int64()));
 	stream.WriteInt32L(I64HIGH(iUpdateFeedTime.Int64()));
-	stream.WriteInt32L(0); // was iSelectOnlyUnplayed
+	stream.WriteInt32L(iDeleteAutomatically);
 	stream.WriteInt32L(0); // was iSeekStepTime
 
 	stream.CommitL();
@@ -342,3 +343,13 @@
 	DP1("CSettingsEngine::SetDownloadSuspended, aSuspended=%d", aSuspended);
 	iDownloadSuspended = aSuspended;
 	}
+
+EXPORT_C TAutoDeleteSetting CSettingsEngine::DeleteAutomatically() 
+	{
+	return iDeleteAutomatically;
+	}
+
+EXPORT_C void CSettingsEngine::SetDeleteAutomatically(TAutoDeleteSetting aDeleteAuto)
+	{
+	iDeleteAutomatically = aDeleteAuto;
+	}
--- a/engine/src/ShowEngine.cpp	Sun Nov 14 13:06:35 2010 +0000
+++ b/engine/src/ShowEngine.cpp	Mon Nov 15 13:59:40 2010 +0000
@@ -374,11 +374,12 @@
 	{
 	return DBGetShowByUidL(aShowUid);
 	}
+
 CShowInfo* CShowEngine::DBGetShowByUidL(TUint aUid)
 	{
 	DP("CShowEngine::DBGetShowByUid");
 	CShowInfo *showInfo = NULL;
-	_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype from shows where uid=%u");
+	_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype, deletedate from shows where uid=%u");
 	iSqlBuffer.Format(KSqlStatement, aUid);
 
 	sqlite3_stmt *st;
@@ -408,7 +409,7 @@
 	{
 	DP("CShowEngine::DBGetShowByUid");
 	CShowInfo *showInfo = NULL;
-	_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype from shows where filename=\"%S\"");
+	_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype, lasterror, deletedate from shows where filename=\"%S\"");
 	iSqlBuffer.Format(KSqlStatement, &aFileName);
 
 	sqlite3_stmt *st;
@@ -435,7 +436,7 @@
 void CShowEngine::DBGetAllShowsL(RShowInfoArray& aShowArray)
 	{
 	DP("CShowEngine::DBGetAllShows");
-	_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype from shows");
+	_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype, lasterror, deletedate from shows");
 	iSqlBuffer.Format(KSqlStatement);
 
 	sqlite3_stmt *st;
@@ -463,7 +464,7 @@
 void CShowEngine::DBGetAllDownloadsL(RShowInfoArray& aShowArray)
 	{
 	DP("CShowEngine::DBGetAllDownloads");
-	_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, shows.uid, showsize, trackno, pubdate, showtype, lasterror from downloads, shows where downloads.uid=shows.uid");
+	_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, shows.uid, showsize, trackno, pubdate, showtype, lasterror, deletedate from downloads, shows where downloads.uid=shows.uid");
 	iSqlBuffer.Format(KSqlStatement);
 
 #ifndef DONT_SORT_SQL
@@ -513,11 +514,53 @@
 		}
 	}
 
+void CShowEngine::DBGetOldShowsL(RShowInfoArray& aShowArray)
+	{
+	DP("CShowEngine::DBGetOldShowsL BEGIN");
+	TTime now;
+	now.HomeTime();
+	_LIT(KSqlStatement, "select filename, deletedate shows where deletedate < %Ld");
+	iSqlBuffer.Format(KSqlStatement, now.Int64());
+
+	sqlite3_stmt *st;
+
+	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
+			&st, (const void**) NULL);
+
+	if (rc == SQLITE_OK)
+		{
+		rc = sqlite3_step(st);
+		Cleanup_sqlite3_finalize_PushL(st);
+		while (rc == SQLITE_ROW)
+			{
+			CShowInfo* showInfo = CShowInfo::NewLC();
+
+			const void *filez = sqlite3_column_text16(st, 3);
+			TPtrC16 file((const TUint16*) filez);
+			showInfo->SetFileNameL(file);
+
+			sqlite3_int64 deletedate = sqlite3_column_int64(st, 15);
+			TTime timedeletedate(deletedate);
+			showInfo->SetDeleteDate(timedeletedate);
+
+			aShowArray.Append(showInfo);
+			CleanupStack::Pop(showInfo);
+			rc = sqlite3_step(st);
+			}
+		CleanupStack::PopAndDestroy();//st
+		}
+	else
+		{
+		User::Leave(KErrCorrupt);
+		}
+	DP("CShowEngine::DBGetOldShowsL END");
+	}
+
 CShowInfo* CShowEngine::DBGetNextDownloadL()
 	{
 	DP("CShowEngine::DBGetNextDownload");
 	CShowInfo *showInfo = NULL;
-	_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, shows.uid, showsize, trackno, pubdate, showtype, lasterror from downloads, shows where downloads.uid=shows.uid");
+	_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, shows.uid, showsize, trackno, pubdate, showtype, lasterror, deletedate from downloads, shows where downloads.uid=shows.uid");
 	iSqlBuffer.Format(KSqlStatement);
 
 #ifdef DONT_SORT_SQL
@@ -560,25 +603,8 @@
 void CShowEngine::DBGetShowsByFeedL(RShowInfoArray& aShowArray, TUint aFeedUid)
 	{
 	DP1("CShowEngine::DBGetShowsByFeed BEGIN, feedUid=%u", aFeedUid);
-	_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype, lasterror from shows where feeduid=%u");
+	_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype, lasterror, deletedate from shows where feeduid=%u");
 	iSqlBuffer.Format(KSqlStatement, aFeedUid);
-
-	if (iShowFilter == ENewShows)
-		{
-		_LIT(KSqlStatementNewShows, " and playstate = 0"); // ENeverPlayed
-		iSqlBuffer.Append(KSqlStatementNewShows);
-		}
-	else if (iShowFilter == EDownloadedShows)
-		{
-	_LIT(KSqlStatementDownloadedShows, " and downloadstate = 4"); // EDownloaded
-		iSqlBuffer.Append(KSqlStatementDownloadedShows);
-		}
-	else if (iShowFilter == ENewAndDownloadedShows)
-		{
-	_LIT(KSqlStatementDownloadedAndNewShows, " and (downloadstate = 4 or playstate = 0)"); // EDownloaded or ENeverPlayed
-		iSqlBuffer.Append(KSqlStatementDownloadedAndNewShows);
-	
-		}
 	
 #ifndef DONT_SORT_SQL	
 	_LIT(KSqlOrderByDate, " order by pubdate desc");
@@ -650,7 +676,7 @@
 void CShowEngine::DBGetDownloadedShowsL(RShowInfoArray& aShowArray)
 	{
 	DP("CShowEngine::DBGetDownloadedShows");
-	_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype, lasterror from shows where downloadstate=%u");
+	_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype, lasterror, deletedate from shows where downloadstate=%u");
 	iSqlBuffer.Format(KSqlStatement, EDownloaded);
 
 #ifndef DONT_SORT_SQL
@@ -686,7 +712,7 @@
 void CShowEngine::DBGetNewShowsL(RShowInfoArray& aShowArray)
 	{
 	DP("CShowEngine::DBGetNewShows");
-	_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype, lasterror from shows where playstate=%u");
+	_LIT(KSqlStatement, "select url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype, lasterror, deletedate from shows where playstate=%u");
 	iSqlBuffer.Format(KSqlStatement, ENeverPlayed);
 
 	sqlite3_stmt *st;
@@ -809,6 +835,10 @@
 	
 	TInt lasterror = sqlite3_column_int(st, 14);
 	showInfo->SetLastError(lasterror);
+
+	sqlite3_int64 deletedate = sqlite3_column_int64(st, 15);
+	TTime timedeletedate(deletedate);
+	showInfo->SetDeleteDate(timedeletedate);
 	}
 
 void CShowEngine::DBAddShowL(const CShowInfo& aItem)
@@ -825,13 +855,13 @@
 	descPtr.Copy(aItem.Description());
 	PodcastUtils::SQLEncode(descPtr);
 	
-	_LIT(KSqlStatement, "insert into shows (url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype) values (\"%S\",\"%S\", \"%S\", \"%S\", \"%Lu\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%Lu\", \"%d\")");
+	_LIT(KSqlStatement, "insert into shows (url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype, deletedate) values (\"%S\",\"%S\", \"%S\", \"%S\", \"%Lu\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%Lu\", \"%d\", \"%Lu\")");
 	
 	iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr,
 			&aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(),
 			aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(),
 			aItem.Uid(), aItem.ShowSize(), aItem.TrackNo(),
-			aItem.PubDate().Int64(), aItem.ShowType());
+			aItem.PubDate().Int64(), aItem.ShowType(), aItem.DeleteDate().Int64());
 
 	CleanupStack::PopAndDestroy(descBuf);
 	CleanupStack::PopAndDestroy(titleBuf);
@@ -898,12 +928,12 @@
 	descPtr.Copy(aItem.Description());
 	PodcastUtils::SQLEncode(descPtr);
 
-	_LIT(KSqlStatement, "update shows set url=\"%S\", title=\"%S\", description=\"%S\", filename=\"%S\", position=\"%Lu\", playtime=\"%u\", playstate=\"%u\", downloadstate=\"%u\", feeduid=\"%u\", showsize=\"%u\", trackno=\"%u\",pubdate=\"%Lu\", showtype=\"%d\", lasterror=\"%d\" where uid=\"%u\"");
+	_LIT(KSqlStatement, "update shows set url=\"%S\", title=\"%S\", description=\"%S\", filename=\"%S\", position=\"%Lu\", playtime=\"%u\", playstate=\"%u\", downloadstate=\"%u\", feeduid=\"%u\", showsize=\"%u\", trackno=\"%u\",pubdate=\"%Lu\", showtype=\"%d\", lasterror=\"%d\",deletedate=\"%Lu\" where uid=\"%u\"");
 	iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr,
 			&aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(),
 			aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(),
 			aItem.ShowSize(), aItem.TrackNo(), aItem.PubDate().Int64(),
-			aItem.ShowType(), aItem.LastError(), aItem.Uid());
+			aItem.ShowType(), aItem.LastError(), aItem.Uid(), aItem.DeleteDate());
 
 	CleanupStack::PopAndDestroy(descBuf);
 	CleanupStack::PopAndDestroy(titleBuf);
@@ -1440,6 +1470,24 @@
 	iDownloadErrors = KMaxDownloadErrors;
 	}
 
+EXPORT_C void CShowEngine::ExpireOldShows()
+	{
+	DP("CShowEngine::ExpireOldShows BEGIN");
+	RShowInfoArray oldShowsArray;
+	
+	TRAPD(err, DBGetOldShowsL(oldShowsArray));
+	
+	if (err == KErrNone)
+		{
+		for (int i=0;i<oldShowsArray.Count();i++)
+			{
+			DP1("    deleting %S", &oldShowsArray[i]->FileName());
+			BaflUtils::DeleteFile(iPodcastModel.FsSession(), oldShowsArray[i]->FileName());
+			}
+		}
+	DP("CShowEngine::ExpireOldShows END");
+	}
+
 EXPORT_C void CShowEngine::CheckForDeletedShows(TUint aFeedUid)
 	{
 	RShowInfoArray shows;
@@ -1469,11 +1517,6 @@
 		}
 	}
 
-EXPORT_C void CShowEngine::SetShowFilter(TShowFilter aFilter)
-	{
-	iShowFilter = aFilter;
-	}
-
 EXPORT_C void CShowEngine::MoveDownloadUpL(TUint aUid)
 	{
 	DP("CShowEngine::MoveDownLoadUpL");
@@ -1599,3 +1642,38 @@
 		User::Leave(KErrCorrupt);
 		}
 	}
+
+EXPORT_C void CShowEngine::PostPlayHandling(CShowInfo *aShow)
+	{
+	DP("CShowEngine::PostPlayHandling BEGIN");
+	if (!aShow)
+		return;
+		
+	aShow->SetPlayState(EPlayed);
+	
+	TAutoDeleteSetting deleteSetting = iPodcastModel.SettingsEngine().DeleteAutomatically();
+	TTimeIntervalDays daysAhead;
+	
+	switch (deleteSetting)
+		{
+		case EAutoDeleteOff:
+			break;
+		case EAutoDeleteAfter1Day:
+			daysAhead = 1;
+			break;
+		case EAutoDeleteAfter7Days:
+			daysAhead = 7;
+			break;
+		case EAutoDeleteAfter3Days:
+			daysAhead = 30;
+			break;
+		}
+	
+	TTime deleteDate;
+	deleteDate.HomeTime();
+	deleteDate += daysAhead;
+	aShow->SetDeleteDate(deleteDate);
+	
+	UpdateShowL(*aShow);
+	DP("CShowEngine::PostPlayHandling END");
+	}
--- a/engine/src/ShowInfo.cpp	Sun Nov 14 13:06:35 2010 +0000
+++ b/engine/src/ShowInfo.cpp	Mon Nov 15 13:59:40 2010 +0000
@@ -255,3 +255,13 @@
 	{
 	return iLastError;
 	}
+
+EXPORT_C const TTime CShowInfo::DeleteDate() const
+	{
+	return iDeleteDate;
+	}
+
+EXPORT_C void CShowInfo::SetDeleteDate(TTime aDeleteDate)
+	{
+	iDeleteDate = aDeleteDate;
+	}