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