Added error handling for searching
authorteknolog
Thu, 25 Feb 2010 17:12:04 +0000
changeset 7 a7a43293ae56
parent 6 e211a78d3037
child 8 aab3aa4acdd6
Added error handling for searching
application/inc/PodcastFeedView.h
application/inc/PodcastQueueView.h
application/inc/PodcastSearchView.h
application/inc/PodcastShowsView.h
application/src/PodcastFeedView.cpp
application/src/PodcastSearchView.cpp
engine/inc/FeedEngine.h
engine/inc/FeedEngineObserver.h
engine/src/FeedEngine.cpp
engine/src/OpmlParser.cpp
--- a/application/inc/PodcastFeedView.h	Thu Feb 25 16:47:16 2010 +0000
+++ b/application/inc/PodcastFeedView.h	Thu Feb 25 17:12:04 2010 +0000
@@ -78,7 +78,7 @@
 		void FeedDownloadStartedL(TFeedState aState,TUint aFeedUid);		
 		void FeedDownloadFinishedL(TFeedState aState,TUint aFeeidUid, TInt aError);
 		void FeedUpdateAllCompleteL(TFeedState aState);
-		void OpmlParsingComplete(TUint aNumFeedsImported);
+		void OpmlParsingComplete(TInt aError, TUint aNumFeedsImported);
 
 		/** 
 		 * Command handling function intended for overriding by sub classes. 
--- a/application/inc/PodcastQueueView.h	Thu Feb 25 16:47:16 2010 +0000
+++ b/application/inc/PodcastQueueView.h	Thu Feb 25 17:12:04 2010 +0000
@@ -78,7 +78,7 @@
 	void FeedDownloadStartedL(TFeedState aState,TUint aFeedUid);
 	void FeedDownloadFinishedL(TFeedState aState,TUint aFeedUid, TInt aError);
 	void FeedUpdateAllCompleteL(TFeedState aState);
-	void OpmlParsingComplete(TUint /*aNumFeedsImported*/) {}
+	void OpmlParsingComplete(TInt /*aError*/, TUint /*aNumFeedsImported*/) {}
 
 	/** 
 	 * Command handling function intended for overriding by sub classes. 
--- a/application/inc/PodcastSearchView.h	Thu Feb 25 16:47:16 2010 +0000
+++ b/application/inc/PodcastSearchView.h	Thu Feb 25 17:12:04 2010 +0000
@@ -69,7 +69,7 @@
 		void FeedDownloadStartedL(TFeedState /*aState*/,TUint /*aFeedUid*/) {}		
 		void FeedDownloadFinishedL(TFeedState /*aState*/,TUint /*aFeedUid*/, TInt /*aError*/) {}
 		void FeedUpdateAllCompleteL(TFeedState /*aState*/) {}
