|
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 |
|
23 #include "CCntSession.h" |
|
24 #include "CCntServer.h" |
|
25 #include "CCntBackupRestoreAgent.h" |
|
26 #include "CCntPackager.h" |
|
27 |
|
28 #include "CCntStateMachine.h" |
|
29 #include "CCntDbManagerController.h" |
|
30 |
|
31 CCntMsgHandler::CCntMsgHandler(CCntSession& aSession) |
|
32 :iManager(aSession.iManager), iPackager(aSession.iPackager), iView(aSession.iView), iTimeOut(aSession.iTimeOut), iSessionId(aSession.iSessionId), iSession(aSession) |
|
33 { |
|
34 } |
|
35 |
|
36 CCntMsgHandler::~CCntMsgHandler() |
|
37 { |
|
38 } |
|
39 |
|
40 |
|
41 // Helper methods |
|
42 |
|
43 /** |
|
44 Many operations require a CCntDbManager instance. This method checks that it |
|
45 exists. |
|
46 */ |
|
47 void CCntMsgHandler::CheckForManagerL() |
|
48 { |
|
49 if(iManager == NULL) |
|
50 { |
|
51 User::Leave(KErrNotReady); |
|
52 } |
|
53 } |
|
54 |
|
55 /** |
|
56 Get reference to the parent CServer2 derived class. |
|
57 */ |
|
58 CCntServer& CCntMsgHandler::Server() |
|
59 { |
|
60 return iSession.Server(); |
|
61 } |
|
62 |
|
63 /** |
|
64 Read message. |
|
65 |
|
66 @leave KErrBadDescriptor Error occurred with aDes. |
|
67 */ |
|
68 void CCntMsgHandler::ReadL(const RMessage2& aMessage, TInt aParam, TDes& aDes) |
|
69 { |
|
70 const TInt ret = aMessage.Read(aParam, aDes); |
|
71 if (ret != KErrNone) |
|
72 { |
|
73 User::Leave(KErrBadDescriptor); |
|
74 } |
|
75 } |
|
76 |
|
77 /** |
|
78 Read message. |
|
79 |
|
80 @leave KErrBadDescriptor Error occurred with aDes. |
|
81 */ |
|
82 void CCntMsgHandler::WriteL(const RMessage2& aMessage, TInt aParam, const TDesC& aDes, TInt aOffset) |
|
83 { |
|
84 const TInt ret = aMessage.Write(aParam, aDes, aOffset); |
|
85 if (ret != KErrNone) |
|
86 { |
|
87 User::Leave(KErrBadDescriptor); |
|
88 } |
|
89 } |
|
90 |
|
91 /** |
|
92 Session is not going to be interested in database event notifications |
|
93 so un-register it. |
|
94 */ |
|
95 void CCntMsgHandler::UnRegisterDatabaseEventObserver() |
|
96 { |
|
97 iSession.UnRegisterDatabaseEventObserver(); |
|
98 } |
|
99 |
|
100 /** |
|
101 Get function pointer to message handling method. |
|
102 */ |
|
103 MsgHandlerFptr CCntMsgHandler::LookupHandlerMethodL(TInt aOpCode, const TInt* aOpCodes, const TInt aOpCodesLength) |
|
104 { |
|
105 for(TInt index = 0; index < aOpCodesLength; index++) |
|
106 { |
|
107 if(aOpCode == aOpCodes[index]) |
|
108 { |
|
109 const RHashMap<TInt,MsgHandlerFptr>& msgLut = Server().MsgLut(); |
|
110 MsgHandlerFptr func_ptr = msgLut.FindL(aOpCode); |
|
111 return func_ptr; |
|
112 } |
|
113 } |
|
114 |
|
115 return NULL; |
|
116 } |