Fixed Code Scanner L-issues; Further improvements to HTTP robustness
authorteknolog
Mon, 05 Apr 2010 13:54:26 +0100
changeset 117 3b59b88b089e
parent 116 a2e43aa1ad11
child 118 b03018fb3418
Fixed Code Scanner L-issues; Further improvements to HTTP robustness
application/inc/PodcastAppui.h
application/inc/PodcastFeedView.h
application/sis/podcatcher_udeb.sis
application/sis/podcatcher_udeb_signed.sis
application/src/PodcastAppui.cpp
application/src/PodcastFeedView.cpp
application/src/PodcastQueueView.cpp
application/src/PodcastSearchView.cpp
application/src/PodcastShowsView.cpp
engine/src/FeedEngine.cpp
engine/src/HttpEventHandler.cpp
engine/src/OpmlParser.cpp
engine/src/ShowEngine.cpp
--- a/application/inc/PodcastAppui.h	Mon Apr 05 11:33:41 2010 +0100
+++ b/application/inc/PodcastAppui.h	Mon Apr 05 13:54:26 2010 +0100
@@ -120,7 +120,7 @@
        void TabRightL();
        void NaviSetTextL(TInt aResourceId);
        void NaviShowTabGroupL();
-       void GetErrorText(TDes &aErrorMessage, TInt aErrorCode);
+       void GetErrorTextL(TDes &aErrorMessage, TInt aErrorCode);
 
     private:
         // From MEikMenuObserver
--- a/application/inc/PodcastFeedView.h	Mon Apr 05 11:33:41 2010 +0100
+++ b/application/inc/PodcastFeedView.h	Mon Apr 05 13:54:26 2010 +0100
@@ -109,6 +109,7 @@
 		void HandleExportFeedsL();
 		void HandleUpdateFeedL();
 		void GetFeedErrorText(TDes &aErrorMessage, TInt aErrorCode);
+		void OpmlParsingCompleteL(TInt aError, TUint aNumFeedsImported);
 
 	private:
 		CPodcastModel& iPodcastModel;		
Binary file application/sis/podcatcher_udeb.sis has changed
Binary file application/sis/podcatcher_udeb_signed.sis has changed
--- a/application/src/PodcastAppui.cpp	Mon Apr 05 11:33:41 2010 +0100
+++ b/application/src/PodcastAppui.cpp	Mon Apr 05 13:54:26 2010 +0100
@@ -344,7 +344,7 @@
 	iSearchView->UpdateToolbar(ETrue);
 	}
 
