cmmanager/cmmgr/Framework/Inc/cmtransactionhandler.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 17 Dec 2009 08:55:21 +0200
changeset 0 5a93021fdf25
permissions -rw-r--r--
Revision: 200949 Kit: 200951

/*
* 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:  Implementation of transaction handler
*
*/

#ifndef CMTRANSACTION_HANDLER_H
#define CMTRANSACTION_HANDLER_H

#include <commsdattypesv1_1.h>

/**
 *  Transaction handler.
 *
 *  @lib cmmanager.lib
 *  @since S60 v3.2
 */
NONSHARABLE_CLASS( CCmTransactionHandler ) : public CBase
    {
    public:

        /** Epoc constructor */
        static CCmTransactionHandler* NewL( CommsDat::CMDBSession& aDb );
        
        // destructor is intentionally not virtual.
        ~CCmTransactionHandler();

    public:
    
        /**
        * @return commsdat session
        */
        CommsDat::CMDBSession& Session()const{ return iDb; };
        
        /**
        * - Checks if transaction is already opened
        * - Set iOwnTransaction is not and opens it and
        *   put 'this' on cleanup&close stack
        */
        void OpenTransactionLC( TBool aSetAttribs = ETrue );
        
        /**
        * - Checks if the transaction is ours.
        * - If yes, commits the transaction.
        * - anyway does nothing
        * @praram aError - error id
        */
        void CommitTransactionL( TInt aError = KErrNone );
        
        /**
        * Performs RollbackTransactionL().
        */
        void Close();     

    private:
    
        /** Constructor. */
        CCmTransactionHandler( CommsDat::CMDBSession& aDb );

        /**
        * Second phase constructor. Leaves on failure.
        */      
        void ConstructL();

    private: // data
    
        CommsDat::CMDBSession&    iDb;   ///< Not owned CommsDat session pointer
        TUint32         iRefCount;
        TUint32         iProtectionFlag;
    };

#endif // CMTRANSACTION_HANDLER