1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
/*
* Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
* Contact: http://www.qt-project.org/legal
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
/**
@file
@internalComponent
*/
#include "ccntmsghandler.h"
#include "ccntsession.h"
#include "ccntserver.h"
#include "ccntbackuprestoreagent.h"
#include "ccntpackager.h"
#include "ccntstatemachine.h"
#include "ccntdbmanagercontroller.h"
CCntMsgHandler::CCntMsgHandler(CCntSession& aSession)
:iManager(aSession.iManager), iPackager(aSession.iPackager), iView(aSession.iView), iTimeOut(aSession.iTimeOut), iSessionId(aSession.iSessionId), iSession(aSession)
{
}
CCntMsgHandler::~CCntMsgHandler()
{
}
// Helper methods
/**
Many operations require a CCntDbManager instance. This method checks that it
exists.
*/
void CCntMsgHandler::CheckForManagerL()
{
if(iManager == NULL)
{
User::Leave(KErrNotReady);
}
}
/**
Get reference to the parent CServer2 derived class.
*/
CCntServer& CCntMsgHandler::Server()
{
return iSession.Server();
}
/**
Read message.
@leave KErrBadDescriptor Error occurred with aDes.
*/
void CCntMsgHandler::ReadL(const RMessage2& aMessage, TInt aParam, TDes& aDes)
{
const TInt ret = aMessage.Read(aParam, aDes);
if (ret != KErrNone)
{
User::Leave(KErrBadDescriptor);
}
}
/**
Read message.
@leave KErrBadDescriptor Error occurred with aDes.
*/
void CCntMsgHandler::WriteL(const RMessage2& aMessage, TInt aParam, const TDesC& aDes, TInt aOffset)
{
const TInt ret = aMessage.Write(aParam, aDes, aOffset);
if (ret != KErrNone)
{
User::Leave(KErrBadDescriptor);
}
}
/**
Session is not going to be interested in database event notifications
so un-register it.
*/
void CCntMsgHandler::UnRegisterDatabaseEventObserver()
{
iSession.UnRegisterDatabaseEventObserver();
}
/**
Get function pointer to message handling method.
*/
MsgHandlerFptr CCntMsgHandler::LookupHandlerMethodL(TInt aOpCode, const TInt* aOpCodes, const TInt aOpCodesLength)
{
for(TInt index = 0; index < aOpCodesLength; index++)
{
if(aOpCode == aOpCodes[index])
{
const RHashMap<TInt,MsgHandlerFptr>& msgLut = Server().MsgLut();
MsgHandlerFptr func_ptr = msgLut.FindL(aOpCode);
return func_ptr;
}
}
return NULL;
}
|