branch | symbian1 |
changeset 164 | 000f9fc147b2 |
parent 149 | 70b2f592a460 |
child 167 | 4bfc2fcec5f6 |
161:ce4f70a6d1d2 | 164:000f9fc147b2 |
---|---|
25 #include <e32hashtab.h> |
25 #include <e32hashtab.h> |
26 #include <httperr.h> |
26 #include <httperr.h> |
27 #include "debug.h" |
27 #include "debug.h" |
28 #include "PodcastUtils.h" |
28 #include "PodcastUtils.h" |
29 |
29 |
30 //#include <mpxmedia.h> |
|
31 //#include <mpxattribute.h> |
|
32 //#include <mpxmediageneraldefs.h> |
|
33 |
|
34 const TUint KMaxDownloadErrors = 3; |
30 const TUint KMaxDownloadErrors = 3; |
35 const TInt KMimeBufLength = 100; |
31 const TInt KMimeBufLength = 100; |
36 |
32 |
37 CShowEngine::CShowEngine(CPodcastModel& aPodcastModel) : |
33 CShowEngine::CShowEngine(CPodcastModel& aPodcastModel) : |
38 iPodcastModel(aPodcastModel), |
34 iPodcastModel(aPodcastModel), |
239 } |
235 } |
240 } |
236 } |
241 |
237 |
242 void CShowEngine::AddShowToMpxCollection(CShowInfo &/*aShowInfo*/) |
238 void CShowEngine::AddShowToMpxCollection(CShowInfo &/*aShowInfo*/) |
243 { |
239 { |
244 /* RArray<TInt> contentIDs; |
240 // do nothing (right now) |
245 contentIDs.AppendL( KMPXMediaIdGeneral ); |
|
246 |
|
247 CMPXMedia* media = CMPXMedia::NewL( contentIDs.Array() ); |
|
248 CleanupStack::PushL( media ); |
|
249 contentIDs.Close(); |
|
250 CleanupStack::PopAndDestroy(media); */ |
|
251 } |
241 } |
252 |
242 |
253 void CShowEngine::CompleteL(CHttpClient* /*aHttpClient*/, TInt aError) |
243 void CShowEngine::CompleteL(CHttpClient* /*aHttpClient*/, TInt aError) |
254 { |
244 { |
255 if (iShowDownloading != NULL) |
245 if (iShowDownloading != NULL) |
698 // what we do: |
688 // what we do: |
699 // 1. sort shows by pubdate |
689 // 1. sort shows by pubdate |
700 // 2. select the first MaxListItems shows |
690 // 2. select the first MaxListItems shows |
701 // 3. delete the rest if downloadstate is ENotDownloaded |
691 // 3. delete the rest if downloadstate is ENotDownloaded |
702 |
692 |
703 _LIT(KSqlStatement,"delete from shows where feeduid=%u and downloadstate=0 and uid not in " \ |
693 _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)"); |
704 "(select uid from shows where feeduid=%u order by pubdate desc limit %u)"); |
|
705 iSqlBuffer.Format(KSqlStatement, aFeedUid, aFeedUid, iPodcastModel.SettingsEngine().MaxListItems()); |
694 iSqlBuffer.Format(KSqlStatement, aFeedUid, aFeedUid, iPodcastModel.SettingsEngine().MaxListItems()); |
706 |
695 |
707 sqlite3_stmt *st; |
696 sqlite3_stmt *st; |
708 |
697 |
709 int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
698 int rc = sqlite3_prepare16_v2(&iDB, (const void*) iSqlBuffer.PtrZ(), -1, |
801 HBufC* descBuf = HBufC::NewLC(KMaxLineLength); |
790 HBufC* descBuf = HBufC::NewLC(KMaxLineLength); |
802 TPtr descPtr(descBuf->Des()); |
791 TPtr descPtr(descBuf->Des()); |
803 descPtr.Copy(aItem.Description()); |
792 descPtr.Copy(aItem.Description()); |
804 PodcastUtils::SQLEncode(descPtr); |
793 PodcastUtils::SQLEncode(descPtr); |
805 |
794 |
806 _LIT(KSqlStatement, "insert into shows (url, title, description, filename, position, playtime, playstate, downloadstate, feeduid, uid, showsize, trackno, pubdate, showtype)" |
795 _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\")"); |
807 " values (\"%S\",\"%S\", \"%S\", \"%S\", \"%Lu\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%u\", \"%Lu\", \"%d\")"); |
|
808 |
796 |
809 iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr, |
797 iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr, |
810 &aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(), |
798 &aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(), |
811 aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(), |
799 aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(), |
812 aItem.Uid(), aItem.ShowSize(), aItem.TrackNo(), |
800 aItem.Uid(), aItem.ShowSize(), aItem.TrackNo(), |
875 HBufC* descBuf = HBufC::NewLC(KMaxLineLength); |
863 HBufC* descBuf = HBufC::NewLC(KMaxLineLength); |
876 TPtr descPtr(descBuf->Des()); |
864 TPtr descPtr(descBuf->Des()); |
877 descPtr.Copy(aItem.Description()); |
865 descPtr.Copy(aItem.Description()); |
878 PodcastUtils::SQLEncode(descPtr); |
866 PodcastUtils::SQLEncode(descPtr); |
879 |
867 |
880 _LIT(KSqlStatement, "update shows set url=\"%S\", title=\"%S\", description=\"%S\", filename=\"%S\", position=\"%Lu\"," |
868 _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\""); |
881 "playtime=\"%u\", playstate=\"%u\", downloadstate=\"%u\", feeduid=\"%u\", showsize=\"%u\", trackno=\"%u\"," |
|
882 "pubdate=\"%Lu\", showtype=\"%d\", lasterror=\"%d\" where uid=\"%u\""); |
|
883 iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr, |
869 iSqlBuffer.Format(KSqlStatement, &aItem.Url(), &titlePtr, &descPtr, |
884 &aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(), |
870 &aItem.FileName(), aItem.Position().Int64(), aItem.PlayTime(), |
885 aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(), |
871 aItem.PlayState(), aItem.DownloadState(), aItem.FeedUid(), |
886 aItem.ShowSize(), aItem.TrackNo(), aItem.PubDate().Int64(), |
872 aItem.ShowSize(), aItem.TrackNo(), aItem.PubDate().Int64(), |
887 aItem.ShowType(), aItem.LastError(), aItem.Uid()); |
873 aItem.ShowType(), aItem.LastError(), aItem.Uid()); |
1578 else |
1564 else |
1579 { |
1565 { |
1580 User::Leave(KErrCorrupt); |
1566 User::Leave(KErrCorrupt); |
1581 } |
1567 } |
1582 } |
1568 } |
1583 |