-		void OpmlParsingComplete(TUint aNumFeedsImported);
+		void OpmlParsingComplete(TInt aError, TUint aNumFeedsImported);
 
 		/** 
 		 * Command handling function intended for overriding by sub classes. 
--- a/application/inc/PodcastShowsView.h	Thu Feb 25 16:47:16 2010 +0000
+++ b/application/inc/PodcastShowsView.h	Thu Feb 25 17:12:04 2010 +0000
@@ -81,7 +81,7 @@
 	void FeedDownloadStartedL(TFeedState aState,TUint aFeedUid);
 	void FeedDownloadFinishedL(TFeedState aState,TUint aFeedUid, TInt aError);
 	void FeedUpdateAllCompleteL(TFeedState aState);
-	void OpmlParsingComplete(TUint /*aNumFeedsImported*/) {}
+	void OpmlParsingComplete(TInt /*aError*/, TUint /*aNumFeedsImported*/) {}
 
 	/** 
 	 * Command handling function intended for overriding by sub classes. 
--- a/application/src/PodcastFeedView.cpp	Thu Feb 25 16:47:16 2010 +0000
+++ b/application/src/PodcastFeedView.cpp	Thu Feb 25 17:12:04 2010 +0000
@@ -872,46 +872,59 @@
 	showsDownloading.ResetAndDestroy();
 	}
 
-void CPodcastFeedView::OpmlParsingComplete(TUint aNumFeedsImported)
+void CPodcastFeedView::OpmlParsingComplete(TInt aError, TUint aNumFeedsImported)
 	{
 	DP("CPodcastFeedView::OpmlParsingComplete BEGIN");
 	
-	switch (iOpmlState)
+	switch (aError)
 		{
-		case EOpmlIdle:
-			break;
-		case EOpmlImporting:
+		case KErrCouldNotConnect:
 			{
-			UpdateListboxItemsL();
-			delete iWaitDialog;
-			iOpmlState = EOpmlIdle;
-				
 			TBuf<KMaxMessageLength> message;
-			TBuf<KMaxMessageLength> templ;
-			iEikonEnv->ReadResourceL(templ, R_IMPORT_FEED_SUCCESS);
-			message.Format(templ, aNumFeedsImported);
-			
-			if(ShowQueryMessage(message))
-				{
-				HandleCommandL(EPodcastUpdateAllFeeds);
-				}
+			iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR);
+			ShowErrorMessage(message);
 			}
 			break;
-		case EOpmlSearching:
-			delete iWaitDialog;
-			if (iPodcastModel.FeedEngine().GetSearchResults().Count() == 0)
+		case KErrNone: 
+		default:			// we don't do more error handling here, just show 0 imported feeds
+		switch (iOpmlState)
+			{
+			case EOpmlIdle:
+				break;
+			case EOpmlImporting:
 				{
+				UpdateListboxItemsL();
+				delete iWaitDialog;
+				iOpmlState = EOpmlIdle;
+					
 				TBuf<KMaxMessageLength> message;
-				iEikonEnv->ReadResourceL(message, R_SEARCH_NORESULTS);
-				ShowErrorMessage(message);
+				TBuf<KMaxMessageLength> templ;
+				iEikonEnv->ReadResourceL(templ, R_IMPORT_FEED_SUCCESS);
+				message.Format(templ, aNumFeedsImported);
+				
+				if(ShowQueryMessage(message))
+					{
+					HandleCommandL(EPodcastUpdateAllFeeds);
+					}
 				}
-			else
-				{
-				AppUi()->ActivateLocalViewL(KUidPodcastSearchViewID,  TUid::Uid(0), KNullDesC8());
-				}
-			iOpmlState = EOpmlIdle;
-		default:
-			break;
+				break;
+			case EOpmlSearching:
+				delete iWaitDialog;
+				if (iPodcastModel.FeedEngine().GetSearchResults().Count() == 0)
+					{
+					TBuf<KMaxMessageLength> message;
+					iEikonEnv->ReadResourceL(message, R_SEARCH_NORESULTS);
+					ShowErrorMessage(message);
+					}
+				else
+					{
+					AppUi()->ActivateLocalViewL(KUidPodcastSearchViewID,  TUid::Uid(0), KNullDesC8());
+					}
+				iOpmlState = EOpmlIdle;
+				break;
+			default:
+				break;
+			}
 		}
 	
 	DP("CPodcastFeedView::OpmlParsingComplete END");
--- a/application/src/PodcastSearchView.cpp	Thu Feb 25 16:47:16 2010 +0000
+++ b/application/src/PodcastSearchView.cpp	Thu Feb 25 17:12:04 2010 +0000
@@ -275,7 +275,7 @@
 		UpdateToolbar();
 	}
 
-void CPodcastSearchView::OpmlParsingComplete(TUint /*aNumFeedsImported*/)
+void CPodcastSearchView::OpmlParsingComplete(TInt /*aError*/, TUint /*aNumFeedsImported*/)
 	{
 	DP("CPodcastSearchView::OpmlParsingComplete BEGIN");
 	UpdateListboxItemsL();
--- a/engine/inc/FeedEngine.h	Thu Feb 25 16:47:16 2010 +0000
+++ b/engine/inc/FeedEngine.h	Thu Feb 25 17:12:04 2010 +0000
@@ -94,7 +94,7 @@
 	IMPORT_C void AddSearchResultL(CFeedInfo *item);
 	IMPORT_C const RFeedInfoArray& GetSearchResults();
 
-	IMPORT_C void OpmlParsingComplete(TUint aNumFeedsAdded);
+	IMPORT_C void OpmlParsingComplete(TInt aError, TUint aNumFeedsAdded);
 protected:
 	
 	static TInt CompareFeedsByTitle(const CFeedInfo &a, const CFeedInfo &b);
@@ -118,7 +118,7 @@
 	
 	void UpdateNextFeedL();
 	void NotifyFeedUpdateComplete(TInt aError);
-	void NotifyOpmlParsingComplete(TUint aNumFeedsAdded);
+	void NotifyOpmlParsingComplete(TInt aError, TUint aNumFeedsAdded);
 
 	
 private:
--- a/engine/inc/FeedEngineObserver.h	Thu Feb 25 16:47:16 2010 +0000
+++ b/engine/inc/FeedEngineObserver.h	Thu Feb 25 17:12:04 2010 +0000
@@ -30,6 +30,6 @@
 	virtual void FeedDownloadStartedL(TFeedState aState, TUint aFeedUid) = 0;
 	virtual void FeedDownloadFinishedL(TFeedState aState, TUint aFeedUid, TInt aError) = 0;
 	virtual void FeedUpdateAllCompleteL(TFeedState aState) = 0;
-	virtual void OpmlParsingComplete(TUint aNumFeedsImported) = 0;
+	virtual void OpmlParsingComplete(TInt aError, TUint aNumFeedsImported) = 0;
 };
 #endif /*FEEDENGINEOBSERVER_H_*/