-void CPodcastAppUi::GetErrorText(TDes &aErrorMessage, TInt aErrorCode)
+void CPodcastAppUi::GetErrorTextL(TDes &aErrorMessage, TInt aErrorCode)
 	{
 	switch (aErrorCode)
 		{
--- a/application/src/PodcastFeedView.cpp	Mon Apr 05 11:33:41 2010 +0100
+++ b/application/src/PodcastFeedView.cpp	Mon Apr 05 13:54:26 2010 +0100
@@ -836,6 +836,11 @@
 
 void CPodcastFeedView::OpmlParsingComplete(TInt aError, TUint aNumFeedsImported)
 	{
+	TRAP_IGNORE(OpmlParsingCompleteL(aError, aNumFeedsImported));
+	}
+
+void CPodcastFeedView::OpmlParsingCompleteL(TInt aError, TUint aNumFeedsImported)
+	{
 	DP("CPodcastFeedView::OpmlParsingComplete BEGIN");
 	
 	switch (aError)
@@ -900,7 +905,7 @@
 
 void CPodcastFeedView::GetFeedErrorText(TDes &aErrorMessage, TInt aErrorCode)
 	{
-	((CPodcastAppUi*)AppUi())->GetErrorText(aErrorMessage,aErrorCode);
+	TRAP_IGNORE(((CPodcastAppUi*)AppUi())->GetErrorTextL(aErrorMessage,aErrorCode));
 	}
 
 void CPodcastFeedView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */)
--- a/application/src/PodcastQueueView.cpp	Mon Apr 05 11:33:41 2010 +0100
+++ b/application/src/PodcastQueueView.cpp	Mon Apr 05 13:54:26 2010 +0100
@@ -392,7 +392,7 @@
 	
 	if(aShowInfo.LastError() != KErrNone)
 		{
-		((CPodcastAppUi*)AppUi())->GetErrorText(infoSize, aShowInfo.LastError());
+		TRAP_IGNORE(((CPodcastAppUi*)AppUi())->GetErrorTextL(infoSize, aShowInfo.LastError()));
 		showDate.Zero();
 		}
 		
--- a/application/src/PodcastSearchView.cpp	Mon Apr 05 11:33:41 2010 +0100
+++ b/application/src/PodcastSearchView.cpp	Mon Apr 05 13:54:26 2010 +0100
@@ -139,7 +139,7 @@
 void CPodcastSearchView::DoDeactivate()
 {
 	CPodcastListView::DoDeactivate();
-	((CPodcastAppUi*)AppUi())->NaviShowTabGroupL();
+	TRAP_IGNORE(((CPodcastAppUi*)AppUi())->NaviShowTabGroupL());
 }
 
 
--- a/application/src/PodcastShowsView.cpp	Mon Apr 05 11:33:41 2010 +0100
+++ b/application/src/PodcastShowsView.cpp	Mon Apr 05 13:54:26 2010 +0100
@@ -445,7 +445,7 @@
 
 void CPodcastShowsView::GetShowErrorText(TDes &aErrorMessage, TInt aErrorCode)
 	{
-	((CPodcastAppUi*)AppUi())->GetErrorText(aErrorMessage,aErrorCode);
+	TRAP_IGNORE(((CPodcastAppUi*)AppUi())->GetErrorTextL(aErrorMessage,aErrorCode));
 	}
 
 void CPodcastShowsView::UpdateShowItemDataL(CShowInfo* aShowInfo,TInt aIndex, TInt aSizeDownloaded)
--- a/engine/src/FeedEngine.cpp	Mon Apr 05 11:33:41 2010 +0100
+++ b/engine/src/FeedEngine.cpp	Mon Apr 05 13:54:26 2010 +0100
@@ -243,15 +243,16 @@
 	_LIT(KFileNameFormat, "%lu.xml");
 	iUpdatingFeedFileName.AppendFormat(KFileNameFormat, aFeedUid);
 	
+	iClientState = EUpdatingFeed;
+			
+	for (TInt i=0;i<iObservers.Count();i++)
+		{
+		TRAP_IGNORE(iObservers[i]->FeedDownloadStartedL(iAutoUpdatedInitiator?MFeedEngineObserver::EFeedAutoUpdate:MFeedEngineObserver::EFeedManualUpdate, iActiveFeed->Uid()));
+		}
+
 	if(iFeedClient->GetL(iActiveFeed->Url(), iUpdatingFeedFileName, iPodcastModel.SettingsEngine().SpecificIAP()))
 		{
-		iClientState = EUpdatingFeed;
 		
-		for (TInt i=0;i<iObservers.Count();i++)
-			{
-			TRAP_IGNORE(iObservers[i]->FeedDownloadStartedL(iAutoUpdatedInitiator?MFeedEngineObserver::EFeedAutoUpdate:MFeedEngineObserver::EFeedManualUpdate, iActiveFeed->Uid()));
-			}
-
 		DP("FeedEngine::UpdateFeedL END, return ETrue");
 		return ETrue;
 		}
@@ -604,6 +605,11 @@
 								}	
 							}
 						}
+					else
+						{
+						// even if it fails, this will allow us to move on
+						iClientState = EIdle;
+						}
 					}
 				iCancelRequested = EFalse;
 				}break;
@@ -655,6 +661,9 @@
 			
 			BaflUtils::DeleteFile(iPodcastModel.FsSession(), iSearchResultsFileName);
 			}break;
+		case EIdle:
+			UpdateNextFeedL();	
+			break;
 		default:
 			Panic(EPodcatcherPanicFeedEngineState);
 			break;
@@ -899,7 +908,7 @@
 	iSortedFeeds.Reset();
 	CFeedInfo *feedInfo = NULL;
 	
-	_LIT(KSqlStatement, "select url, title, description, imageurl, imagefile, link, built, lastupdated, uid, feedtype, customtitle from feeds");
+	_LIT(KSqlStatement, "select url, title, description, imageurl, imagefile, link, built, lastupdated, uid, feedtype, customtitle, lasterror from feeds");
 	iSqlBuffer.Format(KSqlStatement);
 
 	sqlite3_stmt *st;
@@ -957,7 +966,7 @@
 				feedInfo->SetCustomTitle();
 				}
 			
