secureswitools/swisistools/source/interpretsislib/rommanager.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2007-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 ROMMANAGER.H
       
    21  @internalComponent
       
    22  @released
       
    23 */
       
    24 #ifndef	ROMMANAGER_H
       
    25 #define	ROMMANAGER_H
       
    26 
       
    27 // System includes
       
    28 #include <istream>
       
    29 #include <list>
       
    30 #include <vector>
       
    31 #include <map>
       
    32 
       
    33 // User includes
       
    34 #include "symbiantypes.h"
       
    35 #include "parameterlist.h" 
       
    36 
       
    37 // Classes referenced
       
    38 class Options2;
       
    39 struct SBinarySecurityInfo;
       
    40 
       
    41 /**
       
    42  * @publishedPartner
       
    43  * @released
       
    44  */
       
    45 class RomManagerException 
       
    46     {
       
    47 public: // Enumerations
       
    48     enum TType
       
    49         {
       
    50         ETypeUnableToOpenCorrespondingOBY = 0,
       
    51         ETypeUnableToFindCorrespondingOBY,
       
    52         ETypeUnableToOpenLogFile		
       
    53         };
       
    54 
       
    55 public:
       
    56     inline RomManagerException( TType aType, const std::string& aFileName )
       
    57     :   iType( aType ), iFileName( aFileName )
       
    58         {
       
    59         }
       
    60 
       
    61 public:
       
    62     void Display() const;
       
    63 
       
    64 private:
       
    65     TType iType;
       
    66     const std::string iFileName;
       
    67     };
       
    68 
       
    69 
       
    70 /**
       
    71  * Abstract class to access ROM file details (file presence and security info).
       
    72  * 
       
    73  * @internalComponent
       
    74  * @released
       
    75  */
       
    76 class RomManager
       
    77 	{
       
    78 public:
       
    79 	// factory method to create derived class objects based on the user options  
       
    80     static RomManager* New(const CParameterList& aParamList);
       
    81     
       
    82 protected:
       
    83     RomManager();
       
    84 
       
    85 public:
       
    86 	// checks the specified file presense in the ROM
       
    87     virtual bool RomFileExists( const std::wstring& aFileName ) = 0;
       
    88 	
       
    89 	// returns security info of the file, if it is executable (zero returns)
       
    90     virtual TInt ReadSecurityInfo( SBinarySecurityInfo& aInfo, const std::wstring aFileName ) = 0;
       
    91 
       
    92 	// searches for all variants of an adorned file name
       
    93 	virtual void FindAllAdornedVariants(const std::wstring& aSearchNameWild, std::list<std::wstring>& aAdornedFileNamesFound) = 0;
       
    94     
       
    95 	// checks to see if the SID passed is owned by a binary in ROM
       
    96 	virtual bool SidExistsInRom(std::wstring& aFile, TUint32 aSid) = 0;
       
    97 	};
       
    98 
       
    99 /**
       
   100  * @internalComponent
       
   101  * @released
       
   102  */
       
   103 class RomEntry
       
   104     {
       
   105 public: // Enumerations
       
   106     enum TType
       
   107         {
       
   108         ETypeUndefined = 0,
       
   109         ETypeBinary,
       
   110         ETypeData
       
   111         };
       
   112 
       
   113 public: // Constructors & destructor
       
   114     RomEntry( const std::string& aSourceLogFile );
       
   115     ~RomEntry();
       
   116 
       
   117 public: // Access
       
   118     inline TType Type() const { return iType; }
       
   119     inline void SetType( TType aType ) { iType = aType; }
       
   120 
       
   121     inline std::string EnvFileName() const { return iEnvFileName; }
       
   122     inline void SetEnvFileName( std::string aFileName ) { iEnvFileName = aFileName; }
       
   123 
       
   124     inline std::string RomFileName() const { return iRomFileName; }
       
   125     inline void SetRomFileName( std::string aFileName ) { iRomFileName = aFileName; }
       
   126 
       
   127     inline TUint32 Uid1() const { return iUid1; }
       
   128     inline void SetUid1( TUint32 aUid ) { iUid1 = aUid; }
       
   129 
       
   130     inline TUint32 Uid2() const { return iUid2; }
       
   131     inline void SetUid2( TUint32 aUid ) { iUid2 = aUid; }
       
   132 
       
   133     inline TUint32 Uid3() const { return iUid3; }
       
   134     inline void SetUid3( TUint32 aUid ) { iUid3 = aUid; }
       
   135 
       
   136     inline SBinarySecurityInfo& SecurityInfo() { return *iSecInfo; }
       
   137     inline const SBinarySecurityInfo& SecurityInfo() const { return *iSecInfo; }
       
   138 
       
   139 private: // Data members
       
   140     const std::string& iSourceLogFile;
       
   141     TType iType;
       
   142     std::string iEnvFileName;
       
   143     std::string iRomFileName;
       
   144 	TUint32 iUid1;
       
   145 	TUint32 iUid2;
       
   146 	TUint32 iUid3;
       
   147 	SBinarySecurityInfo* iSecInfo;
       
   148     };
       
   149 
       
   150 
       
   151 // This class reads ROM drive details from the file system path provided.
       
   152 class RomManagerFileSystem : public RomManager
       
   153     {
       
   154 public:
       
   155     RomManagerFileSystem( const std::wstring& aPath );
       
   156 
       
   157 public: // From RomManager
       
   158     bool RomFileExists( const std::wstring& aFileName );
       
   159     TInt ReadSecurityInfo( SBinarySecurityInfo& aInfo, const std::wstring aFileName );
       
   160 	void FindAllAdornedVariants(const std::wstring& aSearchNameWild, std::list<std::wstring>& aAdornedFileNamesFound);
       
   161 	bool SidExistsInRom(std::wstring& aFile, TUint32 aSid);
       
   162 
       
   163 private:
       
   164     std::wstring iRomPath;
       
   165     };
       
   166 
       
   167 // This class reads ROM drive details from the .log & .oby files generated by rombuild tools.
       
   168 class RomManagerLogFiles : public RomManager
       
   169     {
       
   170 public:
       
   171     RomManagerLogFiles( const std::list<std::wstring>& aLogFileNames );
       
   172     ~RomManagerLogFiles();
       
   173 
       
   174 public: // From RomManager
       
   175     bool RomFileExists( const std::wstring& aFileName );
       
   176     TInt ReadSecurityInfo( SBinarySecurityInfo& aInfo, const std::wstring aFileName );
       
   177 	void FindAllAdornedVariants(const std::wstring& aSearchNameWild, std::list<std::wstring>& aAdornedFileNamesFound);
       
   178 	bool SidExistsInRom(std::wstring& aFile, TUint32 aSid);
       
   179 
       
   180 private: // Internal methods
       
   181     void ReadObyFile( const std::string& aFileName );
       
   182     void ProcessObyFileLine( const std::string& aFileName, std::string& aLine );
       
   183     //
       
   184     bool ReadLogFile( const std::string& aFileName );
       
   185     void ProcessLogFileLine( std::string& aLine, RomEntry*& aCurrentEntry, const std::string& aFileName, bool& aObyParsingRequired );
       
   186 
       
   187 private: // Type definitions
       
   188     typedef std::map< std::string /* file name */, RomEntry* /* associated data */ > RomEntryMap;
       
   189 
       
   190 private: // Data members
       
   191     RomEntryMap iEntriesIndexedByEnvFileName;
       
   192     RomEntryMap iEntriesIndexedByRomFileName;
       
   193     std::list<std::wstring> iLogFileNames;
       
   194     };
       
   195 
       
   196 // This class is empty holder, used when user selects Z drive eclipsing checks disable option
       
   197 class RomManagerEmpty : public RomManager
       
   198     {
       
   199 
       
   200 public: // From RomManager
       
   201     bool RomFileExists( const std::wstring& aFileName );
       
   202     TInt ReadSecurityInfo( SBinarySecurityInfo& aInfo, const std::wstring aFileName );
       
   203 	void FindAllAdornedVariants(const std::wstring& aSearchNameWild, std::list<std::wstring>& aAdornedFileNamesFound);
       
   204 	bool SidExistsInRom(std::wstring& aFile,TUint32 aSid);
       
   205 
       
   206     };
       
   207 
       
   208 #endif