codhandler/codeng/src/CodEngBase.cpp
branchRCL_3
changeset 93 79859ed3eea9
parent 91 30342f40acbf
child 94 919f36ff910f
equal deleted inserted replaced
92:e1bea15f9a39 93:79859ed3eea9
    15 *      Implementation of class CCodEngBase.   
    15 *      Implementation of class CCodEngBase.   
    16 *      
    16 *      
    17 *
    17 *
    18 */
    18 */
    19 
    19 
       
    20 
    20 // INCLUDE FILES
    21 // INCLUDE FILES
    21 
    22 
    22 #include "CodEngBase.h"
    23 #include "CodEngBase.h"
    23 #include "Connection.h"
    24 #include "Connection.h"
    24 #include "HttpLoader.h"
    25 #include "HttpLoader.h"
    37 #include "MediaObject.h"
    38 #include "MediaObject.h"
    38 #include "DownloadDataClient.h"
    39 #include "DownloadDataClient.h"
    39 
    40 
    40 #include <AiwGenericParam.h>
    41 #include <AiwGenericParam.h>
    41 #include <DocumentHandler.h>
    42 #include <DocumentHandler.h>
    42 #include <ApmStd.h>
    43 #include <apmstd.h>
    43 #include <Oma2Agent.h>
    44 #include <Oma2Agent.h>
    44 #include <RoapDef.h>
    45 #include <RoapDef.h>
    45 #include <f32file.h>
    46 #include <f32file.h>
    46 #include <bodypart.h>
    47 #include <bodypart.h>
    47 #include <SysUtil.h>
    48 #include <sysutil.h>
    48 #include <pathinfo.h>
    49 #include <pathinfo.h>
    49 #include "CodDefs.h"
    50 #include "CodDefs.h"
    50 #include <CodUi.rsg>
    51 #include <CodUi.rsg>
    51 #include <AknQueryDialog.h>
    52 #include <AknQueryDialog.h>
    52 #include <stringloader.h>
    53 #include <StringLoader.h>
    53 #include <bautils.h>
    54 #include  <bautils.h>
    54 #include "FileExt.h"
    55 #include    "FileExt.h"
    55 
    56 
    56 #ifdef __SYNCML_DM_FOTA
    57 #ifdef __SYNCML_DM_FOTA
    57 #include <fotaengine.h>
    58 #include <fotaengine.h>
    58 #include "FotaSaver.h"
    59 #include "FotaSaver.h"
    59 /// FOTA Update Package type.
    60 /// FOTA Update Package type.
    63 #endif /*def __SYNCML_DM_FOTA */
    64 #endif /*def __SYNCML_DM_FOTA */
    64 
    65 
    65 #ifdef RD_MULTIPLE_DRIVE
    66 #ifdef RD_MULTIPLE_DRIVE
    66 #include <centralrepository.h>
    67 #include <centralrepository.h>
    67 #include <driveinfo.h>
    68 #include <driveinfo.h>
    68 #include <browseruisdkcrkeys.h>
    69 #include <BrowserUiSDKCRKeys.h>
    69 #endif //RD_MULTIPLE_DRIVE
    70 #endif //RD_MULTIPLE_DRIVE
    70 
    71 
    71 #include <bldvariant.hrh>
    72 #include <bldvariant.hrh>
    72 
    73 
    73 // ================= CONSTANTS =======================
    74 // ================= CONSTANTS =======================
   480 // CCodEngBase::RemovableMedia()
   481 // CCodEngBase::RemovableMedia()
   481 // ---------------------------------------------------------
   482 // ---------------------------------------------------------
   482 //
   483 //
   483 EXPORT_C TBool CCodEngBase::RemovableMedia() const
   484 EXPORT_C TBool CCodEngBase::RemovableMedia() const
   484     {
   485     {
   485     return ( KDriveAttRemovable == iRemovableMediaStatus ) ? ETrue : EFalse ;
   486     return iRemovableMedia;
   486     }
   487     }
   487 
   488 
   488 // ---------------------------------------------------------
   489 // ---------------------------------------------------------
   489 // CCodEngBase::GetPath()
   490 // CCodEngBase::GetPath()
   490 // ---------------------------------------------------------
   491 // ---------------------------------------------------------
   578   iAvailDriveSpace( -1 ),
   579   iAvailDriveSpace( -1 ),
   579 #else
   580 #else
   580   iPhoneMemoryOk( EFalse ),
   581   iPhoneMemoryOk( EFalse ),
   581   iMmcOk( EFalse ),
   582   iMmcOk( EFalse ),
   582 #endif
   583 #endif
   583   iRemovableMediaStatus( KDriveAttLocal ),
   584   iRemovableMedia( EFalse ),
   584   iStatusCode( KHttp902UserCancelled ),
   585   iStatusCode( KHttp902UserCancelled ),
   585   iResult( KErrGeneral ),
   586   iResult( KErrGeneral ),
   586   iContentTypeCheck ( EFalse ),
   587   iContentTypeCheck ( EFalse ),
   587   iResumedDownload ( EFalse )  
   588   iResumedDownload ( EFalse )  
   588     {
   589     {
  1700     {
  1701     {
  1701     CLOG(( ECodEng, 2, _L("-> CCodEngBase::CapabilityCheckL") ));
  1702     CLOG(( ECodEng, 2, _L("-> CCodEngBase::CapabilityCheckL") ));
  1702     __ASSERT_DEBUG( iData->ActiveDownload(),CodPanic( ECodInternal ));
  1703     __ASSERT_DEBUG( iData->ActiveDownload(),CodPanic( ECodInternal ));
  1703     // 1. Data type checking.
  1704     // 1. Data type checking.
  1704     TInt typeErr( KErrNone );    
  1705     TInt typeErr( KErrNone );    
       
  1706 #ifdef __SYNCML_DM_FOTA
       
  1707     TBool fota( EFalse );
       
  1708 #endif /*def __SYNCML_DM_FOTA */
  1705     for ( TInt i = 0; i < (*iData)[iData->ActiveDownload()]->Types().MdcaCount() && !iContentTypeCheck; i++ )
  1709     for ( TInt i = 0; i < (*iData)[iData->ActiveDownload()]->Types().MdcaCount() && !iContentTypeCheck; i++ )
  1706         {
  1710         {
  1707         const TDataType& type( (*iData)[iData->ActiveDownload()]->Types().MdcaPoint( i ) );
  1711         const TDataType& type( (*iData)[iData->ActiveDownload()]->Types().MdcaPoint( i ) );
  1708 #ifdef __TEST_COD_LOG
  1712 #ifdef __TEST_COD_LOG
  1709         TPtrC8 mime( type.Des8() );
  1713         TPtrC8 mime( type.Des8() );
  1740 #ifdef __SYNCML_DM_FOTA
  1744 #ifdef __SYNCML_DM_FOTA
  1741         else if ( type == TDataType( KFotaPackageDataType ) )
  1745         else if ( type == TDataType( KFotaPackageDataType ) )
  1742             {
  1746             {
  1743             // Accept FOTA download. Special storage (not saved to FS).
  1747             // Accept FOTA download. Special storage (not saved to FS).
  1744             CLOG(( ECodEng, 4, _L8("  <%S> FOTA OK"), &mime ));
  1748             CLOG(( ECodEng, 4, _L8("  <%S> FOTA OK"), &mime ));
       
  1749             fota = ETrue;
  1745             }
  1750             }
  1746 #endif /*def __SYNCML_DM_FOTA */
  1751 #endif /*def __SYNCML_DM_FOTA */
  1747         else 
  1752         else 
  1748             {
  1753             {
  1749             CLOG(( ECodEng, 4, _L8("  <%S> DocHandler check"), &mime ));
  1754             CLOG(( ECodEng, 4, _L8("  <%S> DocHandler check"), &mime ));
  1873         if ( iParams )
  1878         if ( iParams )
  1874             {
  1879             {
  1875             CodUtil::GetIntParam( pkgId, EGenericParamFotaPkgId, *iParams );
  1880             CodUtil::GetIntParam( pkgId, EGenericParamFotaPkgId, *iParams );
  1876             }
  1881             }
  1877         iSaver = CFotaSaver::NewL( aType, pkgId );
  1882         iSaver = CFotaSaver::NewL( aType, pkgId );
  1878         FotaSaverSettingL();
  1883         iSaver->SetObserver( iObserver );
       
  1884         iSaver->SetParams( iParams );
       
  1885         iSaver->SetMaxSize( iData->Size() );
       
  1886         iSaver->OpenStoreL();   // TODO unneeded method, put to construction.
  1879         }
  1887         }
  1880 #endif /*def __SYNCML_DM_FOTA */
  1888 #endif /*def __SYNCML_DM_FOTA */
  1881     else
  1889     else
  1882         {
  1890         {
  1883         // TODO the assert below crashes without early reject!
  1891         // TODO the assert below crashes without early reject!
  1884         //__ASSERT_DEBUG( iFsUsed, CodPanic( ECodInternal ) );
  1892         //__ASSERT_DEBUG( iFsUsed, CodPanic( ECodInternal ) );
  1885 
  1893 
  1886         TBool contentTypeMisMatch ( ETrue );
  1894         TBool contentTypeMisMatch ( ETrue );
  1887         TBool fotadownload(EFalse);
       
  1888         for ( TInt i = 0; i < (*iData)[iData->ActiveDownload()]->Types().MdcaCount(); i++ )
  1895         for ( TInt i = 0; i < (*iData)[iData->ActiveDownload()]->Types().MdcaCount(); i++ )
  1889             {
  1896             {
  1890             const TDataType& type( (*iData)[iData->ActiveDownload()]->Types().MdcaPoint( i ) );
  1897             const TDataType& type( (*iData)[iData->ActiveDownload()]->Types().MdcaPoint( i ) );
  1891             if( type.Des8().Find(KFotaPackageDataType) !=KErrNotFound )
  1898             if( ( aType.Find (type.Des8()) != KErrNotFound ) || 
  1892                 {
       
  1893                  fotadownload = ETrue;
       
  1894                  break;
       
  1895                 }
       
  1896             if((aType.Find (type.Des8()) != KErrNotFound) || iDocHandler->CanOpenL(TDataType(aType)) || 
       
  1897                             ( (type.Des8().Find(KOma1DrmMessageContentType)!= KErrNotFound) && (aType.Find(KOma1DcfContentType)!= KErrNotFound )  ))             
  1899                             ( (type.Des8().Find(KOma1DrmMessageContentType)!= KErrNotFound) && (aType.Find(KOma1DcfContentType)!= KErrNotFound )  ))             
  1898                 {
  1900                 {
  1899                 contentTypeMisMatch = EFalse;
  1901                 contentTypeMisMatch = EFalse;
  1900                 break;
  1902                 break;
  1901                 }                
  1903                 }                
  1902             }
  1904             }
  1903         if (fotadownload)
  1905         if(contentTypeMisMatch)
  1904             {
       
  1905              TInt pkgId( KCodDefaultFotaPkgId );
       
  1906              if ( iParams )
       
  1907                 {
       
  1908                  CodUtil::GetIntParam( pkgId, EGenericParamFotaPkgId, *iParams );
       
  1909                 }
       
  1910              iSaver = CFotaSaver::NewL(KFotaPackageDataType(), pkgId );
       
  1911              FotaSaverSettingL();
       
  1912              return iSaver;
       
  1913            }
       
  1914        if(contentTypeMisMatch)
       
  1915             {
  1906             {
  1916             User::Leave(KErrCodAttributeMismatch);
  1907             User::Leave(KErrCodAttributeMismatch);
  1917             }
  1908             }
  1918         
  1909         
  1919         // Do this only if Unique filename check has never been performed earlier for this file.
  1910         // Do this only if Unique filename check has never been performed earlier for this file.
  1965     CLOG(( ECodEng, 2, _L("<- CCodEngBase::CreateSaverL") ));
  1956     CLOG(( ECodEng, 2, _L("<- CCodEngBase::CreateSaverL") ));
  1966     return iSaver;
  1957     return iSaver;
  1967     }
  1958     }
  1968 
  1959 
  1969 // ---------------------------------------------------------
  1960 // ---------------------------------------------------------
  1970 // CCodEngBase::FotaSaverSettingL
       
  1971 // ---------------------------------------------------------
       
  1972 //
       
  1973 void CCodEngBase::FotaSaverSettingL()
       
  1974     {
       
  1975     iSaver->SetObserver( iObserver );
       
  1976     iSaver->SetParams( iParams );
       
  1977     iSaver->SetMaxSize( iData->Size() );
       
  1978     iSaver->OpenStoreL();   // TODO unneeded method, put to construction.
       
  1979     }
       
  1980 
       
  1981 // ---------------------------------------------------------
       
  1982 // CCodEngBase::SetPathsL
  1961 // CCodEngBase::SetPathsL
  1983 // ---------------------------------------------------------
  1962 // ---------------------------------------------------------
  1984 //
  1963 //
  1985 void CCodEngBase::SetPathsL()
  1964 void CCodEngBase::SetPathsL()
  1986     {
  1965     {
  2028                     &KTempFilesCodDirName );      
  2007                     &KTempFilesCodDirName );      
  2029 
  2008 
  2030     (*iData)[iData->ActiveDownload()]->iTempPath.Append(rootPath.Drive());
  2009     (*iData)[iData->ActiveDownload()]->iTempPath.Append(rootPath.Drive());
  2031     (*iData)[iData->ActiveDownload()]->iTempPath.Append(tempBuf);
  2010     (*iData)[iData->ActiveDownload()]->iTempPath.Append(tempBuf);
  2032 
  2011 
  2033 
  2012     TDriveInfo info;
  2034     TDriveUnit unit( rootPath.Drive() );
  2013     TDriveUnit unit( rootPath.Drive() );
  2035 
  2014     User::LeaveIfError( iFs.Drive( info, unit ) );
  2036 #ifdef RD_MULTIPLE_DRIVE    
  2015     // Create the temp directory earlier in case it's not created yet
  2037     TUint aStatus ;
  2016     iFs.MkDirAll( (*iData)[iData->ActiveDownload()]->iTempPath ); 
  2038     
       
  2039     if( KErrNone == DriveInfo::GetDriveStatus( iFs, unit , aStatus ))
       
  2040             {
       
  2041             iRemovableMediaStatus = (aStatus & DriveInfo::EDriveExternallyMountable) ? aStatus : 0 ;
       
  2042             if( iRemovableMediaStatus )
       
  2043                 {
       
  2044                 iRemovableMediaStatus = (aStatus & DriveInfo::EDriveRemovable) ? KDriveAttRemovable : KDriveAttInternal ;				
       
  2045                 }
       
  2046             else
       
  2047                 {
       
  2048                 iRemovableMediaStatus = KDriveAttLocal ;
       
  2049                 }
       
  2050             }    	
       
  2051 #else
       
  2052     TDriveInfo info;
       
  2053     User::LeaveIfError( iFs.Drive( info, unit ) );	
       
  2054     if ( info.iDriveAtt & KDriveAttRemovable )
  2017     if ( info.iDriveAtt & KDriveAttRemovable )
  2055         {
  2018         {
  2056         iRemovableMediaStatus = KDriveAttRemovable;
  2019         iRemovableMedia = ETrue;
  2057         }
  2020         }
  2058     else
  2021         
  2059         {
       
  2060         iRemovableMediaStatus = KDriveAttLocal;
       
  2061         }
       
  2062 #endif
       
  2063     // Create the temp directory earlier in case it's not created yet
       
  2064     iFs.MkDirAll( (*iData)[iData->ActiveDownload()]->iTempPath );
       
  2065     
       
  2066     CLOG(( ECodEng, 2, _L("<- CCodEngBase::SetPathsL root<%S> temp<%S>"), \
  2022     CLOG(( ECodEng, 2, _L("<- CCodEngBase::SetPathsL root<%S> temp<%S>"), \
  2067         &(*iData)[iData->ActiveDownload()]->iRootPath, &(*iData)[iData->ActiveDownload()]->iTempPath ));
  2023         &(*iData)[iData->ActiveDownload()]->iRootPath, &(*iData)[iData->ActiveDownload()]->iTempPath ));
  2068     }
  2024     }
  2069 
  2025 
  2070 // ---------------------------------------------------------
  2026 // ---------------------------------------------------------
  2081     iPhoneMemoryOk = EFalse;
  2037     iPhoneMemoryOk = EFalse;
  2082     iMmcOk = EFalse;
  2038     iMmcOk = EFalse;
  2083 #endif
  2039 #endif
  2084     //(*iData)[iData->ActiveDownload()]->iTempPath = KNullDesC;
  2040     //(*iData)[iData->ActiveDownload()]->iTempPath = KNullDesC;
  2085     //(*iData)[iData->ActiveDownload()]->iRootPath = KNullDesC;
  2041     //(*iData)[iData->ActiveDownload()]->iRootPath = KNullDesC;
  2086 
  2042     iRemovableMedia = EFalse;
  2087     iRemovableMediaStatus = KDriveAttLocal;
       
  2088     }
  2043     }
  2089 
  2044 
  2090 #ifdef RD_MULTIPLE_DRIVE
  2045 #ifdef RD_MULTIPLE_DRIVE
  2091 //------------------------------------------------------------------------
  2046 //------------------------------------------------------------------------
  2092 //CCodEngBase::QueryDynDriveListLC
  2047 //CCodEngBase::QueryDynDriveListLC