os/persistentdata/persistentstorage/sql/SRC/Server/SqlSrvDbSysSettings.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sql/SRC/Server/SqlSrvDbSysSettings.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,90 @@
     1.4 +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Store/Load database system settings (database settings, security policies)
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#ifndef __SQLSRVDBSYSSETTINGS_H__
    1.22 +#define __SQLSRVDBSYSSETTINGS_H__
    1.23 +
    1.24 +#include "SqlAssert.h"	// ESqlPanicInternalError
    1.25 +#include "SqlUtil.h"	// TSqlCompactionMode
    1.26 +
    1.27 +//Forward declarations
    1.28 +struct sqlite3;
    1.29 +struct sqlite3_stmt;
    1.30 +class CSqlSecurityPolicy;
    1.31 +class TSqlSrvFileData;
    1.32 +class RFs;
    1.33 +
    1.34 +//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    1.35 +//////////////////////////////        TSqlDbSysSettings class         ////////////////////////////////////////         
    1.36 +//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    1.37 +
    1.38 +/**
    1.39 +Stores database system settings to database system settings table.
    1.40 +Stores database security policies to database security policy table.
    1.41 +Loads database system settings from database system settings table.
    1.42 +Loads database security policies from database security policy table.
    1.43 +Reindexes a database that is being 'Open'ed or 'Attach'ed if the collation
    1.44 +dll has changed, and updates the system settings table with the new dll name.
    1.45 +Configures a database that is being 'Open'ed according to the operations
    1.46 +specified in its configuration file, if such a file exists and has not yet
    1.47 +been processed, and updates the system settings table with the version of
    1.48 +the file that was processed.
    1.49 +
    1.50 +@internalComponent
    1.51 +*/
    1.52 +NONSHARABLE_CLASS(TSqlDbSysSettings)
    1.53 +	{
    1.54 +public:
    1.55 +	TSqlDbSysSettings(sqlite3* aDbHandle);
    1.56 +	
    1.57 +	void StoreSecurityPolicyL(const CSqlSecurityPolicy& aSecurityPolicyCon);
    1.58 +	void StoreSettingsL(const TDesC& aDbName, const TDesC& aCollationDllName, TInt aDbConfigFileVersion, TSqlCompactionMode aCompactionMode);
    1.59 +	
    1.60 +	void LoadSecurityPolicyL(CSqlSecurityPolicy& aSecurityPolicyCon);
    1.61 +	void LoadSettingsL(const TDesC& aDbName, TDes& aCollationDllName, TInt& aDbConfigFileVersion, TSqlCompactionMode& aCompactionMode);
    1.62 +
    1.63 +	void ReindexDatabaseL(const TDesC& aDbName, const TDesC& aCurrentCollationDllName);
    1.64 +	void ConfigureDatabaseL(TInt aStoredDbConfigFileVersion, const TSqlSrvFileData& aFileData, const TDesC& aDbName);
    1.65 +	
    1.66 +private:
    1.67 +	void StoreSecurityPoliciesL(const CSqlSecurityPolicy& aSecurityPolicyCon);
    1.68 +	void StoreSecurityPolicyL(sqlite3_stmt* aStmtHandle, TInt aObjType, const TDesC& aObjName, 
    1.69 +							  TInt aPolicyType, const TSecurityPolicy& aPolicy);
    1.70 +	TInt BindSecurityPolicyPrm(sqlite3_stmt* aStmtHandle, TInt aObjType, const TDesC& aObjName, 
    1.71 +							   TInt aPolicyType, const TSecurityPolicy& aPolicy);
    1.72 +	TSecurityPolicy ReadCurrSecurityPolicyL(sqlite3_stmt* aStmtHandle, TInt& aObjType, TPtrC& aObjName, TInt& aPolicyType);
    1.73 +	void StoreDefaultSecurityPolicy(CSqlSecurityPolicy& aSecurityPolicyCon, const TSecurityPolicy& aPolicy, TInt aDbPolicySetFlag);
    1.74 +	void StoreDbSecurityPolicyL(CSqlSecurityPolicy& aSecurityPolicyCon, TInt aPolicyType, 
    1.75 +								const TSecurityPolicy& aPolicy, TInt& aDbPolicySetFlag);
    1.76 +	void StoreDbObjSecurityPolicyL(CSqlSecurityPolicy& aSecurityPolicyCon, TInt aObjType, const TDesC& aObjName,
    1.77 +								   TInt aPolicyType, const TSecurityPolicy& aPolicy);
    1.78 +	
    1.79 +	void GetSettingsL(const TDesC& aDbName, TDes& aCollationDllName, TInt& aDbConfigFileVersion, TInt& aSettingsVersion, TSqlCompactionMode& aCompactionMode);	
    1.80 +	TBool SettingsTableExistsL(const TDesC& aDbName);
    1.81 +	TBool IndexExistsL(const TDesC& aDbName, const TDesC& aCollationName);
    1.82 +		
    1.83 +	void ExecuteConfigurationUpdateL(const TSqlSrvFileData& aFileData, const TDesC& aMatchingConfigFile,
    1.84 +								  	 TInt aDbConfigFileVersion, const TDesC& aDbName);
    1.85 +	void DoExecuteDbConfigFileOpsL(RFs& aFs, const TDesC& aConfigFilePath, const TDesC& aDbName);
    1.86 +	void ParseFileL(const TDesC& aBuffer, const TDesC& aDbName);
    1.87 +	void ProcessStatementL(const TDesC& aLine, const TDesC& aDbName);
    1.88 +		
    1.89 +private:
    1.90 +	sqlite3* 	iDbHandle;
    1.91 +	};
    1.92 +
    1.93 +#endif//__SQLSRVDBSYSSETTINGS_H__