secureswitools/swisistools/source/interpretsislib/sisregistry.h
changeset 0 ba25891c3a9e
child 24 5cc91383ab1e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2006-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 * SisRegistry - All operations related to the registry.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file 
       
    22  @released
       
    23  @internalComponent
       
    24 */
       
    25 
       
    26 #ifndef	SISREGISTRY_H
       
    27 #define	SISREGISTRY_H
       
    28 
       
    29 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
    30 
       
    31 class DbHelper;
       
    32 #include "../xmlparser/xmlparser.h"
       
    33 
       
    34 #endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
    35 #include <vector>
       
    36 #include <string>
       
    37 #include <map>
       
    38 #include <list>
       
    39 
       
    40 #include "siscontroller.h"
       
    41 #include "symbiantypes.h"
       
    42 #include "installablefile.h"
       
    43 #include "parameterlist.h"
       
    44 #include "sisregistryobject.h"
       
    45 
       
    46 
       
    47 // Forward Declarations
       
    48 class SisRegistryPackage;
       
    49 class HashContainer;
       
    50 class SisRegistryObject;
       
    51 class SisFile;
       
    52 class RomManager;
       
    53 class ConfigManager;
       
    54 class CSISController;
       
    55 
       
    56 class SisRegistry
       
    57 	{
       
    58 public: // Constructor & destructor
       
    59 	SisRegistry( CParameterList& aParamList, RomManager& aRomManager, ConfigManager& aConfigManager);
       
    60 	~SisRegistry();
       
    61 
       
    62 public: // API
       
    63 	TBool IsInstalled(TUint32 aUid) const;
       
    64 	const SisRegistryPackage& SidToPackage(TUint32 aSid);
       
    65 	void SidToFileName(TUint32 aSid, std::wstring& aFileName);
       
    66 	bool SidExists(TUint32 aSid) const;
       
    67 	const SisRegistryObject& GetRegistryObject(TUint32 aUid) const;
       
    68 	SisRegistryObject* GetRegistryObjectPtr(TUint32 aUid);
       
    69 	void RemoveEntry(const TUint32 aUid, const std::wstring& aPackageName, const std::wstring& aVendorName);
       
    70 	void RemovePkg(const TUint32& aUid, bool aDeleteRomStub = false);
       
    71 	void RemovePkgLegacy(const TUint32& aUid, bool aDeleteRomStub = false);
       
    72 	
       
    73 	void AddRegistryEntry(const SisFile& aSis, const InstallableFiles& aFiles,
       
    74 							const InstallSISFile& aInstallSISFile);
       
    75 	void UpdateRegistryEntry(const SisFile& aSis, const InstallableFiles& aFiles,
       
    76 							const InstallSISFile& aInstallSISFile);
       
    77 	const SisRegistryObject* OwningPackage(const std::wstring& aFileName, TUint32& aUid) const;
       
    78 	void RemoveBackupLst();
       
    79 	bool IsRomStubPackage(const TUint32 aUid);
       
    80 	void GetStubFileEntries(const TUint32 aUid, std::list<std::wstring>& aFilesEntries);
       
    81 	void GenerateStubRegistry();
       
    82 	int GetAugmentationsNumber(TUint32 aUid);
       
    83 	CSISController* GetStubController(const TUint32 aUid);
       
    84 
       
    85 	static const int KSisRegistryMajorVersion;
       
    86 	static const int KSisRegistryMinorVersion;
       
    87 	static const std::string KRegistryV40string;
       
    88 	static const std::string KRegistryV50string;
       
    89 	static const std::string KRegistryV51string;
       
    90 	static const std::string KRegistryV52string;
       
    91 	static const std::string KRegistryV53string;
       
    92 	static const std::string KRegistryV54string;
       
    93 
       
    94 private: // Internal methods
       
    95     void ReadStubs( const std::wstring& aDirectory );
       
    96     void ReadRegistry( const std::wstring& aRegistryBasePath );
       
    97 	CSISController* GetStubControllerInDir( const std::wstring& aDirectory, const TUint32 aUid);
       
    98 	CSISController* ReadStubController( const wchar_t* aFilename );
       
    99 	void GenerateRegistryEntry(SisRegistryObject& aObj, const SisFile& aSis);
       
   100 	void ExtractRegistryFiles(const std::wstring& path);
       
   101 	void RemoveInstalledFiles(const FileDescriptions& aFileDes, std::wstring& aLocalPath);
       
   102 	void GenerateStubRegistry(SisRegistryObject* aSisRegistryObject, CSISController* aSisController);
       
   103 	void SetNextIndex(SisRegistryObject& aObj) const;
       
   104 	std::wstring GetRegistryDir( const std::wstring& aDrivePath, TUint32 aUid  ) const;
       
   105 	void GenerateRegFile(SisRegistryObject& aObj) const;
       
   106 	void GenerateCtlFile(SisRegistryObject& aObj, const SisFile& aSis) const;
       
   107 
       
   108 public:
       
   109 	TUint32 GetUid(TUint32 aSid) const;
       
   110 	TUint32 GetUid(const std::wstring& aSidFile) const;
       
   111 	bool GetInRom(TUint32 aUid) const;
       
   112 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   113 	const DbHelper* GetDbHelper() const;	
       
   114 #endif
       
   115 
       
   116 private: // Utility functions
       
   117     static bool IsPackageDir( const std::wstring& aString );
       
   118 	void ReadSisRegistryVersion();
       
   119 	void FindMarkerAndSetVersion(const std::wstring& aPath);
       
   120 	TBool IsSisValid(const std::wstring& aStubPath);
       
   121 	bool IsFileWideCard(const std::wstring& aFileName);
       
   122 
       
   123 private: // Friends
       
   124 	friend struct Contains;
       
   125 
       
   126 private: // Type definitions
       
   127 	typedef std::multimap<TUint32, SisRegistryObject*> EntryMap;
       
   128 
       
   129 private: // Constants
       
   130 	static const std::wstring KPathToRegistry;
       
   131 	static const std::wstring KPathToRomStubs;
       
   132 	static const std::wstring KPathToRegistryVersionMarker;
       
   133 	static const std::wstring KSisRegistryVersion;
       
   134 	// SisRegistry versions
       
   135 	static const std::wstring KRegistryFormat;
       
   136 	static const std::wstring KRegistryV40;
       
   137 	static const std::wstring KRegistryV51;
       
   138 	static const std::wstring KRegistryV52;
       
   139 	static const std::wstring KRegistryV53;
       
   140 	static const std::wstring KRegistryV54;
       
   141 	static const std::wstring KRomStubDir;
       
   142 	static const std::wstring KRomRegistryVersionMarker;
       
   143 
       
   144 private: // Data members
       
   145 	std::wstring	iCDrive;
       
   146 	TInt			iSystemDrive;
       
   147     CParameterList& iParamList;
       
   148     RomManager& iRomManager;
       
   149 	ConfigManager& iConfigManager;
       
   150 	EntryMap iEntries;
       
   151 
       
   152 
       
   153 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   154 private:
       
   155 	// internal methods for accessing database
       
   156 	void RemovePkgWithScr(TUint32 aUid, bool aSkipRomStub=false);
       
   157 	
       
   158 
       
   159 private:
       
   160 	XmlDetails::TScrPreProvisionDetail::TComponent CreateRegistryEntry(const SisRegistryObject& aSisRegistryObject);
       
   161 	
       
   162 	// specific methods for adding SisRegistryObject
       
   163 	void AddLocalizedNames	(	XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, 
       
   164 									const SisRegistryObject& aSisRegistryObject
       
   165 								);
       
   166 
       
   167 	
       
   168 	void AddComponentDependencies	(	XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, 
       
   169 										const SisRegistryObject& aSisRegistryObject 
       
   170 									);
       
   171 
       
   172 	void AddEmbeddedPackages	(	XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, 
       
   173 									const std::vector<SisRegistryPackage*>& aEmbeddedPackages 
       
   174 								);
       
   175 	
       
   176 	void AddProperties	(	XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, 
       
   177 							const std::vector<SisRegistryProperty*>& aProperties 
       
   178 						);
       
   179 	
       
   180 	void AddFileDescription	(	XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, 
       
   181 								const std::vector<FileDescription*>& aFileDescription 
       
   182 							);
       
   183 	
       
   184 	void AddFileDescriptionAsFileProperty	(	XmlDetails::TScrPreProvisionDetail::TComponentFile& aComponentFile, 
       
   185 												const FileDescription* aFileDescription
       
   186 											);
       
   187 
       
   188 	void AddTrustStatus	(	XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, const TrustStatus& aTrustStatus );
       
   189 
       
   190 	void AddInstallChainIndices	(	XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, 
       
   191 									const std::vector<TInt>& aInstallChainIndices 
       
   192 								);
       
   193 	
       
   194 	// specific methods for adding SisRegistryToken
       
   195 	void AddSisRegistryToken	(	XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, 
       
   196 									const SisRegistryToken& aSisRegistryToken 
       
   197 								);
       
   198 
       
   199 	void AddControllerInfo	(	XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, 
       
   200 								const std::vector<ControllerInfo*>& aControllerInfo 
       
   201 							);
       
   202 
       
   203 	void AddHashContainer	(	XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, 
       
   204 								const HashContainer& aHashContainer,
       
   205 								int aCount
       
   206 							);
       
   207 
       
   208 	void AddVersion	(	XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, 
       
   209 						const Version& aVersion
       
   210 					);
       
   211 
       
   212 	// specific methods for adding SisRegistryPackage
       
   213 	void AddSisRegistryPackage	(	XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, 
       
   214 									const SisRegistryPackage& aSisRegistryPackage,
       
   215 									int aLanguage
       
   216 								);
       
   217 
       
   218 
       
   219 	// physical schema methods
       
   220 	XmlDetails::TScrPreProvisionDetail::TComponentProperty CreateComponentProperty	(	const std::wstring& aPropName, 
       
   221 																						const std::wstring& aPropValue, 
       
   222 																						bool aIsInt, 
       
   223 																						bool aIsStr8Bit,
       
   224 																						int aLocale=CSISLanguage::ELangTest 
       
   225 																					);
       
   226 
       
   227 	void AddComponentProperty	(	XmlDetails::TScrPreProvisionDetail::TComponent& aComponent,
       
   228 									const std::wstring& aPropName,
       
   229 									int aPropValue,
       
   230 									int aCount
       
   231 								);
       
   232 
       
   233 	void AddComponentProperty	(	XmlDetails::TScrPreProvisionDetail::TComponent& aComponent,
       
   234 									const std::wstring& aPropName,
       
   235 									const std::wstring& aPropValue,
       
   236 									int aCount,
       
   237 									bool aIsBinary
       
   238 								);
       
   239 
       
   240 	void AddFileProperty	(	XmlDetails::TScrPreProvisionDetail::TComponentFile& aComponentFile,
       
   241 								const std::wstring& aPropName,
       
   242 								const std::wstring& aPropValue,
       
   243 								bool aIsBinary
       
   244 							);
       
   245 
       
   246 	void AddFileProperty	(	XmlDetails::TScrPreProvisionDetail::TComponentFile& aComponentFile,
       
   247 								const std::wstring& aPropName,
       
   248 								int aPropValue,
       
   249 								bool aIsBinary
       
   250 							);
       
   251 
       
   252 	// other helper methods
       
   253 	
       
   254 
       
   255 	std::wstring FormatVersionToString( const Version& aVersion );
       
   256 
       
   257 	std::string GetEpocRoot();
       
   258 
       
   259 	void UpdateInstallationInformation(XmlDetails::TScrPreProvisionDetail aScrPreProvisionDetail);
       
   260 	
       
   261 	void GenerateDbRegistryEntry(const SisRegistryObject& aSisRegistryObject, bool aOriginVerified);
       
   262 
       
   263 	std::string GetDbPath();
       
   264 
       
   265 	std::wstring GetGlobalId( TUint32 aUid , TInt aInstallType, std::wstring aPackageName);
       
   266 
       
   267 	void SetOriginVerification(XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, bool aOriginVerified);
       
   268 private:
       
   269 	DbHelper* iDbHelper;
       
   270 
       
   271 	static const std::wstring NativeSoftwareType;
       
   272 
       
   273 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   274 	
       
   275 };
       
   276 
       
   277 #endif	/* SISREGISTRY_H */
       
   278