secureswitools/swisistools/source/dumpsislib/dumpsis.h
changeset 4 32704c33136d
child 26 04d4a7bbc3e0
equal deleted inserted replaced
-1:000000000000 4:32704c33136d
       
     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 *
       
    16 */
       
    17 
       
    18 
       
    19 /**
       
    20  @file 
       
    21  @publishedPartner
       
    22  @released
       
    23 */
       
    24 
       
    25 #ifndef	__DUMPSIS_H__
       
    26 #define	__DUMPSIS_H__
       
    27 
       
    28 #include "siscontents.h"
       
    29 #include "sisinstallblock.h"
       
    30 
       
    31 /**
       
    32  * Structure to hold file description and the capability
       
    33  * verification result. File description of an executable
       
    34  * will have a capability, the iCapVerified field is filled
       
    35  * after verifying this capability against the files actual
       
    36  * capability. Actual capability is extracted from the file 
       
    37  * itself/
       
    38  */
       
    39 typedef struct
       
    40 	{
       
    41 	const CSISFileDescription*	iFileDesc;
       
    42 	int							iActualCap;
       
    43 	bool						iCapVerified;
       
    44 	} TFileCapTest;
       
    45 
       
    46 typedef std::vector<TFileCapTest> TFileCapTestList;
       
    47 
       
    48 class CDumpSis
       
    49 	{
       
    50 public:
       
    51 	enum TExtractionLevel
       
    52 		{
       
    53 		ENone,
       
    54 		EOnlyPackage,		// Extracts package file for the SIS file.
       
    55 		ECertificates,		// Exracts all the certificates present in the SIS.
       
    56 		EBaseFiles,			// Extract all files present in the SIS (excluding files of embedded SIS)
       
    57 		EAllDataFiles,		// Extract all files including those present in the embedded SIS.
       
    58 		EAllButCerts,		// EAllFiles + Embedded SIS files and their packages
       
    59 		EEverything,		// EAllButCerts + certificates
       
    60 		};
       
    61 public:
       
    62 	/**
       
    63 	 * Constructor will take sis file name as input. It will load the file 
       
    64 	 * in memory for future operation. In case of an invalid SIS the 
       
    65 	 * constructor will throw an exception.
       
    66 	 */
       
    67 	explicit CDumpSis(const std::wstring& aSISFileName, bool aVerbose = false);
       
    68 	/**
       
    69 	 * Desctructor. Will delete or free the owned resources.
       
    70 	 */
       
    71 	~CDumpSis();
       
    72 	
       
    73 public:
       
    74 	/**
       
    75 	 * This function will create the package file for the SIS file.
       
    76 	 * @param Name of the package file to be created.
       
    77 	 */
       
    78 	void CreatePackage(const std::wstring& aPkgFileName);
       
    79 	/**
       
    80 	 * This function will generate package file for a specific controller.
       
    81 	 * @param aSisController controller for which the package file needs to be generated.
       
    82 	 * @param aPkgFileName Name of the package file to be created.
       
    83 	 */
       
    84 	void CreatePackage(const CSISController& aSisController, const std::wstring& aPkgFileName);
       
    85 	/**
       
    86 	 * This will extract contents of the SIS file based on the extraction level provided.
       
    87 	 * Please refer TExtractionLevel for details.
       
    88 	 * @param aTargetDir Directory to which the contents to be extracted.
       
    89 	 * @param aLevel Tells the function how much content needs to be extracted.
       
    90 	 */
       
    91 	void ExtractFiles(const std::wstring& aTargetDir, TExtractionLevel aLevel);
       
    92 	/**
       
    93 	 * This function will extract files belonging to a specified controller.
       
    94 	 * @param aSisController Controller whose files need to be extracted.
       
    95 	 * @param aTargetDir Directory to which the files need to be extracted.
       
    96 	 * @param aBaseIndex Absolute DataUnit index of the parent controller.
       
    97 	 */
       
    98 	void ExtractFiles(const CSISController& aSisController, const std::wstring& aTargetDir, int aBaseIndex = 0);
       
    99 	/**
       
   100 	 * Extract the package to a specified directory.
       
   101 	 * @param aTargetDir Directory to which the package file needs to be extracted.
       
   102 	 */ 
       
   103 	void ExtractBasePackageFile(const std::wstring& aTargetDir);
       
   104 	/**
       
   105 	 * Extract all the certificate chains present in the sis file.
       
   106 	 * @param aTargetDir Destination folder.
       
   107 	 */ 
       
   108 	void ExtractAllCertificates(const std::wstring& aTargetDir);
       
   109 	/**
       
   110 	 * Extract all the certificate chains present in the passed controller
       
   111 	 * @param aSisController Controller whose ceritificates needs to be extracted.
       
   112 	 * @param aTargetDir Destination folder.
       
   113 	 */
       
   114 	void ExtractCertificates(const CSISController& aSisController, const std::wstring& aTargetDir);
       
   115 	/**
       
   116 	 * Verify the capabilites stored in file descrition agains the capability extracted
       
   117 	 * from the file content. Return the list of all files will capability verificaton.
       
   118 	 * @param aFileList List of files.
       
   119 	 */
       
   120 	void GetCapVerifiedFileList(TFileCapTestList& aFileList);
       
   121 	
       
   122 private:
       
   123 	void CreateTargetDir(std::wstring& aTargetDir);
       
   124 	void CreateDirectoriesRecursively(std::wstring aTargetDir);
       
   125 	void SisFileNameToPkgFileName(std::wstring& aFileName);
       
   126 	void CreateEmbeddedSis(const std::wstring& aFileName, CSISController& aController, int aStart, int aEnd);
       
   127 	void ExtractNestedSisFile(	const std::wstring& aTargetDir, 
       
   128 								const CSISController& aController, 
       
   129 								bool aExtractSis,
       
   130 								int aStartIndex, 
       
   131 								int aEndIndex);
       
   132 
       
   133 private:
       
   134 	CDumpSis(const CDumpSis&){}
       
   135 	CDumpSis& operator=(const CDumpSis&){return *this;}
       
   136 	
       
   137 private: //Private Member Variables
       
   138 	CSISContents	iSisContents;
       
   139 	CSISController*	iController;
       
   140 	std::wstring	iSisFileName;
       
   141 	TBool			iVerbose;
       
   142 	TBool			iIsStub;
       
   143 	};
       
   144 
       
   145 #endif	// __DUMPSIS_H__