|
1 // Copyright (c) 2005-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 // |
|
15 |
|
16 #ifndef __SQLSRVMAIN_H__ |
|
17 #define __SQLSRVMAIN_H__ |
|
18 |
|
19 #include <f32file.h> |
|
20 #include "SqlPanic.h" //TSqlPanic |
|
21 #include "SqlSrvFileData.h" //TSqlSrvFileData |
|
22 #include "SqlSrvAuthorizer.h" //MSqlPolicyInspector |
|
23 #include "SqlSrvSecurityMap.h" // |
|
24 #include "SqlSrvDriveSpace.h" //RSqlDriveSpaceCol |
|
25 #include "SqlSrvBurInterface.h" //MSqlSrvBurInterface |
|
26 #include "SqlBur.h" |
|
27 #include "SqlBufFlat.h" //RSqlBufFlat |
|
28 |
|
29 //Forward declarations |
|
30 class CSqlCompactor; |
|
31 class CSqlServer; |
|
32 |
|
33 CSqlServer& SqlServer(void); |
|
34 |
|
35 /** |
|
36 CSqlServer class derives from CServer2 and offers methods for: |
|
37 - creating new server side sessions; |
|
38 - accessing the last RMessage2 object; |
|
39 - accessing the TSqlSrvFileData instance (one per server); |
|
40 - accessing the security settings map (one per server); |
|
41 |
|
42 CSqlServer class also implements MSqlPolicyInspector and MSqlSrvBurInterface interfaces; |
|
43 |
|
44 The class owns also the folowing set of data: |
|
45 - iFileData - see TSqlSrvFileData; |
|
46 - iSecurityMap - see RSqlSecurityMap and RSqlMap; |
|
47 |
|
48 @see CServer2 |
|
49 @see MSqlPolicyInspector |
|
50 @see TSqlSrvFileData |
|
51 @see RSqlMap |
|
52 @see RSqlSecurityMap |
|
53 @see CSqlServer::NewLC() |
|
54 @see CSqlServer::NewSessionL() |
|
55 @see CSqlServer::FileData() |
|
56 @see CSqlServer::SecurityMap() |
|
57 @see CSqlServer::Check() |
|
58 |
|
59 @internalComponent |
|
60 */ |
|
61 NONSHARABLE_CLASS(CSqlServer) : public CServer2, public MSqlPolicyInspector, public MSqlSrvBurInterface |
|
62 { |
|
63 public: |
|
64 static CSqlServer* NewLC(); |
|
65 ~CSqlServer(); |
|
66 inline TSqlSrvFileData& FileData(); |
|
67 inline RSqlSecurityMap& SecurityMap(); |
|
68 inline RSqlDriveSpaceCol& DriveSpaceCol(); |
|
69 inline const TDesC& CollationDllName() const; |
|
70 inline MSqlPolicyInspector& SecurityInspector(); |
|
71 //Server buffers |
|
72 RSqlBufFlat& GetFlatBufL(TInt aMinLen); |
|
73 TDes8& GetBuf8L(TInt aMinLen); |
|
74 TDes16& GetBuf16L(TInt aMinLen); |
|
75 inline TDes& FileNameBuf(); |
|
76 void MinimizeBuffers(); |
|
77 //Compactor |
|
78 inline CSqlCompactor& Compactor(); |
|
79 //Overriding CServer2 abstract methods |
|
80 virtual CSession2* NewSessionL(const TVersion &aVersion, const RMessage2& aMessage) const; |
|
81 //Overriding MSqlPolicyInspector abstract methods |
|
82 virtual TBool Check(const TSecurityPolicy& aPolicy) const; |
|
83 //Overriding MSqlSrvBurInterface abstract methods |
|
84 virtual RFs& Fs(); |
|
85 virtual void GetBackUpListL(TSecureId aUid, RArray<TParse>& aFileList); |
|
86 |
|
87 private: |
|
88 CSqlServer(); |
|
89 void ConstructL(); |
|
90 void GetCollationDllNameL(); |
|
91 void CacheDbConfigFileNamesL(RFs& aFs, const TDesC& aServerPrivatePath); |
|
92 TInt ReAllocBuf(TInt aNewBufSize); |
|
93 |
|
94 private: |
|
95 TSqlSrvFileData iFileData; //Used as a temporary storage for file data (file name, drive, path, secure uid) |
|
96 RSqlSecurityMap iSecurityMap; //Collection of database security policies |
|
97 RSqlDriveSpaceCol iDriveSpaceCol; //Collection of "drive space" objects (reserved drive space management) |
|
98 CSqlBackupClient* iBackupClient; // the backup and restore instance |
|
99 TFileName iCollationDllName;//Default collation - dll name - uniquely identifies the collation method |
|
100 RSqlBufFlat iFlatBuf; //general purpose flat buffer. do not keep a state in it between calls! |
|
101 TUint8* iBuf; //general purpose buffer. do not keep a state in it between calls! |
|
102 TPtr8 iBufPtr8; //8-bit pointer to iBuf |
|
103 TPtr16 iBufPtr16; //16-bit pointer to iBuf |
|
104 TFileName iFileNameBuf; //General purpose buffer, can be used for storing file names |
|
105 CDbConfigFiles* iDbConfigFiles; //Holds the database config file names, if any exist (will be NULL if no files exist) |
|
106 CSqlCompactor* iCompactor; //The background compacting object (container for the db entries to be compacted) |
|
107 }; |
|
108 |
|
109 /** |
|
110 @return A reference to the file data object (one per server). |
|
111 */ |
|
112 inline TSqlSrvFileData& CSqlServer::FileData() |
|
113 { |
|
114 return iFileData; |
|
115 } |
|
116 |
|
117 /** |
|
118 @return A reference to the security settings map object which maintains a map of |
|
119 {Database name, security settings container} entries. |
|
120 */ |
|
121 inline RSqlSecurityMap& CSqlServer::SecurityMap() |
|
122 { |
|
123 return iSecurityMap; |
|
124 } |
|
125 |
|
126 /** |
|
127 @return A reference to the "drive space" collection |
|
128 */ |
|
129 inline RSqlDriveSpaceCol& CSqlServer::DriveSpaceCol() |
|
130 { |
|
131 return iDriveSpaceCol; |
|
132 } |
|
133 |
|
134 /** |
|
135 @return A reference to the default collation - the dll name. |
|
136 */ |
|
137 inline const TDesC& CSqlServer::CollationDllName() const |
|
138 { |
|
139 return iCollationDllName; |
|
140 } |
|
141 |
|
142 /** |
|
143 Returns a reference to the security policy inspector interface. |
|
144 @return A reference to the security policy inspector interface. |
|
145 */ |
|
146 inline MSqlPolicyInspector& CSqlServer::SecurityInspector() |
|
147 { |
|
148 return static_cast <MSqlPolicyInspector&> (*this); |
|
149 } |
|
150 |
|
151 /** |
|
152 @return A reference to the file name buffer. |
|
153 */ |
|
154 inline TDes& CSqlServer::FileNameBuf() |
|
155 { |
|
156 return iFileNameBuf; |
|
157 } |
|
158 |
|
159 /** |
|
160 @return A reference to the compactor. |
|
161 @panic SqlDb 7 In _DEBUG mode if the compactor is NULL. |
|
162 */ |
|
163 inline CSqlCompactor& CSqlServer::Compactor() |
|
164 { |
|
165 __SQLASSERT(iCompactor != NULL, ESqlPanicInternalError); |
|
166 return *iCompactor; |
|
167 } |
|
168 |
|
169 #endif//__SQLSRVMAIN_H__ |