ncdengine/engine/transport/src/catalogshttpdownload.cpp
changeset 60 245df5276b97
parent 53 ae54820ef82c
child 64 48c14c385b0e
equal deleted inserted replaced
53:ae54820ef82c 60:245df5276b97
    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 
       
    28 #include <uri8.h> // HLa
    27 
    29 
    28 
    30 
    29 #include <QtGlobal>
    31 #include <QtGlobal>
    30 #include "catalogshttpdownloadmanagerimpl.h"
    32 #include "catalogshttpdownloadmanagerimpl.h"
    31 #include "catalogshttpobserver.h"
    33 #include "catalogshttpobserver.h"
   809     {
   811     {
   810     DLTRACEIN((""));
   812     DLTRACEIN((""));
   811     iConfig->InternalizeL( aStream );
   813     iConfig->InternalizeL( aStream );
   812     HBufC8* contentType = NULL;
   814     HBufC8* contentType = NULL;
   813     InternalizeDesL( contentType, aStream );
   815     InternalizeDesL( contentType, aStream );
   814     if ( contentType->Length() > KMaxContentTypeLength ) 
   816     // HLa if ( contentType->Length() > KMaxContentTypeLength ) 
       
   817     if ( contentType->Length() > 256 )
   815         {
   818         {
   816         DeletePtr( contentType );
   819         DeletePtr( contentType );
   817         DLERROR(("Content type was too long, leaving with KErrCorrupt"));
   820         DLERROR(("Content type was too long, leaving with KErrCorrupt"));
   818         User::Leave( KErrCorrupt );
   821         User::Leave( KErrCorrupt );
   819         }
   822         }
  1082 
  1085 
  1083 // ---------------------------------------------------------------------------
  1086 // ---------------------------------------------------------------------------
  1084 // Handles events from the download manager
  1087 // Handles events from the download manager
  1085 // ---------------------------------------------------------------------------
  1088 // ---------------------------------------------------------------------------
  1086 //	
  1089 //	
       
  1090 
       
  1091 /* HLa
  1087 void CCatalogsHttpDownload::HandleEventL( THttpDownloadEvent aEvent )
  1092 void CCatalogsHttpDownload::HandleEventL( THttpDownloadEvent aEvent )
  1088     {
  1093     {
  1089     DLTRACEIN((""));
  1094     DLTRACEIN((""));
  1090     DLINFO( ("DL id: %d, Dl state: %i, Pr: %i, this-ptr: %X, iState: %d, iProgress: %d, dl-ptr: %X", 
  1095     DLINFO( ("DL id: %d, Dl state: %i, Pr: %i, this-ptr: %X, iState: %d, iProgress: %d, dl-ptr: %X", 
  1091         OperationId().Id(),
  1096         OperationId().Id(),
  1374 */
  1379 */
  1375         /** 
  1380         /** 
  1376         * Download process can be paused again. This event only occurs after
  1381         * Download process can be paused again. This event only occurs after
  1377         * EHttpDlNonPausable. 
  1382         * EHttpDlNonPausable. 
  1378         */	
  1383         */	
       
  1384 /* HLa
  1379         case EHttpDlPausable:
  1385         case EHttpDlPausable:
  1380             {
  1386             {
  1381             DLTRACE(( "Pausable" ));
  1387             DLTRACE(( "Pausable" ));
  1382             iState.iOperationState = ECatalogsHttpOpPausable;
  1388             iState.iOperationState = ECatalogsHttpOpPausable;
  1383             HandleEventProgressL( aEvent );
  1389             HandleEventProgressL( aEvent );
  1409             {
  1415             {
  1410             break;
  1416             break;
  1411             }	
  1417             }	
  1412         }
  1418         }
  1413     }
  1419     }
  1414 
  1420 */
  1415 
  1421 
  1416 
  1422 
  1417 // ---------------------------------------------------------------------------
  1423 // ---------------------------------------------------------------------------
  1418 // 
  1424 // 
  1419 // ---------------------------------------------------------------------------
  1425 // ---------------------------------------------------------------------------
  1420 //	
  1426 //	
       
  1427 /*
  1421 void CCatalogsHttpDownload::HandleEventProgressL( const 
  1428 void CCatalogsHttpDownload::HandleEventProgressL( const 
  1422     THttpDownloadEvent& aEvent )
  1429     THttpDownloadEvent& aEvent )
  1423     {
  1430     {
  1424     DLTRACEIN(( "" ));
  1431     DLTRACEIN(( "" ));
  1425 	switch ( aEvent.iProgressState ) 
  1432 	switch ( aEvent.iProgressState ) 
  1689 		    DLTRACE(("Default"));
  1696 		    DLTRACE(("Default"));
  1690 		    DLTRACE(( "state: %d, progress: %d",aEvent.iDownloadState, aEvent.iProgressState));
  1697 		    DLTRACE(( "state: %d, progress: %d",aEvent.iDownloadState, aEvent.iProgressState));
  1691 			break;
  1698 			break;
  1692 		}
  1699 		}
  1693     }
  1700     }
  1694     
  1701  */   
  1695 
  1702 
  1696 
  1703 
  1697 // ---------------------------------------------------------------------------
  1704 // ---------------------------------------------------------------------------
  1698 // Sets file server session
  1705 // Sets file server session
  1699 // ---------------------------------------------------------------------------
  1706 // ---------------------------------------------------------------------------
  1795         {
  1802         {
  1796         // Download always exists when this is called so no need to check
  1803         // Download always exists when this is called so no need to check
  1797         DLTRACE(("Updating the content type"));
  1804         DLTRACE(("Updating the content type"));
  1798         QString contentType;
  1805         QString contentType;
  1799         contentType= iDownload->attribute(WRT::ContentType).toString();
  1806         contentType= iDownload->attribute(WRT::ContentType).toString();
  1800         	TBuf<KMaxContentTypeLength>  ContentType(contentType.utf16());
  1807         // HLa TBuf<KMaxContentTypeLength>  ContentType(contentType.utf16());
       
  1808         TBuf<256>  ContentType(contentType.utf16());
  1801         	iContentType.Copy(ContentType);
  1809         	iContentType.Copy(ContentType);
  1802    
  1810    
  1803         }
  1811         }
  1804     DLTRACEOUT(("Content-type: %S", &iContentType ));
  1812     DLTRACEOUT(("Content-type: %S", &iContentType ));
  1805     }
  1813     }
  1916     {
  1924     {
  1917     DLTRACEIN( ("") );
  1925     DLTRACEIN( ("") );
  1918     // Get the current url of the download
  1926     // Get the current url of the download
  1919     RBuf8 buf;
  1927     RBuf8 buf;
  1920     CleanupClosePushL( buf );
  1928     CleanupClosePushL( buf );
       
  1929     const TInt KMaxUrlLength = 2048;
  1921     buf.CreateL( KMaxUrlLength );
  1930     buf.CreateL( KMaxUrlLength );
  1922     QString string;
  1931     QString string;
  1923 	try
  1932 	try
  1924 	{
  1933 	{
  1925     string = iDownload->attribute(SourceUrl).toString();
  1934     string = iDownload->attribute(SourceUrl).toString();
  2146 // ---------------------------------------------------------------------------
  2155 // ---------------------------------------------------------------------------
  2147 //	    
  2156 //	    
  2148 TUint CCatalogsHttpDownload::MatchWithPredefinedRequestHeader( 
  2157 TUint CCatalogsHttpDownload::MatchWithPredefinedRequestHeader( 
  2149     const TDesC8& aHeader ) const
  2158     const TDesC8& aHeader ) const
  2150     {
  2159     {
       
  2160     /* HLa
  2151     if ( aHeader.CompareF( KHttpRequestAcceptHeader ) == 0 ) 
  2161     if ( aHeader.CompareF( KHttpRequestAcceptHeader ) == 0 ) 
  2152         {
  2162         {
  2153         return EDlAttrRequestAccept;
  2163         return EDlAttrRequestAccept;
  2154         }
  2164         }
  2155     else if ( aHeader.CompareF( KHttpRequestAcceptCharSetHeader ) == 0 ) 
  2165     else if ( aHeader.CompareF( KHttpRequestAcceptCharSetHeader ) == 0 ) 
  2190         }
  2200         }
  2191     else if ( aHeader.CompareF( KHttpRequestVaryHeader ) == 0 ) 
  2201     else if ( aHeader.CompareF( KHttpRequestVaryHeader ) == 0 ) 
  2192         {
  2202         {
  2193         return EDlAttrRequestVary;
  2203         return EDlAttrRequestVary;
  2194         }
  2204         }
  2195     
  2205     */
  2196     return 0;
  2206     return 0;
  2197     }
  2207     }
  2198     
  2208     
  2199     
  2209     
  2200 // ---------------------------------------------------------------------------
  2210 // ---------------------------------------------------------------------------
  2203 // ---------------------------------------------------------------------------
  2213 // ---------------------------------------------------------------------------
  2204 //	           
  2214 //	           
  2205 TUint CCatalogsHttpDownload::MatchWithPredefinedGeneralHeader( 
  2215 TUint CCatalogsHttpDownload::MatchWithPredefinedGeneralHeader( 
  2206     const TDesC8& aHeader ) const
  2216     const TDesC8& aHeader ) const
  2207     {
  2217     {
       
  2218     /* HLa
  2208     if ( aHeader.CompareF( KHttpGeneralCacheControlHeader ) == 0 ) 
  2219     if ( aHeader.CompareF( KHttpGeneralCacheControlHeader ) == 0 ) 
  2209         {
  2220         {
  2210         return EDlAttrGeneralCacheControl;
  2221         return EDlAttrGeneralCacheControl;
  2211         }    
  2222         }    
  2212     else if ( aHeader.CompareF( KHttpGeneralDateHeader ) == 0 ) 
  2223     else if ( aHeader.CompareF( KHttpGeneralDateHeader ) == 0 ) 
  2222         return EDlAttrGeneralVia;
  2233         return EDlAttrGeneralVia;
  2223         }    
  2234         }    
  2224     else if ( aHeader.CompareF( KHttpGeneralWarningHeader ) == 0 ) 
  2235     else if ( aHeader.CompareF( KHttpGeneralWarningHeader ) == 0 ) 
  2225         {
  2236         {
  2226         return EDlAttrGeneralWarning;
  2237         return EDlAttrGeneralWarning;
  2227         }    
  2238         }
       
  2239         */    
  2228     return 0;
  2240     return 0;
  2229     }
  2241     }
  2230     
  2242     
  2231     
  2243     
  2232 // ---------------------------------------------------------------------------
  2244 // ---------------------------------------------------------------------------
  2235 // ---------------------------------------------------------------------------
  2247 // ---------------------------------------------------------------------------
  2236 //	    
  2248 //	    
  2237 TUint CCatalogsHttpDownload::MatchWithPredefinedEntityHeader( 
  2249 TUint CCatalogsHttpDownload::MatchWithPredefinedEntityHeader( 
  2238     const TDesC8& aHeader ) const
  2250     const TDesC8& aHeader ) const
  2239     {
  2251     {
       
  2252     /*
  2240     if ( aHeader.CompareF( KHttpEntityAllowHeader ) == 0 ) 
  2253     if ( aHeader.CompareF( KHttpEntityAllowHeader ) == 0 ) 
  2241         {
  2254         {
  2242         return EDlAttrEntityAllow;
  2255         return EDlAttrEntityAllow;
  2243         }    
  2256         }    
  2244     else if ( aHeader.CompareF( KHttpEntityContentEncodingHeader ) == 0 ) 
  2257     else if ( aHeader.CompareF( KHttpEntityContentEncodingHeader ) == 0 ) 
  2259         }
  2272         }
  2260     else if ( aHeader.CompareF( KHttpEntityLastModifiedHeader ) == 0 ) 
  2273     else if ( aHeader.CompareF( KHttpEntityLastModifiedHeader ) == 0 ) 
  2261         {
  2274         {
  2262         return EDlAttrEntityLastModified;
  2275         return EDlAttrEntityLastModified;
  2263         }
  2276         }
       
  2277         */
  2264     return 0;
  2278     return 0;
  2265     }
  2279     }
  2266         
  2280         
  2267 
  2281 
  2268 // ---------------------------------------------------------------------------
  2282 // ---------------------------------------------------------------------------
  2297         DLTRACE( ("Reallocating target buffer") );
  2311         DLTRACE( ("Reallocating target buffer") );
  2298         aTarget = aTarget->ReAllocL( headerLength );
  2312         aTarget = aTarget->ReAllocL( headerLength );
  2299         }
  2313         }
  2300 
  2314 
  2301     TPtr8 ptr( aTarget->Des() );
  2315     TPtr8 ptr( aTarget->Des() );
       
  2316     
       
  2317     _LIT8( KHttpFieldSeparator, "\n"); // HLa
       
  2318     const TInt KColon( ':' ); // HLa
  2302     
  2319     
  2303     if( newSize ) 
  2320     if( newSize ) 
  2304         {
  2321         {
  2305         DLTRACE( ("Appending to existing headers") );
  2322         DLTRACE( ("Appending to existing headers") );
  2306         // Append after the existing headers
  2323         // Append after the existing headers