--- a/engine/src/FeedEngine.cpp Sat Oct 23 17:30:22 2010 +0100
+++ b/engine/src/FeedEngine.cpp Sat Nov 13 13:54:36 2010 +0000
@@ -53,6 +53,8 @@
TInt err = KErrNone;
TInt feedCount = 0;
+ DBEnsureFileSizeFieldExists();
+
TRAP(err, feedCount = DBGetFeedCountL());
if (err == KErrNone && feedCount > 0)
{
@@ -101,6 +103,7 @@
CFeedEngine::~CFeedEngine()
{
+ DP("~CFeedEngine BEGIN");
iObservers.Close();
iFeedsUpdating.Close();
@@ -112,6 +115,7 @@
delete iOpmlParser;
//
delete iRepository;
+ DP("~CFeedEngine END");
}
/**
@@ -299,6 +303,7 @@
void CFeedEngine::NewShowL(CShowInfo& aItem)
{
+ DP1("CFeedEngine::NewShowL BEGIN, aItem.Title()=%S", &aItem.Title());
HBufC* description = HBufC::NewLC(KMaxDescriptionLength);
TPtr ptr(description->Des());
ptr.Copy(aItem.Description());
@@ -325,6 +330,7 @@
}
showsAdded++;
+ DP("CFeedEngine::NewShowL END");
}
void CFeedEngine::GetFeedImageL(CFeedInfo *aFeedInfo)
@@ -341,6 +347,11 @@
TFileName fileName;
PodcastUtils::FileNameFromUrl(aFeedInfo->ImageUrl(), fileName);
+ fileName.Trim();
+
+ if (fileName.Length() == 0)
+ User::Leave(KErrNotFound);
+
relPath.Append(fileName);
PodcastUtils::EnsureProperPathName(relPath);
@@ -401,10 +412,10 @@
descPtr.Copy(aItem.Description());
PodcastUtils::SQLEncode(descPtr);
- _LIT(KSqlStatement, "insert into feeds (url, title, description, imageurl, imagefile, link, built, lastupdated, uid, feedtype, customtitle, lasterror) values (\"%S\",\"%S\", \"%S\", \"%S\", \"%S\", \"%S\", \"%Ld\", \"%Ld\", \"%u\", \"%u\", \"%u\", \"%d\")");
+ _LIT(KSqlStatement, "insert into feeds (url, title, description, imageurl, imagefile, link, built, lastupdated, uid, feedtype, customtitle, lasterror, filesize) values (\"%S\",\"%S\", \"%S\", \"%S\", \"%S\", \"%S\", \"%Ld\", \"%Ld\", \"%u\", \"%u\", \"%u\", \"%d\", \"%d\")");
iSqlBuffer.Format(KSqlStatement,
&aItem.Url(), titleBuf, descBuf, &aItem.ImageUrl(), &aItem.ImageFileName(), &aItem.Link(),
- aItem.BuildDate().Int64(), aItem.LastUpdated().Int64(), aItem.Uid(), EAudioPodcast, aItem.CustomTitle(), aItem.LastError());
+ aItem.BuildDate().Int64(), aItem.LastUpdated().Int64(), aItem.Uid(), EAudioPodcast, aItem.CustomTitle(), aItem.LastError(), aItem.FeedFileSize());
CleanupStack::PopAndDestroy(descBuf);
CleanupStack::PopAndDestroy(titleBuf);
@@ -514,11 +525,10 @@
TPtr descPtr(descBuf->Des());
descPtr.Copy(aItem.Description());
PodcastUtils::SQLEncode(descPtr);
-
- _LIT(KSqlStatement, "update feeds set url=\"%S\", title=\"%S\", description=\"%S\", imageurl=\"%S\", imagefile=\"%S\", link=\"%S\", built=\"%Lu\", lastupdated=\"%Lu\", feedtype=\"%u\", customtitle=\"%u\", lasterror=\"%d\" where uid=\"%u\"");
+ _LIT(KSqlStatement, "update feeds set url=\"%S\", title=\"%S\", description=\"%S\", imageurl=\"%S\", imagefile=\"%S\", link=\"%S\", built=\"%Lu\", lastupdated=\"%Lu\", feedtype=\"%u\", customtitle=\"%u\", lasterror=\"%d\", filesize=\"%d\" where uid=\"%u\"");
iSqlBuffer.Format(KSqlStatement,
&aItem.Url(), titleBuf, descBuf, &aItem.ImageUrl(), &aItem.ImageFileName(), &aItem.Link(),
- aItem.BuildDate().Int64(), aItem.LastUpdated().Int64(), EAudioPodcast, aItem.CustomTitle(), aItem.LastError(), aItem.Uid());
+ aItem.BuildDate().Int64(), aItem.LastUpdated().Int64(), EAudioPodcast, aItem.CustomTitle(), aItem.LastError(), aItem.FeedFileSize(), aItem.Uid());
CleanupStack::PopAndDestroy(descBuf);
CleanupStack::PopAndDestroy(titleBuf);
@@ -721,6 +731,25 @@
void CFeedEngine::DownloadInfo(CHttpClient* /*aHttpClient */, int /*aTotalBytes*/)
{
+
+ }
+
+void CFeedEngine::DBEnsureFileSizeFieldExists()
+ {
+ DP("DBEnsureFileSizeFieldExists BEGIN");
+ sqlite3_stmt *st;
+ int rc = sqlite3_prepare_v2(&iDB,"alter table feeds add column filesize 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");
}
EXPORT_C void CFeedEngine::ImportFeedsL(const TDesC& aFile)
@@ -939,7 +968,7 @@
iSortedFeeds.Reset();
CFeedInfo *feedInfo = NULL;
- _LIT(KSqlStatement, "select url, title, description, imageurl, imagefile, link, built, lastupdated, uid, feedtype, customtitle, lasterror from feeds");
+ _LIT(KSqlStatement, "select url, title, description, imageurl, imagefile, link, built, lastupdated, uid, feedtype, customtitle, lasterror, filesize from feeds");
iSqlBuffer.Format(KSqlStatement);
sqlite3_stmt *st;
@@ -981,7 +1010,7 @@
const void *linkz = sqlite3_column_text16(st, 5);
TPtrC16 link((const TUint16*)linkz);
- feedInfo->SetDescriptionL(link);
+ feedInfo->SetLinkL(link);
sqlite3_int64 built = sqlite3_column_int64(st, 6);
TTime buildtime(built);
@@ -999,7 +1028,10 @@
sqlite3_int64 lasterror = sqlite3_column_int(st, 11);
feedInfo->SetLastError(lasterror);
-
+
+ TInt filesize = sqlite3_column_int(st, 12);
+ feedInfo->SetFeedFileSize(filesize);
+
TLinearOrder<CFeedInfo> sortOrder( CFeedEngine::CompareFeedsByTitle);
iSortedFeeds.InsertInOrder(feedInfo, sortOrder);
@@ -1022,7 +1054,7 @@
{
DP("CFeedEngine::DBGetFeedInfoByUid BEGIN");
CFeedInfo *feedInfo = NULL;
- _LIT(KSqlStatement, "select url, title, description, imageurl, imagefile, link, built, lastupdated, uid, feedtype, customtitle, lasterror from feeds where uid=%u");
+ _LIT(KSqlStatement, "select url, title, description, imageurl, imagefile, link, built, lastupdated, uid, feedtype, customtitle, lasterror, filesize from feeds where uid=%u");
iSqlBuffer.Format(KSqlStatement, aFeedUid);
sqlite3_stmt *st;
@@ -1055,11 +1087,11 @@
const void *imagefilez = sqlite3_column_text16(st, 4);
TPtrC16 imagefile((const TUint16*)imagefilez);
- feedInfo->SetDescriptionL(imagefile);
+ feedInfo->SetImageFileNameL(imagefile, &iPodcastModel);
const void *linkz = sqlite3_column_text16(st, 5);
TPtrC16 link((const TUint16*)linkz);
- feedInfo->SetDescriptionL(link);
+ feedInfo->SetLinkL(link);
sqlite3_int64 built = sqlite3_column_int64(st, 6);
TTime buildtime(built);
@@ -1076,7 +1108,10 @@
TInt lasterror = sqlite3_column_int(st, 11);
feedInfo->SetLastError(lasterror);
-
+
+ TInt filesize = sqlite3_column_int(st, 12);
+ feedInfo->SetFeedFileSize(filesize);
+
CleanupStack::Pop(feedInfo);
}
else