cmmanager/cmmgr/Framework/Inc/cmtransactionhandler.h
branchRCL_3
changeset 58 83ca720e2b9a
parent 0 5a93021fdf25
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmmanager/cmmgr/Framework/Inc/cmtransactionhandler.h	Wed Sep 01 12:23:51 2010 +0100
@@ -0,0 +1,83 @@
+/*
+* 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