57 const TInt32 KDmgrVersionNumber = 0x0301; // version number of the info file |
57 const TInt32 KDmgrVersionNumber = 0x0301; // version number of the info file |
58 const TInt KUrlFixChar = '_'; |
58 const TInt KUrlFixChar = '_'; |
59 const TInt KMaxHeaderOfMultipart = 32000; |
59 const TInt KMaxHeaderOfMultipart = 32000; |
60 const TInt KRespSizeForRecognition = 1024; //for THttpProgressState EHttpContTypeRecognitionAvail |
60 const TInt KRespSizeForRecognition = 1024; //for THttpProgressState EHttpContTypeRecognitionAvail |
61 const TInt KMinDataSizeToSend = (32*1024); //for Browser Control to call NewDownloadL |
61 const TInt KMinDataSizeToSend = (32*1024); //for Browser Control to call NewDownloadL |
|
62 const TInt KErrCodHttpDownloadPaused = -20045; //Error code set by the CodHandler if the download is paused by the client |
62 |
63 |
63 _LIT8( KHttpScheme, "http" ); |
64 _LIT8( KHttpScheme, "http" ); |
64 _LIT8( KHttpsScheme, "https" ); |
65 _LIT8( KHttpsScheme, "https" ); |
65 _LIT8( KDefDestFilename, "content.bin" ); |
66 _LIT8( KDefDestFilename, "content.bin" ); |
66 _LIT8( KSchemeAddon, "://" ); |
67 _LIT8( KSchemeAddon, "://" ); |
2438 mediaData->SetProgressiveDownload( aValue ); |
2439 mediaData->SetProgressiveDownload( aValue ); |
2439 } |
2440 } |
2440 |
2441 |
2441 if( iProgState != EHttpProgMovingContentFile ) |
2442 if( iProgState != EHttpProgMovingContentFile ) |
2442 { |
2443 { |
2443 TriggerEvent( iDlState, aValue ? EHttpDlProgProgressive : EHttpDlProgNonProgressive); |
2444 if (aValue && iDlState == EHttpDlMultipleMOCompleted ) |
|
2445 { |
|
2446 /* |
|
2447 if the file size is small, by the time the music player is launched, DMgr already triggered EHttpDlCompleted. |
|
2448 So if the download state is EHttpDlMultipleMOCompleted, we need to trigger EHttpDlCompleted so that music player understands download is completed already |
|
2449 This is needed to ensure backward compatibility |
|
2450 */ |
|
2451 TriggerEvent( EHttpDlCompleted, EHttpDlProgProgressive); |
|
2452 } |
|
2453 else |
|
2454 { |
|
2455 TriggerEvent( iDlState, aValue ? EHttpDlProgProgressive : EHttpDlProgNonProgressive); |
|
2456 } |
2444 } |
2457 } |
2445 } |
2458 } |
2446 else |
2459 else |
2447 { |
2460 { |
2448 TriggerEvent( iDlState, EHttpDlProgNonProgressive); |
2461 TriggerEvent( iDlState, EHttpDlProgNonProgressive); |
3185 { |
3198 { |
3186 iGlobalErrorId = result; |
3199 iGlobalErrorId = result; |
3187 iLastError = EGeneral; |
3200 iLastError = EGeneral; |
3188 } |
3201 } |
3189 } |
3202 } |
3190 TriggerEvent( EHttpDlFailed, EHttpProgNone ); |
3203 |
|
3204 //if the client pauses the download, Codhandler sets error code to KErrCodHttpDownloadPaused. In that case, no need to trigger EHttpDlFailed Event |
|
3205 if ( result != KErrCodHttpDownloadPaused ) |
|
3206 { |
|
3207 TriggerEvent( EHttpDlFailed, EHttpProgNone ); |
|
3208 } |
3191 } |
3209 } |
3192 } |
3210 } |
3193 } |
3211 } |
3194 // ----------------------------------------------------------------------------- |
3212 // ----------------------------------------------------------------------------- |
3195 // CHttpDownload::ClientAppInstance |
3213 // CHttpDownload::ClientAppInstance |
3996 APPEND_BUF_INT( newInfoPtr, iExpires ); |
4014 APPEND_BUF_INT( newInfoPtr, iExpires ); |
3997 APPEND_BUF_INT( newInfoPtr, iMaxAge ); |
4015 APPEND_BUF_INT( newInfoPtr, iMaxAge ); |
3998 |
4016 |
3999 CLOG_WRITE("5"); |
4017 CLOG_WRITE("5"); |
4000 |
4018 |
|
4019 |
|
4020 TInt size = GetHttpHeadersSize(iResponseHeaders)+ GetHttpHeadersSize(iRequestHeaders)+ |
|
4021 GetHttpHeadersSize(iEntityHeaders)+ GetHttpHeadersSize(iGeneralHeaders) + newInfoPtr.Size(); |
|
4022 |
|
4023 |
|
4024 if(size >= bufSz) |
|
4025 { |
|
4026 User::LeaveIfError( KErrArgument ); |
|
4027 } |
|
4028 |
4001 AppendHeadersL( newInfoPtr, iResponseHeaders ); |
4029 AppendHeadersL( newInfoPtr, iResponseHeaders ); |
4002 AppendHeadersL( newInfoPtr, iRequestHeaders ); |
4030 AppendHeadersL( newInfoPtr, iRequestHeaders ); |
4003 AppendHeadersL( newInfoPtr, iEntityHeaders ); |
4031 AppendHeadersL( newInfoPtr, iEntityHeaders ); |
4004 AppendHeadersL( newInfoPtr, iGeneralHeaders ); |
4032 AppendHeadersL( newInfoPtr, iGeneralHeaders ); |
4005 |
4033 |
6510 AppendBufL( aBuf, fieldRawData ); |
6538 AppendBufL( aBuf, fieldRawData ); |
6511 CLOG_WRITE8_2( "%S:%S", fieldName, fieldRawData ); |
6539 CLOG_WRITE8_2( "%S:%S", fieldName, fieldRawData ); |
6512 } |
6540 } |
6513 } |
6541 } |
6514 |
6542 |
|
6543 // ----------------------------------------------------------------------------- |
|
6544 // CHttpDownload::GetHttpHeadersSize |
|
6545 // ----------------------------------------------------------------------------- |
|
6546 // |
|
6547 TInt CHttpDownload::GetHttpHeadersSize(CArrayPtrFlat<CHeaderField>* aHeaders ) |
|
6548 { |
|
6549 TInt headers = aHeaders->Count(); |
|
6550 CLOG_WRITE_1("Headers: %d", headers); |
|
6551 |
|
6552 HBufC8* fieldName = NULL; |
|
6553 HBufC8* fieldRawData = NULL; |
|
6554 |
|
6555 TInt size = 0; |
|
6556 |
|
6557 for( TInt i = 0; i < headers; ++i ) |
|
6558 { |
|
6559 fieldName = (*aHeaders)[i]->FieldName(); |
|
6560 fieldRawData = (*aHeaders)[i]->FieldRawData(); |
|
6561 |
|
6562 size = size + fieldName->Size() + fieldRawData->Size(); |
|
6563 |
|
6564 CLOG_WRITE8_1( "Size = %S:", size ); |
|
6565 } |
|
6566 |
|
6567 return size; |
|
6568 |
|
6569 } |
|
6570 |
|
6571 |
6515 // ----------------------------------------------------------------------------- |
6572 // ----------------------------------------------------------------------------- |
6516 // CHttpDownload::AddHeaderL |
6573 // CHttpDownload::AddHeaderL |
6517 // ----------------------------------------------------------------------------- |
6574 // ----------------------------------------------------------------------------- |
6518 // |
6575 // |
6519 void CHttpDownload::AddHeaderL( THttpDownloadAttrib aAttribute, |
6576 void CHttpDownload::AddHeaderL( THttpDownloadAttrib aAttribute, |