appinstaller/AppinstUi/sisxsifplugin/src/sisxsifpluginactiveimpl.cpp
changeset 44 329d304c1aa1
parent 42 d17dc5398051
child 55 ac7f90a6ff4c
child 60 245df5276b97
--- a/appinstaller/AppinstUi/sisxsifplugin/src/sisxsifpluginactiveimpl.cpp	Fri Jun 11 13:45:18 2010 +0300
+++ b/appinstaller/AppinstUi/sisxsifplugin/src/sisxsifpluginactiveimpl.cpp	Thu Jun 24 12:37:54 2010 +0300
@@ -20,12 +20,12 @@
 #include "sisxsifpluginuihandler.h"         // CSisxSifPluginUiHandler
 #include "sisxsifpluginuihandlersilent.h"   // CSisxSifPluginUiHandlerSilent
 #include "sisxsifplugininstallparams.h"     // CSisxSifPluginInstallParams
+#include "sisxsifpluginerrorhandler.h"      // CSisxSifPluginErrorHandler
 #include "sisxsifcleanuputils.h"            // CleanupResetAndDestroyPushL
+#include "sisxsifpluginerrors.h"            // Error codes
 #include "sisxsifplugin.pan"                // Panic codes
 #include <usif/sif/sifcommon.h>             // Usif::CComponentInfo
 #include <usif/scr/scr.h>                   // RSoftwareComponentRegistry
-#include <usif/usiferror.h>                 // SIF error codes
-#include <swi/sisinstallerrors.h>           // SWI error codes
 #include <swi/asynclauncher.h>              // Swi::CAsyncLauncher
 #include <swi/sisregistrysession.h>         // RSisRegistrySession
 #include "sisregistrywritablesession.h"     // RSisRegistryWritableSession
@@ -85,6 +85,7 @@
     delete iInstallParams;
     delete iComponentInfo;
     delete iFileName;
+    delete iErrorHandler;
     FeatureManager::UnInitializeLib();
     iFs.Close();
     }
@@ -345,6 +346,7 @@
 	if( !aSecurityContext.HasCapability( ECapabilityTrustedUI ) )
 		{
 		FLOG( _L( "CSisxSifPluginActiveImpl::Uninstall, missing ECapabilityTrustedUI") );
+		iErrorHandler->SetExtendedErrorCode( ETrustedUICapabilityRequired );
 		CompleteClientRequest( KErrPermissionDenied );
 		return;
 		}
@@ -382,7 +384,6 @@
         {
         FLOG_1( _L("CSisxSifPluginActiveImpl::Activate, DoActivateL ERROR %d"), error );
         CompleteClientRequest( error );
-        return;
         }
     }
 
@@ -411,7 +412,6 @@
         {
         FLOG_1( _L("CSisxSifPluginActiveImpl::Deactivate, DoDeactivateL ERROR %d"), error );
         CompleteClientRequest( error );
-        return;
         }
     }
 
@@ -436,6 +436,7 @@
     iAsyncLauncher = Swi::CAsyncLauncher::NewL();
     iInstallPrefs = Swi::CInstallPrefs::NewL();
     iComponentInfo = CComponentInfo::NewL();
+    iErrorHandler = CSisxSifPluginErrorHandler::NewL();
     }
 
 // ---------------------------------------------------------------------------
