homescreenpluginsrv/hspsmanager/src/hspsrominstaller.cpp
branchRCL_3
changeset 27 2c7f27287390
parent 22 1b207dd38b72
equal deleted inserted replaced
25:9e077f9a342c 27:2c7f27287390
    26 #include "hspsinstallationhandler.h"
    26 #include "hspsinstallationhandler.h"
    27 #include "hspsclientrequesthandler.h"
    27 #include "hspsclientrequesthandler.h"
    28 #include "hspsserverutil.h"
    28 #include "hspsserverutil.h"
    29 
    29 
    30 _LIT(KPrivateInstallC, "C:\\private\\200159c0\\install\\");
    30 _LIT(KPrivateInstallC, "C:\\private\\200159c0\\install\\");
    31 _LIT(KPrivateInstallE, "E:\\private\\200159c0\\install\\");
    31 _LIT(KPrivateInstall, "\\private\\200159c0\\install\\");
    32 _LIT(KPrivateInstallZ, "Z:\\private\\200159c0\\install\\");
    32 _LIT(KPrivateInstallZ, "Z:\\private\\200159c0\\install\\");
    33 
    33 
    34 _LIT(KBackslash, "\\");
    34 _LIT(KBackslash, "\\");
    35 _LIT(KHsps, "hsps");
    35 _LIT(KHsps, "hsps");
    36 _LIT(KTestLanguage, "00");
    36 _LIT(KTestLanguage, "00");
    37 _LIT(KManifest, "manifest.dat");
    37 _LIT(KManifest, "manifest.dat");
       
    38                              
       
    39 const TInt KExcludedDrives = KDriveAttExclude|KDriveAttRemovable|KDriveAttRemote|KDriveAttSubsted;
    38 
    40 
    39 // ========================= LOCAL FUNCTIONS ==================================
    41 // ========================= LOCAL FUNCTIONS ==================================
    40 
    42 
    41 // ----------------------------------------------------------------------------
    43 // ----------------------------------------------------------------------------
    42 // CleanupResetAndDestroy()
    44 // CleanupResetAndDestroy()
   135 void ChspsRomInstaller::InstallL()
   137 void ChspsRomInstaller::InstallL()
   136     {
   138     {
   137     RPointerArray<HBufC> fileArray;
   139     RPointerArray<HBufC> fileArray;
   138     CleanupResetAndDestroyPushL( fileArray );
   140     CleanupResetAndDestroyPushL( fileArray );
   139             
   141             
   140     // Find the manifest files     
   142     // Find manifest files from the "install" directories 
   141     FindInstallationFilesL( fileArray );
   143     FindInstallFilesL( fileArray );
   142             
   144       
       
   145     // Find manifest files from the "imports" directories
       
   146     FindImportFilesL( fileArray );  
       
   147 	        
   143     // Install the manifest files    
   148     // Install the manifest files    
   144     for( TInt index=0; index < fileArray.Count(); index++ )
   149     for( TInt index=0; index < fileArray.Count(); index++ )
   145         {         
   150         {         
   146         TPtrC namePtr( fileArray[index]->Des() );                               
   151         TPtrC namePtr( fileArray[index]->Des() );                               
   147                 
   152                 
   161         }
   166         }
   162             
   167             
   163     CleanupStack::PopAndDestroy(); // fileArray
   168     CleanupStack::PopAndDestroy(); // fileArray
   164     }
   169     }
   165 
   170 
       
   171 // -----------------------------------------------------------------------------
       
   172 // ChspsRomInstaller::FindImportFilesL()
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 void ChspsRomInstaller::FindImportFilesL(
       
   176         RPointerArray<HBufC>& aFileArray )
       
   177     {                    
       
   178     if( iInstallUdaEmmc )
       
   179         {
       
   180         // If eMMC is present         
       
   181         TInt drive = hspsServerUtil::GetEmmcDrivePath( iFsSession );
       
   182         if ( drive != KErrNotFound )
       
   183             {
       
   184             TDriveUnit unit(drive);
       
   185             
       
   186             HBufC* path = HBufC::NewLC( 
       
   187                     KImportDirectory().Length() + unit.Name().Length() );             
       
   188             path->Des().Append( unit.Name() );
       
   189             path->Des().Append( KImportDirectory );
       
   190             
       
   191             // Find manifest files from eMMC
       
   192             DoFindImportFilesL( aFileArray, *path );
       
   193             
       
   194             CleanupStack::PopAndDestroy( path );
       
   195             }
       
   196             
       
   197         // Find manifest files from C
       
   198         DoFindImportFilesL( aFileArray, KImportDirectoryC );  
       
   199         }
       
   200     }
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // ChspsThemeServer::DoFindImportFilesL()
       
   204 // -----------------------------------------------------------------------------
       
   205 //
       
   206 void ChspsRomInstaller::DoFindImportFilesL( 
       
   207         RPointerArray<HBufC>& aFileArray,
       
   208         const TDesC& aPath )
       
   209     {               
       
   210 	_LIT(KDat, ".dat");
       
   211     CDir* importDir( NULL );                      
       
   212     TFindFile fileFinder( iFsSession );      
       
   213     fileFinder.SetFindMask( KExcludedDrives );       
       
   214     fileFinder.FindWildByPath( aPath, NULL, importDir );          
       
   215     if ( importDir )
       
   216         {
       
   217         CleanupStack::PushL( importDir );
       
   218                 
       
   219         for ( TInt i=0; i < importDir->Count(); i++ )
       
   220             {
       
   221             const TEntry& dirEntry = (*importDir)[i];
       
   222             if ( !dirEntry.IsDir() 
       
   223                     && dirEntry.iName.FindF( KDat ) > 0 )
       
   224                 {                
       
   225                 // Get path to the manifest file
       
   226                 HBufC* manifestBuf = 
       
   227                         iThemeServer.GetManifestFromImportLC( dirEntry.iName, aPath );
       
   228                 if( !manifestBuf )
       
   229                     {
       
   230                     continue;
       
   231                     }
       
   232                 
       
   233                 // Check for duplicates
       
   234                 TBool isShadowed = EFalse;
       
   235                 TParsePtrC manifestPtr( *manifestBuf );                
       
   236                 for( TInt i=0; i < aFileArray.Count(); i++ )
       
   237                     {
       
   238                     TParsePtrC ptr( aFileArray[i]->Des() );
       
   239                     if( ptr.Path() == manifestPtr.Path() )
       
   240                         {
       
   241                         isShadowed = ETrue;
       
   242                         break;
       
   243                         }
       
   244                     }
       
   245                 
       
   246                 if( !isShadowed )
       
   247                     {           
       
   248                     if( BaflUtils::FileExists( iFsSession, *manifestBuf ) )
       
   249                         {                        
       
   250                         HBufC* nameBuf = manifestBuf->Des().AllocLC();                
       
   251                         aFileArray.AppendL( nameBuf );
       
   252                         CleanupStack::Pop( nameBuf );
       
   253                         }
       
   254                     }
       
   255                 
       
   256                 CleanupStack::PopAndDestroy( manifestBuf );
       
   257                 }
       
   258             }
       
   259                         
       
   260         CleanupStack::PopAndDestroy( importDir );
       
   261         }     
       
   262     }
   166 
   263 
   167 // -----------------------------------------------------------------------------
   264 // -----------------------------------------------------------------------------
   168 // ChspsRomInstaller::FindInstallationFilesL()
   265 // ChspsRomInstaller::FindInstallationFilesL()
   169 // -----------------------------------------------------------------------------
   266 // -----------------------------------------------------------------------------
   170 //
   267 //
   171 void ChspsRomInstaller::FindInstallationFilesL(  
   268 void ChspsRomInstaller::FindInstallFilesL(  
   172         RPointerArray<HBufC>& aFileArray )
   269         RPointerArray<HBufC>& aFileArray )
   173     {
   270     {
   174     __ASSERT_DEBUG( aFileArray.Count() == 0, User::Leave( KErrArgument ) );
   271     __ASSERT_DEBUG( aFileArray.Count() == 0, User::Leave( KErrArgument ) );
   175                     
   272                     
   176     if( iInstallUdaEmmc )
   273     if( iInstallUdaEmmc )
   177         {
   274         {
   178         // Handle installation of the imaker exports 
   275         // If eMMC is present             
   179         DoFindInstallationFilesL( aFileArray, KPrivateInstallE );    
   276         TInt drive = hspsServerUtil::GetEmmcDrivePath( iFsSession );
   180         DoFindInstallationFilesL( aFileArray, KPrivateInstallC );  
   277         if ( drive != KErrNotFound )
   181         }
   278             {
   182     
   279             TDriveUnit unit(drive);
   183     // ROM
   280             
   184     DoFindInstallationFilesL( aFileArray, KPrivateInstallZ );    
   281             HBufC* path = HBufC::NewLC( 
   185     }
   282                     KPrivateInstall().Length() + unit.Name().Length() );             
   186 
   283             path->Des().Append( unit.Name() );
   187 // -----------------------------------------------------------------------------
   284             path->Des().Append( KPrivateInstall );
   188 // ChspsRomInstaller::DoFindInstallationFilesL()
   285             
   189 // -----------------------------------------------------------------------------
   286             // Find manifest files from eMMC
   190 //
   287             DoFindInstallFilesL( aFileArray, *path );
   191 void ChspsRomInstaller::DoFindInstallationFilesL(  
   288             
       
   289             CleanupStack::PopAndDestroy( path );
       
   290             }
       
   291         
       
   292         // Find manifest files from C
       
   293         DoFindInstallFilesL( aFileArray, KPrivateInstallC );  
       
   294         }
       
   295     
       
   296     // Find manifest files from Z
       
   297     DoFindInstallFilesL( aFileArray, KPrivateInstallZ );    
       
   298     }
       
   299 
       
   300 // -----------------------------------------------------------------------------
       
   301 // ChspsRomInstaller::DoFindInstallFilesL()
       
   302 // -----------------------------------------------------------------------------
       
   303 //
       
   304 void ChspsRomInstaller::DoFindInstallFilesL(  
   192         RPointerArray<HBufC>& aFileArray,
   305         RPointerArray<HBufC>& aFileArray,
   193         const TDesC& aPath )
   306         const TDesC& aPath )
   194     {               
   307     {               
   195     TFindFile fileFinder( iFsSession );    
   308     TFindFile fileFinder( iFsSession );    
   196     fileFinder.SetFindMask( 
   309     fileFinder.SetFindMask( KExcludedDrives );       
   197          KDriveAttExclude|KDriveAttRemovable|KDriveAttRemote|KDriveAttSubsted );
       
   198     CDir* dirList( NULL );    
   310     CDir* dirList( NULL );    
   199     fileFinder.FindWildByPath( aPath, NULL, dirList );
   311     fileFinder.FindWildByPath( aPath, NULL, dirList );
   200     if ( dirList )
   312     if ( dirList )
   201         {
   313         {
   202         CleanupStack::PushL( dirList );
   314         CleanupStack::PushL( dirList );