Even more robustness improvements for HTTP client - specifically disk full problems
--- a/application/data/PodcastClient_english.rls Sun Apr 04 18:52:11 2010 +0100
+++ b/application/data/PodcastClient_english.rls Sun Apr 04 21:47:56 2010 +0100
@@ -152,3 +152,4 @@
rls_string STRING_r_error_invalid_address "Error: Invalid address"
rls_string STRING_r_error_general "Error: General error %d"
rls_string STRING_r_error_http "Error: HTTP error %d"
+rls_string STRING_r_error_disk_full "Error: Disk full"
--- a/application/data/PodcastStrings.ra Sun Apr 04 18:52:11 2010 +0100
+++ b/application/data/PodcastStrings.ra Sun Apr 04 21:47:56 2010 +0100
@@ -73,3 +73,5 @@
RESOURCE TBUF r_error_invalid_address {buf=STRING_r_error_invalid_address;}
RESOURCE TBUF r_reset_db_query {buf = STRING_r_podcast_setting_reset_db_query;}
+
+RESOURCE TBUF r_error_disk_full {buf = STRING_r_error_disk_full; }
--- a/application/inc/PodcastAppui.h Sun Apr 04 18:52:11 2010 +0100
+++ b/application/inc/PodcastAppui.h Sun Apr 04 21:47:56 2010 +0100
@@ -120,7 +120,8 @@
void TabRightL();
void NaviSetTextL(TInt aResourceId);
void NaviShowTabGroupL();
-
+ void GetErrorText(TDes &aErrorMessage, TInt aErrorCode);
+
private:
// From MEikMenuObserver
void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
--- a/application/inc/PodcastQueueView.h Sun Apr 04 18:52:11 2010 +0100
+++ b/application/inc/PodcastQueueView.h Sun Apr 04 21:47:56 2010 +0100
@@ -104,6 +104,7 @@
TBool iProgressAdded;
TInt iLastImageHandlerError;
TBool iSetTitlebarImage;
+ TBool iEatQueueUpdate;
};
#endif // PODCASTSHOWSVIEWH
--- a/application/src/PodcastAppui.cpp Sun Apr 04 18:52:11 2010 +0100
+++ b/application/src/PodcastAppui.cpp Sun Apr 04 21:47:56 2010 +0100
@@ -343,3 +343,47 @@
iQueueView->UpdateToolbar(ETrue);
iSearchView->UpdateToolbar(ETrue);
}
+
+void CPodcastAppUi::GetErrorText(TDes &aErrorMessage, TInt aErrorCode)
+ {
+ switch (aErrorCode)
+ {
+ case KErrNotFound:
+ {
+ HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_INVALID_ADDRESS);
+ aErrorMessage.Copy(*error);
+ CleanupStack::PopAndDestroy(error);
+ }
+ break;
+ case KErrDiskFull:
+ {
+ HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_DISK_FULL);
+ aErrorMessage.Copy(*error);
+ CleanupStack::PopAndDestroy(error);
+ }
+ break;
+ case 404:
+ {
+ HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_NOTFOUND);
+ aErrorMessage.Copy(*error);
+ CleanupStack::PopAndDestroy(error);
+ }
+ break;
+ default:
+ {
+ if (aErrorCode > 200)
+ {
+ HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_HTTP);
+ aErrorMessage.Format(*error, aErrorCode);
+ CleanupStack::PopAndDestroy(error);
+ }
+ else
+ {
+ HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_GENERAL);
+ aErrorMessage.Format(*error, aErrorCode);
+ CleanupStack::PopAndDestroy(error);
+ }
+ }
+ break;
+ }
+ }
--- a/application/src/PodcastFeedView.cpp Sun Apr 04 18:52:11 2010 +0100
+++ b/application/src/PodcastFeedView.cpp Sun Apr 04 21:47:56 2010 +0100
@@ -900,39 +900,7 @@
void CPodcastFeedView::GetFeedErrorText(TDes &aErrorMessage, TInt aErrorCode)
{
- switch (aErrorCode)
- {
- case -1:
- {
- HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_INVALID_ADDRESS);
- aErrorMessage.Copy(*error);
- CleanupStack::PopAndDestroy(error);
- }
- break;
- case 404:
- {
- HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_NOTFOUND);
- aErrorMessage.Copy(*error);
- CleanupStack::PopAndDestroy(error);
- }
- break;
- default:
- {
- if (aErrorCode > 200)
- {
- HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_HTTP);
- aErrorMessage.Format(*error, aErrorCode);
- CleanupStack::PopAndDestroy(error);
- }
- else
- {
- HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_GENERAL);
- aErrorMessage.Format(*error, aErrorCode);
- CleanupStack::PopAndDestroy(error);
- }
- }
- break;
- }
+ ((CPodcastAppUi*)AppUi())->GetErrorText(aErrorMessage,aErrorCode);
}
void CPodcastFeedView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */)
--- a/application/src/PodcastQueueView.cpp Sun Apr 04 18:52:11 2010 +0100
+++ b/application/src/PodcastQueueView.cpp Sun Apr 04 21:47:56 2010 +0100
@@ -389,11 +389,18 @@
{
aShowInfo.PubDate().FormatL(showDate, KDateFormatShort());
}
-
- if (infoSize.Length() > 0) {
+
+ if(aShowInfo.LastError() != KErrNone)
+ {
+ ((CPodcastAppUi*)AppUi())->GetErrorText(infoSize, aShowInfo.LastError());
+ showDate.Zero();
+ }
+
+ if (infoSize.Length() > 0 && showDate.Length() > 0)
+ {
infoSize.Insert(0,_L(", "));
- }
-
+ }
+
iListboxFormatbuffer.Format(KShowQueueFormat(), iconIndex, &aShowInfo.Title(), &showDate, &infoSize);
}
@@ -522,6 +529,7 @@
TInt index = iListContainer->Listbox()->CurrentItemIndex();
if (index >= 0 && index < iPodcastModel.ActiveShowList().Count())
{
+ iEatQueueUpdate = ETrue;
TRAPD(err, iPodcastModel.ShowEngine().RemoveDownloadL(iPodcastModel.ActiveShowList()[index]->Uid()));
if (err == KErrNone)
@@ -531,10 +539,8 @@
iListContainer->Listbox()->HandleItemRemovalL();
iListContainer->Listbox()->SetCurrentItemIndex(index - 1 > 0 ? index - 1 : 0);
iListContainer->Listbox()->DrawNow();
-
- delete iPodcastModel.ActiveShowList()[index];
- iPodcastModel.ActiveShowList().Remove(index);
}
+ iEatQueueUpdate = EFalse;
}
}
break;
@@ -589,7 +595,8 @@
void CPodcastQueueView::DownloadQueueUpdatedL(TInt /*aDownloadingShows*/, TInt /*aQueuedShows*/)
{
- UpdateListboxItemsL();
+ if (!iEatQueueUpdate)
+ UpdateListboxItemsL();
}
void CPodcastQueueView::FeedUpdateAllCompleteL(TFeedState /*aState*/)
--- a/application/src/PodcastShowsView.cpp Sun Apr 04 18:52:11 2010 +0100
+++ b/application/src/PodcastShowsView.cpp Sun Apr 04 21:47:56 2010 +0100
@@ -445,39 +445,7 @@
void CPodcastShowsView::GetShowErrorText(TDes &aErrorMessage, TInt aErrorCode)
{
- switch (aErrorCode)
- {
- case -1:
- {
- HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_INVALID_ADDRESS);
- aErrorMessage.Copy(*error);
- CleanupStack::PopAndDestroy(error);
- }
- break;
- case 404:
- {
- HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_NOTFOUND);
- aErrorMessage.Copy(*error);
- CleanupStack::PopAndDestroy(error);
- }
- break;
- default:
- {
- if (aErrorCode > 200)
- {
- HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_HTTP);
- aErrorMessage.Format(*error, aErrorCode);
- CleanupStack::PopAndDestroy(error);
- }
- else
- {
- HBufC* error = iCoeEnv->AllocReadResourceLC(R_ERROR_GENERAL);
- aErrorMessage.Format(*error, aErrorCode);
- CleanupStack::PopAndDestroy(error);
- }
- }
- break;
- }
+ ((CPodcastAppUi*)AppUi())->GetErrorText(aErrorMessage,aErrorCode);
}
void CPodcastShowsView::UpdateShowItemDataL(CShowInfo* aShowInfo,TInt aIndex, TInt aSizeDownloaded)
--- a/engine/src/HttpClient.cpp Sun Apr 04 18:52:11 2010 +0100
+++ b/engine/src/HttpClient.cpp Sun Apr 04 21:47:56 2010 +0100
@@ -160,7 +160,7 @@
if (iResumeEnabled && iPodcastModel.FsSession().Entry(iCurrentFileName, entry) == KErrNone) {
DP1("Found file, with size=%d", entry.iSize);
// file exists, so we should probably resume
- rangeText.Format(_L8("bytes=%d-"), entry.iSize-KByteOverlap);
+ rangeText.Format(_L8("bytes=%d-"), (entry.iSize-KByteOverlap > 0 ? entry.iSize-KByteOverlap : 0));
iHandler->SetSaveFileName(iCurrentFileName, ETrue);
} else {
// otherwise just make sure the directory exists
--- a/engine/src/HttpEventHandler.cpp Sun Apr 04 18:52:11 2010 +0100
+++ b/engine/src/HttpEventHandler.cpp Sun Apr 04 21:47:56 2010 +0100
@@ -109,6 +109,7 @@
{
DP("The specified filename is not valid!.");
iSavingResponseBody = EFalse;
+ iHttpClient->ClientRequestCompleteL(KErrBadName);
}
else
{
@@ -118,19 +119,26 @@
{
DP("There was an error opening file");
iSavingResponseBody = EFalse;
+ iHttpClient->ClientRequestCompleteL(KErrInUse);
User::Leave(err);
- } else {
+ }
+ else
+ {
int pos = -KByteOverlap;
- if((err=iRespBodyFile.Seek(ESeekEnd, pos)) != KErrNone) {
+ if((err=iRespBodyFile.Seek(ESeekEnd, pos)) != KErrNone)
+ {
DP("Failed to set position!");
+ iHttpClient->ClientRequestCompleteL(KErrGeneral);
User::Leave(err);
+ }
+ iBytesDownloaded = (pos > 0) ? pos : 0;
+ iBytesTotal += iBytesDownloaded;
+ DP1("Total bytes is now %u", iBytesTotal);
+ DP1("Seeking end: %d", pos);
}
- iBytesDownloaded = (pos > 0) ? pos : 0;
- iBytesTotal += iBytesDownloaded;
- DP1("Total bytes is now %u", iBytesTotal);
- DP1("Seeking end: %d", pos);
- }
- } else {
+ }
+ else
+ {
TInt err = iRespBodyFile.Replace(iFileServ,
iParsedFileName.FullName(),
EFileWrite);
@@ -160,10 +168,9 @@
iRespBody->GetNextDataPart(bodyData);
iBytesDownloaded += bodyData.Length();
TInt error = iRespBodyFile.Write(bodyData);
-
// on writing error we close connection
if (error != KErrNone) {
- //aTransaction.Close();
+ iRespBodyFile.Close();
iCallbacks.FileError(error);
iHttpClient->ClientRequestCompleteL(error);
return;
@@ -196,12 +203,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(iLastStatusCode);
+ iHttpClient->ClientRequestCompleteL(KErrGeneral);
} break;
case THTTPEvent::ERedirectedPermanently:
{
@@ -227,7 +234,7 @@
TInt CHttpEventHandler::MHFRunError(TInt aError, RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/)
{
DP1("MHFRunError fired with error code %d", aError);
-
+ iHttpClient->ClientRequestCompleteL(aError);
return KErrNone;
}
--- a/engine/src/PodcastModel.cpp Sun Apr 04 18:52:11 2010 +0100
+++ b/engine/src/PodcastModel.cpp Sun Apr 04 21:47:56 2010 +0100
@@ -434,7 +434,6 @@
EXPORT_C void CPodcastModel::GetShowsByFeedL(TUint aFeedUid)
{
- DP1("iActiveShowList.Count()=%d", iActiveShowList.Count());
iActiveShowList.ResetAndDestroy();
iShowEngine->GetShowsByFeedL(iActiveShowList, aFeedUid);
}
--- a/engine/src/ShowEngine.cpp Sun Apr 04 18:52:11 2010 +0100
+++ b/engine/src/ShowEngine.cpp Sun Apr 04 21:47:56 2010 +0100
@@ -253,7 +253,7 @@
{
if (iShowDownloading != NULL)
{
- DP1("CShowEngine::Complete\tDownload of file: %S is complete", &iShowDownloading->FileName());
+ DP2("CShowEngine::CompleteL file=%S, aError=%d", &iShowDownloading->FileName(), aError);
if(aError != KErrCouldNotConnect)
{
if(aError == KErrDisconnected && iPodcastModel.SettingsEngine().DownloadSuspended())
@@ -302,12 +302,20 @@
delete iShowDownloading;
iShowDownloading = NULL;
}
+ else if (aError == KErrDiskFull)
+ {
+ // stop downloading immediately if disk is full
+ iShowDownloading->SetDownloadState(EQueued);
+ DBUpdateShowL(*iShowDownloading);
+ iDownloadErrors = KMaxDownloadErrors;
+ }
else // other kind of error, missing network etc, reque this show
{
iShowDownloading->SetDownloadState(EQueued);
DBUpdateShowL(*iShowDownloading);
}
+ NotifyDownloadQueueUpdatedL();
iDownloadErrors++;
if (iDownloadErrors > KMaxDownloadErrors)
{
@@ -1240,11 +1248,9 @@
}
else
{
-
// Start the download
-
CShowInfo *info = DBGetNextDownloadL();
-
+ CleanupStack::PushL(info);
while(info != NULL)
{
DP1("CShowEngine::DownloadNextShow\tDownloading: %S", &(info->Title()));
@@ -1262,6 +1268,7 @@
info->SetDownloadState(EFailedDownload);
DBRemoveDownloadL(info->Uid());
DBUpdateShowL(*info);
+ CleanupStack::PopAndDestroy(info);
info = DBGetNextDownloadL();
if(info == NULL)
@@ -1269,12 +1276,17 @@
iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue);
iShowDownloading = NULL;
}
+ else
+ {
+ CleanupStack::PushL(info);
+ }
}
else
{
break;
}
}
+ CleanupStack::Pop(info); // lives on as iShowDownloading
}
}
else