os/persistentdata/persistentstorage/sql/SRC/Server/SqlSrvMain.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2005-2010 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 "SqlAssert.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, TDriveNumber aDrive, RArray<HBufC*>& aFileNameList);
    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 	void DeleteTempFilesL(TInt aDriveNumber, const TDesC& aServerPrivatePath) const;
    94 
    95 private:
    96 	TSqlSrvFileData		iFileData;		//Used as a temporary storage for file data (file name, drive, path, secure uid)
    97 	RSqlSecurityMap		iSecurityMap;	//Collection of database security policies
    98 	RSqlDriveSpaceCol	iDriveSpaceCol;	//Collection of "drive space" objects (reserved drive space management)
    99 	CSqlBurEventMonitor* iBurEventMonitor;//Monitors B&R events
   100 	TFileName			iCollationDllName;//Default collation - dll name - uniquely identifies the collation method
   101 	RSqlBufFlat  		iFlatBuf;		//general purpose flat buffer. do not keep a state in it between calls!
   102 	TUint8*				iBuf;			//general purpose buffer. do not keep a state in it between calls!
   103 	TPtr8				iBufPtr8;		//8-bit pointer to iBuf
   104 	TPtr16				iBufPtr16;		//16-bit pointer to iBuf
   105 	TFileName 			iFileNameBuf;	//General purpose buffer, can be used for storing file names
   106 	CDbConfigFiles*	    iDbConfigFiles; //Holds the database config file names, if any exist (will be NULL if no files exist)
   107 	CSqlCompactor*		iCompactor;		//The background compacting object (container for the db entries to be compacted)
   108 	};
   109 
   110 /**
   111 @return A reference to the file data object (one per server).
   112 */
   113 inline TSqlSrvFileData& CSqlServer::FileData()
   114 	{
   115 	return iFileData;
   116 	}
   117 	
   118 /**
   119 @return A reference to the security settings map object which maintains a map of 
   120         {Database name, security settings container} entries.
   121 */
   122 inline RSqlSecurityMap& CSqlServer::SecurityMap()
   123 	{
   124 	return iSecurityMap;
   125 	}
   126 
   127 /**
   128 @return A reference to the "drive space" collection
   129 */
   130 inline RSqlDriveSpaceCol& CSqlServer::DriveSpaceCol()
   131 	{
   132 	return iDriveSpaceCol;
   133 	}
   134 
   135 /**
   136 @return A reference to the default collation - the dll name.
   137 */
   138 inline const TDesC& CSqlServer::CollationDllName() const
   139 	{
   140 	return iCollationDllName;	
   141 	}
   142 
   143 /**
   144 Returns a reference to the security policy inspector interface.
   145 @return A reference to the security policy inspector interface.
   146 */
   147 inline MSqlPolicyInspector& CSqlServer::SecurityInspector()
   148 	{
   149 	return static_cast <MSqlPolicyInspector&> (*this);
   150 	}
   151 
   152 /**
   153 @return A reference to the file name buffer.
   154 */
   155 inline TDes& CSqlServer::FileNameBuf()
   156 	{
   157 	return iFileNameBuf;		
   158 	}
   159 
   160 /**
   161 @return A reference to the compactor.
   162 @panic SqlDb 7 In _DEBUG mode if the compactor is NULL.
   163 */
   164 inline CSqlCompactor& CSqlServer::Compactor()
   165 	{
   166 	__ASSERT_DEBUG(iCompactor != NULL, __SQLPANIC(ESqlPanicInternalError));			
   167 	return *iCompactor;
   168 	}
   169 
   170 #endif//__SQLSRVMAIN_H__