47 #include <pathinfo.h> |
51 #include <pathinfo.h> |
48 |
52 |
49 // EXTERNAL DATA STRUCTURES |
53 // EXTERNAL DATA STRUCTURES |
50 //extern ?external_data; |
54 //extern ?external_data; |
51 |
55 |
52 // EXTERNAL FUNCTION PROTOTYPES |
56 // EXTERNAL FUNCTION PROTOTYPES |
53 //extern ?external_function( ?arg_type,?arg_type ); |
57 //extern ?external_function( ?arg_type,?arg_type ); |
54 |
58 |
55 // CONSTANTS |
59 // CONSTANTS |
56 const TInt32 KDMgrInfoFileId = 0x2002; // id to check if it's really an info file |
60 const TInt32 KDMgrInfoFileId = 0x2002; // id to check if it's really an info file |
57 const TInt32 KDmgrVersionNumber = 0x0301; // version number of the info file |
61 const TInt32 KDmgrVersionNumber = 0x0301; // version number of the info file |
58 const TInt KUrlFixChar = '_'; |
62 const TInt KUrlFixChar = '_'; |
59 const TInt KMaxHeaderOfMultipart = 32000; |
63 const TInt KMaxHeaderOfMultipart = 32000; |
60 const TInt KRespSizeForRecognition = 1024; //for THttpProgressState EHttpContTypeRecognitionAvail |
64 const TInt KRespSizeForRecognition = 1024; //for THttpProgressState EHttpContTypeRecognitionAvail |
61 const TInt KMinDataSizeToSend = (32*1024); //for Browser Control to call NewDownloadL |
65 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 |
66 const TInt KErrCodHttpDownloadPaused = -20045; //Error code set by the CodHandler if the download is paused by the client |
63 const TInt KHttp903LossOfService = 903; //Error code set by the CodHandler if connection is lost |
67 const TInt KHttp903LossOfService = 903; //Error code set by the CodHandler if connection is lost |
64 const TInt KHttp954LoaderError = 954; //Error code set by the CodHandler if Loader error is found |
68 const TInt KHttp954LoaderError = 954; //Error code set by the CodHandler if Loader error is found |
65 _LIT8( KHttpScheme, "http" ); |
69 _LIT8( KHttpScheme, "http" ); |
66 _LIT8( KHttpsScheme, "https" ); |
70 _LIT8( KHttpsScheme, "https" ); |
200 ++iDontFireEvent; |
204 ++iDontFireEvent; |
201 |
205 |
202 TRAPD(err, PauseL() ); |
206 TRAPD(err, PauseL() ); |
203 |
207 |
204 --iDontFireEvent; |
208 --iDontFireEvent; |
205 |
209 |
206 User::LeaveIfError( err ); |
210 User::LeaveIfError( err ); |
207 } |
211 } |
208 } |
212 } |
209 |
213 |
210 if( !iStorage->CheckContentFileIntegrityL() ) |
214 if( !iStorage->CheckContentFileIntegrityL() ) |
211 { |
215 { |
212 if (iStorage->ProgressiveDownload() && |
216 if (iStorage->ProgressiveDownload() && |
213 iStorage->Length() == iStorage->DownloadedSize() ) |
217 iStorage->Length() == iStorage->DownloadedSize() ) |
214 // If it was a progressive download |
218 // If it was a progressive download |
215 // and downloaded size = content length, |
219 // and downloaded size = content length, |
216 // it means that download was not properly closed |
220 // it means that download was not properly closed |
217 // in the previous session |
221 // in the previous session |
218 { |
222 { |
219 ReInitializeDownload(); |
223 ReInitializeDownload(); |
654 iClientApp->Engine()->CODDownloadInfoFolder( iClientApp, folder ); |
658 iClientApp->Engine()->CODDownloadInfoFolder( iClientApp, folder ); |
655 file.Format( _L("%S%d"), &folder, iId ); |
659 file.Format( _L("%S%d"), &folder, iId ); |
656 //delete main info file |
660 //delete main info file |
657 err = iClientApp->Engine()->Fs().Delete( file ); |
661 err = iClientApp->Engine()->Fs().Delete( file ); |
658 CLOG_WRITE_2( "Delete info file: %S, err : %d", &file, err ); |
662 CLOG_WRITE_2( "Delete info file: %S, err : %d", &file, err ); |
659 |
663 |
660 //delete subinfo file |
664 //delete subinfo file |
661 CFileMan* fileMan = CFileMan::NewL(iClientApp->Engine()->Fs() ); |
665 CFileMan* fileMan = CFileMan::NewL(iClientApp->Engine()->Fs() ); |
662 file.Format( _L("%S%d_*"), &folder, iId ); |
666 file.Format( _L("%S%d_*"), &folder, iId ); |
663 fileMan->Delete( file ); |
667 fileMan->Delete( file ); |
664 delete fileMan; |
668 delete fileMan; |
665 |
669 |
666 |
670 |
667 // to make sure the CHttpStorage releases the content file |
671 // to make sure the CHttpStorage releases the content file |
668 // and deletes it. |
672 // and deletes it. |
669 CHttpStorage::TFileCloseOperation closeOp = CHttpStorage::EDeleteFile; |
673 CHttpStorage::TFileCloseOperation closeOp = CHttpStorage::EDeleteFile; |
670 |
674 |
671 if( iStorage->DestFNameSet() && iDlState == EHttpDlMultipleMOCompleted ) |
675 if( iStorage->DestFNameSet() && iDlState == EHttpDlMultipleMOCompleted ) |
672 // Do NOT delete the file: if the destination filename was |
676 // Do NOT delete the file: if the destination filename was |
673 // set by the client and download completed. |
677 // set by the client and download completed. |
674 { |
678 { |
675 CLOG_WRITE("Keep file"); |
679 CLOG_WRITE("Keep file"); |
676 closeOp = CHttpStorage::EKeepFile; |
680 closeOp = CHttpStorage::EKeepFile; |
677 } |
681 } |
678 |
682 |
679 if( iStorage->RFileSetByClient()) |
683 if( iStorage->RFileSetByClient()) |
680 { |
684 { |
681 TBool pausable; |
685 TBool pausable; |
682 GetBoolAttributeL( EDlAttrPausable, pausable ); |
686 GetBoolAttributeL( EDlAttrPausable, pausable ); |
683 if( iDlState == EHttpDlMultipleMOCompleted || ( iDlState == EHttpDlInprogress && pausable ) ) |
687 if( iDlState == EHttpDlMultipleMOCompleted || ( iDlState == EHttpDlInprogress && pausable ) ) |
684 { |
688 { |
685 CLOG_WRITE("Keep file"); |
689 CLOG_WRITE("Keep file"); |
686 closeOp = CHttpStorage::EKeepFile; |
690 closeOp = CHttpStorage::EKeepFile; |
687 } |
691 } |
688 |
692 |
689 } |
693 } |
690 if( iCodDlData ) |
694 if( iCodDlData ) |
691 { |
695 { |
692 // For User Delete when all the Downloads are moved to gallery |
696 // For User Delete when all the Downloads are moved to gallery |
693 if( EHttpDlMultipleMOCompleted == iDlState && closeOp == CHttpStorage::EDeleteFile ) |
697 if( EHttpDlMultipleMOCompleted == iDlState && closeOp == CHttpStorage::EDeleteFile ) |
694 { |
698 { |
695 for(TInt i = 1; i <= iCodDlData->Count(); i++) |
699 for(TInt i = 1; i <= iCodDlData->Count(); i++) |
696 { |
700 { |
697 TPtrC fullName = ((*iCodDlData)[i])->DestFilename(); |
701 TPtrC fullName = ((*iCodDlData)[i])->DestFilename(); |
698 ClientApp()->Engine()->Fs().Delete( fullName ); |
702 ClientApp()->Engine()->Fs().Delete( fullName ); |
699 } |
703 } |
700 } |
704 } |
701 // For User Cancel to Cancel Multiple download, Current and Queued DLs will be delete, completed ones will be kept |
705 // For User Cancel to Cancel Multiple download, Current and Queued DLs will be delete, completed ones will be kept |
702 else if( EHttpDlInprogress == iDlState || EHttpDlPaused == iDlState || EHttpDlDeleting == iDlState) |
706 else if( EHttpDlInprogress == iDlState || EHttpDlPaused == iDlState || EHttpDlDeleting == iDlState) |
703 { |
707 { |
704 for(TInt i = 1; i <= iCodDlData->Count(); i++) |
708 for(TInt i = 1; i <= iCodDlData->Count(); i++) |
705 { |
709 { |
706 if( EInProgress == ((*iCodDlData)[i])->State() || EFailed == ((*iCodDlData)[i])->State() ) // OnGoing and Queued will be deleted |
710 if( EInProgress == ((*iCodDlData)[i])->State() || EFailed == ((*iCodDlData)[i])->State() ) // OnGoing and Queued will be deleted |
707 { |
711 { |
708 TPtrC fullName = ((*iCodDlData)[i])->DestFilename(); |
712 TPtrC fullName = ((*iCodDlData)[i])->DestFilename(); |
709 if(fullName.Length()) |
713 if(fullName.Length()) |
710 { |
714 { |
711 ClientApp()->Engine()->Fs().Delete( fullName ); |
715 ClientApp()->Engine()->Fs().Delete( fullName ); |
712 } |
716 } |
713 } |
717 } |
714 //else if( ESucceeded == ((*iCodDlData)[i])->State() ) |
718 //else if( ESucceeded == ((*iCodDlData)[i])->State() ) |
715 // Completed ones will be kept and moved to Gallery |
719 // Completed ones will be kept and moved to Gallery |
716 else if( ESucceeded == ((*iCodDlData)[i])->State() ) |
720 else if( ESucceeded == ((*iCodDlData)[i])->State() ) |
717 { |
721 { |
718 MoveInDelete(i); |
722 MoveInDelete(i); |
719 } |
723 } |
720 } |
724 } |
721 } |
725 } |
722 } |
726 } |
723 else |
727 else |
724 { |
728 { |
725 iStorage->CloseDestinationFile( closeOp ); |
729 iStorage->CloseDestinationFile( closeOp ); |
726 } |
730 } |
727 // when delete there's no store -> no leave |
731 // when delete there's no store -> no leave |
728 // aClAppInstance->ClientApp()->UnregisterDownload( this ); |
732 // aClAppInstance->ClientApp()->UnregisterDownload( this ); |
729 } |
733 } |
730 |
734 |
731 |
735 |
732 // ----------------------------------------------------------------------------- |
736 // ----------------------------------------------------------------------------- |
733 // CHttpDownload::DeleteInfoFile |
737 // CHttpDownload::DeleteInfoFile |
736 // ----------------------------------------------------------------------------- |
740 // ----------------------------------------------------------------------------- |
737 // |
741 // |
738 EXPORT_C void CHttpDownload::DeleteInfoFile( CHttpClientAppInstance* aClAppInstance ) |
742 EXPORT_C void CHttpDownload::DeleteInfoFile( CHttpClientAppInstance* aClAppInstance ) |
739 { |
743 { |
740 CLOG_WRITE( "DeleteInfoFile()" ); |
744 CLOG_WRITE( "DeleteInfoFile()" ); |
741 |
745 |
742 // This should be called only after the completion of download |
746 // This should be called only after the completion of download |
743 if( ! (EHttpDlMultipleMOCompleted == iDlState && |
747 if( ! (EHttpDlMultipleMOCompleted == iDlState && |
744 ( |
748 ( |
745 EHttpProgContentFileMoved == iProgState || |
749 EHttpProgContentFileMoved == iProgState || |
746 EHttpProgContentFileMovedAndDestFNChanged == iProgState |
750 EHttpProgContentFileMovedAndDestFNChanged == iProgState |
747 ) |
751 ) |
748 )) |
752 )) |
749 { |
753 { |
750 return; |
754 return; |
751 } |
755 } |
752 |
756 |
753 // Do not inform user about that we are in deleteing state |
757 // Do not inform user about that we are in deleteing state |
754 // This won't be reenabled at the end of this function so |
758 // This won't be reenabled at the end of this function so |
755 // don't call delete only from outside of this class. |
759 // don't call delete only from outside of this class. |
756 ++iDontFireEvent; |
760 ++iDontFireEvent; |
757 |
761 |
758 TPath folder; |
762 TPath folder; |
759 TFileName file; |
763 TFileName file; |
760 |
764 |
761 // delete info file |
765 // delete info file |
762 iClientApp->Engine()->DownloadInfoFolder( iClientApp, folder ); |
766 iClientApp->Engine()->DownloadInfoFolder( iClientApp, folder ); |
766 |
770 |
767 // delete cod info file |
771 // delete cod info file |
768 iClientApp->Engine()->CODDownloadInfoFolder( iClientApp, folder ); |
772 iClientApp->Engine()->CODDownloadInfoFolder( iClientApp, folder ); |
769 file.Format( _L("%S%d"), &folder, iId ); |
773 file.Format( _L("%S%d"), &folder, iId ); |
770 CLOG_WRITE_1( "Delete info file: %S", &file ); |
774 CLOG_WRITE_1( "Delete info file: %S", &file ); |
771 iClientApp->Engine()->Fs().Delete( file ); |
775 iClientApp->Engine()->Fs().Delete( file ); |
772 |
776 |
773 //delete subinfo file |
777 //delete subinfo file |
774 CFileMan* fileMan = CFileMan::NewL(iClientApp->Engine()->Fs() ); |
778 CFileMan* fileMan = CFileMan::NewL(iClientApp->Engine()->Fs() ); |
775 file.Format( _L("%S%d_*"), &folder, iId ); |
779 file.Format( _L("%S%d_*"), &folder, iId ); |
776 fileMan->Delete( file ); |
780 fileMan->Delete( file ); |
777 delete fileMan; |
781 delete fileMan; |
778 |
782 |
779 |
783 |
780 // to make sure the CHttpStorage releases the content file |
784 // to make sure the CHttpStorage releases the content file |
781 // and deletes it. |
785 // and deletes it. |
782 CHttpStorage::TFileCloseOperation closeOp = CHttpStorage::EDeleteFile; |
786 CHttpStorage::TFileCloseOperation closeOp = CHttpStorage::EDeleteFile; |
783 |
787 |
784 if( iStorage->DestFNameSet() && iDlState == EHttpDlMultipleMOCompleted ) |
788 if( iStorage->DestFNameSet() && iDlState == EHttpDlMultipleMOCompleted ) |
785 // Do NOT delete the file: if the destination filename was |
789 // Do NOT delete the file: if the destination filename was |
786 // set by the client and download completed. |
790 // set by the client and download completed. |
787 { |
791 { |
788 CLOG_WRITE("Keep file"); |
792 CLOG_WRITE("Keep file"); |
789 closeOp = CHttpStorage::EKeepFile; |
793 closeOp = CHttpStorage::EKeepFile; |
790 } |
794 } |
791 |
795 |
792 iStorage->CloseDestinationFile( closeOp ); |
796 iStorage->CloseDestinationFile( closeOp ); |
793 |
797 |
794 // when delete there's no store -> no leave |
798 // when delete there's no store -> no leave |
795 aClAppInstance->ClientApp()->UnregisterDownload( this ); |
799 aClAppInstance->ClientApp()->UnregisterDownload( this ); |
796 } |
800 } |
797 |
801 |
798 |
802 |
799 // ----------------------------------------------------------------------------- |
803 // ----------------------------------------------------------------------------- |
800 // CHttpDownload::MoveL |
804 // CHttpDownload::MoveL |
827 |
831 |
828 if( iProgState == EHttpProgMovingContentFile ) |
832 if( iProgState == EHttpProgMovingContentFile ) |
829 { |
833 { |
830 User::Leave( KErrInUse ); |
834 User::Leave( KErrInUse ); |
831 } |
835 } |
832 |
836 |
833 //File is already moved. Ignore the move |
837 //File is already moved. Ignore the move |
834 if( iProgState == EHttpProgContentFileMovedAndDestFNChanged || |
838 if( iProgState == EHttpProgContentFileMovedAndDestFNChanged || |
835 |
839 |
836 iProgState == EHttpProgContentFileMoved ) |
840 iProgState == EHttpProgContentFileMoved ) |
837 { |
841 { |
838 return; |
842 return; |
839 } |
843 } |
840 |
844 |
841 __ASSERT_DEBUG( !IsActive(), DMPanic( KErrInUse ) ); |
845 __ASSERT_DEBUG( !IsActive(), DMPanic( KErrInUse ) ); |
842 //__ASSERT_DEBUG( !iFileMan, DMPanic( KErrInUse ) ); |
846 //__ASSERT_DEBUG( !iFileMan, DMPanic( KErrInUse ) ); |
843 |
847 |
844 if(_OMADLOTA2_MULTI_DOWNLOAD) |
848 if(_OMADLOTA2_MULTI_DOWNLOAD) |
845 { |
849 { |
846 iMOMoved = 1; |
850 iMOMoved = 1; |
847 SetDownloadStatus( EHttpProgMovingContentFile, iDlState ); |
851 SetDownloadStatus( EHttpProgMovingContentFile, iDlState ); |
848 MoveDownloadedMediaObjectL(iMOMoved); |
852 MoveDownloadedMediaObjectL(iMOMoved); |
869 do |
873 do |
870 { |
874 { |
871 CreateIndexedNameL(uniqueName , fileNamePtr , index); |
875 CreateIndexedNameL(uniqueName , fileNamePtr , index); |
872 if( !BaflUtils::FileExists( rFs , *uniqueName ) ) |
876 if( !BaflUtils::FileExists( rFs , *uniqueName ) ) |
873 //Check if file name exist in Destination path |
877 //Check if file name exist in Destination path |
874 //Generate Unique name if exist |
878 //Generate Unique name if exist |
875 { |
879 { |
876 bFound =ETrue; |
880 bFound =ETrue; |
877 break; |
881 break; |
878 } |
882 } |
879 iDlNameChanged = ETrue; |
883 iDlNameChanged = ETrue; |
880 |
884 |
881 }while( !bFound ); |
885 }while( !bFound ); |
882 CleanupStack::PopAndDestroy( fileName ); |
886 CleanupStack::PopAndDestroy( fileName ); |
883 |
887 |
884 if( iDlNameChanged ) |
888 if( iDlNameChanged ) |
885 { |
889 { |
886 HBufC16* destFileName ; |
890 HBufC16* destFileName ; |
887 destFileName = iStorage->DestFilename(); |
891 destFileName = iStorage->DestFilename(); |
888 TPtr destFileNamePtr = destFileName->Des(); |
892 TPtr destFileNamePtr = destFileName->Des(); |
889 destFileNamePtr.Replace(0, destFileNamePtr.Length() , *uniqueName); |
893 destFileNamePtr.Replace(0, destFileNamePtr.Length() , *uniqueName); |
890 TInt lastSlashPos = destFileNamePtr.LocateReverse( '\\' ); |
894 TInt lastSlashPos = destFileNamePtr.LocateReverse( '\\' ); |
891 TPtr dlName = destFileNamePtr.MidTPtr(lastSlashPos +1 ); |
895 TPtr dlName = destFileNamePtr.MidTPtr(lastSlashPos +1 ); |
892 TInt dotPos = iDlName->LocateReverse( '.' ); |
896 TInt dotPos = iDlName->LocateReverse( '.' ); |
893 if( dotPos == KErrNotFound ) |
897 if( dotPos == KErrNotFound ) |
894 { |
898 { |
895 //Remove Extension from dlName as it was not present in old iDlName |
899 //Remove Extension from dlName as it was not present in old iDlName |
896 dotPos = dlName.LocateReverse( '.' ); |
900 dotPos = dlName.LocateReverse( '.' ); |
897 if(dotPos != KErrNotFound ) |
901 if(dotPos != KErrNotFound ) |
898 { |
902 { |
899 dlName.Copy( dlName.Left(dotPos)); |
903 dlName.Copy( dlName.Left(dotPos)); |
900 } |
904 } |
901 } |
905 } |
902 //download name has changed |
906 //download name has changed |
903 ReallocateStringL( iDlName, dlName, KDownloadNameMaxSize ); |
907 ReallocateStringL( iDlName, dlName, KDownloadNameMaxSize ); |
904 } |
908 } |
905 |
909 |
906 TInt err =iFileMan->Move( *iStorage->LocalFilename(), |
910 TInt err =iFileMan->Move( *iStorage->LocalFilename(), |
907 *iStorage->DestFilename(), |
911 *iStorage->DestFilename(), |
908 CFileMan::EOverWrite, |
912 CFileMan::EOverWrite, |
909 iStatus ); |
913 iStatus ); |
910 if(err != KErrNone) |
914 if(err != KErrNone) |
911 { |
915 { |
912 iMoveInProgress = EFalse; |
916 iMoveInProgress = EFalse; |
913 CLOG_WRITE("setting iMoveInProgress false when move fails"); |
917 CLOG_WRITE("setting iMoveInProgress false when move fails"); |
914 } |
918 } |
915 |
919 |
916 User::LeaveIfError( err ); |
920 User::LeaveIfError( err ); |
917 // waiting for move to complete |
921 // waiting for move to complete |
918 SetActive(); |
922 SetActive(); |
919 SetDownloadStatus( EHttpProgMovingContentFile, iDlState ); |
923 SetDownloadStatus( EHttpProgMovingContentFile, iDlState ); |
920 } |
924 } |
921 |
925 |
1116 User::Leave( KErrArgument ); |
1114 User::Leave( KErrArgument ); |
1117 #endif |
1115 #endif |
1118 } |
1116 } |
1119 break; |
1117 break; |
1120 } |
1118 } |
1121 |
1119 |
1122 iNoRealError = EFalse; |
1120 iNoRealError = EFalse; |
1123 } |
1121 } |
1124 |
1122 |
1125 // ----------------------------------------------------------------------------- |
1123 // ----------------------------------------------------------------------------- |
1126 // CHttpDownload::GetIntAttributeL |
1124 // CHttpDownload::GetIntAttributeL |
1127 // ?implementation_description |
1125 // ?implementation_description |
1128 // (other items were commented in a header). |
1126 // (other items were commented in a header). |
1129 // ----------------------------------------------------------------------------- |
1127 // ----------------------------------------------------------------------------- |
1130 // |
1128 // |
1131 EXPORT_C void CHttpDownload::GetIntAttributeL( THttpDownloadAttrib aAttribute, |
1129 EXPORT_C void CHttpDownload::GetIntAttributeL( THttpDownloadAttrib aAttribute, |
1132 TInt32& aMoIndex, |
1130 TInt32& aMoIndex, |
1133 TInt32& aValue ) |
1131 TInt32& aValue ) |
1134 { |
1132 { |
1135 LOGGER_ENTERFN( "GetIntAttributeL" ); |
1133 LOGGER_ENTERFN( "GetIntAttributeL" ); |
1136 CLOG_WRITE_1( "Attr(%d)", aAttribute ); |
1134 CLOG_WRITE_1( "Attr(%d)", aAttribute ); |
1137 |
1135 |
1138 if (!iCodDlData) |
1136 if (!iCodDlData) |
1139 { |
1137 { |
1140 aValue = 0; |
1138 aValue = 0; |
1141 return; |
1139 return; |
1142 } |
1140 } |
1143 if ((aMoIndex <= KNonMoIndex) || (aMoIndex > iCodDlData->Count())) |
1141 if ((aMoIndex <= KNonMoIndex) || (aMoIndex > iCodDlData->Count())) |
1144 { |
1142 { |
1145 User::Leave( KErrArgument ); |
1143 User::Leave( KErrArgument ); |
1146 } |
1144 } |
1147 |
1145 |
1148 CMediaDataBase* mediaData = (*iCodDlData)[aMoIndex]; |
1146 CMediaDataBase* mediaData = (*iCodDlData)[aMoIndex]; |
1149 iNoRealError = ETrue; |
1147 iNoRealError = ETrue; |
1150 |
1148 |
1151 switch( aAttribute ) |
1149 switch( aAttribute ) |
1152 { |
1150 { |
1217 User::Leave( KErrArgument ); |
1209 User::Leave( KErrArgument ); |
1218 #endif |
1210 #endif |
1219 } |
1211 } |
1220 break; |
1212 break; |
1221 } |
1213 } |
1222 |
1214 |
1223 iNoRealError = EFalse; |
1215 iNoRealError = EFalse; |
1224 } |
1216 } |
1225 |
1217 |
1226 // ----------------------------------------------------------------------------- |
1218 // ----------------------------------------------------------------------------- |
1227 // CHttpDownload::GetBoolAttributeL |
1219 // CHttpDownload::GetBoolAttributeL |
1228 // ?implementation_description |
1220 // ?implementation_description |
1229 // (other items were commented in a header). |
1221 // (other items were commented in a header). |
1230 // ----------------------------------------------------------------------------- |
1222 // ----------------------------------------------------------------------------- |
1231 // |
1223 // |
1232 EXPORT_C void CHttpDownload::GetBoolAttributeL( THttpDownloadAttrib aAttribute, |
1224 EXPORT_C void CHttpDownload::GetBoolAttributeL( THttpDownloadAttrib aAttribute, |
1233 TBool& aValue ) |
1225 TBool& aValue ) |
1234 { |
1226 { |
1235 LOGGER_ENTERFN( "GetBoolAttributeL" ); |
1227 LOGGER_ENTERFN( "GetBoolAttributeL" ); |
1236 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
1228 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
1237 |
1229 |
1326 User::Leave( KErrArgument ); |
1318 User::Leave( KErrArgument ); |
1327 #endif |
1319 #endif |
1328 } |
1320 } |
1329 break; |
1321 break; |
1330 } |
1322 } |
1331 |
1323 |
1332 iNoRealError = EFalse; |
1324 iNoRealError = EFalse; |
1333 } |
1325 } |
1334 |
1326 |
1335 // ----------------------------------------------------------------------------- |
1327 // ----------------------------------------------------------------------------- |
1336 // CHttpDownload::GetBoolAttributeL |
1328 // CHttpDownload::GetBoolAttributeL |
1337 // ?implementation_description |
1329 // ?implementation_description |
1338 // (other items were commented in a header). |
1330 // (other items were commented in a header). |
1339 // ----------------------------------------------------------------------------- |
1331 // ----------------------------------------------------------------------------- |
1340 // |
1332 // |
1341 EXPORT_C void CHttpDownload::GetBoolAttributeL( THttpDownloadAttrib aAttribute, |
1333 EXPORT_C void CHttpDownload::GetBoolAttributeL( THttpDownloadAttrib aAttribute, |
1342 TInt32& aMoIndex, |
1334 TInt32& aMoIndex, |
1343 TBool& aValue ) |
1335 TBool& aValue ) |
1344 { |
1336 { |
1345 LOGGER_ENTERFN( "GetBoolAttributeL" ); |
1337 LOGGER_ENTERFN( "GetBoolAttributeL" ); |
1346 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
1338 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
1347 |
1339 |
1348 if (!iCodDlData) |
1340 if (!iCodDlData) |
1349 { |
1341 { |
1350 aValue = 0; |
1342 aValue = 0; |
1351 return; |
1343 return; |
1352 } |
1344 } |
1353 if ((aMoIndex <= KNonMoIndex) || (aMoIndex > iCodDlData->Count())) |
1345 if ((aMoIndex <= KNonMoIndex) || (aMoIndex > iCodDlData->Count())) |
1354 { |
1346 { |
1355 User::Leave( KErrArgument ); |
1347 User::Leave( KErrArgument ); |
1356 } |
1348 } |
1357 |
1349 |
1358 CMediaDataBase* mediaData = (*iCodDlData)[aMoIndex]; |
1350 CMediaDataBase* mediaData = (*iCodDlData)[aMoIndex]; |
1359 iNoRealError = ETrue; |
1351 iNoRealError = ETrue; |
1360 |
1352 |
1361 switch( aAttribute ) |
1353 switch( aAttribute ) |
1362 { |
1354 { |
1394 User::Leave( KErrArgument ); |
1386 User::Leave( KErrArgument ); |
1395 #endif |
1387 #endif |
1396 } |
1388 } |
1397 break; |
1389 break; |
1398 } |
1390 } |
1399 |
1391 |
1400 iNoRealError = EFalse; |
1392 iNoRealError = EFalse; |
1401 } |
1393 } |
1402 |
1394 |
1403 // ----------------------------------------------------------------------------- |
1395 // ----------------------------------------------------------------------------- |
1404 // CHttpDownload::GetStringAttributeL |
1396 // CHttpDownload::GetStringAttributeL |
1405 // ?implementation_description |
1397 // ?implementation_description |
1406 // (other items were commented in a header). |
1398 // (other items were commented in a header). |
1407 // ----------------------------------------------------------------------------- |
1399 // ----------------------------------------------------------------------------- |
1408 // |
1400 // |
1409 EXPORT_C HBufC* CHttpDownload::GetStringAttributeL( THttpDownloadAttrib aAttribute, |
1401 EXPORT_C HBufC* CHttpDownload::GetStringAttributeL( THttpDownloadAttrib aAttribute, |
1410 TBool& aDelete ) |
1402 TBool& aDelete ) |
1411 { |
1403 { |
1412 LOGGER_ENTERFN( "GetStringAttributeL" ); |
1404 LOGGER_ENTERFN( "GetStringAttributeL" ); |
1413 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
1405 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
1414 |
1406 |
2162 // CHttpDownload::SetIntAttributeL |
2154 // CHttpDownload::SetIntAttributeL |
2163 // ?implementation_description |
2155 // ?implementation_description |
2164 // (other items were commented in a header). |
2156 // (other items were commented in a header). |
2165 // ----------------------------------------------------------------------------- |
2157 // ----------------------------------------------------------------------------- |
2166 // |
2158 // |
2167 EXPORT_C void CHttpDownload::SetIntAttributeL( THttpDownloadAttrib aAttribute, |
2159 EXPORT_C void CHttpDownload::SetIntAttributeL( THttpDownloadAttrib aAttribute, |
2168 const TInt32 aValue ) |
2160 const TInt32 aValue ) |
2169 { |
2161 { |
2170 LOGGER_ENTERFN( "SetIntAttributeL" ); |
2162 LOGGER_ENTERFN( "SetIntAttributeL" ); |
2171 CLOG_WRITE_2( "Attr(%d): %d", aAttribute, aValue ); |
2163 CLOG_WRITE_2( "Attr(%d): %d", aAttribute, aValue ); |
2172 TBool store( ETrue ); |
2164 TBool store( ETrue ); |
2230 } |
2222 } |
2231 break; |
2223 break; |
2232 |
2224 |
2233 case EDlAttrMultipleMOLength: |
2225 case EDlAttrMultipleMOLength: |
2234 { |
2226 { |
2235 iMoLength = aValue; |
2227 iMoLength = aValue; |
2236 } |
2228 } |
2237 break; |
2229 break; |
2238 |
2230 |
2239 case EDlAttrDownloadedSize: |
2231 case EDlAttrDownloadedSize: |
2240 { |
2232 { |
2241 if( (iCodDownload || iContinueDownload) && iDlState == EHttpDlInprogress ) |
2233 if( (iCodDownload || iContinueDownload) && iDlState == EHttpDlInprogress ) |
2242 { |
2234 { |
2243 iStorage->SetDownloadedSize( aValue ); |
2235 iStorage->SetDownloadedSize( aValue ); |
2244 // Calculate downloaded size of current media object from |
2236 // Calculate downloaded size of current media object from |
2245 // album downloaded size. |
2237 // album downloaded size. |
2246 TInt dlSize = iStorage->DownloadedSize(); |
2238 TInt dlSize = iStorage->DownloadedSize(); |
2247 if( iCodDlData ) |
2239 if( iCodDlData ) |
2248 { |
2240 { |
2249 for (TInt index = 0; index < iCodDlData->Count() ; ++index) |
2241 for (TInt index = 0; index < iCodDlData->Count() ; ++index) |
2250 { |
2242 { |
2251 if( iActiveDownload - 1 == index ) |
2243 if( iActiveDownload - 1 == index ) |
2252 { |
2244 { |
2253 //the size of active download has already been taken into account |
2245 //the size of active download has already been taken into account |
2254 continue; |
2246 continue; |
2255 } |
2247 } |
2256 CMediaDataBase* moData = (*iCodDlData)[index+1]; |
2248 CMediaDataBase* moData = (*iCodDlData)[index+1]; |
2257 if ((moData->State() == ESucceeded) || (moData->State() == EInProgress)) |
2249 if ((moData->State() == ESucceeded) || (moData->State() == EInProgress)) |
2258 dlSize += moData->DownloadedSize(); |
2250 dlSize += moData->DownloadedSize(); |
2259 } |
2251 } |
2260 iStorage->SetMoDownloadedSize(dlSize); |
2252 iStorage->SetMoDownloadedSize(dlSize); |
2261 } |
2253 } |
2262 if( iStorage->Length() != KDefaultContentLength && |
2254 if( iStorage->Length() != KDefaultContentLength && |
2263 iStorage->DownloadedSize() > iStorage->Length() ) |
2255 iStorage->DownloadedSize() > iStorage->Length() ) |
2264 // we don't know actually how many bytes will come down. |
2256 // we don't know actually how many bytes will come down. |
2265 { |
2257 { |
2266 CLOG_WRITE( "Length modified" ); |
2258 CLOG_WRITE( "Length modified" ); |
2267 iStorage->SetLength( KDefaultContentLength ); |
2259 iStorage->SetLength( KDefaultContentLength ); |
2268 StoreDownloadInfoL(); |
2260 StoreDownloadInfoL(); |
2269 } |
2261 } |
2270 TriggerEvent( EHttpDlInprogress, EHttpProgResponseBodyReceived ); |
2262 TriggerEvent( EHttpDlInprogress, EHttpProgResponseBodyReceived ); |
2271 } |
2263 } |
2272 |
2264 |
2273 store = EFalse; |
2265 store = EFalse; |
2274 } |
2266 } |
2275 break; |
2267 break; |
2276 |
2268 |
2277 case EDlAttrSucceeded: |
2269 case EDlAttrSucceeded: |
2278 { |
2270 { |
2279 if(!aValue) |
2271 if(!aValue) |
2280 DownloadSucceededL(); |
2272 DownloadSucceededL(); |
2281 else |
2273 else |
2282 iMoDownloadCompleted = ETrue;//Download of MO has been Completed so change State ,But PD is on |
2274 iMoDownloadCompleted = ETrue;//Download of MO has been Completed so change State ,But PD is on |
2283 //So MOVE will be issued by PD Client |
2275 //So MOVE will be issued by PD Client |
2284 |
2276 |
2285 store = EFalse; |
2277 store = EFalse; |
2286 } |
2278 } |
2287 break; |
2279 break; |
2288 |
2280 |
2315 } |
2307 } |
2316 } |
2308 } |
2317 break; |
2309 break; |
2318 |
2310 |
2319 case EDlAttrFotaPckgId: |
2311 case EDlAttrFotaPckgId: |
2320 { |
2312 { |
2321 iFotaPckgId = aValue; |
2313 iFotaPckgId = aValue; |
2322 store = EFalse; |
2314 store = EFalse; |
2323 } |
2315 } |
2324 break; |
2316 break; |
2325 case EDlAttrActiveDownload: |
2317 case EDlAttrActiveDownload: |
2326 { |
2318 { |
2327 iActiveDownload = aValue; |
2319 iActiveDownload = aValue; |
2328 |
2320 |
2329 // Active MO changed. Notify clients. |
2321 // Active MO changed. Notify clients. |
2330 TriggerEvent( EHttpDlCreated, EHttpProgNone ); |
2322 TriggerEvent( EHttpDlCreated, EHttpProgNone ); |
2331 } |
2323 } |
2332 break; |
2324 break; |
2333 |
2325 |
2334 case EDlAttrActivePlayedDownload: |
2326 case EDlAttrActivePlayedDownload: |
2335 { |
2327 { |
2336 iActivePlayedDownload = aValue; |
2328 iActivePlayedDownload = aValue; |
2337 } |
2329 } |
2338 |
2330 |
2339 break; |
|
2340 |
|
2341 case EDlAttrDestRemovable: |
|
2342 { |
|
2343 if( iCodDownload ) |
|
2344 { |
|
2345 iStorage->SetRemovableDest( aValue ); |
|
2346 |
|
2347 if (iCodDlData) |
|
2348 { |
|
2349 // Update for Active media object. |
|
2350 TInt active = iActiveDownload; |
|
2351 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
|
2352 mediaData->SetDesRemovable( aValue ); |
|
2353 } |
|
2354 } |
|
2355 } |
|
2356 break; |
2331 break; |
2357 default: |
2332 default: |
2358 { |
2333 { |
2359 #ifdef __WINS__ |
2334 #ifdef __WINS__ |
2360 DMPanic( KErrArgument ); |
2335 DMPanic( KErrArgument ); |
2379 // CHttpDownload::SetBoolAttributeL |
2354 // CHttpDownload::SetBoolAttributeL |
2380 // ?implementation_description |
2355 // ?implementation_description |
2381 // (other items were commented in a header). |
2356 // (other items were commented in a header). |
2382 // ----------------------------------------------------------------------------- |
2357 // ----------------------------------------------------------------------------- |
2383 // |
2358 // |
2384 EXPORT_C void CHttpDownload::SetBoolAttributeL( THttpDownloadAttrib aAttribute, |
2359 EXPORT_C void CHttpDownload::SetBoolAttributeL( THttpDownloadAttrib aAttribute, |
2385 const TBool aValue ) |
2360 const TBool aValue ) |
2386 { |
2361 { |
2387 LOGGER_ENTERFN( "SetBoolAttributeL" ); |
2362 LOGGER_ENTERFN( "SetBoolAttributeL" ); |
2388 CLOG_WRITE_2( "Attr(%d): %d", aAttribute, aValue ); |
2363 CLOG_WRITE_2( "Attr(%d): %d", aAttribute, aValue ); |
2389 TBool store( ETrue ); |
2364 TBool store( ETrue ); |
2440 case EDlAttrCodDownload: |
2415 case EDlAttrCodDownload: |
2441 { |
2416 { |
2442 SetCodFlag( aValue ); |
2417 SetCodFlag( aValue ); |
2443 } |
2418 } |
2444 break; |
2419 break; |
2445 |
2420 |
2446 case EDlAttrProgressive: |
2421 case EDlAttrProgressive: |
2447 { |
2422 { |
2448 TBool PdSupported(EFalse); |
2423 TBool PdSupported(EFalse); |
2449 |
2424 |
2450 if(iClAppInstance) |
2425 if(iClAppInstance) |
2451 { |
2426 { |
2452 TRAP_IGNORE(iClAppInstance->GetBoolAttributeL(EDlMgrProgressiveDownload, PdSupported)); |
2427 TRAP_IGNORE(iClAppInstance->GetBoolAttributeL(EDlMgrProgressiveDownload, PdSupported)); |
2453 } |
2428 } |
2454 |
2429 |
2455 if(PdSupported) |
2430 if(PdSupported) |
2456 { |
2431 { |
2457 iStorage->SetProgressiveMode( aValue ); |
2432 iStorage->SetProgressiveMode( aValue ); |
2458 |
2433 |
2459 if(!aValue) |
2434 if(!aValue) |
2460 { |
2435 { |
2461 iActivePlayedDownload = 0; |
2436 iActivePlayedDownload = 0; |
2462 } |
2437 } |
2463 |
2438 |
2464 if (iCodDlData) |
2439 if (iCodDlData) |
2465 { |
2440 { |
2466 // Update for Active media object. |
2441 // Update for Active media object. |
2467 TInt active = iActiveDownload; |
2442 TInt active = iActiveDownload; |
2468 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
2443 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
2469 mediaData->SetProgressiveDownload( aValue ); |
2444 mediaData->SetProgressiveDownload( aValue ); |
2470 } |
2445 } |
2471 |
2446 |
2472 if( iProgState != EHttpProgMovingContentFile ) |
2447 if( iProgState != EHttpProgMovingContentFile ) |
2473 { |
2448 { |
2474 if (aValue && iDlState == EHttpDlMultipleMOCompleted ) |
2449 if (aValue && iDlState == EHttpDlMultipleMOCompleted ) |
2475 { |
2450 { |
2476 /* |
2451 /* |
2477 if the file size is small, by the time the music player is launched, DMgr already triggered EHttpDlCompleted. |
2452 if the file size is small, by the time the music player is launched, DMgr already triggered EHttpDlCompleted. |
2478 So if the download state is EHttpDlMultipleMOCompleted, we need to trigger EHttpDlCompleted so that music player understands download is completed already |
2453 So if the download state is EHttpDlMultipleMOCompleted, we need to trigger EHttpDlCompleted so that music player understands download is completed already |
2479 This is needed to ensure backward compatibility |
2454 This is needed to ensure backward compatibility |
2480 */ |
2455 */ |
2481 TriggerEvent( EHttpDlCompleted, EHttpDlProgProgressive); |
2456 TriggerEvent( EHttpDlCompleted, EHttpDlProgProgressive); |
2482 } |
2457 } |
2483 else |
2458 else |
2484 { |
2459 { |
2485 TriggerEvent( iDlState, aValue ? EHttpDlProgProgressive : EHttpDlProgNonProgressive); |
2460 TriggerEvent( iDlState, aValue ? EHttpDlProgProgressive : EHttpDlProgNonProgressive); |
2486 } |
2461 } |
2487 } |
2462 } |
2488 } |
2463 } |
2489 else |
2464 else |
2490 { |
2465 { |
2491 TriggerEvent( iDlState, EHttpDlProgNonProgressive); |
2466 TriggerEvent( iDlState, EHttpDlProgNonProgressive); |
2492 } |
2467 } |
2493 } |
2468 } |
2494 break; |
2469 break; |
2495 |
2470 |
2496 case EDlAttrCodDescriptorAccepted: |
2471 case EDlAttrCodDescriptorAccepted: |
2497 { |
2472 { |
2498 TriggerEvent( EHttpDlInprogress, EHttpProgCodDescriptorAccepted ); |
2473 TriggerEvent( EHttpDlInprogress, EHttpProgCodDescriptorAccepted ); |
2499 } |
2474 } |
2500 break; |
2475 break; |
2501 |
2476 |
2502 case EDlAttrCodLoadEnd: |
2477 case EDlAttrCodLoadEnd: |
2503 { |
2478 { |
2504 SetDownloadStatus(EHttpProgCodLoadEnd,EHttpDlInprogress); |
2479 SetDownloadStatus(EHttpProgCodLoadEnd,EHttpDlInprogress); |
2505 } |
2480 } |
2506 break; |
2481 break; |
2630 } |
2603 } |
2631 else |
2604 else |
2632 { |
2605 { |
2633 User::Leave( KErrInUse ); |
2606 User::Leave( KErrInUse ); |
2634 } |
2607 } |
2635 |
2608 |
2636 if (updateFName) |
2609 if (updateFName) |
2637 { |
2610 { |
2638 iStorage->UpdateDestinationFilenameL( aValue, ETrue ); |
2611 iStorage->UpdateDestinationFilenameL( aValue, ETrue ); |
2639 if (iCodDlData) |
2612 if (iCodDlData) |
2640 { |
2613 { |
2641 CMediaDataBase* mediaData = (*iCodDlData)[aMOIndex]; |
2614 CMediaDataBase* mediaData = (*iCodDlData)[aMOIndex]; |
2642 mediaData->SetDestFilenameL( aValue ); |
2615 mediaData->SetDestFilenameL( aValue ); |
2643 } |
2616 } |
2644 } |
2617 } |
2645 } |
2618 } |
2646 break; |
2619 break; |
2647 } |
2620 } |
2648 } |
2621 } |
2649 |
2622 |
2650 |
2623 |
2651 // ----------------------------------------------------------------------------- |
2624 // ----------------------------------------------------------------------------- |
2652 // CHttpDownload::SetStringAttributeL |
2625 // CHttpDownload::SetStringAttributeL |
2653 // ?implementation_description |
2626 // ?implementation_description |
2654 // (other items were commented in a header). |
2627 // (other items were commented in a header). |
2655 // ----------------------------------------------------------------------------- |
2628 // ----------------------------------------------------------------------------- |
2656 // |
2629 // |
2657 EXPORT_C void CHttpDownload::SetStringAttributeL( THttpDownloadAttrib aAttribute, |
2630 EXPORT_C void CHttpDownload::SetStringAttributeL( THttpDownloadAttrib aAttribute, |
2658 const TDesC16& aValue ) |
2631 const TDesC16& aValue ) |
2659 { |
2632 { |
2660 LOGGER_ENTERFN( "SetStringAttributeL" ); |
2633 LOGGER_ENTERFN( "SetStringAttributeL" ); |
2661 CLOG_WRITE_2( "Attr(%d - %d)", aAttribute, aValue.Length () ); |
2634 CLOG_WRITE_2( "Attr(%d - %d)", aAttribute, aValue.Length () ); |
2662 TBool store( ETrue ); |
2635 TBool store( ETrue ); |
2684 if( iDlState == EHttpDlInprogress ) |
2657 if( iDlState == EHttpDlInprogress ) |
2685 { |
2658 { |
2686 CLOG_WRITE( "EDlAttrContentType updated" ); |
2659 CLOG_WRITE( "EDlAttrContentType updated" ); |
2687 ReallocateStringL( iContentType, aValue, KMaxContentTypeLength ); |
2660 ReallocateStringL( iContentType, aValue, KMaxContentTypeLength ); |
2688 TriggerEvent( EHttpDlInprogress, EHttpProgContentTypeChanged ); |
2661 TriggerEvent( EHttpDlInprogress, EHttpProgContentTypeChanged ); |
2689 |
2662 |
2690 // Update for Active media object. |
2663 // Update for Active media object. |
2691 HBufC8* type8 = HBufC8::NewLC( aValue.Length() ); |
2664 HBufC8* type8 = HBufC8::NewLC( aValue.Length() ); |
2692 type8->Des().Copy( aValue ); |
2665 type8->Des().Copy( aValue ); |
2693 |
2666 |
2694 if (iCodDlData) |
2667 if (iCodDlData) |
2695 { |
2668 { |
2696 TInt active = iActiveDownload; |
2669 TInt active = iActiveDownload; |
2697 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
2670 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
2698 mediaData->SetTypeL( type8->Des() ); |
2671 mediaData->SetTypeL( type8->Des() ); |
2699 CleanupStack::PopAndDestroy( type8 ); |
2672 CleanupStack::PopAndDestroy( type8 ); |
2923 // CHttpDownload::SetStringAttributeL |
2896 // CHttpDownload::SetStringAttributeL |
2924 // ?implementation_description |
2897 // ?implementation_description |
2925 // (other items were commented in a header). |
2898 // (other items were commented in a header). |
2926 // ----------------------------------------------------------------------------- |
2899 // ----------------------------------------------------------------------------- |
2927 // |
2900 // |
2928 EXPORT_C void CHttpDownload::SetStringAttributeL( THttpDownloadAttrib aAttribute, |
2901 EXPORT_C void CHttpDownload::SetStringAttributeL( THttpDownloadAttrib aAttribute, |
2929 const TDesC8& aValue ) |
2902 const TDesC8& aValue ) |
2930 { |
2903 { |
2931 LOGGER_ENTERFN( "SetStringAttributeL(8)" ); |
2904 LOGGER_ENTERFN( "SetStringAttributeL(8)" ); |
2932 CLOG_WRITE_2( "Attr(%d - %d)", aAttribute, aValue.Length () ); |
2905 CLOG_WRITE_2( "Attr(%d - %d)", aAttribute, aValue.Length () ); |
2933 TBool store( ETrue ); |
2906 TBool store( ETrue ); |
3059 case EDlAttrHashedMsgBody: |
3032 case EDlAttrHashedMsgBody: |
3060 { |
3033 { |
3061 ReallocateStringL( iHashedMsgBody, aValue, KHashLength ); |
3034 ReallocateStringL( iHashedMsgBody, aValue, KHashLength ); |
3062 } |
3035 } |
3063 break; |
3036 break; |
3064 |
3037 |
3065 case EDlAttrRedirectedPermanently: |
3038 case EDlAttrRedirectedPermanently: |
3066 { |
3039 { |
3067 RedirectedPermanentlyL( aValue ); |
3040 RedirectedPermanentlyL( aValue ); |
3068 |
3041 |
3069 if (iCodDlData) |
3042 if (iCodDlData) |
3070 { |
3043 { |
3071 // Update for Active media object. |
3044 // Update for Active media object. |
3072 TInt active = iActiveDownload; |
3045 TInt active = iActiveDownload; |
3073 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
3046 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
3074 if (!mediaData->Redirected()) |
3047 if (!mediaData->Redirected()) |
3075 mediaData->SetRedirUrlL( aValue ); |
3048 mediaData->SetRedirUrlL( aValue ); |
3076 } |
3049 } |
3077 } |
3050 } |
3078 break; |
3051 break; |
3079 |
3052 |
3080 case EDlAttrRedirectedTemporary: |
3053 case EDlAttrRedirectedTemporary: |
3081 { |
3054 { |
3082 RedirectedTemporaryL( aValue ); |
3055 RedirectedTemporaryL( aValue ); |
3083 |
3056 |
3084 if (iCodDlData) |
3057 if (iCodDlData) |
3085 { |
3058 { |
3086 // Update for Active media object. |
3059 // Update for Active media object. |
3087 TInt active = iActiveDownload; |
3060 TInt active = iActiveDownload; |
3088 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
3061 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
3089 mediaData->SetRedirected( ETrue ); |
3062 mediaData->SetRedirected( ETrue ); |
3090 } |
3063 } |
3091 } |
3064 } |
3092 break; |
3065 break; |
3093 |
3066 |
3094 case EDlAttrContinueBody: |
3067 case EDlAttrContinueBody: |
3095 { |
3068 { |
3096 iNoRealError = EFalse; |
3069 iNoRealError = EFalse; |
3097 ResponseBodyReceivedL( aValue ); |
3070 ResponseBodyReceivedL( aValue ); |
3098 store = EFalse; |
3071 store = EFalse; |
3171 iStorage->SetDownloadedSize( (*iCodDlData)[i]->DownloadedSize() ); |
3144 iStorage->SetDownloadedSize( (*iCodDlData)[i]->DownloadedSize() ); |
3172 iStorage->SetLength( (*iCodDlData)[i]->Size() ); |
3145 iStorage->SetLength( (*iCodDlData)[i]->Size() ); |
3173 activeDownloadChanged = ETrue; |
3146 activeDownloadChanged = ETrue; |
3174 } |
3147 } |
3175 } |
3148 } |
3176 iStorage->SetMoDownloadedSize( downloadedSize ); |
3149 iStorage->SetMoDownloadedSize( downloadedSize ); |
3177 } |
3150 } |
3178 // ----------------------------------------------------------------------------- |
3151 // ----------------------------------------------------------------------------- |
3179 // CHttpDownload::SetTrackDataAttributeL |
3152 // CHttpDownload::SetTrackDataAttributeL |
3180 // ?implementation_description |
3153 // ?implementation_description |
3181 // (other items were commented in a header). |
3154 // (other items were commented in a header). |
3182 // ----------------------------------------------------------------------------- |
3155 // ----------------------------------------------------------------------------- |
3183 // |
3156 // |
3184 EXPORT_C void CHttpDownload::SetTrackDataAttributeL( TInt aIndex, HBufC8* dlData ) |
3157 EXPORT_C void CHttpDownload::SetTrackDataAttributeL( TInt aIndex, HBufC8* dlData ) |
3185 { |
3158 { |
3186 LOGGER_ENTERFN( "SetTrackDataAttributeL" ); |
3159 LOGGER_ENTERFN( "SetTrackDataAttributeL" ); |
3187 |
3160 |
3188 if (iCodDlData) |
3161 if (iCodDlData) |
3189 { |
3162 { |
3190 CMediaDataServ* updatedMediaData = CMediaDataServ::NewL(*dlData); |
3163 CMediaDataServ* updatedMediaData = CMediaDataServ::NewL(*dlData); |
3191 CMediaDataBase* mediaData = (*iCodDlData)[aIndex]; |
3164 CMediaDataBase* mediaData = (*iCodDlData)[aIndex]; |
3192 mediaData->SetNameL(updatedMediaData->Name()); |
3165 mediaData->SetNameL(updatedMediaData->Name()); |
3198 mediaData->SetState( updatedMediaData->State() ); |
3171 mediaData->SetState( updatedMediaData->State() ); |
3199 mediaData->SetResult( updatedMediaData->Result() ); |
3172 mediaData->SetResult( updatedMediaData->Result() ); |
3200 mediaData->SetDownloadedSize( updatedMediaData->DownloadedSize() ); |
3173 mediaData->SetDownloadedSize( updatedMediaData->DownloadedSize() ); |
3201 mediaData->SetDestFilenameL( updatedMediaData->DestFilename() ); |
3174 mediaData->SetDestFilenameL( updatedMediaData->DestFilename() ); |
3202 mediaData->SetTempFilenameL( updatedMediaData->DestFilename() ); |
3175 mediaData->SetTempFilenameL( updatedMediaData->DestFilename() ); |
3203 |
3176 |
3204 mediaData->ResetTypes(); |
3177 mediaData->ResetTypes(); |
3205 for (TInt type = 0; type < updatedMediaData->TypesCount(); ++type) |
3178 for (TInt type = 0; type < updatedMediaData->TypesCount(); ++type) |
3206 mediaData->AddTypeL( updatedMediaData->Types().MdcaPoint(type) ); |
3179 mediaData->AddTypeL( updatedMediaData->Types().MdcaPoint(type) ); |
3207 mediaData->SetStatusCode( updatedMediaData->StatusCode() ); |
3180 mediaData->SetStatusCode( updatedMediaData->StatusCode() ); |
3208 TInt result = updatedMediaData->Result(); |
3181 TInt result = updatedMediaData->Result(); |
3271 { |
3244 { |
3272 CLOG_WRITE( "No real error" ); |
3245 CLOG_WRITE( "No real error" ); |
3273 iNoRealError = EFalse; |
3246 iNoRealError = EFalse; |
3274 |
3247 |
3275 return; |
3248 return; |
3276 } |
3249 } |
3277 |
3250 |
3278 if( iCodDlData && iCodDlData->Count() > 1 ) |
3251 if( iCodDlData && iCodDlData->Count() > 1 ) |
3279 { |
3252 { |
3280 if( aDlError == KErrMultipeObjectDownloadFailed ) |
3253 if( aDlError == KErrMultipeObjectDownloadFailed ) |
3281 { |
3254 { |
3282 //Permanently failed error in CodHandler |
3255 //Permanently failed error in CodHandler |
3283 //Delete the download |
3256 //Delete the download |
3284 SetDownloadStatus( EHttpProgNone, |
3257 SetDownloadStatus( EHttpProgNone, |
3285 EHttpDlMultipleMOFailed, |
3258 EHttpDlMultipleMOFailed, |
3286 aDlError, |
3259 aDlError, |
3287 aError ); |
3260 aError ); |
3288 return; |
3261 return; |
3289 } |
3262 } |
3290 else |
3263 else |
3291 { |
3264 { |
3292 SetDownloadStatus( EHttpProgNone, |
3265 SetDownloadStatus( EHttpProgNone, |
3293 EHttpDlPaused, |
3266 EHttpDlPaused, |
3294 aDlError, |
3267 aDlError, |
3295 aError ); |
3268 aError ); |
3296 return; |
3269 return; |
3297 |
3270 |
3298 } |
3271 } |
3299 } |
3272 } |
3300 |
3273 |
3301 if( iDlState < EHttpDlCreated ) |
3274 if( iDlState < EHttpDlCreated ) |
3302 // error occured during download object construction -> nothing to do here |
3275 // error occured during download object construction -> nothing to do here |
3344 } |
3317 } |
3345 } |
3318 } |
3346 |
3319 |
3347 if( aError == KErrHttpPartialResponseReceived ) |
3320 if( aError == KErrHttpPartialResponseReceived ) |
3348 { |
3321 { |
3349 //Partial response has been received and connection has been disconnected. This error will be |
3322 //Partial response has been received and connection has been disconnected. This error will be |
3350 //propagated to the client only, if the HTTP:ENotifyOnDisconnect property is set with a value |
3323 //propagated to the client only, if the HTTP:ENotifyOnDisconnect property is set with a value |
3351 //HTTP::EEnableDisconnectNotification |
3324 //HTTP::EEnableDisconnectNotification |
3352 |
3325 |
3353 //This error code was cancelling the pausable download. This error shud be ignored to keep the |
3326 //This error code was cancelling the pausable download. This error shud be ignored to keep the |
3354 //paused download. |
3327 //paused download. |
3355 //TSW Err ID : SXUU-77SRWL |
3328 //TSW Err ID : SXUU-77SRWL |
3356 |
3329 |
3357 SetDownloadStatus( EHttpProgNone, |
3330 SetDownloadStatus( EHttpProgNone, |
3358 EHttpDlPaused, |
3331 EHttpDlPaused, |
3359 aDlError, |
3332 aDlError, |
3360 aError ); |
3333 aError ); |
3361 |
3334 |
3362 } |
3335 } |
3363 else if( aDlError == EConnectionFailed && iPausable) |
3336 else if( aDlError == EConnectionFailed && iPausable) |
3364 { |
3337 { |
3365 //Whenever connection error occurs and download can be paused. |
3338 //Whenever connection error occurs and download can be paused. |
3366 //Keep the download in paused state. |
3339 //Keep the download in paused state. |
3367 SetDownloadStatus( EHttpProgNone, |
3340 SetDownloadStatus( EHttpProgNone, |
3368 EHttpDlPaused, |
3341 EHttpDlPaused, |
3369 aDlError, |
3342 aDlError, |
3370 aError ); |
3343 aError ); |
3371 } |
3344 } |
3372 else if ( aDlError == EMMCRemoved ) |
3345 else if ( aDlError == EMMCRemoved ) |
3373 { |
3346 { |
3374 // MMC removed. Pause the download. |
3347 // MMC removed. Pause the download. |
3375 SetDownloadStatus( EHttpProgNone, |
3348 SetDownloadStatus( EHttpProgNone, |
3558 } |
3531 } |
3559 |
3532 |
3560 iNoMedia = EFalse; |
3533 iNoMedia = EFalse; |
3561 TriggerEvent( EHttpDlMediaInserted ); |
3534 TriggerEvent( EHttpDlMediaInserted ); |
3562 } |
3535 } |
3563 |
3536 |
3564 // ----------------------------------------------------------------------------- |
3537 // ----------------------------------------------------------------------------- |
3565 // CHttpDownload::GetDestinationDriveID |
3538 // CHttpDownload::GetDestinationDriveID |
3566 // ?implementation_description |
3539 // ?implementation_description |
3567 // (other items were commented in a header). |
3540 // (other items were commented in a header). |
3568 // ----------------------------------------------------------------------------- |
3541 // ----------------------------------------------------------------------------- |
3569 // |
3542 // |
3570 TInt CHttpDownload::GetDestinationDriveID() const |
3543 TInt CHttpDownload::GetDestinationDriveID() const |
3571 { |
3544 { |
3572 return (TInt)iStorage->GetDestinationDriveId(); |
3545 return (TInt)iStorage->GetDestinationDriveId(); |
3573 } |
3546 } |
3574 |
3547 |
3575 // ----------------------------------------------------------------------------- |
3548 // ----------------------------------------------------------------------------- |
3576 // CHttpDownload::SetClientInstance |
3549 // CHttpDownload::SetClientInstance |
3577 // ?implementation_description |
3550 // ?implementation_description |
3578 // (other items were commented in a header). |
3551 // (other items were commented in a header). |
3579 // ----------------------------------------------------------------------------- |
3552 // ----------------------------------------------------------------------------- |
3632 // ----------------------------------------------------------------------------- |
3605 // ----------------------------------------------------------------------------- |
3633 // |
3606 // |
3634 void CHttpDownload::SetDownloadNameL( const TDesC& aNewName ) |
3607 void CHttpDownload::SetDownloadNameL( const TDesC& aNewName ) |
3635 { |
3608 { |
3636 CLOG_WRITE_1( "New download name: [%S]", &aNewName ); |
3609 CLOG_WRITE_1( "New download name: [%S]", &aNewName ); |
3637 |
3610 |
3638 ReallocateStringL( iDlName, aNewName, KDownloadNameMaxSize ); |
3611 ReallocateStringL( iDlName, aNewName, KDownloadNameMaxSize ); |
3639 |
3612 |
3640 FixDownloadNameL(); |
3613 FixDownloadNameL(); |
3641 |
3614 |
3642 TriggerEvent( EHttpDlInprogress, EHttpProgDlNameChanged ); |
3615 TriggerEvent( EHttpDlInprogress, EHttpProgDlNameChanged ); |
3643 } |
3616 } |
3644 |
3617 |
3645 // ----------------------------------------------------------------------------- |
3618 // ----------------------------------------------------------------------------- |
3646 // CHttpDownload::MHFRunL |
3619 // CHttpDownload::MHFRunL |
3647 // ?implementation_description |
3620 // ?implementation_description |
3648 // (other items were commented in a header). |
3621 // (other items were commented in a header). |
3649 // ----------------------------------------------------------------------------- |
3622 // ----------------------------------------------------------------------------- |
3650 // |
3623 // |
3651 void CHttpDownload::MHFRunL( RHTTPTransaction /*aTransaction*/, |
3624 void CHttpDownload::MHFRunL( RHTTPTransaction /*aTransaction*/, |
3652 const THTTPEvent& aEvent ) |
3625 const THTTPEvent& aEvent ) |
3653 { |
3626 { |
3654 switch ( aEvent.iStatus ) |
3627 switch ( aEvent.iStatus ) |
3655 { |
3628 { |
3656 case THTTPEvent::EGotResponseHeaders: |
3629 case THTTPEvent::EGotResponseHeaders: |
3657 { |
3630 { |
3658 CLOG_WRITE( "Response header received" ); |
3631 CLOG_WRITE( "Response header received" ); |
3659 ResponseHeaderReceivedL(); |
3632 ResponseHeaderReceivedL(); |
3660 } |
3633 } |
3661 break; |
3634 break; |
3662 |
3635 |
3663 case THTTPEvent::EGotResponseBodyData: |
3636 case THTTPEvent::EGotResponseBodyData: |
3664 { |
3637 { |
3665 MHTTPDataSupplier* respBody = iTrans.Response().Body(); |
3638 MHTTPDataSupplier* respBody = iTrans.Response().Body(); |
3697 { |
3670 { |
3698 iTrans.Close(); |
3671 iTrans.Close(); |
3699 iTransValid = EFalse; |
3672 iTransValid = EFalse; |
3700 } |
3673 } |
3701 iDlStartedByClient = EFalse; |
3674 iDlStartedByClient = EFalse; |
3702 } |
3675 } |
3703 break; |
3676 break; |
3704 |
3677 |
3705 case THTTPEvent::ERedirectedPermanently: |
3678 case THTTPEvent::ERedirectedPermanently: |
3706 { |
3679 { |
3707 RedirectedPermanentlyL( iTrans.Request().URI().UriDes() ); |
3680 RedirectedPermanentlyL( iTrans.Request().URI().UriDes() ); |
3708 } |
3681 } |
3709 break; |
3682 break; |
3710 |
3683 |
3711 case THTTPEvent::ERedirectedTemporarily: |
3684 case THTTPEvent::ERedirectedTemporarily: |
3712 { |
3685 { |
3713 RedirectedTemporaryL( iTrans.Request().URI().UriDes() ); |
3686 RedirectedTemporaryL( iTrans.Request().URI().UriDes() ); |
3714 } |
3687 } |
3715 break; |
3688 break; |
3716 |
3689 |
3717 default: |
3690 default: |
3718 { |
3691 { |
3719 CLOG_WRITE_1( "Event: %d", aEvent.iStatus ); |
3692 CLOG_WRITE_1( "Event: %d", aEvent.iStatus ); |
3720 if( aEvent.iStatus < 0 ) |
3693 if( aEvent.iStatus < 0 ) |
3721 // error occured -> leave will be handled in OnError() |
3694 // error occured -> leave will be handled in OnError() |
3722 { |
3695 { |
3723 User::Leave( aEvent.iStatus ); |
3696 User::Leave( aEvent.iStatus ); |
3724 } |
3697 } |
3725 } |
3698 } |
3726 break; |
3699 break; |
3727 } |
3700 } |
3728 } |
3701 } |
3729 |
3702 |
3730 // ----------------------------------------------------------------------------- |
3703 // ----------------------------------------------------------------------------- |
3731 // CHttpDownload::MHFRunError |
3704 // CHttpDownload::MHFRunError |
3732 // ?implementation_description |
3705 // ?implementation_description |
3733 // (other items were commented in a header). |
3706 // (other items were commented in a header). |
3734 // ----------------------------------------------------------------------------- |
3707 // ----------------------------------------------------------------------------- |
3735 // |
3708 // |
3736 TInt CHttpDownload::MHFRunError( TInt aError, |
3709 TInt CHttpDownload::MHFRunError( TInt aError, |
3737 RHTTPTransaction /*aTransaction*/, |
3710 RHTTPTransaction /*aTransaction*/, |
3738 const THTTPEvent& /*aEvent*/ ) |
3711 const THTTPEvent& /*aEvent*/ ) |
3739 { |
3712 { |
3740 CLOG_WRITE_1( "MHFRunError: %d", aError ); |
3713 CLOG_WRITE_1( "MHFRunError: %d", aError ); |
3741 |
3714 |
3742 OnError( aError, ETransactionFailed ); |
3715 OnError( aError, ETransactionFailed ); |
3796 TriggerEvent( EHttpDlInprogress, EHttpProgCodDownloadShouldResume ); |
3769 TriggerEvent( EHttpDlInprogress, EHttpProgCodDownloadShouldResume ); |
3797 } |
3770 } |
3798 else |
3771 else |
3799 { |
3772 { |
3800 RequestContentL(); |
3773 RequestContentL(); |
3801 } |
3774 } |
3802 } |
3775 } |
3803 |
3776 |
3804 } |
3777 } |
3805 break; |
3778 break; |
3806 |
3779 |
3807 case EHttpProgMovingContentFile: |
3780 case EHttpProgMovingContentFile: |
3808 // Move completed |
3781 // Move completed |
3809 // State remains in completed |
3782 // State remains in completed |
3810 // and move result stored in error attribs |
3783 // and move result stored in error attribs |
3811 { |
3784 { |
3812 CLOG_WRITE_1( "Move result: %d", iStatus.Int() ); |
3785 CLOG_WRITE_1( "Move result: %d", iStatus.Int() ); |
3813 // In case of PDL for OMA2 the MP/VP moves the file after the playback is done. |
3786 // In case of PDL for OMA2 the MP/VP moves the file after the playback is done. |
3814 // So, the download status should be changed after that |
3787 // So, the download status should be changed after that |
3815 //but we again send the progress state as EHttpProgContentFileMoved because we need to display |
3788 //but we again send the progress state as EHttpProgContentFileMoved because we need to display |
3816 //where file is saved(saved to gallery) |
3789 //where file is saved(saved to gallery) |
3817 //Change Dl State to Download Completed if not already |
3790 //Change Dl State to Download Completed if not already |
3818 |
3791 |
3819 if(_OMADLOTA2_MULTI_DOWNLOAD) |
3792 if(_OMADLOTA2_MULTI_DOWNLOAD) |
3820 { |
3793 { |
3821 TPtrC fileNamePtr = ((*iCodDlData)[iMOMoved])->DestFilename(); |
3794 TPtrC fileNamePtr = ((*iCodDlData)[iMOMoved])->DestFilename(); |
3822 NotifyMediaGalleryL(fileNamePtr); |
3795 NotifyMediaGalleryL(fileNamePtr); |
3828 MoveDownloadedMediaObjectL(iMOMoved); |
3801 MoveDownloadedMediaObjectL(iMOMoved); |
3829 break; |
3802 break; |
3830 } |
3803 } |
3831 } |
3804 } |
3832 |
3805 |
3833 SetDownloadStatus( iDlNameChanged ? EHttpProgContentFileMovedAndDestFNChanged : EHttpProgContentFileMoved, |
3806 SetDownloadStatus( iDlNameChanged ? EHttpProgContentFileMovedAndDestFNChanged : EHttpProgContentFileMoved, |
3834 iDlState = EHttpDlMultipleMOCompleted, |
3807 iDlState = EHttpDlMultipleMOCompleted, |
3835 iStatus == KErrNone ? ENoError : EMoveFailed, |
3808 iStatus == KErrNone ? ENoError : EMoveFailed, |
3836 iStatus.Int() ); |
3809 iStatus.Int() ); |
3837 |
3810 |
3838 if(iStatus == KErrNone) |
3811 if(iStatus == KErrNone) |
3839 { |
3812 { |
3840 iMoveInProgress = EFalse; |
3813 iMoveInProgress = EFalse; |
3841 CLOG_WRITE("setting iMoveInProgress false when move is completed"); |
3814 CLOG_WRITE("setting iMoveInProgress false when move is completed"); |
3842 } |
3815 } |
3843 |
3816 |
3844 |
3817 |
3845 delete iFileMan; iFileMan = NULL; |
3818 delete iFileMan; iFileMan = NULL; |
3846 |
3819 |
3847 if( !_OMADLOTA2_MULTI_DOWNLOAD) |
3820 if( !_OMADLOTA2_MULTI_DOWNLOAD) |
3848 { |
3821 { |
3849 TPtr fileNamePtr(iStorage->DestFilename()->Des()); |
3822 TPtr fileNamePtr(iStorage->DestFilename()->Des()); |
3850 NotifyMediaGalleryL(fileNamePtr); |
3823 NotifyMediaGalleryL(fileNamePtr); |
3851 } |
3824 } |
4047 APPEND_BUF_INT( newInfoPtr, iExpires ); |
4020 APPEND_BUF_INT( newInfoPtr, iExpires ); |
4048 APPEND_BUF_INT( newInfoPtr, iMaxAge ); |
4021 APPEND_BUF_INT( newInfoPtr, iMaxAge ); |
4049 |
4022 |
4050 CLOG_WRITE("5"); |
4023 CLOG_WRITE("5"); |
4051 |
4024 |
4052 |
4025 |
4053 TInt size = GetHttpHeadersSize(iResponseHeaders)+ GetHttpHeadersSize(iRequestHeaders)+ |
4026 TInt size = GetHttpHeadersSize(iResponseHeaders)+ GetHttpHeadersSize(iRequestHeaders)+ |
4054 GetHttpHeadersSize(iEntityHeaders)+ GetHttpHeadersSize(iGeneralHeaders) + newInfoPtr.Size(); |
4027 GetHttpHeadersSize(iEntityHeaders)+ GetHttpHeadersSize(iGeneralHeaders) + newInfoPtr.Size(); |
4055 |
4028 |
4056 |
4029 |
4057 if(size >= bufSz) |
4030 if(size >= bufSz) |
4058 { |
4031 { |
4059 User::LeaveIfError( KErrArgument ); |
4032 User::LeaveIfError( KErrArgument ); |
4060 } |
4033 } |
4061 |
4034 |
4062 AppendHeadersL( newInfoPtr, iResponseHeaders ); |
4035 AppendHeadersL( newInfoPtr, iResponseHeaders ); |
4063 AppendHeadersL( newInfoPtr, iRequestHeaders ); |
4036 AppendHeadersL( newInfoPtr, iRequestHeaders ); |
4064 AppendHeadersL( newInfoPtr, iEntityHeaders ); |
4037 AppendHeadersL( newInfoPtr, iEntityHeaders ); |
4065 AppendHeadersL( newInfoPtr, iGeneralHeaders ); |
4038 AppendHeadersL( newInfoPtr, iGeneralHeaders ); |
4066 |
4039 |
4067 CLOG_WRITE("6"); |
4040 CLOG_WRITE("6"); |
4068 |
4041 |
4069 APPEND_BUF_INT( newInfoPtr, iFotaPckgId ); |
4042 APPEND_BUF_INT( newInfoPtr, iFotaPckgId ); |
4070 |
4043 |
4071 CLOG_WRITE("7"); |
4044 CLOG_WRITE("7"); |
4072 |
4045 |
4073 // check if download info is unchanged from previous update |
4046 // check if download info is unchanged from previous update |
4074 if( iDownloadInfo && ( iDownloadInfo->Compare(*newInfo) == 0 )) |
4047 if( iDownloadInfo && ( iDownloadInfo->Compare(*newInfo) == 0 )) |
4075 { |
4048 { |
4076 // no change |
4049 // no change |
4077 CLOG_WRITE("DownloadInfo unchanged - no need to update"); |
4050 CLOG_WRITE("DownloadInfo unchanged - no need to update"); |
4089 HBufC* fileNameBuf = HBufC::NewLC( KMaxPath ); |
4062 HBufC* fileNameBuf = HBufC::NewLC( KMaxPath ); |
4090 TPtr fileName = fileNameBuf->Des(); |
4063 TPtr fileName = fileNameBuf->Des(); |
4091 iClientApp->Engine()->DownloadInfoFolder( iClientApp, folder ); |
4064 iClientApp->Engine()->DownloadInfoFolder( iClientApp, folder ); |
4092 fileName.Format( _L("%S%d"), &folder, iId ); |
4065 fileName.Format( _L("%S%d"), &folder, iId ); |
4093 CLOG_WRITE_1( "info: %S", &fileName ); |
4066 CLOG_WRITE_1( "info: %S", &fileName ); |
4094 |
4067 |
4095 RFile outFile; |
4068 RFile outFile; |
4096 CleanupClosePushL<RFile>( outFile ); |
4069 CleanupClosePushL<RFile>( outFile ); |
4097 User::LeaveIfError( outFile.Replace( iClientApp->Engine()->Fs(), |
4070 User::LeaveIfError( outFile.Replace( iClientApp->Engine()->Fs(), |
4098 fileName, |
4071 fileName, |
4099 EFileShareExclusive | |
4072 EFileShareExclusive | |
4100 EFileStream | |
4073 EFileStream | |
4101 EFileWrite ) ); |
4074 EFileWrite ) ); |
4102 |
4075 |
4103 outFile.Write( newInfoPtr ); |
4076 outFile.Write( newInfoPtr ); |
4104 User::LeaveIfError( outFile.Flush() ); |
4077 User::LeaveIfError( outFile.Flush() ); |
4105 CleanupStack::PopAndDestroy( 2, fileNameBuf ); |
4078 CleanupStack::PopAndDestroy( 2, fileNameBuf ); |
4198 |
4171 |
4199 LoadHeadersL( inFile, iResponseHeaders ); |
4172 LoadHeadersL( inFile, iResponseHeaders ); |
4200 LoadHeadersL( inFile, iRequestHeaders ); |
4173 LoadHeadersL( inFile, iRequestHeaders ); |
4201 LoadHeadersL( inFile, iEntityHeaders ); |
4174 LoadHeadersL( inFile, iEntityHeaders ); |
4202 LoadHeadersL( inFile, iGeneralHeaders ); |
4175 LoadHeadersL( inFile, iGeneralHeaders ); |
4203 |
4176 |
4204 CLOG_WRITE("6"); |
4177 CLOG_WRITE("6"); |
4205 |
4178 |
4206 READ_INT_L( inFile, iFotaPckgId ); |
4179 READ_INT_L( inFile, iFotaPckgId ); |
4207 |
4180 |
4208 CleanupStack::PopAndDestroy(); // inFile |
4181 CleanupStack::PopAndDestroy(); // inFile |
4209 CleanupStack::PopAndDestroy( 2, folderBuf ); // also fileNameBuf |
4182 CleanupStack::PopAndDestroy( 2, folderBuf ); // also fileNameBuf |
4210 |
4183 |
4211 CLOG_WRITE("9"); |
4184 CLOG_WRITE("9"); |
4212 |
4185 |
4213 UpdatePausable(); |
4186 UpdatePausable(); |
4214 } |
4187 } |
4215 |
4188 |
4216 // ----------------------------------------------------------------------------- |
4189 // ----------------------------------------------------------------------------- |
4217 // CHttpDownload::IsExpired |
4190 // CHttpDownload::IsExpired |
4310 namePtr.Copy( fileName->Right(fileName->Length()-lastSlashPos-1) ); |
4283 namePtr.Copy( fileName->Right(fileName->Length()-lastSlashPos-1) ); |
4311 |
4284 |
4312 TInt findDot = iDlName->LocateReverse( '.' ); |
4285 TInt findDot = iDlName->LocateReverse( '.' ); |
4313 if( findDot == KErrNotFound ) |
4286 if( findDot == KErrNotFound ) |
4314 { |
4287 { |
4315 //if Name displayed does not have Extension then |
4288 //if Name displayed does not have Extension then |
4316 // Remove extention from retrieved name |
4289 // Remove extention from retrieved name |
4317 TInt dotInd = namePtr.LocateReverse( '.' ); |
4290 TInt dotInd = namePtr.LocateReverse( '.' ); |
4318 if( dotInd == KErrNotFound ) |
4291 if( dotInd == KErrNotFound ) |
4319 dotInd = namePtr.Length(); |
4292 dotInd = namePtr.Length(); |
4320 namePtr.Copy( namePtr.Left( dotInd ) ); |
4293 namePtr.Copy( namePtr.Left( dotInd ) ); |
4321 |
4294 |
4322 } |
4295 } |
4323 |
4296 |
4324 //we never get file moved and Download complete for Cod download becuase move is inherent |
4297 //we never get file moved and Download complete for Cod download becuase move is inherent |
4325 //to Install() state i.e Download is in progress so display in download list is incorrect. |
4298 //to Install() state i.e Download is in progress so display in download list is incorrect. |
4326 //related to bug HCHA-753D6G |
4299 //related to bug HCHA-753D6G |
4327 |
4300 |
4328 if(namePtr.Compare(*iDlName)) |
4301 if(namePtr.Compare(*iDlName)) |
4329 { |
4302 { |
4330 ReallocateStringL( iDlName, namePtr, KDownloadNameMaxSize ); |
4303 ReallocateStringL( iDlName, namePtr, KDownloadNameMaxSize ); |
4331 SetDownloadStatus( EHttpProgContentFileMovedAndDestFNChanged, EHttpDlMultipleMOCompleted ); |
4304 SetDownloadStatus( EHttpProgContentFileMovedAndDestFNChanged, EHttpDlMultipleMOCompleted ); |
4332 } |
4305 } |
4333 else |
4306 else |
4334 { |
4307 { |
4335 SetDownloadStatus( EHttpProgContentFileMoved, EHttpDlMultipleMOCompleted ); |
4308 SetDownloadStatus( EHttpProgContentFileMoved, EHttpDlMultipleMOCompleted ); |
4336 } |
4309 } |
4337 CleanupStack::PopAndDestroy( name ); |
4310 CleanupStack::PopAndDestroy( name ); |
4338 |
4311 |
4339 } |
4312 } |
4340 else |
4313 else |
4341 { |
4314 { |
4342 TriggerEvent( EHttpDlCompleted, EHttpProgNone ); |
4315 TriggerEvent( EHttpDlCompleted, EHttpProgNone ); |
4343 SetDownloadStatus( EHttpProgNone, EHttpDlMultipleMOCompleted ); |
4316 SetDownloadStatus( EHttpProgNone, EHttpDlMultipleMOCompleted ); |
4344 } |
4317 } |
4345 } |
4318 } |
4737 // ?implementation_description |
4710 // ?implementation_description |
4738 // (other items were commented in a header). |
4711 // (other items were commented in a header). |
4739 // ----------------------------------------------------------------------------- |
4712 // ----------------------------------------------------------------------------- |
4740 // |
4713 // |
4741 void CHttpDownload::ResponseBodyReceivedL( const TDesC8& aBuf ) |
4714 void CHttpDownload::ResponseBodyReceivedL( const TDesC8& aBuf ) |
4742 { |
4715 { |
4743 if( iMultiPart && !iCodDownload ) |
4716 if( iMultiPart && !iCodDownload ) |
4744 { |
4717 { |
4745 TBool isSupportedMultiPart( EFalse ); |
4718 TBool isSupportedMultiPart( EFalse ); |
4746 // If it leaves isSupportedMultiPart remains false -> does not supported! |
4719 // If it leaves isSupportedMultiPart remains false -> does not supported! |
4747 TRAP_IGNORE( isSupportedMultiPart = IsMultipartSupportedL( aBuf ) ); |
4720 TRAP_IGNORE( isSupportedMultiPart = IsMultipartSupportedL( aBuf ) ); |
4748 if( isSupportedMultiPart ) |
4721 if( isSupportedMultiPart ) |
4749 { |
4722 { |
4750 SetCodFlag( ETrue ); |
4723 SetCodFlag( ETrue ); |
4751 TriggerEvent( EHttpDlInprogress, EHttpProgSupportedMultiPart ); |
4724 TriggerEvent( EHttpDlInprogress, EHttpProgSupportedMultiPart ); |
4752 } |
4725 } |
4753 } |
4726 } |
4754 |
4727 |
4755 TBool ret(ETrue); |
4728 TBool ret(ETrue); |
4756 |
4729 |
4757 if( iStorage->BufferingEnabled() ) |
4730 if( iStorage->BufferingEnabled() ) |
4758 { |
4731 { |
4759 // Buffering is enabled, just pass on the data |
4732 // Buffering is enabled, just pass on the data |
4760 ret = iStorage->WriteOutNextBodyDataL(aBuf); |
4733 ret = iStorage->WriteOutNextBodyDataL(aBuf); |
4761 } |
4734 } |
4762 else |
4735 else |
4763 { |
4736 { |
4764 // Buffering not yet enabled, see how much data we still have to write without buffering |
4737 // Buffering not yet enabled, see how much data we still have to write without buffering |
4765 TInt bytesToWrite = aBuf.Length(); |
4738 TInt bytesToWrite = aBuf.Length(); |
4766 TInt downloadedSize = iStorage->DownloadedSize(); |
4739 TInt downloadedSize = iStorage->DownloadedSize(); |
4767 |
4740 |
4768 if(bytesToWrite + downloadedSize < KMinDataSizeToSend) |
4741 if(bytesToWrite + downloadedSize < KMinDataSizeToSend) |
4769 { |
4742 { |
4770 // Just dump non-buffered write |
4743 // Just dump non-buffered write |
4771 ret = iStorage->WriteOutNextBodyDataL( aBuf ); |
4744 ret = iStorage->WriteOutNextBodyDataL( aBuf ); |
4772 } |
4745 } |
4773 else |
4746 else |
4774 { |
4747 { |
4775 // Necessary to switch to buffered writing |
4748 // Necessary to switch to buffered writing |
4776 |
4749 |
4777 TInt leftPartSize = KMinDataSizeToSend - downloadedSize; |
4750 TInt leftPartSize = KMinDataSizeToSend - downloadedSize; |
4778 TInt rightPartSize = bytesToWrite - leftPartSize; |
4751 TInt rightPartSize = bytesToWrite - leftPartSize; |
4779 |
4752 |
4780 TBool ret1 = ETrue; |
4753 TBool ret1 = ETrue; |
4781 TBool ret2 = ETrue; |
4754 TBool ret2 = ETrue; |
4782 |
4755 |
4783 if(leftPartSize > 0) |
4756 if(leftPartSize > 0) |
4784 { |
4757 { |
4785 // Write left side of the block to get alignment matched |
4758 // Write left side of the block to get alignment matched |
4786 ret1 = iStorage->WriteOutNextBodyDataL( aBuf.Left(leftPartSize) ); |
4759 ret1 = iStorage->WriteOutNextBodyDataL( aBuf.Left(leftPartSize) ); |
4787 } |
4760 } |
4788 |
4761 |
4789 // Enable buffering |
4762 // Enable buffering |
4790 iStorage->EnableBufferingL(); |
4763 iStorage->EnableBufferingL(); |
4791 |
4764 |
4792 // And push the rest of this data block |
4765 // And push the rest of this data block |
4793 if(rightPartSize > 0) |
4766 if(rightPartSize > 0) |
4794 { |
4767 { |
4795 ret2 = iStorage->WriteOutNextBodyDataL( aBuf.Right(rightPartSize) ); |
4768 ret2 = iStorage->WriteOutNextBodyDataL( aBuf.Right(rightPartSize) ); |
4796 } |
4769 } |
4797 |
4770 |
4798 if(!ret1 || !ret2) |
4771 if(!ret1 || !ret2) |
4799 { |
4772 { |
4800 ret = EFalse; |
4773 ret = EFalse; |
4801 } |
4774 } |
4802 } |
4775 } |
4838 else |
4811 else |
4839 { |
4812 { |
4840 ret = EFalse; |
4813 ret = EFalse; |
4841 return ret; |
4814 return ret; |
4842 } |
4815 } |
4843 |
4816 |
4844 TInt pos = iHeaderOfMultipart->Des().Find( KContentType() ); |
4817 TInt pos = iHeaderOfMultipart->Des().Find( KContentType() ); |
4845 |
4818 |
4846 User::LeaveIfError( pos ); |
4819 User::LeaveIfError( pos ); |
4847 |
4820 |
4848 pos = pos + KContentType().Length(); |
4821 pos = pos + KContentType().Length(); |
4849 |
4822 |
4850 TPtrC8 p = iHeaderOfMultipart->Des().Mid( pos ); |
4823 TPtrC8 p = iHeaderOfMultipart->Des().Mid( pos ); |
4851 TInt temp = p.Find( KDoubleEOL() ); |
4824 TInt temp = p.Find( KDoubleEOL() ); |
4852 |
4825 |
4853 TInt posEol = pos + temp; |
4826 TInt posEol = pos + temp; |
4854 |
4827 |
4855 TPtrC8 ptr = iHeaderOfMultipart->Des().Mid( pos, ( posEol - pos ) ); |
4828 TPtrC8 ptr = iHeaderOfMultipart->Des().Mid( pos, ( posEol - pos ) ); |
4856 if( 0 == ptr.Find( KDdMimeType() ) || |
4829 if( 0 == ptr.Find( KDdMimeType() ) || |
4857 0 == ptr.Find( KDd2MimeType() ) || |
4830 0 == ptr.Find( KDd2MimeType() ) || |
4858 0 == ptr.Find( KCodMimeType() )) |
4831 0 == ptr.Find( KCodMimeType() )) |
4859 { |
4832 { |
4860 ret = ETrue; |
4833 ret = ETrue; |
4861 delete iHeaderOfMultipart; |
4834 delete iHeaderOfMultipart; |
4862 iHeaderOfMultipart = NULL; |
4835 iHeaderOfMultipart = NULL; |
4863 return ret; |
4836 return ret; |
4864 } |
4837 } |
4865 |
4838 |
4866 return ret; |
4839 return ret; |
4867 } |
4840 } |
4868 |
4841 |
4869 // ----------------------------------------------------------------------------- |
4842 // ----------------------------------------------------------------------------- |
4870 // CHttpDownload::Connect |
4843 // CHttpDownload::Connect |
4871 // ?implementation_description |
4844 // ?implementation_description |
4943 |
4916 |
4944 SetRequestHeaderAddOnL( aStringPool, aHeaders ); |
4917 SetRequestHeaderAddOnL( aStringPool, aHeaders ); |
4945 SetCredentialsInfoL( aStringPool ); |
4918 SetCredentialsInfoL( aStringPool ); |
4946 |
4919 |
4947 // Find ETag in response header |
4920 // Find ETag in response header |
4948 RStringF etag = aStringPool.StringF(HTTP::EETag, |
4921 RStringF etag = aStringPool.StringF(HTTP::EETag, |
4949 RHTTPSession::GetTable()); |
4922 RHTTPSession::GetTable()); |
4950 TInt fieldInd = FindHeaderField( iResponseHeaders, etag.DesC() ); |
4923 TInt fieldInd = FindHeaderField( iResponseHeaders, etag.DesC() ); |
4951 if( fieldInd != KErrNotFound ) |
4924 if( fieldInd != KErrNotFound ) |
4952 // ETag is known. ETag identifies the content. Set If-Match to see |
4925 // ETag is known. ETag identifies the content. Set If-Match to see |
4953 // that if it's changed, or a redirection goes to another url. |
4926 // that if it's changed, or a redirection goes to another url. |
4954 // Server will respond with 412 on error. |
4927 // Server will respond with 412 on error. |
4955 { |
4928 { |
4956 RStringF ifMatch = aStringPool.StringF(HTTP::EIfMatch, |
4929 RStringF ifMatch = aStringPool.StringF(HTTP::EIfMatch, |
4957 RHTTPSession::GetTable()); |
4930 RHTTPSession::GetTable()); |
4958 aHeaders.RemoveField( ifMatch ); |
4931 aHeaders.RemoveField( ifMatch ); |
4959 aHeaders.SetRawFieldL( ifMatch, |
4932 aHeaders.SetRawFieldL( ifMatch, |
4960 *(*iResponseHeaders)[fieldInd]->FieldRawData(), |
4933 *(*iResponseHeaders)[fieldInd]->FieldRawData(), |
4961 KHttpFieldSeparator ); |
4934 KHttpFieldSeparator ); |
4962 CLOG_WRITE8_1( "ETag: %S", (*iResponseHeaders)[fieldInd]->FieldRawData() ); |
4935 CLOG_WRITE8_1( "ETag: %S", (*iResponseHeaders)[fieldInd]->FieldRawData() ); |
4963 } |
4936 } |
4964 |
4937 |
4965 if( aHeadMethod ) |
4938 if( aHeadMethod ) |
5035 // CHttpFilterAuthentication::SetPropertyL |
5008 // CHttpFilterAuthentication::SetPropertyL |
5036 // Set property of the transaction |
5009 // Set property of the transaction |
5037 // ----------------------------------------------------------------------------- |
5010 // ----------------------------------------------------------------------------- |
5038 // |
5011 // |
5039 void CHttpDownload::SetPropertyL( RStringPool& aStringPool, |
5012 void CHttpDownload::SetPropertyL( RStringPool& aStringPool, |
5040 RStringF aPropertyName, |
5013 RStringF aPropertyName, |
5041 const TDesC8& aToken ) |
5014 const TDesC8& aToken ) |
5042 { |
5015 { |
5043 RString tokenStr = aStringPool.OpenStringL( aToken ); |
5016 RString tokenStr = aStringPool.OpenStringL( aToken ); |
5044 THTTPHdrVal tokenVal = tokenStr; |
5017 THTTPHdrVal tokenVal = tokenStr; |
5045 CleanupClosePushL( tokenStr ); |
5018 CleanupClosePushL( tokenStr ); |
5125 { |
5098 { |
5126 LOGGER_ENTERFN( "SetCredentialsInfoL" ); |
5099 LOGGER_ENTERFN( "SetCredentialsInfoL" ); |
5127 |
5100 |
5128 if( iHttpUsername ) |
5101 if( iHttpUsername ) |
5129 { |
5102 { |
5130 RStringF username = aStringPool.StringF( HTTP::EUsername, |
5103 RStringF username = aStringPool.StringF( HTTP::EUsername, |
5131 RHTTPSession::GetTable() ); |
5104 RHTTPSession::GetTable() ); |
5132 |
5105 |
5133 SetPropertyL( aStringPool, username, *iHttpUsername ); |
5106 SetPropertyL( aStringPool, username, *iHttpUsername ); |
5134 } |
5107 } |
5135 |
5108 |
5136 if( iHttpPassword ) |
5109 if( iHttpPassword ) |
5137 { |
5110 { |
5138 RStringF password = aStringPool.StringF( HTTP::EPassword, |
5111 RStringF password = aStringPool.StringF( HTTP::EPassword, |
5139 RHTTPSession::GetTable() ); |
5112 RHTTPSession::GetTable() ); |
5140 |
5113 |
5141 SetPropertyL( aStringPool, password, *iHttpPassword ); |
5114 SetPropertyL( aStringPool, password, *iHttpPassword ); |
5142 } |
5115 } |
5143 |
5116 |
5144 if( iHttpRealm ) |
5117 if( iHttpRealm ) |
5145 { |
5118 { |
5146 RStringF realm = aStringPool.StringF( HTTP::ERealm, |
5119 RStringF realm = aStringPool.StringF( HTTP::ERealm, |
5147 RHTTPSession::GetTable() ); |
5120 RHTTPSession::GetTable() ); |
5148 SetPropertyL( aStringPool, realm, *iHttpRealm ); |
5121 SetPropertyL( aStringPool, realm, *iHttpRealm ); |
5149 } |
5122 } |
5150 |
5123 |
5151 if( iHttpProxyRealm ) |
5124 if( iHttpProxyRealm ) |
5152 { |
5125 { |
5153 RStringF proxyRealmStr = aStringPool.StringF( |
5126 RStringF proxyRealmStr = aStringPool.StringF( |
5154 HttpFilterCommonStringsExt::EProxyRealm, |
5127 HttpFilterCommonStringsExt::EProxyRealm, |
5155 HttpFilterCommonStringsExt::GetTable() ); |
5128 HttpFilterCommonStringsExt::GetTable() ); |
5156 SetPropertyL( aStringPool, proxyRealmStr, *iHttpProxyRealm ); |
5129 SetPropertyL( aStringPool, proxyRealmStr, *iHttpProxyRealm ); |
5157 } |
5130 } |
5158 |
5131 |
5159 if( iHttpProxyUsername ) |
5132 if( iHttpProxyUsername ) |
5160 { |
5133 { |
5161 RStringF proxyUsernameStr = aStringPool.StringF( |
5134 RStringF proxyUsernameStr = aStringPool.StringF( |
5162 HttpFilterCommonStringsExt::EProxyUsername, |
5135 HttpFilterCommonStringsExt::EProxyUsername, |
5163 HttpFilterCommonStringsExt::GetTable() ); |
5136 HttpFilterCommonStringsExt::GetTable() ); |
5164 SetPropertyL( aStringPool, proxyUsernameStr, *iHttpProxyUsername ); |
5137 SetPropertyL( aStringPool, proxyUsernameStr, *iHttpProxyUsername ); |
5165 } |
5138 } |
5166 |
5139 |
5167 if( iHttpProxyPassword ) |
5140 if( iHttpProxyPassword ) |
5168 { |
5141 { |
5169 RStringF proxyPasswordStr = aStringPool.StringF( |
5142 RStringF proxyPasswordStr = aStringPool.StringF( |
5170 HttpFilterCommonStringsExt::EProxyPassword, |
5143 HttpFilterCommonStringsExt::EProxyPassword, |
5171 HttpFilterCommonStringsExt::GetTable() ); |
5144 HttpFilterCommonStringsExt::GetTable() ); |
5172 SetPropertyL( aStringPool, proxyPasswordStr, *iHttpProxyPassword ); |
5145 SetPropertyL( aStringPool, proxyPasswordStr, *iHttpProxyPassword ); |
5173 } |
5146 } |
5174 |
5147 |
5175 if( iHttpNonce ) |
5148 if( iHttpNonce ) |
5176 { |
5149 { |
5177 RStringF nonce = aStringPool.StringF( HTTP::ENonce, |
5150 RStringF nonce = aStringPool.StringF( HTTP::ENonce, |
5178 RHTTPSession::GetTable() ); |
5151 RHTTPSession::GetTable() ); |
5179 |
5152 |
5180 SetPropertyL( aStringPool, nonce, *iHttpNonce ); |
5153 SetPropertyL( aStringPool, nonce, *iHttpNonce ); |
5181 } |
5154 } |
5182 } |
5155 } |
5246 if( expInd != KErrNotFound ) |
5219 if( expInd != KErrNotFound ) |
5247 { |
5220 { |
5248 CLOG_WRITE8_1( "Expire: %S", (*iResponseHeaders)[expInd]->FieldRawData() ); |
5221 CLOG_WRITE8_1( "Expire: %S", (*iResponseHeaders)[expInd]->FieldRawData() ); |
5249 |
5222 |
5250 aHeaders.RemoveField( aField ); |
5223 aHeaders.RemoveField( aField ); |
5251 aHeaders.SetRawFieldL( aField, |
5224 aHeaders.SetRawFieldL( aField, |
5252 *(*iResponseHeaders)[expInd]->FieldRawData(), |
5225 *(*iResponseHeaders)[expInd]->FieldRawData(), |
5253 KHttpFieldSeparator ); |
5226 KHttpFieldSeparator ); |
5254 } |
5227 } |
5255 else if( modInd != KErrNotFound ) |
5228 else if( modInd != KErrNotFound ) |
5256 { |
5229 { |
5257 CLOG_WRITE8_1( "LastMod: %S", (*iResponseHeaders)[modInd]->FieldRawData() ); |
5230 CLOG_WRITE8_1( "LastMod: %S", (*iResponseHeaders)[modInd]->FieldRawData() ); |
5258 |
5231 |
5259 aHeaders.RemoveField( aField ); |
5232 aHeaders.RemoveField( aField ); |
5260 aHeaders.SetRawFieldL( aField, |
5233 aHeaders.SetRawFieldL( aField, |
5261 *(*iResponseHeaders)[modInd]->FieldRawData(), |
5234 *(*iResponseHeaders)[modInd]->FieldRawData(), |
5262 KHttpFieldSeparator ); |
5235 KHttpFieldSeparator ); |
5263 } |
5236 } |
5264 } |
5237 } |
5265 |
5238 |
5266 // ----------------------------------------------------------------------------- |
5239 // ----------------------------------------------------------------------------- |
5273 { |
5246 { |
5274 LOGGER_ENTERFN( "ParseRequestedUrlL" ); |
5247 LOGGER_ENTERFN( "ParseRequestedUrlL" ); |
5275 |
5248 |
5276 __ASSERT_DEBUG( iUrl->Length(), DMPanic( KErrArgument ) ); |
5249 __ASSERT_DEBUG( iUrl->Length(), DMPanic( KErrArgument ) ); |
5277 |
5250 |
5278 TUriParser8 uri; |
5251 TUriParser8 uri; |
5279 uri.Parse( *iUrl ); |
5252 uri.Parse( *iUrl ); |
5280 |
5253 |
5281 TPtrC8 scheme( uri.Extract( EUriScheme ) ); |
5254 TPtrC8 scheme( uri.Extract( EUriScheme ) ); |
5282 |
5255 |
5283 if( scheme != KHttpScheme && |
5256 if( scheme != KHttpScheme && |
5284 scheme != KHttpsScheme ) |
5257 scheme != KHttpsScheme ) |
5285 // unsupported or no scheme in url. |
5258 // unsupported or no scheme in url. |
5286 // Insert 'http://' to the beginning of it. |
5259 // Insert 'http://' to the beginning of it. |
5287 { |
5260 { |
5288 HBufC8* tempBuf = HBufC8::NewL( KHttpScheme().Length() + |
5261 HBufC8* tempBuf = HBufC8::NewL( KHttpScheme().Length() + |
5289 KSchemeAddon().Length() + |
5262 KSchemeAddon().Length() + |
5290 iUrl->Length() ); |
5263 iUrl->Length() ); |
5291 |
5264 |
5292 tempBuf->Des().Append( KHttpScheme ); |
5265 tempBuf->Des().Append( KHttpScheme ); |
5293 tempBuf->Des().Append( KSchemeAddon ); |
5266 tempBuf->Des().Append( KSchemeAddon ); |
5294 tempBuf->Des().Append( *iUrl ); |
5267 tempBuf->Des().Append( *iUrl ); |
5306 url->SetComponentL( uri.Extract( EUriHost ), EUriHost ); |
5279 url->SetComponentL( uri.Extract( EUriHost ), EUriHost ); |
5307 url->SetComponentL( uri.Extract( EUriPath ), EUriPath ); |
5280 url->SetComponentL( uri.Extract( EUriPath ), EUriPath ); |
5308 url->SetComponentL( uri.Extract( EUriUserinfo ), EUriUserinfo ); |
5281 url->SetComponentL( uri.Extract( EUriUserinfo ), EUriUserinfo ); |
5309 url->SetComponentL( uri.Extract( EUriQuery ), EUriQuery ); |
5282 url->SetComponentL( uri.Extract( EUriQuery ), EUriQuery ); |
5310 url->SetComponentL( uri.Extract( EUriFragment ), EUriFragment ); |
5283 url->SetComponentL( uri.Extract( EUriFragment ), EUriFragment ); |
5311 |
5284 |
5312 if( uri.IsPresent( EUriPort ) ) |
5285 if( uri.IsPresent( EUriPort ) ) |
5313 { |
5286 { |
5314 url->SetComponentL( uri.Extract( EUriPort ), EUriPort ); |
5287 url->SetComponentL( uri.Extract( EUriPort ), EUriPort ); |
5315 } |
5288 } |
5316 else |
5289 else |
5440 CHeaderField* field = CHeaderField::NewL( &fieldNameStr.DesC(), &rawData ); |
5413 CHeaderField* field = CHeaderField::NewL( &fieldNameStr.DesC(), &rawData ); |
5441 CleanupStack::PushL( field ); |
5414 CleanupStack::PushL( field ); |
5442 |
5415 |
5443 CLOG_WRITE8_2("%S:%S", &fieldNameStr.DesC(), &rawData); |
5416 CLOG_WRITE8_2("%S:%S", &fieldNameStr.DesC(), &rawData); |
5444 iResponseHeaders->AppendL( field ); |
5417 iResponseHeaders->AppendL( field ); |
5445 |
5418 |
5446 CleanupStack::Pop( field ); |
5419 CleanupStack::Pop( field ); |
5447 |
5420 |
5448 CHeaderField* entityField = CHeaderField::NewL( &fieldNameStr.DesC(), &rawData ); |
5421 CHeaderField* entityField = CHeaderField::NewL( &fieldNameStr.DesC(), &rawData ); |
5449 CleanupStack::PushL( entityField ); |
5422 CleanupStack::PushL( entityField ); |
5450 |
5423 |
5451 CLOG_WRITE8_2("%S:%S", &fieldNameStr.DesC(), &rawData); |
5424 CLOG_WRITE8_2("%S:%S", &fieldNameStr.DesC(), &rawData); |
5452 iEntityHeaders->AppendL( entityField ); |
5425 iEntityHeaders->AppendL( entityField ); |
5453 |
5426 |
5454 CleanupStack::Pop( entityField ); |
5427 CleanupStack::Pop( entityField ); |
5455 |
5428 |
5456 ++it; |
5429 ++it; |
5457 } |
5430 } |
5458 |
5431 |
5459 ParseContentTypeL( strPool ); |
5432 ParseContentTypeL( strPool ); |
5460 |
5433 |
5461 ParseContentDispositionL( strPool); |
5434 ParseContentDispositionL( strPool); |
5462 if (!iCodDownload) |
5435 if (!iCodDownload) |
5463 { |
5436 { |
5464 if (iUseAttachmentFileName || iUseInlineFileName) |
5437 if (iUseAttachmentFileName || iUseInlineFileName) |
5465 { |
5438 { |
5600 // |
5573 // |
5601 void CHttpDownload::SaveCredentialsL( RStringPool aStringPool ) |
5574 void CHttpDownload::SaveCredentialsL( RStringPool aStringPool ) |
5602 { |
5575 { |
5603 LOGGER_ENTERFN( "SaveCredentialsL" ); |
5576 LOGGER_ENTERFN( "SaveCredentialsL" ); |
5604 |
5577 |
5605 RStringF username = aStringPool.StringF( HTTP::EUsername, |
5578 RStringF username = aStringPool.StringF( HTTP::EUsername, |
5606 RHTTPSession::GetTable() ); |
5579 RHTTPSession::GetTable() ); |
5607 RStringF password = aStringPool.StringF( HTTP::EPassword, |
5580 RStringF password = aStringPool.StringF( HTTP::EPassword, |
5608 RHTTPSession::GetTable() ); |
5581 RHTTPSession::GetTable() ); |
5609 RStringF realm = aStringPool.StringF( HTTP::ERealm, |
5582 RStringF realm = aStringPool.StringF( HTTP::ERealm, |
5610 RHTTPSession::GetTable() ); |
5583 RHTTPSession::GetTable() ); |
5611 RStringF nonce = aStringPool.StringF( HTTP::ENonce, |
5584 RStringF nonce = aStringPool.StringF( HTTP::ENonce, |
5612 RHTTPSession::GetTable() ); |
5585 RHTTPSession::GetTable() ); |
5613 |
5586 |
5614 THTTPHdrVal hdrValue; |
5587 THTTPHdrVal hdrValue; |
5615 |
5588 |
5616 // Realm |
5589 // Realm |
5634 { |
5607 { |
5635 ReallocateStringL( iHttpPassword, hdrValue.Str().DesC(), KMaxDefAttrLength ); |
5608 ReallocateStringL( iHttpPassword, hdrValue.Str().DesC(), KMaxDefAttrLength ); |
5636 CLOG_WRITE8_1( "pwd: [%S]", iHttpPassword ); |
5609 CLOG_WRITE8_1( "pwd: [%S]", iHttpPassword ); |
5637 } |
5610 } |
5638 |
5611 |
5639 if( !iTrans.PropertySet().Property( |
5612 if( !iTrans.PropertySet().Property( |
5640 aStringPool.StringF( HTTP::EBasic, |
5613 aStringPool.StringF( HTTP::EBasic, |
5641 RHTTPSession::GetTable() ), |
5614 RHTTPSession::GetTable() ), |
5642 hdrValue ) ) |
5615 hdrValue ) ) |
5643 // this is a digest authentication response |
5616 // this is a digest authentication response |
5644 // store nonce value |
5617 // store nonce value |
5645 { |
5618 { |
5646 if( iTrans.PropertySet().Property( nonce, hdrValue ) ) |
5619 if( iTrans.PropertySet().Property( nonce, hdrValue ) ) |
6360 // CHttpDownload::CheckAttribMaxLengthL |
6333 // CHttpDownload::CheckAttribMaxLengthL |
6361 // ?implementation_description |
6334 // ?implementation_description |
6362 // (other items were commented in a header). |
6335 // (other items were commented in a header). |
6363 // ----------------------------------------------------------------------------- |
6336 // ----------------------------------------------------------------------------- |
6364 // |
6337 // |
6365 void CHttpDownload::CheckAttribMaxLengthL( THttpDownloadAttrib aAttribute, |
6338 void CHttpDownload::CheckAttribMaxLengthL( THttpDownloadAttrib aAttribute, |
6366 const TDesC16& aValue ) |
6339 const TDesC16& aValue ) |
6367 { |
6340 { |
6368 for( TInt i = 0; KStringAttribMaxLengths[i][0]; ++i ) |
6341 for( TInt i = 0; KStringAttribMaxLengths[i][0]; ++i ) |
6369 { |
6342 { |
6370 if( aAttribute == KStringAttribMaxLengths[i][0] ) |
6343 if( aAttribute == KStringAttribMaxLengths[i][0] ) |
6371 { |
6344 { |
6372 if( aValue.Length() > KStringAttribMaxLengths[i][1] ) |
6345 if( aValue.Length() > KStringAttribMaxLengths[i][1] ) |
6373 { |
6346 { |
6374 CLOG_WRITE_2( "Overflow length: %d, max-length: %d", aValue.Length(), |
6347 CLOG_WRITE_2( "Overflow length: %d, max-length: %d", aValue.Length(), |
6375 KStringAttribMaxLengths[i][1] ); |
6348 KStringAttribMaxLengths[i][1] ); |
6376 User::Leave( KErrOverflow ); |
6349 User::Leave( KErrOverflow ); |
6377 } |
6350 } |
6378 } |
6351 } |
6379 } |
6352 } |
6383 // CHttpDownload::CheckAttribMaxLengthL |
6356 // CHttpDownload::CheckAttribMaxLengthL |
6384 // ?implementation_description |
6357 // ?implementation_description |
6385 // (other items were commented in a header). |
6358 // (other items were commented in a header). |
6386 // ----------------------------------------------------------------------------- |
6359 // ----------------------------------------------------------------------------- |
6387 // |
6360 // |
6388 void CHttpDownload::CheckAttribMaxLengthL( THttpDownloadAttrib aAttribute, |
6361 void CHttpDownload::CheckAttribMaxLengthL( THttpDownloadAttrib aAttribute, |
6389 const TDesC8& aValue ) |
6362 const TDesC8& aValue ) |
6390 { |
6363 { |
6391 for( TInt i = 0; KStringAttribMaxLengths[i][0]; ++i ) |
6364 for( TInt i = 0; KStringAttribMaxLengths[i][0]; ++i ) |
6392 { |
6365 { |
6393 if( aAttribute == KStringAttribMaxLengths[i][0] ) |
6366 if( aAttribute == KStringAttribMaxLengths[i][0] ) |
6394 { |
6367 { |
6395 if( aValue.Length() > KStringAttribMaxLengths[i][1] ) |
6368 if( aValue.Length() > KStringAttribMaxLengths[i][1] ) |
6396 { |
6369 { |
6397 CLOG_WRITE_2( "Overflow length: %d, max-length: %d", aValue.Length(), |
6370 CLOG_WRITE_2( "Overflow length: %d, max-length: %d", aValue.Length(), |
6398 KStringAttribMaxLengths[i][1] ); |
6371 KStringAttribMaxLengths[i][1] ); |
6399 User::Leave( KErrOverflow ); |
6372 User::Leave( KErrOverflow ); |
6400 } |
6373 } |
6401 } |
6374 } |
6402 } |
6375 } |
6586 TInt headers = aHeaders->Count(); |
6559 TInt headers = aHeaders->Count(); |
6587 CLOG_WRITE_1("Headers: %d", headers); |
6560 CLOG_WRITE_1("Headers: %d", headers); |
6588 |
6561 |
6589 HBufC8* fieldName = NULL; |
6562 HBufC8* fieldName = NULL; |
6590 HBufC8* fieldRawData = NULL; |
6563 HBufC8* fieldRawData = NULL; |
6591 |
6564 |
6592 TInt size = 0; |
6565 TInt size = 0; |
6593 |
6566 |
6594 for( TInt i = 0; i < headers; ++i ) |
6567 for( TInt i = 0; i < headers; ++i ) |
6595 { |
6568 { |
6596 fieldName = (*aHeaders)[i]->FieldName(); |
6569 fieldName = (*aHeaders)[i]->FieldName(); |
6597 fieldRawData = (*aHeaders)[i]->FieldRawData(); |
6570 fieldRawData = (*aHeaders)[i]->FieldRawData(); |
6598 |
6571 |
6599 size = size + fieldName->Size() + fieldRawData->Size(); |
6572 size = size + fieldName->Size() + fieldRawData->Size(); |
6600 |
6573 |
6601 CLOG_WRITE8_1( "Size = %d:", size ); |
6574 CLOG_WRITE8_1( "Size = %d:", size ); |
6602 } |
6575 } |
6603 |
6576 |
6604 return size; |
6577 return size; |
6605 |
6578 |
6606 } |
6579 } |
6607 |
6580 |
6608 |
6581 |
6609 // ----------------------------------------------------------------------------- |
6582 // ----------------------------------------------------------------------------- |
6610 // CHttpDownload::AddHeaderL |
6583 // CHttpDownload::AddHeaderL |
6611 // ----------------------------------------------------------------------------- |
6584 // ----------------------------------------------------------------------------- |
6612 // |
6585 // |
6613 void CHttpDownload::AddHeaderL( THttpDownloadAttrib aAttribute, |
6586 void CHttpDownload::AddHeaderL( THttpDownloadAttrib aAttribute, |
6614 const TDesC8& aValue, |
6587 const TDesC8& aValue, |
6615 const TInt aConversionTable[][2], |
6588 const TInt aConversionTable[][2], |
6616 CArrayPtrFlat<CHeaderField>* aHeaders ) |
6589 CArrayPtrFlat<CHeaderField>* aHeaders ) |
6617 { |
6590 { |
6618 TInt index( KErrNotFound ); |
6591 TInt index( KErrNotFound ); |
6619 |
6592 |
6620 // search for if this field is already in the |
6593 // search for if this field is already in the |
6621 for( index = 0; aConversionTable[index][0]; ++index ) |
6594 for( index = 0; aConversionTable[index][0]; ++index ) |
6622 { |
6595 { |
6623 if( aConversionTable[index][0] == aAttribute ) |
6596 if( aConversionTable[index][0] == aAttribute ) |
6624 { |
6597 { |
6625 break; |
6598 break; |
6684 ParseDownloadNameL(); |
6657 ParseDownloadNameL(); |
6685 StoreDownloadInfoL(); // to store iRedirect |
6658 StoreDownloadInfoL(); // to store iRedirect |
6686 |
6659 |
6687 TriggerEvent( EHttpDlInprogress, EHttpProgRedirectedTemporarily ); |
6660 TriggerEvent( EHttpDlInprogress, EHttpProgRedirectedTemporarily ); |
6688 } |
6661 } |
6689 |
6662 |
6690 // ----------------------------------------------------------------------------- |
6663 // ----------------------------------------------------------------------------- |
6691 // CHttpDownload::FixDownloadNameL |
6664 // CHttpDownload::FixDownloadNameL |
6692 // ----------------------------------------------------------------------------- |
6665 // ----------------------------------------------------------------------------- |
6693 // |
6666 // |
6694 void CHttpDownload::FixDownloadNameL() |
6667 void CHttpDownload::FixDownloadNameL() |
6695 { |
6668 { |
6696 if( !iCodDownload ) |
6669 if( !iCodDownload ) |
6697 { |
6670 { |
6698 TPtr name( iDlName->Des() ); |
6671 TPtr name( iDlName->Des() ); |
6699 |
6672 |
6700 for( TInt i = 0; i < name.Length(); ++i ) |
6673 for( TInt i = 0; i < name.Length(); ++i ) |
6701 { |
6674 { |
6702 TChar currChar = (*iDlName)[i]; |
6675 TChar currChar = (*iDlName)[i]; |
6703 |
6676 |
6704 if( currChar.IsAlphaDigit() || |
6677 if( currChar.IsAlphaDigit() || |
6705 currChar.IsGraph() || |
6678 currChar.IsGraph() || |
6706 currChar == 0x20 ) // space |
6679 currChar == 0x20 ) // space |
6707 { |
6680 { |
6708 continue; |
6681 continue; |
6709 } |
6682 } |
6710 else |
6683 else |
6711 { |
6684 { |
6712 name[i] = KUrlFixChar; |
6685 name[i] = KUrlFixChar; |
6713 } |
6686 } |
6714 } |
6687 } |
6715 |
6688 |
6716 ConvertDownloadNameUniqueL(); |
6689 ConvertDownloadNameUniqueL(); |
6717 } |
6690 } |
6718 } |
6691 } |
6719 |
6692 |
6720 // ----------------------------------------------------------------------------- |
6693 // ----------------------------------------------------------------------------- |
6837 User::Leave( err ); |
6810 User::Leave( err ); |
6838 } |
6811 } |
6839 } |
6812 } |
6840 CLOG_WRITE_1( " exiting fileName: %S", fileName ); |
6813 CLOG_WRITE_1( " exiting fileName: %S", fileName ); |
6841 #ifdef RD_MULTIPLE_DRIVE |
6814 #ifdef RD_MULTIPLE_DRIVE |
6842 CleanupStack::PopAndDestroy( drivesDynList ); |
6815 CleanupStack::PopAndDestroy( drivesDynList ); |
6843 #endif |
6816 #endif |
6844 CleanupStack::PopAndDestroy( &fs ); |
6817 CleanupStack::PopAndDestroy( &fs ); |
6845 } |
6818 } |
6846 |
6819 |
6847 // --------------------------------------------------------- |
6820 // --------------------------------------------------------- |
6848 // CHttpDownload::UpdateDCFRepositoryL() |
6821 // CHttpDownload::UpdateDCFRepositoryL() |
6849 // Update saved file to DCFRepository |
6822 // Update saved file to DCFRepository |
6850 // --------------------------------------------------------- |
6823 // --------------------------------------------------------- |
6851 // |
6824 // |
6852 void CHttpDownload::UpdateDCFRepositoryL( |
6825 void CHttpDownload::UpdateDCFRepositoryL( |
6853 const TDesC& aFileName ) |
6826 const TDesC& aFileName ) |
6854 { |
6827 { |
6855 LOGGER_ENTERFN( "UpdateDCFRepositoryL" ); |
6828 LOGGER_ENTERFN( "UpdateDCFRepositoryL" ); |
6856 CLOG_WRITE_1( " :UpdateDCFRepositoryL() for: %S", &aFileName ); |
6829 CLOG_WRITE_1( " :UpdateDCFRepositoryL() for: %S", &aFileName ); |
6857 CDcfEntry* dcfEntry = NULL; |
6830 CDcfEntry* dcfEntry = NULL; |
6858 dcfEntry = CDcfEntry::NewL(); |
6831 dcfEntry = CDcfEntry::NewL(); |
6859 CleanupStack::PushL( dcfEntry ); |
6832 CleanupStack::PushL( dcfEntry ); |
6860 |
6833 |
6861 CDcfRep* dcfRep = NULL; |
6834 CDcfRep* dcfRep = NULL; |
6862 dcfRep = CDcfRep::NewL(); |
6835 dcfRep = CDcfRep::NewL(); |
6863 CleanupStack::PushL( dcfRep ); |
6836 CleanupStack::PushL( dcfRep ); |
6864 |
6837 |
6865 dcfEntry->SetLocationL( aFileName, 0 ); |
6838 dcfEntry->SetLocationL( aFileName, 0 ); |
6866 CLOG_WRITE(" : SetLocationL OK"); |
6839 CLOG_WRITE(" : SetLocationL OK"); |
6867 dcfRep->UpdateL( dcfEntry ); |
6840 dcfRep->UpdateL( dcfEntry ); |
6868 CLOG_WRITE(" :UpdateL OK"); |
6841 CLOG_WRITE(" :UpdateL OK"); |
6869 CleanupStack::PopAndDestroy(2); // dcfEntry, dcfRep |
6842 CleanupStack::PopAndDestroy(2); // dcfEntry, dcfRep |
6870 } |
6843 } |
6871 |
6844 |
6872 // ----------------------------------------------------------------------------- |
6845 // ----------------------------------------------------------------------------- |
6873 // CHttpDownload::MoveInDeleteL |
6846 // CHttpDownload::MoveInDeleteL |
6874 // ?implementation_description |
6847 // ?implementation_description |
6875 // (other items were commented in a header). |
6848 // (other items were commented in a header). |
6904 { |
6877 { |
6905 LOGGER_ENTERFN( "MoveDownloadedMediaObjectsL" ); |
6878 LOGGER_ENTERFN( "MoveDownloadedMediaObjectsL" ); |
6906 |
6879 |
6907 if( iDlState != EHttpDlMultipleMOCompleted && !iMoDownloadCompleted ) |
6880 if( iDlState != EHttpDlMultipleMOCompleted && !iMoDownloadCompleted ) |
6908 { |
6881 { |
6909 iStorage->SetProgressiveMode( EFalse ); |
6882 iStorage->SetProgressiveMode( EFalse ); |
6910 TriggerEvent( iDlState, EHttpDlProgNonProgressive); |
6883 TriggerEvent( iDlState, EHttpDlProgNonProgressive); |
6911 return;//Move will be Done by COD as MO Completed has not happened |
6884 return;//Move will be Done by COD as MO Completed has not happened |
6912 } |
6885 } |
6913 |
6886 |
6914 //__ASSERT_DEBUG( !IsActive(), DMPanic( KErrInUse ) ); |
6887 //__ASSERT_DEBUG( !IsActive(), DMPanic( KErrInUse ) ); |
6915 //__ASSERT_DEBUG( !iFileMan, DMPanic( KErrInUse ) ); |
6888 //__ASSERT_DEBUG( !iFileMan, DMPanic( KErrInUse ) ); |
6916 |
6889 |
6917 #if 0 |
6890 #if 0 |
6918 |
6891 |
6919 #else |
6892 #else |
6920 |
6893 |
6921 HBufC* filename = HBufC::NewLC(KMaxFileName); |
6894 HBufC* filename = HBufC::NewLC(KMaxFileName); |
6922 TPtr filenamePtr1 = filename->Des(); |
6895 TPtr filenamePtr1 = filename->Des(); |
6923 |
6896 |
6924 RFs &fs = iClientApp->Engine()->Fs(); |
6897 RFs &fs = iClientApp->Engine()->Fs(); |
6925 if(!iFileMan) |
6898 if(!iFileMan) |
6926 { |
6899 { |
6927 iFileMan = CFileMan::NewL(fs); |
6900 iFileMan = CFileMan::NewL(fs); |
6928 } |
6901 } |
6929 |
6902 |
6930 TPtrC filenamePtr2 = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
6903 TPtrC filenamePtr2 = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
6931 if(!filenamePtr2.Length()) |
6904 if(!filenamePtr2.Length()) |
6932 { |
6905 { |
6933 CleanupStack::PopAndDestroy(filename); |
6906 CleanupStack::PopAndDestroy(filename); |
6934 return; |
6907 return; |
6935 } |
6908 } |
6936 |
6909 |
6937 TInt firstSlashPos = filenamePtr2.Locate( '\\' ); |
6910 TInt firstSlashPos = filenamePtr2.Locate( '\\' ); |
6938 |
6911 |
6939 if(firstSlashPos < 0) |
6912 if(firstSlashPos < 0) |
6940 { |
6913 { |
6941 CleanupStack::PopAndDestroy(filename); |
6914 CleanupStack::PopAndDestroy(filename); |
6942 return; |
6915 return; |
6943 } |
6916 } |
6944 TPtrC dlName = filenamePtr2.Left(firstSlashPos); |
6917 TPtrC dlName = filenamePtr2.Left(firstSlashPos); |
6945 |
6918 |
6946 TInt drive; |
6919 TInt drive; |
6947 |
6920 |
6948 User::LeaveIfError( fs.CharToDrive( dlName[0], drive )); |
6921 User::LeaveIfError( fs.CharToDrive( dlName[0], drive )); |
6949 |
6922 |
6950 |
6923 |
6951 // Getting RootPath for selected Drive |
6924 // Getting RootPath for selected Drive |
6952 TFileName rootPath; |
6925 TFileName rootPath; |
6959 filenamePtr1.Append(_L("\\")); |
6932 filenamePtr1.Append(_L("\\")); |
6960 |
6933 |
6961 TInt error = fs.MkDirAll(filenamePtr1); |
6934 TInt error = fs.MkDirAll(filenamePtr1); |
6962 if (error!=KErrNone && error!=KErrAlreadyExists) |
6935 if (error!=KErrNone && error!=KErrAlreadyExists) |
6963 { |
6936 { |
6964 User::Leave(error); |
6937 User::Leave(error); |
6965 } |
6938 } |
6966 if( mediaObjectIndex == iActivePlayedDownload ) |
6939 if( mediaObjectIndex == iActivePlayedDownload ) |
6967 { |
6940 { |
6968 |
6941 |
6969 iFname = ((*iCodDlData)[mediaObjectIndex])->TempFilename(); |
6942 iFname = ((*iCodDlData)[mediaObjectIndex])->TempFilename(); |
6970 } |
6943 } |
6971 |
6944 |
6972 else |
6945 else |
6973 { |
6946 { |
6974 |
6947 |
6975 iFname = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
6948 iFname = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
6976 } |
6949 } |
6977 // Find a unique name to avoid any conflict. |
6950 // Find a unique name to avoid any conflict. |
6978 // Here iFname has full path of current location of file |
6951 // Here iFname has full path of current location of file |
6979 // and filename has destination path. |
6952 // and filename has destination path. |
6980 FindUniqueDestinationFileNameL( iFname, filename ); |
6953 FindUniqueDestinationFileNameL( iFname, filename ); |
6981 |
6954 |
6982 filenamePtr1 = filename->Des(); |
6955 filenamePtr1 = filename->Des(); |
6983 |
6956 |
6984 User::LeaveIfError( iFileMan->Move( iFname, filenamePtr1, CFileMan::EOverWrite, iStatus ) ); |
6957 User::LeaveIfError( iFileMan->Move( iFname, filenamePtr1, CFileMan::EOverWrite, iStatus ) ); |
6985 // waiting for move to complete |
6958 // waiting for move to complete |
6986 SetActive(); |
6959 SetActive(); |
6987 iFname = filenamePtr1; |
6960 iFname = filenamePtr1; |
6988 ((*iCodDlData)[mediaObjectIndex])->SetDestFilenameL(filenamePtr1); |
6961 ((*iCodDlData)[mediaObjectIndex])->SetDestFilenameL(filenamePtr1); |
6989 |
6962 |
6990 CleanupStack::PopAndDestroy(filename); |
6963 CleanupStack::PopAndDestroy(filename); |
6991 |
6964 |
6992 #endif |
6965 #endif |
6993 } |
6966 } |
6994 |
6967 |
6995 // ----------------------------------------------------------------------------- |
6968 // ----------------------------------------------------------------------------- |
6996 // CHttpDownload::MoveDownloadedMediaObjectSyncL |
6969 // CHttpDownload::MoveDownloadedMediaObjectSyncL |
7009 |
6982 |
7010 //__ASSERT_DEBUG( !IsActive(), DMPanic( KErrInUse ) ); |
6983 //__ASSERT_DEBUG( !IsActive(), DMPanic( KErrInUse ) ); |
7011 //__ASSERT_DEBUG( !iFileMan, DMPanic( KErrInUse ) ); |
6984 //__ASSERT_DEBUG( !iFileMan, DMPanic( KErrInUse ) ); |
7012 |
6985 |
7013 |
6986 |
7014 |
6987 |
7015 RFs &fs = iClientApp->Engine()->Fs(); |
6988 RFs &fs = iClientApp->Engine()->Fs(); |
7016 if(!iFileMan) |
6989 if(!iFileMan) |
7017 { |
6990 { |
7018 iFileMan = CFileMan::NewL(fs); |
6991 iFileMan = CFileMan::NewL(fs); |
7019 } |
6992 } |
7020 |
6993 |
7021 HBufC* filename = HBufC::NewLC(KMaxFileName); |
6994 HBufC* filename = HBufC::NewLC(KMaxFileName); |
7022 TPtr filenamePtr = filename->Des(); |
6995 TPtr filenamePtr = filename->Des(); |
7023 |
6996 |
7024 TPtrC fileNamePtr = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
6997 TPtrC fileNamePtr = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
7025 TInt firstSlashPos = fileNamePtr.Locate( '\\' ); |
6998 TInt firstSlashPos = fileNamePtr.Locate( '\\' ); |
7026 if(firstSlashPos < 0) |
6999 if(firstSlashPos < 0) |
7027 { |
7000 { |
7028 CleanupStack::PopAndDestroy(filename); |
7001 CleanupStack::PopAndDestroy(filename); |
7029 return; |
7002 return; |
7030 } |
7003 } |
7031 TPtrC dlName = fileNamePtr.Left(firstSlashPos); |
7004 TPtrC dlName = fileNamePtr.Left(firstSlashPos); |
7032 TInt drive; |
7005 TInt drive; |
7033 |
7006 |
7034 User::LeaveIfError( fs.CharToDrive( dlName[0], drive )); |
7007 User::LeaveIfError( fs.CharToDrive( dlName[0], drive )); |
7035 |
7008 |
7036 |
7009 |
7037 // Getting RootPath for selected Drive |
7010 // Getting RootPath for selected Drive |
7038 TFileName rootPath; |
7011 TFileName rootPath; |
7041 // Setting KDownloadPath |
7014 // Setting KDownloadPath |
7042 rootPath.Append( KDownloadPath ); |
7015 rootPath.Append( KDownloadPath ); |
7043 |
7016 |
7044 filenamePtr.Copy(rootPath); |
7017 filenamePtr.Copy(rootPath); |
7045 filenamePtr.Append(_L("\\")); |
7018 filenamePtr.Append(_L("\\")); |
7046 |
7019 |
7047 TInt error = fs.MkDirAll(filenamePtr); |
7020 TInt error = fs.MkDirAll(filenamePtr); |
7048 if (error!=KErrNone && error!=KErrAlreadyExists) |
7021 if (error!=KErrNone && error!=KErrAlreadyExists) |
7049 { |
7022 { |
7050 User::Leave(error); |
7023 User::Leave(error); |
7051 } |
7024 } |
7052 iFname = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
7025 iFname = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
7053 |
7026 |
7054 // Find a unique name to avoid any conflict. |
7027 // Find a unique name to avoid any conflict. |
7055 // Here iFname has full path of current location of file |
7028 // Here iFname has full path of current location of file |
7056 // and filename has destination path. |
7029 // and filename has destination path. |
7057 FindUniqueDestinationFileNameL( iFname, filename ); |
7030 FindUniqueDestinationFileNameL( iFname, filename ); |
7058 |
7031 |
7059 filenamePtr = filename->Des(); |
7032 filenamePtr = filename->Des(); |
7060 |
7033 |
7061 TInt err = iFileMan->Move(iFname, filenamePtr, CFileMan::EOverWrite); |
7034 TInt err = iFileMan->Move(iFname, filenamePtr, CFileMan::EOverWrite); |
7062 if(err != KErrNone) |
7035 if(err != KErrNone) |
7063 { |
7036 { |
7107 destPath->Des().Append( *fileExtention ); |
7080 destPath->Des().Append( *fileExtention ); |
7108 |
7081 |
7109 CleanupStack::PopAndDestroy( fileName ); |
7082 CleanupStack::PopAndDestroy( fileName ); |
7110 CleanupStack::PopAndDestroy( fileExtention ); |
7083 CleanupStack::PopAndDestroy( fileExtention ); |
7111 } |
7084 } |
7112 |
7085 |
7113 |
7086 |
7114 // --------------------------------------------------------- |
7087 // --------------------------------------------------------- |
7115 // CHttpDownload::NotifyMediaGalleryL() |
7088 // CHttpDownload::NotifyMediaGalleryL() |
7116 // Notify media gallery about the new file. |
7089 // Notify media gallery about the new file. |
7117 // --------------------------------------------------------- |
7090 // --------------------------------------------------------- |
7118 // |
7091 // |
7119 void CHttpDownload::NotifyMediaGalleryL( const TDesC& aFileName ) |
7092 void CHttpDownload::NotifyMediaGalleryL( const TDesC& aFileName ) |
7120 { |
7093 { |
7121 |
7094 |
7122 LOGGER_ENTERFN( "CHttpDownload::NotifyMediaGalleryL" ); |
7095 LOGGER_ENTERFN( "CHttpDownload::NotifyMediaGalleryL" ); |
7123 CLOG_WRITE_1(" notifying Gallery and DcfReposory about move for: %S",&aFileName); |
7096 CLOG_WRITE_1(" notifying Gallery and DcfReposory about move for: %S",&aFileName); |
7124 |
7097 |
7125 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF |
7098 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF |
7126 |
7099 |
7127 // |
7100 // |
7128 // Notify Media Gallery about new media file |
7101 // Notify Media Gallery about new media file |
7129 CMGXFileManager* mgFileManager = MGXFileManagerFactory::NewFileManagerL( |
7102 CMGXFileManager* mgFileManager = MGXFileManagerFactory::NewFileManagerL( |
7130 iClientApp->Engine()->Fs() ); |
7103 iClientApp->Engine()->Fs() ); |
7131 CleanupStack::PushL( mgFileManager ); |
7104 CleanupStack::PushL( mgFileManager ); |