sl@0: // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Store/Load database system settings (database settings, security policies) sl@0: // sl@0: // sl@0: sl@0: #ifndef __SQLSRVDBSYSSETTINGS_H__ sl@0: #define __SQLSRVDBSYSSETTINGS_H__ sl@0: sl@0: #include "SqlAssert.h" // ESqlPanicInternalError sl@0: #include "SqlUtil.h" // TSqlCompactionMode sl@0: sl@0: //Forward declarations sl@0: struct sqlite3; sl@0: struct sqlite3_stmt; sl@0: class CSqlSecurityPolicy; sl@0: class TSqlSrvFileData; sl@0: class RFs; sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: ////////////////////////////// TSqlDbSysSettings class //////////////////////////////////////// sl@0: ////////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: /** sl@0: Stores database system settings to database system settings table. sl@0: Stores database security policies to database security policy table. sl@0: Loads database system settings from database system settings table. sl@0: Loads database security policies from database security policy table. sl@0: Reindexes a database that is being 'Open'ed or 'Attach'ed if the collation sl@0: dll has changed, and updates the system settings table with the new dll name. sl@0: Configures a database that is being 'Open'ed according to the operations sl@0: specified in its configuration file, if such a file exists and has not yet sl@0: been processed, and updates the system settings table with the version of sl@0: the file that was processed. sl@0: sl@0: @internalComponent sl@0: */ sl@0: NONSHARABLE_CLASS(TSqlDbSysSettings) sl@0: { sl@0: public: sl@0: TSqlDbSysSettings(sqlite3* aDbHandle); sl@0: sl@0: void StoreSecurityPolicyL(const CSqlSecurityPolicy& aSecurityPolicyCon); sl@0: void StoreSettingsL(const TDesC& aDbName, const TDesC& aCollationDllName, TInt aDbConfigFileVersion, TSqlCompactionMode aCompactionMode); sl@0: sl@0: void LoadSecurityPolicyL(CSqlSecurityPolicy& aSecurityPolicyCon); sl@0: void LoadSettingsL(const TDesC& aDbName, TDes& aCollationDllName, TInt& aDbConfigFileVersion, TSqlCompactionMode& aCompactionMode); sl@0: sl@0: void ReindexDatabaseL(const TDesC& aDbName, const TDesC& aCurrentCollationDllName); sl@0: void ConfigureDatabaseL(TInt aStoredDbConfigFileVersion, const TSqlSrvFileData& aFileData, const TDesC& aDbName); sl@0: sl@0: private: sl@0: void StoreSecurityPoliciesL(const CSqlSecurityPolicy& aSecurityPolicyCon); sl@0: void StoreSecurityPolicyL(sqlite3_stmt* aStmtHandle, TInt aObjType, const TDesC& aObjName, sl@0: TInt aPolicyType, const TSecurityPolicy& aPolicy); sl@0: TInt BindSecurityPolicyPrm(sqlite3_stmt* aStmtHandle, TInt aObjType, const TDesC& aObjName, sl@0: TInt aPolicyType, const TSecurityPolicy& aPolicy); sl@0: TSecurityPolicy ReadCurrSecurityPolicyL(sqlite3_stmt* aStmtHandle, TInt& aObjType, TPtrC& aObjName, TInt& aPolicyType); sl@0: void StoreDefaultSecurityPolicy(CSqlSecurityPolicy& aSecurityPolicyCon, const TSecurityPolicy& aPolicy, TInt aDbPolicySetFlag); sl@0: void StoreDbSecurityPolicyL(CSqlSecurityPolicy& aSecurityPolicyCon, TInt aPolicyType, sl@0: const TSecurityPolicy& aPolicy, TInt& aDbPolicySetFlag); sl@0: void StoreDbObjSecurityPolicyL(CSqlSecurityPolicy& aSecurityPolicyCon, TInt aObjType, const TDesC& aObjName, sl@0: TInt aPolicyType, const TSecurityPolicy& aPolicy); sl@0: sl@0: void GetSettingsL(const TDesC& aDbName, TDes& aCollationDllName, TInt& aDbConfigFileVersion, TInt& aSettingsVersion, TSqlCompactionMode& aCompactionMode); sl@0: TBool SettingsTableExistsL(const TDesC& aDbName); sl@0: TBool IndexExistsL(const TDesC& aDbName, const TDesC& aCollationName); sl@0: sl@0: void ExecuteConfigurationUpdateL(const TSqlSrvFileData& aFileData, const TDesC& aMatchingConfigFile, sl@0: TInt aDbConfigFileVersion, const TDesC& aDbName); sl@0: void DoExecuteDbConfigFileOpsL(RFs& aFs, const TDesC& aConfigFilePath, const TDesC& aDbName); sl@0: void ParseFileL(const TDesC& aBuffer, const TDesC& aDbName); sl@0: void ProcessStatementL(const TDesC& aLine, const TDesC& aDbName); sl@0: sl@0: private: sl@0: sqlite3* iDbHandle; sl@0: }; sl@0: sl@0: #endif//__SQLSRVDBSYSSETTINGS_H__