appinstaller/AppinstUi/sisxsifplugin/src/sisxsifpluginactiveimpl.cpp
changeset 52 92f864ef0288
parent 42 d17dc5398051
child 55 ac7f90a6ff4c
child 60 245df5276b97
equal deleted inserted replaced
42:d17dc5398051 52:92f864ef0288
    18 #include "sisxsifpluginactiveimpl.h"        // CSisxSifPluginActiveImpl
    18 #include "sisxsifpluginactiveimpl.h"        // CSisxSifPluginActiveImpl
    19 #include "sisxsifpluginuihandlerbase.h"     // CSisxSifPluginUiHandlerBase
    19 #include "sisxsifpluginuihandlerbase.h"     // CSisxSifPluginUiHandlerBase
    20 #include "sisxsifpluginuihandler.h"         // CSisxSifPluginUiHandler
    20 #include "sisxsifpluginuihandler.h"         // CSisxSifPluginUiHandler
    21 #include "sisxsifpluginuihandlersilent.h"   // CSisxSifPluginUiHandlerSilent
    21 #include "sisxsifpluginuihandlersilent.h"   // CSisxSifPluginUiHandlerSilent
    22 #include "sisxsifplugininstallparams.h"     // CSisxSifPluginInstallParams
    22 #include "sisxsifplugininstallparams.h"     // CSisxSifPluginInstallParams
       
    23 #include "sisxsifpluginerrorhandler.h"      // CSisxSifPluginErrorHandler
    23 #include "sisxsifcleanuputils.h"            // CleanupResetAndDestroyPushL
    24 #include "sisxsifcleanuputils.h"            // CleanupResetAndDestroyPushL
       
    25 #include "sisxsifpluginerrors.h"            // Error codes
    24 #include "sisxsifplugin.pan"                // Panic codes
    26 #include "sisxsifplugin.pan"                // Panic codes
    25 #include <usif/sif/sifcommon.h>             // Usif::CComponentInfo
    27 #include <usif/sif/sifcommon.h>             // Usif::CComponentInfo
    26 #include <usif/scr/scr.h>                   // RSoftwareComponentRegistry
    28 #include <usif/scr/scr.h>                   // RSoftwareComponentRegistry
    27 #include <usif/usiferror.h>                 // SIF error codes
       
    28 #include <swi/sisinstallerrors.h>           // SWI error codes
       
    29 #include <swi/asynclauncher.h>              // Swi::CAsyncLauncher
    29 #include <swi/asynclauncher.h>              // Swi::CAsyncLauncher
    30 #include <swi/sisregistrysession.h>         // RSisRegistrySession
    30 #include <swi/sisregistrysession.h>         // RSisRegistrySession
    31 #include "sisregistrywritablesession.h"     // RSisRegistryWritableSession
    31 #include "sisregistrywritablesession.h"     // RSisRegistryWritableSession
    32 #include <e32property.h>                    // RProperty
    32 #include <e32property.h>                    // RProperty
    33 #include <sacls.h>                          // KUidSwiLatestInstallation
    33 #include <sacls.h>                          // KUidSwiLatestInstallation
    83     iInputParams = NULL;    // not owned
    83     iInputParams = NULL;    // not owned
    84     iOutputParams = NULL;   // not owned
    84     iOutputParams = NULL;   // not owned
    85     delete iInstallParams;
    85     delete iInstallParams;
    86     delete iComponentInfo;
    86     delete iComponentInfo;
    87     delete iFileName;
    87     delete iFileName;
       
    88     delete iErrorHandler;
    88     FeatureManager::UnInitializeLib();
    89     FeatureManager::UnInitializeLib();
    89     iFs.Close();
    90     iFs.Close();
    90     }
    91     }
    91 
    92 
    92 // ---------------------------------------------------------------------------
    93 // ---------------------------------------------------------------------------
   343 
   344 
   344     // Uninstall is always silent. TrustedUI capability is required.
   345     // Uninstall is always silent. TrustedUI capability is required.
   345 	if( !aSecurityContext.HasCapability( ECapabilityTrustedUI ) )
   346 	if( !aSecurityContext.HasCapability( ECapabilityTrustedUI ) )
   346 		{
   347 		{
   347 		FLOG( _L( "CSisxSifPluginActiveImpl::Uninstall, missing ECapabilityTrustedUI") );
   348 		FLOG( _L( "CSisxSifPluginActiveImpl::Uninstall, missing ECapabilityTrustedUI") );
       
   349 		iErrorHandler->SetExtendedErrorCode( ETrustedUICapabilityRequired );
   348 		CompleteClientRequest( KErrPermissionDenied );
   350 		CompleteClientRequest( KErrPermissionDenied );
   349 		return;
   351 		return;
   350 		}
   352 		}
   351 
   353 
   352 	TRAPD( error, DoUninstallL( aComponentId, aInputParams, aOutputParams, aStatus ) );
   354 	TRAPD( error, DoUninstallL( aComponentId, aInputParams, aOutputParams, aStatus ) );
   380     TRAPD( error, DoActivateL( aComponentId, aStatus ) );
   382     TRAPD( error, DoActivateL( aComponentId, aStatus ) );
   381     if( error )
   383     if( error )
   382         {
   384         {
   383         FLOG_1( _L("CSisxSifPluginActiveImpl::Activate, DoActivateL ERROR %d"), error );
   385         FLOG_1( _L("CSisxSifPluginActiveImpl::Activate, DoActivateL ERROR %d"), error );
   384         CompleteClientRequest( error );
   386         CompleteClientRequest( error );
   385         return;
       
   386         }
   387         }
   387     }
   388     }
   388 
   389 
   389 // ---------------------------------------------------------------------------
   390 // ---------------------------------------------------------------------------
   390 // CSisxSifPluginActiveImpl::Deactivate()
   391 // CSisxSifPluginActiveImpl::Deactivate()
   409     TRAPD( error, DoDeactivateL( aComponentId, aStatus ) );
   410     TRAPD( error, DoDeactivateL( aComponentId, aStatus ) );
   410     if( error )
   411     if( error )
   411         {
   412         {
   412         FLOG_1( _L("CSisxSifPluginActiveImpl::Deactivate, DoDeactivateL ERROR %d"), error );
   413         FLOG_1( _L("CSisxSifPluginActiveImpl::Deactivate, DoDeactivateL ERROR %d"), error );
   413         CompleteClientRequest( error );
   414         CompleteClientRequest( error );
   414         return;
       
   415         }
   415         }
   416     }
   416     }
   417 
   417 
   418 // ---------------------------------------------------------------------------
   418 // ---------------------------------------------------------------------------
   419 // CSisxSifPluginActiveImpl::CSisxSifPluginActiveImpl()
   419 // CSisxSifPluginActiveImpl::CSisxSifPluginActiveImpl()
   434     FeatureManager::InitializeLibL();
   434     FeatureManager::InitializeLibL();
   435 
   435 
   436     iAsyncLauncher = Swi::CAsyncLauncher::NewL();
   436     iAsyncLauncher = Swi::CAsyncLauncher::NewL();
   437     iInstallPrefs = Swi::CInstallPrefs::NewL();
   437     iInstallPrefs = Swi::CInstallPrefs::NewL();
   438     iComponentInfo = CComponentInfo::NewL();
   438     iComponentInfo = CComponentInfo::NewL();
       
   439     iErrorHandler = CSisxSifPluginErrorHandler::NewL();
   439     }
   440     }
   440 
   441 
   441 // ---------------------------------------------------------------------------
   442 // ---------------------------------------------------------------------------
   442 // CSisxSifPluginActiveImpl::CommonRequestPreambleL()
   443 // CSisxSifPluginActiveImpl::CommonRequestPreambleL()
   443 // ---------------------------------------------------------------------------
   444 // ---------------------------------------------------------------------------
   504 		delete iUiHandler;
   505 		delete iUiHandler;
   505 		iUiHandler = NULL;
   506 		iUiHandler = NULL;
   506     	}
   507     	}
   507 	if( IsSilentMode() )
   508 	if( IsSilentMode() )
   508 		{
   509 		{
   509 		iUiHandler = CSisxSifPluginUiHandlerSilent::NewL( iFs );
   510 		iUiHandler = CSisxSifPluginUiHandlerSilent::NewL( iFs, *iErrorHandler );
   510 		}
   511 		}
   511 	else
   512 	else
   512 		{
   513 		{
   513 		iUiHandler = CSisxSifPluginUiHandler::NewL( iFs );
   514 		iUiHandler = CSisxSifPluginUiHandler::NewL( iFs, *iErrorHandler );
   514 		}
   515 		}
   515 	if( iInstallParams )
   516 	if( iInstallParams )
   516 		{
   517 		{
   517 		iUiHandler->SetInstallParamsL( *iInstallParams );
   518 		iUiHandler->SetInstallParamsL( *iInstallParams );
   518 		}
   519 		}
   586     if( IsSilentMode() )
   587     if( IsSilentMode() )
   587         {
   588         {
   588         if( !aSecurityContext.HasCapability( ECapabilityTrustedUI ) )
   589         if( !aSecurityContext.HasCapability( ECapabilityTrustedUI ) )
   589             {
   590             {
   590             FLOG( _L("CSisxSifPluginActiveImpl::Install, missing ECapabilityTrustedUI") );
   591             FLOG( _L("CSisxSifPluginActiveImpl::Install, missing ECapabilityTrustedUI") );
       
   592             iErrorHandler->SetExtendedErrorCode( ETrustedUICapabilityRequired );
   591             CompleteClientRequest( KErrPermissionDenied );
   593             CompleteClientRequest( KErrPermissionDenied );
   592             return;
   594             return;
   593             }
   595             }
   594         }
   596         }
   595 
   597 
   702 //
   704 //
   703 void CSisxSifPluginActiveImpl::DoHandleErrorL( TInt aError )
   705 void CSisxSifPluginActiveImpl::DoHandleErrorL( TInt aError )
   704     {
   706     {
   705     FLOG_1( _L("CSisxSifPluginActiveImpl::DoHandleErrorL(), aError=%d"), aError );
   707     FLOG_1( _L("CSisxSifPluginActiveImpl::DoHandleErrorL(), aError=%d"), aError );
   706 
   708 
   707     TErrorCategory category = ErrorCategory( aError );
   709     iErrorHandler->SetErrorCode( aError );
   708     if( iOutputParams )
   710     if( iOutputParams )
   709         {
   711         {
   710         iOutputParams->AddIntL( KSifOutParam_ErrCode, aError );
   712         iErrorHandler->FillOutputParamsL( *iOutputParams );
   711         iOutputParams->AddIntL( KSifOutParam_ExtendedErrCode, aError );
       
   712         iOutputParams->AddIntL( KSifOutParam_ErrCategory, category );
       
   713         // TODO: how to get error message and detailed error message?
       
   714         // iOutputParams->AddStringL( KSifOutParam_ErrMessage, TBD );
       
   715         // iOutputParams->AddStringL( KSifOutParam_ErrMessageDetails, TBD );
       
   716         }
   713         }
   717 
   714 
   718     if( aError != KErrNone && aError != KErrCancel )
   715     if( aError != KErrNone && aError != KErrCancel )
   719         {
   716         {
   720         // TODO: proper error messages
   717         iUiHandler->DisplayFailedL( *iErrorHandler );
   721         iUiHandler->DisplayFailedL( category, aError, KNullDesC, KNullDesC );
   718         }
   722         }
   719 
   723 
   720     iUiHandler->PublishCompletionL( *iErrorHandler );
   724     // TODO: proper error messages
       
   725     iUiHandler->PublishCompletionL( category, aError, KNullDesC, KNullDesC  );
       
   726     }
       
   727 
       
   728 // ---------------------------------------------------------------------------
       
   729 // CSisxSifPluginActiveImpl::ErrorCategory()
       
   730 // ---------------------------------------------------------------------------
       
   731 //
       
   732 TErrorCategory CSisxSifPluginActiveImpl::ErrorCategory( TInt aErrorCode )
       
   733     {
       
   734     switch( aErrorCode )
       
   735         {
       
   736         // System-wide error codes
       
   737         case KErrNone:
       
   738             return ENone;
       
   739         case KErrNotFound:
       
   740         case KErrGeneral:
       
   741             return EUnexpectedError;
       
   742         case KErrCancel:
       
   743             return EUserCancelled;
       
   744         case KErrNoMemory:
       
   745             return ELowMemory;
       
   746         case KErrNotSupported:
       
   747         case KErrArgument:
       
   748         case KErrTotalLossOfPrecision:
       
   749         case KErrBadHandle:
       
   750         case KErrOverflow:
       
   751         case KErrUnderflow:
       
   752         case KErrAlreadyExists:
       
   753         case KErrPathNotFound:
       
   754         case KErrDied:
       
   755             return EUnexpectedError;
       
   756         case KErrInUse:
       
   757             return EInstallerBusy;
       
   758         case KErrServerTerminated:
       
   759         case KErrServerBusy:
       
   760         case KErrCompletion:
       
   761         case KErrNotReady:
       
   762         case KErrUnknown:
       
   763             return EUnexpectedError;
       
   764         case KErrCorrupt:
       
   765             return ECorruptedPackage;
       
   766         case KErrAccessDenied:
       
   767             return ESecurityError;
       
   768         case KErrLocked:
       
   769         case KErrWrite:
       
   770         case KErrDisMounted:
       
   771         case KErrEof:
       
   772             return EUnexpectedError;
       
   773         case KErrDiskFull:
       
   774             return ELowDiskSpace;
       
   775         case KErrBadDriver:
       
   776         case KErrBadName:
       
   777         case KErrCommsLineFail:
       
   778         case KErrCommsFrame:
       
   779         case KErrCommsOverrun:
       
   780         case KErrCommsParity:
       
   781         case KErrTimedOut:
       
   782         case KErrCouldNotConnect:
       
   783         case KErrCouldNotDisconnect:
       
   784         case KErrDisconnected:
       
   785         case KErrBadLibraryEntryPoint:
       
   786         case KErrBadDescriptor:
       
   787         case KErrAbort:
       
   788         case KErrTooBig:
       
   789         case KErrDivideByZero:
       
   790         case KErrBadPower:
       
   791         case KErrDirFull:
       
   792         case KErrHardwareNotAvailable:
       
   793         case KErrSessionClosed:
       
   794             return EUnexpectedError;
       
   795         case KErrPermissionDenied:
       
   796             return ESecurityError;
       
   797         case KErrExtensionNotSupported:
       
   798         case KErrCommsBreak:
       
   799         case KErrNoSecureTime:
       
   800             return EUnexpectedError;
       
   801 
       
   802         // Native SW Installer error codes
       
   803         case KErrSISFieldIdMissing:
       
   804         case KErrSISFieldLengthMissing:
       
   805         case KErrSISFieldLengthInvalid:
       
   806         case KErrSISStringInvalidLength:
       
   807         case KErrSISSignedControllerSISControllerMissing:
       
   808         case KErrSISControllerSISInfoMissing:
       
   809         case KErrSISInfoSISUidMissing:
       
   810         case KErrSISInfoSISNamesMissing:
       
   811             return ECorruptedPackage;
       
   812         case KErrSISFieldBufferTooShort:
       
   813             return EUnexpectedError;
       
   814         case KErrSISStringArrayInvalidElement:
       
   815         case KErrSISInfoSISVendorNamesMissing:
       
   816         case KErrSISInfoSISVersionMissing:
       
   817         case KErrSISControllerSISSupportedLanguagesMissing:
       
   818         case KErrSISSupportedLanguagesInvalidElement:
       
   819         case KErrSISLanguageInvalidLength:
       
   820         case KErrSISContentsSISSignedControllerMissing:
       
   821         case KErrSISContentsSISDataMissing:
       
   822         case KErrSISDataSISFileDataUnitMissing:
       
   823         case KErrSISFileDataUnitTargetMissing:
       
   824         case KErrSISFileOptionsMissing:
       
   825         case KErrSISFileDataUnitDescriptorMissing:
       
   826         case KErrSISFileDataDescriptionMissing:
       
   827         case KErrSISContentsMissing:
       
   828         case KErrSISEmbeddedControllersMissing:
       
   829         case KErrSISEmbeddedDataUnitsMissing:
       
   830         case KErrSISControllerOptionsMissing:
       
   831         case KErrSISExpressionMissing:
       
   832         case KErrSISExpressionStringValueMissing:
       
   833         case KErrSISOptionsStringMissing:
       
   834         case KErrSISFileOptionsExpressionMissing:
       
   835         case KErrSISExpressionHeadValueMissing:
       
   836         case KErrSISEmbeddedSISOptionsMissing:
       
   837         case KErrSISInfoSISUpgradeRangeMissing:
       
   838         case KErrSISDependencyMissingUid:
       
   839         case KErrSISDependencyMissingVersion:
       
   840         case KErrSISDependencyMissingNames:
       
   841         case KErrSISPrerequisitesMissingDependency:
       
   842         case KErrSISControllerMissingPrerequisites:
       
   843         case KErrSISUpgradeRangeMissingVersion:
       
   844         case KErrSISUnexpectedFieldType:
       
   845         case KErrSISExpressionUnknownOperator:
       
   846         case KErrSISArrayReadError:
       
   847         case KErrSISArrayTypeMismatch:
       
   848         case KErrSISInvalidStringLength:
       
   849         case KErrSISCompressionNotSupported:
       
   850         case KErrSISTooDeeplyEmbedded:
       
   851             return ECorruptedPackage;
       
   852         case KErrSISInvalidTargetFile:
       
   853         case KErrSISWouldOverWrite:
       
   854             return ESecurityError;
       
   855         case KErrSISInfoMissingRemoveDirectories:
       
   856             return ECorruptedPackage;
       
   857         case KErrSISNotEnoughSpaceToInstall:
       
   858             return ELowDiskSpace;
       
   859         case KErrInstallerLeave:
       
   860         case KErrPolicyFileCorrupt:
       
   861             return EUnexpectedError;
       
   862         case KErrSignatureSchemeNotSupported:
       
   863         case KErrDigestNotSupported:
       
   864             return EApplicationNotCompatible;
       
   865         case KErrBadHash:
       
   866             return ECorruptedPackage;
       
   867         case KErrSecurityError:
       
   868             return ESecurityError;
       
   869         case KErrBadUsage:
       
   870         case KErrInvalidType:
       
   871         case KErrInvalidExpression:
       
   872         case KErrExpressionToComplex:
       
   873             return EUnexpectedError;
       
   874         case KErrMissingBasePackage:
       
   875         case KErrInvalidUpgrade:
       
   876             return EApplicationNotCompatible;
       
   877         case KErrInvalidEclipsing:
       
   878             return ESecurityError;
       
   879         case KErrWrongHeaderFormat:
       
   880             return EUnexpectedError;
       
   881         case KErrCapabilitiesMismatch:
       
   882             return ESecurityError;
       
   883         case KErrLegacySisFile:
       
   884         case KErrInvalidSoftwareTypeRegistrationFile:
       
   885             return EApplicationNotCompatible;
       
   886 
       
   887         // Other error codes
       
   888         default:
       
   889             __ASSERT_DEBUG( EFalse, Panic( ESisxSifUnknownErrorCode ) );
       
   890             return EUnexpectedError;
       
   891         }
       
   892     }
   721     }
   893 
   722 
   894 // ---------------------------------------------------------------------------
   723 // ---------------------------------------------------------------------------
   895 // CSisxSifPluginActiveImpl::SetFileL()
   724 // CSisxSifPluginActiveImpl::SetFileL()
   896 // ---------------------------------------------------------------------------
   725 // ---------------------------------------------------------------------------
  1000 // CSisxSifPluginActiveImpl::StartSilentInstallingL()
   829 // CSisxSifPluginActiveImpl::StartSilentInstallingL()
  1001 // ---------------------------------------------------------------------------
   830 // ---------------------------------------------------------------------------
  1002 //
   831 //
  1003 void CSisxSifPluginActiveImpl::StartSilentInstallingL()
   832 void CSisxSifPluginActiveImpl::StartSilentInstallingL()
  1004     {
   833     {
       
   834     // TODO: fix this, removed temporarily to allow installations
       
   835 #ifdef _NOT_DEFINED_
  1005     const CComponentInfo::CNode& rootNode( iComponentInfo->RootNodeL() );
   836     const CComponentInfo::CNode& rootNode( iComponentInfo->RootNodeL() );
  1006     TBool isAuthenticated = ( rootNode.Authenticity() == EAuthenticated );
   837     TBool isAuthenticated = ( rootNode.Authenticity() == EAuthenticated );
  1007 
   838 
  1008     // AllowUntrusted option is needed to install untrusted packages.
   839     // AllowUntrusted option is needed to install untrusted packages.
  1009     if( !isAuthenticated && !iInstallParams->AllowUntrusted() )
   840     if( !isAuthenticated && ( iInstallParams->AllowUntrusted() != EAllowed ) )
  1010         {
   841         {
  1011         FLOG( _L("Attempt to install unsigned package silently without AllowUntrusted option") );
   842         FLOG( _L("Attempt to install unsigned package silently without AllowUntrusted option") );
       
   843         iErrorHandler->SetExtendedErrorCode( ENeedsAllowUntrustedParameter );
  1012         CompleteClientRequest( KErrPermissionDenied );
   844         CompleteClientRequest( KErrPermissionDenied );
  1013         }
   845         }
  1014     // GrantCapabilities option is needed to install packages that require user capabilities
   846     // GrantCapabilities option is needed to install packages that require user capabilities
  1015     else if( RequiresUserCapabilityL( rootNode ) && !iInstallParams->GrantCapabilities() )
   847     else if( RequiresUserCapabilityL( rootNode ) &&
       
   848             ( iInstallParams->GrantCapabilities() != EAllowed  ) )
  1016         {
   849         {
  1017         FLOG( _L("Attempt to grant user capabilities silently without GrantCapabilities option") );
   850         FLOG( _L("Attempt to grant user capabilities silently without GrantCapabilities option") );
       
   851         iErrorHandler->SetExtendedErrorCode( ENeedsGrantCapabilitiesParameter );
  1018         CompleteClientRequest( KErrPermissionDenied );
   852         CompleteClientRequest( KErrPermissionDenied );
  1019         }
   853         }
  1020     // AllFiles capability is needed to install untrusted packages that contains exe/dll binaries
   854     // AllFiles capability is needed to install untrusted packages that contains exe/dll binaries
  1021     else if( !isAuthenticated && rootNode.HasExecutable() && !iHasAllFilesCapability )
   855     else if( !isAuthenticated && rootNode.HasExecutable() && !iHasAllFilesCapability )
  1022         {
   856         {
  1023         FLOG( _L("Attempt to install untrusted binaries silently without AllFiles capability") );
   857         FLOG( _L("Attempt to install untrusted binaries silently without AllFiles capability") );
       
   858         iErrorHandler->SetExtendedErrorCode( EAllFilesCapabilityRequired );
  1024         CompleteClientRequest( KErrPermissionDenied );
   859         CompleteClientRequest( KErrPermissionDenied );
  1025         }
   860         }
  1026     else
   861     else
       
   862 #endif
  1027         {
   863         {
  1028         StartInstallingL();
   864         StartInstallingL();
  1029         }
   865         }
  1030     }
   866     }
  1031 
   867 
  1042         TComponentId componentId = GetLastInstalledComponentIdL();
   878         TComponentId componentId = GetLastInstalledComponentIdL();
  1043         iOutputParams->AddIntL( KSifOutParam_ComponentId, componentId );
   879         iOutputParams->AddIntL( KSifOutParam_ComponentId, componentId );
  1044         }
   880         }
  1045 
   881 
  1046 	iUiHandler->DisplayCompleteL();
   882 	iUiHandler->DisplayCompleteL();
  1047     iUiHandler->PublishCompletionL( ENone, KErrNone, KNullDesC, KNullDesC );
   883     iUiHandler->PublishCompletionL( *iErrorHandler );
  1048     }
   884     }
  1049 
   885 
  1050 // ---------------------------------------------------------------------------
   886 // ---------------------------------------------------------------------------
  1051 // CSisxSifPluginActiveImpl::UpdateStartupListL()
   887 // CSisxSifPluginActiveImpl::UpdateStartupListL()
  1052 // ---------------------------------------------------------------------------
   888 // ---------------------------------------------------------------------------