# HG changeset patch # User Sebastian Brannstrom # Date 1289907264 0 # Node ID 3317b29a19f13d3ee033030e9b38b1f7d8bbd2e5 # Parent 998e9d114bd5b0de6329b0474babddb249dfdf07 Bug 3912 - better support for feeds that add shows at the bottom diff -r 998e9d114bd5 -r 3317b29a19f1 engine/inc/FeedParser.h --- a/engine/inc/FeedParser.h Tue Nov 16 10:39:20 2010 +0000 +++ b/engine/inc/FeedParser.h Tue Nov 16 11:34:24 2010 +0000 @@ -62,6 +62,13 @@ ELatin1 }; +enum TFeedDirection + { + EFeedUnknown, + EFeedAddsAtTop, + EFeedAddsAtBottom + }; + const int KBufferLength = 1024; class CFeedParser : public CBase, public Xml::MContentHandler @@ -102,6 +109,8 @@ TEncoding iEncoding; RFs& iRfs; TInt iFileSize; + TFeedDirection iFeedDirection; + TTime iPreviousPubDate; }; #endif diff -r 998e9d114bd5 -r 3317b29a19f1 engine/src/FeedParser.cpp --- a/engine/src/FeedParser.cpp Tue Nov 16 10:39:20 2010 +0000 +++ b/engine/src/FeedParser.cpp Tue Nov 16 11:34:24 2010 +0000 @@ -73,6 +73,8 @@ HBufC* charset = HBufC::NewLC(KMaxParseBuffer); charset->Des().Copy(aDocParam.CharacterSetName().DesC()); iEncoding = EUtf8; + iFeedDirection = EFeedUnknown; + iPreviousPubDate = 0; if (charset->CompareF(_L("utf-8")) == 0) { DP("setting UTF8"); iEncoding = EUtf8; @@ -302,6 +304,24 @@ iActiveShow->SetPubDate(now); } + if (iFeedDirection == EFeedUnknown) + { + if (iPreviousPubDate.Int64() != 0) { + if (iActiveShow->PubDate() > iPreviousPubDate) + { + DP("Feed adds at bottom"); + iFeedDirection = EFeedAddsAtBottom; + } + else + { + DP("Feed adds at top"); + iFeedDirection = EFeedAddsAtTop; + } + } + iPreviousPubDate = iActiveShow->PubDate(); + } + + if (iUid) { iActiveShow->SetUid(iUid); @@ -316,7 +336,8 @@ iItemsParsed++; DP2("iItemsParsed: %d, iMaxItems: %d", iItemsParsed, iMaxItems); - if (iItemsParsed >= iMaxItems) + // we stop parsing after iMaxItems, but not if feed builds at bottom + if (iItemsParsed >= iMaxItems && iFeedDirection != EFeedAddsAtBottom) { iStoppedParsing = ETrue; DP("*** Too many items, aborting parsing");