emailservices/emailstore/message_store/server/inc/ContainerStoreUtils.h
changeset 0 8466d47a6819
child 8 e1b6206813b4
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Container store utilities.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __CONTAINER_STORE_UTILS_H__
       
    21 #define __CONTAINER_STORE_UTILS_H__
       
    22 
       
    23 // ========
       
    24 // INCLUDES
       
    25 // ========
       
    26 
       
    27 #include <e32std.h>
       
    28 #include <f32file.h>
       
    29 #include <d32dbms.h>  // database
       
    30 #include <s32file.h>  // stream store 
       
    31 //<cmail>
       
    32 #include "DebugLogMacros.h"
       
    33 //</cmail>
       
    34 
       
    35 // ====================
       
    36 // FORWARD DECLARATIONS
       
    37 // ====================
       
    38 
       
    39 class RDbDatabase;
       
    40 class RDbRowSet;
       
    41 class RDbTable;
       
    42 class CCompactionHandler;
       
    43 class CDeleteHandler;
       
    44 
       
    45 // =======
       
    46 // CLASSES
       
    47 // =======
       
    48 
       
    49 // : WOULD BE GOOD TO RENAME THIS SOMETHING LIKE CContainerStoreDatabase
       
    50 
       
    51 // ===========================
       
    52 // CLASS: CContainerStoreUtils
       
    53 // ===========================
       
    54 class CContainerStoreUtils : public CBase
       
    55     {
       
    56     public:
       
    57 
       
    58         // ==============
       
    59         // PUBLIC METHODS
       
    60         // ==============
       
    61     
       
    62         static CContainerStoreUtils* NewL( TDriveNumber    aDriveNumber, 
       
    63                                            TInt            aCompactionPriority,
       
    64                                            const TDesC&    aDbFilename,
       
    65                                            CDeleteHandler& aDeleteHandler );
       
    66         
       
    67         static void LeaveIfFalse( TBool aCondition, TInt aLeaveCode );
       
    68         
       
    69         virtual ~CContainerStoreUtils();
       
    70     
       
    71 		RFs& FileSystem();												
       
    72 		
       
    73 		void LeaveIfLowDiskSpaceL( TUint aBytesToWrite );
       
    74 		
       
    75 		const TDesC& PrivatePath() const;
       
    76 		
       
    77 		void SuspendCompactionLC();
       
    78 		
       
    79 		void ResumeCompaction();
       
    80 
       
    81         // Database management functions
       
    82 
       
    83         void CreateDatabaseL();
       
    84         
       
    85         void CreateTableL( const TDesC& aTableName, CDbColSet& aColSet );
       
    86         
       
    87         void CreateIndexL( const TDesC& aName, const TDesC& aTable, const CDbKey& aKey );
       
    88 
       
    89         void OpenDatabaseL();
       
    90         
       
    91         void OpenTableL( RDbTable& aTable, const TDesC& aTableName );
       
    92 
       
    93         void CloseTable( RDbTable& aTable );        
       
    94 
       
    95         void CloseDatabaseL();        
       
    96 		
       
    97         // Ignore compactation
       
    98         void CloseDatabase();
       
    99         
       
   100 		// Long database column functions
       
   101 
       
   102 	    void ReadLongColumnL( RDbRowSet& aRowSet, 
       
   103 		                      TUint      aColNum, 
       
   104 		                      RBuf8&     aBuffer,
       
   105 		                      TUint      aBufferPadSpace = 0 );
       
   106 
       
   107 		void WriteLongColumnL( RDbRowSet&    aRowSet,
       
   108                 	           TUint         aColNum, 
       
   109                       	       const TDesC8& aBuffer );
       
   110 
       
   111         // SQL view functions
       
   112                               	       
       
   113         void PopulateViewL( RDbView& aView, const TDesC& aSqlQuery, RDbRowSet::TAccess aAccess = RDbRowSet::EReadOnly );
       
   114 
       
   115         void Execute( const TDesC &aSql, TDbTextComparison aComparison=EDbCompareNormal );
       
   116                       	       
       
   117         // Database transaction functions
       
   118         
       
   119 		void BeginDatabaseTransactionLC();		
       
   120 
       
   121 		void CommitDatabaseTransactionL();		
       
   122 
       
   123 		void RollbackDatabaseTransactionL();
       
   124 		
       
   125 		inline TBool InTransaction() { return iDatabase.InTransaction(); }
       
   126         
       
   127         TBool FindFirstEncryptedOrUnencryptedL( RDbTable& aTable, const TDesC& aColName, TBool aFindEncrypted, TDbBookmark& aBookmark );
       
   128 	
       
   129         #ifdef _DEBUG		
       
   130 		void SimulateLowDiskSpace( TInt aLatency );
       
   131         #endif		
       
   132 		
       
   133     private:
       
   134     
       
   135         // ===============
       
   136         // PRIVATE METHODS
       
   137         // ===============
       
   138     
       
   139         CContainerStoreUtils( TDriveNumber    aDriveNumber, 
       
   140                               TInt            aCompactionPriority,
       
   141                               const TDesC&    aDbFilename,
       
   142                               CDeleteHandler& aDeleteHandler );
       
   143         
       
   144         void ConstructL(); 
       
   145 
       
   146         static void RollbackDatabaseTransactionL( TAny* aObject );
       
   147     
       
   148         // ==================
       
   149         // PRIVATE ATTRIBUTES
       
   150         // ==================
       
   151     
       
   152         const TDriveNumber      iDriveNumber;
       
   153         const TInt              iCompactionPriority;
       
   154         const TDesC&            iDbFilename;
       
   155         CDeleteHandler&         iDeleteHandler;
       
   156         RDbStoreDatabase        iDatabase;
       
   157         RFs                     iFs;
       
   158 		CFileStore*             iFileStore;		
       
   159         TFileName               iPrivatePath;
       
   160    		CCompactionHandler*     iCompactionHandler;
       
   161    		
       
   162    		RPointerArray<RDbTable> iTables;
       
   163 
       
   164         #ifdef _DEBUG		
       
   165         TInt               iLowDiskSpaceLatency;
       
   166         #endif
       
   167 
       
   168         __LOG_DECLARATION
       
   169 
       
   170     }; // end class ContainerStoreUtils
       
   171     
       
   172 #endif