-			TInt lasterror = sqlite3_column_int(st, 11);
+			sqlite3_int64 lasterror = sqlite3_column_int(st, 11);
 			feedInfo->SetLastError(lasterror);
 			
 			TLinearOrder<CFeedInfo> sortOrder( CFeedEngine::CompareFeedsByTitle);
--- a/engine/src/HttpEventHandler.cpp	Mon Apr 05 11:33:41 2010 +0100
+++ b/engine/src/HttpEventHandler.cpp	Mon Apr 05 13:54:26 2010 +0100
@@ -19,7 +19,6 @@
 // HttpEventHandler.cpp
 #include <e32debug.h>
 #include <httperr.h>
-
 #include "HttpEventHandler.h"
 #include "bautils.h"
 #include "Httpclient.h"
@@ -105,6 +104,7 @@
 				{
 				iFileServ.Parse(iFileName, iParsedFileName);
 				TInt valid = iFileServ.IsValidName(iFileName);
+				
 				if (!valid)
 					{
 					DP("The specified filename is not valid!.");
@@ -128,7 +128,7 @@
 							if((err=iRespBodyFile.Seek(ESeekEnd, pos)) != KErrNone)
 								{
 								DP("Failed to set position!");
-								iHttpClient->ClientRequestCompleteL(KErrGeneral);
+								iHttpClient->ClientRequestCompleteL(KErrWrite);
 								User::Leave(err);
 								}
 						iBytesDownloaded = (pos > 0) ? pos : 0;
@@ -168,6 +168,7 @@
 				iRespBody->GetNextDataPart(bodyData);
 				iBytesDownloaded += bodyData.Length();
 				TInt error = iRespBodyFile.Write(bodyData);
+
 				// on writing error we close connection 
 				if (error != KErrNone) {
 					iRespBodyFile.Close();
@@ -203,12 +204,12 @@
 			DP("Transaction Failed");
 			aTransaction.Close();
 			
-//			if(iLastStatusCode == HTTPStatus::EOk || iLastStatusCode == HTTPStatus::ECreated || iLastStatusCode == HTTPStatus::EAccepted)
-//				{
-//				iLastStatusCode = KErrNone;
-//				}
+			if(iLastStatusCode == HTTPStatus::EOk || iLastStatusCode == HTTPStatus::ECreated || iLastStatusCode == HTTPStatus::EAccepted)
+				{
+				iLastStatusCode = KErrNone;
+				}
 			
-			iHttpClient->ClientRequestCompleteL(KErrGeneral);
+			iHttpClient->ClientRequestCompleteL(iLastStatusCode);
 			} break;
 		case THTTPEvent::ERedirectedPermanently:
 			{
@@ -231,10 +232,11 @@
 		}
 	}
 
-TInt CHttpEventHandler::MHFRunError(TInt aError, RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/)
+TInt CHttpEventHandler::MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& /*aEvent*/)
 	{
 	DP1("MHFRunError fired with error code %d", aError);
-	iHttpClient->ClientRequestCompleteL(aError);
+	aTransaction.Close();
+	TRAP_IGNORE(iHttpClient->ClientRequestCompleteL(aError));
 	return KErrNone;
 	}
 
--- a/engine/src/OpmlParser.cpp	Mon Apr 05 11:33:41 2010 +0100
+++ b/engine/src/OpmlParser.cpp	Mon Apr 05 13:54:26 2010 +0100
@@ -245,7 +245,7 @@
 void COpmlParser::OnError(TInt aErrorCode)
 	{
 	DP1("COpmlParser::OnError %d", aErrorCode);
-	iFeedEngine.OpmlParsingCompleteL(aErrorCode, iNumFeedsAdded);
+	TRAP_IGNORE(iFeedEngine.OpmlParsingCompleteL(aErrorCode, iNumFeedsAdded));
 	}
 
 TAny* COpmlParser::GetExtendedInterface(const TInt32 /*aUid*/)
--- a/engine/src/ShowEngine.cpp	Mon Apr 05 11:33:41 2010 +0100
+++ b/engine/src/ShowEngine.cpp	Mon Apr 05 13:54:26 2010 +0100
@@ -320,7 +320,7 @@
 
 				NotifyDownloadQueueUpdatedL();
 				iDownloadErrors++;
-				if (iDownloadErrors > KMaxDownloadErrors)
+				if (iDownloadErrors >= KMaxDownloadErrors)
 					{
 					DP("Too many downloading errors, suspending downloads");
 					iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue);