secureswitools/swisistools/source/sisxlibrary/sisfiledescription.h
changeset 0 ba25891c3a9e
child 26 04d4a7bbc3e0
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 * Note: This file may contain code to generate corrupt files for test purposes.
       
    16 * Such code is excluded from production builds by use of compiler defines;
       
    17 * it is recommended that such code should be removed if this code is ever published publicly.
       
    18 * As specified in SGL.GT0188.251
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 /**
       
    24  @file 
       
    25  @publishedPartner
       
    26  @released
       
    27 */
       
    28 
       
    29 #ifndef __SISFILEDESCRIPTION_H__
       
    30 #define __SISFILEDESCRIPTION_H__
       
    31 
       
    32 #include "sisstring.h"
       
    33 #include "sishash.h"
       
    34 #include "siscapabilities.h"
       
    35 #include "numeric.h"
       
    36 
       
    37 class CSISData;
       
    38 class CSISDataUnit;
       
    39 
       
    40 #define SYSTEMDRIVE		'$'
       
    41 
       
    42 typedef struct {
       
    43 	wchar_t*		iName;
       
    44 } SKeyword1;
       
    45 
       
    46 class CSISFileDescription : public CStructure <CSISFieldRoot::ESISFileDescription>
       
    47 	{
       
    48 public:
       
    49 	/**
       
    50 	 * Enumeration to specify various file operation.
       
    51 	 */
       
    52 	typedef enum 
       
    53 		{
       
    54 		EOpNone = 0,
       
    55 		EOpInstall = 1,
       
    56 		EOpRun = 2,
       
    57 		EOpText = 4,
       
    58 		EOpNull = 8,
       
    59 		EOpIllegal = 16
       
    60 		} TSISFileOperation;
       
    61 
       
    62 	/**
       
    63 	 * Enumeration to specify various installation options
       
    64 	 */ 
       
    65 	typedef enum 
       
    66 		{
       
    67 		EInstFileNone =						0,
       
    68 
       
    69 		//EOpRun Options
       
    70 		EInstFileRunOptionInstall =			1 << 1,		// Run at installation
       
    71 		EInstFileRunOptionUninstall =		1 << 2,		// Run at uninstallation
       
    72 		EInstFileRunOptionByMimeType =		1 << 3,		// Run using MIME type
       
    73 		EInstFileRunOptionWaitEnd =			1 << 4,		// Wait for end before continuing
       
    74 		EInstFileRunOptionSendEnd =			1 << 5,		// Terminate after (un)install ends
       
    75 		EInstFileRunOptionBeforeShutdown=	1 << 6,		// Run at uninstallation , before any running applications are shut down.
       
    76 		EInstFileRunOptionAfterInstall=		1 << 7,		// Run after install	
       
    77 
       
    78 		//EOpText Options
       
    79 		EInstFileTextOptionContinue	= 		1 << 9,		// Continue button
       
    80 		EInstFileTextOptionSkipIfNo	=		1 << 10,	// Yes/No - skip next file if user selects no	
       
    81 		EInstFileTextOptionAbortIfNo =		1 << 11,	// Yes/No - abort       install if user selects no
       
    82 		EInstFileTextOptionExitIfNo	=		1 << 12,	// Yes/No - uninstall if user selects no
       
    83 		EInstFileTextOptionForceAbort =		1 << 13,	// Continue button .Installation aborts. 
       
    84 
       
    85 		EInstVerifyOnRestore =				1 << 15		// Verify on Restore
       
    86 
       
    87 		} TSISInstOption;
       
    88 
       
    89 public:
       
    90 	/** 
       
    91 	 * Default constructor
       
    92 	 */
       
    93 	CSISFileDescription ();
       
    94 	/**
       
    95 	 * Copy constructor.
       
    96 	 */
       
    97 	CSISFileDescription (const CSISFileDescription& aInitialiser);
       
    98 	
       
    99 public:
       
   100 	/**
       
   101 	 * Fix minor issues with the structure.
       
   102 	 */
       
   103 	virtual void MakeNeat ();
       
   104 	/**
       
   105 	 * This function verifies the structure
       
   106 	 * @param aLanguage - language
       
   107 	 */ 
       
   108 	virtual void Verify (const TUint32 aLanguages) const;
       
   109 	/**
       
   110 	 * @return name of the class.
       
   111 	 */
       
   112 	virtual std::string Name () const;
       
   113 #ifdef GENERATE_ERRORS
       
   114 	virtual void CreateDefects ();
       
   115 #endif // GENERATE_ERRORS
       
   116 
       
   117 	/**
       
   118 	 * Set MIME type of the last file of the base controller's install block.
       
   119 	 * @param aMimeType MIME type
       
   120 	 */
       
   121 	void SetMimeType (const std::wstring& aMimeType);
       
   122 	/**
       
   123 	 * Set the target for this file
       
   124 	 * @param aTarget new taret location for this file.
       
   125 	 */
       
   126 	void SetTarget (const std::wstring& aTarget);
       
   127 	/**
       
   128 	 * Sets the new file operation.
       
   129 	 * @param new file operation.
       
   130 	 */
       
   131 	void SetOperation (const TUint32 aOperation);
       
   132 	/**
       
   133 	 * Sets the new file options.
       
   134 	 * @param new file options.
       
   135 	 */
       
   136 	void SetOptions (const TUint32 aOperationOptions);
       
   137 	/**
       
   138 	 * Sets the file index of this file. Its an index into the data unit.
       
   139 	 * @param aFileIndex new file index to be set.
       
   140 	 */
       
   141 	void SetFileIndex (const TUint32 aFileIndex);
       
   142 	/**
       
   143 	 * Set compressed and uncompressed lengths of this file.
       
   144 	 * @param aUncompressed uncompressed size
       
   145 	 * @param aCompressed compressed size
       
   146 	 */
       
   147 	void SetLengths (const TUint64 aUncompressed, const TUint64 aCompressed);
       
   148 	/**
       
   149 	 * Checks if the file has a MIME type or not.
       
   150 	 * @return true for success else false
       
   151 	 */
       
   152 	bool HasMimeType () const;
       
   153 	/**
       
   154 	 * Sets the hash of the file.
       
   155 	 * @param aHash new hash value
       
   156 	 */
       
   157 	void SetHash (const CSISHash& aHash);
       
   158 
       
   159 	/**
       
   160 	 * @return File index of the file.
       
   161 	 */
       
   162 	TUint32 FileIndex() const;
       
   163 	/**
       
   164 	 * @return file operation (TSISFileOperation).
       
   165 	 */
       
   166 	CSISFileDescription::TSISFileOperation Operation() const;
       
   167 	/**
       
   168 	 * @return file options (TSISInstOption).
       
   169 	 */
       
   170 	CSISFileDescription::TSISInstOption OperationOptions() const;
       
   171 	/**
       
   172 	 * @return file length
       
   173 	 */
       
   174 	CSISUInt64&	Length() const;
       
   175 	/**
       
   176 	 * @return uncompressed file length
       
   177 	 */
       
   178 	CSISUInt64&	UncompressedLength() const;
       
   179 	/**
       
   180 	 * @return Hash of the file.
       
   181 	 */
       
   182 	CSISHash& Hash() const;
       
   183 	/**
       
   184 	 * @return Target location of the file.
       
   185 	 */
       
   186 	inline const CSISString& Target() const;
       
   187 	/**
       
   188 	 * @return File MIME type.
       
   189 	 */
       
   190 	inline const CSISString& MimeType() const;
       
   191 	/**
       
   192 	 * Converts the string into installation option (only if its valid) and sets the
       
   193 	 * option to this file.
       
   194 	 * @param aOption installation option string.
       
   195 	 * @return returns the installation option
       
   196 	 */
       
   197 	TSISInstOption InterpretOption (const std::wstring& aOption);
       
   198 	/**
       
   199 	 * Sets the hash of the file.
       
   200 	 * @param aHash hash value
       
   201 	 * @param aHashSize size of hash
       
   202 	 */
       
   203 	void SetHash(const TUint8* aHash, TUint32 aHashSize);
       
   204 	/**
       
   205 	 * Extracts capabilities of this file.
       
   206 	 * @param file name whose capabilities need to be retieved.
       
   207 	 */
       
   208 	void ExtractCapabilities(const std::wstring& aFileName);
       
   209 	/**
       
   210 	 * Retrieves the file name
       
   211 	 */
       
   212 	const wchar_t* GetFileName() const;
       
   213 	/**
       
   214 	 * Adds package entry related to the file description.
       
   215 	 * @param aStream stream into which the package details need to be written.
       
   216 	 * @param aVerbose If this option is set then detail description of pkg
       
   217 	 * 			will be written into the stream.
       
   218 	 */
       
   219 	void AddPackageEntry(std::wostream& aStream, bool aVerbose) const;
       
   220 	/**
       
   221 	 * Retrieves the capability list associated with this sis file.
       
   222 	 * @param aCapList list to be filled by this function.
       
   223 	 */
       
   224 	inline void GetCapabilityList(std::vector<std::wstring>& aCapList) const;
       
   225 	/**
       
   226 	 * Retrieves the capability list associated with this sis file.
       
   227 	 * @return capability list in number format.
       
   228 	 */
       
   229 	inline TUint32 Capabilities() const;
       
   230 	
       
   231 private:
       
   232 	void InsertMembers ();
       
   233 
       
   234 private:
       
   235 	CSISString			iTarget;
       
   236 	CSISString			iMimeType;
       
   237 	CSISCapabilities	iCapabilities;
       
   238 	CSISHash			iHash;
       
   239 	CSISUInt32			iOperation;
       
   240 	CSISUInt32			iOperationOptions;
       
   241 	CSISUInt64			iLength;
       
   242 	CSISUInt64			iUncompressedLength;
       
   243 	CSISUInt32			iFileIndex;
       
   244 	};
       
   245 
       
   246 
       
   247 inline CSISFileDescription::TSISInstOption operator | (const CSISFileDescription::TSISInstOption aLHS, const CSISFileDescription::TSISInstOption aRHS)
       
   248 	{
       
   249 		return static_cast <CSISFileDescription::TSISInstOption> (static_cast <TUint32> (aLHS) | static_cast <TUint32> (aRHS));
       
   250 	}
       
   251 
       
   252 
       
   253 inline CSISFileDescription::CSISFileDescription ()
       
   254 	{ 
       
   255 	InsertMembers (); 
       
   256 	}
       
   257 
       
   258 
       
   259 inline void CSISFileDescription::SetMimeType (const std::wstring& aMimeType)
       
   260 	{ 
       
   261 	iMimeType = aMimeType; 
       
   262 	}
       
   263 
       
   264 
       
   265 inline void CSISFileDescription::SetTarget (const std::wstring& aTarget)
       
   266 	{ 
       
   267 	iTarget = aTarget; 
       
   268 	}
       
   269 
       
   270 
       
   271 inline void CSISFileDescription::SetOperation (const TUint32 aOperation)
       
   272 	{ 
       
   273 	iOperation |= aOperation; 
       
   274 	}
       
   275 
       
   276 
       
   277 inline void CSISFileDescription::SetOptions (const TUint32 aOperationOptions)
       
   278 	{ 
       
   279 	iOperationOptions |= aOperationOptions; 
       
   280 	}
       
   281 
       
   282 
       
   283 inline void CSISFileDescription::SetFileIndex (const TUint32 aFileIndex)
       
   284 	{ 
       
   285 	iFileIndex = aFileIndex; 
       
   286 	}
       
   287 
       
   288 
       
   289 inline void CSISFileDescription::SetLengths (const TUint64 aUncompressed, const TUint64 aCompressed)
       
   290 	{
       
   291 	iLength = aCompressed;
       
   292 	iUncompressedLength = aUncompressed;
       
   293 	}
       
   294 
       
   295 inline bool CSISFileDescription::HasMimeType () const
       
   296 	{
       
   297 	return ! iMimeType.empty ();
       
   298 	}
       
   299 
       
   300 inline TUint32 CSISFileDescription::FileIndex() const
       
   301 	{
       
   302 	return iFileIndex.Value();
       
   303 	}
       
   304 
       
   305 inline CSISFileDescription::TSISFileOperation CSISFileDescription::Operation() const
       
   306 	{
       
   307 	return (CSISFileDescription::TSISFileOperation)(int)iOperation;
       
   308 	}
       
   309 
       
   310 inline CSISFileDescription::TSISInstOption CSISFileDescription::OperationOptions() const
       
   311 	{
       
   312 	return (CSISFileDescription::TSISInstOption)(int)iOperationOptions;
       
   313 	}
       
   314 
       
   315 inline CSISUInt64& CSISFileDescription::Length() const
       
   316 	{
       
   317 	return (CSISUInt64&)iLength;
       
   318 	}
       
   319 
       
   320 inline CSISUInt64& CSISFileDescription::UncompressedLength() const
       
   321 	{
       
   322 	return (CSISUInt64&)iUncompressedLength;
       
   323 	}
       
   324 
       
   325 inline CSISHash& CSISFileDescription::Hash() const
       
   326 	{
       
   327 	return (CSISHash&)iHash;
       
   328 	}
       
   329 
       
   330 inline const CSISString& CSISFileDescription::Target() const
       
   331 	{
       
   332 	return iTarget;
       
   333 	}
       
   334 
       
   335 inline const CSISString& CSISFileDescription::MimeType() const
       
   336 	{
       
   337 	return iMimeType;
       
   338 	}
       
   339 
       
   340 inline void CSISFileDescription::GetCapabilityList(std::vector<std::wstring>& aCapList) const
       
   341 	{
       
   342 	iCapabilities.GetCapabilityList(aCapList);
       
   343 	}
       
   344 
       
   345 inline TUint32 CSISFileDescription::Capabilities() const
       
   346 	{
       
   347 	return iCapabilities.Capabilities();
       
   348 	}
       
   349 
       
   350 #endif // __SISFILEDESCRIPTION_H__
       
   351