appinstaller/AppinstUi/Daemon/Src/versionRevisor.cpp
changeset 25 98b66e4fb0be
parent 0 ba25891c3a9e
child 29 26b6f0522fd8
equal deleted inserted replaced
24:84a16765cd86 25:98b66e4fb0be
    43 
    43 
    44 const TInt KVerRevSisVersionOlder = 200;
    44 const TInt KVerRevSisVersionOlder = 200;
    45 const TInt KVerRevSisVersionSame = 300;
    45 const TInt KVerRevSisVersionSame = 300;
    46 const TInt KVerRevSisVersionNewer = 400;
    46 const TInt KVerRevSisVersionNewer = 400;
    47 
    47 
    48 namespace Swi
    48 using namespace Swi;
       
    49 //namespace Swi
       
    50 //    {
       
    51 // -----------------------------------------------------------------------
       
    52 // Two-phased constructor
       
    53 // -----------------------------------------------------------------------
       
    54 //    
       
    55 CVersionRevisor* CVersionRevisor::NewL( CProgramStatus& aMainStatus )
    49     {
    56     {
    50     // -----------------------------------------------------------------------
    57     CVersionRevisor* self = NewLC( aMainStatus );
    51     // Two-phased constructor
    58     CleanupStack::Pop( self );
    52     // -----------------------------------------------------------------------
    59     return self;
    53     //    
    60     }
    54     CVersionRevisor* CVersionRevisor::NewL( CProgramStatus& aMainStatus )
    61 
       
    62 // ------------------------------------------------------------------------
       
    63 // Two-phased constructor
       
    64 // ------------------------------------------------------------------------
       
    65 //    
       
    66 CVersionRevisor* CVersionRevisor::NewLC( CProgramStatus& aMainStatus )
       
    67     {
       
    68     CVersionRevisor* self = new (ELeave) CVersionRevisor;
       
    69     CleanupStack::PushL( self );
       
    70     self->ConstructL( aMainStatus );
       
    71     return self;    
       
    72     }
       
    73   
       
    74 // -----------------------------------------------------------------------
       
    75 // 2nd constructor
       
    76 // -----------------------------------------------------------------------
       
    77 //    
       
    78 void CVersionRevisor::ConstructL( CProgramStatus& aMainStatus )
       
    79     {
       
    80     FLOG( _L("[VersionRev] ConstructL start") );
       
    81     iSisUninstaller = NULL;
       
    82     iStartupReason = KErrNone; 
       
    83     // Note revisor do not own this instance.
       
    84     iProgramStatus = &aMainStatus;         
       
    85     User::LeaveIfError( iFs.Connect() );
       
    86     // Get system startup reason.
       
    87     TRAP_IGNORE( StartUpReasonL() );         
       
    88     FLOG( _L("[VersionRev] ConstructL end") );
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------
       
    92 // c++ destructor
       
    93 // -----------------------------------------------------------------------
       
    94 //    
       
    95 CVersionRevisor::~CVersionRevisor()
       
    96     {
       
    97     FLOG( _L("[VersionRev] ~CVersionRevisor start") );         
       
    98     delete iSisUninstaller;
       
    99     iSisUninstaller = NULL;         
       
   100     iStubDataArray.ResetAndDestroy();               
       
   101     iFs.Close(); 
       
   102     FLOG( _L("[VersionRev] ~CVersionRevisor end") ); 
       
   103     }
       
   104  
       
   105 // -----------------------------------------------------------------------
       
   106 // Starts uninstall process.
       
   107 // -----------------------------------------------------------------------
       
   108 //    
       
   109 TInt CVersionRevisor::StartProcessL()
       
   110     {  
       
   111     FLOG( _L("[VersionRev] StartProcessL start") );        
       
   112     TInt err = KErrNone;
       
   113     
       
   114     // If firmware update is done, start scan process.
       
   115      if( iStartupReason == EFirmwareUpdate )
       
   116           {                             
       
   117           iSisUninstaller = 
       
   118               CSisPkgUninstaller::NewL( *iProgramStatus, *this );  
       
   119           
       
   120           TRAP( err, ProcessStubFilesL() );
       
   121           FLOG_1( _L("[VersionRev] Process stub TRAP error = %d"), err );
       
   122            
       
   123           TRAP( err, ProcessSisRegistryL() ); 
       
   124           FLOG_1( _L("[VersionRev] Process sis TRAP error = %d"), err );
       
   125            
       
   126           iSisUninstaller->StartUninstallL();                           
       
   127           }        
       
   128      else
       
   129          {
       
   130          FLOG( _L("[VersionRev] StartProcessL: No firmware update") );
       
   131          // Ok, no need to start process. Leave so main will call delete. 
       
   132          User::Leave( KErrAbort );
       
   133          }
       
   134                                                  
       
   135     FLOG( _L("[VersionRev] StartProcessL end") );
       
   136     return KErrNone;
       
   137     }
       
   138 
       
   139 // -----------------------------------------------------------------------
       
   140 // Reads stub sis files.
       
   141 // -----------------------------------------------------------------------
       
   142 //    
       
   143 TInt CVersionRevisor::ProcessStubFilesL()
       
   144     {  
       
   145     FLOG( _L("[VersionRev] ProcessStubFilesL start") );
       
   146     CDir* dir;
       
   147     
       
   148     TInt err = iFs.GetDir( 
       
   149             KVerRevStubSISDir, 
       
   150             KEntryAttNormal, 
       
   151             ESortNone, 
       
   152             dir );
       
   153     
       
   154     if ( err == KErrNone )
    55         {
   155         {
    56         CVersionRevisor* self = NewLC( aMainStatus );
   156         CleanupStack::PushL( dir );
    57         CleanupStack::Pop( self );
   157         
    58         return self;
   158         TInt count = dir->Count();
       
   159         FLOG_1( _L("[VersionRev] Stub count = %d"), count );
       
   160 
       
   161         for ( TInt index = 0; index < count; index++ )
       
   162             {
       
   163             FLOG_1( _L("[VersionRev] Stub index = %d"), index );                                               
       
   164             TFileName stubName;                 
       
   165             stubName.Append( KVerRevStubSISDir );
       
   166             stubName.Append( (*dir)[index].iName );                
       
   167             FLOG_1( _L("[VersionRev] Stub name: %S\n "), 
       
   168                     &(*dir)[index].iName );                
       
   169             // Function needs to be trapped because SisController leavs 
       
   170             // if some corrupted file is in dir etc.
       
   171             TRAP( err, AppendStubInfoL( stubName ) );                            
       
   172             }                       
       
   173         CleanupStack::PopAndDestroy( dir ); 
    59         }
   174         }
    60     
   175     
    61     // ------------------------------------------------------------------------
   176     FLOG( _L("[VersionRev] ProcessStubFilesL end") );         
    62     // Two-phased constructor
   177     return err;
    63     // ------------------------------------------------------------------------
   178     }
    64     //    
   179 
    65     CVersionRevisor* CVersionRevisor::NewLC( CProgramStatus& aMainStatus )
   180 // -----------------------------------------------------------------------
       
   181 // Checks rom updates from sis registry and adds pkg UID to array for
       
   182 // uninstaller process.
       
   183 //
       
   184 // Pre contitons for uninstall is: 
       
   185 // 1. sis version is older or same as rom STUB version.
       
   186 // 2. sis has files only in C drvie.
       
   187 // 3. if sis version is same as stub version, all binary files must be
       
   188 // present in rom (z:\sys\bin).
       
   189 // Rom STUB <- SA       = uninstalled
       
   190 // Rom STUB <- SP       = no uninstall, returned drive is Z   (0x04)
       
   191 // Rom STUB <- PU       = no uninstall, returned drive is Z+C (0x2000004)
       
   192 // Rom STUB <- SA <- SP = SA is uninstalled, SP is not (n-gage) 
       
   193 // Rom STUB <- SA <- PU = uninstalled
       
   194 // Rom STUB <- SA + emped. sis = SA is uninstalled, empedded pkg is not.
       
   195 // -----------------------------------------------------------------------
       
   196 //    
       
   197 TInt CVersionRevisor::ProcessSisRegistryL()
       
   198     {
       
   199     FLOG( _L("[VersionRev] ProcessSisRegistryL start") );        
       
   200     TInt stubArrayCount = iStubDataArray.Count();
       
   201     FLOG_1( _L("[VersionRev] Stub array count = %d"), stubArrayCount );
       
   202     
       
   203     if ( stubArrayCount )
    66         {
   204         {
    67         CVersionRevisor* self = new (ELeave) CVersionRevisor;
   205         Swi::RSisRegistrySession sisRegSession;                                        
    68         CleanupStack::PushL( self );
   206         User::LeaveIfError( sisRegSession.Connect() );                
    69         self->ConstructL( aMainStatus );
   207         CleanupClosePushL( sisRegSession );
    70         return self;    
   208                            
       
   209         Swi::RSisRegistryEntry entry;                                    
       
   210         TInt err = KErrNone;
       
   211                      
       
   212         // Search correct sis pagace and open entry to it.
       
   213         for ( TInt stubIndex = 0; stubIndex < stubArrayCount; stubIndex++ )
       
   214             {                  
       
   215             TUid stubUID = iStubDataArray[stubIndex]->pkgUID;                 
       
   216             FLOG_1( _L("[VersionRev] Stub UID: 0x%x \n "), stubUID.iUid );                                                  
       
   217                             
       
   218             TBool isInstalled = sisRegSession.IsInstalledL( stubUID );
       
   219                                                                          
       
   220             if ( isInstalled )
       
   221                 {                                
       
   222                 err = entry.Open( sisRegSession, stubUID );                     
       
   223                 
       
   224                 if ( !err )
       
   225                     {
       
   226                     CleanupClosePushL( entry );                                                                                                                                                                                                                                                                                      
       
   227                                             
       
   228                     TUint drives = entry.InstalledDrivesL();
       
   229                     FLOG_1( _L("[VersionRev] Installe drive: 0x%x \n "), 
       
   230                             drives );                                                                                               
       
   231                                             
       
   232                     if ( drives == KVerRevDriveC )
       
   233                         { 
       
   234                         FLOG( _L("[VersionRev] SIS is installed to C:") );                                                        
       
   235                         FLOG( _L("[VersionRev] Check SIS version") );
       
   236                                                     
       
   237                         TVersion stubVersion(
       
   238                                 iStubDataArray[stubIndex]->major,
       
   239                                 iStubDataArray[stubIndex]->minor,
       
   240                                 iStubDataArray[stubIndex]->build );
       
   241                                                  
       
   242                         // Check sis and stub version.              
       
   243                         TInt ver = CompareVersions( 
       
   244                                entry.VersionL(), 
       
   245                                stubVersion ); 
       
   246                         FLOG_1( _L("[VersionRev] CompareVer.= %d "), ver );                                                                                           
       
   247                         TBool removePkg = EFalse;
       
   248                         
       
   249                         if ( ver == KVerRevSisVersionSame )
       
   250                             {
       
   251                             // If version is same check that all binary 
       
   252                             // files in rom is found. If files are missing
       
   253                             // do not remove sis pkg.
       
   254                             FLOG( _L("[VersionRev] Sis version same"));
       
   255                             removePkg = AllRomBinariesFoundL( entry );
       
   256                             }
       
   257                         if ( ver == KVerRevSisVersionOlder )
       
   258                             {
       
   259                             FLOG( _L("[VersionRev] Sis version older"));
       
   260                             removePkg = ETrue;
       
   261                             } 
       
   262                         
       
   263                         // Add uid to uninstall array if removePkg is true.
       
   264                         if ( removePkg )
       
   265                             {                                                                   
       
   266                             iSisUninstaller->AddUidToListL( stubUID );
       
   267                             FLOG_1( _L("[VersionRev] Uninst. UID:0x%x"), 
       
   268                                       stubUID.iUid );                                  
       
   269                             } 
       
   270                         }//if
       
   271                     CleanupStack::PopAndDestroy(); //entry                         
       
   272                     }//if                                                                   
       
   273                 } //if                                                                          
       
   274             } //for  
       
   275         CleanupStack::PopAndDestroy(); //sisRegSession
       
   276         } //if
       
   277       
       
   278     return KErrNone;
       
   279     }
       
   280 
       
   281 
       
   282 // -----------------------------------------------------------------------
       
   283 // This function reads firmware string and checks if firmware update has
       
   284 // been done. This function does create file to private directory and
       
   285 // saves current firmware version string to it.
       
   286 // -----------------------------------------------------------------------
       
   287 //    
       
   288 void CVersionRevisor::StartUpReasonL()
       
   289     {          
       
   290     FLOG( _L("[VersionRev] StartUpReasonL") );                           
       
   291     iStartupReason = KErrNotFound;                               
       
   292     HBufC* currentVersionString = HBufC::NewLC( KVerRevStrLength*2 );
       
   293     TPtr currentStringPtr = currentVersionString->Des();
       
   294     
       
   295     // Get current firmware string from sysutil. 
       
   296     // Firmware string is saved to Z:\\resource\\versions\\sw.txt
       
   297     SysUtil::GetSWVersion( currentStringPtr );
       
   298     FLOG_1( _L("[VersionRev] Firmware version = %S "), 
       
   299             &currentStringPtr );                 
       
   300     TUint result;
       
   301     // If private directory is not found create it. 
       
   302     TInt err = iFs.Att( KVerRevPrivatePath, result );
       
   303     
       
   304     if ( ! err == KErrNone && result & KEntryAttDir )
       
   305         {                 
       
   306         iFs.CreatePrivatePath( EDriveC ); 
       
   307         FLOG( _L("[VersionRev] StartUpReasonL: Create private folder") );
    71         }
   308         }
    72       
   309            
    73     // -----------------------------------------------------------------------
   310     RFile file; 
    74     // 2nd constructor
   311     TFindFile find( iFs );                      
    75     // -----------------------------------------------------------------------
   312     // Check if version file is found in Daemon private director.
    76     //    
   313     err = find.FindByPath( KVerRevVersionFile(), &KVerRevPrivatePath() );
    77     void CVersionRevisor::ConstructL( CProgramStatus& aMainStatus )
   314     FLOG_1( _L("[VersionRev] StartUpReasonL: Find file = %d"), err );  
       
   315     
       
   316     if ( err )
    78         {
   317         {
    79         FLOG( _L("[VersionRev] ConstructL start") );
   318         // If file is not found this is first boot or user memory (C:) has 
    80         iSisUninstaller = NULL;
   319         // been formatted. No need to start version checking but let's save
    81         iStartupReason = KErrNone; 
   320         // the current firmware version to Daemon private folder.
    82         // Note revisor do not own this instance.
   321         err = file.Create( 
    83         iProgramStatus = &aMainStatus;         
   322                 iFs, 
    84         User::LeaveIfError( iFs.Connect() );
   323                 KVerRevVersionFile, 
    85         // Get system startup reason.
   324                 EFileWrite|EFileRead|EFileStreamText );
    86         TRAP_IGNORE( StartUpReasonL() );         
   325         
    87         FLOG( _L("[VersionRev] ConstructL end") );
   326         FLOG_1( _L("[VersionRev] file create err = %d"), err ); 
       
   327         User::LeaveIfError( err );
       
   328         
       
   329         // Write current firmware version strign to file. 
       
   330         WriteFileText( file, currentStringPtr );
       
   331         
       
   332         file.Flush();
       
   333         file.Close();                        
    88         }
   334         }
    89     
   335     else
    90     // -----------------------------------------------------------------------
       
    91     // c++ destructor
       
    92     // -----------------------------------------------------------------------
       
    93     //    
       
    94     CVersionRevisor::~CVersionRevisor()
       
    95         {
   336         {
    96         FLOG( _L("[VersionRev] ~CVersionRevisor start") );         
   337         
    97         delete iSisUninstaller;
   338         HBufC* previousVersionString = HBufC::NewLC( KVerRevStrLength*2 );
    98         iSisUninstaller = NULL;         
   339         TPtr previousStringPtr = previousVersionString->Des();            
    99         iStubDataArray.ResetAndDestroy();               
   340         
   100         iFs.Close(); 
   341         // Open firmware version file from private directory.
   101         FLOG( _L("[VersionRev] ~CVersionRevisor end") ); 
   342         err = file.Open( 
   102         }
   343                 iFs, 
   103      
   344                 KVerRevVersionFile, 
   104     // -----------------------------------------------------------------------
   345                 EFileWrite|EFileRead|EFileStreamText );
   105     // Starts uninstall process.
   346         
   106     // -----------------------------------------------------------------------
   347         FLOG_1( _L("[VersionRev] file open err = %d"), err ); 
   107     //    
   348         User::LeaveIfError( err );            
   108     TInt CVersionRevisor::StartProcessL()
   349         
   109         {  
   350         // Read previous firmware string from the file. 
   110         FLOG( _L("[VersionRev] StartProcessL start") );        
   351         ReadFileText( file, previousStringPtr );
   111         TInt err = KErrNone;
   352         FLOG_1( _L("[VersionRev] Previous sw version: %S"), 
   112         
   353                 &previousStringPtr ); 
   113         // If firmware update is done, start scan process.
   354                     
   114          if( iStartupReason == EFirmwareUpdate )
   355         file.Close();
   115               {                             
   356         
   116               iSisUninstaller = 
   357         if ( previousStringPtr.Length() != 0 )
   117                   CSisPkgUninstaller::NewL( *iProgramStatus, *this );  
   358             {                                                                             
   118               
   359             // Compare firmware strings.
   119               TRAP( err, ProcessStubFilesL() );
   360             err = previousVersionString->Compare( currentStringPtr );
   120               FLOG_1( _L("[VersionRev] Process stub TRAP error = %d"), err );
   361             FLOG_1( _L("[VersionRev] String compare = %d"), err ); 
   121                
   362             
   122               TRAP( err, ProcessSisRegistryL() ); 
   363             if ( err == KErrNone )
   123               FLOG_1( _L("[VersionRev] Process sis TRAP error = %d"), err );
   364                 {  
   124                
   365                 // Strings are identical, no firmware update.
   125               iSisUninstaller->StartUninstallL();                           
   366                 iStartupReason = KErrNone;
   126               }        
   367                 FLOG( _L("[VersionRev] iStartupReason = KErrNone") );                 
   127          else
   368                 }
   128              {
   369             else
   129              FLOG( _L("[VersionRev] StartProcessL: No firmware update") );
       
   130              // Ok, no need to start process. Leave so main will call delete. 
       
   131              User::Leave( KErrAbort );
       
   132              }
       
   133                                                      
       
   134         FLOG( _L("[VersionRev] StartProcessL end") );
       
   135         return KErrNone;
       
   136         }
       
   137    
       
   138     // -----------------------------------------------------------------------
       
   139     // Reads stub sis files.
       
   140     // -----------------------------------------------------------------------
       
   141     //    
       
   142     TInt CVersionRevisor::ProcessStubFilesL()
       
   143         {  
       
   144         FLOG( _L("[VersionRev] ProcessStubFilesL start") );
       
   145         CDir* dir;
       
   146         
       
   147         TInt err = iFs.GetDir( 
       
   148                 KVerRevStubSISDir, 
       
   149                 KEntryAttNormal, 
       
   150                 ESortNone, 
       
   151                 dir );
       
   152         
       
   153         if ( err == KErrNone )
       
   154             {
       
   155             CleanupStack::PushL( dir );
       
   156             
       
   157             TInt count = dir->Count();
       
   158             FLOG_1( _L("[VersionRev] Stub count = %d"), count );
       
   159 
       
   160             for ( TInt index = 0; index < count; index++ )
       
   161                 {
   370                 {
   162                 FLOG_1( _L("[VersionRev] Stub index = %d"), index );                                               
   371                 iStartupReason = EFirmwareUpdate;
   163                 TFileName stubName;                 
   372                 FLOG( _L("[VersionRev] iStartupReason = EFirmwareUpdate") );                     
   164                 stubName.Append( KVerRevStubSISDir );
   373                 file.Replace(                    
   165                 stubName.Append( (*dir)[index].iName );                
       
   166                 FLOG_1( _L("[VersionRev] Stub name: %S\n "), 
       
   167                         &(*dir)[index].iName );                
       
   168                 // Function needs to be trapped because SisController leavs 
       
   169                 // if some corrupted file is in dir etc.
       
   170                 TRAP( err, AppendStubInfoL( stubName ) );                            
       
   171                 }                       
       
   172             CleanupStack::PopAndDestroy( dir ); 
       
   173             }
       
   174         
       
   175         FLOG( _L("[VersionRev] ProcessStubFilesL end") );         
       
   176         return err;
       
   177         }
       
   178     
       
   179     // -----------------------------------------------------------------------
       
   180     // Checks rom updates from sis registry and adds pkg UID to array for
       
   181     // uninstaller process.
       
   182     //
       
   183     // Pre contitons for uninstall is: 
       
   184     // 1. sis version is older or same as rom STUB version.
       
   185     // 2. sis has files only in C drvie.
       
   186     // 3. if sis version is same as stub version, all binary files must be
       
   187     // present in rom (z:\sys\bin).
       
   188     // Rom STUB <- SA       = uninstalled
       
   189     // Rom STUB <- SP       = no uninstall, returned drive is Z   (0x04)
       
   190     // Rom STUB <- PU       = no uninstall, returned drive is Z+C (0x2000004)
       
   191     // Rom STUB <- SA <- SP = SA is uninstalled, SP is not (n-gage) 
       
   192     // Rom STUB <- SA <- PU = uninstalled
       
   193     // Rom STUB <- SA + emped. sis = SA is uninstalled, empedded pkg is not.
       
   194     // -----------------------------------------------------------------------
       
   195     //    
       
   196     TInt CVersionRevisor::ProcessSisRegistryL()
       
   197         {
       
   198         FLOG( _L("[VersionRev] ProcessSisRegistryL start") );        
       
   199         TInt stubArrayCount = iStubDataArray.Count();
       
   200         FLOG_1( _L("[VersionRev] Stub array count = %d"), stubArrayCount );
       
   201         
       
   202         if ( stubArrayCount )
       
   203             {
       
   204             Swi::RSisRegistrySession sisRegSession;                                        
       
   205             User::LeaveIfError( sisRegSession.Connect() );                
       
   206             CleanupClosePushL( sisRegSession );
       
   207                                
       
   208             Swi::RSisRegistryEntry entry;                                    
       
   209             TInt err = KErrNone;
       
   210                          
       
   211             // Search correct sis pagace and open entry to it.
       
   212             for ( TInt stubIndex = 0; stubIndex < stubArrayCount; stubIndex++ )
       
   213                 {                  
       
   214                 TUid stubUID = iStubDataArray[stubIndex]->pkgUID;                 
       
   215                 FLOG_1( _L("[VersionRev] Stub UID: 0x%x \n "), stubUID.iUid );                                                  
       
   216                                 
       
   217                 TBool isInstalled = sisRegSession.IsInstalledL( stubUID );
       
   218                                                                              
       
   219                 if ( isInstalled )
       
   220                     {                                
       
   221                     err = entry.Open( sisRegSession, stubUID );                     
       
   222                     
       
   223                     if ( !err )
       
   224                         {
       
   225                         CleanupClosePushL( entry );                                                                                                                                                                                                                                                                                      
       
   226                                                 
       
   227                         TUint drives = entry.InstalledDrivesL();
       
   228                         FLOG_1( _L("[VersionRev] Installe drive: 0x%x \n "), 
       
   229                                 drives );                                                                                               
       
   230                                                 
       
   231                         if ( drives == KVerRevDriveC )
       
   232                             { 
       
   233                             FLOG( _L("[VersionRev] SIS is installed to C:") );                                                        
       
   234                             FLOG( _L("[VersionRev] Check SIS version") );
       
   235                                                         
       
   236                             TVersion stubVersion(
       
   237                                     iStubDataArray[stubIndex]->major,
       
   238                                     iStubDataArray[stubIndex]->minor,
       
   239                                     iStubDataArray[stubIndex]->build );
       
   240                                                      
       
   241                             // Check sis and stub version.              
       
   242                             TInt ver = CompareVersions( 
       
   243                                    entry.VersionL(), 
       
   244                                    stubVersion ); 
       
   245                             FLOG_1( _L("[VersionRev] CompareVer.= %d "), ver );                                                                                           
       
   246                             TBool removePkg = EFalse;
       
   247                             
       
   248                             if ( ver == KVerRevSisVersionSame )
       
   249                                 {
       
   250                                 // If version is same check that all binary 
       
   251                                 // files in rom is found. If files are missing
       
   252                                 // do not remove sis pkg.
       
   253                                 FLOG( _L("[VersionRev] Sis version same"));
       
   254                                 removePkg = AllRomBinariesFoundL( entry );
       
   255                                 }
       
   256                             if ( ver == KVerRevSisVersionOlder )
       
   257                                 {
       
   258                                 FLOG( _L("[VersionRev] Sis version older"));
       
   259                                 removePkg = ETrue;
       
   260                                 } 
       
   261                             
       
   262                             // Add uid to uninstall array if removePkg is true.
       
   263                             if ( removePkg )
       
   264                                 {                                                                   
       
   265                                 iSisUninstaller->AddUidToListL( stubUID );
       
   266                                 FLOG_1( _L("[VersionRev] Uninst. UID:0x%x"), 
       
   267                                           stubUID.iUid );                                  
       
   268                                 } 
       
   269                             }//if
       
   270                         CleanupStack::PopAndDestroy(); //entry                         
       
   271                         }//if                                                                   
       
   272                     } //if                                                                          
       
   273                 } //for  
       
   274             CleanupStack::PopAndDestroy(); //sisRegSession
       
   275             } //if
       
   276           
       
   277         return KErrNone;
       
   278         }
       
   279 
       
   280     
       
   281     // -----------------------------------------------------------------------
       
   282     // This function reads firmware string and checks if firmware update has
       
   283     // been done. This function does create file to private directory and
       
   284     // saves current firmware version string to it.
       
   285     // -----------------------------------------------------------------------
       
   286     //    
       
   287     void CVersionRevisor::StartUpReasonL()
       
   288         {          
       
   289         FLOG( _L("[VersionRev] StartUpReasonL") );                           
       
   290         iStartupReason = KErrNotFound;                               
       
   291         HBufC* currentVersionString = HBufC::NewLC( KVerRevStrLength*2 );
       
   292         TPtr currentStringPtr = currentVersionString->Des();
       
   293         
       
   294         // Get current firmware string from sysutil. 
       
   295         // Firmware string is saved to Z:\\resource\\versions\\sw.txt
       
   296         SysUtil::GetSWVersion( currentStringPtr );
       
   297         FLOG_1( _L("[VersionRev] Firmware version = %S "), 
       
   298                 &currentStringPtr );                 
       
   299         TUint result;
       
   300         // If private directory is not found create it. 
       
   301         TInt err = iFs.Att( KVerRevPrivatePath, result );
       
   302         
       
   303         if ( ! err == KErrNone && result & KEntryAttDir )
       
   304             {                 
       
   305             iFs.CreatePrivatePath( EDriveC ); 
       
   306             FLOG( _L("[VersionRev] StartUpReasonL: Create private folder") );
       
   307             }
       
   308                
       
   309         RFile file; 
       
   310         TFindFile find( iFs );                      
       
   311         // Check if version file is found in Daemon private director.
       
   312         err = find.FindByPath( KVerRevVersionFile(), &KVerRevPrivatePath() );
       
   313         FLOG_1( _L("[VersionRev] StartUpReasonL: Find file = %d"), err );  
       
   314         
       
   315         if ( err )
       
   316             {
       
   317             // If file is not found this is first boot or user memory (C:) has 
       
   318             // been formatted. No need to start version checking but let's save
       
   319             // the current firmware version to Daemon private folder.
       
   320             err = file.Create( 
       
   321                     iFs, 
   374                     iFs, 
   322                     KVerRevVersionFile, 
   375                     KVerRevVersionFile, 
   323                     EFileWrite|EFileRead|EFileStreamText );
   376                     EFileWrite|EFileStreamText );                                        
   324             
   377                 // Ok we have firmware update. Let's write new firmware 
   325             FLOG_1( _L("[VersionRev] file create err = %d"), err ); 
   378                 // string to file and start version checking.
   326             User::LeaveIfError( err );
   379                 WriteFileText( file, currentStringPtr );                                                                                 
   327             
   380                 file.Flush();
   328             // Write current firmware version strign to file. 
   381                 file.Close();  
   329             WriteFileText( file, currentStringPtr );
   382                 }
   330             
   383             }            
   331             file.Flush();
   384         CleanupStack::PopAndDestroy(); //previousVersionString  
   332             file.Close();                        
   385         }                                                                   
   333             }
   386     CleanupStack::PopAndDestroy( ); //currentVersionString                  
   334         else
   387     }
       
   388  
       
   389 
       
   390 // -----------------------------------------------------------------------
       
   391 // Help function to read firmware version string from file.
       
   392 // -----------------------------------------------------------------------
       
   393 //  
       
   394 void CVersionRevisor::ReadFileText( RFile& aFile, TDes& aText )
       
   395     {                        
       
   396     TFileText fileText;
       
   397     fileText.Set( aFile );
       
   398     fileText.Read( aText );
       
   399      
       
   400      // Replace new-line patterns with real ones.
       
   401      TInt position = aText.Find( KVerRevNewLinePattern );
       
   402      while ( position != KErrNotFound )
       
   403          {
       
   404          // err is a position
       
   405          aText.Replace( 
       
   406                  position, 
       
   407                  KVerRevNewLinePattern().Length(), 
       
   408                  KVerRevNewLine );
       
   409          
       
   410          position = aText.Find( KVerRevNewLinePattern );
       
   411          }                        
       
   412     }
       
   413 
       
   414 
       
   415 // -----------------------------------------------------------------------
       
   416 // Help function to write firmware version string from file.
       
   417 // -----------------------------------------------------------------------
       
   418 //  
       
   419 void CVersionRevisor::WriteFileText( RFile& aFile, TDes& aText )
       
   420     { 
       
   421     // Replace real new-line marker with pattern. This makes 
       
   422     // reading operation easy.
       
   423     TInt position = aText.Find( KVerRevNewLine );                
       
   424     while ( position != KErrNotFound )
       
   425         {                
       
   426         aText.Replace( 
       
   427                 position, 
       
   428                 KVerRevNewLine().Length(), 
       
   429                 KVerRevNewLinePattern );
       
   430          
       
   431          position = aText.Find( KVerRevNewLine );
       
   432          }
       
   433                  
       
   434     TFileText fileText;
       
   435     fileText.Set( aFile );
       
   436     fileText.Write( aText );                       
       
   437     }
       
   438     
       
   439 
       
   440 // -----------------------------------------------------------------------
       
   441 // This function reads stub sis files version and uid and adds the info
       
   442 // in array.
       
   443 // -----------------------------------------------------------------------
       
   444 //  
       
   445 void CVersionRevisor::AppendStubInfoL( TDesC& aStubName )
       
   446     {                                             
       
   447     CFileSisDataProvider* provider = 
       
   448         CFileSisDataProvider::NewLC( iFs, aStubName );
       
   449             
       
   450     Sis::CController* stubData = Sis::CController::NewLC( *provider );
       
   451             
       
   452     const Sis::CVersion& version = stubData->Info().Version();
       
   453             
       
   454     TVersionRevStubData* stubPkg = new( ELeave ) TVersionRevStubData();
       
   455     CleanupStack::PushL( stubPkg );        
       
   456     stubPkg->pkgUID = stubData->Info().Uid().Uid();
       
   457     stubPkg->major = version.Major();
       
   458     stubPkg->minor = version.Minor();
       
   459     stubPkg->build = version.Build();
       
   460     
       
   461     iStubDataArray.AppendL( stubPkg );
       
   462     
       
   463     CleanupStack::Pop( stubPkg );
       
   464     
       
   465 #ifdef _DEBUG  
       
   466     RDebug::Print( _L("[VersionRev] Add Stub UID: 0x%x Ver: %d.%d.%d\n "),                  
       
   467               stubData->Info().Uid().Uid(),
       
   468               version.Major(),
       
   469               version.Minor(),
       
   470               version.Build() );        
       
   471 #endif
       
   472                 
       
   473     CleanupStack::PopAndDestroy( 2, provider );
       
   474     provider = NULL;
       
   475     stubData = NULL;
       
   476     stubPkg = NULL;        
       
   477     }
       
   478 
       
   479 // -----------------------------------------------------------------------    
       
   480 // This function compares sis and stub versions. 
       
   481 // -----------------------------------------------------------------------
       
   482 //   
       
   483 TInt CVersionRevisor::CompareVersions( 
       
   484     TVersion aSisVer, 
       
   485     TVersion aStubVer )
       
   486     { 
       
   487     FLOG( _L("[VersionRev] CompareVersions()") );
       
   488                     
       
   489     // Compare major version
       
   490     if ( aSisVer.iMajor > aStubVer.iMajor  )
       
   491         {
       
   492         FLOG( _L("[VersionRev] STUB major version older ") );
       
   493         return KVerRevSisVersionNewer;
       
   494         }
       
   495     // If same major version, check minor version.
       
   496     else if ( aSisVer.iMajor == aStubVer.iMajor )
       
   497         {                           
       
   498         if ( aSisVer.iMinor > aStubVer.iMinor )
   335             {
   499             {
   336             
   500             FLOG( _L("[VersionRev] STUB minor version older ") );
   337             HBufC* previousVersionString = HBufC::NewLC( KVerRevStrLength*2 );
       
   338             TPtr previousStringPtr = previousVersionString->Des();            
       
   339             
       
   340             // Open firmware version file from private directory.
       
   341             err = file.Open( 
       
   342                     iFs, 
       
   343                     KVerRevVersionFile, 
       
   344                     EFileWrite|EFileRead|EFileStreamText );
       
   345             
       
   346             FLOG_1( _L("[VersionRev] file open err = %d"), err ); 
       
   347             User::LeaveIfError( err );            
       
   348             
       
   349             // Read previous firmware string from the file. 
       
   350             ReadFileText( file, previousStringPtr );
       
   351             FLOG_1( _L("[VersionRev] Previous sw version: %S"), 
       
   352                     &previousStringPtr ); 
       
   353                         
       
   354             file.Close();
       
   355             
       
   356             if ( previousStringPtr.Length() != 0 )
       
   357                 {                                                                             
       
   358                 // Compare firmware strings.
       
   359                 err = previousVersionString->Compare( currentStringPtr );
       
   360                 FLOG_1( _L("[VersionRev] String compare = %d"), err ); 
       
   361                 
       
   362                 if ( err == KErrNone )
       
   363                     {  
       
   364                     // Strings are identical, no firmware update.
       
   365                     iStartupReason = KErrNone;
       
   366                     FLOG( _L("[VersionRev] iStartupReason = KErrNone") );                 
       
   367                     }
       
   368                 else
       
   369                     {
       
   370                     iStartupReason = EFirmwareUpdate;
       
   371                     FLOG( _L("[VersionRev] iStartupReason = EFirmwareUpdate") );                     
       
   372                     file.Replace(                    
       
   373                         iFs, 
       
   374                         KVerRevVersionFile, 
       
   375                         EFileWrite|EFileStreamText );                                        
       
   376                     // Ok we have firmware update. Let's write new firmware 
       
   377                     // string to file and start version checking.
       
   378                     WriteFileText( file, currentStringPtr );                                                                                 
       
   379                     file.Flush();
       
   380                     file.Close();  
       
   381                     }
       
   382                 }            
       
   383             CleanupStack::PopAndDestroy(); //previousVersionString  
       
   384             }                                                                   
       
   385         CleanupStack::PopAndDestroy( ); //currentVersionString                  
       
   386         }
       
   387      
       
   388     
       
   389     // -----------------------------------------------------------------------
       
   390     // Help function to read firmware version string from file.
       
   391     // -----------------------------------------------------------------------
       
   392     //  
       
   393     void CVersionRevisor::ReadFileText( RFile& aFile, TDes& aText )
       
   394         {                        
       
   395         TFileText fileText;
       
   396         fileText.Set( aFile );
       
   397         fileText.Read( aText );
       
   398          
       
   399          // Replace new-line patterns with real ones.
       
   400          TInt position = aText.Find( KVerRevNewLinePattern );
       
   401          while ( position != KErrNotFound )
       
   402              {
       
   403              // err is a position
       
   404              aText.Replace( 
       
   405                      position, 
       
   406                      KVerRevNewLinePattern().Length(), 
       
   407                      KVerRevNewLine );
       
   408              
       
   409              position = aText.Find( KVerRevNewLinePattern );
       
   410              }                        
       
   411         }
       
   412 
       
   413     
       
   414     // -----------------------------------------------------------------------
       
   415     // Help function to write firmware version string from file.
       
   416     // -----------------------------------------------------------------------
       
   417     //  
       
   418     void CVersionRevisor::WriteFileText( RFile& aFile, TDes& aText )
       
   419         { 
       
   420         // Replace real new-line marker with pattern. This makes 
       
   421         // reading operation easy.
       
   422         TInt position = aText.Find( KVerRevNewLine );                
       
   423         while ( position != KErrNotFound )
       
   424             {                
       
   425             aText.Replace( 
       
   426                     position, 
       
   427                     KVerRevNewLine().Length(), 
       
   428                     KVerRevNewLinePattern );
       
   429              
       
   430              position = aText.Find( KVerRevNewLine );
       
   431              }
       
   432                      
       
   433         TFileText fileText;
       
   434         fileText.Set( aFile );
       
   435         fileText.Write( aText );                       
       
   436         }
       
   437         
       
   438     
       
   439     // -----------------------------------------------------------------------
       
   440     // This function reads stub sis files version and uid and adds the info
       
   441     // in array.
       
   442     // -----------------------------------------------------------------------
       
   443     //  
       
   444     void CVersionRevisor::AppendStubInfoL( TDesC& aStubName )
       
   445         {                                             
       
   446         CFileSisDataProvider* provider = 
       
   447             CFileSisDataProvider::NewLC( iFs, aStubName );
       
   448                 
       
   449         Sis::CController* stubData = Sis::CController::NewLC( *provider );
       
   450                 
       
   451         const Sis::CVersion& version = stubData->Info().Version();
       
   452                 
       
   453         TVersionRevStubData* stubPkg = new( ELeave ) TVersionRevStubData();
       
   454         CleanupStack::PushL( stubPkg );        
       
   455         stubPkg->pkgUID = stubData->Info().Uid().Uid();
       
   456         stubPkg->major = version.Major();
       
   457         stubPkg->minor = version.Minor();
       
   458         stubPkg->build = version.Build();
       
   459         
       
   460         iStubDataArray.AppendL( stubPkg );
       
   461         
       
   462         CleanupStack::Pop( stubPkg );
       
   463         
       
   464  #ifdef _DEBUG  
       
   465         RDebug::Print( _L("[VersionRev] Add Stub UID: 0x%x Ver: %d.%d.%d\n "),                  
       
   466                   stubData->Info().Uid().Uid(),
       
   467                   version.Major(),
       
   468                   version.Minor(),
       
   469                   version.Build() );        
       
   470  #endif
       
   471                     
       
   472         CleanupStack::PopAndDestroy( 2, provider );
       
   473         provider = NULL;
       
   474         stubData = NULL;
       
   475         stubPkg = NULL;        
       
   476         }
       
   477 
       
   478     // -----------------------------------------------------------------------    
       
   479     // This function compares sis and stub versions. 
       
   480     // -----------------------------------------------------------------------
       
   481     //   
       
   482     TInt CVersionRevisor::CompareVersions( 
       
   483         TVersion aSisVer, 
       
   484         TVersion aStubVer )
       
   485         { 
       
   486         FLOG( _L("[VersionRev] CompareVersions()") );
       
   487                         
       
   488         // Compare major version
       
   489         if ( aSisVer.iMajor > aStubVer.iMajor  )
       
   490             {
       
   491             FLOG( _L("[VersionRev] STUB major version older ") );
       
   492             return KVerRevSisVersionNewer;
   501             return KVerRevSisVersionNewer;
   493             }
   502             }
   494         // If same major version, check minor version.
   503         // If same minor version, check build version.
   495         else if ( aSisVer.iMajor == aStubVer.iMajor )
   504         else if ( aSisVer.iMinor == aStubVer.iMinor )
   496             {                           
   505             {
   497             if ( aSisVer.iMinor > aStubVer.iMinor )
   506             if ( aSisVer.iBuild > aStubVer.iBuild  )
   498                 {
   507                 {
   499                 FLOG( _L("[VersionRev] STUB minor version older ") );
   508                 FLOG( _L("[VersionRev] STUB build version older ") );
   500                 return KVerRevSisVersionNewer;
   509                 return KVerRevSisVersionNewer;                        
       
   510                 }  
       
   511             else if ( aSisVer.iBuild == aStubVer.iBuild  )
       
   512                 {
       
   513                 // Sis build version is same as stub.
       
   514                 FLOG( _L("[VersionRev] Build version same ") );
       
   515                 return KVerRevSisVersionSame;                        
       
   516                 }                                  
       
   517             else // build
       
   518                 {
       
   519                 // Sis build version is older.
       
   520                 FLOG( _L("[VersionRev] SIS build version OLDER !") );
       
   521                 return KVerRevSisVersionOlder;
   501                 }
   522                 }
   502             // If same minor version, check build version.
   523             }
   503             else if ( aSisVer.iMinor == aStubVer.iMinor )
   524         else // minor
   504                 {
       
   505                 if ( aSisVer.iBuild > aStubVer.iBuild  )
       
   506                     {
       
   507                     FLOG( _L("[VersionRev] STUB build version older ") );
       
   508                     return KVerRevSisVersionNewer;                        
       
   509                     }  
       
   510                 else if ( aSisVer.iBuild == aStubVer.iBuild  )
       
   511                     {
       
   512                     // Sis build version is same as stub.
       
   513                     FLOG( _L("[VersionRev] Build version same ") );
       
   514                     return KVerRevSisVersionSame;                        
       
   515                     }                                  
       
   516                 else // build
       
   517                     {
       
   518                     // Sis build version is older.
       
   519                     FLOG( _L("[VersionRev] SIS build version OLDER !") );
       
   520                     return KVerRevSisVersionOlder;
       
   521                     }
       
   522                 }
       
   523             else // minor
       
   524                 {
       
   525                 // Sis minor version is older.
       
   526                 FLOG( _L("[VersionRev] SIS minor version OLDER !") );
       
   527                 return KVerRevSisVersionOlder;
       
   528                 }            
       
   529             }        
       
   530         else //major
       
   531             {
   525             {
   532             // Sis major version is older.
   526             // Sis minor version is older.
   533             FLOG( _L("[VersionRev] SIS major version OLDER !") );
   527             FLOG( _L("[VersionRev] SIS minor version OLDER !") );
   534             return KVerRevSisVersionOlder;
   528             return KVerRevSisVersionOlder;
   535             }            
   529             }            
       
   530         }        
       
   531     else //major
       
   532         {
       
   533         // Sis major version is older.
       
   534         FLOG( _L("[VersionRev] SIS major version OLDER !") );
       
   535         return KVerRevSisVersionOlder;
       
   536         }            
       
   537     }
       
   538 
       
   539 // -----------------------------------------------------------------------    
       
   540 // This function check that all sis pkg's binary files are found from rom. 
       
   541 // -----------------------------------------------------------------------
       
   542 //     
       
   543 TBool CVersionRevisor::AllRomBinariesFoundL( Swi::RSisRegistryEntry& aEntry )
       
   544     {
       
   545     FLOG( _L("[VersionRev] AllRomBinariesFoundL") );
       
   546     TBool allBinaryFilesFound = EFalse;
       
   547     TInt err = KErrNone;
       
   548     RPointerArray<HBufC> sisFilesArray;
       
   549     RPointerArray<HBufC> binaryFilesArray;
       
   550             
       
   551     // Get installed files from this entry.
       
   552     aEntry.FilesL( sisFilesArray );
       
   553     TInt arrayCount = sisFilesArray.Count();   
       
   554     FLOG_1( _L("[VersionRev] Sis files count = %d"), arrayCount );
       
   555     
       
   556     if ( arrayCount )
       
   557         {                                                   
       
   558         for ( TInt index = 0; index < arrayCount; index++ )
       
   559             {
       
   560             // Get file path
       
   561             HBufC* tempFilePath = sisFilesArray[index]->AllocL();
       
   562             CleanupStack::PushL( tempFilePath );
       
   563             FLOG_1( _L("[VersionRev] File path: %S \n"), tempFilePath );                
       
   564             
       
   565             // Check if file is installed to sys\bin folder.
       
   566             // Search \sys\bin string from the descriptor's data.
       
   567             err = tempFilePath->Find( KVerRevSysPath );
       
   568             FLOG_1( _L("[VersionRev] Sys path found = %d"), err );
       
   569             
       
   570             if ( err != KErrNotFound )
       
   571                 {
       
   572                 // If binary file, add to array.
       
   573                 binaryFilesArray.Append( tempFilePath );
       
   574                 CleanupStack::Pop(); //tempFilePath
       
   575                 }
       
   576             else
       
   577                 {
       
   578                 // Delete temp descriptor.
       
   579                 CleanupStack::PopAndDestroy( tempFilePath );
       
   580                 tempFilePath = NULL;
       
   581                 }                
       
   582             }
       
   583         
       
   584         // Count how meny binary files are found.
       
   585         TInt binaryCount = binaryFilesArray.Count();
       
   586         FLOG_1( _L("[VersionRev] Binary files count = %d"), binaryCount );
       
   587         if ( binaryCount )
       
   588             {
       
   589             TInt foundInRomCount = 0;
       
   590             TFindFile find( iFs );
       
   591             TParse stringParser;                
       
   592             TFileName binaryFileNameAndExt;
       
   593             
       
   594             for ( TInt index = 0; index < binaryCount; index++ )
       
   595                  {
       
   596                  // Get binary file path.
       
   597                  HBufC* binaryPathBuf = binaryFilesArray[index];
       
   598                  // Parse file name and extension.                                                  
       
   599                  stringParser.Set( *binaryPathBuf ,NULL, NULL );                                                                                  
       
   600                  binaryFileNameAndExt.Copy( stringParser.NameAndExt() );                                          
       
   601                  FLOG_1( _L("[VersionRev] Search file: %S \n"), 
       
   602                          &binaryFileNameAndExt );   
       
   603                                                          
       
   604                  // Search file in z:\sys\bin.
       
   605                  // Note path must contain drive letter.
       
   606                  err = find.FindByPath( 
       
   607                          binaryFileNameAndExt, 
       
   608                          &KVerRevRomSysPath() ); 
       
   609                  FLOG_1( _L("[VersionRev] Found in rom = %d"), err );
       
   610                  
       
   611                  if ( err == KErrNone )
       
   612                      {
       
   613                      // File found in rom. Increase counter.
       
   614                      foundInRomCount++;
       
   615                      }                                                  
       
   616                  } //for
       
   617             
       
   618             // Check that all binary files are found in rom.
       
   619             if ( binaryCount == foundInRomCount )
       
   620                 {
       
   621                 allBinaryFilesFound = ETrue;
       
   622                 FLOG( _L("[VersionRev] All rom file found !") );
       
   623                 }                
       
   624             } //if  
       
   625         
       
   626         // Free all objects and array.
       
   627         binaryFilesArray.ResetAndDestroy();
   536         }
   628         }
   537   
   629     // Free all objects and array.
   538     // -----------------------------------------------------------------------    
   630     sisFilesArray.ResetAndDestroy();
   539     // This function check that all sis pkg's binary files are found from rom. 
   631     
   540     // -----------------------------------------------------------------------
   632     return allBinaryFilesFound;
   541     //     
   633     }
   542     TBool CVersionRevisor::AllRomBinariesFoundL( Swi::RSisRegistryEntry& aEntry )
   634 
   543         {
   635 
   544         FLOG( _L("[VersionRev] AllRomBinariesFoundL") );
   636 // -----------------------------------------------------------------------
   545         TBool allBinaryFilesFound = EFalse;
   637 // This function handles VersionRevisors self exit.
   546         TInt err = KErrNone;
   638 // -----------------------------------------------------------------------
   547         RPointerArray<HBufC> sisFilesArray;
   639 //      
   548         RPointerArray<HBufC> binaryFilesArray;
   640  void CVersionRevisor::Exit()
   549                 
   641      {
   550         // Get installed files from this entry.
   642      FLOG( _L("[VersionRev] Exit() ") );         
   551         aEntry.FilesL( sisFilesArray );
   643      // Ok all is done. Free all resources and exit.
   552         TInt arrayCount = sisFilesArray.Count();   
   644      delete this;
   553         FLOG_1( _L("[VersionRev] Sis files count = %d"), arrayCount );
   645      }
   554         
   646 
   555         if ( arrayCount )
   647 //    } // namespace Swi
   556             {                                                   
       
   557             for ( TInt index = 0; index < arrayCount; index++ )
       
   558                 {
       
   559                 // Get file path
       
   560                 HBufC* tempFilePath = sisFilesArray[index]->AllocL();
       
   561                 CleanupStack::PushL( tempFilePath );
       
   562                 FLOG_1( _L("[VersionRev] File path: %S \n"), tempFilePath );                
       
   563                 
       
   564                 // Check if file is installed to sys\bin folder.
       
   565                 // Search \sys\bin string from the descriptor's data.
       
   566                 err = tempFilePath->Find( KVerRevSysPath );
       
   567                 FLOG_1( _L("[VersionRev] Sys path found = %d"), err );
       
   568                 
       
   569                 if ( err != KErrNotFound )
       
   570                     {
       
   571                     // If binary file, add to array.
       
   572                     binaryFilesArray.Append( tempFilePath );
       
   573                     CleanupStack::Pop(); //tempFilePath
       
   574                     }
       
   575                 else
       
   576                     {
       
   577                     // Delete temp descriptor.
       
   578                     CleanupStack::PopAndDestroy( tempFilePath );
       
   579                     tempFilePath = NULL;
       
   580                     }                
       
   581                 }
       
   582             
       
   583             // Count how meny binary files are found.
       
   584             TInt binaryCount = binaryFilesArray.Count();
       
   585             FLOG_1( _L("[VersionRev] Binary files count = %d"), binaryCount );
       
   586             if ( binaryCount )
       
   587                 {
       
   588                 TInt foundInRomCount = 0;
       
   589                 TFindFile find( iFs );
       
   590                 TParse stringParser;                
       
   591                 TFileName binaryFileNameAndExt;
       
   592                 
       
   593                 for ( TInt index = 0; index < binaryCount; index++ )
       
   594                      {
       
   595                      // Get binary file path.
       
   596                      HBufC* binaryPathBuf = binaryFilesArray[index];
       
   597                      // Parse file name and extension.                                                  
       
   598                      stringParser.Set( *binaryPathBuf ,NULL, NULL );                                                                                  
       
   599                      binaryFileNameAndExt.Copy( stringParser.NameAndExt() );                                          
       
   600                      FLOG_1( _L("[VersionRev] Search file: %S \n"), 
       
   601                              &binaryFileNameAndExt );   
       
   602                                                              
       
   603                      // Search file in z:\sys\bin.
       
   604                      // Note path must contain drive letter.
       
   605                      err = find.FindByPath( 
       
   606                              binaryFileNameAndExt, 
       
   607                              &KVerRevRomSysPath() ); 
       
   608                      FLOG_1( _L("[VersionRev] Found in rom = %d"), err );
       
   609                      
       
   610                      if ( err == KErrNone )
       
   611                          {
       
   612                          // File found in rom. Increase counter.
       
   613                          foundInRomCount++;
       
   614                          }                                                  
       
   615                      } //for
       
   616                 
       
   617                 // Check that all binary files are found in rom.
       
   618                 if ( binaryCount == foundInRomCount )
       
   619                     {
       
   620                     allBinaryFilesFound = ETrue;
       
   621                     FLOG( _L("[VersionRev] All rom file found !") );
       
   622                     }                
       
   623                 } //if  
       
   624             
       
   625             // Free all objects and array.
       
   626             binaryFilesArray.ResetAndDestroy();
       
   627             }
       
   628         // Free all objects and array.
       
   629         sisFilesArray.ResetAndDestroy();
       
   630         
       
   631         return allBinaryFilesFound;
       
   632         }
       
   633     
       
   634     
       
   635     // -----------------------------------------------------------------------
       
   636     // This function handles VersionRevisors self exit.
       
   637     // -----------------------------------------------------------------------
       
   638     //      
       
   639      void CVersionRevisor::Exit()
       
   640          {
       
   641          FLOG( _L("[VersionRev] Exit() ") );         
       
   642          // Ok all is done. Free all resources and exit.
       
   643          delete this;
       
   644          }
       
   645 
       
   646     } // namespace Swi
       
   647 
   648 
   648 //EOF
   649 //EOF