16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 |
19 |
20 // INCLUDE FILES |
20 // INCLUDE FILES |
21 #include <browser_platform_variant.hrh> |
21 //#include <platform/mw/Browser_platform_variant.hrh> |
|
22 #include <Browser_platform_variant.hrh> |
22 #include "HeaderField.h" |
23 #include "HeaderField.h" |
23 #include "HttpDownloadManagerServerEngine.h" |
24 #include "HttpDownloadManagerServerEngine.h" |
24 #include "HttpClientApp.h" |
25 #include "HttpClientApp.h" |
25 #include "FileExt.h" |
26 #include "FileExt.h" |
26 #include "HttpDownload.h" |
27 #include "HttpDownload.h" |
27 #include "HttpStorage.h" |
28 #include "HttpStorage.h" |
28 #include "HttpDownloadMgrLogger.h" |
29 #include "HttpDownloadMgrLogger.h" |
29 #include "bautils.h" |
30 #include "bautils.h" |
30 |
31 |
31 #include <CommDbConnPref.h> |
32 #include <commdbconnpref.h> |
32 #include <Uri16.h> |
33 #include <uri16.h> |
33 #include <F32FILE.H> |
34 #include <f32file.h> |
34 #include <EscapeUtils.h> |
35 #include <escapeutils.h> |
35 #include <httpfiltercommonstringsext.h> |
36 #include <httpfiltercommonstringsext.h> |
36 #include <tinternetdate.h> |
37 #include <tinternetdate.h> |
37 #include <SysUtil.h> |
38 #include <sysutil.h> |
|
39 |
|
40 // following line is temporary: AVKON dependency removal |
|
41 #undef BRDO_APP_GALLERY_SUPPORTED_FF |
38 |
42 |
39 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF |
43 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF |
40 #include <MGXFileManagerFactory.h> |
44 #include <MGXFileManagerFactory.h> |
41 #include <CMGXFileManager.h> |
45 #include <CMGXFileManager.h> |
42 #endif |
46 #endif |
44 #include <DcfEntry.h> |
48 #include <DcfEntry.h> |
45 #include <DcfRep.h> |
49 #include <DcfRep.h> |
46 |
50 |
47 #include <pathinfo.h> |
51 #include <pathinfo.h> |
48 |
52 |
49 #ifdef DOWNLOADMGR_PATH_PLUGIN_ENABLED_FF |
|
50 #include <DownloadPathHandler.h> |
|
51 #endif |
|
52 // EXTERNAL DATA STRUCTURES |
53 // EXTERNAL DATA STRUCTURES |
53 //extern ?external_data; |
54 //extern ?external_data; |
54 |
55 |
55 // EXTERNAL FUNCTION PROTOTYPES |
56 // EXTERNAL FUNCTION PROTOTYPES |
56 //extern ?external_function( ?arg_type,?arg_type ); |
57 //extern ?external_function( ?arg_type,?arg_type ); |
57 |
58 |
58 // CONSTANTS |
59 // CONSTANTS |
59 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 |
60 const TInt32 KDmgrVersionNumber = 0x0301; // version number of the info file |
61 const TInt32 KDmgrVersionNumber = 0x0301; // version number of the info file |
61 const TInt KUrlFixChar = '_'; |
62 const TInt KUrlFixChar = '_'; |
62 const TInt KMaxHeaderOfMultipart = 32000; |
63 const TInt KMaxHeaderOfMultipart = 32000; |
63 const TInt KRespSizeForRecognition = 1024; //for THttpProgressState EHttpContTypeRecognitionAvail |
64 const TInt KRespSizeForRecognition = 1024; //for THttpProgressState EHttpContTypeRecognitionAvail |
64 const TInt KMinDataSizeToSend = (32*1024); //for Browser Control to call NewDownloadL |
65 const TInt KMinDataSizeToSend = (32*1024); //for Browser Control to call NewDownloadL |
65 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 |
66 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 |
67 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 |
68 _LIT8( KHttpScheme, "http" ); |
69 _LIT8( KHttpScheme, "http" ); |
69 _LIT8( KHttpsScheme, "https" ); |
70 _LIT8( KHttpsScheme, "https" ); |
203 ++iDontFireEvent; |
204 ++iDontFireEvent; |
204 |
205 |
205 TRAPD(err, PauseL() ); |
206 TRAPD(err, PauseL() ); |
206 |
207 |
207 --iDontFireEvent; |
208 --iDontFireEvent; |
208 |
209 |
209 User::LeaveIfError( err ); |
210 User::LeaveIfError( err ); |
210 } |
211 } |
211 } |
212 } |
212 |
213 |
213 if( !iStorage->CheckContentFileIntegrityL() ) |
214 if( !iStorage->CheckContentFileIntegrityL() ) |
214 { |
215 { |
215 if (iStorage->ProgressiveDownload() && |
216 if (iStorage->ProgressiveDownload() && |
216 iStorage->Length() == iStorage->DownloadedSize() ) |
217 iStorage->Length() == iStorage->DownloadedSize() ) |
217 // If it was a progressive download |
218 // If it was a progressive download |
218 // and downloaded size = content length, |
219 // and downloaded size = content length, |
219 // it means that download was not properly closed |
220 // it means that download was not properly closed |
220 // in the previous session |
221 // in the previous session |
221 { |
222 { |
222 ReInitializeDownload(); |
223 ReInitializeDownload(); |
657 iClientApp->Engine()->CODDownloadInfoFolder( iClientApp, folder ); |
658 iClientApp->Engine()->CODDownloadInfoFolder( iClientApp, folder ); |
658 file.Format( _L("%S%d"), &folder, iId ); |
659 file.Format( _L("%S%d"), &folder, iId ); |
659 //delete main info file |
660 //delete main info file |
660 err = iClientApp->Engine()->Fs().Delete( file ); |
661 err = iClientApp->Engine()->Fs().Delete( file ); |
661 CLOG_WRITE_2( "Delete info file: %S, err : %d", &file, err ); |
662 CLOG_WRITE_2( "Delete info file: %S, err : %d", &file, err ); |
662 |
663 |
663 //delete subinfo file |
664 //delete subinfo file |
664 CFileMan* fileMan = CFileMan::NewL(iClientApp->Engine()->Fs() ); |
665 CFileMan* fileMan = CFileMan::NewL(iClientApp->Engine()->Fs() ); |
665 file.Format( _L("%S%d_*"), &folder, iId ); |
666 file.Format( _L("%S%d_*"), &folder, iId ); |
666 fileMan->Delete( file ); |
667 fileMan->Delete( file ); |
667 delete fileMan; |
668 delete fileMan; |
668 |
669 |
669 |
670 |
670 // to make sure the CHttpStorage releases the content file |
671 // to make sure the CHttpStorage releases the content file |
671 // and deletes it. |
672 // and deletes it. |
672 CHttpStorage::TFileCloseOperation closeOp = CHttpStorage::EDeleteFile; |
673 CHttpStorage::TFileCloseOperation closeOp = CHttpStorage::EDeleteFile; |
673 |
674 |
674 if( iStorage->DestFNameSet() && iDlState == EHttpDlMultipleMOCompleted ) |
675 if( iStorage->DestFNameSet() && iDlState == EHttpDlMultipleMOCompleted ) |
675 // Do NOT delete the file: if the destination filename was |
676 // Do NOT delete the file: if the destination filename was |
676 // set by the client and download completed. |
677 // set by the client and download completed. |
677 { |
678 { |
678 CLOG_WRITE("Keep file"); |
679 CLOG_WRITE("Keep file"); |
679 closeOp = CHttpStorage::EKeepFile; |
680 closeOp = CHttpStorage::EKeepFile; |
680 } |
681 } |
681 |
682 |
682 if( iStorage->RFileSetByClient()) |
683 if( iStorage->RFileSetByClient()) |
683 { |
684 { |
684 TBool pausable; |
685 TBool pausable; |
685 GetBoolAttributeL( EDlAttrPausable, pausable ); |
686 GetBoolAttributeL( EDlAttrPausable, pausable ); |
686 if( iDlState == EHttpDlMultipleMOCompleted || ( iDlState == EHttpDlInprogress && pausable ) ) |
687 if( iDlState == EHttpDlMultipleMOCompleted || ( iDlState == EHttpDlInprogress && pausable ) ) |
687 { |
688 { |
688 CLOG_WRITE("Keep file"); |
689 CLOG_WRITE("Keep file"); |
689 closeOp = CHttpStorage::EKeepFile; |
690 closeOp = CHttpStorage::EKeepFile; |
690 } |
691 } |
691 |
692 |
692 } |
693 } |
693 if( iCodDlData ) |
694 if( iCodDlData ) |
694 { |
695 { |
695 // For User Delete when all the Downloads are moved to gallery |
696 // For User Delete when all the Downloads are moved to gallery |
696 if( EHttpDlMultipleMOCompleted == iDlState && closeOp == CHttpStorage::EDeleteFile ) |
697 if( EHttpDlMultipleMOCompleted == iDlState && closeOp == CHttpStorage::EDeleteFile ) |
697 { |
698 { |
698 for(TInt i = 1; i <= iCodDlData->Count(); i++) |
699 for(TInt i = 1; i <= iCodDlData->Count(); i++) |
699 { |
700 { |
700 TPtrC fullName = ((*iCodDlData)[i])->DestFilename(); |
701 TPtrC fullName = ((*iCodDlData)[i])->DestFilename(); |
701 ClientApp()->Engine()->Fs().Delete( fullName ); |
702 ClientApp()->Engine()->Fs().Delete( fullName ); |
702 } |
703 } |
703 } |
704 } |
704 // 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 |
705 else if( EHttpDlInprogress == iDlState || EHttpDlPaused == iDlState || EHttpDlDeleting == iDlState) |
706 else if( EHttpDlInprogress == iDlState || EHttpDlPaused == iDlState || EHttpDlDeleting == iDlState) |
706 { |
707 { |
707 for(TInt i = 1; i <= iCodDlData->Count(); i++) |
708 for(TInt i = 1; i <= iCodDlData->Count(); i++) |
708 { |
709 { |
709 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 |
710 { |
711 { |
711 TPtrC fullName = ((*iCodDlData)[i])->DestFilename(); |
712 TPtrC fullName = ((*iCodDlData)[i])->DestFilename(); |
712 if(fullName.Length()) |
713 if(fullName.Length()) |
713 { |
714 { |
714 ClientApp()->Engine()->Fs().Delete( fullName ); |
715 ClientApp()->Engine()->Fs().Delete( fullName ); |
715 } |
716 } |
716 } |
717 } |
717 //else if( ESucceeded == ((*iCodDlData)[i])->State() ) |
718 //else if( ESucceeded == ((*iCodDlData)[i])->State() ) |
718 // Completed ones will be kept and moved to Gallery |
719 // Completed ones will be kept and moved to Gallery |
719 else if( ESucceeded == ((*iCodDlData)[i])->State() ) |
720 else if( ESucceeded == ((*iCodDlData)[i])->State() ) |
720 { |
721 { |
721 MoveInDelete(i); |
722 MoveInDelete(i); |
722 } |
723 } |
723 } |
724 } |
724 } |
725 } |
725 } |
726 } |
726 else |
727 else |
727 { |
728 { |
728 iStorage->CloseDestinationFile( closeOp ); |
729 iStorage->CloseDestinationFile( closeOp ); |
729 } |
730 } |
730 // when delete there's no store -> no leave |
731 // when delete there's no store -> no leave |
731 // aClAppInstance->ClientApp()->UnregisterDownload( this ); |
732 // aClAppInstance->ClientApp()->UnregisterDownload( this ); |
732 } |
733 } |
733 |
734 |
734 |
735 |
735 // ----------------------------------------------------------------------------- |
736 // ----------------------------------------------------------------------------- |
736 // CHttpDownload::DeleteInfoFile |
737 // CHttpDownload::DeleteInfoFile |
739 // ----------------------------------------------------------------------------- |
740 // ----------------------------------------------------------------------------- |
740 // |
741 // |
741 EXPORT_C void CHttpDownload::DeleteInfoFile( CHttpClientAppInstance* aClAppInstance ) |
742 EXPORT_C void CHttpDownload::DeleteInfoFile( CHttpClientAppInstance* aClAppInstance ) |
742 { |
743 { |
743 CLOG_WRITE( "DeleteInfoFile()" ); |
744 CLOG_WRITE( "DeleteInfoFile()" ); |
744 |
745 |
745 // This should be called only after the completion of download |
746 // This should be called only after the completion of download |
746 if( ! (EHttpDlMultipleMOCompleted == iDlState && |
747 if( ! (EHttpDlMultipleMOCompleted == iDlState && |
747 ( |
748 ( |
748 EHttpProgContentFileMoved == iProgState || |
749 EHttpProgContentFileMoved == iProgState || |
749 EHttpProgContentFileMovedAndDestFNChanged == iProgState |
750 EHttpProgContentFileMovedAndDestFNChanged == iProgState |
750 ) |
751 ) |
751 )) |
752 )) |
752 { |
753 { |
753 return; |
754 return; |
754 } |
755 } |
755 |
756 |
756 // Do not inform user about that we are in deleteing state |
757 // Do not inform user about that we are in deleteing state |
757 // 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 |
758 // don't call delete only from outside of this class. |
759 // don't call delete only from outside of this class. |
759 ++iDontFireEvent; |
760 ++iDontFireEvent; |
760 |
761 |
761 TPath folder; |
762 TPath folder; |
762 TFileName file; |
763 TFileName file; |
763 |
764 |
764 // delete info file |
765 // delete info file |
765 iClientApp->Engine()->DownloadInfoFolder( iClientApp, folder ); |
766 iClientApp->Engine()->DownloadInfoFolder( iClientApp, folder ); |
769 |
770 |
770 // delete cod info file |
771 // delete cod info file |
771 iClientApp->Engine()->CODDownloadInfoFolder( iClientApp, folder ); |
772 iClientApp->Engine()->CODDownloadInfoFolder( iClientApp, folder ); |
772 file.Format( _L("%S%d"), &folder, iId ); |
773 file.Format( _L("%S%d"), &folder, iId ); |
773 CLOG_WRITE_1( "Delete info file: %S", &file ); |
774 CLOG_WRITE_1( "Delete info file: %S", &file ); |
774 iClientApp->Engine()->Fs().Delete( file ); |
775 iClientApp->Engine()->Fs().Delete( file ); |
775 |
776 |
776 //delete subinfo file |
777 //delete subinfo file |
777 CFileMan* fileMan = CFileMan::NewL(iClientApp->Engine()->Fs() ); |
778 CFileMan* fileMan = CFileMan::NewL(iClientApp->Engine()->Fs() ); |
778 file.Format( _L("%S%d_*"), &folder, iId ); |
779 file.Format( _L("%S%d_*"), &folder, iId ); |
779 fileMan->Delete( file ); |
780 fileMan->Delete( file ); |
780 delete fileMan; |
781 delete fileMan; |
781 |
782 |
782 |
783 |
783 // to make sure the CHttpStorage releases the content file |
784 // to make sure the CHttpStorage releases the content file |
784 // and deletes it. |
785 // and deletes it. |
785 CHttpStorage::TFileCloseOperation closeOp = CHttpStorage::EDeleteFile; |
786 CHttpStorage::TFileCloseOperation closeOp = CHttpStorage::EDeleteFile; |
786 |
787 |
787 if( iStorage->DestFNameSet() && iDlState == EHttpDlMultipleMOCompleted ) |
788 if( iStorage->DestFNameSet() && iDlState == EHttpDlMultipleMOCompleted ) |
788 // Do NOT delete the file: if the destination filename was |
789 // Do NOT delete the file: if the destination filename was |
789 // set by the client and download completed. |
790 // set by the client and download completed. |
790 { |
791 { |
791 CLOG_WRITE("Keep file"); |
792 CLOG_WRITE("Keep file"); |
792 closeOp = CHttpStorage::EKeepFile; |
793 closeOp = CHttpStorage::EKeepFile; |
793 } |
794 } |
794 |
795 |
795 iStorage->CloseDestinationFile( closeOp ); |
796 iStorage->CloseDestinationFile( closeOp ); |
796 |
797 |
797 // when delete there's no store -> no leave |
798 // when delete there's no store -> no leave |
798 aClAppInstance->ClientApp()->UnregisterDownload( this ); |
799 aClAppInstance->ClientApp()->UnregisterDownload( this ); |
799 } |
800 } |
800 |
801 |
801 |
802 |
802 // ----------------------------------------------------------------------------- |
803 // ----------------------------------------------------------------------------- |
803 // CHttpDownload::MoveL |
804 // CHttpDownload::MoveL |
830 |
831 |
831 if( iProgState == EHttpProgMovingContentFile ) |
832 if( iProgState == EHttpProgMovingContentFile ) |
832 { |
833 { |
833 User::Leave( KErrInUse ); |
834 User::Leave( KErrInUse ); |
834 } |
835 } |
835 |
836 |
836 //File is already moved. Ignore the move |
837 //File is already moved. Ignore the move |
837 if( iProgState == EHttpProgContentFileMovedAndDestFNChanged || |
838 if( iProgState == EHttpProgContentFileMovedAndDestFNChanged || |
838 |
839 |
839 iProgState == EHttpProgContentFileMoved ) |
840 iProgState == EHttpProgContentFileMoved ) |
840 { |
841 { |
841 return; |
842 return; |
842 } |
843 } |
843 |
844 |
844 __ASSERT_DEBUG( !IsActive(), DMPanic( KErrInUse ) ); |
845 __ASSERT_DEBUG( !IsActive(), DMPanic( KErrInUse ) ); |
845 //__ASSERT_DEBUG( !iFileMan, DMPanic( KErrInUse ) ); |
846 //__ASSERT_DEBUG( !iFileMan, DMPanic( KErrInUse ) ); |
846 |
847 |
847 if(_OMADLOTA2_MULTI_DOWNLOAD) |
848 if(_OMADLOTA2_MULTI_DOWNLOAD) |
848 { |
849 { |
849 iMOMoved = 1; |
850 iMOMoved = 1; |
850 SetDownloadStatus( EHttpProgMovingContentFile, iDlState ); |
851 SetDownloadStatus( EHttpProgMovingContentFile, iDlState ); |
851 MoveDownloadedMediaObjectL(iMOMoved); |
852 MoveDownloadedMediaObjectL(iMOMoved); |
872 do |
873 do |
873 { |
874 { |
874 CreateIndexedNameL(uniqueName , fileNamePtr , index); |
875 CreateIndexedNameL(uniqueName , fileNamePtr , index); |
875 if( !BaflUtils::FileExists( rFs , *uniqueName ) ) |
876 if( !BaflUtils::FileExists( rFs , *uniqueName ) ) |
876 //Check if file name exist in Destination path |
877 //Check if file name exist in Destination path |
877 //Generate Unique name if exist |
878 //Generate Unique name if exist |
878 { |
879 { |
879 bFound =ETrue; |
880 bFound =ETrue; |
880 break; |
881 break; |
881 } |
882 } |
882 iDlNameChanged = ETrue; |
883 iDlNameChanged = ETrue; |
883 |
884 |
884 }while( !bFound ); |
885 }while( !bFound ); |
885 CleanupStack::PopAndDestroy( fileName ); |
886 CleanupStack::PopAndDestroy( fileName ); |
886 |
887 |
887 if( iDlNameChanged ) |
888 if( iDlNameChanged ) |
888 { |
889 { |
889 HBufC16* destFileName ; |
890 HBufC16* destFileName ; |
890 destFileName = iStorage->DestFilename(); |
891 destFileName = iStorage->DestFilename(); |
891 TPtr destFileNamePtr = destFileName->Des(); |
892 TPtr destFileNamePtr = destFileName->Des(); |
892 destFileNamePtr.Replace(0, destFileNamePtr.Length() , *uniqueName); |
893 destFileNamePtr.Replace(0, destFileNamePtr.Length() , *uniqueName); |
893 TInt lastSlashPos = destFileNamePtr.LocateReverse( '\\' ); |
894 TInt lastSlashPos = destFileNamePtr.LocateReverse( '\\' ); |
894 TPtr dlName = destFileNamePtr.MidTPtr(lastSlashPos +1 ); |
895 TPtr dlName = destFileNamePtr.MidTPtr(lastSlashPos +1 ); |
895 TInt dotPos = iDlName->LocateReverse( '.' ); |
896 TInt dotPos = iDlName->LocateReverse( '.' ); |
896 if( dotPos == KErrNotFound ) |
897 if( dotPos == KErrNotFound ) |
897 { |
898 { |
898 //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 |
899 dotPos = dlName.LocateReverse( '.' ); |
900 dotPos = dlName.LocateReverse( '.' ); |
900 if(dotPos != KErrNotFound ) |
901 if(dotPos != KErrNotFound ) |
901 { |
902 { |
902 dlName.Copy( dlName.Left(dotPos)); |
903 dlName.Copy( dlName.Left(dotPos)); |
903 } |
904 } |
904 } |
905 } |
905 //download name has changed |
906 //download name has changed |
906 ReallocateStringL( iDlName, dlName, KDownloadNameMaxSize ); |
907 ReallocateStringL( iDlName, dlName, KDownloadNameMaxSize ); |
907 } |
908 } |
908 |
909 |
909 TInt err =iFileMan->Move( *iStorage->LocalFilename(), |
910 TInt err =iFileMan->Move( *iStorage->LocalFilename(), |
910 *iStorage->DestFilename(), |
911 *iStorage->DestFilename(), |
911 CFileMan::EOverWrite, |
912 CFileMan::EOverWrite, |
912 iStatus ); |
913 iStatus ); |
913 if(err != KErrNone) |
914 if(err != KErrNone) |
914 { |
915 { |
915 iMoveInProgress = EFalse; |
916 iMoveInProgress = EFalse; |
916 CLOG_WRITE("setting iMoveInProgress false when move fails"); |
917 CLOG_WRITE("setting iMoveInProgress false when move fails"); |
917 } |
918 } |
918 |
919 |
919 User::LeaveIfError( err ); |
920 User::LeaveIfError( err ); |
920 // waiting for move to complete |
921 // waiting for move to complete |
921 SetActive(); |
922 SetActive(); |
922 SetDownloadStatus( EHttpProgMovingContentFile, iDlState ); |
923 SetDownloadStatus( EHttpProgMovingContentFile, iDlState ); |
923 } |
924 } |
924 |
925 |
1119 User::Leave( KErrArgument ); |
1114 User::Leave( KErrArgument ); |
1120 #endif |
1115 #endif |
1121 } |
1116 } |
1122 break; |
1117 break; |
1123 } |
1118 } |
1124 |
1119 |
1125 iNoRealError = EFalse; |
1120 iNoRealError = EFalse; |
1126 } |
1121 } |
1127 |
1122 |
1128 // ----------------------------------------------------------------------------- |
1123 // ----------------------------------------------------------------------------- |
1129 // CHttpDownload::GetIntAttributeL |
1124 // CHttpDownload::GetIntAttributeL |
1130 // ?implementation_description |
1125 // ?implementation_description |
1131 // (other items were commented in a header). |
1126 // (other items were commented in a header). |
1132 // ----------------------------------------------------------------------------- |
1127 // ----------------------------------------------------------------------------- |
1133 // |
1128 // |
1134 EXPORT_C void CHttpDownload::GetIntAttributeL( THttpDownloadAttrib aAttribute, |
1129 EXPORT_C void CHttpDownload::GetIntAttributeL( THttpDownloadAttrib aAttribute, |
1135 TInt32& aMoIndex, |
1130 TInt32& aMoIndex, |
1136 TInt32& aValue ) |
1131 TInt32& aValue ) |
1137 { |
1132 { |
1138 LOGGER_ENTERFN( "GetIntAttributeL" ); |
1133 LOGGER_ENTERFN( "GetIntAttributeL" ); |
1139 CLOG_WRITE_1( "Attr(%d)", aAttribute ); |
1134 CLOG_WRITE_1( "Attr(%d)", aAttribute ); |
1140 |
1135 |
1141 if (!iCodDlData) |
1136 if (!iCodDlData) |
1142 { |
1137 { |
1143 aValue = 0; |
1138 aValue = 0; |
1144 return; |
1139 return; |
1145 } |
1140 } |
1146 if ((aMoIndex <= KNonMoIndex) || (aMoIndex > iCodDlData->Count())) |
1141 if ((aMoIndex <= KNonMoIndex) || (aMoIndex > iCodDlData->Count())) |
1147 { |
1142 { |
1148 User::Leave( KErrArgument ); |
1143 User::Leave( KErrArgument ); |
1149 } |
1144 } |
1150 |
1145 |
1151 CMediaDataBase* mediaData = (*iCodDlData)[aMoIndex]; |
1146 CMediaDataBase* mediaData = (*iCodDlData)[aMoIndex]; |
1152 iNoRealError = ETrue; |
1147 iNoRealError = ETrue; |
1153 |
1148 |
1154 switch( aAttribute ) |
1149 switch( aAttribute ) |
1155 { |
1150 { |
1220 User::Leave( KErrArgument ); |
1209 User::Leave( KErrArgument ); |
1221 #endif |
1210 #endif |
1222 } |
1211 } |
1223 break; |
1212 break; |
1224 } |
1213 } |
1225 |
1214 |
1226 iNoRealError = EFalse; |
1215 iNoRealError = EFalse; |
1227 } |
1216 } |
1228 |
1217 |
1229 // ----------------------------------------------------------------------------- |
1218 // ----------------------------------------------------------------------------- |
1230 // CHttpDownload::GetBoolAttributeL |
1219 // CHttpDownload::GetBoolAttributeL |
1231 // ?implementation_description |
1220 // ?implementation_description |
1232 // (other items were commented in a header). |
1221 // (other items were commented in a header). |
1233 // ----------------------------------------------------------------------------- |
1222 // ----------------------------------------------------------------------------- |
1234 // |
1223 // |
1235 EXPORT_C void CHttpDownload::GetBoolAttributeL( THttpDownloadAttrib aAttribute, |
1224 EXPORT_C void CHttpDownload::GetBoolAttributeL( THttpDownloadAttrib aAttribute, |
1236 TBool& aValue ) |
1225 TBool& aValue ) |
1237 { |
1226 { |
1238 LOGGER_ENTERFN( "GetBoolAttributeL" ); |
1227 LOGGER_ENTERFN( "GetBoolAttributeL" ); |
1239 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
1228 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
1240 |
1229 |
1329 User::Leave( KErrArgument ); |
1318 User::Leave( KErrArgument ); |
1330 #endif |
1319 #endif |
1331 } |
1320 } |
1332 break; |
1321 break; |
1333 } |
1322 } |
1334 |
1323 |
1335 iNoRealError = EFalse; |
1324 iNoRealError = EFalse; |
1336 } |
1325 } |
1337 |
1326 |
1338 // ----------------------------------------------------------------------------- |
1327 // ----------------------------------------------------------------------------- |
1339 // CHttpDownload::GetBoolAttributeL |
1328 // CHttpDownload::GetBoolAttributeL |
1340 // ?implementation_description |
1329 // ?implementation_description |
1341 // (other items were commented in a header). |
1330 // (other items were commented in a header). |
1342 // ----------------------------------------------------------------------------- |
1331 // ----------------------------------------------------------------------------- |
1343 // |
1332 // |
1344 EXPORT_C void CHttpDownload::GetBoolAttributeL( THttpDownloadAttrib aAttribute, |
1333 EXPORT_C void CHttpDownload::GetBoolAttributeL( THttpDownloadAttrib aAttribute, |
1345 TInt32& aMoIndex, |
1334 TInt32& aMoIndex, |
1346 TBool& aValue ) |
1335 TBool& aValue ) |
1347 { |
1336 { |
1348 LOGGER_ENTERFN( "GetBoolAttributeL" ); |
1337 LOGGER_ENTERFN( "GetBoolAttributeL" ); |
1349 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
1338 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
1350 |
1339 |
1351 if (!iCodDlData) |
1340 if (!iCodDlData) |
1352 { |
1341 { |
1353 aValue = 0; |
1342 aValue = 0; |
1354 return; |
1343 return; |
1355 } |
1344 } |
1356 if ((aMoIndex <= KNonMoIndex) || (aMoIndex > iCodDlData->Count())) |
1345 if ((aMoIndex <= KNonMoIndex) || (aMoIndex > iCodDlData->Count())) |
1357 { |
1346 { |
1358 User::Leave( KErrArgument ); |
1347 User::Leave( KErrArgument ); |
1359 } |
1348 } |
1360 |
1349 |
1361 CMediaDataBase* mediaData = (*iCodDlData)[aMoIndex]; |
1350 CMediaDataBase* mediaData = (*iCodDlData)[aMoIndex]; |
1362 iNoRealError = ETrue; |
1351 iNoRealError = ETrue; |
1363 |
1352 |
1364 switch( aAttribute ) |
1353 switch( aAttribute ) |
1365 { |
1354 { |
1397 User::Leave( KErrArgument ); |
1386 User::Leave( KErrArgument ); |
1398 #endif |
1387 #endif |
1399 } |
1388 } |
1400 break; |
1389 break; |
1401 } |
1390 } |
1402 |
1391 |
1403 iNoRealError = EFalse; |
1392 iNoRealError = EFalse; |
1404 } |
1393 } |
1405 |
1394 |
1406 // ----------------------------------------------------------------------------- |
1395 // ----------------------------------------------------------------------------- |
1407 // CHttpDownload::GetStringAttributeL |
1396 // CHttpDownload::GetStringAttributeL |
1408 // ?implementation_description |
1397 // ?implementation_description |
1409 // (other items were commented in a header). |
1398 // (other items were commented in a header). |
1410 // ----------------------------------------------------------------------------- |
1399 // ----------------------------------------------------------------------------- |
1411 // |
1400 // |
1412 EXPORT_C HBufC* CHttpDownload::GetStringAttributeL( THttpDownloadAttrib aAttribute, |
1401 EXPORT_C HBufC* CHttpDownload::GetStringAttributeL( THttpDownloadAttrib aAttribute, |
1413 TBool& aDelete ) |
1402 TBool& aDelete ) |
1414 { |
1403 { |
1415 LOGGER_ENTERFN( "GetStringAttributeL" ); |
1404 LOGGER_ENTERFN( "GetStringAttributeL" ); |
1416 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
1405 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
1417 |
1406 |
2165 // CHttpDownload::SetIntAttributeL |
2154 // CHttpDownload::SetIntAttributeL |
2166 // ?implementation_description |
2155 // ?implementation_description |
2167 // (other items were commented in a header). |
2156 // (other items were commented in a header). |
2168 // ----------------------------------------------------------------------------- |
2157 // ----------------------------------------------------------------------------- |
2169 // |
2158 // |
2170 EXPORT_C void CHttpDownload::SetIntAttributeL( THttpDownloadAttrib aAttribute, |
2159 EXPORT_C void CHttpDownload::SetIntAttributeL( THttpDownloadAttrib aAttribute, |
2171 const TInt32 aValue ) |
2160 const TInt32 aValue ) |
2172 { |
2161 { |
2173 LOGGER_ENTERFN( "SetIntAttributeL" ); |
2162 LOGGER_ENTERFN( "SetIntAttributeL" ); |
2174 CLOG_WRITE_2( "Attr(%d): %d", aAttribute, aValue ); |
2163 CLOG_WRITE_2( "Attr(%d): %d", aAttribute, aValue ); |
2175 TBool store( ETrue ); |
2164 TBool store( ETrue ); |
2233 } |
2222 } |
2234 break; |
2223 break; |
2235 |
2224 |
2236 case EDlAttrMultipleMOLength: |
2225 case EDlAttrMultipleMOLength: |
2237 { |
2226 { |
2238 iMoLength = aValue; |
2227 iMoLength = aValue; |
2239 } |
2228 } |
2240 break; |
2229 break; |
2241 |
2230 |
2242 case EDlAttrDownloadedSize: |
2231 case EDlAttrDownloadedSize: |
2243 { |
2232 { |
2244 if( (iCodDownload || iContinueDownload) && iDlState == EHttpDlInprogress ) |
2233 if( (iCodDownload || iContinueDownload) && iDlState == EHttpDlInprogress ) |
2245 { |
2234 { |
2246 iStorage->SetDownloadedSize( aValue ); |
2235 iStorage->SetDownloadedSize( aValue ); |
2247 // Calculate downloaded size of current media object from |
2236 // Calculate downloaded size of current media object from |
2248 // album downloaded size. |
2237 // album downloaded size. |
2249 TInt dlSize = iStorage->DownloadedSize(); |
2238 TInt dlSize = iStorage->DownloadedSize(); |
2250 if( iCodDlData ) |
2239 if( iCodDlData ) |
2251 { |
2240 { |
2252 for (TInt index = 0; index < iCodDlData->Count() ; ++index) |
2241 for (TInt index = 0; index < iCodDlData->Count() ; ++index) |
2253 { |
2242 { |
2254 if( iActiveDownload - 1 == index ) |
2243 if( iActiveDownload - 1 == index ) |
2255 { |
2244 { |
2256 //the size of active download has already been taken into account |
2245 //the size of active download has already been taken into account |
2257 continue; |
2246 continue; |
2258 } |
2247 } |
2259 CMediaDataBase* moData = (*iCodDlData)[index+1]; |
2248 CMediaDataBase* moData = (*iCodDlData)[index+1]; |
2260 if ((moData->State() == ESucceeded) || (moData->State() == EInProgress)) |
2249 if ((moData->State() == ESucceeded) || (moData->State() == EInProgress)) |
2261 dlSize += moData->DownloadedSize(); |
2250 dlSize += moData->DownloadedSize(); |
2262 } |
2251 } |
2263 iStorage->SetMoDownloadedSize(dlSize); |
2252 iStorage->SetMoDownloadedSize(dlSize); |
2264 } |
2253 } |
2265 if( iStorage->Length() != KDefaultContentLength && |
2254 if( iStorage->Length() != KDefaultContentLength && |
2266 iStorage->DownloadedSize() > iStorage->Length() ) |
2255 iStorage->DownloadedSize() > iStorage->Length() ) |
2267 // we don't know actually how many bytes will come down. |
2256 // we don't know actually how many bytes will come down. |
2268 { |
2257 { |
2269 CLOG_WRITE( "Length modified" ); |
2258 CLOG_WRITE( "Length modified" ); |
2270 iStorage->SetLength( KDefaultContentLength ); |
2259 iStorage->SetLength( KDefaultContentLength ); |
2271 StoreDownloadInfoL(); |
2260 StoreDownloadInfoL(); |
2272 } |
2261 } |
2273 TriggerEvent( EHttpDlInprogress, EHttpProgResponseBodyReceived ); |
2262 TriggerEvent( EHttpDlInprogress, EHttpProgResponseBodyReceived ); |
2274 } |
2263 } |
2275 |
2264 |
2276 store = EFalse; |
2265 store = EFalse; |
2277 } |
2266 } |
2278 break; |
2267 break; |
2279 |
2268 |
2280 case EDlAttrSucceeded: |
2269 case EDlAttrSucceeded: |
2281 { |
2270 { |
2282 if(!aValue) |
2271 if(!aValue) |
2283 DownloadSucceededL(); |
2272 DownloadSucceededL(); |
2284 else |
2273 else |
2285 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 |
2286 //So MOVE will be issued by PD Client |
2275 //So MOVE will be issued by PD Client |
2287 |
2276 |
2288 store = EFalse; |
2277 store = EFalse; |
2289 } |
2278 } |
2290 break; |
2279 break; |
2291 |
2280 |
2318 } |
2307 } |
2319 } |
2308 } |
2320 break; |
2309 break; |
2321 |
2310 |
2322 case EDlAttrFotaPckgId: |
2311 case EDlAttrFotaPckgId: |
2323 { |
2312 { |
2324 iFotaPckgId = aValue; |
2313 iFotaPckgId = aValue; |
2325 store = EFalse; |
2314 store = EFalse; |
2326 } |
2315 } |
2327 break; |
2316 break; |
2328 case EDlAttrActiveDownload: |
2317 case EDlAttrActiveDownload: |
2329 { |
2318 { |
2330 iActiveDownload = aValue; |
2319 iActiveDownload = aValue; |
2331 |
2320 |
2332 // Active MO changed. Notify clients. |
2321 // Active MO changed. Notify clients. |
2333 TriggerEvent( EHttpDlCreated, EHttpProgNone ); |
2322 TriggerEvent( EHttpDlCreated, EHttpProgNone ); |
2334 } |
2323 } |
2335 break; |
2324 break; |
2336 |
2325 |
2337 case EDlAttrActivePlayedDownload: |
2326 case EDlAttrActivePlayedDownload: |
2338 { |
2327 { |
2339 iActivePlayedDownload = aValue; |
2328 iActivePlayedDownload = aValue; |
2340 } |
2329 } |
2341 |
2330 |
2342 break; |
|
2343 |
|
2344 case EDlAttrDestRemovable: |
|
2345 { |
|
2346 if( iCodDownload ) |
|
2347 { |
|
2348 iStorage->SetRemovableDest( aValue ); |
|
2349 |
|
2350 if (iCodDlData) |
|
2351 { |
|
2352 // Update for Active media object. |
|
2353 TInt active = iActiveDownload; |
|
2354 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
|
2355 mediaData->SetDesRemovable( aValue ); |
|
2356 } |
|
2357 } |
|
2358 } |
|
2359 break; |
2331 break; |
2360 default: |
2332 default: |
2361 { |
2333 { |
2362 #ifdef __WINS__ |
2334 #ifdef __WINS__ |
2363 DMPanic( KErrArgument ); |
2335 DMPanic( KErrArgument ); |
2382 // CHttpDownload::SetBoolAttributeL |
2354 // CHttpDownload::SetBoolAttributeL |
2383 // ?implementation_description |
2355 // ?implementation_description |
2384 // (other items were commented in a header). |
2356 // (other items were commented in a header). |
2385 // ----------------------------------------------------------------------------- |
2357 // ----------------------------------------------------------------------------- |
2386 // |
2358 // |
2387 EXPORT_C void CHttpDownload::SetBoolAttributeL( THttpDownloadAttrib aAttribute, |
2359 EXPORT_C void CHttpDownload::SetBoolAttributeL( THttpDownloadAttrib aAttribute, |
2388 const TBool aValue ) |
2360 const TBool aValue ) |
2389 { |
2361 { |
2390 LOGGER_ENTERFN( "SetBoolAttributeL" ); |
2362 LOGGER_ENTERFN( "SetBoolAttributeL" ); |
2391 CLOG_WRITE_2( "Attr(%d): %d", aAttribute, aValue ); |
2363 CLOG_WRITE_2( "Attr(%d): %d", aAttribute, aValue ); |
2392 TBool store( ETrue ); |
2364 TBool store( ETrue ); |
2443 case EDlAttrCodDownload: |
2415 case EDlAttrCodDownload: |
2444 { |
2416 { |
2445 SetCodFlag( aValue ); |
2417 SetCodFlag( aValue ); |
2446 } |
2418 } |
2447 break; |
2419 break; |
2448 |
2420 |
2449 case EDlAttrProgressive: |
2421 case EDlAttrProgressive: |
2450 { |
2422 { |
2451 TBool PdSupported(EFalse); |
2423 TBool PdSupported(EFalse); |
2452 |
2424 |
2453 if(iClAppInstance) |
2425 if(iClAppInstance) |
2454 { |
2426 { |
2455 TRAP_IGNORE(iClAppInstance->GetBoolAttributeL(EDlMgrProgressiveDownload, PdSupported)); |
2427 TRAP_IGNORE(iClAppInstance->GetBoolAttributeL(EDlMgrProgressiveDownload, PdSupported)); |
2456 } |
2428 } |
2457 |
2429 |
2458 if(PdSupported) |
2430 if(PdSupported) |
2459 { |
2431 { |
2460 iStorage->SetProgressiveMode( aValue ); |
2432 iStorage->SetProgressiveMode( aValue ); |
2461 |
2433 |
2462 if(!aValue) |
2434 if(!aValue) |
2463 { |
2435 { |
2464 iActivePlayedDownload = 0; |
2436 iActivePlayedDownload = 0; |
2465 } |
2437 } |
2466 |
2438 |
2467 if (iCodDlData) |
2439 if (iCodDlData) |
2468 { |
2440 { |
2469 // Update for Active media object. |
2441 // Update for Active media object. |
2470 TInt active = iActiveDownload; |
2442 TInt active = iActiveDownload; |
2471 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
2443 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
2472 mediaData->SetProgressiveDownload( aValue ); |
2444 mediaData->SetProgressiveDownload( aValue ); |
2473 } |
2445 } |
2474 |
2446 |
2475 if( iProgState != EHttpProgMovingContentFile ) |
2447 if( iProgState != EHttpProgMovingContentFile ) |
2476 { |
2448 { |
2477 if (aValue && iDlState == EHttpDlMultipleMOCompleted ) |
2449 if (aValue && iDlState == EHttpDlMultipleMOCompleted ) |
2478 { |
2450 { |
2479 /* |
2451 /* |
2480 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. |
2481 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 |
2482 This is needed to ensure backward compatibility |
2454 This is needed to ensure backward compatibility |
2483 */ |
2455 */ |
2484 TriggerEvent( EHttpDlCompleted, EHttpDlProgProgressive); |
2456 TriggerEvent( EHttpDlCompleted, EHttpDlProgProgressive); |
2485 } |
2457 } |
2486 else |
2458 else |
2487 { |
2459 { |
2488 TriggerEvent( iDlState, aValue ? EHttpDlProgProgressive : EHttpDlProgNonProgressive); |
2460 TriggerEvent( iDlState, aValue ? EHttpDlProgProgressive : EHttpDlProgNonProgressive); |
2489 } |
2461 } |
2490 } |
2462 } |
2491 } |
2463 } |
2492 else |
2464 else |
2493 { |
2465 { |
2494 TriggerEvent( iDlState, EHttpDlProgNonProgressive); |
2466 TriggerEvent( iDlState, EHttpDlProgNonProgressive); |
2495 } |
2467 } |
2496 } |
2468 } |
2497 break; |
2469 break; |
2498 |
2470 |
2499 case EDlAttrCodDescriptorAccepted: |
2471 case EDlAttrCodDescriptorAccepted: |
2500 { |
2472 { |
2501 TriggerEvent( EHttpDlInprogress, EHttpProgCodDescriptorAccepted ); |
2473 TriggerEvent( EHttpDlInprogress, EHttpProgCodDescriptorAccepted ); |
2502 } |
2474 } |
2503 break; |
2475 break; |
2504 |
2476 |
2505 case EDlAttrCodLoadEnd: |
2477 case EDlAttrCodLoadEnd: |
2506 { |
2478 { |
2507 SetDownloadStatus(EHttpProgCodLoadEnd,EHttpDlInprogress); |
2479 SetDownloadStatus(EHttpProgCodLoadEnd,EHttpDlInprogress); |
2508 } |
2480 } |
2509 break; |
2481 break; |
2633 } |
2603 } |
2634 else |
2604 else |
2635 { |
2605 { |
2636 User::Leave( KErrInUse ); |
2606 User::Leave( KErrInUse ); |
2637 } |
2607 } |
2638 |
2608 |
2639 if (updateFName) |
2609 if (updateFName) |
2640 { |
2610 { |
2641 iStorage->UpdateDestinationFilenameL( aValue, ETrue ); |
2611 iStorage->UpdateDestinationFilenameL( aValue, ETrue ); |
2642 if (iCodDlData) |
2612 if (iCodDlData) |
2643 { |
2613 { |
2644 CMediaDataBase* mediaData = (*iCodDlData)[aMOIndex]; |
2614 CMediaDataBase* mediaData = (*iCodDlData)[aMOIndex]; |
2645 mediaData->SetDestFilenameL( aValue ); |
2615 mediaData->SetDestFilenameL( aValue ); |
2646 } |
2616 } |
2647 } |
2617 } |
2648 } |
2618 } |
2649 break; |
2619 break; |
2650 } |
2620 } |
2651 } |
2621 } |
2652 |
2622 |
2653 |
2623 |
2654 // ----------------------------------------------------------------------------- |
2624 // ----------------------------------------------------------------------------- |
2655 // CHttpDownload::SetStringAttributeL |
2625 // CHttpDownload::SetStringAttributeL |
2656 // ?implementation_description |
2626 // ?implementation_description |
2657 // (other items were commented in a header). |
2627 // (other items were commented in a header). |
2658 // ----------------------------------------------------------------------------- |
2628 // ----------------------------------------------------------------------------- |
2659 // |
2629 // |
2660 EXPORT_C void CHttpDownload::SetStringAttributeL( THttpDownloadAttrib aAttribute, |
2630 EXPORT_C void CHttpDownload::SetStringAttributeL( THttpDownloadAttrib aAttribute, |
2661 const TDesC16& aValue ) |
2631 const TDesC16& aValue ) |
2662 { |
2632 { |
2663 LOGGER_ENTERFN( "SetStringAttributeL" ); |
2633 LOGGER_ENTERFN( "SetStringAttributeL" ); |
2664 CLOG_WRITE_2( "Attr(%d - %d)", aAttribute, aValue.Length () ); |
2634 CLOG_WRITE_2( "Attr(%d - %d)", aAttribute, aValue.Length () ); |
2665 TBool store( ETrue ); |
2635 TBool store( ETrue ); |
2687 if( iDlState == EHttpDlInprogress ) |
2657 if( iDlState == EHttpDlInprogress ) |
2688 { |
2658 { |
2689 CLOG_WRITE( "EDlAttrContentType updated" ); |
2659 CLOG_WRITE( "EDlAttrContentType updated" ); |
2690 ReallocateStringL( iContentType, aValue, KMaxContentTypeLength ); |
2660 ReallocateStringL( iContentType, aValue, KMaxContentTypeLength ); |
2691 TriggerEvent( EHttpDlInprogress, EHttpProgContentTypeChanged ); |
2661 TriggerEvent( EHttpDlInprogress, EHttpProgContentTypeChanged ); |
2692 |
2662 |
2693 // Update for Active media object. |
2663 // Update for Active media object. |
2694 HBufC8* type8 = HBufC8::NewLC( aValue.Length() ); |
2664 HBufC8* type8 = HBufC8::NewLC( aValue.Length() ); |
2695 type8->Des().Copy( aValue ); |
2665 type8->Des().Copy( aValue ); |
2696 |
2666 |
2697 if (iCodDlData) |
2667 if (iCodDlData) |
2698 { |
2668 { |
2699 TInt active = iActiveDownload; |
2669 TInt active = iActiveDownload; |
2700 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
2670 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
2701 mediaData->SetTypeL( type8->Des() ); |
2671 mediaData->SetTypeL( type8->Des() ); |
2702 CleanupStack::PopAndDestroy( type8 ); |
2672 CleanupStack::PopAndDestroy( type8 ); |
2926 // CHttpDownload::SetStringAttributeL |
2896 // CHttpDownload::SetStringAttributeL |
2927 // ?implementation_description |
2897 // ?implementation_description |
2928 // (other items were commented in a header). |
2898 // (other items were commented in a header). |
2929 // ----------------------------------------------------------------------------- |
2899 // ----------------------------------------------------------------------------- |
2930 // |
2900 // |
2931 EXPORT_C void CHttpDownload::SetStringAttributeL( THttpDownloadAttrib aAttribute, |
2901 EXPORT_C void CHttpDownload::SetStringAttributeL( THttpDownloadAttrib aAttribute, |
2932 const TDesC8& aValue ) |
2902 const TDesC8& aValue ) |
2933 { |
2903 { |
2934 LOGGER_ENTERFN( "SetStringAttributeL(8)" ); |
2904 LOGGER_ENTERFN( "SetStringAttributeL(8)" ); |
2935 CLOG_WRITE_2( "Attr(%d - %d)", aAttribute, aValue.Length () ); |
2905 CLOG_WRITE_2( "Attr(%d - %d)", aAttribute, aValue.Length () ); |
2936 TBool store( ETrue ); |
2906 TBool store( ETrue ); |
3062 case EDlAttrHashedMsgBody: |
3032 case EDlAttrHashedMsgBody: |
3063 { |
3033 { |
3064 ReallocateStringL( iHashedMsgBody, aValue, KHashLength ); |
3034 ReallocateStringL( iHashedMsgBody, aValue, KHashLength ); |
3065 } |
3035 } |
3066 break; |
3036 break; |
3067 |
3037 |
3068 case EDlAttrRedirectedPermanently: |
3038 case EDlAttrRedirectedPermanently: |
3069 { |
3039 { |
3070 RedirectedPermanentlyL( aValue ); |
3040 RedirectedPermanentlyL( aValue ); |
3071 |
3041 |
3072 if (iCodDlData) |
3042 if (iCodDlData) |
3073 { |
3043 { |
3074 // Update for Active media object. |
3044 // Update for Active media object. |
3075 TInt active = iActiveDownload; |
3045 TInt active = iActiveDownload; |
3076 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
3046 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
3077 if (!mediaData->Redirected()) |
3047 if (!mediaData->Redirected()) |
3078 mediaData->SetRedirUrlL( aValue ); |
3048 mediaData->SetRedirUrlL( aValue ); |
3079 } |
3049 } |
3080 } |
3050 } |
3081 break; |
3051 break; |
3082 |
3052 |
3083 case EDlAttrRedirectedTemporary: |
3053 case EDlAttrRedirectedTemporary: |
3084 { |
3054 { |
3085 RedirectedTemporaryL( aValue ); |
3055 RedirectedTemporaryL( aValue ); |
3086 |
3056 |
3087 if (iCodDlData) |
3057 if (iCodDlData) |
3088 { |
3058 { |
3089 // Update for Active media object. |
3059 // Update for Active media object. |
3090 TInt active = iActiveDownload; |
3060 TInt active = iActiveDownload; |
3091 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
3061 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
3092 mediaData->SetRedirected( ETrue ); |
3062 mediaData->SetRedirected( ETrue ); |
3093 } |
3063 } |
3094 } |
3064 } |
3095 break; |
3065 break; |
3096 |
3066 |
3097 case EDlAttrContinueBody: |
3067 case EDlAttrContinueBody: |
3098 { |
3068 { |
3099 iNoRealError = EFalse; |
3069 iNoRealError = EFalse; |
3100 ResponseBodyReceivedL( aValue ); |
3070 ResponseBodyReceivedL( aValue ); |
3101 store = EFalse; |
3071 store = EFalse; |
3174 iStorage->SetDownloadedSize( (*iCodDlData)[i]->DownloadedSize() ); |
3144 iStorage->SetDownloadedSize( (*iCodDlData)[i]->DownloadedSize() ); |
3175 iStorage->SetLength( (*iCodDlData)[i]->Size() ); |
3145 iStorage->SetLength( (*iCodDlData)[i]->Size() ); |
3176 activeDownloadChanged = ETrue; |
3146 activeDownloadChanged = ETrue; |
3177 } |
3147 } |
3178 } |
3148 } |
3179 iStorage->SetMoDownloadedSize( downloadedSize ); |
3149 iStorage->SetMoDownloadedSize( downloadedSize ); |
3180 } |
3150 } |
3181 // ----------------------------------------------------------------------------- |
3151 // ----------------------------------------------------------------------------- |
3182 // CHttpDownload::SetTrackDataAttributeL |
3152 // CHttpDownload::SetTrackDataAttributeL |
3183 // ?implementation_description |
3153 // ?implementation_description |
3184 // (other items were commented in a header). |
3154 // (other items were commented in a header). |
3185 // ----------------------------------------------------------------------------- |
3155 // ----------------------------------------------------------------------------- |
3186 // |
3156 // |
3187 EXPORT_C void CHttpDownload::SetTrackDataAttributeL( TInt aIndex, HBufC8* dlData ) |
3157 EXPORT_C void CHttpDownload::SetTrackDataAttributeL( TInt aIndex, HBufC8* dlData ) |
3188 { |
3158 { |
3189 LOGGER_ENTERFN( "SetTrackDataAttributeL" ); |
3159 LOGGER_ENTERFN( "SetTrackDataAttributeL" ); |
3190 |
3160 |
3191 if (iCodDlData) |
3161 if (iCodDlData) |
3192 { |
3162 { |
3193 CMediaDataServ* updatedMediaData = CMediaDataServ::NewL(*dlData); |
3163 CMediaDataServ* updatedMediaData = CMediaDataServ::NewL(*dlData); |
3194 CMediaDataBase* mediaData = (*iCodDlData)[aIndex]; |
3164 CMediaDataBase* mediaData = (*iCodDlData)[aIndex]; |
3195 mediaData->SetNameL(updatedMediaData->Name()); |
3165 mediaData->SetNameL(updatedMediaData->Name()); |
3201 mediaData->SetState( updatedMediaData->State() ); |
3171 mediaData->SetState( updatedMediaData->State() ); |
3202 mediaData->SetResult( updatedMediaData->Result() ); |
3172 mediaData->SetResult( updatedMediaData->Result() ); |
3203 mediaData->SetDownloadedSize( updatedMediaData->DownloadedSize() ); |
3173 mediaData->SetDownloadedSize( updatedMediaData->DownloadedSize() ); |
3204 mediaData->SetDestFilenameL( updatedMediaData->DestFilename() ); |
3174 mediaData->SetDestFilenameL( updatedMediaData->DestFilename() ); |
3205 mediaData->SetTempFilenameL( updatedMediaData->DestFilename() ); |
3175 mediaData->SetTempFilenameL( updatedMediaData->DestFilename() ); |
3206 |
3176 |
3207 mediaData->ResetTypes(); |
3177 mediaData->ResetTypes(); |
3208 for (TInt type = 0; type < updatedMediaData->TypesCount(); ++type) |
3178 for (TInt type = 0; type < updatedMediaData->TypesCount(); ++type) |
3209 mediaData->AddTypeL( updatedMediaData->Types().MdcaPoint(type) ); |
3179 mediaData->AddTypeL( updatedMediaData->Types().MdcaPoint(type) ); |
3210 mediaData->SetStatusCode( updatedMediaData->StatusCode() ); |
3180 mediaData->SetStatusCode( updatedMediaData->StatusCode() ); |
3211 TInt result = updatedMediaData->Result(); |
3181 TInt result = updatedMediaData->Result(); |
3274 { |
3244 { |
3275 CLOG_WRITE( "No real error" ); |
3245 CLOG_WRITE( "No real error" ); |
3276 iNoRealError = EFalse; |
3246 iNoRealError = EFalse; |
3277 |
3247 |
3278 return; |
3248 return; |
3279 } |
3249 } |
3280 |
3250 |
3281 if( iCodDlData && iCodDlData->Count() > 1 ) |
3251 if( iCodDlData && iCodDlData->Count() > 1 ) |
3282 { |
3252 { |
3283 if( aDlError == KErrMultipeObjectDownloadFailed ) |
3253 if( aDlError == KErrMultipeObjectDownloadFailed ) |
3284 { |
3254 { |
3285 //Permanently failed error in CodHandler |
3255 //Permanently failed error in CodHandler |
3286 //Delete the download |
3256 //Delete the download |
3287 SetDownloadStatus( EHttpProgNone, |
3257 SetDownloadStatus( EHttpProgNone, |
3288 EHttpDlMultipleMOFailed, |
3258 EHttpDlMultipleMOFailed, |
3289 aDlError, |
3259 aDlError, |
3290 aError ); |
3260 aError ); |
3291 return; |
3261 return; |
3292 } |
3262 } |
3293 else |
3263 else |
3294 { |
3264 { |
3295 SetDownloadStatus( EHttpProgNone, |
3265 SetDownloadStatus( EHttpProgNone, |
3296 EHttpDlPaused, |
3266 EHttpDlPaused, |
3297 aDlError, |
3267 aDlError, |
3298 aError ); |
3268 aError ); |
3299 return; |
3269 return; |
3300 |
3270 |
3301 } |
3271 } |
3302 } |
3272 } |
3303 |
3273 |
3304 if( iDlState < EHttpDlCreated ) |
3274 if( iDlState < EHttpDlCreated ) |
3305 // error occured during download object construction -> nothing to do here |
3275 // error occured during download object construction -> nothing to do here |
3347 } |
3317 } |
3348 } |
3318 } |
3349 |
3319 |
3350 if( aError == KErrHttpPartialResponseReceived ) |
3320 if( aError == KErrHttpPartialResponseReceived ) |
3351 { |
3321 { |
3352 //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 |
3353 //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 |
3354 //HTTP::EEnableDisconnectNotification |
3324 //HTTP::EEnableDisconnectNotification |
3355 |
3325 |
3356 //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 |
3357 //paused download. |
3327 //paused download. |
3358 //TSW Err ID : SXUU-77SRWL |
3328 //TSW Err ID : SXUU-77SRWL |
3359 |
3329 |
3360 SetDownloadStatus( EHttpProgNone, |
3330 SetDownloadStatus( EHttpProgNone, |
3361 EHttpDlPaused, |
3331 EHttpDlPaused, |
3362 aDlError, |
3332 aDlError, |
3363 aError ); |
3333 aError ); |
3364 |
3334 |
3365 } |
3335 } |
3366 else if( aDlError == EConnectionFailed && iPausable) |
3336 else if( aDlError == EConnectionFailed && iPausable) |
3367 { |
3337 { |
3368 //Whenever connection error occurs and download can be paused. |
3338 //Whenever connection error occurs and download can be paused. |
3369 //Keep the download in paused state. |
3339 //Keep the download in paused state. |
3370 SetDownloadStatus( EHttpProgNone, |
3340 SetDownloadStatus( EHttpProgNone, |
3371 EHttpDlPaused, |
3341 EHttpDlPaused, |
3372 aDlError, |
3342 aDlError, |
3373 aError ); |
3343 aError ); |
3374 } |
3344 } |
3375 else if ( aDlError == EMMCRemoved ) |
3345 else if ( aDlError == EMMCRemoved ) |
3376 { |
3346 { |
3377 // MMC removed. Pause the download. |
3347 // MMC removed. Pause the download. |
3378 SetDownloadStatus( EHttpProgNone, |
3348 SetDownloadStatus( EHttpProgNone, |
3561 } |
3531 } |
3562 |
3532 |
3563 iNoMedia = EFalse; |
3533 iNoMedia = EFalse; |
3564 TriggerEvent( EHttpDlMediaInserted ); |
3534 TriggerEvent( EHttpDlMediaInserted ); |
3565 } |
3535 } |
3566 |
3536 |
3567 // ----------------------------------------------------------------------------- |
3537 // ----------------------------------------------------------------------------- |
3568 // CHttpDownload::GetDestinationDriveID |
3538 // CHttpDownload::GetDestinationDriveID |
3569 // ?implementation_description |
3539 // ?implementation_description |
3570 // (other items were commented in a header). |
3540 // (other items were commented in a header). |
3571 // ----------------------------------------------------------------------------- |
3541 // ----------------------------------------------------------------------------- |
3572 // |
3542 // |
3573 TInt CHttpDownload::GetDestinationDriveID() const |
3543 TInt CHttpDownload::GetDestinationDriveID() const |
3574 { |
3544 { |
3575 return (TInt)iStorage->GetDestinationDriveId(); |
3545 return (TInt)iStorage->GetDestinationDriveId(); |
3576 } |
3546 } |
3577 |
3547 |
3578 // ----------------------------------------------------------------------------- |
3548 // ----------------------------------------------------------------------------- |
3579 // CHttpDownload::SetClientInstance |
3549 // CHttpDownload::SetClientInstance |
3580 // ?implementation_description |
3550 // ?implementation_description |
3581 // (other items were commented in a header). |
3551 // (other items were commented in a header). |
3582 // ----------------------------------------------------------------------------- |
3552 // ----------------------------------------------------------------------------- |
3635 // ----------------------------------------------------------------------------- |
3605 // ----------------------------------------------------------------------------- |
3636 // |
3606 // |
3637 void CHttpDownload::SetDownloadNameL( const TDesC& aNewName ) |
3607 void CHttpDownload::SetDownloadNameL( const TDesC& aNewName ) |
3638 { |
3608 { |
3639 CLOG_WRITE_1( "New download name: [%S]", &aNewName ); |
3609 CLOG_WRITE_1( "New download name: [%S]", &aNewName ); |
3640 |
3610 |
3641 ReallocateStringL( iDlName, aNewName, KDownloadNameMaxSize ); |
3611 ReallocateStringL( iDlName, aNewName, KDownloadNameMaxSize ); |
3642 |
3612 |
3643 FixDownloadNameL(); |
3613 FixDownloadNameL(); |
3644 |
3614 |
3645 TriggerEvent( EHttpDlInprogress, EHttpProgDlNameChanged ); |
3615 TriggerEvent( EHttpDlInprogress, EHttpProgDlNameChanged ); |
3646 } |
3616 } |
3647 |
3617 |
3648 // ----------------------------------------------------------------------------- |
3618 // ----------------------------------------------------------------------------- |
3649 // CHttpDownload::MHFRunL |
3619 // CHttpDownload::MHFRunL |
3650 // ?implementation_description |
3620 // ?implementation_description |
3651 // (other items were commented in a header). |
3621 // (other items were commented in a header). |
3652 // ----------------------------------------------------------------------------- |
3622 // ----------------------------------------------------------------------------- |
3653 // |
3623 // |
3654 void CHttpDownload::MHFRunL( RHTTPTransaction /*aTransaction*/, |
3624 void CHttpDownload::MHFRunL( RHTTPTransaction /*aTransaction*/, |
3655 const THTTPEvent& aEvent ) |
3625 const THTTPEvent& aEvent ) |
3656 { |
3626 { |
3657 switch ( aEvent.iStatus ) |
3627 switch ( aEvent.iStatus ) |
3658 { |
3628 { |
3659 case THTTPEvent::EGotResponseHeaders: |
3629 case THTTPEvent::EGotResponseHeaders: |
3660 { |
3630 { |
3661 CLOG_WRITE( "Response header received" ); |
3631 CLOG_WRITE( "Response header received" ); |
3662 ResponseHeaderReceivedL(); |
3632 ResponseHeaderReceivedL(); |
3663 } |
3633 } |
3664 break; |
3634 break; |
3665 |
3635 |
3666 case THTTPEvent::EGotResponseBodyData: |
3636 case THTTPEvent::EGotResponseBodyData: |
3667 { |
3637 { |
3668 MHTTPDataSupplier* respBody = iTrans.Response().Body(); |
3638 MHTTPDataSupplier* respBody = iTrans.Response().Body(); |
3700 { |
3670 { |
3701 iTrans.Close(); |
3671 iTrans.Close(); |
3702 iTransValid = EFalse; |
3672 iTransValid = EFalse; |
3703 } |
3673 } |
3704 iDlStartedByClient = EFalse; |
3674 iDlStartedByClient = EFalse; |
3705 } |
3675 } |
3706 break; |
3676 break; |
3707 |
3677 |
3708 case THTTPEvent::ERedirectedPermanently: |
3678 case THTTPEvent::ERedirectedPermanently: |
3709 { |
3679 { |
3710 RedirectedPermanentlyL( iTrans.Request().URI().UriDes() ); |
3680 RedirectedPermanentlyL( iTrans.Request().URI().UriDes() ); |
3711 } |
3681 } |
3712 break; |
3682 break; |
3713 |
3683 |
3714 case THTTPEvent::ERedirectedTemporarily: |
3684 case THTTPEvent::ERedirectedTemporarily: |
3715 { |
3685 { |
3716 RedirectedTemporaryL( iTrans.Request().URI().UriDes() ); |
3686 RedirectedTemporaryL( iTrans.Request().URI().UriDes() ); |
3717 } |
3687 } |
3718 break; |
3688 break; |
3719 |
3689 |
3720 default: |
3690 default: |
3721 { |
3691 { |
3722 CLOG_WRITE_1( "Event: %d", aEvent.iStatus ); |
3692 CLOG_WRITE_1( "Event: %d", aEvent.iStatus ); |
3723 if( aEvent.iStatus < 0 ) |
3693 if( aEvent.iStatus < 0 ) |
3724 // error occured -> leave will be handled in OnError() |
3694 // error occured -> leave will be handled in OnError() |
3725 { |
3695 { |
3726 User::Leave( aEvent.iStatus ); |
3696 User::Leave( aEvent.iStatus ); |
3727 } |
3697 } |
3728 } |
3698 } |
3729 break; |
3699 break; |
3730 } |
3700 } |
3731 } |
3701 } |
3732 |
3702 |
3733 // ----------------------------------------------------------------------------- |
3703 // ----------------------------------------------------------------------------- |
3734 // CHttpDownload::MHFRunError |
3704 // CHttpDownload::MHFRunError |
3735 // ?implementation_description |
3705 // ?implementation_description |
3736 // (other items were commented in a header). |
3706 // (other items were commented in a header). |
3737 // ----------------------------------------------------------------------------- |
3707 // ----------------------------------------------------------------------------- |
3738 // |
3708 // |
3739 TInt CHttpDownload::MHFRunError( TInt aError, |
3709 TInt CHttpDownload::MHFRunError( TInt aError, |
3740 RHTTPTransaction /*aTransaction*/, |
3710 RHTTPTransaction /*aTransaction*/, |
3741 const THTTPEvent& /*aEvent*/ ) |
3711 const THTTPEvent& /*aEvent*/ ) |
3742 { |
3712 { |
3743 CLOG_WRITE_1( "MHFRunError: %d", aError ); |
3713 CLOG_WRITE_1( "MHFRunError: %d", aError ); |
3744 |
3714 |
3745 OnError( aError, ETransactionFailed ); |
3715 OnError( aError, ETransactionFailed ); |
3799 TriggerEvent( EHttpDlInprogress, EHttpProgCodDownloadShouldResume ); |
3769 TriggerEvent( EHttpDlInprogress, EHttpProgCodDownloadShouldResume ); |
3800 } |
3770 } |
3801 else |
3771 else |
3802 { |
3772 { |
3803 RequestContentL(); |
3773 RequestContentL(); |
3804 } |
3774 } |
3805 } |
3775 } |
3806 |
3776 |
3807 } |
3777 } |
3808 break; |
3778 break; |
3809 |
3779 |
3810 case EHttpProgMovingContentFile: |
3780 case EHttpProgMovingContentFile: |
3811 // Move completed |
3781 // Move completed |
3812 // State remains in completed |
3782 // State remains in completed |
3813 // and move result stored in error attribs |
3783 // and move result stored in error attribs |
3814 { |
3784 { |
3815 CLOG_WRITE_1( "Move result: %d", iStatus.Int() ); |
3785 CLOG_WRITE_1( "Move result: %d", iStatus.Int() ); |
3816 // 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. |
3817 // So, the download status should be changed after that |
3787 // So, the download status should be changed after that |
3818 //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 |
3819 //where file is saved(saved to gallery) |
3789 //where file is saved(saved to gallery) |
3820 //Change Dl State to Download Completed if not already |
3790 //Change Dl State to Download Completed if not already |
3821 |
3791 |
3822 if( iStatus ==KErrNone ) |
3792 if(_OMADLOTA2_MULTI_DOWNLOAD) |
3823 { |
3793 { |
3824 if(_OMADLOTA2_MULTI_DOWNLOAD) |
3794 TPtrC fileNamePtr = ((*iCodDlData)[iMOMoved])->DestFilename(); |
3825 { |
3795 NotifyMediaGalleryL(fileNamePtr); |
3826 TPtrC fileNamePtr = ((*iCodDlData)[iMOMoved])->DestFilename(); |
3796 |
3827 NotifyMediaGalleryL(fileNamePtr); |
3797 // Initiate async move for the next media object |
3828 |
3798 iMOMoved++; |
3829 // Initiate async move for the next media object |
3799 if(iMOMoved <= iCodDlData->Count()) |
3830 iMOMoved++; |
3800 { |
3831 if(iMOMoved <= iCodDlData->Count()) |
3801 MoveDownloadedMediaObjectL(iMOMoved); |
3832 { |
3802 break; |
3833 MoveDownloadedMediaObjectL(iMOMoved); |
3803 } |
3834 break; |
3804 } |
3835 } |
3805 |
3836 } |
3806 SetDownloadStatus( iDlNameChanged ? EHttpProgContentFileMovedAndDestFNChanged : EHttpProgContentFileMoved, |
3837 |
3807 iDlState = EHttpDlMultipleMOCompleted, |
3838 SetDownloadStatus( iDlNameChanged ? EHttpProgContentFileMovedAndDestFNChanged : EHttpProgContentFileMoved, |
|
3839 iDlState = EHttpDlMultipleMOCompleted, |
|
3840 iStatus == KErrNone ? ENoError : EMoveFailed, |
3808 iStatus == KErrNone ? ENoError : EMoveFailed, |
3841 iStatus.Int() ); |
3809 iStatus.Int() ); |
3842 |
3810 |
3843 if(iStatus == KErrNone) |
3811 if(iStatus == KErrNone) |
3844 { |
3812 { |
3845 iMoveInProgress = EFalse; |
3813 iMoveInProgress = EFalse; |
3846 CLOG_WRITE("setting iMoveInProgress false when move is completed"); |
3814 CLOG_WRITE("setting iMoveInProgress false when move is completed"); |
3847 } |
3815 } |
3848 |
3816 |
3849 delete iFileMan; iFileMan = NULL; |
3817 |
3850 |
3818 delete iFileMan; iFileMan = NULL; |
3851 if( !_OMADLOTA2_MULTI_DOWNLOAD) |
3819 |
3852 { |
3820 if( !_OMADLOTA2_MULTI_DOWNLOAD) |
3853 TPtr fileNamePtr(iStorage->DestFilename()->Des()); |
3821 { |
3854 NotifyMediaGalleryL(fileNamePtr); |
3822 TPtr fileNamePtr(iStorage->DestFilename()->Des()); |
3855 } |
3823 NotifyMediaGalleryL(fileNamePtr); |
3856 } |
3824 } |
3857 else |
3825 } |
3858 { |
|
3859 CLOG_WRITE("Move Operation Failed "); |
|
3860 CLOG_WRITE("setting progress state to EHttpProgNone when move is Failing"); |
|
3861 SetDownloadStatus( EHttpProgNone, iDlState ); |
|
3862 CLOG_WRITE("setting iMoveInProgress false when move is Failing"); |
|
3863 iMoveInProgress = EFalse; |
|
3864 } |
|
3865 } |
|
3866 break; |
3826 break; |
3867 |
3827 |
3868 default: |
3828 default: |
3869 { |
3829 { |
3870 DMPanic( KErrUnknown ); |
3830 DMPanic( KErrUnknown ); |
4060 APPEND_BUF_INT( newInfoPtr, iExpires ); |
4020 APPEND_BUF_INT( newInfoPtr, iExpires ); |
4061 APPEND_BUF_INT( newInfoPtr, iMaxAge ); |
4021 APPEND_BUF_INT( newInfoPtr, iMaxAge ); |
4062 |
4022 |
4063 CLOG_WRITE("5"); |
4023 CLOG_WRITE("5"); |
4064 |
4024 |
4065 |
4025 |
4066 TInt size = GetHttpHeadersSize(iResponseHeaders)+ GetHttpHeadersSize(iRequestHeaders)+ |
4026 TInt size = GetHttpHeadersSize(iResponseHeaders)+ GetHttpHeadersSize(iRequestHeaders)+ |
4067 GetHttpHeadersSize(iEntityHeaders)+ GetHttpHeadersSize(iGeneralHeaders) + newInfoPtr.Size(); |
4027 GetHttpHeadersSize(iEntityHeaders)+ GetHttpHeadersSize(iGeneralHeaders) + newInfoPtr.Size(); |
4068 |
4028 |
4069 |
4029 |
4070 if(size >= bufSz) |
4030 if(size >= bufSz) |
4071 { |
4031 { |
4072 User::LeaveIfError( KErrArgument ); |
4032 User::LeaveIfError( KErrArgument ); |
4073 } |
4033 } |
4074 |
4034 |
4075 AppendHeadersL( newInfoPtr, iResponseHeaders ); |
4035 AppendHeadersL( newInfoPtr, iResponseHeaders ); |
4076 AppendHeadersL( newInfoPtr, iRequestHeaders ); |
4036 AppendHeadersL( newInfoPtr, iRequestHeaders ); |
4077 AppendHeadersL( newInfoPtr, iEntityHeaders ); |
4037 AppendHeadersL( newInfoPtr, iEntityHeaders ); |
4078 AppendHeadersL( newInfoPtr, iGeneralHeaders ); |
4038 AppendHeadersL( newInfoPtr, iGeneralHeaders ); |
4079 |
4039 |
4080 CLOG_WRITE("6"); |
4040 CLOG_WRITE("6"); |
4081 |
4041 |
4082 APPEND_BUF_INT( newInfoPtr, iFotaPckgId ); |
4042 APPEND_BUF_INT( newInfoPtr, iFotaPckgId ); |
4083 |
4043 |
4084 CLOG_WRITE("7"); |
4044 CLOG_WRITE("7"); |
4085 |
4045 |
4086 // check if download info is unchanged from previous update |
4046 // check if download info is unchanged from previous update |
4087 if( iDownloadInfo && ( iDownloadInfo->Compare(*newInfo) == 0 )) |
4047 if( iDownloadInfo && ( iDownloadInfo->Compare(*newInfo) == 0 )) |
4088 { |
4048 { |
4089 // no change |
4049 // no change |
4090 CLOG_WRITE("DownloadInfo unchanged - no need to update"); |
4050 CLOG_WRITE("DownloadInfo unchanged - no need to update"); |
4102 HBufC* fileNameBuf = HBufC::NewLC( KMaxPath ); |
4062 HBufC* fileNameBuf = HBufC::NewLC( KMaxPath ); |
4103 TPtr fileName = fileNameBuf->Des(); |
4063 TPtr fileName = fileNameBuf->Des(); |
4104 iClientApp->Engine()->DownloadInfoFolder( iClientApp, folder ); |
4064 iClientApp->Engine()->DownloadInfoFolder( iClientApp, folder ); |
4105 fileName.Format( _L("%S%d"), &folder, iId ); |
4065 fileName.Format( _L("%S%d"), &folder, iId ); |
4106 CLOG_WRITE_1( "info: %S", &fileName ); |
4066 CLOG_WRITE_1( "info: %S", &fileName ); |
4107 |
4067 |
4108 RFile outFile; |
4068 RFile outFile; |
4109 CleanupClosePushL<RFile>( outFile ); |
4069 CleanupClosePushL<RFile>( outFile ); |
4110 User::LeaveIfError( outFile.Replace( iClientApp->Engine()->Fs(), |
4070 User::LeaveIfError( outFile.Replace( iClientApp->Engine()->Fs(), |
4111 fileName, |
4071 fileName, |
4112 EFileShareExclusive | |
4072 EFileShareExclusive | |
4113 EFileStream | |
4073 EFileStream | |
4114 EFileWrite ) ); |
4074 EFileWrite ) ); |
4115 |
4075 |
4116 outFile.Write( newInfoPtr ); |
4076 outFile.Write( newInfoPtr ); |
4117 User::LeaveIfError( outFile.Flush() ); |
4077 User::LeaveIfError( outFile.Flush() ); |
4118 CleanupStack::PopAndDestroy( 2, fileNameBuf ); |
4078 CleanupStack::PopAndDestroy( 2, fileNameBuf ); |
4211 |
4171 |
4212 LoadHeadersL( inFile, iResponseHeaders ); |
4172 LoadHeadersL( inFile, iResponseHeaders ); |
4213 LoadHeadersL( inFile, iRequestHeaders ); |
4173 LoadHeadersL( inFile, iRequestHeaders ); |
4214 LoadHeadersL( inFile, iEntityHeaders ); |
4174 LoadHeadersL( inFile, iEntityHeaders ); |
4215 LoadHeadersL( inFile, iGeneralHeaders ); |
4175 LoadHeadersL( inFile, iGeneralHeaders ); |
4216 |
4176 |
4217 CLOG_WRITE("6"); |
4177 CLOG_WRITE("6"); |
4218 |
4178 |
4219 READ_INT_L( inFile, iFotaPckgId ); |
4179 READ_INT_L( inFile, iFotaPckgId ); |
4220 |
4180 |
4221 CleanupStack::PopAndDestroy(); // inFile |
4181 CleanupStack::PopAndDestroy(); // inFile |
4222 CleanupStack::PopAndDestroy( 2, folderBuf ); // also fileNameBuf |
4182 CleanupStack::PopAndDestroy( 2, folderBuf ); // also fileNameBuf |
4223 |
4183 |
4224 CLOG_WRITE("9"); |
4184 CLOG_WRITE("9"); |
4225 |
4185 |
4226 UpdatePausable(); |
4186 UpdatePausable(); |
4227 } |
4187 } |
4228 |
4188 |
4229 // ----------------------------------------------------------------------------- |
4189 // ----------------------------------------------------------------------------- |
4230 // CHttpDownload::IsExpired |
4190 // CHttpDownload::IsExpired |
4323 namePtr.Copy( fileName->Right(fileName->Length()-lastSlashPos-1) ); |
4283 namePtr.Copy( fileName->Right(fileName->Length()-lastSlashPos-1) ); |
4324 |
4284 |
4325 TInt findDot = iDlName->LocateReverse( '.' ); |
4285 TInt findDot = iDlName->LocateReverse( '.' ); |
4326 if( findDot == KErrNotFound ) |
4286 if( findDot == KErrNotFound ) |
4327 { |
4287 { |
4328 //if Name displayed does not have Extension then |
4288 //if Name displayed does not have Extension then |
4329 // Remove extention from retrieved name |
4289 // Remove extention from retrieved name |
4330 TInt dotInd = namePtr.LocateReverse( '.' ); |
4290 TInt dotInd = namePtr.LocateReverse( '.' ); |
4331 if( dotInd == KErrNotFound ) |
4291 if( dotInd == KErrNotFound ) |
4332 dotInd = namePtr.Length(); |
4292 dotInd = namePtr.Length(); |
4333 namePtr.Copy( namePtr.Left( dotInd ) ); |
4293 namePtr.Copy( namePtr.Left( dotInd ) ); |
4334 |
4294 |
4335 } |
4295 } |
4336 |
4296 |
4337 //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 |
4338 //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. |
4339 //related to bug HCHA-753D6G |
4299 //related to bug HCHA-753D6G |
4340 |
4300 |
4341 if(namePtr.Compare(*iDlName)) |
4301 if(namePtr.Compare(*iDlName)) |
4342 { |
4302 { |
4343 ReallocateStringL( iDlName, namePtr, KDownloadNameMaxSize ); |
4303 ReallocateStringL( iDlName, namePtr, KDownloadNameMaxSize ); |
4344 SetDownloadStatus( EHttpProgContentFileMovedAndDestFNChanged, EHttpDlMultipleMOCompleted ); |
4304 SetDownloadStatus( EHttpProgContentFileMovedAndDestFNChanged, EHttpDlMultipleMOCompleted ); |
4345 } |
4305 } |
4346 else |
4306 else |
4347 { |
4307 { |
4348 SetDownloadStatus( EHttpProgContentFileMoved, EHttpDlMultipleMOCompleted ); |
4308 SetDownloadStatus( EHttpProgContentFileMoved, EHttpDlMultipleMOCompleted ); |
4349 } |
4309 } |
4350 CleanupStack::PopAndDestroy( name ); |
4310 CleanupStack::PopAndDestroy( name ); |
4351 |
4311 |
4352 } |
4312 } |
4353 else |
4313 else |
4354 { |
4314 { |
4355 TriggerEvent( EHttpDlCompleted, EHttpProgNone ); |
4315 TriggerEvent( EHttpDlCompleted, EHttpProgNone ); |
4356 SetDownloadStatus( EHttpProgNone, EHttpDlMultipleMOCompleted ); |
4316 SetDownloadStatus( EHttpProgNone, EHttpDlMultipleMOCompleted ); |
4357 } |
4317 } |
4358 } |
4318 } |
4750 // ?implementation_description |
4710 // ?implementation_description |
4751 // (other items were commented in a header). |
4711 // (other items were commented in a header). |
4752 // ----------------------------------------------------------------------------- |
4712 // ----------------------------------------------------------------------------- |
4753 // |
4713 // |
4754 void CHttpDownload::ResponseBodyReceivedL( const TDesC8& aBuf ) |
4714 void CHttpDownload::ResponseBodyReceivedL( const TDesC8& aBuf ) |
4755 { |
4715 { |
4756 if( iMultiPart && !iCodDownload ) |
4716 if( iMultiPart && !iCodDownload ) |
4757 { |
4717 { |
4758 TBool isSupportedMultiPart( EFalse ); |
4718 TBool isSupportedMultiPart( EFalse ); |
4759 // If it leaves isSupportedMultiPart remains false -> does not supported! |
4719 // If it leaves isSupportedMultiPart remains false -> does not supported! |
4760 TRAP_IGNORE( isSupportedMultiPart = IsMultipartSupportedL( aBuf ) ); |
4720 TRAP_IGNORE( isSupportedMultiPart = IsMultipartSupportedL( aBuf ) ); |
4761 if( isSupportedMultiPart ) |
4721 if( isSupportedMultiPart ) |
4762 { |
4722 { |
4763 SetCodFlag( ETrue ); |
4723 SetCodFlag( ETrue ); |
4764 TriggerEvent( EHttpDlInprogress, EHttpProgSupportedMultiPart ); |
4724 TriggerEvent( EHttpDlInprogress, EHttpProgSupportedMultiPart ); |
4765 } |
4725 } |
4766 } |
4726 } |
4767 |
4727 |
4768 TBool ret(ETrue); |
4728 TBool ret(ETrue); |
4769 |
4729 |
4770 if( iStorage->BufferingEnabled() ) |
4730 if( iStorage->BufferingEnabled() ) |
4771 { |
4731 { |
4772 // Buffering is enabled, just pass on the data |
4732 // Buffering is enabled, just pass on the data |
4773 ret = iStorage->WriteOutNextBodyDataL(aBuf); |
4733 ret = iStorage->WriteOutNextBodyDataL(aBuf); |
4774 } |
4734 } |
4775 else |
4735 else |
4776 { |
4736 { |
4777 // 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 |
4778 TInt bytesToWrite = aBuf.Length(); |
4738 TInt bytesToWrite = aBuf.Length(); |
4779 TInt downloadedSize = iStorage->DownloadedSize(); |
4739 TInt downloadedSize = iStorage->DownloadedSize(); |
4780 |
4740 |
4781 if(bytesToWrite + downloadedSize < KMinDataSizeToSend) |
4741 if(bytesToWrite + downloadedSize < KMinDataSizeToSend) |
4782 { |
4742 { |
4783 // Just dump non-buffered write |
4743 // Just dump non-buffered write |
4784 ret = iStorage->WriteOutNextBodyDataL( aBuf ); |
4744 ret = iStorage->WriteOutNextBodyDataL( aBuf ); |
4785 } |
4745 } |
4786 else |
4746 else |
4787 { |
4747 { |
4788 // Necessary to switch to buffered writing |
4748 // Necessary to switch to buffered writing |
4789 |
4749 |
4790 TInt leftPartSize = KMinDataSizeToSend - downloadedSize; |
4750 TInt leftPartSize = KMinDataSizeToSend - downloadedSize; |
4791 TInt rightPartSize = bytesToWrite - leftPartSize; |
4751 TInt rightPartSize = bytesToWrite - leftPartSize; |
4792 |
4752 |
4793 TBool ret1 = ETrue; |
4753 TBool ret1 = ETrue; |
4794 TBool ret2 = ETrue; |
4754 TBool ret2 = ETrue; |
4795 |
4755 |
4796 if(leftPartSize > 0) |
4756 if(leftPartSize > 0) |
4797 { |
4757 { |
4798 // Write left side of the block to get alignment matched |
4758 // Write left side of the block to get alignment matched |
4799 ret1 = iStorage->WriteOutNextBodyDataL( aBuf.Left(leftPartSize) ); |
4759 ret1 = iStorage->WriteOutNextBodyDataL( aBuf.Left(leftPartSize) ); |
4800 } |
4760 } |
4801 |
4761 |
4802 // Enable buffering |
4762 // Enable buffering |
4803 iStorage->EnableBufferingL(); |
4763 iStorage->EnableBufferingL(); |
4804 |
4764 |
4805 // And push the rest of this data block |
4765 // And push the rest of this data block |
4806 if(rightPartSize > 0) |
4766 if(rightPartSize > 0) |
4807 { |
4767 { |
4808 ret2 = iStorage->WriteOutNextBodyDataL( aBuf.Right(rightPartSize) ); |
4768 ret2 = iStorage->WriteOutNextBodyDataL( aBuf.Right(rightPartSize) ); |
4809 } |
4769 } |
4810 |
4770 |
4811 if(!ret1 || !ret2) |
4771 if(!ret1 || !ret2) |
4812 { |
4772 { |
4813 ret = EFalse; |
4773 ret = EFalse; |
4814 } |
4774 } |
4815 } |
4775 } |
4851 else |
4811 else |
4852 { |
4812 { |
4853 ret = EFalse; |
4813 ret = EFalse; |
4854 return ret; |
4814 return ret; |
4855 } |
4815 } |
4856 |
4816 |
4857 TInt pos = iHeaderOfMultipart->Des().Find( KContentType() ); |
4817 TInt pos = iHeaderOfMultipart->Des().Find( KContentType() ); |
4858 |
4818 |
4859 User::LeaveIfError( pos ); |
4819 User::LeaveIfError( pos ); |
4860 |
4820 |
4861 pos = pos + KContentType().Length(); |
4821 pos = pos + KContentType().Length(); |
4862 |
4822 |
4863 TPtrC8 p = iHeaderOfMultipart->Des().Mid( pos ); |
4823 TPtrC8 p = iHeaderOfMultipart->Des().Mid( pos ); |
4864 TInt temp = p.Find( KDoubleEOL() ); |
4824 TInt temp = p.Find( KDoubleEOL() ); |
4865 |
4825 |
4866 TInt posEol = pos + temp; |
4826 TInt posEol = pos + temp; |
4867 |
4827 |
4868 TPtrC8 ptr = iHeaderOfMultipart->Des().Mid( pos, ( posEol - pos ) ); |
4828 TPtrC8 ptr = iHeaderOfMultipart->Des().Mid( pos, ( posEol - pos ) ); |
4869 if( 0 == ptr.Find( KDdMimeType() ) || |
4829 if( 0 == ptr.Find( KDdMimeType() ) || |
4870 0 == ptr.Find( KDd2MimeType() ) || |
4830 0 == ptr.Find( KDd2MimeType() ) || |
4871 0 == ptr.Find( KCodMimeType() )) |
4831 0 == ptr.Find( KCodMimeType() )) |
4872 { |
4832 { |
4873 ret = ETrue; |
4833 ret = ETrue; |
4874 delete iHeaderOfMultipart; |
4834 delete iHeaderOfMultipart; |
4875 iHeaderOfMultipart = NULL; |
4835 iHeaderOfMultipart = NULL; |
4876 return ret; |
4836 return ret; |
4877 } |
4837 } |
4878 |
4838 |
4879 return ret; |
4839 return ret; |
4880 } |
4840 } |
4881 |
4841 |
4882 // ----------------------------------------------------------------------------- |
4842 // ----------------------------------------------------------------------------- |
4883 // CHttpDownload::Connect |
4843 // CHttpDownload::Connect |
4884 // ?implementation_description |
4844 // ?implementation_description |
4956 |
4916 |
4957 SetRequestHeaderAddOnL( aStringPool, aHeaders ); |
4917 SetRequestHeaderAddOnL( aStringPool, aHeaders ); |
4958 SetCredentialsInfoL( aStringPool ); |
4918 SetCredentialsInfoL( aStringPool ); |
4959 |
4919 |
4960 // Find ETag in response header |
4920 // Find ETag in response header |
4961 RStringF etag = aStringPool.StringF(HTTP::EETag, |
4921 RStringF etag = aStringPool.StringF(HTTP::EETag, |
4962 RHTTPSession::GetTable()); |
4922 RHTTPSession::GetTable()); |
4963 TInt fieldInd = FindHeaderField( iResponseHeaders, etag.DesC() ); |
4923 TInt fieldInd = FindHeaderField( iResponseHeaders, etag.DesC() ); |
4964 if( fieldInd != KErrNotFound ) |
4924 if( fieldInd != KErrNotFound ) |
4965 // 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 |
4966 // 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. |
4967 // Server will respond with 412 on error. |
4927 // Server will respond with 412 on error. |
4968 { |
4928 { |
4969 RStringF ifMatch = aStringPool.StringF(HTTP::EIfMatch, |
4929 RStringF ifMatch = aStringPool.StringF(HTTP::EIfMatch, |
4970 RHTTPSession::GetTable()); |
4930 RHTTPSession::GetTable()); |
4971 aHeaders.RemoveField( ifMatch ); |
4931 aHeaders.RemoveField( ifMatch ); |
4972 aHeaders.SetRawFieldL( ifMatch, |
4932 aHeaders.SetRawFieldL( ifMatch, |
4973 *(*iResponseHeaders)[fieldInd]->FieldRawData(), |
4933 *(*iResponseHeaders)[fieldInd]->FieldRawData(), |
4974 KHttpFieldSeparator ); |
4934 KHttpFieldSeparator ); |
4975 CLOG_WRITE8_1( "ETag: %S", (*iResponseHeaders)[fieldInd]->FieldRawData() ); |
4935 CLOG_WRITE8_1( "ETag: %S", (*iResponseHeaders)[fieldInd]->FieldRawData() ); |
4976 } |
4936 } |
4977 |
4937 |
4978 if( aHeadMethod ) |
4938 if( aHeadMethod ) |
5048 // CHttpFilterAuthentication::SetPropertyL |
5008 // CHttpFilterAuthentication::SetPropertyL |
5049 // Set property of the transaction |
5009 // Set property of the transaction |
5050 // ----------------------------------------------------------------------------- |
5010 // ----------------------------------------------------------------------------- |
5051 // |
5011 // |
5052 void CHttpDownload::SetPropertyL( RStringPool& aStringPool, |
5012 void CHttpDownload::SetPropertyL( RStringPool& aStringPool, |
5053 RStringF aPropertyName, |
5013 RStringF aPropertyName, |
5054 const TDesC8& aToken ) |
5014 const TDesC8& aToken ) |
5055 { |
5015 { |
5056 RString tokenStr = aStringPool.OpenStringL( aToken ); |
5016 RString tokenStr = aStringPool.OpenStringL( aToken ); |
5057 THTTPHdrVal tokenVal = tokenStr; |
5017 THTTPHdrVal tokenVal = tokenStr; |
5058 CleanupClosePushL( tokenStr ); |
5018 CleanupClosePushL( tokenStr ); |
5138 { |
5098 { |
5139 LOGGER_ENTERFN( "SetCredentialsInfoL" ); |
5099 LOGGER_ENTERFN( "SetCredentialsInfoL" ); |
5140 |
5100 |
5141 if( iHttpUsername ) |
5101 if( iHttpUsername ) |
5142 { |
5102 { |
5143 RStringF username = aStringPool.StringF( HTTP::EUsername, |
5103 RStringF username = aStringPool.StringF( HTTP::EUsername, |
5144 RHTTPSession::GetTable() ); |
5104 RHTTPSession::GetTable() ); |
5145 |
5105 |
5146 SetPropertyL( aStringPool, username, *iHttpUsername ); |
5106 SetPropertyL( aStringPool, username, *iHttpUsername ); |
5147 } |
5107 } |
5148 |
5108 |
5149 if( iHttpPassword ) |
5109 if( iHttpPassword ) |
5150 { |
5110 { |
5151 RStringF password = aStringPool.StringF( HTTP::EPassword, |
5111 RStringF password = aStringPool.StringF( HTTP::EPassword, |
5152 RHTTPSession::GetTable() ); |
5112 RHTTPSession::GetTable() ); |
5153 |
5113 |
5154 SetPropertyL( aStringPool, password, *iHttpPassword ); |
5114 SetPropertyL( aStringPool, password, *iHttpPassword ); |
5155 } |
5115 } |
5156 |
5116 |
5157 if( iHttpRealm ) |
5117 if( iHttpRealm ) |
5158 { |
5118 { |
5159 RStringF realm = aStringPool.StringF( HTTP::ERealm, |
5119 RStringF realm = aStringPool.StringF( HTTP::ERealm, |
5160 RHTTPSession::GetTable() ); |
5120 RHTTPSession::GetTable() ); |
5161 SetPropertyL( aStringPool, realm, *iHttpRealm ); |
5121 SetPropertyL( aStringPool, realm, *iHttpRealm ); |
5162 } |
5122 } |
5163 |
5123 |
5164 if( iHttpProxyRealm ) |
5124 if( iHttpProxyRealm ) |
5165 { |
5125 { |
5166 RStringF proxyRealmStr = aStringPool.StringF( |
5126 RStringF proxyRealmStr = aStringPool.StringF( |
5167 HttpFilterCommonStringsExt::EProxyRealm, |
5127 HttpFilterCommonStringsExt::EProxyRealm, |
5168 HttpFilterCommonStringsExt::GetTable() ); |
5128 HttpFilterCommonStringsExt::GetTable() ); |
5169 SetPropertyL( aStringPool, proxyRealmStr, *iHttpProxyRealm ); |
5129 SetPropertyL( aStringPool, proxyRealmStr, *iHttpProxyRealm ); |
5170 } |
5130 } |
5171 |
5131 |
5172 if( iHttpProxyUsername ) |
5132 if( iHttpProxyUsername ) |
5173 { |
5133 { |
5174 RStringF proxyUsernameStr = aStringPool.StringF( |
5134 RStringF proxyUsernameStr = aStringPool.StringF( |
5175 HttpFilterCommonStringsExt::EProxyUsername, |
5135 HttpFilterCommonStringsExt::EProxyUsername, |
5176 HttpFilterCommonStringsExt::GetTable() ); |
5136 HttpFilterCommonStringsExt::GetTable() ); |
5177 SetPropertyL( aStringPool, proxyUsernameStr, *iHttpProxyUsername ); |
5137 SetPropertyL( aStringPool, proxyUsernameStr, *iHttpProxyUsername ); |
5178 } |
5138 } |
5179 |
5139 |
5180 if( iHttpProxyPassword ) |
5140 if( iHttpProxyPassword ) |
5181 { |
5141 { |
5182 RStringF proxyPasswordStr = aStringPool.StringF( |
5142 RStringF proxyPasswordStr = aStringPool.StringF( |
5183 HttpFilterCommonStringsExt::EProxyPassword, |
5143 HttpFilterCommonStringsExt::EProxyPassword, |
5184 HttpFilterCommonStringsExt::GetTable() ); |
5144 HttpFilterCommonStringsExt::GetTable() ); |
5185 SetPropertyL( aStringPool, proxyPasswordStr, *iHttpProxyPassword ); |
5145 SetPropertyL( aStringPool, proxyPasswordStr, *iHttpProxyPassword ); |
5186 } |
5146 } |
5187 |
5147 |
5188 if( iHttpNonce ) |
5148 if( iHttpNonce ) |
5189 { |
5149 { |
5190 RStringF nonce = aStringPool.StringF( HTTP::ENonce, |
5150 RStringF nonce = aStringPool.StringF( HTTP::ENonce, |
5191 RHTTPSession::GetTable() ); |
5151 RHTTPSession::GetTable() ); |
5192 |
5152 |
5193 SetPropertyL( aStringPool, nonce, *iHttpNonce ); |
5153 SetPropertyL( aStringPool, nonce, *iHttpNonce ); |
5194 } |
5154 } |
5195 } |
5155 } |
5259 if( expInd != KErrNotFound ) |
5219 if( expInd != KErrNotFound ) |
5260 { |
5220 { |
5261 CLOG_WRITE8_1( "Expire: %S", (*iResponseHeaders)[expInd]->FieldRawData() ); |
5221 CLOG_WRITE8_1( "Expire: %S", (*iResponseHeaders)[expInd]->FieldRawData() ); |
5262 |
5222 |
5263 aHeaders.RemoveField( aField ); |
5223 aHeaders.RemoveField( aField ); |
5264 aHeaders.SetRawFieldL( aField, |
5224 aHeaders.SetRawFieldL( aField, |
5265 *(*iResponseHeaders)[expInd]->FieldRawData(), |
5225 *(*iResponseHeaders)[expInd]->FieldRawData(), |
5266 KHttpFieldSeparator ); |
5226 KHttpFieldSeparator ); |
5267 } |
5227 } |
5268 else if( modInd != KErrNotFound ) |
5228 else if( modInd != KErrNotFound ) |
5269 { |
5229 { |
5270 CLOG_WRITE8_1( "LastMod: %S", (*iResponseHeaders)[modInd]->FieldRawData() ); |
5230 CLOG_WRITE8_1( "LastMod: %S", (*iResponseHeaders)[modInd]->FieldRawData() ); |
5271 |
5231 |
5272 aHeaders.RemoveField( aField ); |
5232 aHeaders.RemoveField( aField ); |
5273 aHeaders.SetRawFieldL( aField, |
5233 aHeaders.SetRawFieldL( aField, |
5274 *(*iResponseHeaders)[modInd]->FieldRawData(), |
5234 *(*iResponseHeaders)[modInd]->FieldRawData(), |
5275 KHttpFieldSeparator ); |
5235 KHttpFieldSeparator ); |
5276 } |
5236 } |
5277 } |
5237 } |
5278 |
5238 |
5279 // ----------------------------------------------------------------------------- |
5239 // ----------------------------------------------------------------------------- |
5286 { |
5246 { |
5287 LOGGER_ENTERFN( "ParseRequestedUrlL" ); |
5247 LOGGER_ENTERFN( "ParseRequestedUrlL" ); |
5288 |
5248 |
5289 __ASSERT_DEBUG( iUrl->Length(), DMPanic( KErrArgument ) ); |
5249 __ASSERT_DEBUG( iUrl->Length(), DMPanic( KErrArgument ) ); |
5290 |
5250 |
5291 TUriParser8 uri; |
5251 TUriParser8 uri; |
5292 uri.Parse( *iUrl ); |
5252 uri.Parse( *iUrl ); |
5293 |
5253 |
5294 TPtrC8 scheme( uri.Extract( EUriScheme ) ); |
5254 TPtrC8 scheme( uri.Extract( EUriScheme ) ); |
5295 |
5255 |
5296 if( scheme != KHttpScheme && |
5256 if( scheme != KHttpScheme && |
5297 scheme != KHttpsScheme ) |
5257 scheme != KHttpsScheme ) |
5298 // unsupported or no scheme in url. |
5258 // unsupported or no scheme in url. |
5299 // Insert 'http://' to the beginning of it. |
5259 // Insert 'http://' to the beginning of it. |
5300 { |
5260 { |
5301 HBufC8* tempBuf = HBufC8::NewL( KHttpScheme().Length() + |
5261 HBufC8* tempBuf = HBufC8::NewL( KHttpScheme().Length() + |
5302 KSchemeAddon().Length() + |
5262 KSchemeAddon().Length() + |
5303 iUrl->Length() ); |
5263 iUrl->Length() ); |
5304 |
5264 |
5305 tempBuf->Des().Append( KHttpScheme ); |
5265 tempBuf->Des().Append( KHttpScheme ); |
5306 tempBuf->Des().Append( KSchemeAddon ); |
5266 tempBuf->Des().Append( KSchemeAddon ); |
5307 tempBuf->Des().Append( *iUrl ); |
5267 tempBuf->Des().Append( *iUrl ); |
5319 url->SetComponentL( uri.Extract( EUriHost ), EUriHost ); |
5279 url->SetComponentL( uri.Extract( EUriHost ), EUriHost ); |
5320 url->SetComponentL( uri.Extract( EUriPath ), EUriPath ); |
5280 url->SetComponentL( uri.Extract( EUriPath ), EUriPath ); |
5321 url->SetComponentL( uri.Extract( EUriUserinfo ), EUriUserinfo ); |
5281 url->SetComponentL( uri.Extract( EUriUserinfo ), EUriUserinfo ); |
5322 url->SetComponentL( uri.Extract( EUriQuery ), EUriQuery ); |
5282 url->SetComponentL( uri.Extract( EUriQuery ), EUriQuery ); |
5323 url->SetComponentL( uri.Extract( EUriFragment ), EUriFragment ); |
5283 url->SetComponentL( uri.Extract( EUriFragment ), EUriFragment ); |
5324 |
5284 |
5325 if( uri.IsPresent( EUriPort ) ) |
5285 if( uri.IsPresent( EUriPort ) ) |
5326 { |
5286 { |
5327 url->SetComponentL( uri.Extract( EUriPort ), EUriPort ); |
5287 url->SetComponentL( uri.Extract( EUriPort ), EUriPort ); |
5328 } |
5288 } |
5329 else |
5289 else |
5453 CHeaderField* field = CHeaderField::NewL( &fieldNameStr.DesC(), &rawData ); |
5413 CHeaderField* field = CHeaderField::NewL( &fieldNameStr.DesC(), &rawData ); |
5454 CleanupStack::PushL( field ); |
5414 CleanupStack::PushL( field ); |
5455 |
5415 |
5456 CLOG_WRITE8_2("%S:%S", &fieldNameStr.DesC(), &rawData); |
5416 CLOG_WRITE8_2("%S:%S", &fieldNameStr.DesC(), &rawData); |
5457 iResponseHeaders->AppendL( field ); |
5417 iResponseHeaders->AppendL( field ); |
5458 |
5418 |
5459 CleanupStack::Pop( field ); |
5419 CleanupStack::Pop( field ); |
5460 |
5420 |
5461 CHeaderField* entityField = CHeaderField::NewL( &fieldNameStr.DesC(), &rawData ); |
5421 CHeaderField* entityField = CHeaderField::NewL( &fieldNameStr.DesC(), &rawData ); |
5462 CleanupStack::PushL( entityField ); |
5422 CleanupStack::PushL( entityField ); |
5463 |
5423 |
5464 CLOG_WRITE8_2("%S:%S", &fieldNameStr.DesC(), &rawData); |
5424 CLOG_WRITE8_2("%S:%S", &fieldNameStr.DesC(), &rawData); |
5465 iEntityHeaders->AppendL( entityField ); |
5425 iEntityHeaders->AppendL( entityField ); |
5466 |
5426 |
5467 CleanupStack::Pop( entityField ); |
5427 CleanupStack::Pop( entityField ); |
5468 |
5428 |
5469 ++it; |
5429 ++it; |
5470 } |
5430 } |
5471 |
5431 |
5472 ParseContentTypeL( strPool ); |
5432 ParseContentTypeL( strPool ); |
5473 |
5433 |
5474 ParseContentDispositionL( strPool); |
5434 ParseContentDispositionL( strPool); |
5475 if (!iCodDownload) |
5435 if (!iCodDownload) |
5476 { |
5436 { |
5477 if (iUseAttachmentFileName || iUseInlineFileName) |
5437 if (iUseAttachmentFileName || iUseInlineFileName) |
5478 { |
5438 { |
5613 // |
5573 // |
5614 void CHttpDownload::SaveCredentialsL( RStringPool aStringPool ) |
5574 void CHttpDownload::SaveCredentialsL( RStringPool aStringPool ) |
5615 { |
5575 { |
5616 LOGGER_ENTERFN( "SaveCredentialsL" ); |
5576 LOGGER_ENTERFN( "SaveCredentialsL" ); |
5617 |
5577 |
5618 RStringF username = aStringPool.StringF( HTTP::EUsername, |
5578 RStringF username = aStringPool.StringF( HTTP::EUsername, |
5619 RHTTPSession::GetTable() ); |
5579 RHTTPSession::GetTable() ); |
5620 RStringF password = aStringPool.StringF( HTTP::EPassword, |
5580 RStringF password = aStringPool.StringF( HTTP::EPassword, |
5621 RHTTPSession::GetTable() ); |
5581 RHTTPSession::GetTable() ); |
5622 RStringF realm = aStringPool.StringF( HTTP::ERealm, |
5582 RStringF realm = aStringPool.StringF( HTTP::ERealm, |
5623 RHTTPSession::GetTable() ); |
5583 RHTTPSession::GetTable() ); |
5624 RStringF nonce = aStringPool.StringF( HTTP::ENonce, |
5584 RStringF nonce = aStringPool.StringF( HTTP::ENonce, |
5625 RHTTPSession::GetTable() ); |
5585 RHTTPSession::GetTable() ); |
5626 |
5586 |
5627 THTTPHdrVal hdrValue; |
5587 THTTPHdrVal hdrValue; |
5628 |
5588 |
5629 // Realm |
5589 // Realm |
5647 { |
5607 { |
5648 ReallocateStringL( iHttpPassword, hdrValue.Str().DesC(), KMaxDefAttrLength ); |
5608 ReallocateStringL( iHttpPassword, hdrValue.Str().DesC(), KMaxDefAttrLength ); |
5649 CLOG_WRITE8_1( "pwd: [%S]", iHttpPassword ); |
5609 CLOG_WRITE8_1( "pwd: [%S]", iHttpPassword ); |
5650 } |
5610 } |
5651 |
5611 |
5652 if( !iTrans.PropertySet().Property( |
5612 if( !iTrans.PropertySet().Property( |
5653 aStringPool.StringF( HTTP::EBasic, |
5613 aStringPool.StringF( HTTP::EBasic, |
5654 RHTTPSession::GetTable() ), |
5614 RHTTPSession::GetTable() ), |
5655 hdrValue ) ) |
5615 hdrValue ) ) |
5656 // this is a digest authentication response |
5616 // this is a digest authentication response |
5657 // store nonce value |
5617 // store nonce value |
5658 { |
5618 { |
5659 if( iTrans.PropertySet().Property( nonce, hdrValue ) ) |
5619 if( iTrans.PropertySet().Property( nonce, hdrValue ) ) |
6373 // CHttpDownload::CheckAttribMaxLengthL |
6333 // CHttpDownload::CheckAttribMaxLengthL |
6374 // ?implementation_description |
6334 // ?implementation_description |
6375 // (other items were commented in a header). |
6335 // (other items were commented in a header). |
6376 // ----------------------------------------------------------------------------- |
6336 // ----------------------------------------------------------------------------- |
6377 // |
6337 // |
6378 void CHttpDownload::CheckAttribMaxLengthL( THttpDownloadAttrib aAttribute, |
6338 void CHttpDownload::CheckAttribMaxLengthL( THttpDownloadAttrib aAttribute, |
6379 const TDesC16& aValue ) |
6339 const TDesC16& aValue ) |
6380 { |
6340 { |
6381 for( TInt i = 0; KStringAttribMaxLengths[i][0]; ++i ) |
6341 for( TInt i = 0; KStringAttribMaxLengths[i][0]; ++i ) |
6382 { |
6342 { |
6383 if( aAttribute == KStringAttribMaxLengths[i][0] ) |
6343 if( aAttribute == KStringAttribMaxLengths[i][0] ) |
6384 { |
6344 { |
6385 if( aValue.Length() > KStringAttribMaxLengths[i][1] ) |
6345 if( aValue.Length() > KStringAttribMaxLengths[i][1] ) |
6386 { |
6346 { |
6387 CLOG_WRITE_2( "Overflow length: %d, max-length: %d", aValue.Length(), |
6347 CLOG_WRITE_2( "Overflow length: %d, max-length: %d", aValue.Length(), |
6388 KStringAttribMaxLengths[i][1] ); |
6348 KStringAttribMaxLengths[i][1] ); |
6389 User::Leave( KErrOverflow ); |
6349 User::Leave( KErrOverflow ); |
6390 } |
6350 } |
6391 } |
6351 } |
6392 } |
6352 } |
6396 // CHttpDownload::CheckAttribMaxLengthL |
6356 // CHttpDownload::CheckAttribMaxLengthL |
6397 // ?implementation_description |
6357 // ?implementation_description |
6398 // (other items were commented in a header). |
6358 // (other items were commented in a header). |
6399 // ----------------------------------------------------------------------------- |
6359 // ----------------------------------------------------------------------------- |
6400 // |
6360 // |
6401 void CHttpDownload::CheckAttribMaxLengthL( THttpDownloadAttrib aAttribute, |
6361 void CHttpDownload::CheckAttribMaxLengthL( THttpDownloadAttrib aAttribute, |
6402 const TDesC8& aValue ) |
6362 const TDesC8& aValue ) |
6403 { |
6363 { |
6404 for( TInt i = 0; KStringAttribMaxLengths[i][0]; ++i ) |
6364 for( TInt i = 0; KStringAttribMaxLengths[i][0]; ++i ) |
6405 { |
6365 { |
6406 if( aAttribute == KStringAttribMaxLengths[i][0] ) |
6366 if( aAttribute == KStringAttribMaxLengths[i][0] ) |
6407 { |
6367 { |
6408 if( aValue.Length() > KStringAttribMaxLengths[i][1] ) |
6368 if( aValue.Length() > KStringAttribMaxLengths[i][1] ) |
6409 { |
6369 { |
6410 CLOG_WRITE_2( "Overflow length: %d, max-length: %d", aValue.Length(), |
6370 CLOG_WRITE_2( "Overflow length: %d, max-length: %d", aValue.Length(), |
6411 KStringAttribMaxLengths[i][1] ); |
6371 KStringAttribMaxLengths[i][1] ); |
6412 User::Leave( KErrOverflow ); |
6372 User::Leave( KErrOverflow ); |
6413 } |
6373 } |
6414 } |
6374 } |
6415 } |
6375 } |
6599 TInt headers = aHeaders->Count(); |
6559 TInt headers = aHeaders->Count(); |
6600 CLOG_WRITE_1("Headers: %d", headers); |
6560 CLOG_WRITE_1("Headers: %d", headers); |
6601 |
6561 |
6602 HBufC8* fieldName = NULL; |
6562 HBufC8* fieldName = NULL; |
6603 HBufC8* fieldRawData = NULL; |
6563 HBufC8* fieldRawData = NULL; |
6604 |
6564 |
6605 TInt size = 0; |
6565 TInt size = 0; |
6606 |
6566 |
6607 for( TInt i = 0; i < headers; ++i ) |
6567 for( TInt i = 0; i < headers; ++i ) |
6608 { |
6568 { |
6609 fieldName = (*aHeaders)[i]->FieldName(); |
6569 fieldName = (*aHeaders)[i]->FieldName(); |
6610 fieldRawData = (*aHeaders)[i]->FieldRawData(); |
6570 fieldRawData = (*aHeaders)[i]->FieldRawData(); |
6611 |
6571 |
6612 size = size + fieldName->Size() + fieldRawData->Size(); |
6572 size = size + fieldName->Size() + fieldRawData->Size(); |
6613 |
6573 |
6614 CLOG_WRITE8_1( "Size = %d:", size ); |
6574 CLOG_WRITE8_1( "Size = %d:", size ); |
6615 } |
6575 } |
6616 |
6576 |
6617 return size; |
6577 return size; |
6618 |
6578 |
6619 } |
6579 } |
6620 |
6580 |
6621 |
6581 |
6622 // ----------------------------------------------------------------------------- |
6582 // ----------------------------------------------------------------------------- |
6623 // CHttpDownload::AddHeaderL |
6583 // CHttpDownload::AddHeaderL |
6624 // ----------------------------------------------------------------------------- |
6584 // ----------------------------------------------------------------------------- |
6625 // |
6585 // |
6626 void CHttpDownload::AddHeaderL( THttpDownloadAttrib aAttribute, |
6586 void CHttpDownload::AddHeaderL( THttpDownloadAttrib aAttribute, |
6627 const TDesC8& aValue, |
6587 const TDesC8& aValue, |
6628 const TInt aConversionTable[][2], |
6588 const TInt aConversionTable[][2], |
6629 CArrayPtrFlat<CHeaderField>* aHeaders ) |
6589 CArrayPtrFlat<CHeaderField>* aHeaders ) |
6630 { |
6590 { |
6631 TInt index( KErrNotFound ); |
6591 TInt index( KErrNotFound ); |
6632 |
6592 |
6633 // search for if this field is already in the |
6593 // search for if this field is already in the |
6634 for( index = 0; aConversionTable[index][0]; ++index ) |
6594 for( index = 0; aConversionTable[index][0]; ++index ) |
6635 { |
6595 { |
6636 if( aConversionTable[index][0] == aAttribute ) |
6596 if( aConversionTable[index][0] == aAttribute ) |
6637 { |
6597 { |
6638 break; |
6598 break; |
6697 ParseDownloadNameL(); |
6657 ParseDownloadNameL(); |
6698 StoreDownloadInfoL(); // to store iRedirect |
6658 StoreDownloadInfoL(); // to store iRedirect |
6699 |
6659 |
6700 TriggerEvent( EHttpDlInprogress, EHttpProgRedirectedTemporarily ); |
6660 TriggerEvent( EHttpDlInprogress, EHttpProgRedirectedTemporarily ); |
6701 } |
6661 } |
6702 |
6662 |
6703 // ----------------------------------------------------------------------------- |
6663 // ----------------------------------------------------------------------------- |
6704 // CHttpDownload::FixDownloadNameL |
6664 // CHttpDownload::FixDownloadNameL |
6705 // ----------------------------------------------------------------------------- |
6665 // ----------------------------------------------------------------------------- |
6706 // |
6666 // |
6707 void CHttpDownload::FixDownloadNameL() |
6667 void CHttpDownload::FixDownloadNameL() |
6708 { |
6668 { |
6709 if( !iCodDownload ) |
6669 if( !iCodDownload ) |
6710 { |
6670 { |
6711 TPtr name( iDlName->Des() ); |
6671 TPtr name( iDlName->Des() ); |
6712 |
6672 |
6713 for( TInt i = 0; i < name.Length(); ++i ) |
6673 for( TInt i = 0; i < name.Length(); ++i ) |
6714 { |
6674 { |
6715 TChar currChar = (*iDlName)[i]; |
6675 TChar currChar = (*iDlName)[i]; |
6716 |
6676 |
6717 if( currChar.IsAlphaDigit() || |
6677 if( currChar.IsAlphaDigit() || |
6718 currChar.IsGraph() || |
6678 currChar.IsGraph() || |
6719 currChar == 0x20 ) // space |
6679 currChar == 0x20 ) // space |
6720 { |
6680 { |
6721 continue; |
6681 continue; |
6722 } |
6682 } |
6723 else |
6683 else |
6724 { |
6684 { |
6725 name[i] = KUrlFixChar; |
6685 name[i] = KUrlFixChar; |
6726 } |
6686 } |
6727 } |
6687 } |
6728 |
6688 |
6729 ConvertDownloadNameUniqueL(); |
6689 ConvertDownloadNameUniqueL(); |
6730 } |
6690 } |
6731 } |
6691 } |
6732 |
6692 |
6733 // ----------------------------------------------------------------------------- |
6693 // ----------------------------------------------------------------------------- |
6782 TInt drive( EDriveC ); |
6742 TInt drive( EDriveC ); |
6783 TBool criticalSpace( EFalse ); |
6743 TBool criticalSpace( EFalse ); |
6784 TBool needToUpdatePath( ETrue ); |
6744 TBool needToUpdatePath( ETrue ); |
6785 |
6745 |
6786 CLOG_WRITE_1( " entering fileName: %S", fileName ); |
6746 CLOG_WRITE_1( " entering fileName: %S", fileName ); |
6787 #ifdef DOWNLOADMGR_PATH_PLUGIN_ENABLED_FF |
|
6788 CDownloadPathHandler* downloadPathPlugin = NULL; |
|
6789 downloadPathPlugin = GetDownloadPathPluginInstanceL(); |
|
6790 if( downloadPathPlugin ) |
|
6791 { |
|
6792 CleanupStack::PushL( downloadPathPlugin ); |
|
6793 } |
|
6794 #endif |
|
6795 #ifdef RD_MULTIPLE_DRIVE |
6747 #ifdef RD_MULTIPLE_DRIVE |
6796 HBufC8* drivesDynList = iClientApp->Engine()->QueryDynDriveListLC(); |
6748 HBufC8* drivesDynList = iClientApp->Engine()->QueryDynDriveListLC(); |
6797 TPtrC8 drives( *drivesDynList ); |
6749 TPtrC8 drives( *drivesDynList ); |
6798 #else |
6750 #else |
6799 TPtrC drives( iClientApp->Engine()->iDriveLettersCenRep ); |
6751 TPtrC drives( iClientApp->Engine()->iDriveLettersCenRep ); |
6800 #endif |
6752 #endif |
6801 // drive letters are separated by semicolons |
6753 // drive letters are separated by semicolons |
6802 for( TInt i = 0; i < drives.Length() && (err || !criticalSpace); i = i + 2 ) |
6754 for( TInt i = 0; i < drives.Length() && (err || !criticalSpace); i = i + 2 ) |
6803 { |
6755 { |
6804 if( ( err = fs.CharToDrive( drives[i], drive )) != KErrNone ) |
6756 if( ( err = fs.CharToDrive( drives[i], drive )) != KErrNone ) |
6805 { |
6757 { |
6806 continue; |
6758 continue; |
6807 } |
6759 } |
6808 if( drive == currentDrive || iStorage->DestFNameSet())//if the current path is same as the path in cenrep then no need to update.The diff is because we must have not known size before hand |
6760 if( drive == currentDrive )//if the current path is same as the path in cenrep then no need to update.The diff is because we must have not known size before hand |
6809 { |
6761 { |
6810 #ifdef DOWNLOADMGR_PATH_PLUGIN_ENABLED_FF |
|
6811 if( !downloadPathPlugin ) |
|
6812 { |
|
6813 needToUpdatePath = EFalse; |
|
6814 } |
|
6815 #else |
|
6816 needToUpdatePath = EFalse; |
6762 needToUpdatePath = EFalse; |
6817 #endif |
|
6818 break; |
6763 break; |
6819 } |
6764 } |
6820 else |
6765 else |
6821 { |
6766 { |
6822 TInt bytesToWrite = downloadedSize; |
6767 TInt bytesToWrite = downloadedSize; |
6823 if (bytesToWrite < 0) |
6768 if (bytesToWrite < 0) |
6824 bytesToWrite = 0; |
6769 bytesToWrite = 0; |
6825 |
6770 |
6826 TRAP( err, criticalSpace = !SysUtil::DiskSpaceBelowCriticalLevelL( |
6771 TRAP( err, criticalSpace = !SysUtil::DiskSpaceBelowCriticalLevelL( |
6827 &fs, bytesToWrite, drive )); |
6772 &fs, bytesToWrite, drive )); |
6828 } |
6773 } |
6829 } |
6774 } |
6830 if( needToUpdatePath ) |
6775 if( needToUpdatePath ) |
6831 { |
6776 { |
6832 iDlNameChanged = ETrue; |
6777 iDlNameChanged = ETrue; |
6833 #ifdef RD_MULTIPLE_DRIVE |
6778 #ifdef RD_MULTIPLE_DRIVE |
6845 if( lastSlashPos != KErrNotFound ) |
6790 if( lastSlashPos != KErrNotFound ) |
6846 { |
6791 { |
6847 fileNamePtr.Delete( 0, lastSlashPos ); |
6792 fileNamePtr.Delete( 0, lastSlashPos ); |
6848 } |
6793 } |
6849 } |
6794 } |
6850 |
6795 |
6851 // Setting RootPath for new Destination file |
6796 // Setting RootPath for new Destination file |
6852 fileNamePtr.Insert( 0, rootPath ); |
6797 fileNamePtr.Insert( 0, rootPath ); |
6853 #ifdef DOWNLOADMGR_PATH_PLUGIN_ENABLED_FF |
|
6854 if( downloadPathPlugin ) |
|
6855 { |
|
6856 GetUpdatedPathFromPluginL(downloadPathPlugin,rootPath,fileNamePtr); |
|
6857 } |
|
6858 else |
|
6859 { |
|
6860 // Setting KDownloadPath |
|
6861 fileNamePtr.Insert( rootPath.Length(), KDownloadPath ); |
|
6862 } |
|
6863 #else |
|
6864 // Setting KDownloadPath |
6798 // Setting KDownloadPath |
6865 fileNamePtr.Insert( rootPath.Length(), KDownloadPath ); |
6799 fileNamePtr.Insert( rootPath.Length(), KDownloadPath ); |
6866 |
|
6867 #endif |
|
6868 |
|
6869 #else |
6800 #else |
6870 TChar driveChar; |
6801 TChar driveChar; |
6871 fs.DriveToChar(drive, driveChar); |
6802 fs.DriveToChar(drive, driveChar); |
6872 TBuf<2> buf; |
6803 TBuf<2> buf; |
6873 buf.Append(driveChar); |
6804 buf.Append(driveChar); |
6879 User::Leave( err ); |
6810 User::Leave( err ); |
6880 } |
6811 } |
6881 } |
6812 } |
6882 CLOG_WRITE_1( " exiting fileName: %S", fileName ); |
6813 CLOG_WRITE_1( " exiting fileName: %S", fileName ); |
6883 #ifdef RD_MULTIPLE_DRIVE |
6814 #ifdef RD_MULTIPLE_DRIVE |
6884 CleanupStack::PopAndDestroy( drivesDynList ); |
6815 CleanupStack::PopAndDestroy( drivesDynList ); |
6885 #endif |
|
6886 |
|
6887 #ifdef DOWNLOADMGR_PATH_PLUGIN_ENABLED_FF |
|
6888 if(downloadPathPlugin) |
|
6889 { |
|
6890 CleanupStack::PopAndDestroy( downloadPathPlugin ); |
|
6891 } |
|
6892 #endif |
6816 #endif |
6893 CleanupStack::PopAndDestroy( &fs ); |
6817 CleanupStack::PopAndDestroy( &fs ); |
6894 } |
6818 } |
6895 |
6819 |
6896 // --------------------------------------------------------- |
6820 // --------------------------------------------------------- |
6897 // CHttpDownload::UpdateDCFRepositoryL() |
6821 // CHttpDownload::UpdateDCFRepositoryL() |
6898 // Update saved file to DCFRepository |
6822 // Update saved file to DCFRepository |
6899 // --------------------------------------------------------- |
6823 // --------------------------------------------------------- |
6900 // |
6824 // |
6901 void CHttpDownload::UpdateDCFRepositoryL( |
6825 void CHttpDownload::UpdateDCFRepositoryL( |
6902 const TDesC& aFileName ) |
6826 const TDesC& aFileName ) |
6903 { |
6827 { |
6904 LOGGER_ENTERFN( "UpdateDCFRepositoryL" ); |
6828 LOGGER_ENTERFN( "UpdateDCFRepositoryL" ); |
6905 CLOG_WRITE_1( " :UpdateDCFRepositoryL() for: %S", &aFileName ); |
6829 CLOG_WRITE_1( " :UpdateDCFRepositoryL() for: %S", &aFileName ); |
6906 CDcfEntry* dcfEntry = NULL; |
6830 CDcfEntry* dcfEntry = NULL; |
6907 dcfEntry = CDcfEntry::NewL(); |
6831 dcfEntry = CDcfEntry::NewL(); |
6908 CleanupStack::PushL( dcfEntry ); |
6832 CleanupStack::PushL( dcfEntry ); |
6909 |
6833 |
6910 CDcfRep* dcfRep = NULL; |
6834 CDcfRep* dcfRep = NULL; |
6911 dcfRep = CDcfRep::NewL(); |
6835 dcfRep = CDcfRep::NewL(); |
6912 CleanupStack::PushL( dcfRep ); |
6836 CleanupStack::PushL( dcfRep ); |
6913 |
6837 |
6914 dcfEntry->SetLocationL( aFileName, 0 ); |
6838 dcfEntry->SetLocationL( aFileName, 0 ); |
6915 CLOG_WRITE(" : SetLocationL OK"); |
6839 CLOG_WRITE(" : SetLocationL OK"); |
6916 dcfRep->UpdateL( dcfEntry ); |
6840 dcfRep->UpdateL( dcfEntry ); |
6917 CLOG_WRITE(" :UpdateL OK"); |
6841 CLOG_WRITE(" :UpdateL OK"); |
6918 CleanupStack::PopAndDestroy(2); // dcfEntry, dcfRep |
6842 CleanupStack::PopAndDestroy(2); // dcfEntry, dcfRep |
6919 } |
6843 } |
6920 |
6844 |
6921 // ----------------------------------------------------------------------------- |
6845 // ----------------------------------------------------------------------------- |
6922 // CHttpDownload::MoveInDeleteL |
6846 // CHttpDownload::MoveInDeleteL |
6923 // ?implementation_description |
6847 // ?implementation_description |
6924 // (other items were commented in a header). |
6848 // (other items were commented in a header). |
6953 { |
6877 { |
6954 LOGGER_ENTERFN( "MoveDownloadedMediaObjectsL" ); |
6878 LOGGER_ENTERFN( "MoveDownloadedMediaObjectsL" ); |
6955 |
6879 |
6956 if( iDlState != EHttpDlMultipleMOCompleted && !iMoDownloadCompleted ) |
6880 if( iDlState != EHttpDlMultipleMOCompleted && !iMoDownloadCompleted ) |
6957 { |
6881 { |
6958 iStorage->SetProgressiveMode( EFalse ); |
6882 iStorage->SetProgressiveMode( EFalse ); |
6959 TriggerEvent( iDlState, EHttpDlProgNonProgressive); |
6883 TriggerEvent( iDlState, EHttpDlProgNonProgressive); |
6960 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 |
6961 } |
6885 } |
6962 |
6886 |
6963 //__ASSERT_DEBUG( !IsActive(), DMPanic( KErrInUse ) ); |
6887 //__ASSERT_DEBUG( !IsActive(), DMPanic( KErrInUse ) ); |
6964 //__ASSERT_DEBUG( !iFileMan, DMPanic( KErrInUse ) ); |
6888 //__ASSERT_DEBUG( !iFileMan, DMPanic( KErrInUse ) ); |
6965 |
6889 |
6966 #if 0 |
6890 #if 0 |
6967 |
6891 |
6968 #else |
6892 #else |
6969 |
6893 |
6970 HBufC* filename = HBufC::NewLC(KMaxFileName); |
6894 HBufC* filename = HBufC::NewLC(KMaxFileName); |
6971 TPtr filenamePtr1 = filename->Des(); |
6895 TPtr filenamePtr1 = filename->Des(); |
6972 |
6896 |
6973 RFs &fs = iClientApp->Engine()->Fs(); |
6897 RFs &fs = iClientApp->Engine()->Fs(); |
6974 if(!iFileMan) |
6898 if(!iFileMan) |
6975 { |
6899 { |
6976 iFileMan = CFileMan::NewL(fs); |
6900 iFileMan = CFileMan::NewL(fs); |
6977 } |
6901 } |
6978 |
6902 |
6979 TPtrC filenamePtr2 = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
6903 TPtrC filenamePtr2 = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
6980 if(!filenamePtr2.Length()) |
6904 if(!filenamePtr2.Length()) |
6981 { |
6905 { |
6982 CleanupStack::PopAndDestroy(filename); |
6906 CleanupStack::PopAndDestroy(filename); |
6983 return; |
6907 return; |
6984 } |
6908 } |
6985 |
6909 |
6986 TInt firstSlashPos = filenamePtr2.Locate( '\\' ); |
6910 TInt firstSlashPos = filenamePtr2.Locate( '\\' ); |
6987 |
6911 |
6988 if(firstSlashPos < 0) |
6912 if(firstSlashPos < 0) |
6989 { |
6913 { |
6990 CleanupStack::PopAndDestroy(filename); |
6914 CleanupStack::PopAndDestroy(filename); |
6991 return; |
6915 return; |
6992 } |
6916 } |
6993 TPtrC dlName = filenamePtr2.Left(firstSlashPos); |
6917 TPtrC dlName = filenamePtr2.Left(firstSlashPos); |
6994 |
6918 |
6995 TInt drive; |
6919 TInt drive; |
6996 |
6920 |
6997 User::LeaveIfError( fs.CharToDrive( dlName[0], drive )); |
6921 User::LeaveIfError( fs.CharToDrive( dlName[0], drive )); |
6998 |
6922 |
6999 |
6923 |
7000 // Getting RootPath for selected Drive |
6924 // Getting RootPath for selected Drive |
7001 TFileName rootPath; |
6925 TFileName rootPath; |
7008 filenamePtr1.Append(_L("\\")); |
6932 filenamePtr1.Append(_L("\\")); |
7009 |
6933 |
7010 TInt error = fs.MkDirAll(filenamePtr1); |
6934 TInt error = fs.MkDirAll(filenamePtr1); |
7011 if (error!=KErrNone && error!=KErrAlreadyExists) |
6935 if (error!=KErrNone && error!=KErrAlreadyExists) |
7012 { |
6936 { |
7013 User::Leave(error); |
6937 User::Leave(error); |
7014 } |
6938 } |
7015 if( mediaObjectIndex == iActivePlayedDownload ) |
6939 if( mediaObjectIndex == iActivePlayedDownload ) |
7016 { |
6940 { |
7017 |
6941 |
7018 iFname = ((*iCodDlData)[mediaObjectIndex])->TempFilename(); |
6942 iFname = ((*iCodDlData)[mediaObjectIndex])->TempFilename(); |
7019 } |
6943 } |
7020 |
6944 |
7021 else |
6945 else |
7022 { |
6946 { |
7023 |
6947 |
7024 iFname = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
6948 iFname = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
7025 } |
6949 } |
7026 // Find a unique name to avoid any conflict. |
6950 // Find a unique name to avoid any conflict. |
7027 // Here iFname has full path of current location of file |
6951 // Here iFname has full path of current location of file |
7028 // and filename has destination path. |
6952 // and filename has destination path. |
7029 FindUniqueDestinationFileNameL( iFname, filename ); |
6953 FindUniqueDestinationFileNameL( iFname, filename ); |
7030 |
6954 |
7031 filenamePtr1 = filename->Des(); |
6955 filenamePtr1 = filename->Des(); |
7032 |
6956 |
7033 User::LeaveIfError( iFileMan->Move( iFname, filenamePtr1, CFileMan::EOverWrite, iStatus ) ); |
6957 User::LeaveIfError( iFileMan->Move( iFname, filenamePtr1, CFileMan::EOverWrite, iStatus ) ); |
7034 // waiting for move to complete |
6958 // waiting for move to complete |
7035 SetActive(); |
6959 SetActive(); |
7036 iFname = filenamePtr1; |
6960 iFname = filenamePtr1; |
7037 ((*iCodDlData)[mediaObjectIndex])->SetDestFilenameL(filenamePtr1); |
6961 ((*iCodDlData)[mediaObjectIndex])->SetDestFilenameL(filenamePtr1); |
7038 |
6962 |
7039 CleanupStack::PopAndDestroy(filename); |
6963 CleanupStack::PopAndDestroy(filename); |
7040 |
6964 |
7041 #endif |
6965 #endif |
7042 } |
6966 } |
7043 |
6967 |
7044 // ----------------------------------------------------------------------------- |
6968 // ----------------------------------------------------------------------------- |
7045 // CHttpDownload::MoveDownloadedMediaObjectSyncL |
6969 // CHttpDownload::MoveDownloadedMediaObjectSyncL |
7058 |
6982 |
7059 //__ASSERT_DEBUG( !IsActive(), DMPanic( KErrInUse ) ); |
6983 //__ASSERT_DEBUG( !IsActive(), DMPanic( KErrInUse ) ); |
7060 //__ASSERT_DEBUG( !iFileMan, DMPanic( KErrInUse ) ); |
6984 //__ASSERT_DEBUG( !iFileMan, DMPanic( KErrInUse ) ); |
7061 |
6985 |
7062 |
6986 |
7063 |
6987 |
7064 RFs &fs = iClientApp->Engine()->Fs(); |
6988 RFs &fs = iClientApp->Engine()->Fs(); |
7065 if(!iFileMan) |
6989 if(!iFileMan) |
7066 { |
6990 { |
7067 iFileMan = CFileMan::NewL(fs); |
6991 iFileMan = CFileMan::NewL(fs); |
7068 } |
6992 } |
7069 |
6993 |
7070 HBufC* filename = HBufC::NewLC(KMaxFileName); |
6994 HBufC* filename = HBufC::NewLC(KMaxFileName); |
7071 TPtr filenamePtr = filename->Des(); |
6995 TPtr filenamePtr = filename->Des(); |
7072 |
6996 |
7073 TPtrC fileNamePtr = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
6997 TPtrC fileNamePtr = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
7074 TInt firstSlashPos = fileNamePtr.Locate( '\\' ); |
6998 TInt firstSlashPos = fileNamePtr.Locate( '\\' ); |
7075 if(firstSlashPos < 0) |
6999 if(firstSlashPos < 0) |
7076 { |
7000 { |
7077 CleanupStack::PopAndDestroy(filename); |
7001 CleanupStack::PopAndDestroy(filename); |
7078 return; |
7002 return; |
7079 } |
7003 } |
7080 TPtrC dlName = fileNamePtr.Left(firstSlashPos); |
7004 TPtrC dlName = fileNamePtr.Left(firstSlashPos); |
7081 TInt drive; |
7005 TInt drive; |
7082 |
7006 |
7083 User::LeaveIfError( fs.CharToDrive( dlName[0], drive )); |
7007 User::LeaveIfError( fs.CharToDrive( dlName[0], drive )); |
7084 |
7008 |
7085 |
7009 |
7086 // Getting RootPath for selected Drive |
7010 // Getting RootPath for selected Drive |
7087 TFileName rootPath; |
7011 TFileName rootPath; |
7090 // Setting KDownloadPath |
7014 // Setting KDownloadPath |
7091 rootPath.Append( KDownloadPath ); |
7015 rootPath.Append( KDownloadPath ); |
7092 |
7016 |
7093 filenamePtr.Copy(rootPath); |
7017 filenamePtr.Copy(rootPath); |
7094 filenamePtr.Append(_L("\\")); |
7018 filenamePtr.Append(_L("\\")); |
7095 |
7019 |
7096 TInt error = fs.MkDirAll(filenamePtr); |
7020 TInt error = fs.MkDirAll(filenamePtr); |
7097 if (error!=KErrNone && error!=KErrAlreadyExists) |
7021 if (error!=KErrNone && error!=KErrAlreadyExists) |
7098 { |
7022 { |
7099 User::Leave(error); |
7023 User::Leave(error); |
7100 } |
7024 } |
7101 iFname = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
7025 iFname = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
7102 |
7026 |
7103 // Find a unique name to avoid any conflict. |
7027 // Find a unique name to avoid any conflict. |
7104 // Here iFname has full path of current location of file |
7028 // Here iFname has full path of current location of file |
7105 // and filename has destination path. |
7029 // and filename has destination path. |
7106 FindUniqueDestinationFileNameL( iFname, filename ); |
7030 FindUniqueDestinationFileNameL( iFname, filename ); |
7107 |
7031 |
7108 filenamePtr = filename->Des(); |
7032 filenamePtr = filename->Des(); |
7109 |
7033 |
7110 TInt err = iFileMan->Move(iFname, filenamePtr, CFileMan::EOverWrite); |
7034 TInt err = iFileMan->Move(iFname, filenamePtr, CFileMan::EOverWrite); |
7111 if(err != KErrNone) |
7035 if(err != KErrNone) |
7112 { |
7036 { |
7156 destPath->Des().Append( *fileExtention ); |
7080 destPath->Des().Append( *fileExtention ); |
7157 |
7081 |
7158 CleanupStack::PopAndDestroy( fileName ); |
7082 CleanupStack::PopAndDestroy( fileName ); |
7159 CleanupStack::PopAndDestroy( fileExtention ); |
7083 CleanupStack::PopAndDestroy( fileExtention ); |
7160 } |
7084 } |
7161 |
7085 |
7162 |
7086 |
7163 // --------------------------------------------------------- |
7087 // --------------------------------------------------------- |
7164 // CHttpDownload::NotifyMediaGalleryL() |
7088 // CHttpDownload::NotifyMediaGalleryL() |
7165 // Notify media gallery about the new file. |
7089 // Notify media gallery about the new file. |
7166 // --------------------------------------------------------- |
7090 // --------------------------------------------------------- |
7167 // |
7091 // |
7168 void CHttpDownload::NotifyMediaGalleryL( const TDesC& aFileName ) |
7092 void CHttpDownload::NotifyMediaGalleryL( const TDesC& aFileName ) |
7169 { |
7093 { |
7170 |
7094 |
7171 LOGGER_ENTERFN( "CHttpDownload::NotifyMediaGalleryL" ); |
7095 LOGGER_ENTERFN( "CHttpDownload::NotifyMediaGalleryL" ); |
7172 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); |
7173 |
7097 |
7174 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF |
7098 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF |
7175 |
7099 |
7176 // |
7100 // |
7177 // Notify Media Gallery about new media file |
7101 // Notify Media Gallery about new media file |
7178 CMGXFileManager* mgFileManager = MGXFileManagerFactory::NewFileManagerL( |
7102 CMGXFileManager* mgFileManager = MGXFileManagerFactory::NewFileManagerL( |
7179 iClientApp->Engine()->Fs() ); |
7103 iClientApp->Engine()->Fs() ); |
7180 CleanupStack::PushL( mgFileManager ); |
7104 CleanupStack::PushL( mgFileManager ); |
7230 |
7154 |
7231 }while( bFound ); |
7155 }while( bFound ); |
7232 |
7156 |
7233 CleanupStack::PopAndDestroy(&rFs); |
7157 CleanupStack::PopAndDestroy(&rFs); |
7234 CleanupStack::PopAndDestroy(fullNameTemp); |
7158 CleanupStack::PopAndDestroy(fullNameTemp); |
7235 |
7159 |
7236 // This is the unique name that we were looking for. |
7160 // This is the unique name that we were looking for. |
7237 CleanupStack::PopAndDestroy(fileName); |
7161 CleanupStack::PopAndDestroy(fileName); |
7238 fileName = uniqueName; |
7162 fileName = uniqueName; |
7239 CleanupStack::PushL(fileName); |
7163 CleanupStack::PushL(fileName); |
7240 } |
7164 } |
7241 |
7165 |
7242 #ifdef DOWNLOADMGR_PATH_PLUGIN_ENABLED_FF |
|
7243 |
|
7244 // ----------------------------------------------------------------------------- |
|
7245 // CHttpDownload::GetDownloadPathPluginInstanceL |
|
7246 // ----------------------------------------------------------------------------- |
|
7247 // |
|
7248 CDownloadPathHandler* CHttpDownload::GetDownloadPathPluginInstanceL() |
|
7249 { |
|
7250 CDownloadPathHandler* downloadPathPlugin = NULL; |
|
7251 if ( iContentType ) |
|
7252 { |
|
7253 TRAPD( kErr, downloadPathPlugin = CDownloadPathHandler::NewL( *iContentType ) ); |
|
7254 if( kErr != KErrNone ) |
|
7255 { |
|
7256 downloadPathPlugin = NULL; |
|
7257 } |
|
7258 } |
|
7259 return downloadPathPlugin; |
|
7260 |
|
7261 } |
|
7262 |
|
7263 // ----------------------------------------------------------------------------- |
|
7264 // CHttpDownload::GetUpdatedPathFromPluginL |
|
7265 // ----------------------------------------------------------------------------- |
|
7266 // |
|
7267 void CHttpDownload::GetUpdatedPathFromPluginL(CDownloadPathHandler* downloadPathPlugin,TFileName& rootPath, TPtr& fileNamePtr) |
|
7268 { |
|
7269 HBufC16* locFileName ; |
|
7270 locFileName = iStorage->LocalFilename(); |
|
7271 |
|
7272 // Gets the updated path for the music content from Plugin |
|
7273 TRAPD( kErr, downloadPathPlugin->GetUpdatedPathL( *locFileName, fileNamePtr ) ); |
|
7274 if( kErr != KErrNone ) |
|
7275 { |
|
7276 // Setting to KDownloadPath |
|
7277 fileNamePtr.Insert( rootPath.Length(), KDownloadPath ); |
|
7278 } |
|
7279 } |
|
7280 #endif |
|
7281 // End of File |
7166 // End of File |