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