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