60 _LIT(KHsps, "\\hsps\\" ); |
60 _LIT(KHsps, "\\hsps\\" ); |
61 _LIT(KXuikon, "xuikon" ); |
61 _LIT(KXuikon, "xuikon" ); |
62 |
62 |
63 const TInt KMaxMediaTypeLength = 100; |
63 const TInt KMaxMediaTypeLength = 100; |
64 |
64 |
65 // ============================ MEMBER FUNCTIONS =============================== |
65 // ========================= LOCAL FUNCTIONS ================================== |
|
66 |
|
67 // ---------------------------------------------------------------------------- |
|
68 // CleanupResetAndDestroy() |
|
69 // ---------------------------------------------------------------------------- |
|
70 // |
|
71 template<class T> |
|
72 static void CleanupResetAndDestroy( TAny* aObj ) |
|
73 { |
|
74 if( aObj ) |
|
75 { |
|
76 static_cast<T*>( aObj )->ResetAndDestroy(); |
|
77 } |
|
78 } |
|
79 |
|
80 // ---------------------------------------------------------------------------- |
|
81 // CleanupResetAndDestroyPushL |
|
82 // ---------------------------------------------------------------------------- |
|
83 // |
|
84 template<class T> |
|
85 static void CleanupResetAndDestroyPushL(T& aArray) |
|
86 { |
|
87 CleanupStack::PushL( TCleanupItem( &CleanupResetAndDestroy<T>, &aArray ) ); |
|
88 } |
|
89 |
|
90 // ========================= MEMBER FUNCTIONS ================================== |
66 |
91 |
67 // ----------------------------------------------------------------------------- |
92 // ----------------------------------------------------------------------------- |
68 // Callback function for removing repository lock if error occurs while repository is locked |
93 // Callback function for removing repository lock if error occurs while repository is locked |
69 // ----------------------------------------------------------------------------- |
94 // ----------------------------------------------------------------------------- |
70 // |
95 // |
2188 TLex lex( entry.iName ); |
2213 TLex lex( entry.iName ); |
2189 TInt error = lex.Val( languageIndex ); |
2214 TInt error = lex.Val( languageIndex ); |
2190 |
2215 |
2191 // See enumarations from e32lang.h |
2216 // See enumarations from e32lang.h |
2192 if( !error && languageIndex >= ELangTest ) |
2217 if( !error && languageIndex >= ELangTest ) |
2193 { |
2218 { |
|
2219 |
|
2220 // Process only supported languages |
|
2221 CArrayFixFlat<TInt>* languageCodes = NULL; |
|
2222 hspsServerUtil::GetInstalledLanguagesL( languageCodes ); |
|
2223 CleanupStack::PushL( languageCodes ); |
|
2224 TBool isSupported = EFalse; |
|
2225 for( TInt i=0; i<languageCodes->Count(); i++ ) |
|
2226 { |
|
2227 if( languageCodes->At( i ) == languageIndex ) |
|
2228 { |
|
2229 isSupported = ETrue; |
|
2230 break; |
|
2231 } |
|
2232 } |
|
2233 CleanupStack::PopAndDestroy( languageCodes ); |
|
2234 if( !isSupported ) |
|
2235 { |
|
2236 continue; |
|
2237 } |
|
2238 |
2194 // If we found the first language specification |
2239 // If we found the first language specification |
2195 if ( !iDefaultSpecificationSet ) |
2240 if ( !iDefaultSpecificationSet ) |
2196 { |
2241 { |
2197 // Assume this is the default language shown incase |
2242 // Assume this is the default language shown incase |
2198 // there is no locale for the active UI language |
2243 // there is no locale for the active UI language |
2199 iDefaultSpecification = (TLanguage)languageIndex; |
2244 iDefaultSpecification = (TLanguage)languageIndex; |
2200 iDefaultSpecificationSet = ETrue; |
2245 iDefaultSpecificationSet = ETrue; |
2201 } |
2246 } |
2202 |
2247 |
2203 // Setup a path to the subdirectory |
2248 // Setup a path to the subdirectory |
2204 localePath.Copy( aPath ); |
2249 localePath.Copy( aPath ); |
2205 localePath.Append( entry.iName ); |
2250 localePath.Append( entry.iName ); |
2206 localePath.Append( KPathDelim ); |
2251 localePath.Append( KPathDelim ); |
2207 |
2252 |
2278 // ChspsInstallationHandler::AddInterfaceResourcesV2L |
2310 // ChspsInstallationHandler::AddInterfaceResourcesV2L |
2279 // ----------------------------------------------------------------------------- |
2311 // ----------------------------------------------------------------------------- |
2280 // |
2312 // |
2281 void ChspsInstallationHandler::AddInterfaceResourcesV2L( |
2313 void ChspsInstallationHandler::AddInterfaceResourcesV2L( |
2282 const TDesC& aPath ) |
2314 const TDesC& aPath ) |
2283 { |
2315 { |
|
2316 // Retrieve supported localizations. |
|
2317 |
|
2318 CArrayFixFlat<TInt>* systemEpocLanguageCodes = NULL; |
|
2319 hspsServerUtil::GetInstalledLanguagesL( |
|
2320 systemEpocLanguageCodes ); |
|
2321 CleanupStack::PushL( systemEpocLanguageCodes ); |
|
2322 |
|
2323 // Find all entries under the Xuikon folders that |
|
2324 // match our eclipsing rules and localisations supported by phone. |
|
2325 |
2284 RArray<TInt> driveArray; |
2326 RArray<TInt> driveArray; |
2285 CleanupClosePushL( driveArray ); |
2327 CleanupClosePushL( driveArray ); |
2286 |
2328 driveArray.Append( EDriveE ); |
2287 // Set search order for eclipsing, only the ROM and UDA drives should be scanned |
|
2288 driveArray.Append( EDriveC ); |
2329 driveArray.Append( EDriveC ); |
2289 driveArray.Append( EDriveZ ); |
2330 driveArray.Append( EDriveZ ); |
2290 |
2331 |
2291 // Find all unique locale entries under the Xuikon folders in either drive |
2332 FindResourceFilesL( aPath, ETrue, driveArray, systemEpocLanguageCodes ); |
2292 RPointerArray<HBufC> locales; |
2333 |
2293 CleanupClosePushL( locales ); |
2334 CleanupStack::PopAndDestroy(); // driveArray |
2294 hspsServerUtil::FindFilesRecursivelyL( |
2335 CleanupStack::PopAndDestroy( systemEpocLanguageCodes ); |
2295 iFsSession, |
|
2296 driveArray, |
|
2297 aPath, |
|
2298 locales, |
|
2299 EFalse ); |
|
2300 |
|
2301 // Find all file entries under the Xuikon folders in either drive |
|
2302 RPointerArray<HBufC> folders; |
|
2303 CleanupClosePushL( folders ); |
|
2304 hspsServerUtil::FindFilesRecursivelyL( |
|
2305 iFsSession, |
|
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 ) |
|
2360 { |
|
2361 file = folders[ folderIndex ]->Des(); |
|
2362 break; |
|
2363 } |
|
2364 } |
|
2365 } |
|
2366 |
|
2367 if( file.Length() ) |
|
2368 { |
|
2369 TBool duplicate = EFalse; |
|
2370 for( TInt i=0; i< iResourceList->Count(); i++ ) |
|
2371 { |
|
2372 ChspsResource* r = iResourceList->At(i); |
|
2373 if( r->Language() == languageIndex |
|
2374 && r->FileName().CompareF( file ) == 0 ) |
|
2375 { |
|
2376 duplicate = ETrue; |
|
2377 break; |
|
2378 } |
|
2379 } |
|
2380 if( !duplicate ) |
|
2381 { |
|
2382 |
|
2383 TPtrC8 mimeType; |
|
2384 TPtrC8 tag; |
|
2385 HBufC8* tagBuf8 = NULL; |
|
2386 if ( resource->Tags().Length() ) |
|
2387 { |
|
2388 tagBuf8 = HBufC8::NewLC( resource->Tags().Length() ); |
|
2389 tagBuf8->Des().Copy( resource->Tags() ); |
|
2390 tag.Set( tagBuf8->Des() ); |
|
2391 } |
|
2392 |
|
2393 // Add localized files into the resource array |
|
2394 AddResourceL( |
|
2395 *iResourceList, |
|
2396 file, |
|
2397 (TLanguage)languageIndex, |
|
2398 EResourceOther, |
|
2399 mimeType, |
|
2400 tag ); |
|
2401 |
|
2402 if ( tagBuf8 ) |
|
2403 { |
|
2404 CleanupStack::PopAndDestroy( tagBuf8 ); |
|
2405 } |
|
2406 |
|
2407 } |
|
2408 } |
|
2409 } |
|
2410 |
|
2411 } |
|
2412 |
|
2413 folders.ResetAndDestroy(); |
|
2414 locales.ResetAndDestroy(); |
|
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 } |
2336 } |
2423 |
2337 |
2424 // ----------------------------------------------------------------------------- |
2338 // ----------------------------------------------------------------------------- |
2425 // Finds locale specific subdirectories and resources and appends those |
2339 // Finds locale specific subdirectories and resources and appends those |
2426 // into the resource array |
2340 // into the resource array |
2448 TLex lex( entry.iName ); |
2362 TLex lex( entry.iName ); |
2449 TInt error = lex.Val( languageIndex ); |
2363 TInt error = lex.Val( languageIndex ); |
2450 |
2364 |
2451 // See enumarations from e32lang.h |
2365 // See enumarations from e32lang.h |
2452 if( !error && languageIndex >= ELangTest ) |
2366 if( !error && languageIndex >= ELangTest ) |
2453 { |
2367 { |
|
2368 |
|
2369 // Process only supported languages |
|
2370 CArrayFixFlat<TInt>* languageCodes = NULL; |
|
2371 hspsServerUtil::GetInstalledLanguagesL( languageCodes ); |
|
2372 CleanupStack::PushL( languageCodes ); |
|
2373 TBool isSupported = EFalse; |
|
2374 for( TInt i=0; i<languageCodes->Count(); i++ ) |
|
2375 { |
|
2376 if( languageCodes->At( i ) == languageIndex ) |
|
2377 { |
|
2378 isSupported = ETrue; |
|
2379 break; |
|
2380 } |
|
2381 } |
|
2382 CleanupStack::PopAndDestroy( languageCodes ); |
|
2383 if( !isSupported ) |
|
2384 { |
|
2385 continue; |
|
2386 } |
|
2387 |
2454 // If we found the first language specification |
2388 // If we found the first language specification |
2455 if ( !iDefaultSpecificationSet ) |
2389 if ( !iDefaultSpecificationSet ) |
2456 { |
2390 { |
2457 // Assume this is the default language shown incase |
2391 // Assume this is the default language shown incase |
2458 // there is no locale for the active UI language |
2392 // there is no locale for the active UI language |
2459 iDefaultSpecification = (TLanguage)languageIndex; |
2393 iDefaultSpecification = (TLanguage)languageIndex; |
2460 iDefaultSpecificationSet = ETrue; |
2394 iDefaultSpecificationSet = ETrue; |
2461 } |
2395 } |
2462 |
2396 |
2463 // Setup a path to the subdirectory |
2397 // Setup a path to the subdirectory |
2464 localePath.Copy( aPath ); |
2398 localePath.Copy( aPath ); |
2465 localePath.Append( entry.iName ); |
2399 localePath.Append( entry.iName ); |
2466 localePath.Append( KPathDelim ); |
2400 localePath.Append( KPathDelim ); |
2467 |
2401 |
2529 tagsPtr ); |
2456 tagsPtr ); |
2530 |
2457 |
2531 CleanupStack::PopAndDestroy( dtdPath ); |
2458 CleanupStack::PopAndDestroy( dtdPath ); |
2532 } |
2459 } |
2533 |
2460 |
2534 // Store locale specific resources if the "localization" element has been declared in XML definition |
2461 // Find localized files from the provided directory |
2535 ChspsResource* resource = NULL; |
2462 RArray<TInt> driveArray; |
2536 for( TInt resourceIndex=0; resourceIndex < iTempLocalizedResourceList->Count(); resourceIndex++ ) |
2463 CleanupClosePushL( driveArray ); |
2537 { |
2464 driveArray.Append( EDriveC ); |
2538 resource = iTempLocalizedResourceList->At( resourceIndex ); |
2465 |
2539 |
2466 FindResourceFilesL( aPath, EFalse, driveArray, NULL ); |
2540 HBufC* resourcePath = HBufC::NewLC( aPath.Length() + resource->FileName().Length() ); |
2467 |
2541 resourcePath->Des().Copy( aPath ); |
2468 CleanupStack::PopAndDestroy(); // driveArray |
2542 resourcePath->Des().Append( resource->FileName() ); |
|
2543 |
|
2544 TDataType dataType( resource->MimeType() ); |
|
2545 |
|
2546 TPtrC8 tagsPtr; |
|
2547 HBufC8* tagBuf8 = NULL; |
|
2548 if ( resource->Tags().Length() ) |
|
2549 { |
|
2550 tagBuf8 = HBufC8::NewLC( resource->Tags().Length() ); |
|
2551 tagBuf8->Des().Copy( resource->Tags() ); |
|
2552 tagsPtr.Set( tagBuf8->Des() ); |
|
2553 } |
|
2554 |
|
2555 // Add localized files into the resource array |
|
2556 AddResourceL( |
|
2557 *iResourceList, |
|
2558 *resourcePath, |
|
2559 aLanguage, |
|
2560 EResourceOther, |
|
2561 dataType.Des8(), |
|
2562 tagsPtr |
|
2563 ); |
|
2564 |
|
2565 if ( tagBuf8 ) |
|
2566 { |
|
2567 CleanupStack::PopAndDestroy( tagBuf8 ); |
|
2568 } |
|
2569 |
|
2570 CleanupStack::PopAndDestroy( resourcePath ); |
|
2571 } |
|
2572 |
|
2573 } |
2469 } |
2574 |
2470 |
2575 // ----------------------------------------------------------------------------- |
2471 // ----------------------------------------------------------------------------- |
2576 // ChspsInstallationHandler::ApplyUidRangeTestsL |
2472 // ChspsInstallationHandler::ApplyUidRangeTestsL |
2577 // ----------------------------------------------------------------------------- |
2473 // ----------------------------------------------------------------------------- |
2675 } // IsFile |
2571 } // IsFile |
2676 |
2572 |
2677 CleanupStack::Pop( aResultString ); |
2573 CleanupStack::Pop( aResultString ); |
2678 } |
2574 } |
2679 |
2575 |
|
2576 // ----------------------------------------------------------------------------- |
|
2577 // ChspsInstallationHandler::FindResourceFilesL |
|
2578 // ----------------------------------------------------------------------------- |
|
2579 // |
|
2580 void ChspsInstallationHandler::FindResourceFilesL( const TDesC& aPath, |
|
2581 const TBool aRecursive, |
|
2582 RArray<TInt>& aDriveArray, |
|
2583 CArrayFixFlat<TInt>* aDeviceLanguages ) |
|
2584 { |
|
2585 RPointerArray<HBufC> filesArray; |
|
2586 CleanupResetAndDestroyPushL( filesArray ); |
|
2587 |
|
2588 hspsServerUtil::FindResourcesL( |
|
2589 iFsSession, |
|
2590 aDriveArray, |
|
2591 aPath, |
|
2592 filesArray, |
|
2593 aDeviceLanguages, |
|
2594 aRecursive ); |
|
2595 |
|
2596 // Filter search results and select only relevant files |
|
2597 TInt error = KErrNone; |
|
2598 for( TInt i = 0; i < filesArray.Count(); i++ ) |
|
2599 { |
|
2600 const TFileName fileName = filesArray[ i ]->Des(); |
|
2601 |
|
2602 // Check that file is listed in manifest resource. |
|
2603 |
|
2604 error = KErrNotFound; |
|
2605 |
|
2606 TParsePtrC fileNameParser( fileName ); |
|
2607 const TFileName fixedName = |
|
2608 hspsServerUtil::GetFixedOdtName( fileNameParser.NameAndExt() ); |
|
2609 |
|
2610 ChspsResource* temporaryResource = NULL; |
|
2611 |
|
2612 for( TInt j = 0; |
|
2613 j < iTempLocalizedResourceList->Count(); |
|
2614 j++ ) |
|
2615 { |
|
2616 temporaryResource = iTempLocalizedResourceList->At( j ); |
|
2617 if( fixedName.CompareF( temporaryResource->FileName() ) == 0 ) |
|
2618 { |
|
2619 error = KErrNone; |
|
2620 break; |
|
2621 } |
|
2622 } |
|
2623 |
|
2624 // Extract localisation code from path. |
|
2625 |
|
2626 TInt localizationCode = 0; |
|
2627 |
|
2628 if( error == KErrNone ) |
|
2629 { |
|
2630 TPath path = fileNameParser.Path(); |
|
2631 if( path.Right( KPathDelim().Length() ).Compare( KPathDelim() ) == 0 ) |
|
2632 { |
|
2633 path.Delete( path.Length() - KPathDelim().Length(), KPathDelim().Length() ); |
|
2634 } |
|
2635 |
|
2636 TParsePtrC localizationParser( path ); |
|
2637 TLex lex( localizationParser.Name() ); |
|
2638 error = lex.Val( localizationCode ); |
|
2639 |
|
2640 if( error == KErrNone && localizationCode < ELangTest ) |
|
2641 { |
|
2642 error = KErrCorrupt; |
|
2643 } |
|
2644 } |
|
2645 |
|
2646 // Check for duplicates. |
|
2647 |
|
2648 if( error == KErrNone ) |
|
2649 { |
|
2650 for( TInt k = 0; k < iResourceList->Count(); k++ ) |
|
2651 { |
|
2652 ChspsResource* resource = iResourceList->At( k ); |
|
2653 |
|
2654 if( resource->Language() == localizationCode && |
|
2655 resource->FileName().CompareF( fileName ) == 0 ) |
|
2656 { |
|
2657 error = KErrAlreadyExists; |
|
2658 break; |
|
2659 } |
|
2660 } |
|
2661 } |
|
2662 |
|
2663 // Add to actual resource list. |
|
2664 if( error == KErrNone ) |
|
2665 { |
|
2666 TPtrC8 tag; |
|
2667 HBufC8* tagBuf8 = NULL; |
|
2668 |
|
2669 if ( temporaryResource->Tags().Length() ) |
|
2670 { |
|
2671 tagBuf8 = HBufC8::NewLC( temporaryResource->Tags().Length() ); |
|
2672 tagBuf8->Des().Copy( temporaryResource->Tags() ); |
|
2673 tag.Set( tagBuf8->Des() ); |
|
2674 } |
|
2675 |
|
2676 TDataType dataType( temporaryResource->MimeType() ); |
|
2677 |
|
2678 // Add localized files into the resource array |
|
2679 AddResourceL( |
|
2680 *iResourceList, |
|
2681 fileName, |
|
2682 (TLanguage)localizationCode, |
|
2683 EResourceOther, |
|
2684 dataType.Des8(), |
|
2685 tag ); |
|
2686 |
|
2687 if ( tagBuf8 ) |
|
2688 { |
|
2689 CleanupStack::PopAndDestroy( tagBuf8 ); |
|
2690 } |
|
2691 } |
|
2692 } |
|
2693 |
|
2694 CleanupStack::PopAndDestroy(); // filesArray |
|
2695 } |
|
2696 |
2680 // end of file |
2697 // end of file |