installationservices/refswinstallationplugin/inc/sifrefinstallertask.h
branchRCL_3
changeset 66 8b7f4e561641
parent 65 7333d7932ef7
child 70 e8965914fac7
equal deleted inserted replaced
65:7333d7932ef7 66:8b7f4e561641
     1 /*
       
     2 * Copyright (c) 2008-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 * This file defines tasks for the Reference Installer. These tasks implement the CSifTransportTask
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalComponent
       
    23  exampleCode
       
    24  interface. Please @see siftransporttask.h for details of this interface.
       
    25 */
       
    26 
       
    27 #ifndef SIFREFINSTALLERTASK_H
       
    28 #define SIFREFINSTALLERTASK_H
       
    29 
       
    30 #include <usif/scr/scr.h>
       
    31 #include <usif/sts/sts.h>
       
    32 #include <usif/sif/sif.h>
       
    33 #include <usif/sif/siftransporttask.h>
       
    34 #include "sifrefbinpkgextractor.h"
       
    35 #include "sifrefpkgparser.h"
       
    36 
       
    37 namespace Usif
       
    38 	{
       
    39 
       
    40 	/**
       
    41 	The MInstallerUIHandler class defines an interface for UI callbacks. The Reference
       
    42 	Installer tasks uses a concrete implementation of this interface to interact with the user.
       
    43 	
       
    44 	This interface defines four arbitrary chosen callbacks. A real installer may define
       
    45 	its own interface when these callbacks aren't sufficient.
       
    46 	*/
       
    47 	class MInstallerUIHandler
       
    48 		{
       
    49 	public:
       
    50 		/**
       
    51 		Gets called when an installer needs a confirmation dialog to be displayed to the user.
       
    52 		*/
       
    53 		virtual TBool ConfirmationUIHandler(const TDesC& aQuestion) = 0;
       
    54 
       
    55 		/**
       
    56 		Gets called when an installer needs an error description to be displayed to the user.
       
    57 		*/
       
    58 		virtual void ErrorDescriptionUIHandler(const TDesC& aDescription) = 0;
       
    59 		};
       
    60 
       
    61 	/**
       
    62 	A factory function. The Reference Installer Server uses this function to instantiate a UI handler object.
       
    63 	*/
       
    64 	typedef MInstallerUIHandler* (*TInstallerUIHandlerFactory)();
       
    65 
       
    66 // ===========================================================================================================
       
    67 
       
    68 	/**
       
    69 	An auxiliary data structure used by the Reference Installer tasks for SCR search results.
       
    70 	*/
       
    71 	struct TComponentSearchData
       
    72 		{
       
    73 		const TDesC* iName;
       
    74 		const TDesC* iVendor;
       
    75 		TVersionName iVersion;
       
    76 		TScomoState iScomoState;
       
    77 		TInstallStatus iInstallStatus;
       
    78 		TComponentId iComponentId;
       
    79 		};
       
    80 
       
    81 // ===========================================================================================================
       
    82 
       
    83 	/**
       
    84 	A Reference Installer task that implements the 'GetComponentInfo' SIF request.
       
    85 	*/
       
    86 	class CSifRefGetComponentInfoTask : public CSifTransportTask
       
    87 		{
       
    88 	public:
       
    89 		static CSifRefGetComponentInfoTask* NewL(TTransportTaskParams& aParams);
       
    90 		virtual ~CSifRefGetComponentInfoTask();
       
    91 
       
    92 	protected:
       
    93 		virtual TBool ExecuteImplL();
       
    94 
       
    95 	private:
       
    96 		CSifRefGetComponentInfoTask(TTransportTaskParams& aParams);
       
    97 
       
    98 		// GetComponentInfo steps
       
    99 		void ExtractEmbeddedPkgsL();
       
   100 		TInt ParsePkgFileL();
       
   101 		void CheckAndSetComponentInfoL();
       
   102 		TInt CreateComponentInfoNodeL();
       
   103 		void SetComponentInfoL();
       
   104 
       
   105 		// Installer's tools
       
   106 		RSoftwareComponentRegistry iScr;
       
   107 		RStsSession iSts; // used for temporary files
       
   108 		CSifRefPkgParser* iParser;
       
   109 
       
   110 		// Interstate data
       
   111 		TComponentSearchData iCompSearchData;
       
   112 
       
   113 		// Embedded components extracted from a compound package
       
   114 		RCPointerArray<SifRefBinPkgExtractor::CAuxNode> iEmbeddedComponents;
       
   115 		TInt iCurrentComponent;
       
   116 
       
   117 		// Stuff needed for processing packages of different types
       
   118 		RSoftwareInstall iSif;
       
   119 		TBool iSifRequestInProgress;
       
   120 		CComponentInfo* iComponentInfo;
       
   121 		RFs iFs;
       
   122 		RFile iFile;
       
   123 
       
   124 		// The GetComponentInfo task consists of the following steps
       
   125 		enum TGetComponentInfoSteps
       
   126 			{
       
   127 			EExtractEmbeddedPkgs = 1,
       
   128 			EParsePkgFile,
       
   129 			EFindComponent,
       
   130 			ECreateComponentInfoNode,
       
   131 			ESetComponentInfo
       
   132 			};
       
   133 		TInt iStep;
       
   134 		};
       
   135 
       
   136 // ===========================================================================================================
       
   137 
       
   138 	/**
       
   139 	A Reference Installer task that implements the 'Install' SIF request.
       
   140 	*/
       
   141 	class CSifRefInstallTask : public CSifTransportTask
       
   142 		{
       
   143 	public:
       
   144 		static CSifRefInstallTask* NewL(TTransportTaskParams& aParams, TInstallerUIHandlerFactory aUiHandlerFactory);
       
   145 		virtual ~CSifRefInstallTask();
       
   146 
       
   147 	protected:
       
   148 		virtual TBool ExecuteImplL();
       
   149 
       
   150 	private:
       
   151 		CSifRefInstallTask(TTransportTaskParams& aParams);
       
   152 		void ConstructL(TInstallerUIHandlerFactory aUiHandlerFactory);
       
   153 
       
   154 		// Installation steps
       
   155 		void ExtractEmbeddedPkgsL();
       
   156 		TInt ParsePkgFileImplL();
       
   157 		TInt ParsePkgFileL();
       
   158 		void LaunchForeignInstallL();
       
   159 		void FinishForeignInstallL();
       
   160 		TInt FindAndCheckComponentL();
       
   161 		void GetInstalledFileListL();
       
   162 		TBool UnregisterAndDeleteFileL();
       
   163 		void RegisterComponentL();
       
   164 		TBool CopyFileL();
       
   165 		TInt SetScomoStateL();
       
   166 		void CommitL();
       
   167 
       
   168 		// Installer's tools
       
   169 		RSoftwareComponentRegistry iScr;
       
   170 		RStsSession iSts;
       
   171 		CSifRefPkgParser* iParser;
       
   172 		TBool iScrTransaction;
       
   173 
       
   174 		// UI interaction
       
   175 		MInstallerUIHandler* iUiHandler;
       
   176 
       
   177 		// Interstate data
       
   178 		TComponentSearchData iCompSearchData;
       
   179 		RSoftwareComponentRegistryFilesList iFileList;
       
   180 
       
   181 		// Embedded components extracted from a compound package
       
   182 		RCPointerArray<SifRefBinPkgExtractor::CAuxNode> iEmbeddedComponents;
       
   183 		TInt iCurrentComponent;
       
   184 
       
   185 		// Stuff needed for processing packages of different types
       
   186 		RSoftwareInstall iSif;
       
   187 		COpaqueNamedParams* iOpaqueArguments;
       
   188 		COpaqueNamedParams* iOpaqueResults;
       
   189 		TBool iSifRequestInProgress;
       
   190 		RFs iFs;
       
   191 		RFile iFile;
       
   192 
       
   193 		// The Install task consists of the following steps
       
   194 		enum TInstallSteps
       
   195 			{
       
   196 			EExtractEmbeddedPkgs = 1,
       
   197 			EParsePkgFile,
       
   198 			ELaunchForeignInstall,
       
   199 			EFinishForeignInstall,
       
   200 			EFindAndCheckComponent,
       
   201 			EGetInstalledFileList,
       
   202 			EUnregisterAndDeleteFile,
       
   203 			ERegisterComponent,
       
   204 			ECopyFile,
       
   205 			ESetScomoState,
       
   206 			ECommit
       
   207 			};
       
   208 		TInt iStep;
       
   209 
       
   210 		// File index for the state machine in the ECopyFile step
       
   211 		TInt iCopyFileIndex;
       
   212 		// Component size will be calculated and set in the SCR
       
   213 		TInt64 iComponentSize; 
       
   214 		};
       
   215 
       
   216 // ===========================================================================================================
       
   217 
       
   218 	/**
       
   219 	A Reference Installer task that implements the 'Uninstall' SIF request.
       
   220 	*/
       
   221 	class CSifRefUninstallTask : public CSifTransportTask
       
   222 		{
       
   223 	public:
       
   224 		static CSifRefUninstallTask* NewL(TTransportTaskParams& aParams, TInstallerUIHandlerFactory aUiHandlerFactory);
       
   225 		virtual ~CSifRefUninstallTask();
       
   226 
       
   227 	protected:
       
   228 		virtual TBool ExecuteImplL();
       
   229 
       
   230 	private:
       
   231 		CSifRefUninstallTask(TTransportTaskParams& aParams);
       
   232 		void ConstructL(TInstallerUIHandlerFactory aUiHandlerFactory);
       
   233 
       
   234 		void GetFileListL();
       
   235 		TBool UnregisterAndDeleteFileL();
       
   236 		void CommitL();
       
   237 
       
   238 		// UI interaction
       
   239 		MInstallerUIHandler* iUiHandler;
       
   240 
       
   241 		// Installer's tools
       
   242 		RSoftwareComponentRegistry iScr;
       
   243 		RStsSession iSts;
       
   244 		
       
   245 		// Interstate data
       
   246 		RSoftwareComponentRegistryFilesList iFileList;
       
   247 
       
   248 		// The Uninstall task consists of the following steps
       
   249 		enum TUninstallSteps
       
   250 			{
       
   251 			EGetFileList = 1,
       
   252 			EUnregisterAndDeleteFile,
       
   253 			ECommit
       
   254 			};
       
   255 		TInt iStep;
       
   256 		};
       
   257 
       
   258 // ===========================================================================================================
       
   259 
       
   260 	/**
       
   261 	A Reference Installer task that implements the 'Activate' and 'Deactivate' SIF requests.
       
   262 	*/
       
   263 	class CSifRefActivateDeactivateTask : public CSifTransportTask
       
   264 		{
       
   265 	public:
       
   266 		CSifRefActivateDeactivateTask(TTransportTaskParams& aParams, TScomoState aScomoState);
       
   267 		virtual ~CSifRefActivateDeactivateTask();
       
   268 
       
   269 	protected:
       
   270 		virtual TBool ExecuteImplL();
       
   271 
       
   272 	private:
       
   273 		// Installer's tools
       
   274 		RSoftwareComponentRegistry iScr;
       
   275 
       
   276 		TScomoState iScomoState;
       
   277 		};
       
   278 
       
   279 	} // namespace Usif
       
   280 
       
   281 #endif // SIFREFINSTALLERTASK_H