appinstaller/AppinstUi/Daemon/Src/silentuninstaller.cpp
changeset 25 98b66e4fb0be
parent 0 ba25891c3a9e
child 29 26b6f0522fd8
--- a/appinstaller/AppinstUi/Daemon/Src/silentuninstaller.cpp	Fri Mar 19 09:33:35 2010 +0200
+++ b/appinstaller/AppinstUi/Daemon/Src/silentuninstaller.cpp	Fri Apr 16 15:05:20 2010 +0300
@@ -17,8 +17,9 @@
 
 // INCLUDE FILES
 #include "silentuninstaller.h"
+#include "SWInstDefs.h"
 #include "SWInstDebug.h"
-#include "SWInstDefs.h"
+
 
 using namespace Swi;
 
@@ -40,12 +41,16 @@
 //
 void CSilentUninstaller::ConstructL()
     {
-    // Silently kill the app. if needed.
-    FLOG(_L("[CSilentUninstaller] iKillApp = SwiUI::EPolicyAllowed;"));
-    iOptions.iKillApp = SwiUI::EPolicyAllowed; 
-    FLOG(_L("[CSilentUninstaller] iBreakDependency = SwiUI::EPolicyNotAllowed"));
-    iOptions.iBreakDependency = SwiUI::EPolicyNotAllowed;         
-    iOptionsPckg = iOptions;      
+    iConnected = EFalse; 
+    
+    iSifOptions = Usif::COpaqueNamedParams::NewL();
+    iSifResults = Usif::COpaqueNamedParams::NewL();
+    
+    // Set parameters for silent uninstall.
+    // iSifOptions->AddIntL( Usif::KSifInParam_AllowAppShutdown, ETrue );    
+    // iSifOptions->AddIntL( Usif::KSifInParam_AllowAppBreakDependency, EFalse );   
+// TODO: Should "silent install" be defined also for uninstall
+    //iSifOptions->AddIntL( Usif::KSifInParam_InstallSilently, ETrue );     
     }
 
 
@@ -70,7 +75,15 @@
 CSilentUninstaller::~CSilentUninstaller()
     {
     FLOG( _L("[CSilentUninstaller] ~CSilentUninstaller") );
-    iLauncher.Close();
+
+    delete iSifOptions;
+    delete iSifResults;
+    
+    if ( iConnected )
+        {
+        iSWInstallerFW.Close();
+        iRegistrySession.Close();
+        }    
     }
 
 
@@ -83,15 +96,36 @@
     TRequestStatus& aReqStatus, 
     TDesC8& aMIME )
     {
+    FLOG_1( _L("Daemon: UninstallL: UID = 0x%x"), aUid.iUid );
+    
     if ( !iConnected )
-        {
-        FLOG( _L("[CSilentUninstaller] Connect to server") );
-        User::LeaveIfError( iLauncher.Connect() );
-        iConnected = ETrue;            
-        }                
+        {               
+        FLOG( _L("[CSilentUninstaller] Connect to sif installer server") );    
+        User::LeaveIfError( iSWInstallerFW.Connect() );                     
+    
+        FLOG( _L("[CSilentUninstaller] Connect to SisRegistery") );      
+        User::LeaveIfError( iRegistrySession.Connect() );           
+        
+        iConnected = ETrue;   
+        }
+    
+// TODO: How is mime type set ?    
+    // Set MIME type.
+    //iSifOptions->AddStringL( Usif::KSifInParam_MimeType, aMIME );  
+           
+    // Usif need the component ID, so we need to map the package UID to 
+    // component ID. To do this simple we need SisRegistry.           
+    Usif::TComponentId componentId;
+    componentId = iRegistrySession.GetComponentIdForUidL( aUid );
+    FLOG_1( _L("Daemon: UninstallL: ComponentId = %d"), componentId );
+                                   
     // Launch the installation
-    FLOG( _L("[CSilentUninstaller] Launch uninstall") );
-    iLauncher.SilentUninstall( aReqStatus, aUid, iOptionsPckg, aMIME );
+    FLOG( _L("[CSilentUninstaller] Launch uninstall") );                 
+    iSWInstallerFW.Uninstall( componentId, 
+                              *iSifOptions,
+                              *iSifResults, 
+                              aReqStatus,
+                              ETrue );
     }
   
 
@@ -101,8 +135,8 @@
 // 
 void CSilentUninstaller::Cancel()
     {
-    FLOG( _L("[CSilentUninstaller] Cancel silet uninstall") );     
-    iLauncher.CancelAsyncRequest( SwiUI::ERequestSilentUninstall );   
+    FLOG( _L("[CSilentUninstaller] Cancel silet uninstall") );              
+    iSWInstallerFW.CancelOperation(); 
     }
 
 //  End of File