emailservices/emailstore/message_store/server/inc/ContainerStoreAccountTable.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Feb 2010 22:37:30 +0200
branchRCL_3
changeset 8 e1b6206813b4
parent 0 8466d47a6819
child 24 d189ee25cf9d
permissions -rw-r--r--
Revision: 201003 Kit: 201007

/*
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Container store account table.
*
*/



#ifndef __CONTAINER_STORE_ACCOUNT_TABLE_H__
#define __CONTAINER_STORE_ACCOUNT_TABLE_H__

// ========
// INCLUDES
// ========

#include <e32base.h>
#include <d32dbms.h>  // database
//<cmail>
#include "debuglogmacros.h"
//</cmail>

#include "ContainerStoreTable.h"
#include "ContainerStore.h"
#include "EncryptableTable.h"

// =======
// CLASSES
// =======

// ==================================
// CLASS: CContainerStoreAccountTable
// ==================================
class CContainerStoreAccountTable : public CContainerStoreTable, public MEncryptableTable
	{
	public:
	
	    // ==============
	    // PUBLIC METHODS
	    // ==============
	
		static CContainerStoreAccountTable* CreateL( CContainerStoreUtils&      aUtils, 
													 CContainerStoreEncryption& aEncryption, 
													 MCustomBehaviorProvider&   aCustomBehaviorProvider );
		
		static CContainerStoreAccountTable* OpenL( CContainerStoreUtils&      aUtils, 
												   CContainerStoreEncryption& aEncryption,
												   MCustomBehaviorProvider&   aCustomBehaviorProvider );
		
		virtual ~CContainerStoreAccountTable();
		
		void AddAccountL( TContainerId aMailboxId, TInt32 aOwnerId, const TDesC8& aName );
		
		TContainerId FindAccountL( TInt32 aOwnerId, const TDesC8& aName );
		
		TContainerId DeleteAccountL( TInt32 aOwnerId, const TDesC8& aName );
		
		void RenameAccountL( TInt32 aOwnerId, const TDesC8& aOldName, const TDesC8& aNewName );
		
		void AccountsL( TDes8& aCoountsBuf );
        
        void MailboxIdsL( RArray<TContainerId>& aMailboxIds );
		
		void TotalCountsL( TContainerId aMailBoxId, TDes8& aTotalCounts );	
		
		void UpdateTotalCountsL( TContainerId aMailBoxId, const TDesC8& aTotalCounts );
        
        // ===================================
        // Inherited from MEncryptableTable
        // ===================================
        TBool EncryptFirstL( TDbBookmark& aNextRow );
        TBool EncryptNextL( TDbBookmark& aNextRow );
        
        TBool DecryptFirstL( TDbBookmark& aNextRow );
        TBool DecryptNextL( TDbBookmark& aNextRow );
		
	private:

        // ===============
        // PRIVATE METHODS
        // ===============
        	
		CContainerStoreAccountTable( CContainerStoreUtils&      aUtils, 
									 CContainerStoreEncryption& aEncryption,
									 MCustomBehaviorProvider&   aCustomBehaviorProvider );
		
		void OpenTableL();
		
		void CreateTableL();
		
		void WriteNameL( const TDesC8& aName, TBool aEncryptBeforeWrite );
		
		void ReadNameL( RBuf8& aName );
        
        void SeekL( TContainerId aMailBoxId );
        
        TBool IsEncrypted();
        void SetEncryptedL( TBool aIsEncrypted );
				
        // ==================
        // PRIVATE ATTRIBUTES
        // ==================
        	
        CContainerStoreEncryption&   iEncryption;
		MCustomBehaviorProvider&     iCustomBehaviorProvider;
        
	    TInt                  iOwnerIdColNum;
	    TInt                  iAccountNameColNum;
	    TInt                  iMailBoxIdColNum;
	    TInt                  iTotalCountsColNum;
	    
	    /**
	     * This column stores the flag that indicates whether the
	     * current row is encrypted or not (the account name needs enctyption).  
         * When enable/disable encryption is being processed, the 
         * encryption/decryption is done row by row. So, this flag is updated row 
         * by row. So that we can know whether this row is enctypted or not.
	     */
	    TInt                  iIsEncryptedColNum;    
	    
		TUint                 iCountsLength;
	    
	    __LOG_DECLARATION
    		
	}; // end class CContainerStoreAccountTable

#endif