engine/src/OpmlParser.cpp
changeset 60 4d230e702aa3
parent 20 c92d8384952c
child 65 bcd88ba95046
--- a/engine/src/OpmlParser.cpp	Thu Mar 11 20:53:00 2010 +0100
+++ b/engine/src/OpmlParser.cpp	Tue Apr 27 19:26:48 2010 +0100
@@ -73,7 +73,7 @@
 
 void COpmlParser::OnEndDocumentL(TInt aErrorCode)
 	{
-	iFeedEngine.OpmlParsingComplete(aErrorCode, iNumFeedsAdded);
+	iFeedEngine.OpmlParsingCompleteL(aErrorCode, iNumFeedsAdded);
 	//DP("OnEndDocumentL()");
 	}
 
@@ -96,7 +96,15 @@
 		if(str.CompareF(KTagOutline) == 0) {
 			iOpmlState = EStateOpmlOutline;
 		}
-		break;
+		
+		// there are two variations on OPML, where the <outline> tags sit either
+		// directly below <body>, or inside a collective <body> <outline>
+		// by checking if the <body> <outline> has arguments, we can support both
+		// by falling through to the nextstate
+		if (aAttributes.Count() == 0)
+			{
+			break;
+			}
 	case EStateOpmlOutline:
 		// <body> <outline> <outline...
 		if(str.CompareF(KTagOutline) == 0) {
@@ -122,18 +130,17 @@
 				} else if (attr16.Compare(KTagHtmlUrl) == 0) {
 					newFeed->SetLinkL(*val16);
 					hasUrl = ETrue;
-				// text=...
+				// title=...
 				} else if (attr16.Compare(KTagTitle) == 0) {
 					newFeed->SetTitleL(*val16);
-					newFeed->SetCustomTitle();
 					hasTitle = ETrue;
 				// description=
 				} else if (attr16.Compare(KTagDescription) == 0) {
 					newFeed->SetDescriptionL(*val16);
+				// text=
 				} else if (attr16.Compare(KTagText) == 0) {
 					if (!hasTitle) {
 						newFeed->SetTitleL(*val16);
-						newFeed->SetCustomTitle();
 						hasTitle = ETrue;
 					}
 				} 
@@ -148,11 +155,20 @@
 				newFeed->SetTitleL(newFeed->Url());
 			}
 			
+			// if the title is the same as the URL, it is hardly a custom
+			// title, so let's replace it on update
+			if (newFeed->Title().Length() &&
+					newFeed->Url().Length() &&
+					newFeed->Title().Compare(newFeed->Url()) != 0) {
+				newFeed->SetCustomTitle();
+			}
+			
 			if (iSearching) {
 				iFeedEngine.AddSearchResultL(newFeed);
 				CleanupStack::Pop(newFeed);
 			} else {
-				if(iFeedEngine.AddFeedL(*newFeed))
+				TRAPD(err, iFeedEngine.AddFeedL(*newFeed))
+				if (err == KErrNone)
 					{
 					iNumFeedsAdded++;
 					}
@@ -229,7 +245,7 @@
 void COpmlParser::OnError(TInt aErrorCode)
 	{
 	DP1("COpmlParser::OnError %d", aErrorCode);
-	iFeedEngine.OpmlParsingComplete(aErrorCode, iNumFeedsAdded);
+	TRAP_IGNORE(iFeedEngine.OpmlParsingCompleteL(aErrorCode, iNumFeedsAdded));
 	}
 
 TAny* COpmlParser::GetExtendedInterface(const TInt32 /*aUid*/)