appinstaller/AppinstUi/Daemon/Src/daemoninstaller.cpp
changeset 42 d17dc5398051
parent 37 6e7b00453237
child 80 9dcba1ee99f7
equal deleted inserted replaced
37:6e7b00453237 42:d17dc5398051
    13 *
    13 *
    14 * Description: 
    14 * Description: 
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <usif/scr/scr.h>
       
    19 #include <usif/scr/screntries.h>
       
    20 
       
    21 #include "daemoninstaller.h"
    18 #include "daemoninstaller.h"
    22 #include "DialogWrapper.h"
    19 #include "DialogWrapper.h"
    23 #include "swispubsubdefs.h"
    20 #include "swispubsubdefs.h"
    24 
    21 
    25 #include "SWInstDebug.h"
    22 #include "SWInstDebug.h"
    43 
    40 
    44 using namespace Swi;
    41 using namespace Swi;
    45 
    42 
    46 const static TInt KInstallRetryWaitTime = 10000000; // 10 secs
    43 const static TInt KInstallRetryWaitTime = 10000000; // 10 secs
    47 // For uninstaller
    44 // For uninstaller
    48 const static TInt KWaitUninstallerTime = 1000000; // 1 secs  
    45 const static TInt KWaitUninstallerTime = 1000000; // 1 secs 
    49 
    46 
    50 _LIT(KMCSisInstaller,"Daemon-Installer"); // Minor-Component name
    47 _LIT(KMCSisInstaller,"Daemon-Installer"); // Minor-Component name
    51 
    48 
    52 
    49 
    53 // -----------------------------------------------------------------------
    50 // -----------------------------------------------------------------------
    84 // Destructor
    81 // Destructor
    85 // -----------------------------------------------------------------------
    82 // -----------------------------------------------------------------------
    86 //
    83 //
    87 CSisInstaller::~CSisInstaller()
    84 CSisInstaller::~CSisInstaller()
    88     {
    85     {
       
    86     FLOG( _L("Daemon: CSisInstaller::~CSisInstaller") );
    89     Cancel();
    87     Cancel();
    90     iTimer.Close();
    88     iTimer.Close();
    91     iFilesToInstall.ResetAndDestroy();
    89     iFilesToInstall.ResetAndDestroy();
    92     iFilesToInstall.Close();
    90     iFilesToInstall.Close();    
    93     delete iInstallLauncher;
    91     delete iInstallLauncher;
    94     delete iDialogs;      
    92     delete iDialogs;      
    95     delete iPreviouslyInstalledAppsCache;
    93     delete iPreviouslyInstalledAppsCache;
    96     delete iInstallationFailedAppsCache;  
    94     delete iInstallationFailedAppsCache;  
    97     delete iShutdownWatcher;
    95     delete iShutdownWatcher;
   125     // For uninstaller
   123     // For uninstaller
   126     // SisInstaller do not own this so do not delete.     
   124     // SisInstaller do not own this so do not delete.     
   127     iProgramStatus = &aMainStatus;  
   125     iProgramStatus = &aMainStatus;  
   128     iUpdateCache = ETrue;    
   126     iUpdateCache = ETrue;    
   129     iFileOpen = EFalse;    
   127     iFileOpen = EFalse;    
       
   128     iInstallLauncher = NULL;
   130     }
   129     }
   131 		
   130 		
   132 // -----------------------------------------------------------------------
   131 // -----------------------------------------------------------------------
   133 // CSisInstaller::AddFileToInstallL
   132 // CSisInstaller::AddFileToInstallL
   134 // Set the location of all sis files and the list of them
   133 // Set the location of all sis files and the list of them
   150 //
   149 //
   151 void CSisInstaller::StartInstallingL()
   150 void CSisInstaller::StartInstallingL()
   152     {
   151     {
   153     FLOG( _L("Daemon: StartInstallingL") );
   152     FLOG( _L("Daemon: StartInstallingL") );
   154 
   153 
   155     if(!iFilesToInstall.Count())
   154     if( !iFilesToInstall.Count() )
   156         {
   155         {
   157         // For uninstaller
   156         // For uninstaller
   158         // Check state, if installing change it to idle.
   157         // Check state, if installing change it to idle.
   159         if ( EStateInstalling == iProgramStatus->GetProgramStatus() )
   158         if ( EStateInstalling == iProgramStatus->GetProgramStatus() )
   160             {
   159             {
   161             FLOG( _L("Daemon: StartInstallingL: Set EStateIdle") );
   160             FLOG( _L("Daemon: StartInstallingL: Set EStateIdle") );
   162             iProgramStatus->SetProgramStatusToIdle();
   161             iProgramStatus->SetProgramStatusToIdle();
   163             }        
   162             }        
   164         
   163         FLOG( _L("Daemon: StartInstallingL: User::Leave(KErrAbort)") );
   165         User::Leave(KErrAbort);
   164         User::Leave(KErrAbort);
   166         }
   165         }
   167     
   166     
   168     // For uninstaller        
   167     // For uninstaller        
   169     // Check state. If idle chage it to installing, but if installing 
   168     // Check state. If idle chage it to installing, but if installing 
   170     // or uninstalling do nothing. 
   169     // or uninstalling do nothing. 
   171     if ( EStateIdle == iProgramStatus->GetProgramStatus() )
   170     if ( EStateIdle == iProgramStatus->GetProgramStatus() )
   172         {
   171         {
   173         FLOG( _L("Daemon: StartInstallingL: Set EStateInstalling") );
   172         FLOG( _L("Daemon: StartInstallingL: Set EStateInstalling") );
   174         iProgramStatus->SetProgramStatus( EStateInstalling );
   173         iProgramStatus->SetProgramStatus( EStateInstalling );
   175         }         
   174         } 
   176     FLOG_1( _L("[CSisInstaller] ConstructL iGeneralProcessStatus = %d"),
   175     
   177             iGeneralProcessStatus );  
   176     FLOG_1( _L("Daemon: iGeneralProcessStatus: %d"), iGeneralProcessStatus );     
       
   177     FLOG_1( _L("Daemon: iInstallLauncher: 0x%x"),iInstallLauncher );  
   178         
   178         
   179     if ( !iInstallLauncher )
   179     if ( iInstallLauncher == NULL )
   180         {
   180         {
       
   181         FLOG( _L("Daemon: Create iInstallLauncher") );
   181         iInstallLauncher = CSilentLauncher::NewL( iFs );   
   182         iInstallLauncher = CSilentLauncher::NewL( iFs );   
   182         
   183         
   183         // Update cache so we do not try to start install for
   184         // Update cache so we do not try to start install for
   184         // components which are installed. This is done always
   185         // components which are installed. This is done always
   185         // when new install session is started (e.g. after mmc insert).
   186         // when new install session is started (e.g. after mmc insert).
   189         }   
   190         }   
   190 
   191 
   191     if ( iState == EDSisInstallerStateIdle )
   192     if ( iState == EDSisInstallerStateIdle )
   192         {                
   193         {                
   193         // Reset the error
   194         // Reset the error
   194         iInstallErr = KErrNone; 
   195         iInstallErr = KErrNone;           
   195           
       
   196         CompleteSelf();
   196         CompleteSelf();
   197         }
   197         }
   198     }
   198     }
   199     
   199     
   200 // -----------------------------------------------------------------------
   200 // -----------------------------------------------------------------------
   223     {
   223     {
   224     FLOG( _L("Daemon: CSisInstaller::CompleteSelf") );
   224     FLOG( _L("Daemon: CSisInstaller::CompleteSelf") );
   225     if ( !IsActive() )
   225     if ( !IsActive() )
   226         {        
   226         {        
   227         TRequestStatus* status = &iStatus;
   227         TRequestStatus* status = &iStatus;
   228         User::RequestComplete(status,KErrNone);
   228         FLOG( _L("Daemon: CompleteSelf: RequestComplete") );
       
   229         User::RequestComplete( status, KErrNone );
       
   230         FLOG( _L("Daemon: CompleteSelf: SetActive") );
   229         SetActive();
   231         SetActive();
   230         }    
   232         }    
   231     }
   233     }
   232 
   234 
   233 // -----------------------------------------------------------------------
   235 // -----------------------------------------------------------------------
   444                                     &iSisFile );                             
   446                                     &iSisFile );                             
   445                             TRAP_IGNORE( iDaemonBehaviour->RequestPluginInstall( 
   447                             TRAP_IGNORE( iDaemonBehaviour->RequestPluginInstall( 
   446                                     iSisFile ) );                                                                                  
   448                                     iSisFile ) );                                                                                  
   447                             
   449                             
   448                             // Let's continue to give all packages to plug-in. 
   450                             // Let's continue to give all packages to plug-in. 
   449                             // Note that we do not have iStatus as this is not async. call 
   451                             // Note that we do not have iStatus as this is not 
   450                             // so we can not use EDSisInstallerStateInstalling state.                             
   452                             // async. call so we can not use 
       
   453                             // EDSisInstallerStateInstalling state.                             
   451                             iState = EDSisInstallerStateIdle;                                                 
   454                             iState = EDSisInstallerStateIdle;                                                 
   452                             iInstallerState = iState;
   455                             iInstallerState = iState;
   453                 
   456                 
   454                             // Plugin interface is not asyncronous. We need to 
   457                             // Plugin interface is not asyncronous. We need to 
   455                             // complete self to get all packages to plugin.                            
   458                             // complete self to get all packages to plugin.                            
   456                             CompleteSelf(); 
   459                             CompleteSelf(); 
   457                             }                            
   460                             }                            
   458                         else
   461                         else
   459                             {                                                
   462                             {  
       
   463                             // Start also the universal indicator.
       
   464                             TRAP_IGNORE( iDialogs->ActivateIndicatorL( iPercentValue ) );
       
   465                             // Start to show progress dialog. Dialog is shown 
       
   466                             // only 3 sec. 
       
   467                             TRAP_IGNORE( iDialogs->ShowWaitingNoteL() );    
       
   468                                                         
   460                             FLOG_1( _L("Daemon: Start install for %S"), &iSisFile );
   469                             FLOG_1( _L("Daemon: Start install for %S"), &iSisFile );
   461                                                                                                                                                                                                                                                    
   470                                                                                                                                                                                                                                                    
   462                             iInstallLauncher->InstallL( iSisFileHandle, 
   471                             iInstallLauncher->InstallL( iSisFileHandle, 
   463                                                         iSisFile, 
   472                                                         iSisFile, 
   464                                                         iStatus );
   473                                                         iStatus );
   465                             
   474                                                         
   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                             
       
   472                             iState = EDSisInstallerStateInstalling;                       
   475                             iState = EDSisInstallerStateInstalling;                       
   473                             iInstallerState = iState;                                                   
   476                             iInstallerState = iState;                                                   
   474                             SetActive();                               
   477                             SetActive();                               
   475                             }
   478                             }
   476                         }               
   479                         }               
   506                     FLOG_1( _L("Daemon: Open File: %S"), &iSisFile );
   509                     FLOG_1( _L("Daemon: Open File: %S"), &iSisFile );
   507                 
   510                 
   508                     TInt err = iSisFileHandle.Open( 
   511                     TInt err = iSisFileHandle.Open( 
   509                                     iFs, 
   512                                     iFs, 
   510                                     iSisFile, 
   513                                     iSisFile, 
   511                                     EFileRead | EFileShareReadersOnly
   514                                     EFileRead | EFileShareReadersOnly ); 
   512                                     /*EFileShareReadersOrWriters|EFileRead*/ ); 
       
   513                                                            
   515                                                            
   514                     if ( err )
   516                     if ( err )
   515                          {
   517                          {
   516                          FLOG_1( _L("Daemon: File open ERROR = %d"), err );
   518                          FLOG_1( _L("Daemon: File open ERROR = %d"), err );
   517                          iFileOpen = EFalse;
   519                          iFileOpen = EFalse;
   690 	FLOG_1( _L("Daemon: Is UID installed = 0x%x"), packageId.iUid );
   692 	FLOG_1( _L("Daemon: Is UID installed = 0x%x"), packageId.iUid );
   691 	needsInstalling = !iPreviouslyInstalledAppsCache->
   693 	needsInstalling = !iPreviouslyInstalledAppsCache->
   692                             HasBeenPreviouslyInstalled(packageId);
   694                             HasBeenPreviouslyInstalled(packageId);
   693 	FLOG_1( _L("Daemon: Has been installed (cache) = %d"), !needsInstalling );
   695 	FLOG_1( _L("Daemon: Has been installed (cache) = %d"), !needsInstalling );
   694 	
   696 	
   695 // TODO: Onko rom stubien tarkistus tarpeen jos upgrade ei ole sallittu.
   697 	// No need to check rom stubs in here anymore. 
   696 // Ei taida kannattaa tarksitaan RU ei pitäisi mennä läpi.
   698 	// Note 1: SWI Daemon policy has been that RU packages are not installed 
   697 	FLOG( _L("Daemon: HUOM ROM STUBEJA EI TARKISTETA") ); 	
   699 	// from removable media.	
       
   700 	// Note 2: UpdateAllL will add all pkg uids in cache (PreviouslyInstalled),
       
   701 	// so rom upgrades are not installed since uid is found from the cache.
       
   702 	// Note 3: Install params do not allow RU to be installed. So SWI will
       
   703 	// reject RU (rom upgrade) package anyway.
       
   704 
   698 	/*	
   705 	/*	
   699 	// Huom! edellinen koodi ollut väärin koska UID on jo cachessä !
   706 	// Note! this code has been wrong. No need to check stubs since
   700 	// Tarkistus pitää tehdä vain jos UID löytyy cachestä.
   707 	// policy do not allow RU updates and SWI will reject the install.
   701 	if ( !needsInstalling )
   708 	if ( !needsInstalling )
   702         {
   709         {
   703         RSisRegistrySession registry;
   710         RSisRegistrySession registry;
   704         User::LeaveIfError( registry.Connect() );  
   711         User::LeaveIfError( registry.Connect() );  
   705         CleanupClosePushL( registry );  
   712         CleanupClosePushL( registry );  
   828             // filen count. Let's not show over 100% to user.
   835             // filen count. Let's not show over 100% to user.
   829             // This may happend after last package is processed since 
   836             // This may happend after last package is processed since 
   830             // index counter is updated before install starts.
   837             // index counter is updated before install starts.
   831             iPercentValue = 100;
   838             iPercentValue = 100;
   832             }
   839             }
   833         }
   840         }           
   834         
       
   835     //TInt tempVal = (TInt)iPercentValue;    
       
   836     FLOG_1( _L("Daemon: CalcPercentValue value = %d"), (TInt)iPercentValue );
   841     FLOG_1( _L("Daemon: CalcPercentValue value = %d"), (TInt)iPercentValue );
   837     }
   842     }
   838 
   843 
   839 //EOF
   844 //EOF
   840 
   845