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