engine/src/ShowEngine.cpp
changeset 77 6284a24658d6
parent 67 9c24c921ec35
child 82 c70a6524a236
equal deleted inserted replaced
73:4abf603ec3e6 77:6284a24658d6
   681 	// what we do:
   681 	// what we do:
   682 	// 1. sort shows by pubdate
   682 	// 1. sort shows by pubdate
   683 	// 2. select the first MaxListItems shows
   683 	// 2. select the first MaxListItems shows
   684 	// 3. delete the rest if downloadstate is ENotDownloaded
   684 	// 3. delete the rest if downloadstate is ENotDownloaded
   685 	
   685 	
   686 	_LIT(KSqlStatement,"delete from shows where feeduid=%u and downloadstate=0 and uid not in " \
   686 	_LIT(KSqlStatement,"delete from shows where feeduid=%u and downloadstate=0 and uid not in (select uid from shows where feeduid=%u order by pubdate desc limit %u)");
   687 			"(select uid from shows where feeduid=%u order by pubdate desc limit %u)");
       
   688 	iSqlBuffer.Format(KSqlStatement, aFeedUid, aFeedUid, iPodcastModel.SettingsEngine().MaxListItems());
   687 	iSqlBuffer.Format(KSqlStatement, aFeedUid, aFeedUid, iPodcastModel.SettingsEngine().MaxListItems());
   689 
   688 
   690 	sqlite3_stmt *st;
   689 	sqlite3_stmt *st;
   691 
   690 
   692 	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
   691 	int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1,
   784 	HBufC* descBuf = HBufC::NewLC(KMaxLineLength);
   783 	HBufC* descBuf = HBufC::NewLC(KMaxLineLength);
   785 	TPtr descPtr(descBuf->Des());
   784 	TPtr descPtr(descBuf->Des());
   786 	descPtr.Copy(aItem.Description());
   785 	descPtr.Copy(aItem.Description());
   787 	PodcastUtils::SQLEncode(descPtr);
   786 	PodcastUtils::SQLEncode(descPtr);
   788 	
   787 	
   789 	_LIT(KSqlStatement, "insert into shows (url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype)"
   788 	_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\")");
   790 			" values (\"%S\",\"%S\", \"%S\", \"%S\", \"%Lu\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%Lu\", \"%d\")");
       
   791 	
   789 	
   792 	iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr,
   790 	iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr,
   793 			&aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(),
   791 			&aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(),
   794 			aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(),
   792 			aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(),
   795 			aItem.Uid(), aItem.ShowSize(), aItem.TrackNo(),
   793 			aItem.Uid(), aItem.ShowSize(), aItem.TrackNo(),
   858 	HBufC* descBuf = HBufC::NewLC(KMaxLineLength);
   856 	HBufC* descBuf = HBufC::NewLC(KMaxLineLength);
   859 	TPtr descPtr(descBuf->Des());
   857 	TPtr descPtr(descBuf->Des());
   860 	descPtr.Copy(aItem.Description());
   858 	descPtr.Copy(aItem.Description());
   861 	PodcastUtils::SQLEncode(descPtr);
   859 	PodcastUtils::SQLEncode(descPtr);
   862 
   860 
   863 	_LIT(KSqlStatement, "update shows set url=\"%S\", title=\"%S\", description=\"%S\", filename=\"%S\", position=\"%Lu\","
   861 	_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\"");
   864 			"playtime=\"%u\", playstate=\"%u\", downloadstate=\"%u\", feeduid=\"%u\", showsize=\"%u\", trackno=\"%u\","
       
   865 			"pubdate=\"%Lu\", showtype=\"%d\", lasterror=\"%d\" where uid=\"%u\"");
       
   866 	iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr,
   862 	iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr,
   867 			&aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(),
   863 			&aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(),
   868 			aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(),
   864 			aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(),
   869 			aItem.ShowSize(), aItem.TrackNo(), aItem.PubDate().Int64(),
   865 			aItem.ShowSize(), aItem.TrackNo(), aItem.PubDate().Int64(),
   870 			aItem.ShowType(), aItem.LastError(), aItem.Uid());
   866 			aItem.ShowType(), aItem.LastError(), aItem.Uid());