equal
deleted
inserted
replaced
17 */ |
17 */ |
18 |
18 |
19 // HttpEventHandler.cpp |
19 // HttpEventHandler.cpp |
20 #include <e32debug.h> |
20 #include <e32debug.h> |
21 #include <httperr.h> |
21 #include <httperr.h> |
22 |
|
23 #include "HttpEventHandler.h" |
22 #include "HttpEventHandler.h" |
24 #include "bautils.h" |
23 #include "bautils.h" |
25 #include "Httpclient.h" |
24 #include "Httpclient.h" |
26 |
25 |
27 void CHttpEventHandler::ConstructL() |
26 void CHttpEventHandler::ConstructL() |
103 } |
102 } |
104 else if (iSavingResponseBody) // If we're saving, then open a file handle for the new file |
103 else if (iSavingResponseBody) // If we're saving, then open a file handle for the new file |
105 { |
104 { |
106 iFileServ.Parse(iFileName, iParsedFileName); |
105 iFileServ.Parse(iFileName, iParsedFileName); |
107 TInt valid = iFileServ.IsValidName(iFileName); |
106 TInt valid = iFileServ.IsValidName(iFileName); |
|
107 |
108 if (!valid) |
108 if (!valid) |
109 { |
109 { |
110 DP("The specified filename is not valid!."); |
110 DP("The specified filename is not valid!."); |
111 iSavingResponseBody = EFalse; |
111 iSavingResponseBody = EFalse; |
112 iHttpClient->ClientRequestCompleteL(KErrBadName); |
112 iHttpClient->ClientRequestCompleteL(KErrBadName); |
126 { |
126 { |
127 int pos = -KByteOverlap; |
127 int pos = -KByteOverlap; |
128 if((err=iRespBodyFile.Seek(ESeekEnd, pos)) != KErrNone) |
128 if((err=iRespBodyFile.Seek(ESeekEnd, pos)) != KErrNone) |
129 { |
129 { |
130 DP("Failed to set position!"); |
130 DP("Failed to set position!"); |
131 iHttpClient->ClientRequestCompleteL(KErrGeneral); |
131 iHttpClient->ClientRequestCompleteL(KErrWrite); |
132 User::Leave(err); |
132 User::Leave(err); |
133 } |
133 } |
134 iBytesDownloaded = (pos > 0) ? pos : 0; |
134 iBytesDownloaded = (pos > 0) ? pos : 0; |
135 iBytesTotal += iBytesDownloaded; |
135 iBytesTotal += iBytesDownloaded; |
136 DP1("Total bytes is now %u", iBytesTotal); |
136 DP1("Total bytes is now %u", iBytesTotal); |
166 { |
166 { |
167 TPtrC8 bodyData; |
167 TPtrC8 bodyData; |
168 iRespBody->GetNextDataPart(bodyData); |
168 iRespBody->GetNextDataPart(bodyData); |
169 iBytesDownloaded += bodyData.Length(); |
169 iBytesDownloaded += bodyData.Length(); |
170 TInt error = iRespBodyFile.Write(bodyData); |
170 TInt error = iRespBodyFile.Write(bodyData); |
|
171 |
171 // on writing error we close connection |
172 // on writing error we close connection |
172 if (error != KErrNone) { |
173 if (error != KErrNone) { |
173 iRespBodyFile.Close(); |
174 iRespBodyFile.Close(); |
174 iCallbacks.FileError(error); |
175 iCallbacks.FileError(error); |
175 iHttpClient->ClientRequestCompleteL(error); |
176 iHttpClient->ClientRequestCompleteL(error); |
201 case THTTPEvent::EFailed: |
202 case THTTPEvent::EFailed: |
202 { |
203 { |
203 DP("Transaction Failed"); |
204 DP("Transaction Failed"); |
204 aTransaction.Close(); |
205 aTransaction.Close(); |
205 |
206 |
206 // if(iLastStatusCode == HTTPStatus::EOk || iLastStatusCode == HTTPStatus::ECreated || iLastStatusCode == HTTPStatus::EAccepted) |
207 if(iLastStatusCode == HTTPStatus::EOk || iLastStatusCode == HTTPStatus::ECreated || iLastStatusCode == HTTPStatus::EAccepted) |
207 // { |
208 { |
208 // iLastStatusCode = KErrNone; |
209 iLastStatusCode = KErrNone; |
209 // } |
210 } |
210 |
211 |
211 iHttpClient->ClientRequestCompleteL(KErrGeneral); |
212 iHttpClient->ClientRequestCompleteL(iLastStatusCode); |
212 } break; |
213 } break; |
213 case THTTPEvent::ERedirectedPermanently: |
214 case THTTPEvent::ERedirectedPermanently: |
214 { |
215 { |
215 DP("Permanent Redirection"); |
216 DP("Permanent Redirection"); |
216 } break; |
217 } break; |
229 } |
230 } |
230 } break; |
231 } break; |
231 } |
232 } |
232 } |
233 } |
233 |
234 |
234 TInt CHttpEventHandler::MHFRunError(TInt aError, RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/) |
235 TInt CHttpEventHandler::MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& /*aEvent*/) |
235 { |
236 { |
236 DP1("MHFRunError fired with error code %d", aError); |
237 DP1("MHFRunError fired with error code %d", aError); |
237 iHttpClient->ClientRequestCompleteL(aError); |
238 aTransaction.Close(); |
|
239 TRAP_IGNORE(iHttpClient->ClientRequestCompleteL(aError)); |
238 return KErrNone; |
240 return KErrNone; |
239 } |
241 } |
240 |
242 |
241 void CHttpEventHandler::SetSaveFileName(const TDesC &fName, TBool aContinue) |
243 void CHttpEventHandler::SetSaveFileName(const TDesC &fName, TBool aContinue) |
242 { |
244 { |