appinstaller/AppinstUi/Daemon/Src/uninstaller.cpp
branchRCL_3
changeset 25 7333d7932ef7
parent 0 ba25891c3a9e
child 26 8b7f4e561641
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
    32 #include "DialogWrapper.h"
    32 #include "DialogWrapper.h"
    33 
    33 
    34 using namespace Swi;
    34 using namespace Swi;
    35 
    35 
    36 const static TInt KWaitTime = 3000000; // 2 secs
    36 const static TInt KWaitTime = 3000000; // 2 secs
       
    37 const TInt KMimeTextLength = 64;
    37 
    38 
    38 // -----------------------------------------------------------------------
    39 // -----------------------------------------------------------------------
    39 // Two phased construction
    40 // Two phased construction
    40 // -----------------------------------------------------------------------
    41 // -----------------------------------------------------------------------
    41 //   
    42 //   
   112     User::LeaveIfError( iFs.Connect() );    
   113     User::LeaveIfError( iFs.Connect() );    
   113     User::LeaveIfError( iApaSession.Connect() );    
   114     User::LeaveIfError( iApaSession.Connect() );    
   114     iFs.ShareProtected();
   115     iFs.ShareProtected();
   115     iUidArrayIndex = 0;
   116     iUidArrayIndex = 0;
   116     iSilentUninstaller = NULL;
   117     iSilentUninstaller = NULL;
   117     iState = EUninstallerStateIdle;      
   118     iState = EUninstallerStateIdle;   
   118     // Alloc descriptor for mime type sis/sisx
   119     
   119     iMime = SwiUI::KSisxMimeType().AllocL();      
   120     // Alloc descriptor for mime type sis/sisx    
       
   121     iMime = HBufC::NewL( KMimeTextLength );
       
   122     TPtr iMimePtr = iMime->Des();
       
   123     iMimePtr.Copy( SwiUI::KSisxMimeType );
       
   124          
   120     // Note this will create new instance for dialog class and
   125     // Note this will create new instance for dialog class and
   121     // also new dialog watcher AO for uninstaller.
   126     // also new dialog watcher AO for uninstaller.
   122     // Since uninstaller is used rarely this is not big issue.
   127     // Since uninstaller is used rarely this is not big issue.
   123     // In future dialog class could be added to CProgramStatus class 
   128     // In future dialog class could be added to CProgramStatus class 
   124     // member from where both installer and uninstaller could us it.    
   129     // member from where both installer and uninstaller could us it.    
   274                  if ( iUidArrayIndex < iPkgUidArray.Count() )
   279                  if ( iUidArrayIndex < iPkgUidArray.Count() )
   275                      { 
   280                      { 
   276                      // Display installing note for user.
   281                      // Display installing note for user.
   277                      iDialogs->ShowWaitingNoteForUninstallerL(); 
   282                      iDialogs->ShowWaitingNoteForUninstallerL(); 
   278                      
   283                      
       
   284                      if ( iUidArrayIndex == 0 )
       
   285                          {
       
   286                          // Set uninstall mode for universal indicator and
       
   287                          // set percent value to 0%.
       
   288                          iDialogs->SetModeToIndicatorL( KSWIDaemonUninstallerMode );
       
   289                          }
       
   290                      else
       
   291                          {
       
   292                          // Calculate current percent value to iPercentValue. 
       
   293                          CalcPercentValue();
       
   294                          // Activate new value to universal indicator.
       
   295                          iDialogs->ActivateIndicatorL( iPercentValue );
       
   296                          }
       
   297                      
   279                      FLOG_1( _L("[SISUninstaller] Run uninstall index = %d"), 
   298                      FLOG_1( _L("[SISUninstaller] Run uninstall index = %d"), 
   280                              iUidArrayIndex ); 
   299                              iUidArrayIndex ); 
   281                      
   300                      
   282                      // Get next UID. 
   301                      // Get next UID. 
   283                      iUID = iPkgUidArray[ iUidArrayIndex ];
   302                      iUID = iPkgUidArray[ iUidArrayIndex ];
   340 // -----------------------------------------------------------------------
   359 // -----------------------------------------------------------------------
   341 //
   360 //
   342 void CSisPkgUninstaller::UninstallationCompleted( TInt /*aResult*/ )
   361 void CSisPkgUninstaller::UninstallationCompleted( TInt /*aResult*/ )
   343     {
   362     {
   344     FLOG( _L("[SISUninstaller] UninstallationCompleted") );
   363     FLOG( _L("[SISUninstaller] UninstallationCompleted") );
       
   364     // Update indicator value last time and show 100% to user.
       
   365     iDialogs->ActivateIndicatorL( 100 );
   345     
   366     
   346     if ( EStateUninstalling == iProgramStatus->GetProgramStatus() )
   367     if ( EStateUninstalling == iProgramStatus->GetProgramStatus() )
   347          {   
   368          {   
   348          FLOG( _L("[SISUninstaller] Set status to idle"));
   369          FLOG( _L("[SISUninstaller] Set status to idle"));
   349          iProgramStatus->SetProgramStatusToIdle();
   370          iProgramStatus->SetProgramStatusToIdle();
   351  
   372  
   352     iUidArrayIndex = 0;    
   373     iUidArrayIndex = 0;    
   353     iState = EUninstallerStateIdle; 
   374     iState = EUninstallerStateIdle; 
   354           
   375           
   355     // Cancel waiting note.
   376     // Cancel waiting note.
   356     TRAP_IGNORE( iDialogs->CancelWaitingNoteL() );       
   377     TRAP_IGNORE( iDialogs->CancelWaitingNoteForUninstaller());
       
   378     // Close indicator.
       
   379     iDialogs->CancelIndicatorL();
   357     }  
   380     }  
   358 
   381 
   359 
   382 
   360 // -----------------------------------------------------------------------
   383 // -----------------------------------------------------------------------
   361 // This is for self exit.
   384 // This is for self exit.
   367     // Uninstall is completed and we do not need uninstaller anymore.
   390     // Uninstall is completed and we do not need uninstaller anymore.
   368     // Call revisor's destructor.
   391     // Call revisor's destructor.
   369     iRevisor->Exit();
   392     iRevisor->Exit();
   370     }
   393     }
   371 
   394 
       
   395 // -----------------------------------------------------------------------
       
   396 // CSisInstaller::CalcPrecentValue
       
   397 // -----------------------------------------------------------------------
       
   398 //
       
   399 void CSisPkgUninstaller::CalcPercentValue()
       
   400     {     
       
   401     FLOG( _L("[SISUninstaller] CalcPercentValue") );
       
   402     FLOG_1( _L("[SISUninstaller] iUidArrayIndex = %d"), iUidArrayIndex ); 
       
   403     // Let's calculate indicator value for UI now.
       
   404     TInt packageUidCount = iPkgUidArray.Count();
       
   405     FLOG_1( _L("[SISUninstaller] pkg UID count = %d"), packageUidCount ); 
       
   406     
       
   407     iPercentValue = 0;
       
   408 
       
   409     if ( iUidArrayIndex && packageUidCount )
       
   410         {
       
   411         // Let's calculate new precent value.     
       
   412         if ( iUidArrayIndex <= packageUidCount )
       
   413             {
       
   414             TReal32 realArrayIndex = iUidArrayIndex;
       
   415             TReal32 realPkgCount = packageUidCount;
       
   416             iPercentValue = (realArrayIndex/realPkgCount)*100;                                   
       
   417             }
       
   418         else
       
   419             {
       
   420             // Most probably all is uninstalled if index is bigger then
       
   421             // filen count. Let's not show over 100% to user.           
       
   422             iPercentValue = 100;
       
   423             }
       
   424         }
       
   425             
       
   426     FLOG_1( _L("[SISUninstaller] percent value = %d"), (TInt)iPercentValue );
       
   427     }
       
   428 
   372 //EOF
   429 //EOF