appinstaller/AppinstUi/Daemon/Src/daemoninstaller.cpp
changeset 37 6e7b00453237
parent 29 26b6f0522fd8
child 42 d17dc5398051
equal deleted inserted replaced
33:8110bf1194d1 37:6e7b00453237
   117     iFs.ShareProtected();
   117     iFs.ShareProtected();
   118     iDialogs = CDialogWrapper::NewL( iFs );
   118     iDialogs = CDialogWrapper::NewL( iFs );
   119     iPreviouslyInstalledAppsCache = CPreviouslyInstalledAppsCache::NewL();
   119     iPreviouslyInstalledAppsCache = CPreviouslyInstalledAppsCache::NewL();
   120     iInstallationFailedAppsCache = CInstallationFailedAppsCache::NewL();
   120     iInstallationFailedAppsCache = CInstallationFailedAppsCache::NewL();
   121     iShutdownWatcher = CShutdownWatcher::NewL( *this );
   121     iShutdownWatcher = CShutdownWatcher::NewL( *this );
   122     iShutdownWatcher->Start();
   122     iShutdownWatcher->Start();        
       
   123     iPercentValue = 0;
       
   124     
   123     // For uninstaller
   125     // For uninstaller
   124     // SisInstaller do not own this so do not delete.     
   126     // SisInstaller do not own this so do not delete.     
   125     iProgramStatus = &aMainStatus;  
   127     iProgramStatus = &aMainStatus;  
   126     iUpdateCache = ETrue;    
   128     iUpdateCache = ETrue;    
   127     iFileOpen = EFalse;    
   129     iFileOpen = EFalse;    
   264 // When the software installer has changed state attemp to install a 
   266 // When the software installer has changed state attemp to install a 
   265 // sisx file
   267 // sisx file
   266 // -----------------------------------------------------------------------
   268 // -----------------------------------------------------------------------
   267 //
   269 //
   268 void CSisInstaller::RunL()
   270 void CSisInstaller::RunL()
   269     {
   271     {    
   270     FLOG_1( _L("Daemon: Installer RunL status:%d"), iStatus.Int() );  
   272     FLOG_1( _L("Daemon: Installer RunL status:%d"), iStatus.Int() );  
   271     FLOG_1( _L("Daemon: Installer RunL state:%d"), iState );                
   273     FLOG_1( _L("Daemon: Installer RunL state:%d"), iState );                
   272     
   274     
   273     // For uninstaller
   275     // For uninstaller
   274     // Check that uninstaller is not running.
   276     // Check that uninstaller is not running.
   399                     iUpdateCache = EFalse;
   401                     iUpdateCache = EFalse;
   400                     }
   402                     }
   401                 
   403                 
   402                 if ( iFileIndex < iFilesToInstall.Count() )
   404                 if ( iFileIndex < iFilesToInstall.Count() )
   403                     { 
   405                     { 
       
   406                     // Let's calc. values before index is updated.
       
   407                     CalcPercentValue();
       
   408                                                        
   404                     // Get next sisx package from array.                 
   409                     // Get next sisx package from array.                 
   405                     iSisFile.Copy( *iFilesToInstall[iFileIndex] );
   410                     iSisFile.Copy( *iFilesToInstall[iFileIndex] );
   406                     ++iFileIndex;    
   411                     ++iFileIndex;    
   407                     
   412                     
   408                     FLOG_1( _L("Daemon: RunL: Open File: %S"), &iSisFile );
   413                     FLOG_1( _L("Daemon: RunL: Open File: %S"), &iSisFile );
   456                                                                                                                                                                                                                                                    
   461                                                                                                                                                                                                                                                    
   457                             iInstallLauncher->InstallL( iSisFileHandle, 
   462                             iInstallLauncher->InstallL( iSisFileHandle, 
   458                                                         iSisFile, 
   463                                                         iSisFile, 
   459                                                         iStatus );
   464                                                         iStatus );
   460                             
   465                             
   461                             iDialogs->ShowWaitingNoteL(); 
   466                             // Start to show progress dialog. Dialog is shown 
       
   467                             // only 3 sec. 
       
   468                             iDialogs->ShowWaitingNoteL();    
       
   469                             // Start also the universal indicator.
       
   470                             iDialogs->ActivateIndicatorL( iPercentValue );
       
   471                             
   462                             iState = EDSisInstallerStateInstalling;                       
   472                             iState = EDSisInstallerStateInstalling;                       
   463                             iInstallerState = iState;                                                   
   473                             iInstallerState = iState;                                                   
   464                             SetActive();                               
   474                             SetActive();                               
   465                             }
   475                             }
   466                         }               
   476                         }               
   576 // CSisInstaller::InstallationCompleted
   586 // CSisInstaller::InstallationCompleted
   577 // -----------------------------------------------------------------------
   587 // -----------------------------------------------------------------------
   578 //
   588 //
   579 void CSisInstaller::InstallationCompleted( TInt aResult )
   589 void CSisInstaller::InstallationCompleted( TInt aResult )
   580     {
   590     {
       
   591     // Let's update universal indicator ones more.   
       
   592     iDialogs->ActivateIndicatorL( 100 );
       
   593     
   581     FLOG_1( _L("Daemon: InstallationCompleted with result = %d"), aResult );  
   594     FLOG_1( _L("Daemon: InstallationCompleted with result = %d"), aResult );  
   582     iState = EDSisInstallerStateIdle;    
   595     iState = EDSisInstallerStateIdle;    
   583     iInstallErr = KErrNone;     
   596     iInstallErr = KErrNone;     
   584     FLOG( _L("Daemon: InstallationCompleted: Delete iInstallLauncher") );
   597     FLOG( _L("Daemon: InstallationCompleted: Delete iInstallLauncher") );
   585     delete iInstallLauncher;
   598     delete iInstallLauncher;
   600         {
   613         {
   601         FLOG( _L("Daemon: InstallationCompleted: File open - Close it !!!") );
   614         FLOG( _L("Daemon: InstallationCompleted: File open - Close it !!!") );
   602         iSisFileHandle.Close();
   615         iSisFileHandle.Close();
   603         iFileOpen = EFalse;
   616         iFileOpen = EFalse;
   604         }    
   617         }    
   605                             
   618     
   606     TRAP_IGNORE( iDialogs->CancelWaitingNoteL() );
   619     // Make sure that progress note is closed.
       
   620     TRAP_IGNORE( iDialogs->CancelWaitingNote() );
       
   621     // Close the universal indicator. 
       
   622     iDialogs->CancelIndicatorL();
   607         
   623         
   608     if ( aResult != KErrNone && 
   624     if ( aResult != KErrNone && 
   609          iSisFile.Length() > 0 && 
   625          iSisFile.Length() > 0 && 
   610          IsMediaPresent( TChar( iSisFile[0] ) ) )
   626          IsMediaPresent( TChar( iSisFile[0] ) ) )
   611         {        
   627         {        
   778         }           
   794         }           
   779            
   795            
   780     FLOG_1( _L("Daemon: IsValidPackageL = %d"), result );  
   796     FLOG_1( _L("Daemon: IsValidPackageL = %d"), result );  
   781     return result;    
   797     return result;    
   782     }
   798     }
   783     
   799  
       
   800 // -----------------------------------------------------------------------
       
   801 // CSisInstaller::CalcPrecentValue
       
   802 // -----------------------------------------------------------------------
       
   803 //
       
   804 void CSisInstaller::CalcPercentValue()
       
   805     {  
       
   806     FLOG( _L("Daemon: CSisInstaller::CalcPercentValue") );
       
   807     FLOG_1( _L("Daemon: iFileIndex = %d"), iFileIndex ); 
       
   808     // Let's calculate indicator value for UI now.
       
   809     TInt sisxFileCount = iFilesToInstall.Count();
       
   810     FLOG_1( _L("Daemon: iFilesToInstall.Count = %d"), sisxFileCount ); 
       
   811     iPercentValue = 0;
       
   812 
       
   813     // Note! if iFileIndex is zero, no package is installed bacause
       
   814     // installation process starts after this function.     
       
   815     if ( iFileIndex && sisxFileCount )
       
   816         {
       
   817         // Let's calculate new precent value after some
       
   818         // package is installed.     
       
   819         if ( iFileIndex <= sisxFileCount )
       
   820             {
       
   821             TReal32 realFileIndex = iFileIndex;
       
   822             TReal32 realFileCount = sisxFileCount;
       
   823             iPercentValue = (realFileIndex/realFileCount)*100;                                   
       
   824             }
       
   825         else
       
   826             {
       
   827             // Most probably all is installed if index is bigger then
       
   828             // filen count. Let's not show over 100% to user.
       
   829             // This may happend after last package is processed since 
       
   830             // index counter is updated before install starts.
       
   831             iPercentValue = 100;
       
   832             }
       
   833         }
       
   834         
       
   835     //TInt tempVal = (TInt)iPercentValue;    
       
   836     FLOG_1( _L("Daemon: CalcPercentValue value = %d"), (TInt)iPercentValue );
       
   837     }
       
   838 
   784 //EOF
   839 //EOF
   785 
   840 
   786 
   841 
   787 
   842 
   788 
   843