diff -r 8d5c0f720979 -r 69385a7c9810 engine/src/HttpClient.cpp --- a/engine/src/HttpClient.cpp Sat Oct 23 16:26:37 2010 +0100 +++ b/engine/src/HttpClient.cpp Sun Oct 24 01:27:31 2010 +0100 @@ -20,6 +20,9 @@ CHttpClient::~CHttpClient() { + + iPodcastModel.ConnectionEngine().RemoveObserver(this); + if (iHandler) { iHandler->CloseSaveFile(); @@ -111,29 +114,38 @@ void CHttpClient::ConnectCompleteL(TInt aErrorCode) { + DP1("CHttpClient::ConnectCompleteL BEGIN, aErrorCode=%d", aErrorCode); + DP1(" iWaitingForGet=%d", iWaitingForGet); if(iWaitingForGet) { iWaitingForGet = EFalse; if( aErrorCode == KErrNone) { + TRAP_IGNORE(iSession.OpenL()); + DP(" one"); RHTTPConnectionInfo connInfo = iSession.ConnectionInfo(); + DP(" one point five"); RStringPool pool = iSession.StringPool(); // Attach to socket server + DP(" two"); connInfo.SetPropertyL(pool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()), THTTPHdrVal(iPodcastModel.ConnectionEngine().SockServ().Handle())); // Attach to connection + DP(" three"); TInt connPtr = REINTERPRET_CAST(TInt, &iPodcastModel.ConnectionEngine().Connection()); connInfo.SetPropertyL(pool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()), THTTPHdrVal(connPtr)); - + DP(" four"); iPodcastModel.SetProxyUsageIfNeededL(iSession); - DoGetAfterConnectL(); + DoGetAfterConnectL(); + //iWaitingForGet = EFalse; // set to true by DoGetAfterConnectL } else { ClientRequestCompleteL(KErrCouldNotConnect); iSession.Close(); } - } + } + DP("CHttpClient::ConnectCompleteL END"); } void CHttpClient::Disconnected() @@ -144,6 +156,7 @@ void CHttpClient::DoGetAfterConnectL() { + DP("CHttpClient::DoGetAfterConnectL BEGIN"); // since nothing should be downloading now. Delete the handler if (iHandler) { @@ -158,7 +171,7 @@ TBuf8 rangeText; if (iResumeEnabled && iPodcastModel.FsSession().Entry(iCurrentFileName, entry) == KErrNone) { - DP1("Found file, with size=%d", entry.iSize); + DP1(" Found file, with size=%d", entry.iSize); // file exists, so we should probably resume rangeText.Format(_L8("bytes=%d-"), (entry.iSize-KByteOverlap > 0 ? entry.iSize-KByteOverlap : 0)); iHandler->SetSaveFileName(iCurrentFileName, ETrue); @@ -179,7 +192,7 @@ SetHeaderL(hdr, HTTP::EAccept, KAccept); TBuf range16; range16.Copy(rangeText); - DP1("range text: %S", &range16); + DP1(" range text: %S", &range16); if (rangeText.Length() > 0) { SetHeaderL(hdr, HTTP::ERange, rangeText); } @@ -187,7 +200,7 @@ // submit the transaction iTrans.SubmitL(); iIsActive = ETrue; - DP("CHttpClient::Get END"); + DP("CHttpClient::DoGetAfterConnectL END"); } TBool CHttpClient::GetL(const TDesC& aUrl, const TDesC& aFileName, TBool aSilent) { @@ -215,17 +228,18 @@ iSilentGet = aSilent; iCurrentFileName.Copy(aFileName); - iWaitingForGet = ETrue; if (iTransactionCount == 0) { DP("CHttpClient::GetL\t*** Opening HTTP session ***"); iSession.Close(); iSession.OpenL(); + iWaitingForGet = ETrue; ConnectHttpSessionL(); } else { + iWaitingForGet = EFalse; DoGetAfterConnectL(); } return ETrue; @@ -257,9 +271,10 @@ } void CHttpClient::ClientRequestCompleteL(TInt aErrorCode) { + DP1("CHttpClient::ClientRequestCompleteL, aErrorCode=%d", aErrorCode); iIsActive = EFalse; iObserver.CompleteL(this, aErrorCode); - DP("CHttpClient::ClientRequestCompleteL"); + DP1(" iTransactionCount=%d", iTransactionCount); if(iTransactionCount>0) { iTransactionCount--;