equal
deleted
inserted
replaced
22 #include <e32err.h> |
22 #include <e32err.h> |
23 #include <DocumentHandler.h> |
23 #include <DocumentHandler.h> |
24 #include <apmstd.h> // TDataType |
24 #include <apmstd.h> // TDataType |
25 #include <escapeutils.h> |
25 #include <escapeutils.h> |
26 #include <downloadmanager.h> |
26 #include <downloadmanager.h> |
27 |
27 #include <cmmanager.h> |
28 #include <uri8.h> // HLa |
28 #include <cmdestination.h> |
29 |
29 #include <uri8.h> |
30 |
|
31 #include <QtGlobal> |
30 #include <QtGlobal> |
|
31 #include <QStringList> |
|
32 #include <xqconversions.h> |
|
33 |
32 #include "catalogshttpdownloadmanagerimpl.h" |
34 #include "catalogshttpdownloadmanagerimpl.h" |
33 #include "catalogshttpobserver.h" |
35 #include "catalogshttpobserver.h" |
34 #include "catalogshttpconfigimpl.h" |
36 #include "catalogshttpconfigimpl.h" |
35 #include "catalogskeyvaluepair.h" |
37 #include "catalogskeyvaluepair.h" |
36 #include "catalogshttpheadersimpl.h" |
38 #include "catalogshttpheadersimpl.h" |
690 DLTRACEIN(("")); |
692 DLTRACEIN(("")); |
691 // We get the content size only once in order to minimize |
693 // We get the content size only once in order to minimize |
692 // client-server communication with the Download manager server |
694 // client-server communication with the Download manager server |
693 if ( iDownload && iContentSize <= 0 ) |
695 if ( iDownload && iContentSize <= 0 ) |
694 { |
696 { |
695 |
697 iContentSize = iDownload->attribute(TotalSize).toInt(); |
696 int downloadbytes = iDownload->attribute(DownloadedSize).toInt(); |
|
697 DLTRACE(("Content size from download: %i", iContentSize )); |
698 DLTRACE(("Content size from download: %i", iContentSize )); |
698 } |
699 } |
699 return iContentSize; |
700 return iContentSize; |
700 } |
701 } |
701 |
702 |
862 |
863 |
863 case DownloadEvent::Started: |
864 case DownloadEvent::Started: |
864 |
865 |
865 break; |
866 break; |
866 |
867 |
|
868 case DownloadEvent::Error: |
867 case DownloadEvent::Failed: |
869 case DownloadEvent::Failed: |
|
870 case DownloadEvent::NetworkLoss: |
|
871 case DownloadEvent::ConnectionNeeded: |
|
872 case DownloadEvent::ConnectionDisconnected: |
868 { |
873 { |
869 TInt32 errorId = -1; |
874 TInt32 errorId = -1; |
|
875 if ( aEvent.type() == DownloadEvent::NetworkLoss || |
|
876 aEvent.type() == DownloadEvent::ConnectionNeeded || |
|
877 aEvent.type() == DownloadEvent::ConnectionDisconnected ) |
|
878 { |
|
879 errorId = WRT::ConnectionFailed; |
|
880 } |
870 SetTransferring( EFalse ); |
881 SetTransferring( EFalse ); |
871 errorId = iDownload->attribute(LastError).toInt(); |
882 errorId = iDownload->attribute(LastError).toInt(); |
872 if ( ( errorId == ConnectionFailed || |
883 if ( errorId > 0 ) |
|
884 { |
|
885 // Symbian error codes are always negative numbers |
|
886 errorId = -1 * errorId; |
|
887 } |
|
888 |
|
889 /*if ( ( errorId == ConnectionFailed || |
873 errorId == TransactionFailed )) |
890 errorId == TransactionFailed )) |
874 { |
891 { |
875 DLTRACE(("Try to reconnect")); |
892 DLTRACE(("Try to reconnect")); |
876 iReconnectWhenFail = EFalse; |
893 iReconnectWhenFail = EFalse; |
877 iDownload->start(); |
894 iDownload->start(); |
883 DLTRACE(("Content has changed, reset and restart")); |
900 DLTRACE(("Content has changed, reset and restart")); |
884 iReconnectWhenFail = EFalse; |
901 iReconnectWhenFail = EFalse; |
885 iDownload->cancel(); |
902 iDownload->cancel(); |
886 iDownload->start(); |
903 iDownload->start(); |
887 break; |
904 break; |
888 } |
905 }*/ |
889 |
906 iState.iOperationState = ECatalogsHttpOpFailed; |
|
907 |
|
908 TBool deleted = EFalse; |
|
909 if ( iObserver ) |
|
910 { |
|
911 // Determine whether failure was due to a HTTP error or some |
|
912 // other error. |
|
913 //if ( errorId >= 400 ) |
|
914 // { |
|
915 // deleted = iObserver->HandleHttpError( |
|
916 // *this, TCatalogsHttpError( |
|
917 // ECatalogsHttpErrorHttp, |
|
918 // errorId ) ); |
|
919 // } |
|
920 // else |
|
921 { |
|
922 AddRef(); |
|
923 //iOwner.ConnectionManager().ReportConnectionError( |
|
924 // TCatalogsConnectionMethod(), errorId ); |
|
925 |
|
926 if ( iRefCount > 1 ) |
|
927 { |
|
928 deleted = iObserver->HandleHttpError( |
|
929 *this, TCatalogsHttpError( |
|
930 ECatalogsHttpErrorGeneral, errorId ) ); |
|
931 } |
|
932 else |
|
933 { |
|
934 deleted = ETrue; |
|
935 } |
|
936 Release(); |
|
937 } |
|
938 } |
|
939 if ( !deleted ) |
|
940 { |
|
941 iOwner.CompleteOperation( this ); |
|
942 iState.iProgressState = ECatalogsHttpDone; |
|
943 } |
890 } |
944 } |
891 break; |
945 break; |
892 |
946 |
893 case DownloadEvent::Cancelled: |
947 case DownloadEvent::Cancelled: |
894 |
948 |
901 // Read the response headers from platform DL manager |
955 // Read the response headers from platform DL manager |
902 UpdateResponseHeadersL(); |
956 UpdateResponseHeadersL(); |
903 UpdateContentType(); |
957 UpdateContentType(); |
904 } |
958 } |
905 break; |
959 break; |
906 |
960 |
907 case DownloadEvent::NetworkLoss: |
961 |
908 |
|
909 break; |
|
910 |
|
911 case DownloadEvent::Completed: |
962 case DownloadEvent::Completed: |
912 { |
963 { |
913 // move/rename temp file as the target file |
964 // move/rename temp file as the target file |
914 TRAPD( err, MoveFileL() ); |
965 TRAPD( err, MoveFileL() ); |
915 |
966 |
921 |
972 |
922 |
973 |
923 DLTRACE(("Deleting download")); |
974 DLTRACE(("Deleting download")); |
924 DeletePlatformDownload(); |
975 DeletePlatformDownload(); |
925 } |
976 } |
|
977 iState.iProgressState = ECatalogsHttpDone; |
|
978 iOwner.CompleteOperation( this ); |
|
979 iState.iOperationState = ECatalogsHttpOpCompleted; |
|
980 |
|
981 if ( iObserver ) |
|
982 { |
|
983 iObserver->HandleHttpEventL( *this, iState ); |
|
984 } |
926 |
985 |
927 } |
986 } |
928 break; |
987 break; |
929 |
988 |
930 case DownloadEvent::InProgress: |
989 case DownloadEvent::InProgress: |
931 |
990 { |
932 break; |
991 iTransferredSize = iDownload->attribute(DownloadedSize).toInt(); |
|
992 if ( iObserver ) |
|
993 { |
|
994 iObserver->HandleHttpEventL( *this, iState ); |
|
995 } |
|
996 } |
|
997 break; |
933 |
998 |
934 default: |
999 default: |
935 { |
1000 { |
936 } |
1001 } |
937 }; |
1002 }; |
2365 DLTRACEIN(("")); |
2430 DLTRACEIN(("")); |
2366 DASSERT( iConnection ); |
2431 DASSERT( iConnection ); |
2367 |
2432 |
2368 TRAPD( err, |
2433 TRAPD( err, |
2369 { |
2434 { |
2370 iOwner.SetConnectionL( *iConnection ); |
2435 if ( Config().ConnectionMethod().iType == ECatalogsConnectionMethodTypeDestination ) |
|
2436 { |
|
2437 RCmManager cmManager; |
|
2438 CleanupClosePushL( cmManager ); |
|
2439 cmManager.OpenL(); |
|
2440 RCmDestination dest = cmManager.DestinationL( Config().ConnectionMethod().iId ); |
|
2441 CleanupClosePushL( dest ); |
|
2442 HBufC* temp = dest.NameLC(); |
|
2443 QString destname; |
|
2444 destname = XQConversions::s60DescToQString( *temp ); |
|
2445 CleanupStack::PopAndDestroy( temp ); |
|
2446 CleanupStack::PopAndDestroy( &dest ); |
|
2447 CleanupStack::PopAndDestroy( &cmManager ); |
|
2448 if ( iOwner.GetDownloadManager() ) |
|
2449 { |
|
2450 iOwner.GetDownloadManager()->attribute(AccessPoints).toStringList(); |
|
2451 iOwner.GetDownloadManager()->setAttribute(AccessPoint, destname); |
|
2452 } |
|
2453 } |
2371 |
2454 |
2372 // Update the configuration |
2455 // Update the configuration |
2373 if ( iState.iProgressState == ECatalogsHttpNone ) |
2456 if ( iState.iProgressState == ECatalogsHttpNone ) |
2374 { |
2457 { |
2375 DLTRACE(("Updating dl config")); |
2458 DLTRACE(("Updating dl config")); |
2702 // Update the request headers to the download manager but do it |
2785 // Update the request headers to the download manager but do it |
2703 // only once |
2786 // only once |
2704 UpdateRequestHeadersL(); |
2787 UpdateRequestHeadersL(); |
2705 } |
2788 } |
2706 |
2789 |
2707 // Check if the download has been set progressive |
2790 // Check if the |
2708 TBool progressive = EFalse; |
2791 //download has been set progressive |
|
2792 /* MTA |
|
2793 * TBool progressive = EFalse; |
2709 try |
2794 try |
2710 { |
2795 { |
2711 progressive =iDownload->attribute(Progressive).toBool(); |
2796 progressive =iDownload->attribute(Progressive).toBool(); |
2712 } |
2797 } |
2713 catch(const std::exception& exception) |
2798 catch(const std::exception& exception) |
2748 } |
2833 } |
2749 catch(const std::exception& exception) |
2834 catch(const std::exception& exception) |
2750 { |
2835 { |
2751 qt_symbian_exception2LeaveL(exception); |
2836 qt_symbian_exception2LeaveL(exception); |
2752 } |
2837 } |
2753 |
2838 **/ |
2754 if ( !iFileIsSet ) |
2839 if ( !iFileIsSet ) |
2755 { |
2840 { |
2756 DLTRACE(("Setting filehandle to download")); |
2841 DLTRACE(("Setting filehandle to download")); |
2757 // User::LeaveIfError( iDownload->SetFileHandleAttribute( file ) ); |
2842 // User::LeaveIfError( iDownload->SetFileHandleAttribute( file ) ); |
|
2843 file.Close(); |
|
2844 TInt ret = BaflUtils::DeleteFile( iFs, *iTempFilename ); |
|
2845 iDownload->setAttribute(DestinationPath,XQConversions::s60DescToQString(iConfig->Directory())); |
|
2846 iDownload->setAttribute(FileName, XQConversions::s60DescToQString(*iTempFilename)); |
2758 iFileIsSet = ETrue; |
2847 iFileIsSet = ETrue; |
2759 } |
2848 } |
2760 |
2849 |
2761 CleanupStack::PopAndDestroy( &file ); |
2850 CleanupStack::PopAndDestroy( &file ); |
2762 } |
2851 } |
2832 |
2921 |
2833 CCatalogsHttpQTDownload::CCatalogsHttpQTDownload(CCatalogsHttpDownload* aHttpDownload,Download* aDownload) |
2922 CCatalogsHttpQTDownload::CCatalogsHttpQTDownload(CCatalogsHttpDownload* aHttpDownload,Download* aDownload) |
2834 { |
2923 { |
2835 iCatalogsHttpDownload = aHttpDownload; |
2924 iCatalogsHttpDownload = aHttpDownload; |
2836 iDownload = aDownload; |
2925 iDownload = aDownload; |
2837 connect(iDownload, SIGNAL(downloadEvent(DownloadManagerEvent*)), this,SLOT(downloadEvent(DownloadEvent*))); |
2926 connect(iDownload, SIGNAL(downloadEvent(DownloadEvent*)), this,SLOT(downloadEventHandler(DownloadEvent*))); |
|
2927 connect(iDownload, SIGNAL(downloadError(Error)), this,SLOT(downloadErrorHandler(Error))); |
2838 } |
2928 } |
2839 |
2929 |
2840 void CCatalogsHttpQTDownload::downloadEvent(WRT::DownloadEvent* aEvent) |
2930 void CCatalogsHttpQTDownload::downloadEventHandler(DownloadEvent* aEvent) |
2841 { |
2931 { |
2842 iCatalogsHttpDownload->HandledownloadEventL(*aEvent); |
2932 iCatalogsHttpDownload->HandledownloadEventL(*aEvent); |
2843 } |
2933 } |
2844 void CCatalogsHttpQTDownload::downloadError(WRT::Error) |
2934 void CCatalogsHttpQTDownload::downloadErrorHandler(Error) |
2845 { |
2935 { |
2846 //iCatalogsHttpDownload->HandledownloadEventL(*aEvent); |
2936 //iCatalogsHttpDownload->HandledownloadEventL(*aEvent); |
2847 } |
2937 } |
|
2938 |
|
2939 |