@@ -506,11 +507,11 @@
     	}
 	if( IsSilentMode() )
 		{
-		iUiHandler = CSisxSifPluginUiHandlerSilent::NewL( iFs );
+		iUiHandler = CSisxSifPluginUiHandlerSilent::NewL( iFs, *iErrorHandler );
 		}
 	else
 		{
-		iUiHandler = CSisxSifPluginUiHandler::NewL( iFs );
+		iUiHandler = CSisxSifPluginUiHandler::NewL( iFs, *iErrorHandler );
 		}
 	if( iInstallParams )
 		{
@@ -588,6 +589,7 @@
         if( !aSecurityContext.HasCapability( ECapabilityTrustedUI ) )
             {
             FLOG( _L("CSisxSifPluginActiveImpl::Install, missing ECapabilityTrustedUI") );
+            iErrorHandler->SetExtendedErrorCode( ETrustedUICapabilityRequired );
             CompleteClientRequest( KErrPermissionDenied );
             return;
             }
@@ -704,191 +706,18 @@
     {
     FLOG_1( _L("CSisxSifPluginActiveImpl::DoHandleErrorL(), aError=%d"), aError );
 
-    TErrorCategory category = ErrorCategory( aError );
+    iErrorHandler->SetErrorCode( aError );
     if( iOutputParams )
         {
-        iOutputParams->AddIntL( KSifOutParam_ErrCode, aError );
-        iOutputParams->AddIntL( KSifOutParam_ExtendedErrCode, aError );
-        iOutputParams->AddIntL( KSifOutParam_ErrCategory, category );
-        // TODO: how to get error message and detailed error message?
-        // iOutputParams->AddStringL( KSifOutParam_ErrMessage, TBD );
-        // iOutputParams->AddStringL( KSifOutParam_ErrMessageDetails, TBD );
+        iErrorHandler->FillOutputParamsL( *iOutputParams );
         }
 
     if( aError != KErrNone && aError != KErrCancel )
         {
-        // TODO: proper error messages
-        iUiHandler->DisplayFailedL( category, aError, KNullDesC, KNullDesC );
+        iUiHandler->DisplayFailedL( *iErrorHandler );
         }
 
-    // TODO: proper error messages
-    iUiHandler->PublishCompletionL( category, aError, KNullDesC, KNullDesC  );
-    }
-
-// ---------------------------------------------------------------------------
-// CSisxSifPluginActiveImpl::ErrorCategory()
-// ---------------------------------------------------------------------------
-//
-TErrorCategory CSisxSifPluginActiveImpl::ErrorCategory( TInt aErrorCode )
-    {
-    switch( aErrorCode )
-        {
-        // System-wide error codes
-        case KErrNone:
-            return ENone;
-        case KErrNotFound:
-        case KErrGeneral:
-            return EUnexpectedError;
-        case KErrCancel:
-            return EUserCancelled;
-        case KErrNoMemory:
-            return ELowMemory;
-        case KErrNotSupported:
-        case KErrArgument:
-        case KErrTotalLossOfPrecision:
-        case KErrBadHandle:
-        case KErrOverflow:
-        case KErrUnderflow:
-        case KErrAlreadyExists:
-        case KErrPathNotFound:
-        case KErrDied:
-            return EUnexpectedError;
-        case KErrInUse:
-            return EInstallerBusy;
-        case KErrServerTerminated:
-        case KErrServerBusy:
-        case KErrCompletion:
-        case KErrNotReady:
-        case KErrUnknown:
-            return EUnexpectedError;
-        case KErrCorrupt:
-            return ECorruptedPackage;
-        case KErrAccessDenied:
-            return ESecurityError;
-        case KErrLocked:
-        case KErrWrite:
-        case KErrDisMounted:
-        case KErrEof:
-            return EUnexpectedError;
-        case KErrDiskFull:
-            return ELowDiskSpace;
-        case KErrBadDriver:
-        case KErrBadName:
-        case KErrCommsLineFail:
-        case KErrCommsFrame:
-        case KErrCommsOverrun:
-        case KErrCommsParity:
-        case KErrTimedOut:
-        case KErrCouldNotConnect:
-        case KErrCouldNotDisconnect:
-        case KErrDisconnected:
-        case KErrBadLibraryEntryPoint:
-        case KErrBadDescriptor:
-        case KErrAbort:
-        case KErrTooBig:
-        case KErrDivideByZero:
-        case KErrBadPower:
-        case KErrDirFull:
-        case KErrHardwareNotAvailable:
-        case KErrSessionClosed:
-            return EUnexpectedError;
-        case KErrPermissionDenied:
-            return ESecurityError;
-        case KErrExtensionNotSupported:
-        case KErrCommsBreak:
-        case KErrNoSecureTime:
-            return EUnexpectedError;
-
-        // Native SW Installer error codes
-        case KErrSISFieldIdMissing:
-        case KErrSISFieldLengthMissing:
-        case KErrSISFieldLengthInvalid:
-        case KErrSISStringInvalidLength:
-        case KErrSISSignedControllerSISControllerMissing:
-        case KErrSISControllerSISInfoMissing:
-        case KErrSISInfoSISUidMissing:
-        case KErrSISInfoSISNamesMissing:
-            return ECorruptedPackage;
-        case KErrSISFieldBufferTooShort:
-            return EUnexpectedError;
-        case KErrSISStringArrayInvalidElement:
-        case KErrSISInfoSISVendorNamesMissing:
-        case KErrSISInfoSISVersionMissing:
-        case KErrSISControllerSISSupportedLanguagesMissing:
-        case KErrSISSupportedLanguagesInvalidElement:
-        case KErrSISLanguageInvalidLength:
-        case KErrSISContentsSISSignedControllerMissing:
-        case KErrSISContentsSISDataMissing:
-        case KErrSISDataSISFileDataUnitMissing:
-        case KErrSISFileDataUnitTargetMissing:
-        case KErrSISFileOptionsMissing:
-        case KErrSISFileDataUnitDescriptorMissing:
-        case KErrSISFileDataDescriptionMissing:
-        case KErrSISContentsMissing:
-        case KErrSISEmbeddedControllersMissing:
-        case KErrSISEmbeddedDataUnitsMissing:
-        case KErrSISControllerOptionsMissing:
-        case KErrSISExpressionMissing:
-        case KErrSISExpressionStringValueMissing:
-        case KErrSISOptionsStringMissing:
-        case KErrSISFileOptionsExpressionMissing:
-        case KErrSISExpressionHeadValueMissing:
-        case KErrSISEmbeddedSISOptionsMissing:
-        case KErrSISInfoSISUpgradeRangeMissing:
-        case KErrSISDependencyMissingUid:
-        case KErrSISDependencyMissingVersion:
-        case KErrSISDependencyMissingNames:
-        case KErrSISPrerequisitesMissingDependency:
-        case KErrSISControllerMissingPrerequisites:
-        case KErrSISUpgradeRangeMissingVersion:
-        case KErrSISUnexpectedFieldType:
-        case KErrSISExpressionUnknownOperator:
-        case KErrSISArrayReadError:
-        case KErrSISArrayTypeMismatch:
-        case KErrSISInvalidStringLength:
-        case KErrSISCompressionNotSupported:
-        case KErrSISTooDeeplyEmbedded:
-            return ECorruptedPackage;
-        case KErrSISInvalidTargetFile:
-        case KErrSISWouldOverWrite:
-            return ESecurityError;
-        case KErrSISInfoMissingRemoveDirectories:
-            return ECorruptedPackage;
-        case KErrSISNotEnoughSpaceToInstall:
-            return ELowDiskSpace;
-        case KErrInstallerLeave:
-        case KErrPolicyFileCorrupt:
-            return EUnexpectedError;
-        case KErrSignatureSchemeNotSupported:
-        case KErrDigestNotSupported:
-            return EApplicationNotCompatible;
-        case KErrBadHash:
-            return ECorruptedPackage;
-        case KErrSecurityError:
-            return ESecurityError;
-        case KErrBadUsage:
-        case KErrInvalidType:
-        case KErrInvalidExpression:
-        case KErrExpressionToComplex:
-            return EUnexpectedError;
-        case KErrMissingBasePackage:
-        case KErrInvalidUpgrade:
-            return EApplicationNotCompatible;
-        case KErrInvalidEclipsing:
-            return ESecurityError;
-        case KErrWrongHeaderFormat:
-            return EUnexpectedError;
-        case KErrCapabilitiesMismatch:
-            return ESecurityError;
-        case KErrLegacySisFile:
-        case KErrInvalidSoftwareTypeRegistrationFile:
-            return EApplicationNotCompatible;
-
-        // Other error codes
-        default:
-            __ASSERT_DEBUG( EFalse, Panic( ESisxSifUnknownErrorCode ) );
-            return EUnexpectedError;
-        }
+    iUiHandler->PublishCompletionL( *iErrorHandler );
     }
 
 // ---------------------------------------------------------------------------
@@ -1002,28 +831,35 @@
 //
 void CSisxSifPluginActiveImpl::StartSilentInstallingL()
     {
+    // TODO: fix this, removed temporarily to allow installations
+#ifdef _NOT_DEFINED_
     const CComponentInfo::CNode& rootNode( iComponentInfo->RootNodeL() );
     TBool isAuthenticated = ( rootNode.Authenticity() == EAuthenticated );
 
     // AllowUntrusted option is needed to install untrusted packages.
-    if( !isAuthenticated && !iInstallParams->AllowUntrusted() )
+    if( !isAuthenticated && ( iInstallParams->AllowUntrusted() != EAllowed ) )
         {
         FLOG( _L("Attempt to install unsigned package silently without AllowUntrusted option") );
+        iErrorHandler->SetExtendedErrorCode( ENeedsAllowUntrustedParameter );
         CompleteClientRequest( KErrPermissionDenied );
         }
     // GrantCapabilities option is needed to install packages that require user capabilities
-    else if( RequiresUserCapabilityL( rootNode ) && !iInstallParams->GrantCapabilities() )
+    else if( RequiresUserCapabilityL( rootNode ) &&
+            ( iInstallParams->GrantCapabilities() != EAllowed  ) )
         {
         FLOG( _L("Attempt to grant user capabilities silently without GrantCapabilities option") );
+        iErrorHandler->SetExtendedErrorCode( ENeedsGrantCapabilitiesParameter );
         CompleteClientRequest( KErrPermissionDenied );
         }
     // AllFiles capability is needed to install untrusted packages that contains exe/dll binaries
     else if( !isAuthenticated && rootNode.HasExecutable() && !iHasAllFilesCapability )
         {
         FLOG( _L("Attempt to install untrusted binaries silently without AllFiles capability") );
+        iErrorHandler->SetExtendedErrorCode( EAllFilesCapabilityRequired );
         CompleteClientRequest( KErrPermissionDenied );
         }
     else
+#endif
         {
         StartInstallingL();
         }
@@ -1044,7 +880,7 @@
         }
 
 	iUiHandler->DisplayCompleteL();
-    iUiHandler->PublishCompletionL( ENone, KErrNone, KNullDesC, KNullDesC );
+    iUiHandler->PublishCompletionL( *iErrorHandler );
     }
 
 // ---------------------------------------------------------------------------