sl@0: // Copyright (c) 2005-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: // sl@0: sl@0: #ifndef __SQLSRVMAIN_H__ sl@0: #define __SQLSRVMAIN_H__ sl@0: sl@0: #include sl@0: #include "SqlAssert.h" //TSqlPanic sl@0: #include "SqlSrvFileData.h" //TSqlSrvFileData sl@0: #include "SqlSrvAuthorizer.h" //MSqlPolicyInspector sl@0: #include "SqlSrvSecurityMap.h" // sl@0: #include "SqlSrvDriveSpace.h" //RSqlDriveSpaceCol sl@0: #include "SqlSrvBurInterface.h" //MSqlSrvBurInterface sl@0: #include "SqlBur.h" sl@0: #include "SqlBufFlat.h" //RSqlBufFlat sl@0: sl@0: //Forward declarations sl@0: class CSqlCompactor; sl@0: class CSqlServer; sl@0: sl@0: CSqlServer& SqlServer(void); sl@0: sl@0: /** sl@0: CSqlServer class derives from CServer2 and offers methods for: sl@0: - creating new server side sessions; sl@0: - accessing the last RMessage2 object; sl@0: - accessing the TSqlSrvFileData instance (one per server); sl@0: - accessing the security settings map (one per server); sl@0: sl@0: CSqlServer class also implements MSqlPolicyInspector and MSqlSrvBurInterface interfaces; sl@0: sl@0: The class owns also the folowing set of data: sl@0: - iFileData - see TSqlSrvFileData; sl@0: - iSecurityMap - see RSqlSecurityMap and RSqlMap; sl@0: sl@0: @see CServer2 sl@0: @see MSqlPolicyInspector sl@0: @see TSqlSrvFileData sl@0: @see RSqlMap sl@0: @see RSqlSecurityMap sl@0: @see CSqlServer::NewLC() sl@0: @see CSqlServer::NewSessionL() sl@0: @see CSqlServer::FileData() sl@0: @see CSqlServer::SecurityMap() sl@0: @see CSqlServer::Check() sl@0: sl@0: @internalComponent sl@0: */ sl@0: NONSHARABLE_CLASS(CSqlServer) : public CServer2, public MSqlPolicyInspector, public MSqlSrvBurInterface sl@0: { sl@0: public: sl@0: static CSqlServer* NewLC(); sl@0: ~CSqlServer(); sl@0: inline TSqlSrvFileData& FileData(); sl@0: inline RSqlSecurityMap& SecurityMap(); sl@0: inline RSqlDriveSpaceCol& DriveSpaceCol(); sl@0: inline const TDesC& CollationDllName() const; sl@0: inline MSqlPolicyInspector& SecurityInspector(); sl@0: //Server buffers sl@0: RSqlBufFlat& GetFlatBufL(TInt aMinLen); sl@0: TDes8& GetBuf8L(TInt aMinLen); sl@0: TDes16& GetBuf16L(TInt aMinLen); sl@0: inline TDes& FileNameBuf(); sl@0: void MinimizeBuffers(); sl@0: //Compactor sl@0: inline CSqlCompactor& Compactor(); sl@0: //Overriding CServer2 abstract methods sl@0: virtual CSession2* NewSessionL(const TVersion &aVersion, const RMessage2& aMessage) const; sl@0: //Overriding MSqlPolicyInspector abstract methods sl@0: virtual TBool Check(const TSecurityPolicy& aPolicy) const; sl@0: //Overriding MSqlSrvBurInterface abstract methods sl@0: virtual RFs& Fs(); sl@0: virtual void GetBackUpListL(TSecureId aUid, TDriveNumber aDrive, RArray& aFileNameList); sl@0: sl@0: private: sl@0: CSqlServer(); sl@0: void ConstructL(); sl@0: void GetCollationDllNameL(); sl@0: void CacheDbConfigFileNamesL(RFs& aFs, const TDesC& aServerPrivatePath); sl@0: TInt ReAllocBuf(TInt aNewBufSize); sl@0: void DeleteTempFilesL(TInt aDriveNumber, const TDesC& aServerPrivatePath) const; sl@0: sl@0: private: sl@0: TSqlSrvFileData iFileData; //Used as a temporary storage for file data (file name, drive, path, secure uid) sl@0: RSqlSecurityMap iSecurityMap; //Collection of database security policies sl@0: RSqlDriveSpaceCol iDriveSpaceCol; //Collection of "drive space" objects (reserved drive space management) sl@0: CSqlBurEventMonitor* iBurEventMonitor;//Monitors B&R events sl@0: TFileName iCollationDllName;//Default collation - dll name - uniquely identifies the collation method sl@0: RSqlBufFlat iFlatBuf; //general purpose flat buffer. do not keep a state in it between calls! sl@0: TUint8* iBuf; //general purpose buffer. do not keep a state in it between calls! sl@0: TPtr8 iBufPtr8; //8-bit pointer to iBuf sl@0: TPtr16 iBufPtr16; //16-bit pointer to iBuf sl@0: TFileName iFileNameBuf; //General purpose buffer, can be used for storing file names sl@0: CDbConfigFiles* iDbConfigFiles; //Holds the database config file names, if any exist (will be NULL if no files exist) sl@0: CSqlCompactor* iCompactor; //The background compacting object (container for the db entries to be compacted) sl@0: }; sl@0: sl@0: /** sl@0: @return A reference to the file data object (one per server). sl@0: */ sl@0: inline TSqlSrvFileData& CSqlServer::FileData() sl@0: { sl@0: return iFileData; sl@0: } sl@0: sl@0: /** sl@0: @return A reference to the security settings map object which maintains a map of sl@0: {Database name, security settings container} entries. sl@0: */ sl@0: inline RSqlSecurityMap& CSqlServer::SecurityMap() sl@0: { sl@0: return iSecurityMap; sl@0: } sl@0: sl@0: /** sl@0: @return A reference to the "drive space" collection sl@0: */ sl@0: inline RSqlDriveSpaceCol& CSqlServer::DriveSpaceCol() sl@0: { sl@0: return iDriveSpaceCol; sl@0: } sl@0: sl@0: /** sl@0: @return A reference to the default collation - the dll name. sl@0: */ sl@0: inline const TDesC& CSqlServer::CollationDllName() const sl@0: { sl@0: return iCollationDllName; sl@0: } sl@0: sl@0: /** sl@0: Returns a reference to the security policy inspector interface. sl@0: @return A reference to the security policy inspector interface. sl@0: */ sl@0: inline MSqlPolicyInspector& CSqlServer::SecurityInspector() sl@0: { sl@0: return static_cast (*this); sl@0: } sl@0: sl@0: /** sl@0: @return A reference to the file name buffer. sl@0: */ sl@0: inline TDes& CSqlServer::FileNameBuf() sl@0: { sl@0: return iFileNameBuf; sl@0: } sl@0: sl@0: /** sl@0: @return A reference to the compactor. sl@0: @panic SqlDb 7 In _DEBUG mode if the compactor is NULL. sl@0: */ sl@0: inline CSqlCompactor& CSqlServer::Compactor() sl@0: { sl@0: __ASSERT_DEBUG(iCompactor != NULL, __SQLPANIC(ESqlPanicInternalError)); sl@0: return *iCompactor; sl@0: } sl@0: sl@0: #endif//__SQLSRVMAIN_H__