installationservices/swi/source/swis/server/installationprocessor.h
changeset 0 ba25891c3a9e
child 5 3eebb1e54d3a
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2004-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 /**
       
    20  @file 
       
    21  @released
       
    22  @internalTechnology 
       
    23 */
       
    24 
       
    25 #ifndef __INSTALLATIONPROCESSOR_H__
       
    26 #define __INSTALLATIONPROCESSOR_H__
       
    27 
       
    28 #include <e32base.h>
       
    29 #include <f32file.h>
       
    30 #include "msisuihandlers.h"
       
    31 #include "sisregistryfiledescription.h"
       
    32 #include "processor.h"
       
    33 
       
    34 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
    35 #include "registrywrapper.h"
       
    36 #else
       
    37 #include "sisregistrywritablesession.h"
       
    38 #endif
       
    39 
       
    40 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
    41 class CIntegrityServices;
       
    42 #endif
       
    43 
       
    44 namespace Swi
       
    45 {
       
    46 class CApplication;
       
    47 class CSecurityManager;
       
    48 class RSisHelper;
       
    49 class RUiHandler;
       
    50 class CHashContainer;
       
    51 class CPlan;
       
    52 class CFileExtractor;
       
    53 class CSidCache;
       
    54 class MSisDataProvider;
       
    55 
       
    56 /**
       
    57  * This class processes a CApplication created by the installation planner
       
    58  * @released
       
    59  * @internalTechnology 
       
    60  */
       
    61 class CInstallationProcessor : public CProcessor
       
    62 	{
       
    63 	
       
    64 public:
       
    65 	/**
       
    66 	 * This class contains information about the temporary location of a file,
       
    67 	 * and it's final destination, since the application processor installs files
       
    68 	 * in a two stage process.
       
    69 	 */
       
    70 	class CFileCopyDescription 
       
    71 		{
       
    72 	public:
       
    73 		static CFileCopyDescription* NewL(const TDesC& aTemporaryFileName, const CSisRegistryFileDescription& aFileDescription);
       
    74 		
       
    75 		static CFileCopyDescription* NewLC(const TDesC& aTemporaryFileName, const CSisRegistryFileDescription& aFileDescription);
       
    76 		
       
    77 		~CFileCopyDescription();
       
    78 	
       
    79 		// Access functions
       
    80 		inline const CSisRegistryFileDescription& FileDescription() const;
       
    81 		
       
    82 		inline const TDesC& TemporaryFileName() const;
       
    83 		
       
    84 	private:
       
    85 		CFileCopyDescription(const CSisRegistryFileDescription& aFileDescription);
       
    86 		
       
    87 		void ConstructL(const TDesC& aTemporaryFileName);
       
    88 	
       
    89 	private:
       
    90 		/// The temporary filename
       
    91 		const CSisRegistryFileDescription& iFileDescription;
       
    92 		
       
    93 		/// The temporary filename
       
    94 		HBufC* iTemporaryFileName;
       
    95 		};
       
    96 
       
    97 public:
       
    98 		
       
    99 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   100 	/**
       
   101 	 * Creates a new CInstallationProcessor
       
   102 	 * @param aPlan              	Installation plan
       
   103 	 * @param aSecurityManager   	Used to calculate file hashes
       
   104 	 * @param aSisHelper         	Extracts new files from the SISX file
       
   105 	 * @param aUiHandler         	Interface for progress notification
       
   106 	 * @param aStsSession 			Used to rollback installation process
       
   107 	 * @param aRegistryWrapper		Used for registy operations
       
   108 	 * @param aObserver			 	SWI Observer sessision handle which is used to log SWI events.
       
   109 	 * @return                   	New application processor object
       
   110 	 */
       
   111 	static CInstallationProcessor* NewL(const CPlan& aPlan,
       
   112 		CSecurityManager& aSecurityManager, RSisHelper& aSisHelper,
       
   113 		RUiHandler& aUiHandler, Usif::RStsSession& aStsSession,
       
   114 		CRegistryWrapper& aRegistryWrapper,
       
   115 		const TDesC8& aControllerData, RSwiObserverSession& aObserver);
       
   116 #else
       
   117 	/**
       
   118 	 * Creates a new CInstallationProcessor
       
   119 	 * @param aPlan              Installation plan
       
   120 	 * @param aSecurityManager   Used to calculate file hashes
       
   121 	 * @param aSisHelper         Extracts new files from the SISX file
       
   122 	 * @param aUiHandler         Interface for progress notification
       
   123 	 * @param aIntegrityServices Used to rollback installation process
       
   124 	 * @param aObserver			 SWI Observer sessision handle which is used to log SWI events.
       
   125 	 * @return                   New application processor object
       
   126 	 */
       
   127 	static CInstallationProcessor* NewL(const CPlan& aPlan,
       
   128 		CSecurityManager& aSecurityManager, RSisHelper& aSisHelper,
       
   129 		RUiHandler& aUiHandler, CIntegrityServices& aIntegrityServices,
       
   130 		const TDesC8& aControllerData, RSwiObserverSession& aObserver);
       
   131 #endif
       
   132 
       
   133 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   134 	/**
       
   135 	 * Creates a new CInstallationProcessor and places it on the cleanup stack
       
   136 	 * @param aPlan              	Installation plan
       
   137 	 * @param aSecurityManager   	Used to calculate file hashes
       
   138 	 * @param aSisHelper         	Extracts new files from the SISX file
       
   139 	 * @param aUiHandler         	Interface for progress notification
       
   140 	 * @param aStsSession 			Used to rollback installation process
       
   141 	 * @param aRegistryWrapper		Used for registy operations
       
   142 	 * @param aObserver			 	SWI Observer sessision handle which is used to log SWI events.
       
   143 	 * @return                   	New application processor object on the 
       
   144 	 *                           	cleanup stack
       
   145 	 */
       
   146 	static CInstallationProcessor* NewLC(const CPlan& aPlan,
       
   147 		CSecurityManager& aSecurityManager, RSisHelper& aSisHelper,
       
   148 		RUiHandler& aUiHandler, Usif::RStsSession& aStsSession,
       
   149 		CRegistryWrapper& aRegistryWrapper,
       
   150 		const TDesC8& aControllerData, RSwiObserverSession& aObserver);
       
   151 #else
       
   152 	/**
       
   153 	 * Creates a new CInstallationProcessor and places it on the cleanup stack
       
   154 	 * @param aPlan              Installation plan
       
   155 	 * @param aSecurityManager   Used to calculate file hashes
       
   156 	 * @param aSisHelper         Extracts new files from the SISX file
       
   157 	 * @param aUiHandler         Interface for progress notification
       
   158 	 * @param aIntegrityServices Used to rollback installation process
       
   159 	 * @param aObserver			 SWI Observer sessision handle which is used to log SWI events.
       
   160 	 * @return                   New application processor object on the 
       
   161 	 *                           cleanup stack
       
   162 	 */
       
   163 	static CInstallationProcessor* NewLC(const CPlan& aPlan,
       
   164 		CSecurityManager& aSecurityManager, RSisHelper& aSisHelper,
       
   165 		RUiHandler& aUiHandler, CIntegrityServices& aIntegrityServices,
       
   166 		const TDesC8& aControllerData, RSwiObserverSession& aObserver);
       
   167 #endif
       
   168 
       
   169 	static CInstallationProcessor* NewL(CInstallationProcessor& aProcessor);
       
   170 	
       
   171 	virtual ~CInstallationProcessor();
       
   172 	
       
   173 	
       
   174 private:
       
   175 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   176 	CInstallationProcessor(const CPlan& aPlan,
       
   177 		CSecurityManager& aSecurityManager, RSisHelper& aSisHelper,
       
   178 		RUiHandler& aUiHandler, Usif::RStsSession& aStsSession,
       
   179 		CRegistryWrapper& aRegistryWrapper,
       
   180 		const TDesC8& aControllerData, RSwiObserverSession& aObserver);
       
   181 #else
       
   182 	CInstallationProcessor(const CPlan& aPlan,
       
   183 		CSecurityManager& aSecurityManager, RSisHelper& aSisHelper,
       
   184 		RUiHandler& aUiHandler, CIntegrityServices& aIntegrityServices,
       
   185 		const TDesC8& aControllerData, RSwiObserverSession& aObserver);
       
   186 #endif
       
   187 
       
   188 	void ConstructL();
       
   189 
       
   190 	/**
       
   191 	 * Uses Integrity Support to first backup then remove old files
       
   192 	 * @param aFileDescription - the file to display
       
   193 	 */
       
   194 	void DisplayFileL(const CSisRegistryFileDescription& aFileDescription, Sis::TSISFileOperationOptions aFileOperationOption);
       
   195 	
       
   196 	/**
       
   197 	 * Uses SISHelper to extract a file into a temporary location, verifies 
       
   198 	 * its hash using Security Manager, detaches hash to \sys\hash on system drive
       
   199 	 * if this is an executable file
       
   200 	 *
       
   201 	 * @param aFileToExtract - the file to extract
       
   202 	 * @return ETrue to indicate caller should wait for request completion, EFalse otherwise.
       
   203 	 */
       
   204 	 TBool ExtractFileL(CSisRegistryFileDescription& aFileDescription);
       
   205 
       
   206 	/**
       
   207 	 * Extracts executable file hash and places it as a file by the same 
       
   208 	 * name in \sys\hash on system drive ; adds the hash file to the transaction 
       
   209 	 * in the integrity services.
       
   210 	 *
       
   211 	 * @param aFileName Original name of the file
       
   212 	 * @param aHash     SHA1 hash from SISController
       
   213 	 */
       
   214 	void ExtractHashL(const TFileName& aFileName, const CHashContainer& aHash);
       
   215 	
       
   216 	/**
       
   217 	 * Ensures files are only installed in valid locations
       
   218 	 */
       
   219 	void VerifyInstallPathL(const CSisRegistryFileDescription& aFileDescription);
       
   220 	
       
   221 	/**
       
   222 	 * Installs files by moving them from the temporary location to
       
   223 	 * the target location specified in the SISX file.
       
   224 	 * @param aFileCopyDescription containing the source and target filenames
       
   225 	 */
       
   226 	void InstallFileL(const CFileCopyDescription& aFileCopyDescription);
       
   227 	
       
   228 	void DoExtractHashL(const CSisRegistryFileDescription& aFileToExtract);
       
   229 	
       
   230 	/**
       
   231 	 * Calculate hash value for the file and compare with the one given.
       
   232 	 * @leave KErrCorrupt if hashes do not match.
       
   233 	 */
       
   234 	void CheckHashL(const CSisRegistryFileDescription& aFileToExtract, const TDesC& aCurrentFileName);
       
   235 	
       
   236 	/**
       
   237 	* Construct the temporary filename
       
   238 	*/
       
   239 	void TemporaryFileNameLC(const CSisRegistryFileDescription& aFileToExtract, TDes& aTemporaryFileName);
       
   240 
       
   241 	/**
       
   242 	 * Ensures the temporary directory, we use to store files in
       
   243 	 * before copying them to the final destination, exists.
       
   244 	 */
       
   245 	void EnsureTemporaryInstallDirExistsL(const TDesC& aFileTarget);
       
   246 	void ReportErrorL(TErrorDialog aError);
       
   247 	void AddEventToLogL(const CSisRegistryFileDescription& aFileDescription);
       
   248 	
       
   249 	/**
       
   250 	 * Add in apparc files (incase of reg files) and Launch the file by checking the file operation.
       
   251 	 */
       
   252 	void LaunchFileL(const CSisRegistryFileDescription& aFileDescription);
       
   253 	
       
   254 	/*
       
   255 	 * Checks whether the file is launchable or not.
       
   256 	 * Returns true if operation flag is set RI. 
       
   257 	 */
       
   258 	TBool ShouldLaunchL(const CSisRegistryFileDescription& aFileDescription);
       
   259 		
       
   260 	/*
       
   261 	 * Add apparc registered files in our apparc registered file list.
       
   262 	 */	
       
   263 	 void AddApparcFilesInListL(const TDesC& aTargetFileName);
       
   264 	 
       
   265 	// Functions which get called by CProcessor::RunL to do the work
       
   266 private:
       
   267 	virtual TBool DoStateInitializeL();
       
   268 	virtual TBool DoStateProcessEmbeddedL();
       
   269 	virtual TBool DoStateExtractFilesL();
       
   270 	virtual TBool DoStateVerifyPathsL();
       
   271 	virtual TBool DoStateInstallFilesL();
       
   272 	virtual TBool DoStateDisplayFilesL();
       
   273 	virtual TBool DoStateUpdateRegistryL();
       
   274 	virtual TBool DoStateProcessFilesL();
       
   275 	virtual TBool DoStateProcessSkipFilesL();
       
   276 
       
   277 	virtual void DoCancel();
       
   278 
       
   279 	CInstallationProcessor& EmbeddedProcessorL();
       
   280 
       
   281 	// Verify that all embedded applications were installed on the same drive
       
   282 	static TBool CheckEmbeddedAppsInstalledOnSameDrive(RPointerArray<CApplication> aArray, TChar aDrive);
       
   283 	// Check whether the application is permitted in a removable media card SIS stub
       
   284 	static TBool IsApplicationPermittedInStub(const CApplication& aApplication);
       
   285 	
       
   286 	/* Create the stub SIS file 
       
   287 	@param aFileName Stub sis filename
       
   288 	*/
       
   289 	void CreateStubSisFileL(TFileName &aFileName);
       
   290 	
       
   291 	/* Register the stub SIS to SWI Registry while uninstallation 
       
   292 	@param aFileName Stub sis filename
       
   293 	*/
       
   294 	void RegisterStubSisFileL(const TFileName &aFileName);
       
   295 	
       
   296 	/* Check whether the media is removable or not */
       
   297 	TBool IsStubSisFileRequiredL();
       
   298 		
       
   299 	/** Create a SisRegistry file description for the given
       
   300 	SIS stub file
       
   301 	@param aFs A file server session
       
   302 	@param aFileName The full path and filename of the SIS stub file
       
   303 	*/
       
   304 	CSisRegistryFileDescription* CreateSisStubRegistryFileDescriptionLC(RFs& aFs, const TDesC& aFileName);
       
   305 
       
   306 	/// @return true if aFilename is an Apparc registration file 
       
   307 	bool FileIsApparcReg(const TDesC& aFilename) const;
       
   308 private:
       
   309 	/// Security Manager provided by SWIS
       
   310 	CSecurityManager& iSecurityManager;
       
   311 		
       
   312 	/// SisHelper provided by SWIS
       
   313 	RSisHelper& iSisHelper;
       
   314 	
       
   315 	/// Processes embedded applications
       
   316 	CInstallationProcessor* iEmbeddedProcessor;
       
   317 	
       
   318 	/**
       
   319 	 * A list of files which need to be copied from the temporary location to their
       
   320 	 * final locations.
       
   321 	 */
       
   322 	RPointerArray<CFileCopyDescription> iFilesToCopy;
       
   323 		
       
   324 	TInt iCurrent;
       
   325 	TInt iFilesToCopyCurrent;
       
   326 	
       
   327 	CFileExtractor* iFileExtractor;
       
   328 	
       
   329 	const TDesC8& iControllerData;
       
   330 
       
   331 	/**
       
   332 	 * The list of Apparc registration files to pass to apparc before
       
   333 	 * running an exe.
       
   334 	 */
       
   335 	RPointerArray<TDesC> iApparcRegFiles;
       
   336 	
       
   337 	RLoader iLoader;
       
   338 	
       
   339 	/**
       
   340 	 * The list of input received from user for the DisplayText dialog. This array is parallel bit 
       
   341 	 * array with ApplicationL().FilesToSkipOnInstall()
       
   342 	 */
       
   343 	RArray<TBool> iSkipFile;
       
   344 	
       
   345 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   346 	/** The list of the software types to be registered read from the XML registration file. */
       
   347 	RCPointerArray<CSoftwareTypeRegInfo> iSoftwareTypeRegInfoArray;
       
   348 #endif
       
   349 	};
       
   350 
       
   351 	
       
   352 // inline functions
       
   353 
       
   354 inline const CSisRegistryFileDescription& CInstallationProcessor::CFileCopyDescription::FileDescription() const
       
   355 	{
       
   356 	return iFileDescription;
       
   357 	}
       
   358 			
       
   359 inline const TDesC& CInstallationProcessor::CFileCopyDescription::TemporaryFileName() const
       
   360 	{
       
   361 	return *iTemporaryFileName;
       
   362 	}
       
   363 
       
   364 
       
   365 } // namespace Swi
       
   366 
       
   367 #endif