Bug 3912 - better support for feeds that add shows at the bottom symbian1
authorSebastian Brannstrom <sebastianb@symbian.org>
Tue, 16 Nov 2010 11:34:24 +0000
branchsymbian1
changeset 365 3317b29a19f1
parent 364 998e9d114bd5
child 366 f015466e6642
Bug 3912 - better support for feeds that add shows at the bottom
engine/inc/FeedParser.h
engine/src/FeedParser.cpp
--- 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");