27 #include "hspsresource.h" |
27 #include "hspsresource.h" |
28 #include "hspsdomattribute.h" |
28 #include "hspsdomattribute.h" |
29 #include "hspsmanifest.h" |
29 #include "hspsmanifest.h" |
30 #include "bautils.h" |
30 #include "bautils.h" |
31 #include "sysutil.h" |
31 #include "sysutil.h" |
|
32 #include <syslangutil.h> |
32 |
33 |
33 |
34 |
34 _LIT(KHspsFolder, "\\200159c0\\themes\\" ); |
35 _LIT(KHspsFolder, "\\200159c0\\themes\\" ); |
35 _LIT(KSourcesFolder, "\\sources\\"); |
36 _LIT(KSourcesFolder, "\\sources\\"); |
36 _LIT( KThemesFolder, "\\themes\\" ); |
37 _LIT( KThemesFolder, "\\themes\\" ); |
1942 } |
1943 } |
1943 } |
1944 } |
1944 } |
1945 } |
1945 |
1946 |
1946 // ----------------------------------------------------------------------------- |
1947 // ----------------------------------------------------------------------------- |
1947 // hspsServerUtil::FindFilesRecursivelyL |
1948 // hspsServerUtil::FindResourcesL |
1948 // ----------------------------------------------------------------------------- |
1949 // ----------------------------------------------------------------------------- |
1949 void hspsServerUtil::FindFilesRecursivelyL( |
1950 void hspsServerUtil::FindResourcesL( |
1950 RFs& aFs, |
1951 RFs& aFs, |
1951 const RArray<TInt>& aDriveArray, |
1952 const RArray<TInt>& aDriveArray, |
1952 const TDesC& aPath, |
1953 const TDesC& aPath, |
1953 RPointerArray<HBufC>& aFolders, |
1954 RPointerArray<HBufC>& aFileArray, |
|
1955 CArrayFixFlat<TInt>* aDeviceLanguages, |
1954 TBool aRecursive ) |
1956 TBool aRecursive ) |
1955 { |
1957 { |
1956 TParsePtrC parser( aPath ); |
1958 // Scan internal drives only |
1957 |
|
1958 TFindFile fileFinder( aFs ); |
1959 TFindFile fileFinder( aFs ); |
1959 fileFinder.SetFindMask( KDriveAttExclude|KDriveAttRemovable|KDriveAttRemote|KDriveAttSubsted ); |
1960 fileFinder.SetFindMask( KDriveAttExclude|KDriveAttRemovable|KDriveAttRemote|KDriveAttSubsted ); |
1960 |
1961 |
1961 _LIT(KMaskFile, "*"); |
1962 TParsePtrC parser( aPath ); |
|
1963 |
|
1964 // Loop the provided disk drives |
1962 for( TInt driveIndex=0; driveIndex < aDriveArray.Count(); driveIndex++ ) |
1965 for( TInt driveIndex=0; driveIndex < aDriveArray.Count(); driveIndex++ ) |
1963 { |
1966 { |
1964 TChar driveChar; |
1967 TChar driveChar; |
1965 User::LeaveIfError( RFs::DriveToChar( aDriveArray[driveIndex], driveChar ) ); |
1968 User::LeaveIfError( RFs::DriveToChar( aDriveArray[driveIndex], driveChar ) ); |
1966 TBuf16<2> driveBuf(2); |
1969 TBuf16<2> driveBuf(2); |
1968 driveBuf[1] = TUint( TChar(':') ); |
1971 driveBuf[1] = TUint( TChar(':') ); |
1969 |
1972 |
1970 TPath path; |
1973 TPath path; |
1971 path.Copy( driveBuf ); |
1974 path.Copy( driveBuf ); |
1972 path.Append( parser.Path() ); |
1975 path.Append( parser.Path() ); |
1973 |
1976 |
1974 CDir* dirList( NULL ); |
1977 // Find files from the drive and path |
1975 fileFinder.FindWildByDir( KMaskFile, path, dirList ); |
1978 CDir* dirList( NULL ); |
|
1979 fileFinder.FindWildByPath( path, NULL, dirList ); |
1976 if ( dirList ) |
1980 if ( dirList ) |
1977 { |
1981 { |
1978 CleanupStack::PushL( dirList ); |
1982 CleanupStack::PushL( dirList ); |
1979 |
1983 |
1980 const TInt count = dirList->Count(); |
1984 const TInt count = dirList->Count(); |
1981 for( TInt entryIndex = 0; entryIndex < count; entryIndex++ ) |
1985 for( TInt entryIndex = 0; entryIndex < count; entryIndex++ ) |
1982 { |
1986 { |
1983 const TEntry& entry = (*dirList)[ entryIndex ]; |
1987 const TEntry& entry = (*dirList)[ entryIndex ]; |
1984 |
1988 |
1985 TFileName file( path ); |
1989 TFileName file( path ); |
1986 file.Append( entry.iName ); |
1990 file.Append( entry.iName ); |
1987 if( entry.IsDir() ) |
1991 |
1988 { |
1992 if( entry.IsDir() ) |
|
1993 { |
|
1994 if( aDeviceLanguages ) |
|
1995 { |
|
1996 TInt dirLanguage = 0; |
|
1997 TLex lex( entry.iName ); |
|
1998 TBool skipDir = ETrue; |
|
1999 if( lex.Val( dirLanguage ) == KErrNone && dirLanguage >= ELangTest ) |
|
2000 { |
|
2001 for( TInt i=0; i < aDeviceLanguages->Count(); i++ ) |
|
2002 { |
|
2003 TInt supportedLanguage = aDeviceLanguages->At( i ); |
|
2004 if( supportedLanguage == dirLanguage ) |
|
2005 { |
|
2006 skipDir = EFalse; |
|
2007 break; |
|
2008 } |
|
2009 } |
|
2010 } |
|
2011 if( skipDir ) |
|
2012 { |
|
2013 continue; |
|
2014 } |
|
2015 } |
|
2016 |
1989 file.Append( KDoubleBackSlash ); |
2017 file.Append( KDoubleBackSlash ); |
1990 } |
2018 } |
1991 |
2019 |
1992 if( !BaflUtils::FileExists( aFs, file ) ) |
|
1993 { |
|
1994 continue; |
|
1995 } |
|
1996 if( entry.IsDir() && aRecursive ) |
2020 if( entry.IsDir() && aRecursive ) |
1997 { |
2021 { |
1998 FindFilesRecursivelyL( aFs, aDriveArray, file, aFolders ); |
2022 // Find files from the directory and drive |
|
2023 RArray<TInt> driveArray; |
|
2024 CleanupClosePushL( driveArray ); |
|
2025 driveArray.Append( aDriveArray[driveIndex] ); |
|
2026 FindResourcesL( aFs, driveArray, file, aFileArray, NULL ); |
|
2027 CleanupStack::PopAndDestroy( &driveArray ); |
1999 } |
2028 } |
2000 else |
2029 else |
2001 { |
2030 { |
2002 HBufC* nameBuf = file.AllocLC(); |
2031 HBufC* nameBuf = file.AllocLC(); |
2003 aFolders.AppendL( nameBuf ); |
2032 aFileArray.AppendL( nameBuf ); |
2004 CleanupStack::Pop( nameBuf ); |
2033 CleanupStack::Pop( nameBuf ); |
2005 } |
2034 } |
2006 } |
2035 } |
2007 |
2036 |
2008 CleanupStack::PopAndDestroy( dirList ); |
2037 CleanupStack::PopAndDestroy( dirList ); |
2009 dirList = 0; |
2038 dirList = 0; |
2010 } // dirlist |
2039 } // dirlist |
2011 |
2040 |
2012 } // driveIndex |
2041 } // driveIndex |
2013 } |
2042 } |
2014 |
2043 |
|
2044 void hspsServerUtil::GetInstalledLanguagesL( |
|
2045 CArrayFixFlat<TInt>*& aLanguages ) |
|
2046 { |
|
2047 User::LeaveIfError( SysLangUtil::GetInstalledLanguages( aLanguages ) ); |
|
2048 CleanupStack::PushL( aLanguages ); |
|
2049 |
|
2050 const TInt testLang = (TInt)ELangTest; |
|
2051 |
|
2052 TBool isIncluded = EFalse; |
|
2053 for( TInt i = 0; i < aLanguages->Count(); i++ ) |
|
2054 { |
|
2055 if( aLanguages->At( i ) == testLang ) |
|
2056 { |
|
2057 isIncluded = ETrue; |
|
2058 break; |
|
2059 } |
|
2060 } |
|
2061 |
|
2062 if( !isIncluded ) |
|
2063 { |
|
2064 aLanguages->InsertL( 0, testLang ); |
|
2065 } |
|
2066 |
|
2067 CleanupStack::Pop( aLanguages ); |
|
2068 } |
|
2069 |
2015 |
2070 |
2016 // ----------------------------------------------------------------------------- |
2071 // ----------------------------------------------------------------------------- |
2017 // hspsServerUtil::hspsServerUtil |
2072 // hspsServerUtil::hspsServerUtil |
2018 // ----------------------------------------------------------------------------- |
2073 // ----------------------------------------------------------------------------- |
2019 // |
2074 // |