os/persistentdata/persistentstorage/sql/SRC/Server/SqlSrvDbSysSettings.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Store/Load database system settings (database settings, security policies)
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#ifndef __SQLSRVDBSYSSETTINGS_H__
sl@0
    19
#define __SQLSRVDBSYSSETTINGS_H__
sl@0
    20
sl@0
    21
#include "SqlAssert.h"	// ESqlPanicInternalError
sl@0
    22
#include "SqlUtil.h"	// TSqlCompactionMode
sl@0
    23
sl@0
    24
//Forward declarations
sl@0
    25
struct sqlite3;
sl@0
    26
struct sqlite3_stmt;
sl@0
    27
class CSqlSecurityPolicy;
sl@0
    28
class TSqlSrvFileData;
sl@0
    29
class RFs;
sl@0
    30
sl@0
    31
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
    32
//////////////////////////////        TSqlDbSysSettings class         ////////////////////////////////////////         
sl@0
    33
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
    34
sl@0
    35
/**
sl@0
    36
Stores database system settings to database system settings table.
sl@0
    37
Stores database security policies to database security policy table.
sl@0
    38
Loads database system settings from database system settings table.
sl@0
    39
Loads database security policies from database security policy table.
sl@0
    40
Reindexes a database that is being 'Open'ed or 'Attach'ed if the collation
sl@0
    41
dll has changed, and updates the system settings table with the new dll name.
sl@0
    42
Configures a database that is being 'Open'ed according to the operations
sl@0
    43
specified in its configuration file, if such a file exists and has not yet
sl@0
    44
been processed, and updates the system settings table with the version of
sl@0
    45
the file that was processed.
sl@0
    46
sl@0
    47
@internalComponent
sl@0
    48
*/
sl@0
    49
NONSHARABLE_CLASS(TSqlDbSysSettings)
sl@0
    50
	{
sl@0
    51
public:
sl@0
    52
	TSqlDbSysSettings(sqlite3* aDbHandle);
sl@0
    53
	
sl@0
    54
	void StoreSecurityPolicyL(const CSqlSecurityPolicy& aSecurityPolicyCon);
sl@0
    55
	void StoreSettingsL(const TDesC& aDbName, const TDesC& aCollationDllName, TInt aDbConfigFileVersion, TSqlCompactionMode aCompactionMode);
sl@0
    56
	
sl@0
    57
	void LoadSecurityPolicyL(CSqlSecurityPolicy& aSecurityPolicyCon);
sl@0
    58
	void LoadSettingsL(const TDesC& aDbName, TDes& aCollationDllName, TInt& aDbConfigFileVersion, TSqlCompactionMode& aCompactionMode);
sl@0
    59
sl@0
    60
	void ReindexDatabaseL(const TDesC& aDbName, const TDesC& aCurrentCollationDllName);
sl@0
    61
	void ConfigureDatabaseL(TInt aStoredDbConfigFileVersion, const TSqlSrvFileData& aFileData, const TDesC& aDbName);
sl@0
    62
	
sl@0
    63
private:
sl@0
    64
	void StoreSecurityPoliciesL(const CSqlSecurityPolicy& aSecurityPolicyCon);
sl@0
    65
	void StoreSecurityPolicyL(sqlite3_stmt* aStmtHandle, TInt aObjType, const TDesC& aObjName, 
sl@0
    66
							  TInt aPolicyType, const TSecurityPolicy& aPolicy);
sl@0
    67
	TInt BindSecurityPolicyPrm(sqlite3_stmt* aStmtHandle, TInt aObjType, const TDesC& aObjName, 
sl@0
    68
							   TInt aPolicyType, const TSecurityPolicy& aPolicy);
sl@0
    69
	TSecurityPolicy ReadCurrSecurityPolicyL(sqlite3_stmt* aStmtHandle, TInt& aObjType, TPtrC& aObjName, TInt& aPolicyType);
sl@0
    70
	void StoreDefaultSecurityPolicy(CSqlSecurityPolicy& aSecurityPolicyCon, const TSecurityPolicy& aPolicy, TInt aDbPolicySetFlag);
sl@0
    71
	void StoreDbSecurityPolicyL(CSqlSecurityPolicy& aSecurityPolicyCon, TInt aPolicyType, 
sl@0
    72
								const TSecurityPolicy& aPolicy, TInt& aDbPolicySetFlag);
sl@0
    73
	void StoreDbObjSecurityPolicyL(CSqlSecurityPolicy& aSecurityPolicyCon, TInt aObjType, const TDesC& aObjName,
sl@0
    74
								   TInt aPolicyType, const TSecurityPolicy& aPolicy);
sl@0
    75
	
sl@0
    76
	void GetSettingsL(const TDesC& aDbName, TDes& aCollationDllName, TInt& aDbConfigFileVersion, TInt& aSettingsVersion, TSqlCompactionMode& aCompactionMode);	
sl@0
    77
	TBool SettingsTableExistsL(const TDesC& aDbName);
sl@0
    78
	TBool IndexExistsL(const TDesC& aDbName, const TDesC& aCollationName);
sl@0
    79
		
sl@0
    80
	void ExecuteConfigurationUpdateL(const TSqlSrvFileData& aFileData, const TDesC& aMatchingConfigFile,
sl@0
    81
								  	 TInt aDbConfigFileVersion, const TDesC& aDbName);
sl@0
    82
	void DoExecuteDbConfigFileOpsL(RFs& aFs, const TDesC& aConfigFilePath, const TDesC& aDbName);
sl@0
    83
	void ParseFileL(const TDesC& aBuffer, const TDesC& aDbName);
sl@0
    84
	void ProcessStatementL(const TDesC& aLine, const TDesC& aDbName);
sl@0
    85
		
sl@0
    86
private:
sl@0
    87
	sqlite3* 	iDbHandle;
sl@0
    88
	};
sl@0
    89
sl@0
    90
#endif//__SQLSRVDBSYSSETTINGS_H__