engine/src/FeedParser.cpp
branchsymbian1
changeset 365 3317b29a19f1
parent 340 37610dda6102
child 374 f067cee22e48
--- 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");