homescreenpluginsrv/hspsmanager/src/hspsinstallationhandler.cpp
branchRCL_3
changeset 23 ace62b58f4b2
parent 22 1b207dd38b72
child 25 9e077f9a342c
equal deleted inserted replaced
22:1b207dd38b72 23:ace62b58f4b2
   518 // ChspsInstallationHandler::ValidateL() 
   518 // ChspsInstallationHandler::ValidateL() 
   519 // -----------------------------------------------------------------------------
   519 // -----------------------------------------------------------------------------
   520 //
   520 //
   521 void ChspsInstallationHandler::FinalizeParsingL()
   521 void ChspsInstallationHandler::FinalizeParsingL()
   522     {               
   522     {               
   523     // Check resources
   523     // Add resources
   524     TFileName interfacePath( GetInterfacePath() );       
   524     TFileName interfacePath( GetInterfacePath() );       
   525     if ( interfacePath.Length() )        
   525     if ( interfacePath.Length() )        
   526        {
   526         {
   527        // If name of the DTD file was specified in the manifest
   527         // If name of the DTD file was specified in the manifest
   528        if ( iDtdFile )
   528         if ( iDtdFile )
   529           { 
   529             { 
   530           TParse pathParser;
   530             TParse pathParser;
   531           pathParser.Set( iThemeFilePath, NULL, NULL );                               
   531             pathParser.Set( iThemeFilePath, NULL, NULL );                               
   532           pathParser.PopDir(); // pop locale specific folder
   532             pathParser.PopDir(); // pop locale specific folder
   533           
   533             
   534           // Find locale specific DTD file
   534             // Find locale specific DTD file
   535           AddHspsLocalesV2L( pathParser.FullName() );
   535             AddLocalesL( pathParser.FullName(), ETrue );
   536           }
   536             }
   537        
   537         
   538        // Find Xuikon resources of each locale 
   538         // Find Xuikon resources of each locale 
   539        AddInterfaceResourcesV2L( interfacePath );
   539         AddInterfaceResourcesV2L( interfacePath );
   540        }
   540        }
   541     else
   541     else
   542        {
   542        {
   543        // Find DTD files and locale specific resources from subdirectories under the installation path
   543        // Find DTD files and locale specific resources from subdirectories under the installation path
   544        AddLocalesL( iThemeFilePath );                       
   544        AddLocalesL( iThemeFilePath, EFalse );                       
   545        }       
   545        }       
   546           
   546           
   547    // Validate other input from the manifest
   547    // Validate other input from the manifest
   548    CheckHeaderL();
   548    CheckHeaderL();
   549            
   549            
  2196     {
  2196     {
  2197     iInstallFromUDAEmmc = EFalse;
  2197     iInstallFromUDAEmmc = EFalse;
  2198     }
  2198     }
  2199 
  2199 
  2200 // -----------------------------------------------------------------------------
  2200 // -----------------------------------------------------------------------------
  2201 // Finds locale specific subdirectories and DTD resources and appends those
       
  2202 // into the resource array 
       
  2203 // Should be executed prior to the CheckHeader method!
       
  2204 // -----------------------------------------------------------------------------
       
  2205 //
       
  2206 void ChspsInstallationHandler::AddHspsLocalesV2L(
       
  2207         const TDesC& aPath )
       
  2208     {           
       
  2209     // Find all locale specific subfolders
       
  2210     TFindFile fileFinder( iFsSession );
       
  2211     _LIT( KFilter, "*" );
       
  2212     CDir* fileList( NULL );    
       
  2213     fileFinder.FindWildByDir( KFilter, aPath, fileList );
       
  2214     if ( fileList )
       
  2215         {
       
  2216         CleanupStack::PushL( fileList );
       
  2217         TFileName localePath;
       
  2218         for( TInt i = 0; i < fileList->Count(); i++ )       
       
  2219             {
       
  2220             const TEntry& entry = (*fileList)[i];                        
       
  2221             if ( entry.IsDir() )
       
  2222                 {
       
  2223                 TInt languageIndex = 0;
       
  2224                 TLex lex( entry.iName );
       
  2225                 TInt error = lex.Val( languageIndex );    
       
  2226                                 
       
  2227                 // See enumarations from e32lang.h
       
  2228                 if( !error && languageIndex >= ELangTest )
       
  2229                     {
       
  2230                 
       
  2231                     // Process only supported languages
       
  2232                     CArrayFixFlat<TInt>* languageCodes = NULL;
       
  2233                     hspsServerUtil::GetInstalledLanguagesL( languageCodes );
       
  2234                     CleanupStack::PushL( languageCodes );                    
       
  2235                     TBool isSupported = EFalse;
       
  2236                     for( TInt i=0; i<languageCodes->Count(); i++ )
       
  2237                         {
       
  2238                         if( languageCodes->At( i ) == languageIndex )
       
  2239                             {
       
  2240                             isSupported = ETrue;
       
  2241                             break;
       
  2242                             }
       
  2243                         }
       
  2244                     CleanupStack::PopAndDestroy( languageCodes );                                       
       
  2245                     if( !isSupported )
       
  2246                         {
       
  2247                         continue;
       
  2248                         }           
       
  2249                     
       
  2250                     // If we found the first language specification          
       
  2251                     if ( !iDefaultSpecificationSet )
       
  2252                         {
       
  2253                         // Assume this is the default language shown incase 
       
  2254                         // there is no locale for the active UI language
       
  2255                         iDefaultSpecification = (TLanguage)languageIndex;
       
  2256                         iDefaultSpecificationSet = ETrue;
       
  2257                         }
       
  2258                     
       
  2259                     // Setup a path to the subdirectory 
       
  2260                     localePath.Copy( aPath );
       
  2261                     localePath.Append( entry.iName );
       
  2262                     localePath.Append( KPathDelim );
       
  2263                     
       
  2264                     // Find localized resources 
       
  2265                     AddLocalizedResourcesDTDV2L( 
       
  2266                         localePath,
       
  2267                         (TLanguage)languageIndex );
       
  2268                     }                                       
       
  2269                 }
       
  2270                         
       
  2271             }        
       
  2272         CleanupStack::PopAndDestroy( fileList );
       
  2273         fileList = NULL;
       
  2274         }
       
  2275     }
       
  2276 
       
  2277 // -----------------------------------------------------------------------------
       
  2278 // Adds localized resources from the provided subdirectory
       
  2279 // -----------------------------------------------------------------------------
       
  2280 //
       
  2281 void ChspsInstallationHandler::AddLocalizedResourcesDTDV2L(
       
  2282         const TDesC& aPath,
       
  2283         const TLanguage aLanguage )
       
  2284     {
       
  2285     // Append path with the default name of DTD files
       
  2286     const TInt len = aPath.Length() + iDtdFile->Des().Length();
       
  2287     HBufC* dtdPath = HBufC::NewLC( len );
       
  2288     dtdPath->Des().Copy( aPath );    
       
  2289     dtdPath->Des().Append( *iDtdFile );
       
  2290         
       
  2291     // Check whether the file exists
       
  2292     if( !BaflUtils::FileExists( iFsSession, *dtdPath ) )
       
  2293         {
       
  2294 #ifdef HSPS_LOG_ACTIVE  
       
  2295         if( iLogBus )
       
  2296             {
       
  2297             iLogBus->LogText( _L( "ChspsInstallationHandler::AddLocalizedResourcesDTDV2L(): - DTD file was not found '%S'" ),
       
  2298                     &dtdPath );
       
  2299             }
       
  2300 #endif            
       
  2301         iFileNotFound = ETrue;
       
  2302         iResult->iXuikonError = KErrDtdFileNotFound;
       
  2303         User::Leave( KErrNotFound );
       
  2304         }
       
  2305         
       
  2306     // Store locale specific DTD files into the resource array
       
  2307     TPtrC8 mediaType;
       
  2308     TPtrC8 tags;
       
  2309     AddResourceL(
       
  2310         *iResourceList,
       
  2311         *dtdPath,
       
  2312         aLanguage,
       
  2313         EResourceDTD,
       
  2314         mediaType,
       
  2315         tags );                                
       
  2316     
       
  2317     CleanupStack::PopAndDestroy( dtdPath );
       
  2318     }
       
  2319 
       
  2320 // -----------------------------------------------------------------------------
       
  2321 // ChspsInstallationHandler::AddInterfaceResourcesV2L
  2201 // ChspsInstallationHandler::AddInterfaceResourcesV2L
  2322 // -----------------------------------------------------------------------------
  2202 // -----------------------------------------------------------------------------
  2323 //
  2203 //
  2324 void ChspsInstallationHandler::AddInterfaceResourcesV2L(
  2204 void ChspsInstallationHandler::AddInterfaceResourcesV2L(
  2325         const TDesC& aPath )
  2205         const TDesC& aPath )
  2351 // into the resource array 
  2231 // into the resource array 
  2352 // Should be executed prior to the CheckHeader method!
  2232 // Should be executed prior to the CheckHeader method!
  2353 // -----------------------------------------------------------------------------
  2233 // -----------------------------------------------------------------------------
  2354 //
  2234 //
  2355 void ChspsInstallationHandler::AddLocalesL(
  2235 void ChspsInstallationHandler::AddLocalesL(
  2356         const TDesC& aPath )
  2236         const TDesC& aPath,
       
  2237         const TBool aProcessOnlyDTD )
  2357     {
  2238     {
  2358     // Retrieve phone supported language.
  2239     // Retrieve phone supported language.
  2359     CArrayFixFlat<TInt>* languageCodes = NULL;
  2240     CArrayFixFlat<TInt>* languageCodes = NULL;
  2360     hspsServerUtil::GetInstalledLanguagesL( languageCodes );
  2241     hspsServerUtil::GetInstalledLanguagesL( languageCodes );
  2361     CleanupStack::PushL( languageCodes );     
  2242     CleanupStack::PushL( languageCodes );     
  2362     
  2243     
  2363     // Ensure that path contains '\' at the end.
  2244     // Ensure that path contains '\' at the end.
  2364     TFileName xuikonPath;
  2245     TFileName pathBase;
  2365     xuikonPath.Copy( aPath );
  2246     pathBase.Copy( aPath );
  2366     if( xuikonPath.Length() > KPathDelim().Length() )
  2247     if( pathBase.Length() > KPathDelim().Length() )
  2367         {
  2248         {
  2368         if( xuikonPath.Mid( xuikonPath.Length() -
  2249         if( pathBase.Mid( pathBase.Length() -
  2369                             KPathDelim().Length()
  2250                           KPathDelim().Length()
  2370                             ).Compare( KPathDelim ) != 0 )
  2251                          ).Compare( KPathDelim ) != 0 )
  2371             {
  2252             {
  2372             xuikonPath.Append( KPathDelim );
  2253             pathBase.Append( KPathDelim );
  2373             }
  2254             }
  2374         }
  2255         }
  2375             
  2256             
  2376     _LIT( KFormatting, "%02d" );    
  2257     TParsePtrC driveParser( pathBase );
       
  2258     TInt driveEnum = KErrNotFound;
       
  2259     
       
  2260     if( !aProcessOnlyDTD )
       
  2261         {
       
  2262         if( driveParser.DrivePresent() && driveParser.Drive().Length() > 0 )
       
  2263             {
       
  2264             User::LeaveIfError(
       
  2265                     RFs::CharToDrive( ( driveParser.Drive() )[0],
       
  2266                             driveEnum ) );
       
  2267             }
       
  2268         }
       
  2269     
       
  2270     _LIT( KFormatNN, "%02d" );    
  2377     TFileName localePath;
  2271     TFileName localePath;
  2378     
  2272     
  2379     for( TInt i = 0; i < languageCodes->Count(); i++ )
  2273     for( TInt i = 0; i < languageCodes->Count(); i++ )
  2380         {                       
  2274         {                       
  2381         const TInt languageCode = languageCodes->At( i );
  2275         const TInt languageCode = languageCodes->At( i );
  2382 
  2276 
  2383         // Construct locale path using two digit minium
  2277         // Construct locale path using two digit minium
  2384         // width and zero as padding.
  2278         // width and zero as padding.
  2385         
  2279         
  2386         localePath.Copy( xuikonPath );
  2280         localePath.Copy( pathBase );
  2387         localePath.AppendFormat( KFormatting, languageCode );        
  2281         if( languageCode < 10 )
       
  2282             {
       
  2283             localePath.AppendFormat( KFormatNN, languageCode );
       
  2284             }
       
  2285         else
       
  2286             {
       
  2287             localePath.AppendNum( languageCode );
       
  2288             }
  2388         localePath.Append( KPathDelim );
  2289         localePath.Append( KPathDelim );
  2389 
  2290 
  2390         // Check if folder for supported language exists.        
  2291         // Check if folder for supported language exists.        
  2391         TBool exists = EFalse;
  2292         TBool exists = EFalse;
  2392         
  2293         
  2393         if( BaflUtils::FolderExists( iFsSession, localePath ) )
  2294         if( BaflUtils::FolderExists( iFsSession, localePath ) )
  2394             {
  2295             {
  2395             exists = ETrue;
  2296             exists = ETrue;
  2396             }
  2297             }
  2397         
  2298         
  2398         // Support also one digit type folder naming.
  2299         // Support also one digit type folder naming possibly used by the imports.
  2399         if( !exists && languageCode < 10 )
  2300         if( !exists && languageCode < 10 )
  2400             {
  2301             {
  2401             localePath.Copy( xuikonPath );
  2302             localePath.Copy( pathBase );
  2402             localePath.AppendNum( languageCode );        
  2303             localePath.AppendNum( languageCode );        
  2403             localePath.Append( KPathDelim );
  2304             localePath.Append( KPathDelim );
  2404             
  2305             
  2405             if( BaflUtils::FolderExists( iFsSession, localePath ) )
  2306             if( BaflUtils::FolderExists( iFsSession, localePath ) )
  2406                 {
  2307                 {
  2416                 // Assume this is the default language shown incase 
  2317                 // Assume this is the default language shown incase 
  2417                 // there is no locale for the active UI language
  2318                 // there is no locale for the active UI language
  2418                 iDefaultSpecification = (TLanguage)languageCode;
  2319                 iDefaultSpecification = (TLanguage)languageCode;
  2419                 iDefaultSpecificationSet = ETrue;
  2320                 iDefaultSpecificationSet = ETrue;
  2420                 }                                                            
  2321                 }                                                            
  2421         
  2322                 
  2422         
  2323             // Add dtd file if existing.
  2423             // Find and add localized resources 
  2324             AddDtdFileL( localePath, (TLanguage)languageCode );
  2424             AddLocalizedResourcesL( 
  2325             
  2425                     localePath,
  2326             if( !aProcessOnlyDTD )
  2426                     (TLanguage)languageCode );            
  2327                 {
       
  2328                 // Find localized files from the provided directory
       
  2329                 RArray<TInt> driveArray;
       
  2330                 CleanupClosePushL( driveArray );                
       
  2331                 driveArray.Append( driveEnum );
       
  2332                 
       
  2333                 FindResourceFilesL( localePath,
       
  2334                                     EFalse,
       
  2335                                     driveArray,
       
  2336                                     NULL );
       
  2337                 
       
  2338                 CleanupStack::PopAndDestroy(); // driveArray
       
  2339                 }
  2427             }        
  2340             }        
  2428         }
  2341         }
  2429     
  2342     
  2430     CleanupStack::PopAndDestroy( languageCodes );
  2343     CleanupStack::PopAndDestroy( languageCodes );
  2431     languageCodes = NULL;
  2344     languageCodes = NULL;
  2432     }
  2345     }
  2433 
  2346 
  2434 // -----------------------------------------------------------------------------
  2347 // -----------------------------------------------------------------------------
  2435 // Adds localized resources from the provided subdirectory
  2348 // Adds localized dtd resources from the provided subdirectory
  2436 // -----------------------------------------------------------------------------
  2349 // -----------------------------------------------------------------------------
  2437 //
  2350 //
  2438 void ChspsInstallationHandler::AddLocalizedResourcesL(
  2351 void ChspsInstallationHandler::AddDtdFileL(
  2439         const TDesC& aPath,
  2352         const TDesC& aPath,
  2440         const TLanguage aLanguage )
  2353         const TLanguage aLanguage )
  2441     {
  2354     {    
  2442     // If FileDTD was declared
  2355     // If FileDTD was declared
  2443     if ( iDtdFile && iDtdFile->Des().Length() )
  2356     if ( iDtdFile && iDtdFile->Des().Length() )
  2444         {    
  2357         {    
  2445         // Append path with the default name of DTD files
  2358         // Append path with the default name of DTD files
  2446         const TInt len = aPath.Length() + iDtdFile->Des().Length();
  2359         const TInt len = aPath.Length() + iDtdFile->Des().Length();
  2473             EResourceDTD,
  2386             EResourceDTD,
  2474             mediaType,
  2387             mediaType,
  2475             tagsPtr );
  2388             tagsPtr );
  2476         
  2389         
  2477         CleanupStack::PopAndDestroy( dtdPath );
  2390         CleanupStack::PopAndDestroy( dtdPath );
  2478         }
  2391         }          
  2479     
       
  2480     // Find localized files from the provided directory
       
  2481     RArray<TInt> driveArray;
       
  2482     CleanupClosePushL( driveArray );   
       
  2483     driveArray.Append( EDriveE );
       
  2484     driveArray.Append( EDriveC );
       
  2485         
       
  2486     FindResourceFilesL( aPath, EFalse, driveArray, NULL );
       
  2487     
       
  2488     CleanupStack::PopAndDestroy(); // driveArray        
       
  2489     }
  2392     }
  2490 
  2393 
  2491 // -----------------------------------------------------------------------------
  2394 // -----------------------------------------------------------------------------
  2492 // ChspsInstallationHandler::ApplyUidRangeTestsL
  2395 // ChspsInstallationHandler::ApplyUidRangeTestsL
  2493 // -----------------------------------------------------------------------------
  2396 // -----------------------------------------------------------------------------