--- a/engine/src/FeedEngine.cpp	Thu Feb 25 16:47:16 2010 +0000
+++ b/engine/src/FeedEngine.cpp	Thu Feb 25 17:12:04 2010 +0000
@@ -583,40 +583,44 @@
 				}break;
 			}
 		
-		NotifyFeedUpdateComplete(aError);
-
-		// we will wait until the image has been downloaded to start the next feed update.
-		if (iClientState == EIdle)
+			NotifyFeedUpdateComplete(aError);
+	
+			// we will wait until the image has been downloaded to start the next feed update.
+			if (iClientState == EIdle)
+				{
+				UpdateNextFeedL();	
+				}
+			}break;
+		case EUpdatingImage:
+			{
+			// change client state to not updating
+			iClientState = EIdle;
+	
+			NotifyFeedUpdateComplete(aError);
+			UpdateNextFeedL();
+			}break;
+		case ESearching: 
 			{
-			UpdateNextFeedL();	
-			}
-		}break;
-	case EUpdatingImage:
-		{
-		// change client state to not updating
-		iClientState = EIdle;
-
-		NotifyFeedUpdateComplete(aError);
-		UpdateNextFeedL();
-		}break;
-	case ESearching: 
-		{
-		iClientState = EIdle;
-
-		DP2("Search complete, results in %S with error %d", &iSearchResultsFileName, aError);
-		if(aError == KErrNone)
-			{
-			if (!iOpmlParser) 
+			iClientState = EIdle;
+	
+			DP2("Search complete, results in %S with error %d", &iSearchResultsFileName, aError);
+			if(aError == KErrNone)
 				{
-				iOpmlParser = new COpmlParser(*this, iPodcastModel.FsSession());
+				if (!iOpmlParser) 
+					{
+					iOpmlParser = new COpmlParser(*this, iPodcastModel.FsSession());
+					}
+	
+				DP("Parsing OPML");
+				iOpmlParser->ParseOpmlL(iSearchResultsFileName, ETrue);
 				}
-
-			DP("Parsing OPML");
-			iOpmlParser->ParseOpmlL(iSearchResultsFileName, ETrue);
-			}
-		
-		BaflUtils::DeleteFile(iPodcastModel.FsSession(), iSearchResultsFileName);
-		}break;
+			else
+				{
+				NotifyOpmlParsingComplete(aError, 0);
+				}
+			
+			BaflUtils::DeleteFile(iPodcastModel.FsSession(), iSearchResultsFileName);
+			}break;
 		}
 	DP("CFeedEngine::CompleteL END");
 	}
@@ -1063,15 +1067,15 @@
 	}
 
 
-EXPORT_C void CFeedEngine::OpmlParsingComplete(TUint aNumFeedsAdded)
+EXPORT_C void CFeedEngine::OpmlParsingComplete(TInt aError, TUint aNumFeedsAdded)
 	{
-	NotifyOpmlParsingComplete(aNumFeedsAdded);
+	NotifyOpmlParsingComplete(aError, aNumFeedsAdded);
 	}
 
-void CFeedEngine::NotifyOpmlParsingComplete(TUint aNumFeedsAdded)
+void CFeedEngine::NotifyOpmlParsingComplete(TInt aError, TUint aNumFeedsAdded)
 	{
 	for (TInt i=0;i<iObservers.Count();i++) 
 		{
-		iObservers[i]->OpmlParsingComplete(aNumFeedsAdded);
+		iObservers[i]->OpmlParsingComplete(aError, aNumFeedsAdded);
 		}
 	}
--- a/engine/src/OpmlParser.cpp	Thu Feb 25 16:47:16 2010 +0000
+++ b/engine/src/OpmlParser.cpp	Thu Feb 25 17:12:04 2010 +0000
@@ -71,9 +71,9 @@
 	CleanupStack::PopAndDestroy(charset);
 	}
 
-void COpmlParser::OnEndDocumentL(TInt /*aErrorCode*/)
+void COpmlParser::OnEndDocumentL(TInt aErrorCode)
 	{
-	iFeedEngine.OpmlParsingComplete(iNumFeedsAdded);
+	iFeedEngine.OpmlParsingComplete(aErrorCode, iNumFeedsAdded);
 	//DP("OnEndDocumentL()");
 	}
 
@@ -227,7 +227,7 @@
 void COpmlParser::OnError(TInt aErrorCode)
 	{
 	DP1("COpmlParser::OnError %d", aErrorCode);
-	iFeedEngine.OpmlParsingComplete(iNumFeedsAdded);
+	iFeedEngine.OpmlParsingComplete(aErrorCode, iNumFeedsAdded);
 	}
 
 TAny* COpmlParser::GetExtendedInterface(const TInt32 /*aUid*/)