|
1 // Copyright (c) 2007-2009 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 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #include "CCntMsgHandler.h" |
|
22 #include "CCntMsgHandlerFptr.h" |
|
23 #include "CCntTransactionMsgHandler.h" |
|
24 |
|
25 #include "CCntServer.h" |
|
26 #include "CCntIpcCodes.h" |
|
27 #include "CCntRequest.h" |
|
28 #include "CCntDbManager.h" |
|
29 #include "CCntStateMachine.h" |
|
30 |
|
31 const TInt KCntTransactionIpcCodes[] = |
|
32 { |
|
33 EBeginDbTransaction, |
|
34 EEndDbTransaction, |
|
35 ERollbackDbTransaction |
|
36 }; |
|
37 |
|
38 CCntTransactionMsgHandler* CCntTransactionMsgHandler::NewLC(CCntSession& aSession) |
|
39 { |
|
40 CCntTransactionMsgHandler* CntTransactionMsgHandler = new (ELeave) CCntTransactionMsgHandler(aSession); |
|
41 CleanupStack::PushL(CntTransactionMsgHandler); |
|
42 return CntTransactionMsgHandler; |
|
43 } |
|
44 |
|
45 |
|
46 CCntTransactionMsgHandler::CCntTransactionMsgHandler(CCntSession& aSession) |
|
47 :CCntMsgHandler(aSession) |
|
48 { |
|
49 } |
|
50 |
|
51 CCntTransactionMsgHandler::~CCntTransactionMsgHandler() |
|
52 { |
|
53 } |
|
54 |
|
55 /** |
|
56 Delegates the incoming op code to a message handling method. |
|
57 |
|
58 First checks if this class services the op code, it then uses the lookup table and finds |
|
59 function pointer(to message handling method) mapped to the incoming message function (op code) |
|
60 and finally delegates the message to handling method. |
|
61 |
|
62 It returns KErrNotFound if op code not handled. |
|
63 */ |
|
64 TInt CCntTransactionMsgHandler::HandleMessageL(const RMessage2& aMessage) |
|
65 { |
|
66 MsgHandlerFptr func_ptr = LookupHandlerMethodL(aMessage.Function(), KCntTransactionIpcCodes, sizeof(KCntTransactionIpcCodes)/sizeof(TInt)); |
|
67 |
|
68 if(func_ptr) |
|
69 { |
|
70 TransactionMsgHandlerFptr mem_func_ptr = static_cast<TransactionMsgHandlerFptr>(func_ptr); |
|
71 (this->*mem_func_ptr)(aMessage); |
|
72 return (KErrNone); |
|
73 } |
|
74 |
|
75 return (KErrNotFound); |
|
76 } |
|
77 |
|
78 /** |
|
79 Message handling methods. |
|
80 */ |
|
81 void CCntTransactionMsgHandler::BeginDbTransactionL(const RMessage2& aMessage) |
|
82 { |
|
83 // Maps to RCntModel::BeginDbTransaction(). |
|
84 |
|
85 CheckForManagerL(); |
|
86 CReqDbBeginTrans* request = CReqDbBeginTrans::NewLC(iSessionId, aMessage, iTimeOut); |
|
87 iManager->StateMachineL().ProcessRequestL(request); // ownership transferred |
|
88 |
|
89 // ProcessRequestL received ownership of the request, the request only need |
|
90 // to be popped from CleanupStack. |
|
91 CleanupStack::Pop(request); |
|
92 } |
|
93 |
|
94 void CCntTransactionMsgHandler::EndDbTransactionL(const RMessage2& aMessage) |
|
95 { |
|
96 // Maps to RCntModel::CommitDbTransaction(). |
|
97 |
|
98 CheckForManagerL(); |
|
99 CReqDbCommitTrans* request = CReqDbCommitTrans::NewLC(iSessionId, aMessage, iTimeOut); |
|
100 iManager->StateMachineL().ProcessRequestL(request); // ownership transferred |
|
101 |
|
102 // ProcessRequestL received ownership of the request, the request only need |
|
103 // to be popped from CleanupStack. |
|
104 CleanupStack::Pop(request); |
|
105 } |
|
106 |
|
107 void CCntTransactionMsgHandler::RollbackDbTransactionL(const RMessage2& aMessage) |
|
108 { |
|
109 // Maps to RCntModel::RollbackDbTransaction(). |
|
110 |
|
111 CheckForManagerL(); |
|
112 CReqDbRollbackTrans* request = CReqDbRollbackTrans::NewLC(iSessionId, aMessage, iTimeOut); |
|
113 iManager->StateMachineL().ProcessRequestL(request); // ownership transferred |
|
114 |
|
115 // ProcessRequestL received ownership of the request, the request only need |
|
116 // to be popped from CleanupStack. |
|
117 CleanupStack::Pop(request); |
|
118 } |
|
119 |