21 #include <bautils.h> |
21 #include <bautils.h> |
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> |
|
27 #include <cmmanager.h> |
|
28 #include <cmdestination.h> |
|
29 #include <uri8.h> |
|
30 #include <QtGlobal> |
|
31 #include <QStringList> |
|
32 #include <xqconversions.h> |
26 |
33 |
27 #include "catalogshttpdownloadmanagerimpl.h" |
34 #include "catalogshttpdownloadmanagerimpl.h" |
28 #include "catalogshttpobserver.h" |
35 #include "catalogshttpobserver.h" |
29 #include "catalogshttpconfigimpl.h" |
36 #include "catalogshttpconfigimpl.h" |
30 #include "catalogskeyvaluepair.h" |
37 #include "catalogskeyvaluepair.h" |
797 { |
812 { |
798 DLTRACEIN(("")); |
813 DLTRACEIN(("")); |
799 iConfig->InternalizeL( aStream ); |
814 iConfig->InternalizeL( aStream ); |
800 HBufC8* contentType = NULL; |
815 HBufC8* contentType = NULL; |
801 InternalizeDesL( contentType, aStream ); |
816 InternalizeDesL( contentType, aStream ); |
802 if ( contentType->Length() > KMaxContentTypeLength ) |
817 // HLa if ( contentType->Length() > KMaxContentTypeLength ) |
|
818 if ( contentType->Length() > 256 ) |
803 { |
819 { |
804 DeletePtr( contentType ); |
820 DeletePtr( contentType ); |
805 DLERROR(("Content type was too long, leaving with KErrCorrupt")); |
821 DLERROR(("Content type was too long, leaving with KErrCorrupt")); |
806 User::Leave( KErrCorrupt ); |
822 User::Leave( KErrCorrupt ); |
807 } |
823 } |
837 return iOwner.OperationPriorityChanged( this ); |
853 return iOwner.OperationPriorityChanged( this ); |
838 } |
854 } |
839 return KErrNone; |
855 return KErrNone; |
840 } |
856 } |
841 |
857 |
842 |
858 void CCatalogsHttpDownload::HandledownloadEventL(DownloadEvent& aEvent) |
|
859 { |
|
860 |
|
861 switch(aEvent.type()) |
|
862 { |
|
863 |
|
864 case DownloadEvent::Started: |
|
865 |
|
866 break; |
|
867 |
|
868 case DownloadEvent::Error: |
|
869 case DownloadEvent::Failed: |
|
870 case DownloadEvent::NetworkLoss: |
|
871 case DownloadEvent::ConnectionNeeded: |
|
872 case DownloadEvent::ConnectionDisconnected: |
|
873 { |
|
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 } |
|
881 SetTransferring( EFalse ); |
|
882 errorId = iDownload->attribute(LastError).toInt(); |
|
883 if ( errorId > 0 ) |
|
884 { |
|
885 // Symbian error codes are always negative numbers |
|
886 errorId = -1 * errorId; |
|
887 } |
|
888 |
|
889 /*if ( ( errorId == ConnectionFailed || |
|
890 errorId == TransactionFailed )) |
|
891 { |
|
892 DLTRACE(("Try to reconnect")); |
|
893 iReconnectWhenFail = EFalse; |
|
894 iDownload->start(); |
|
895 break; |
|
896 } |
|
897 else if ( errorId == ContentExpired || |
|
898 errorId == PartialContentModified ) |
|
899 { |
|
900 DLTRACE(("Content has changed, reset and restart")); |
|
901 iReconnectWhenFail = EFalse; |
|
902 iDownload->cancel(); |
|
903 iDownload->start(); |
|
904 break; |
|
905 }*/ |
|
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 } |
|
944 } |
|
945 break; |
|
946 |
|
947 case DownloadEvent::Cancelled: |
|
948 |
|
949 break; |
|
950 case DownloadEvent::ContentTypeChanged: |
|
951 |
|
952 break; |
|
953 case DownloadEvent::HeadersReceived: |
|
954 { |
|
955 // Read the response headers from platform DL manager |
|
956 UpdateResponseHeadersL(); |
|
957 UpdateContentType(); |
|
958 } |
|
959 break; |
|
960 |
|
961 |
|
962 case DownloadEvent::Completed: |
|
963 { |
|
964 // move/rename temp file as the target file |
|
965 TRAPD( err, MoveFileL() ); |
|
966 |
|
967 // DLMAIN-546, delete DL manager's download before starting |
|
968 // the next one so that downloads don't jam, again |
|
969 if ( iDownload ) |
|
970 { |
|
971 iTransferredSize = iDownload->attribute(DownloadedSize).toInt(); |
|
972 |
|
973 |
|
974 DLTRACE(("Deleting download")); |
|
975 DeletePlatformDownload(); |
|
976 } |
|
977 iState.iProgressState = ECatalogsHttpDone; |
|
978 iOwner.CompleteOperation( this ); |
|
979 iState.iOperationState = ECatalogsHttpOpCompleted; |
|
980 |
|
981 if ( iObserver ) |
|
982 { |
|
983 iObserver->HandleHttpEventL( *this, iState ); |
|
984 } |
|
985 |
|
986 } |
|
987 break; |
|
988 |
|
989 case DownloadEvent::InProgress: |
|
990 { |
|
991 iTransferredSize = iDownload->attribute(DownloadedSize).toInt(); |
|
992 if ( iObserver ) |
|
993 { |
|
994 iObserver->HandleHttpEventL( *this, iState ); |
|
995 } |
|
996 } |
|
997 break; |
|
998 |
|
999 default: |
|
1000 { |
|
1001 } |
|
1002 }; |
|
1003 } |
843 // --------------------------------------------------------------------------- |
1004 // --------------------------------------------------------------------------- |
844 // Handles events from the transaction |
1005 // Handles events from the transaction |
845 // --------------------------------------------------------------------------- |
1006 // --------------------------------------------------------------------------- |
846 // |
1007 // |
847 void CCatalogsHttpDownload::HandleHttpEventL( |
1008 void CCatalogsHttpDownload::HandleHttpEventL( |
989 |
1150 |
990 // --------------------------------------------------------------------------- |
1151 // --------------------------------------------------------------------------- |
991 // Handles events from the download manager |
1152 // Handles events from the download manager |
992 // --------------------------------------------------------------------------- |
1153 // --------------------------------------------------------------------------- |
993 // |
1154 // |
|
1155 |
|
1156 /* HLa |
994 void CCatalogsHttpDownload::HandleEventL( THttpDownloadEvent aEvent ) |
1157 void CCatalogsHttpDownload::HandleEventL( THttpDownloadEvent aEvent ) |
995 { |
1158 { |
996 DLTRACEIN(("")); |
1159 DLTRACEIN(("")); |
997 DLINFO( ("DL id: %d, Dl state: %i, Pr: %i, this-ptr: %X, iState: %d, iProgress: %d, dl-ptr: %X", |
1160 DLINFO( ("DL id: %d, Dl state: %i, Pr: %i, this-ptr: %X, iState: %d, iProgress: %d, dl-ptr: %X", |
998 OperationId().Id(), |
1161 OperationId().Id(), |
1023 return; |
1186 return; |
1024 } |
1187 } |
1025 |
1188 |
1026 TInt32 statusCode = -1; |
1189 TInt32 statusCode = -1; |
1027 |
1190 |
1028 iDownload->GetIntAttribute( EDlAttrStatusCode, statusCode ); |
1191 statusCode = (Download::State)iDownload->attribute(WRT::State).toInt(); |
1029 DLINFO( ("Response status: %i", statusCode ) ); |
1192 DLINFO( ("Response status: %i", statusCode ) ); |
1030 |
1193 |
1031 #ifdef CATALOGS_BUILD_CONFIG_DEBUG |
1194 #ifdef CATALOGS_BUILD_CONFIG_DEBUG |
1032 TInt32 errorId = 0; |
1195 TInt32 errorId = 0; |
1033 |
1196 errorId=iDownload->attribute(LastError).toInt(); |
1034 iDownload->GetIntAttribute( EDlAttrErrorId, errorId ); |
1197 |
1035 DLINFO( ("Error id: %i", errorId ) ); |
1198 DLINFO( ("Error id: %i", errorId ) ); |
1036 |
1199 |
1037 #endif |
1200 #endif |
1038 |
1201 |
1039 TInt32 globalErrorId = 0; |
1202 TInt32 globalErrorId = 0; |
1040 iDownload->GetIntAttribute( |
1203 globalErrorId= iDownload->attribute(LastError).toInt(); |
1041 EDlAttrGlobalErrorId, globalErrorId ); |
1204 |
1042 DLINFO( ("Global error id: %i", globalErrorId ) ); |
1205 DLINFO( ("Global error id: %i", globalErrorId ) ); |
1043 |
1206 |
1044 |
1207 |
1045 // was >=, DL manager should give us proper errors but it doesn't always |
1208 // was >=, DL manager should give us proper errors but it doesn't always |
1046 if ( ( statusCode == KHttpErrorStatus || |
1209 if ( ( statusCode == KHttpErrorStatus || |
1141 TRAPD( err, MoveFileL() ); |
1304 TRAPD( err, MoveFileL() ); |
1142 |
1305 |
1143 // DLMAIN-546, delete DL manager's download before starting |
1306 // DLMAIN-546, delete DL manager's download before starting |
1144 // the next one so that downloads don't jam, again |
1307 // the next one so that downloads don't jam, again |
1145 if ( iDownload ) |
1308 if ( iDownload ) |
1146 { |
1309 { |
1147 iDownload->GetIntAttribute( |
1310 iTransferredSize = iDownload->attribute(DownloadedSize).toInt(); |
1148 EDlAttrDownloadedSize, iTransferredSize ); |
1311 |
1149 |
1312 |
1150 DLTRACE(("Deleting download")); |
1313 DLTRACE(("Deleting download")); |
1151 DeletePlatformDownload(); |
1314 DeletePlatformDownload(); |
1152 } |
1315 } |
1153 |
1316 |
1177 case EHttpDlFailed: |
1340 case EHttpDlFailed: |
1178 { |
1341 { |
1179 DLTRACE(( "Download failed" )); |
1342 DLTRACE(( "Download failed" )); |
1180 TInt32 errorId = -1; |
1343 TInt32 errorId = -1; |
1181 SetTransferring( EFalse ); |
1344 SetTransferring( EFalse ); |
1182 iDownload->GetIntAttribute( EDlAttrErrorId, errorId ); |
1345 errorId = iDownload->attribute(LastError).toInt(); |
|
1346 |
1183 DLINFO( ("Error id: %i", errorId ) ); |
1347 DLINFO( ("Error id: %i", errorId ) ); |
1184 |
1348 |
1185 DLINFO( ("Global error id: %i", globalErrorId ) ); |
1349 DLINFO( ("Global error id: %i", globalErrorId ) ); |
1186 |
1350 |
1187 if ( iReconnectWhenFail && |
1351 if ( iReconnectWhenFail && |
1188 ( errorId == EConnectionFailed || |
1352 ( errorId == EConnectionFailed || |
1189 errorId == ETransactionFailed )) |
1353 errorId == ETransactionFailed )) |
1190 { |
1354 { |
1191 DLTRACE(("Try to reconnect")); |
1355 DLTRACE(("Try to reconnect")); |
1192 iReconnectWhenFail = EFalse; |
1356 iReconnectWhenFail = EFalse; |
1193 iDownload->Start(); |
1357 iDownload->start(); |
1194 break; |
1358 break; |
1195 } |
1359 } |
1196 else if ( errorId == EContentExpired || |
1360 else if ( errorId == EContentExpired || |
1197 errorId == EPartialContentModified ) |
1361 errorId == EPartialContentModified ) |
1198 { |
1362 { |
1199 DLTRACE(("Content has changed, reset and restart")); |
1363 DLTRACE(("Content has changed, reset and restart")); |
1200 iReconnectWhenFail = EFalse; |
1364 iReconnectWhenFail = EFalse; |
1201 iDownload->Reset(); |
1365 iDownload->cancel(); |
1202 iDownload->Start(); |
1366 iDownload->start(); |
1203 break; |
1367 break; |
1204 } |
1368 } |
1205 |
1369 |
1206 ReleasePtr( iConnection ); |
1370 ReleasePtr( iConnection ); |
1207 iState.iOperationState = ECatalogsHttpOpFailed; |
1371 iState.iOperationState = ECatalogsHttpOpFailed; |
1386 SetTransferring( EFalse ); |
1552 SetTransferring( EFalse ); |
1387 // Don't restart paused downloads or notify about disconnection |
1553 // Don't restart paused downloads or notify about disconnection |
1388 if ( !iPaused ) |
1554 if ( !iPaused ) |
1389 { |
1555 { |
1390 TInt32 globalErrorId = 0; |
1556 TInt32 globalErrorId = 0; |
1391 iDownload->GetIntAttribute( |
1557 globalErrorId = iDownload->attribute(LastError).toInt(); |
1392 EDlAttrGlobalErrorId, globalErrorId ); |
|
1393 DLINFO( ("Global error id: %i", globalErrorId ) ); |
1558 DLINFO( ("Global error id: %i", globalErrorId ) ); |
1394 |
1559 |
1395 if ( globalErrorId == KErrCancel ) |
1560 if ( globalErrorId == KErrCancel ) |
1396 { |
1561 { |
1397 DLTRACE(("Cancelled")); |
1562 DLTRACE(("Cancelled")); |
1634 // Constructor |
1800 // Constructor |
1635 // --------------------------------------------------------------------------- |
1801 // --------------------------------------------------------------------------- |
1636 // |
1802 // |
1637 CCatalogsHttpDownload::CCatalogsHttpDownload( |
1803 CCatalogsHttpDownload::CCatalogsHttpDownload( |
1638 CCatalogsHttpDownloadManager& aOwner, |
1804 CCatalogsHttpDownloadManager& aOwner, |
1639 RHttpDownload* aDownload ) : |
1805 Download* aDownload ) : |
1640 iOwner( aOwner ), |
1806 iOwner( aOwner ), |
1641 iDownload( aDownload ), |
1807 iDownload( aDownload ), |
1642 iState( ECatalogsHttpOpCreated, ECatalogsHttpNone ), |
1808 iState( ECatalogsHttpOpCreated, ECatalogsHttpNone ), |
1643 iRefCount( 1 ), |
1809 iRefCount( 1 ), |
1644 iNormalDelete( EFalse ), |
1810 iNormalDelete( EFalse ), |
1657 // Get the id for the download and update iUri |
1823 // Get the id for the download and update iUri |
1658 if ( iDownload ) |
1824 if ( iDownload ) |
1659 { |
1825 { |
1660 // id part will be updated from disk |
1826 // id part will be updated from disk |
1661 iId = TCatalogsTransportOperationId( iOwner.SessionId(), KErrNotFound ); |
1827 iId = TCatalogsTransportOperationId( iOwner.SessionId(), KErrNotFound ); |
1662 |
1828 iQTDownload = new CCatalogsHttpQTDownload(this,iDownload); |
|
1829 |
1663 UpdateSecondaryIdL(); |
1830 UpdateSecondaryIdL(); |
1664 |
1831 |
1665 User::LeaveIfError( SetDeleteState( EDownloadCanBeDeleted ) ); |
1832 User::LeaveIfError( SetDeleteState( EDownloadCanBeDeleted ) ); |
1666 // Update iUri to match the current URI |
1833 // Update iUri to match the current URI |
1667 UpdateUriL(); |
1834 UpdateUriL(); |
1698 DLTRACEIN(( "" )); |
1865 DLTRACEIN(( "" )); |
1699 if ( !iContentType.Length() ) |
1866 if ( !iContentType.Length() ) |
1700 { |
1867 { |
1701 // Download always exists when this is called so no need to check |
1868 // Download always exists when this is called so no need to check |
1702 DLTRACE(("Updating the content type")); |
1869 DLTRACE(("Updating the content type")); |
1703 iDownload->GetStringAttribute( EDlAttrContentType, |
1870 QString contentType; |
1704 iContentType ); |
1871 contentType= iDownload->attribute(WRT::ContentType).toString(); |
|
1872 // HLa TBuf<KMaxContentTypeLength> ContentType(contentType.utf16()); |
|
1873 TBuf<256> ContentType(contentType.utf16()); |
|
1874 iContentType.Copy(ContentType); |
|
1875 |
1705 } |
1876 } |
1706 DLTRACEOUT(("Content-type: %S", &iContentType )); |
1877 DLTRACEOUT(("Content-type: %S", &iContentType )); |
1707 } |
1878 } |
1708 |
1879 |
1709 |
1880 |
1818 { |
1989 { |
1819 DLTRACEIN( ("") ); |
1990 DLTRACEIN( ("") ); |
1820 // Get the current url of the download |
1991 // Get the current url of the download |
1821 RBuf8 buf; |
1992 RBuf8 buf; |
1822 CleanupClosePushL( buf ); |
1993 CleanupClosePushL( buf ); |
|
1994 const TInt KMaxUrlLength = 2048; |
1823 buf.CreateL( KMaxUrlLength ); |
1995 buf.CreateL( KMaxUrlLength ); |
1824 |
1996 QString string; |
1825 User::LeaveIfError( iDownload->GetStringAttribute( EDlAttrCurrentUrl, |
1997 try |
1826 buf ) ); |
1998 { |
|
1999 string = iDownload->attribute(SourceUrl).toString(); |
|
2000 } |
|
2001 catch(const std::exception& exception) |
|
2002 { |
|
2003 qt_symbian_exception2LeaveL(exception); |
|
2004 } |
|
2005 |
1827 |
2006 |
1828 // DL manager has the encoded URI |
2007 // DL manager has the encoded URI |
1829 AssignDesL( iEncodedUri, buf ); |
2008 AssignDesL( iEncodedUri, buf ); |
1830 CleanupStack::PopAndDestroy( &buf ); |
2009 CleanupStack::PopAndDestroy( &buf ); |
1831 |
2010 |
1865 { |
2044 { |
1866 AddRequestHeaderL( iAddedRequestHeaders, *headers[i] ); |
2045 AddRequestHeaderL( iAddedRequestHeaders, *headers[i] ); |
1867 } |
2046 } |
1868 else |
2047 else |
1869 { |
2048 { |
1870 User::LeaveIfError( iDownload->SetStringAttribute( |
2049 /* User::LeaveIfError( iDownload->SetStringAttribute( |
1871 predefined, headers[i]->Value() ) ); |
2050 predefined, headers[i]->Value() ) );*/ |
1872 } |
2051 } |
1873 } |
2052 } |
1874 |
2053 |
1875 // Add the headers that don't have a predefined enumeration in |
2054 // Add the headers that don't have a predefined enumeration in |
1876 // the platform DL manager |
2055 // the platform DL manager |
1877 if ( iAddedRequestHeaders ) |
2056 if ( iAddedRequestHeaders ) |
1878 { |
2057 { |
1879 DLTRACE(( "added request headers: %S", iAddedRequestHeaders )); |
2058 DLTRACE(( "added request headers: %S", iAddedRequestHeaders )); |
1880 User::LeaveIfError( iDownload->SetStringAttribute( |
2059 /* User::LeaveIfError( iDownload->SetStringAttribute( |
1881 EDlAttrRequestHeaderAddon, *iAddedRequestHeaders ) ); |
2060 EDlAttrRequestHeaderAddon, *iAddedRequestHeaders ) );*/ |
1882 delete iAddedRequestHeaders; |
2061 delete iAddedRequestHeaders; |
1883 iAddedRequestHeaders = NULL; |
2062 iAddedRequestHeaders = NULL; |
1884 } |
2063 } |
1885 DLTRACEOUT(("")); |
2064 DLTRACEOUT(("")); |
1886 } |
2065 } |
2243 DLTRACEIN(("")); |
2430 DLTRACEIN(("")); |
2244 DASSERT( iConnection ); |
2431 DASSERT( iConnection ); |
2245 |
2432 |
2246 TRAPD( err, |
2433 TRAPD( err, |
2247 { |
2434 { |
2248 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 } |
2249 |
2454 |
2250 // Update the configuration |
2455 // Update the configuration |
2251 if ( iState.iProgressState == ECatalogsHttpNone ) |
2456 if ( iState.iProgressState == ECatalogsHttpNone ) |
2252 { |
2457 { |
2253 DLTRACE(("Updating dl config")); |
2458 DLTRACE(("Updating dl config")); |
2254 InitializeDownloadL(); |
2459 InitializeDownloadL(); |
2255 } |
2460 } |
2256 }); |
2461 }); |
2257 |
2462 |
2258 if ( err == KErrNone ) |
2463 if ( err == KErrNone ) |
2259 { |
2464 { |
2260 err = iDownload->Start(); |
2465 try |
|
2466 { |
|
2467 iDownload->start(); |
|
2468 } |
|
2469 catch(const std::exception& exception) |
|
2470 { |
|
2471 qt_symbian_exception2LeaveL(exception); |
|
2472 } |
2261 } |
2473 } |
2262 return err; |
2474 return err; |
2263 } |
2475 } |
2264 |
2476 |
2265 |
2477 |
2469 DLTRACEIN(( "aStatus: %x, id: %x", aStatus, OperationId().Id() )); |
2681 DLTRACEIN(( "aStatus: %x, id: %x", aStatus, OperationId().Id() )); |
2470 |
2682 |
2471 TInt err = KErrNone; |
2683 TInt err = KErrNone; |
2472 if ( iDownload ) |
2684 if ( iDownload ) |
2473 { |
2685 { |
2474 err = iDownload->SetIntAttribute( EDlAttrUserData, aStatus ); |
2686 |
|
2687 iStatus = aStatus; |
2475 } |
2688 } |
2476 |
2689 |
2477 return err; |
2690 return err; |
2478 } |
2691 } |
2479 |
2692 |
2480 |
2693 CCatalogsHttpDownload::TDownloadDeleteState CCatalogsHttpDownload::GetStatusState() |
|
2694 { |
|
2695 return iStatus; |
|
2696 } |
2481 // --------------------------------------------------------------------------- |
2697 // --------------------------------------------------------------------------- |
2482 // Gets delete status and download id from the platform download |
2698 // Gets delete status and download id from the platform download |
2483 // --------------------------------------------------------------------------- |
2699 // --------------------------------------------------------------------------- |
2484 // |
2700 // |
2485 TInt CCatalogsHttpDownload::GetDeleteState( |
2701 TInt CCatalogsHttpDownload::GetDeleteState( |
2568 // Update the request headers to the download manager but do it |
2785 // Update the request headers to the download manager but do it |
2569 // only once |
2786 // only once |
2570 UpdateRequestHeadersL(); |
2787 UpdateRequestHeadersL(); |
2571 } |
2788 } |
2572 |
2789 |
2573 // Check if the download has been set progressive |
2790 // Check if the |
2574 TBool progressive = EFalse; |
2791 //download has been set progressive |
2575 User::LeaveIfError( iDownload->GetBoolAttribute( |
2792 /* MTA |
2576 EDlAttrProgressive, progressive ) ); |
2793 * TBool progressive = EFalse; |
|
2794 try |
|
2795 { |
|
2796 progressive =iDownload->attribute(Progressive).toBool(); |
|
2797 } |
|
2798 catch(const std::exception& exception) |
|
2799 { |
|
2800 qt_symbian_exception2LeaveL(exception); |
|
2801 } |
2577 |
2802 |
2578 |
2803 |
2579 // We want to have progressive downloads because then DL manager uses |
2804 // We want to have progressive downloads because then DL manager uses |
2580 // a smaller download buffer which makes progress events much more |
2805 // a smaller download buffer which makes progress events much more |
2581 // frequent. However, something goes wrong if the progressive flag is |
2806 // frequent. However, something goes wrong if the progressive flag is |
2589 // set the flag if it has already been set because it |
2814 // set the flag if it has already been set because it |
2590 // messes the download |
2815 // messes the download |
2591 !iFileIsSet ) |
2816 !iFileIsSet ) |
2592 { |
2817 { |
2593 DLTRACE(("Setting download as progressive")); |
2818 DLTRACE(("Setting download as progressive")); |
2594 User::LeaveIfError( iDownload->SetBoolAttribute( |
2819 try |
2595 EDlAttrProgressive, ETrue ) ); |
2820 { |
2596 } |
2821 iDownload->setAttribute(Progressive,ETrue); |
|
2822 } |
|
2823 catch(const std::exception& exception) |
|
2824 { |
|
2825 qt_symbian_exception2LeaveL(exception); |
|
2826 } |
|
2827 } |
2597 |
2828 |
2598 // Doesn't pause the download after content type has been received |
2829 // Doesn't pause the download after content type has been received |
2599 User::LeaveIfError( iDownload->SetBoolAttribute( |
2830 try |
2600 EDlAttrNoContentTypeCheck, ETrue ) ); |
2831 { |
2601 |
2832 iDownload->setAttribute(Progressive,ETrue); |
|
2833 } |
|
2834 catch(const std::exception& exception) |
|
2835 { |
|
2836 qt_symbian_exception2LeaveL(exception); |
|
2837 } |
|
2838 **/ |
2602 if ( !iFileIsSet ) |
2839 if ( !iFileIsSet ) |
2603 { |
2840 { |
2604 DLTRACE(("Setting filehandle to download")); |
2841 DLTRACE(("Setting filehandle to download")); |
2605 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)); |
2606 iFileIsSet = ETrue; |
2847 iFileIsSet = ETrue; |
2607 } |
2848 } |
2608 |
2849 |
2609 CleanupStack::PopAndDestroy( &file ); |
2850 CleanupStack::PopAndDestroy( &file ); |
2610 } |
2851 } |
2611 } |
2852 } |
2612 |
2853 |
2613 |
2854 Download* CCatalogsHttpDownload::GetDownload() |
|
2855 { |
|
2856 return iDownload; |
|
2857 } |
2614 // --------------------------------------------------------------------------- |
2858 // --------------------------------------------------------------------------- |
2615 // Delete platform download and reset secondary id |
2859 // Delete platform download and reset secondary id |
2616 // --------------------------------------------------------------------------- |
2860 // --------------------------------------------------------------------------- |
2617 // |
2861 // |
2618 void CCatalogsHttpDownload::DeletePlatformDownload() |
2862 void CCatalogsHttpDownload::DeletePlatformDownload() |
2619 { |
2863 { |
2620 if ( iDownload ) |
2864 if ( iDownload ) |
2621 { |
2865 { |
2622 iDownload->Delete(); |
2866 iOwner.GetDownloadManager()->removeOne(iDownload); |
2623 iDownload = NULL; |
2867 iDownload = NULL; |
2624 iId.SetSecondaryId( KErrNotFound ); |
2868 iId.SetSecondaryId( KErrNotFound ); |
2625 } |
2869 } |
2626 } |
2870 } |
2627 |
2871 |
2673 { |
2916 { |
2674 aName.Delete( dotPos, aName.Length()- dotPos ); |
2917 aName.Delete( dotPos, aName.Length()- dotPos ); |
2675 aName.Append( aExt ); |
2918 aName.Append( aExt ); |
2676 } |
2919 } |
2677 } |
2920 } |
|
2921 |
|
2922 CCatalogsHttpQTDownload::CCatalogsHttpQTDownload(CCatalogsHttpDownload* aHttpDownload,Download* aDownload) |
|
2923 { |
|
2924 iCatalogsHttpDownload = aHttpDownload; |
|
2925 iDownload = aDownload; |
|
2926 connect(iDownload, SIGNAL(downloadEvent(DownloadEvent*)), this,SLOT(downloadEventHandler(DownloadEvent*))); |
|
2927 connect(iDownload, SIGNAL(downloadError(Error)), this,SLOT(downloadErrorHandler(Error))); |
|
2928 } |
|
2929 |
|
2930 void CCatalogsHttpQTDownload::downloadEventHandler(DownloadEvent* aEvent) |
|
2931 { |
|
2932 iCatalogsHttpDownload->HandledownloadEventL(*aEvent); |
|
2933 } |
|
2934 void CCatalogsHttpQTDownload::downloadErrorHandler(Error) |
|
2935 { |
|
2936 //iCatalogsHttpDownload->HandledownloadEventL(*aEvent); |
|
2937 } |
|
2938 |
|
2939 |