appinstaller/AppinstUi/Daemon/Src/silentuninstaller.cpp
branchRCL_3
changeset 26 8b7f4e561641
parent 25 7333d7932ef7
equal deleted inserted replaced
25:7333d7932ef7 26:8b7f4e561641
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // INCLUDE FILES
    18 // INCLUDE FILES
    19 #include "silentuninstaller.h"
    19 #include "silentuninstaller.h"
       
    20 #include "SWInstDebug.h"
    20 #include "SWInstDefs.h"
    21 #include "SWInstDefs.h"
    21 #include "SWInstDebug.h"
       
    22 
       
    23 
    22 
    24 using namespace Swi;
    23 using namespace Swi;
    25 
    24 
    26 // ============================ MEMBER FUNCTIONS ===============================
    25 // ============================ MEMBER FUNCTIONS ===============================
    27 
    26 
    39 // 2nd constructor
    38 // 2nd constructor
    40 // -----------------------------------------------------------------------------
    39 // -----------------------------------------------------------------------------
    41 //
    40 //
    42 void CSilentUninstaller::ConstructL()
    41 void CSilentUninstaller::ConstructL()
    43     {
    42     {
    44     iConnected = EFalse;     
    43     // Silently kill the app. if needed.
    45     iSifOptions = Usif::COpaqueNamedParams::NewL();
    44     FLOG(_L("[CSilentUninstaller] iKillApp = SwiUI::EPolicyAllowed;"));
    46     iSifResults = Usif::COpaqueNamedParams::NewL();    
    45     iOptions.iKillApp = SwiUI::EPolicyAllowed; 
    47     // Set parameters for silent uninstall.    
    46     FLOG(_L("[CSilentUninstaller] iBreakDependency = SwiUI::EPolicyNotAllowed"));
    48     iSifOptions->AddIntL( Usif::KSifInParam_InstallSilently, ETrue );       
    47     iOptions.iBreakDependency = SwiUI::EPolicyNotAllowed;         
    49     iSifOptions->AddIntL( Usif::KSifInParam_AllowAppShutdown, ETrue );    
    48     iOptionsPckg = iOptions;      
    50     iSifOptions->AddIntL( Usif::KSifInParam_AllowAppBreakDependency, EFalse );     
       
    51     }
    49     }
    52 
    50 
    53 
    51 
    54 // -----------------------------------------------------------------------------
    52 // -----------------------------------------------------------------------------
    55 // Two-phased constructor.
    53 // Two-phased constructor.
    70 // -----------------------------------------------------------------------------
    68 // -----------------------------------------------------------------------------
    71 //
    69 //
    72 CSilentUninstaller::~CSilentUninstaller()
    70 CSilentUninstaller::~CSilentUninstaller()
    73     {
    71     {
    74     FLOG( _L("[CSilentUninstaller] ~CSilentUninstaller") );
    72     FLOG( _L("[CSilentUninstaller] ~CSilentUninstaller") );
    75 
    73     iLauncher.Close();
    76     delete iSifOptions;
       
    77     delete iSifResults;
       
    78     
       
    79     if ( iConnected )
       
    80         {
       
    81         iSWInstallerFW.Close();
       
    82         iRegistrySession.Close();
       
    83         }    
       
    84     }
    74     }
    85 
    75 
    86 
    76 
    87 // -----------------------------------------------------------------------------
    77 // -----------------------------------------------------------------------------
    88 // Perform uninstallation.
    78 // Perform uninstallation.
    89 // -----------------------------------------------------------------------------
    79 // -----------------------------------------------------------------------------
    90 //
    80 //
    91 void CSilentUninstaller::UninstallL( 
    81 void CSilentUninstaller::UninstallL( 
    92     TUid& aUid, 
    82     TUid& aUid, 
    93     TRequestStatus& aReqStatus, 
    83     TRequestStatus& aReqStatus, 
    94     TDesC& aMIME )
    84     TDesC8& aMIME )
    95     {
    85     {
    96     FLOG_1( _L("Daemon: UninstallL: UID = 0x%x"), aUid.iUid );
       
    97     
       
    98     if ( !iConnected )
    86     if ( !iConnected )
    99         {               
    87         {
   100         FLOG( _L("[CSilentUninstaller] Connect to sif installer server") );    
    88         FLOG( _L("[CSilentUninstaller] Connect to server") );
   101         User::LeaveIfError( iSWInstallerFW.Connect() );                         
    89         User::LeaveIfError( iLauncher.Connect() );
   102         FLOG( _L("[CSilentUninstaller] Connect to SisRegistery") );      
    90         iConnected = ETrue;            
   103         User::LeaveIfError( iRegistrySession.Connect() );                   
    91         }                
   104         iConnected = ETrue;   
       
   105         }
       
   106       
       
   107     // Set MIME type.
       
   108     iSifOptions->AddStringL( Usif::KSifInParam_MimeType, aMIME );  
       
   109            
       
   110     // Usif need the component ID, so we need to map the package UID to 
       
   111     // component ID. To do this simple we need SisRegistry.           
       
   112     Usif::TComponentId componentId;
       
   113     componentId = iRegistrySession.GetComponentIdForUidL( aUid );
       
   114     FLOG_1( _L("Daemon: UninstallL: ComponentId = %d"), componentId );
       
   115                                    
       
   116     // Launch the installation
    92     // Launch the installation
   117     FLOG( _L("[CSilentUninstaller] Launch uninstall") );                 
    93     FLOG( _L("[CSilentUninstaller] Launch uninstall") );
   118     iSWInstallerFW.Uninstall( componentId, 
    94     iLauncher.SilentUninstall( aReqStatus, aUid, iOptionsPckg, aMIME );
   119                               *iSifOptions,
       
   120                               *iSifResults, 
       
   121                               aReqStatus,
       
   122                               ETrue );
       
   123     }
    95     }
   124   
    96   
   125 
    97 
   126 // -----------------------------------------------------------------------------
    98 // -----------------------------------------------------------------------------
   127 // Cancel the current installation.
    99 // Cancel the current installation.
   128 // -----------------------------------------------------------------------------
   100 // -----------------------------------------------------------------------------
   129 // 
   101 // 
   130 void CSilentUninstaller::Cancel()
   102 void CSilentUninstaller::Cancel()
   131     {
   103     {
   132     FLOG( _L("[CSilentUninstaller] Cancel silet uninstall") );              
   104     FLOG( _L("[CSilentUninstaller] Cancel silet uninstall") );     
   133     iSWInstallerFW.CancelOperation(); 
   105     iLauncher.CancelAsyncRequest( SwiUI::ERequestSilentUninstall );   
   134     }
   106     }
   135 
   107 
   136 //  End of File  
   108 //  End of File