--- 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");
+ }