|
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 "CCntEventMsgHandler.h" |
|
24 #include "CCntEventQueue.h" |
|
25 #include "CCntIpcCodes.h" |
|
26 #include "CCntServer.h" |
|
27 |
|
28 const TInt KCntEventIpcCodes[] = |
|
29 { |
|
30 ECntRequestEvent, |
|
31 ECntCancelEventRequest |
|
32 }; |
|
33 |
|
34 CCntEventMsgHandler* CCntEventMsgHandler::NewLC(CCntSession& aSession) |
|
35 { |
|
36 CCntEventMsgHandler* CntEventMsgHandler = new (ELeave) CCntEventMsgHandler(aSession); |
|
37 CleanupStack::PushL(CntEventMsgHandler); |
|
38 CntEventMsgHandler->ConstructL(); |
|
39 return CntEventMsgHandler; |
|
40 } |
|
41 |
|
42 |
|
43 CCntEventMsgHandler::CCntEventMsgHandler(CCntSession& aSession) |
|
44 :CCntMsgHandler(aSession) |
|
45 { |
|
46 } |
|
47 |
|
48 void CCntEventMsgHandler::ConstructL() |
|
49 { |
|
50 iEventQueue = new (ELeave) CEventQueue; |
|
51 } |
|
52 |
|
53 CCntEventMsgHandler::~CCntEventMsgHandler() |
|
54 { |
|
55 delete iEventQueue; |
|
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 CCntEventMsgHandler::HandleMessageL(const RMessage2& aMessage) |
|
68 { |
|
69 MsgHandlerFptr func_ptr = LookupHandlerMethodL(aMessage.Function(), KCntEventIpcCodes, sizeof(KCntEventIpcCodes)/sizeof(TInt)); |
|
70 |
|
71 if(func_ptr) |
|
72 { |
|
73 EventMsgHandlerFptr mem_func_ptr = static_cast<EventMsgHandlerFptr>(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 CCntEventMsgHandler::RequestEvent(const RMessage2& aMessage) |
|
85 { |
|
86 iEventQueue->RequestEvent(aMessage); |
|
87 } |
|
88 |
|
89 void CCntEventMsgHandler::CancelEventRequest(const RMessage2& aMessage) |
|
90 { |
|
91 // Complete the asynchronous request sent by the client-side |
|
92 // database event consumer (the CCntDbNotifyMonitor class). |
|
93 iEventQueue->CancelEventRequest(); |
|
94 // Complete the cancelling request (sent to server when we got |
|
95 // here). |
|
96 aMessage.Complete(KErrNone); |
|
97 } |
|
98 |
|
99 void CCntEventMsgHandler::QueueEvent(const TContactDbObserverEvent aEvent) |
|
100 { |
|
101 iEventQueue->QueueEvent(aEvent); |
|
102 } |
|
103 |