installationservices/swinstallationfw/examples/refnativeplugin/source/refnativeplugin.cpp
branchRCL_3
changeset 25 7333d7932ef7
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "refnativeplugin.h"
       
    20 #include "usiflog.h"
       
    21 #include <usif/sif/sif.h>
       
    22 #include <usif/sif/sifcommon.h>
       
    23 #include <usif/usiferror.h>
       
    24 #include <usif/sif/sifplugin.h>
       
    25 #include <usif/scr/screntries.h>
       
    26 #include <usif/scr/scr.h>
       
    27 #include <swi/msisuihandlers.h>
       
    28 #include <swi/asynclauncher.h>
       
    29 #include <swi/sisinstallerrors.h>
       
    30 #include <e32property.h>
       
    31 #include <sacls.h>
       
    32 #include "sisregistrywritablesession.h"
       
    33 #include "sisregistrysession.h"
       
    34 
       
    35 using namespace Usif;
       
    36 
       
    37 static const TInt KRefNativePluginImpId = 0x10285BC4;
       
    38 
       
    39 static const TImplementationProxy ImplementationTable[] = 
       
    40 	{
       
    41 	IMPLEMENTATION_PROXY_ENTRY(KRefNativePluginImpId, CRefNativePlugin::NewL)
       
    42 	};
       
    43 
       
    44 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
    45 	{
       
    46 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
    47 	return ImplementationTable;
       
    48 	}
       
    49 
       
    50 CRefNativePlugin* CRefNativePlugin::NewL()
       
    51 	{
       
    52 	DEBUG_PRINTF(_L8("Constructing CRefNativePlugin"));
       
    53 	CRefNativePlugin *self = new (ELeave) CRefNativePlugin();
       
    54 	CleanupStack::PushL(self);
       
    55 	self->ConstructL();
       
    56 	CleanupStack::Pop(self);
       
    57 	return self;
       
    58 	}
       
    59 
       
    60 void CRefNativePlugin::ConstructL()
       
    61 	{
       
    62 	iImpl = CRefNativePluginActiveImpl::NewL();
       
    63 	}
       
    64 
       
    65 CRefNativePlugin::~CRefNativePlugin()
       
    66 	{
       
    67 	delete iImpl;
       
    68 	}
       
    69 
       
    70 void CRefNativePlugin::CancelOperation()
       
    71 	{
       
    72 	DEBUG_PRINTF(_L8("Reference native plugin - Cancel"));
       
    73 	iImpl->Cancel();
       
    74 	}
       
    75 
       
    76 void CRefNativePlugin::GetComponentInfo(const TDesC& aFileName, const TSecurityContext& /*aSecurityContext*/,
       
    77 										 CComponentInfo& aComponentInfo, TRequestStatus& aStatus)
       
    78 	{
       
    79 	iImpl->GetComponentInfo(aFileName, aComponentInfo, aStatus);
       
    80 	}
       
    81 
       
    82 void CRefNativePlugin::GetComponentInfo(RFile& aFileHandle, const TSecurityContext& /*aSecurityContext*/,
       
    83 						 				CComponentInfo& aComponentInfo, TRequestStatus& aStatus)
       
    84 	{
       
    85 	iImpl->GetComponentInfo(aFileHandle, aComponentInfo, aStatus);
       
    86 	}
       
    87 
       
    88 void CRefNativePlugin::Install(const TDesC& aFileName, const TSecurityContext& aSecurityContext,
       
    89 								const COpaqueNamedParams& aInputParams, COpaqueNamedParams& aOutputParams,
       
    90 								TRequestStatus& aStatus)
       
    91 	{
       
    92 	iImpl->Install(aFileName, aSecurityContext, aInputParams, aOutputParams, aStatus);
       
    93 	}
       
    94 
       
    95 void CRefNativePlugin::Install(RFile& aFileHandle, const TSecurityContext& aSecurityContext,
       
    96 								const COpaqueNamedParams& aInputParams, COpaqueNamedParams& aOutputParams,
       
    97 								TRequestStatus& aStatus)
       
    98 	{
       
    99 	iImpl->Install(aFileHandle, aSecurityContext, aInputParams, aOutputParams, aStatus);
       
   100 	}
       
   101 
       
   102 void CRefNativePlugin::Uninstall(TComponentId aComponentId, const TSecurityContext& aSecurityContext,
       
   103 								const COpaqueNamedParams& aInputParams, COpaqueNamedParams& aOutputParams, TRequestStatus& aStatus)
       
   104 	{
       
   105 	iImpl->Uninstall(aComponentId, aSecurityContext, aInputParams, aOutputParams, aStatus);
       
   106 	}
       
   107 
       
   108 void CRefNativePlugin::Activate(TComponentId aComponentId, const TSecurityContext& aSecurityContext, TRequestStatus& aStatus)
       
   109 
       
   110 	{
       
   111 	DEBUG_PRINTF(_L8("Reference native plugin - Activate"));
       
   112 	iImpl->Activate(aComponentId, aSecurityContext, aStatus);
       
   113 	}
       
   114 
       
   115 void CRefNativePlugin::Deactivate(TComponentId aComponentId, const TSecurityContext& aSecurityContext, TRequestStatus& aStatus)
       
   116 	{
       
   117 	DEBUG_PRINTF(_L8("Reference native plugin - Deactivate"));
       
   118 	iImpl->Deactivate(aComponentId, aSecurityContext, aStatus);
       
   119 	}
       
   120 
       
   121 //------------------CRefNativePluginActiveImpl---------------------
       
   122 
       
   123 CRefNativePluginActiveImpl* CRefNativePluginActiveImpl::NewL()
       
   124 	{
       
   125 	DEBUG_PRINTF(_L8("Reference native plugin - Constructing CRefNativePluginActiveImpl"));
       
   126 	CRefNativePluginActiveImpl *self = new (ELeave) CRefNativePluginActiveImpl();
       
   127 	CleanupStack::PushL(self);
       
   128 	self->ConstructL();
       
   129 	CleanupStack::Pop(1, self);
       
   130 	return self;
       
   131 	}
       
   132 
       
   133 void CRefNativePluginActiveImpl::ConstructL()
       
   134 	{
       
   135 	iInstallPrefs = Swi::CInstallPrefs::NewL();
       
   136 	iAsyncLauncher = Swi::CAsyncLauncher::NewL();
       
   137 	iComponentInfo = CComponentInfo::NewL();
       
   138 	CActiveScheduler::Add(this);
       
   139 	}
       
   140 
       
   141 CRefNativePluginActiveImpl::~CRefNativePluginActiveImpl()
       
   142 	{
       
   143 	delete iAsyncLauncher;
       
   144 	delete iInstallPrefs;
       
   145 	delete iComponentInfo;
       
   146 	}
       
   147 
       
   148 const TInt KSystemWideErrorsBoundary = -100;
       
   149 
       
   150 TInt ConvertToSifErrorCode(TInt aSwiErrorCode)
       
   151 	{
       
   152 	if (aSwiErrorCode > KSystemWideErrorsBoundary)
       
   153 		return aSwiErrorCode; 
       
   154 	switch (aSwiErrorCode)
       
   155 		{
       
   156 		case KErrSISFieldIdMissing:
       
   157 		case KErrSISFieldLengthMissing:
       
   158 		case KErrSISFieldLengthInvalid:
       
   159 		case KErrSISStringInvalidLength:
       
   160 		case KErrSISSignedControllerSISControllerMissing:
       
   161 		case KErrSISControllerSISInfoMissing:
       
   162 		case KErrSISInfoSISUidMissing:
       
   163 		case KErrSISInfoSISNamesMissing:
       
   164 		case KErrSISFieldBufferTooShort:
       
   165 		case KErrSISStringArrayInvalidElement:
       
   166 		case KErrSISInfoSISVendorNamesMissing:
       
   167 		case KErrSISInfoSISVersionMissing:
       
   168 		case KErrSISControllerSISSupportedLanguagesMissing:
       
   169 		case KErrSISSupportedLanguagesInvalidElement:
       
   170 		case KErrSISLanguageInvalidLength:
       
   171 		case KErrSISContentsSISSignedControllerMissing:
       
   172 		case KErrSISContentsSISDataMissing:
       
   173 		case KErrSISDataSISFileDataUnitMissing:
       
   174 		case KErrSISFileDataUnitTargetMissing:
       
   175 		case KErrSISFileOptionsMissing:
       
   176 		case KErrSISFileDataUnitDescriptorMissing:
       
   177 		case KErrSISFileDataDescriptionMissing:
       
   178 		case KErrSISContentsMissing:
       
   179 		case KErrSISEmbeddedControllersMissing:
       
   180 		case KErrSISEmbeddedDataUnitsMissing:
       
   181 		case KErrSISControllerOptionsMissing:
       
   182 		case KErrSISExpressionMissing:
       
   183 		case KErrSISExpressionStringValueMissing:
       
   184 		case KErrSISOptionsStringMissing:
       
   185 		case KErrSISFileOptionsExpressionMissing:
       
   186 		case KErrSISExpressionHeadValueMissing:
       
   187 		case KErrSISEmbeddedSISOptionsMissing:
       
   188 		case KErrSISInfoSISUpgradeRangeMissing:
       
   189 		case KErrSISDependencyMissingUid:
       
   190 		case KErrSISDependencyMissingVersion:
       
   191 		case KErrSISDependencyMissingNames:
       
   192 		case KErrSISControllerMissingPrerequisites:
       
   193 		case KErrSISUpgradeRangeMissingVersion:
       
   194 		case KErrSISUnexpectedFieldType:
       
   195 		case KErrSISExpressionUnknownOperator:
       
   196 		case KErrSISArrayReadError:
       
   197 		case KErrSISArrayTypeMismatch:
       
   198 		case KErrSISInvalidStringLength:
       
   199 		case KErrSISCompressionNotSupported:
       
   200 		case KErrSISTooDeeplyEmbedded:
       
   201 		case KErrWrongHeaderFormat:
       
   202 		case KErrExpressionToComplex:
       
   203 		case KErrInvalidExpression:
       
   204 		case KErrInvalidType:
       
   205 
       
   206 			return KErrSifCorruptedPackage;
       
   207 
       
   208 		case KErrBadUsage:
       
   209 		case KErrInstallerLeave:
       
   210 
       
   211 			return KErrSifUnknown;
       
   212 
       
   213 		case KErrSISPrerequisitesMissingDependency:
       
   214 
       
   215 			return KErrSifMissingDependencies;
       
   216 
       
   217 		case KErrMissingBasePackage:
       
   218 
       
   219 			return KErrSifMissingBasePackage;
       
   220 
       
   221 		case KErrCapabilitiesMismatch:
       
   222 		case KErrInvalidEclipsing:
       
   223 		case KErrSecurityError:
       
   224 		case KErrBadHash:
       
   225 		case KErrDigestNotSupported:
       
   226 		case KErrSignatureSchemeNotSupported:
       
   227 		case KErrSISWouldOverWrite:
       
   228 		case KErrSISInvalidTargetFile:
       
   229 
       
   230 			return KErrPermissionDenied;
       
   231 
       
   232 		case KErrPolicyFileCorrupt:
       
   233 
       
   234 			return KErrSifBadInstallerConfiguration;
       
   235 
       
   236 		case KErrInvalidUpgrade:
       
   237 		case KErrLegacySisFile:
       
   238 
       
   239 			return KErrSifPackageCannotBeInstalledOnThisDevice;
       
   240 
       
   241 		case KErrSISNotEnoughSpaceToInstall:
       
   242 
       
   243 			return KErrSifNotEnoughSpace;
       
   244 
       
   245 		default:
       
   246 			return KErrSifUnknown;
       
   247 		}
       
   248 	}
       
   249 
       
   250 TBool CRefNativePluginActiveImpl::NeedUserCapabilityL()
       
   251 	{
       
   252 	// Silent install is not allowed when the package requires additional capabilities
       
   253 	// than what it is signed for (Pakage may request for some capability that is not 
       
   254 	// granted by the certificate used to sign it).
       
   255 	for(TInt cap=0; cap<ECapability_Limit; ++cap)
       
   256 		{
       
   257 		if (iComponentInfo->RootNodeL().UserGrantableCaps().HasCapability(TCapability(cap)))
       
   258 			{
       
   259 			DEBUG_PRINTF2(_L("Package requires additional capability - %d"), cap);
       
   260 			return ETrue;
       
   261 			}
       
   262 		}
       
   263 			
       
   264 	return EFalse;
       
   265 	}
       
   266 
       
   267 void CRefNativePluginActiveImpl::RunL()
       
   268 	{
       
   269 	if (iSilentInstall)
       
   270 		{
       
   271 		DEBUG_PRINTF(_L("Silent install  - CRefNativePluginActiveImpl::RunL"));
       
   272 		ProcessSilentInstallL();
       
   273 		}
       
   274 	else
       
   275 		{
       
   276 		TInt res = iStatus.Int();
       
   277 		DEBUG_PRINTF2(_L8("Reference native plugin - Operation finished with result %d"), res);
       
   278 	
       
   279 		// Output options
       
   280 		if (iOutputParams != NULL)
       
   281 			{
       
   282 			iOutputParams->AddIntL(KSifOutParam_ExtendedErrCode, res);
       
   283 			
       
   284 			if (iInstallRequest && res == KErrNone)
       
   285 				{
       
   286 				TComponentId resultComponentId = 0;
       
   287 				TRAPD(getLastIdErr, resultComponentId = GetLastInstalledComponentIdL());
       
   288 				if (getLastIdErr == KErrNone)
       
   289 					iOutputParams->AddIntL(KSifOutParam_ComponentId, resultComponentId);
       
   290 				}
       
   291 			}
       
   292 	
       
   293 		User::RequestComplete(iClientStatus, ConvertToSifErrorCode(res));
       
   294 		iClientStatus = NULL;
       
   295 		}
       
   296 	}
       
   297 
       
   298 void CRefNativePluginActiveImpl::ProcessSilentInstallL()
       
   299 	{
       
   300 	// We need to do this only once per installation request
       
   301 	iSilentInstall = EFalse;
       
   302 	iInstallRequest = ETrue;
       
   303 	
       
   304 	TBool isNotAuthenticated = (ENotAuthenticated == iComponentInfo->RootNodeL().Authenticity());
       
   305 	TBool reqUserCap = NeedUserCapabilityL();
       
   306 	if (isNotAuthenticated || reqUserCap)
       
   307 		{
       
   308 		if (isNotAuthenticated)
       
   309 			{
       
   310 				DEBUG_PRINTF(_L("Silent Install is not allowed on unsigned or self-signed packages"));
       
   311 			}
       
   312 		
       
   313 		if (reqUserCap)
       
   314 			{
       
   315 				DEBUG_PRINTF(_L("Silent Install is not allowed when user capabilities are required"));
       
   316 			}
       
   317 		
       
   318 		User::RequestComplete(iClientStatus, KErrNotSupported);
       
   319 		iClientStatus = NULL;
       
   320 		}		
       
   321 	else
       
   322 		{
       
   323 		TInt err;
       
   324 		if (iFileHandle)
       
   325 			{
       
   326 			TRAP(err, iAsyncLauncher->InstallL(*this, *iFileHandle, *iInstallPrefs, iStatus));
       
   327 			}
       
   328 		else
       
   329 			{
       
   330 			//DEBUG_PRINTF2(_L("!!!Silent install for %S"), iFileName);
       
   331 			TRAP(err, iAsyncLauncher->InstallL(*this, iFileName, *iInstallPrefs, iStatus));
       
   332 			}
       
   333 		
       
   334 		if (err != KErrNone)
       
   335 			{
       
   336 			User::RequestComplete(iClientStatus, err);
       
   337 			iClientStatus = NULL;			
       
   338 			}
       
   339 		
       
   340 		SetActive();
       
   341 		}
       
   342 	}
       
   343 
       
   344 void CRefNativePluginActiveImpl::DoCancel()
       
   345 	{
       
   346 	if (iClientStatus)
       
   347 		{
       
   348 		iAsyncLauncher->CancelOperation();
       
   349 		delete iAsyncLauncher;
       
   350 		iAsyncLauncher = NULL;
       
   351 		
       
   352 		User::RequestComplete(iClientStatus, KErrCancel);
       
   353 		iClientStatus = NULL;
       
   354 		}
       
   355 	}
       
   356 
       
   357 void CRefNativePluginActiveImpl::CommonRequestPreamble(const TSecurityContext& aSecurityContext, const COpaqueNamedParams& aInputParams, 
       
   358 				COpaqueNamedParams& aOutputParams, TRequestStatus& aStatus)
       
   359 	{
       
   360 	aStatus = KRequestPending;
       
   361 	iClientStatus = &aStatus;
       
   362 
       
   363 	iInputParams = &aInputParams;
       
   364 	iOutputParams = &aOutputParams;
       
   365 
       
   366 	TInt declineOperation = 0;
       
   367 	TRAPD(err, aInputParams.GetIntByNameL(KDeclineOperationOptionName, declineOperation));
       
   368 	if(err == KErrNone && declineOperation)
       
   369 		{
       
   370 		iDeclineOperation = ETrue;
       
   371 		}
       
   372 	
       
   373 	// Check to see if we have the opaque input argument - InstallSilently 
       
   374 	TInt silentInstall = 0;
       
   375 	TRAP_IGNORE(aInputParams.GetIntByNameL(KSifInParam_InstallSilently, silentInstall));
       
   376 	if (silentInstall)
       
   377 		{
       
   378 		iSilentInstall = ETrue;
       
   379 		if (!aSecurityContext.HasCapability(ECapabilityTrustedUI))
       
   380 			{
       
   381 			User::RequestComplete(iClientStatus, KErrPermissionDenied);
       
   382 			iClientStatus = NULL;			
       
   383 			}
       
   384 		}	
       
   385 	}
       
   386 
       
   387 TComponentId CRefNativePluginActiveImpl::GetLastInstalledComponentIdL()
       
   388   	{
       
   389   	ASSERT(iInstallRequest);
       
   390   
       
   391   	// Find the id of the last installed component and return it
       
   392   	TInt uid;
       
   393   	User::LeaveIfError(RProperty::Get(KUidSystemCategory, KUidSwiLatestInstallation, uid));
       
   394 
       
   395 	Swi::RSisRegistrySession sisRegistrySession;
       
   396 	User::LeaveIfError(sisRegistrySession.Connect());
       
   397 	CleanupClosePushL(sisRegistrySession);
       
   398   
       
   399 	TUid tuid(TUid::Uid(uid));
       
   400 	TComponentId componentId = sisRegistrySession.GetComponentIdForUidL(tuid);
       
   401 	CleanupStack::PopAndDestroy(&sisRegistrySession);
       
   402 	
       
   403 	return componentId;
       
   404   	}
       
   405 
       
   406 void CRefNativePluginActiveImpl::GetComponentInfo(const TDesC& aFileName, CComponentInfo& aComponentInfo, TRequestStatus& aStatus)
       
   407 	{
       
   408 	DEBUG_PRINTF2(_L("Reference native plugin - retrieving component info for %S"), &aFileName);
       
   409 
       
   410 	aStatus = KRequestPending;
       
   411 	iClientStatus = &aStatus;
       
   412 
       
   413 	TRAPD(err, iAsyncLauncher->GetComponentInfoL(*this, aFileName, *iInstallPrefs, aComponentInfo, iStatus));
       
   414 	if (err != KErrNone)
       
   415 		{
       
   416 		TRequestStatus *statusPtr(&aStatus);
       
   417 		User::RequestComplete(statusPtr, err);
       
   418 		return;
       
   419 		}
       
   420 
       
   421 	SetActive();
       
   422 	}
       
   423 
       
   424 void CRefNativePluginActiveImpl::GetComponentInfo(RFile& aFileHandle, CComponentInfo& aComponentInfo, TRequestStatus& aStatus)
       
   425 	{
       
   426 	DEBUG_PRINTF(_L8("Reference native plugin - getting component info by file handle"));
       
   427 	
       
   428 	aStatus = KRequestPending;
       
   429 	iClientStatus = &aStatus;	
       
   430 
       
   431 	TRAPD(err, iAsyncLauncher->GetComponentInfoL(*this, aFileHandle, *iInstallPrefs, aComponentInfo, iStatus));
       
   432 	if (err != KErrNone)
       
   433 		{
       
   434 		TRequestStatus *statusPtr(&aStatus);
       
   435 		User::RequestComplete(statusPtr, err);
       
   436 		return;
       
   437 		}
       
   438 
       
   439 	SetActive();
       
   440 	}	
       
   441 
       
   442 void CRefNativePluginActiveImpl::Install(const TDesC& aFileName, const TSecurityContext& aSecurityContext,
       
   443 											const COpaqueNamedParams& aInputParams, COpaqueNamedParams& aOutputParams,
       
   444 											TRequestStatus& aStatus)
       
   445 	{
       
   446 	DEBUG_PRINTF2(_L("Reference native plugin - install for %S"), &aFileName);
       
   447 	
       
   448 	CommonRequestPreamble(aSecurityContext, aInputParams, aOutputParams, aStatus);
       
   449 	
       
   450 	TInt err;
       
   451 	if (iSilentInstall)
       
   452 		{
       
   453 		// Silent install does a few addtional checks on the package to see if is 
       
   454 		// signed and had the required capabilities. So we need to the get the 
       
   455 		// package component information with out installing it.
       
   456 		DEBUG_PRINTF2(_L("Silent install  - Get the ComponentInfo for %S"), &aFileName);
       
   457 		iFileName = aFileName;
       
   458 		TRAP(err, iAsyncLauncher->GetComponentInfoL(*this, aFileName, *iInstallPrefs, *iComponentInfo, iStatus));
       
   459 		}
       
   460 	else
       
   461 		{
       
   462 		// Proceed with the normal installation.
       
   463 		TRAP(err, iAsyncLauncher->InstallL(*this, aFileName, *iInstallPrefs, iStatus));
       
   464 		iInstallRequest = ETrue;
       
   465 		}
       
   466 	
       
   467 	if (err != KErrNone)
       
   468 		{
       
   469 		TRequestStatus *statusPtr(&aStatus);
       
   470 		User::RequestComplete(statusPtr, err);
       
   471 		return;
       
   472 		}
       
   473 	
       
   474 	SetActive();
       
   475 	}
       
   476 
       
   477 void CRefNativePluginActiveImpl::Install(RFile& aFileHandle, const TSecurityContext& aSecurityContext,
       
   478 											const COpaqueNamedParams& aInputParams, COpaqueNamedParams& aOutputParams,
       
   479 											TRequestStatus& aStatus)
       
   480 	{
       
   481 	DEBUG_PRINTF(_L8("Reference native plugin - install by file handle"));
       
   482 
       
   483 	CommonRequestPreamble(aSecurityContext, aInputParams, aOutputParams, aStatus);
       
   484 
       
   485 	TInt err;
       
   486 	if (iSilentInstall)
       
   487 		{
       
   488 		// Silent install does a few addtional checks on the package to see if is 
       
   489 		// signed and had the required capabilities. So we need to the get the 
       
   490 		// package component information with out installing it.
       
   491 		iFileHandle = &aFileHandle;
       
   492 		TRAP(err, iAsyncLauncher->GetComponentInfoL(*this, aFileHandle, *iInstallPrefs, *iComponentInfo, iStatus));
       
   493 		}
       
   494 	else
       
   495 		{
       
   496 		// Proceed with the normal installation.
       
   497 		TRAP(err, iAsyncLauncher->InstallL(*this, aFileHandle, *iInstallPrefs, iStatus));
       
   498 		iInstallRequest = ETrue;
       
   499 		}
       
   500 	
       
   501 	if (err != KErrNone)
       
   502 		{
       
   503 		TRequestStatus *statusPtr(&aStatus);
       
   504 		User::RequestComplete(statusPtr, err);
       
   505 		return;
       
   506 		}
       
   507 
       
   508 	SetActive();
       
   509 	}
       
   510 
       
   511 void CRefNativePluginActiveImpl::Uninstall(TComponentId aComponentId, const TSecurityContext& aSecurityContext,
       
   512 		  const COpaqueNamedParams& aInputParams, COpaqueNamedParams& aOutputParams, TRequestStatus& aStatus)
       
   513 	{
       
   514 	TRAPD(err, UninstallL(aComponentId, aSecurityContext, aInputParams, aOutputParams, aStatus));
       
   515 	if (err != KErrNone)
       
   516 		{
       
   517 		TRequestStatus *statusPtr(&aStatus);
       
   518 		User::RequestComplete(statusPtr, err);
       
   519 		return;
       
   520 		}
       
   521 	SetActive();
       
   522 	}
       
   523 
       
   524 void CRefNativePluginActiveImpl::UninstallL(TComponentId aComponentId, const TSecurityContext& aSecurityContext,
       
   525 		  const COpaqueNamedParams& aInputParams, COpaqueNamedParams& aOutputParams, TRequestStatus& aStatus)
       
   526 	{
       
   527 	DEBUG_PRINTF(_L8("Reference native plugin - uninstall"));
       
   528 	CommonRequestPreamble(aSecurityContext, aInputParams, aOutputParams, aStatus);
       
   529     // Get UID for given component id
       
   530 	RSoftwareComponentRegistry scrSession;
       
   531 	User::LeaveIfError(scrSession.Connect());
       
   532 	CleanupClosePushL(scrSession);
       
   533 	
       
   534 	CPropertyEntry* propertyEntry = scrSession.GetComponentPropertyL(aComponentId, _L("CompUid"));
       
   535 	CleanupStack::PushL(propertyEntry);
       
   536 
       
   537 	CIntPropertyEntry* intPropertyEntry = dynamic_cast<CIntPropertyEntry *>(propertyEntry); 
       
   538 	
       
   539 	TRequestStatus *statusPtr(&aStatus);
       
   540 	if (intPropertyEntry == NULL)
       
   541 		{
       
   542 		DEBUG_PRINTF2(_L8("UID property for component %d was not found"), aComponentId);
       
   543 		User::RequestComplete(statusPtr, KErrNotFound);
       
   544 		return;
       
   545 		}
       
   546 
       
   547 	TUid objectId = TUid::Uid(intPropertyEntry->IntValue());
       
   548 	CleanupStack::PopAndDestroy(2, &scrSession);
       
   549 
       
   550 	iAsyncLauncher->UninstallL(*this, objectId, iStatus);
       
   551 	}
       
   552 
       
   553 void CRefNativePluginActiveImpl::Activate(TComponentId aComponentId, const TSecurityContext& /*aSecurityContext*/, TRequestStatus& aStatus)
       
   554 	{
       
   555 	DEBUG_PRINTF(_L8("Reference native plugin - activate"));
       
   556 	iStatus = KRequestPending;
       
   557 	aStatus = KRequestPending;
       
   558 	iClientStatus = &aStatus;
       
   559 
       
   560 	TRequestStatus* rs(&iStatus);
       
   561 	
       
   562 	Swi::RSisRegistryWritableSession sisRegSession;
       
   563 	TRAPD(err, 
       
   564 			User::LeaveIfError(sisRegSession.Connect());
       
   565 			sisRegSession.ActivateComponentL(aComponentId);
       
   566 			)
       
   567 	sisRegSession.Close();
       
   568 
       
   569 	User::RequestComplete(rs, err);
       
   570 	SetActive();
       
   571 	}
       
   572 
       
   573 void CRefNativePluginActiveImpl::Deactivate(TComponentId aComponentId, const TSecurityContext& /*aSecurityContext*/, TRequestStatus& aStatus)
       
   574 	{
       
   575 	DEBUG_PRINTF(_L8("Reference native plugin - deactivate"));
       
   576 	iStatus = KRequestPending;
       
   577 	aStatus = KRequestPending;
       
   578 	iClientStatus = &aStatus;
       
   579 
       
   580 	TRequestStatus* rs(&iStatus);
       
   581 
       
   582 	Swi::RSisRegistryWritableSession sisRegSession;
       
   583 	TRAPD(err, 
       
   584 			User::LeaveIfError(sisRegSession.Connect());
       
   585 			sisRegSession.DeactivateComponentL(aComponentId);
       
   586 			)
       
   587 	sisRegSession.Close();
       
   588 
       
   589 	User::RequestComplete(rs, err);
       
   590 	SetActive();
       
   591 	}
       
   592 
       
   593 // SWI::MUiHandler implementation
       
   594 TInt CRefNativePluginActiveImpl::DisplayLanguageL(const Swi::CAppInfo& /*aAppInfo*/,const RArray<TLanguage>& /*aLanguages*/)
       
   595 	{
       
   596 	DEBUG_PRINTF(_L8("Reference native plugin - DisplayLanguageL"));
       
   597 	return 0;
       
   598 	}
       
   599 
       
   600 TInt CRefNativePluginActiveImpl::DisplayDriveL(const Swi::CAppInfo& /*aAppInfo*/,TInt64 /*aSize*/, const RArray<TChar>& /*aDriveLetters*/, const RArray<TInt64>& /*aDriveSpaces*/)
       
   601 	{
       
   602 	DEBUG_PRINTF(_L8("Reference native plugin - DisplayDriveL"));
       
   603 	return 0;
       
   604 	}
       
   605 
       
   606 TBool CRefNativePluginActiveImpl::DisplayUninstallL(const Swi::CAppInfo& /*aAppInfo*/)
       
   607 	{
       
   608 	DEBUG_PRINTF(_L8("Reference native plugin - DisplayUninstallL"));
       
   609 	if (iDeclineOperation)
       
   610 		{
       
   611 		DEBUG_PRINTF(_L8("Reference native plugin - Received an option to decline operation - stopping uninstall"));
       
   612 		return EFalse;
       
   613 		}
       
   614 	return ETrue;
       
   615 	}
       
   616 
       
   617 TBool CRefNativePluginActiveImpl::DisplayTextL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TFileTextOption /*aOption*/, const TDesC& /*aText*/)
       
   618 	{
       
   619 	DEBUG_PRINTF(_L8("Reference native plugin - DisplayTextL"));
       
   620 	return ETrue;
       
   621 	}
       
   622 
       
   623 TBool CRefNativePluginActiveImpl::DisplayDependencyBreakL(const Swi::CAppInfo& /*aAppInfo*/, const RPointerArray<TDesC>& /*aComponents*/)
       
   624 	{
       
   625 	DEBUG_PRINTF(_L8("Reference native plugin - DisplayDependencyBreakL"));
       
   626 	return ETrue;
       
   627 	}
       
   628 
       
   629 TBool CRefNativePluginActiveImpl::DisplayApplicationsInUseL(const Swi::CAppInfo& /*aAppInfo*/, const RPointerArray<TDesC>& /*aAppNames*/)
       
   630 	{
       
   631 	DEBUG_PRINTF(_L8("Reference native plugin - DisplayApplicationsInUseL"));
       
   632 	return ETrue;
       
   633 	}
       
   634 
       
   635 TBool CRefNativePluginActiveImpl::DisplayQuestionL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TQuestionDialog /*aQuestion*/, const TDesC& /*aDes*/)
       
   636 	{
       
   637 	DEBUG_PRINTF(_L8("Reference native plugin - DisplayQuestionL"));
       
   638 	return ETrue;
       
   639 	}
       
   640 
       
   641 TBool CRefNativePluginActiveImpl::DisplayInstallL(const Swi::CAppInfo& /*aAppInfo*/, const CApaMaskedBitmap* /*aLogo*/, const RPointerArray<Swi::CCertificateInfo>& /*aCertificates*/)
       
   642 	{
       
   643 	DEBUG_PRINTF(_L8("Reference native plugin - DisplayInstallL"));
       
   644 
       
   645 	if (iDeclineOperation)
       
   646 		{
       
   647 		DEBUG_PRINTF(_L8("Reference native plugin - Received an option to decline operation - stopping install"));
       
   648 		return EFalse;
       
   649 		}
       
   650 	return ETrue;
       
   651 	}
       
   652 
       
   653 TBool CRefNativePluginActiveImpl::DisplayGrantCapabilitiesL(const Swi::CAppInfo& /*aAppInfo*/, const TCapabilitySet& /*aCapabilitySet*/)
       
   654 	{
       
   655 	DEBUG_PRINTF(_L8("Reference native plugin - DisplayGrantCapabilitiesL"));
       
   656 	return ETrue;
       
   657 	}
       
   658 
       
   659 TBool CRefNativePluginActiveImpl::DisplayUpgradeL(const Swi::CAppInfo& /*aAppInfo*/, const Swi::CAppInfo& /*aExistingAppInfo*/)
       
   660 	{
       
   661 	DEBUG_PRINTF(_L8("Reference native plugin - DisplayUpgradeL"));
       
   662 	return ETrue;
       
   663 	}
       
   664 
       
   665 TBool CRefNativePluginActiveImpl::DisplayOptionsL(const Swi::CAppInfo& /*aAppInfo*/, const RPointerArray<TDesC>& /*aOptions*/, RArray<TBool>& /*aSelections*/)
       
   666 	{
       
   667 	DEBUG_PRINTF(_L8("Reference native plugin - DisplayOptionsL"));
       
   668 	return ETrue;
       
   669 	}
       
   670 
       
   671 TBool CRefNativePluginActiveImpl::DisplaySecurityWarningL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TSignatureValidationResult /*aSigValidationResult*/,
       
   672 						RPointerArray<CPKIXValidationResultBase>& /*aPkixResults*/, RPointerArray<Swi::CCertificateInfo>& /*aCertificates*/, TBool /*aInstallAnyway*/)
       
   673 	{
       
   674 	DEBUG_PRINTF(_L8("Reference native plugin - DisplaySecurityWarningL"));
       
   675 	return ETrue;
       
   676 	}
       
   677 
       
   678 TBool CRefNativePluginActiveImpl::DisplayOcspResultL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TRevocationDialogMessage /*aMessage*/, RPointerArray<TOCSPOutcome>& /*aOutcomes*/, 
       
   679 						RPointerArray<Swi::CCertificateInfo>& /*aCertificates*/,TBool /*aWarningOnly*/)
       
   680 	{
       
   681 	DEBUG_PRINTF(_L8("Reference native plugin - DisplayOcspResultL"));
       
   682 	return ETrue;
       
   683 	}
       
   684 
       
   685 TBool CRefNativePluginActiveImpl::DisplayMissingDependencyL(const Swi::CAppInfo& /*aAppInfo*/, const TDesC& /*aDependencyName*/, TVersion /*aWantedVersionFrom*/,
       
   686 						TVersion /*aWantedVersionTo*/, TVersion /*aInstalledVersion*/)
       
   687 	{
       
   688 	DEBUG_PRINTF(_L8("Reference native plugin - DisplayMissingDependencyL"));
       
   689 	return ETrue;
       
   690 	}
       
   691 
       
   692 TBool CRefNativePluginActiveImpl::HandleInstallEventL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TInstallEvent /*aEvent*/, TInt /*aValue*/, const TDesC& /*aDes*/)
       
   693 	{
       
   694 	DEBUG_PRINTF(_L8("Reference native plugin - HandleInstallEventL"));
       
   695 	return ETrue;
       
   696 	}
       
   697 
       
   698 void CRefNativePluginActiveImpl::HandleCancellableInstallEventL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TInstallCancellableEvent /*aEvent*/, Swi::MCancelHandler& /*aCancelHandler*/,
       
   699 						TInt /*aValue*/,const TDesC& /*aDes*/)
       
   700 	{	
       
   701 	DEBUG_PRINTF(_L8("Reference native plugin - HandleCancellableInstallEventL"));
       
   702 	}
       
   703 
       
   704 void CRefNativePluginActiveImpl::DisplayCannotOverwriteFileL(const Swi::CAppInfo& /*aAppInfo*/, const Swi::CAppInfo& /*aInstalledAppInfo*/,const TDesC& /*aFileName*/)
       
   705 	{	
       
   706 	DEBUG_PRINTF(_L8("Reference native plugin - DisplayCannotOverwriteFileL"));
       
   707 	}
       
   708 
       
   709 void CRefNativePluginActiveImpl::DisplayErrorL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TErrorDialog /*aType*/, const TDesC& /*aParam*/)
       
   710 	{
       
   711 	DEBUG_PRINTF(_L8("Reference native plugin - DisplayErrorL"));
       
   712 	}
       
   713