|
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 "ccnteventmsghandler.h" |
|
27 #include "ccnteventqueue.h" |
|
28 #include "ccntipccodes.h" |
|
29 #include "ccntserver.h" |
|
30 |
|
31 const TInt KCntEventIpcCodes[] = |
|
32 { |
|
33 ECntRequestEvent, |
|
34 ECntCancelEventRequest |
|
35 }; |
|
36 |
|
37 CCntEventMsgHandler* CCntEventMsgHandler::NewLC(CCntSession& aSession) |
|
38 { |
|
39 CCntEventMsgHandler* CntEventMsgHandler = new (ELeave) CCntEventMsgHandler(aSession); |
|
40 CleanupStack::PushL(CntEventMsgHandler); |
|
41 CntEventMsgHandler->ConstructL(); |
|
42 return CntEventMsgHandler; |
|
43 } |
|
44 |
|
45 |
|
46 CCntEventMsgHandler::CCntEventMsgHandler(CCntSession& aSession) |
|
47 :CCntMsgHandler(aSession) |
|
48 { |
|
49 } |
|
50 |
|
51 void CCntEventMsgHandler::ConstructL() |
|
52 { |
|
53 iEventQueue = new (ELeave) CEventQueue; |
|
54 } |
|
55 |
|
56 CCntEventMsgHandler::~CCntEventMsgHandler() |
|
57 { |
|
58 delete iEventQueue; |
|
59 } |
|
60 |
|
61 /** |
|
62 Delegates the incoming op code to a message handling method. |
|
63 |
|
64 First checks if this class services the op code, it then uses the lookup table and finds |
|
65 function pointer(to message handling method) mapped to the incoming message function (op code) |
|
66 and finally delegates the message to handling method. |
|
67 |
|
68 It returns KErrNotFound if op code not handled. |
|
69 */ |
|
70 TInt CCntEventMsgHandler::HandleMessageL(const RMessage2& aMessage) |
|
71 { |
|
72 MsgHandlerFptr func_ptr = LookupHandlerMethodL(aMessage.Function(), KCntEventIpcCodes, sizeof(KCntEventIpcCodes)/sizeof(TInt)); |
|
73 |
|
74 if(func_ptr) |
|
75 { |
|
76 EventMsgHandlerFptr mem_func_ptr = static_cast<EventMsgHandlerFptr>(func_ptr); |
|
77 (this->*mem_func_ptr)(aMessage); |
|
78 return (KErrNone); |
|
79 } |
|
80 |
|
81 return (KErrNotFound); |
|
82 } |
|
83 |
|
84 /** |
|
85 Message handling methods. |
|
86 */ |
|
87 void CCntEventMsgHandler::RequestEvent(const RMessage2& aMessage) |
|
88 { |
|
89 iEventQueue->RequestEvent(aMessage); |
|
90 } |
|
91 |
|
92 void CCntEventMsgHandler::CancelEventRequest(const RMessage2& aMessage) |
|
93 { |
|
94 // Complete the asynchronous request sent by the client-side |
|
95 // database event consumer (the CCntDbNotifyMonitor class). |
|
96 iEventQueue->CancelEventRequest(); |
|
97 // Complete the cancelling request (sent to server when we got |
|
98 // here). |
|
99 aMessage.Complete(KErrNone); |
|
100 } |
|
101 |
|
102 void CCntEventMsgHandler::QueueEvent(const TContactDbObserverEventV2 aEvent) |
|
103 { |
|
104 iEventQueue->QueueEvent(aEvent); |
|
105 } |
|
106 |