2271 tags ); |
2272 tags ); |
2272 |
2273 |
2273 CleanupStack::PopAndDestroy( dtdPath ); |
2274 CleanupStack::PopAndDestroy( dtdPath ); |
2274 } |
2275 } |
2275 |
2276 |
|
2277 // ----------------------------------------------------------------------------- |
|
2278 // ChspsInstallationHandler::AddInterfaceResourcesV2L |
|
2279 // ----------------------------------------------------------------------------- |
|
2280 // |
2276 void ChspsInstallationHandler::AddInterfaceResourcesV2L( |
2281 void ChspsInstallationHandler::AddInterfaceResourcesV2L( |
2277 const TDesC& aPath ) |
2282 const TDesC& aPath ) |
2278 { |
2283 { |
2279 // Find all locale specific subfolders |
2284 RArray<TInt> driveArray; |
2280 TFindFile fileFinder( iFsSession ); |
2285 CleanupClosePushL( driveArray ); |
2281 _LIT( KFilter, "*" ); |
2286 |
2282 CDir* fileList( NULL ); |
2287 // Set search order for eclipsing, only the ROM and UDA drives should be scanned |
2283 fileFinder.FindWildByDir( KFilter, aPath, fileList ); |
2288 driveArray.Append( EDriveC ); |
2284 if ( fileList ) |
2289 driveArray.Append( EDriveZ ); |
2285 { |
2290 |
2286 CleanupStack::PushL( fileList ); |
2291 // Find all unique locale entries under the Xuikon folders in either drive |
2287 TFileName localePath; |
2292 RPointerArray<HBufC> locales; |
2288 for( TInt i = 0; i < fileList->Count(); i++ ) |
2293 CleanupClosePushL( locales ); |
2289 { |
2294 hspsServerUtil::FindFilesRecursivelyL( |
2290 const TEntry& entry = (*fileList)[i]; |
2295 iFsSession, |
2291 if ( entry.IsDir() ) |
2296 driveArray, |
2292 { |
2297 aPath, |
2293 TInt languageIndex = 0; |
2298 locales, |
2294 TLex lex( entry.iName ); |
2299 EFalse ); |
2295 TInt error = lex.Val( languageIndex ); |
2300 |
2296 |
2301 // Find all file entries under the Xuikon folders in either drive |
2297 // See enumarations from e32lang.h |
2302 RPointerArray<HBufC> folders; |
2298 if( !error && languageIndex >= ELangTest ) |
2303 CleanupClosePushL( folders ); |
2299 { |
2304 hspsServerUtil::FindFilesRecursivelyL( |
2300 // If we found the first language specification |
2305 iFsSession, |
2301 if ( !iDefaultSpecificationSet ) |
2306 driveArray, |
|
2307 aPath, |
|
2308 folders, |
|
2309 ETrue ); |
|
2310 |
|
2311 // Loop language folders |
|
2312 for(TInt localeIndex=0; localeIndex < locales.Count(); localeIndex++ ) |
|
2313 { |
|
2314 TParsePtrC localeParser( locales[ localeIndex ]->Des() ); |
|
2315 TPath localePath = localeParser.Path(); |
|
2316 |
|
2317 TPath tempPath = locales[ localeIndex ]->Des(); |
|
2318 if( tempPath.Right( KPathDelim().Length() ).Compare( KPathDelim() ) == 0 ) |
|
2319 { |
|
2320 tempPath.Delete( tempPath.Length() - KPathDelim().Length(), KPathDelim().Length() ); |
|
2321 } |
|
2322 TParsePtrC tempParser( tempPath ); |
|
2323 TFileName localeName = tempParser.Name(); |
|
2324 TInt languageIndex = 0; |
|
2325 TLex lex( localeName ); |
|
2326 if( lex.Val( languageIndex ) != KErrNone ) |
|
2327 { |
|
2328 continue; |
|
2329 } |
|
2330 if( languageIndex < ELangTest ) |
|
2331 { |
|
2332 User::Leave( KErrIllegalInstallation ); |
|
2333 } |
|
2334 |
|
2335 // If we found the first language specification |
|
2336 if ( !iDefaultSpecificationSet ) |
|
2337 { |
|
2338 // Assume this is the default language shown when device language is not supported |
|
2339 iDefaultSpecification = (TLanguage)languageIndex; |
|
2340 iDefaultSpecificationSet = ETrue; |
|
2341 } |
|
2342 |
|
2343 // Loop file resources which should be found from either drive |
|
2344 ChspsResource* resource = NULL; |
|
2345 for( TInt resourceIndex=0; resourceIndex < iTempLocalizedResourceList->Count(); resourceIndex++ ) |
|
2346 { |
|
2347 resource = iTempLocalizedResourceList->At( resourceIndex ); |
|
2348 TFileName file; |
|
2349 |
|
2350 for( TInt folderIndex=0; folderIndex < folders.Count(); folderIndex++ ) |
|
2351 { |
|
2352 TParsePtrC folderParser( folders[ folderIndex ]->Des() ); |
|
2353 TPath folderPath = folderParser.Path(); |
|
2354 TFileName name = folderParser.Name(); |
|
2355 |
|
2356 if( localePath.CompareF( folderPath ) == 0 ) |
|
2357 { |
|
2358 TFileName fixedName = hspsServerUtil::GetFixedOdtName( folderParser.NameAndExt() ); |
|
2359 if( fixedName.CompareF( resource->FileName() ) == 0 ) |
2302 { |
2360 { |
2303 // Assume this is the default language shown incase |
2361 file = folders[ folderIndex ]->Des(); |
2304 // there is no locale for the active UI language |
2362 break; |
2305 iDefaultSpecification = (TLanguage)languageIndex; |
|
2306 iDefaultSpecificationSet = ETrue; |
|
2307 } |
2363 } |
2308 |
2364 } |
2309 // Setup a path to the subdirectory |
2365 } |
2310 localePath.Copy( aPath ); |
2366 |
2311 localePath.Append( entry.iName ); |
2367 if( file.Length() ) |
2312 localePath.Append( KPathDelim ); |
2368 { |
2313 |
2369 TBool duplicate = EFalse; |
2314 // Find localized resources |
2370 for( TInt i=0; i< iResourceList->Count(); i++ ) |
2315 AddLocalizedResourcesV2L( |
2371 { |
2316 localePath, |
2372 ChspsResource* r = iResourceList->At(i); |
2317 (TLanguage)languageIndex ); |
2373 if( r->Language() == languageIndex |
2318 } |
2374 && r->FileName().CompareF( file ) == 0 ) |
2319 } |
|
2320 |
|
2321 } |
|
2322 CleanupStack::PopAndDestroy( fileList ); |
|
2323 fileList = NULL; |
|
2324 } |
|
2325 |
|
2326 // If no DTD files were found |
|
2327 if ( iDefaultSpecification != ELangTest || !iDefaultSpecificationSet ) |
|
2328 { |
|
2329 // Halt installation, test language was not found |
|
2330 User::Leave( KErrNotFound ); |
|
2331 } |
|
2332 } |
|
2333 |
|
2334 void ChspsInstallationHandler::AddLocalizedResourcesV2L( |
|
2335 const TDesC& aPath, |
|
2336 const TLanguage aLanguage ) |
|
2337 { |
|
2338 TFindFile fileFinder( iFsSession ); |
|
2339 _LIT( KFilter, "*" ); |
|
2340 CDir* fileList( NULL ); |
|
2341 fileFinder.FindWildByDir( KFilter, aPath, fileList ); |
|
2342 if ( fileList ) |
|
2343 { |
|
2344 CleanupStack::PushL( fileList ); |
|
2345 |
|
2346 TFileName localePath; |
|
2347 ChspsResource* resource = NULL; |
|
2348 for( TInt i = 0; i < fileList->Count(); i++ ) |
|
2349 { |
|
2350 const TEntry& entry = (*fileList)[i]; |
|
2351 if ( !entry.IsDir() ) |
|
2352 { |
|
2353 TParsePtrC parserPtr( entry.iName ); |
|
2354 TFileName modName = hspsServerUtil::GetFixedOdtName( entry.iName ); |
|
2355 |
|
2356 TBool addingOk = EFalse; |
|
2357 for( TInt resourceIndex=0; resourceIndex < iTempLocalizedResourceList->Count(); resourceIndex++ ) |
|
2358 { |
|
2359 resource = iTempLocalizedResourceList->At( resourceIndex ); |
|
2360 if( modName.CompareF( resource->FileName() ) == 0 ) |
|
2361 { |
2375 { |
2362 addingOk = ETrue; |
2376 duplicate = ETrue; |
2363 break; |
2377 break; |
2364 } |
2378 } |
2365 } |
2379 } |
2366 if ( addingOk ) |
2380 if( !duplicate ) |
2367 { |
2381 { |
2368 HBufC* resourcePath = HBufC::NewLC( aPath.Length() + entry.iName.Length() ); |
2382 |
2369 resourcePath->Des().Copy( aPath ); |
|
2370 resourcePath->Des().Append( entry.iName ); |
|
2371 |
|
2372 TPtrC8 mimeType; |
2383 TPtrC8 mimeType; |
2373 TPtrC8 tag; |
2384 TPtrC8 tag; |
2374 |
|
2375 HBufC8* tagBuf8 = NULL; |
2385 HBufC8* tagBuf8 = NULL; |
2376 if ( resource->Tags().Length() ) |
2386 if ( resource->Tags().Length() ) |
2377 { |
2387 { |
2378 tagBuf8 = HBufC8::NewLC( resource->Tags().Length() ); |
2388 tagBuf8 = HBufC8::NewLC( resource->Tags().Length() ); |
2379 tagBuf8->Des().Copy( resource->Tags() ); |
2389 tagBuf8->Des().Copy( resource->Tags() ); |
2380 tag.Set( tagBuf8->Des() ); |
2390 tag.Set( tagBuf8->Des() ); |
2381 } |
2391 } |
2382 |
2392 |
2383 // Add localized files into the resource array |
2393 // Add localized files into the resource array |
2384 AddResourceL( |
2394 AddResourceL( |
2385 *iResourceList, |
2395 *iResourceList, |
2386 *resourcePath, |
2396 file, |
2387 aLanguage, |
2397 (TLanguage)languageIndex, |
2388 EResourceOther, |
2398 EResourceOther, |
2389 mimeType, |
2399 mimeType, |
2390 tag ); |
2400 tag ); |
2391 |
2401 |
2392 if ( tagBuf8 ) |
2402 if ( tagBuf8 ) |
2393 { |
2403 { |
2394 CleanupStack::PopAndDestroy( tagBuf8 ); |
2404 CleanupStack::PopAndDestroy( tagBuf8 ); |
2395 } |
2405 } |
2396 CleanupStack::PopAndDestroy( resourcePath ); |
2406 |
2397 } |
2407 } |
2398 } |
2408 } |
2399 } |
2409 } |
2400 |
2410 |
2401 CleanupStack::PopAndDestroy( fileList ); |
2411 } |
2402 fileList = NULL; |
2412 |
2403 } |
2413 folders.ResetAndDestroy(); |
2404 } |
2414 locales.ResetAndDestroy(); |
2405 |
2415 CleanupStack::PopAndDestroy( 3, &driveArray ); // driveArray, locales, folders, |
|
2416 |
|
2417 if ( iDefaultSpecification != ELangTest || !iDefaultSpecificationSet ) |
|
2418 { |
|
2419 // Halt installation, test language was not found |
|
2420 User::Leave( KErrNotFound ); |
|
2421 } |
|
2422 } |
|
2423 |
2406 // ----------------------------------------------------------------------------- |
2424 // ----------------------------------------------------------------------------- |
2407 // Finds locale specific subdirectories and resources and appends those |
2425 // Finds locale specific subdirectories and resources and appends those |
2408 // into the resource array |
2426 // into the resource array |
2409 // Should be executed prior to the CheckHeader method! |
2427 // Should be executed prior to the CheckHeader method! |
2410 // ----------------------------------------------------------------------------- |
2428 // ----------------------------------------------------------------------------- |