sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description: Class definition of plugin implementing message handler
|
sl@0
|
15 |
* interface.
|
sl@0
|
16 |
*
|
sl@0
|
17 |
*/
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
// Include files
|
sl@0
|
22 |
#include "ciplatformmsghndlrplugin.h"
|
sl@0
|
23 |
#include "ciplatformmsghndlrplugin.hrh"
|
sl@0
|
24 |
#include "citraces.h"
|
sl@0
|
25 |
#include <ecom.h>
|
sl@0
|
26 |
#include <CustomInterfaceBuilder.h>
|
sl@0
|
27 |
#include <CustomInterfaceCustomCommandParser.h>
|
sl@0
|
28 |
|
sl@0
|
29 |
#define RET_ERR_IF_ERR(s) if(s!=KErrNone) return s
|
sl@0
|
30 |
|
sl@0
|
31 |
// ---------------------------------------------------------------------------
|
sl@0
|
32 |
// Constructs and returns an application object.
|
sl@0
|
33 |
// ---------------------------------------------------------------------------
|
sl@0
|
34 |
//
|
sl@0
|
35 |
MCIMsgHndlrIntfc* CCIPlatformMsgHndlrPlugin::NewL()
|
sl@0
|
36 |
{
|
sl@0
|
37 |
DEB_TRACE0(_L("*CI* CCIPlatformMsgHndlrPlugin::NewL"));
|
sl@0
|
38 |
CCIPlatformMsgHndlrPlugin* self = new (ELeave) CCIPlatformMsgHndlrPlugin;
|
sl@0
|
39 |
CleanupStack::PushL( self );
|
sl@0
|
40 |
self->ConstructL();
|
sl@0
|
41 |
CleanupStack::Pop( self );
|
sl@0
|
42 |
MCIMsgHndlrIntfc* ptr = static_cast<MCIMsgHndlrIntfc*>(self);
|
sl@0
|
43 |
return ptr;
|
sl@0
|
44 |
}
|
sl@0
|
45 |
|
sl@0
|
46 |
// ---------------------------------------------------------------------------
|
sl@0
|
47 |
// Destructor
|
sl@0
|
48 |
// ---------------------------------------------------------------------------
|
sl@0
|
49 |
//
|
sl@0
|
50 |
CCIPlatformMsgHndlrPlugin::~CCIPlatformMsgHndlrPlugin()
|
sl@0
|
51 |
{
|
sl@0
|
52 |
// No Impl
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
// ---------------------------------------------------------------------------
|
sl@0
|
56 |
// Called by framework when plugin is constructed
|
sl@0
|
57 |
// ---------------------------------------------------------------------------
|
sl@0
|
58 |
//
|
sl@0
|
59 |
TInt CCIPlatformMsgHndlrPlugin::Initialize( MCustomInterface& aCustomInterface, TUid aDestructorKey )
|
sl@0
|
60 |
{
|
sl@0
|
61 |
TInt status(KErrNone);
|
sl@0
|
62 |
iMCustomInterface = &aCustomInterface;
|
sl@0
|
63 |
iDestructorKey = aDestructorKey;
|
sl@0
|
64 |
iCIFWObjectsInitialized = EFalse;
|
sl@0
|
65 |
return status;
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
// ---------------------------------------------------------------------------
|
sl@0
|
69 |
// Called by framework when it needs to know plugin implementation uid
|
sl@0
|
70 |
// ---------------------------------------------------------------------------
|
sl@0
|
71 |
//
|
sl@0
|
72 |
TUid CCIPlatformMsgHndlrPlugin::ImplementationUid()
|
sl@0
|
73 |
{
|
sl@0
|
74 |
TUid implId = {KUidCCIPlatformMsgHndlrPlugin};
|
sl@0
|
75 |
return implId;
|
sl@0
|
76 |
}
|
sl@0
|
77 |
|
sl@0
|
78 |
// ---------------------------------------------------------------------------
|
sl@0
|
79 |
// Called by framework forwarding request to handle aMessage
|
sl@0
|
80 |
// ---------------------------------------------------------------------------
|
sl@0
|
81 |
//
|
sl@0
|
82 |
TBool CCIPlatformMsgHndlrPlugin::HandleMessage( const RMmfIpcMessage& aMessage )
|
sl@0
|
83 |
{
|
sl@0
|
84 |
DEB_TRACE0(_L("*CI* CCIPlatformMsgHndlrPlugin::HandleMessage"));
|
sl@0
|
85 |
|
sl@0
|
86 |
TBool handled(EFalse);
|
sl@0
|
87 |
// Initialize Custom Interface Framework Objects if not done already
|
sl@0
|
88 |
if (!iCIFWObjectsInitialized)
|
sl@0
|
89 |
{
|
sl@0
|
90 |
TRAPD( status, InitializeCIFWObjectsL());
|
sl@0
|
91 |
if ( status != KErrNone )
|
sl@0
|
92 |
{
|
sl@0
|
93 |
aMessage.Complete(status);
|
sl@0
|
94 |
handled = ETrue;
|
sl@0
|
95 |
}
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
// Get the destination info from the client into TMMFMessage.
|
sl@0
|
99 |
TMMFMessage message(aMessage);
|
sl@0
|
100 |
TRAPD(status, message.FetchDestinationL());
|
sl@0
|
101 |
|
sl@0
|
102 |
// Check if Custom Command Parser manager can handle the message...
|
sl@0
|
103 |
if (!handled)
|
sl@0
|
104 |
{
|
sl@0
|
105 |
handled = iCustomCommandParserManager->HandleRequest(message);
|
sl@0
|
106 |
}
|
sl@0
|
107 |
|
sl@0
|
108 |
// Check if the aMessage is for one of the MMF Objects
|
sl@0
|
109 |
if (!handled)
|
sl@0
|
110 |
{
|
sl@0
|
111 |
CMMFObject* object = NULL;
|
sl@0
|
112 |
// Try to find MMFObject that handles this request
|
sl@0
|
113 |
TInt status = iMMFObjectContainer->FindMMFObject(message.Destination(),
|
sl@0
|
114 |
object);
|
sl@0
|
115 |
|
sl@0
|
116 |
// If found, give message to the MMFObject
|
sl@0
|
117 |
if ( KErrNone == status )
|
sl@0
|
118 |
{
|
sl@0
|
119 |
object->HandleRequest(message);
|
sl@0
|
120 |
handled = ETrue;
|
sl@0
|
121 |
}
|
sl@0
|
122 |
}
|
sl@0
|
123 |
|
sl@0
|
124 |
return handled;
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|
sl@0
|
127 |
// ---------------------------------------------------------------------------
|
sl@0
|
128 |
// Called by framework when plugin is to be deleted
|
sl@0
|
129 |
// ---------------------------------------------------------------------------
|
sl@0
|
130 |
//
|
sl@0
|
131 |
void CCIPlatformMsgHndlrPlugin::Close()
|
sl@0
|
132 |
{
|
sl@0
|
133 |
DEB_TRACE0(_L("*CI* CCIPlatformMsgHndlrPlugin::Close"));
|
sl@0
|
134 |
|
sl@0
|
135 |
iMCustomInterface = NULL;
|
sl@0
|
136 |
delete iCustomCommandParserManager;
|
sl@0
|
137 |
|
sl@0
|
138 |
iCustomCommandParserManager = NULL;
|
sl@0
|
139 |
delete iMMFObjectContainer;
|
sl@0
|
140 |
iMMFObjectContainer = NULL;
|
sl@0
|
141 |
|
sl@0
|
142 |
iCIFWObjectsInitialized = EFalse;
|
sl@0
|
143 |
|
sl@0
|
144 |
REComSession::DestroyedImplementation(iDestructorKey);
|
sl@0
|
145 |
|
sl@0
|
146 |
delete this;
|
sl@0
|
147 |
}
|
sl@0
|
148 |
|
sl@0
|
149 |
// ---------------------------------------------------------------------------
|
sl@0
|
150 |
// Called by framework to get handle to custom interface builder
|
sl@0
|
151 |
// ---------------------------------------------------------------------------
|
sl@0
|
152 |
//
|
sl@0
|
153 |
const TMMFMessageDestination& CCIPlatformMsgHndlrPlugin::GetCustomInterfaceBuilderL()
|
sl@0
|
154 |
{
|
sl@0
|
155 |
// return the handle
|
sl@0
|
156 |
return iCustomInterfaceBuilder->Handle();
|
sl@0
|
157 |
}
|
sl@0
|
158 |
|
sl@0
|
159 |
// ---------------------------------------------------------------------------
|
sl@0
|
160 |
// Constructor
|
sl@0
|
161 |
// ---------------------------------------------------------------------------
|
sl@0
|
162 |
//
|
sl@0
|
163 |
CCIPlatformMsgHndlrPlugin::CCIPlatformMsgHndlrPlugin()
|
sl@0
|
164 |
:iMCustomInterface(NULL),
|
sl@0
|
165 |
iCIFWObjectsInitialized(EFalse),
|
sl@0
|
166 |
iMMFObjectContainer(NULL),
|
sl@0
|
167 |
iCustomCommandParserManager(NULL),
|
sl@0
|
168 |
iCustomInterfaceBuilder(NULL)
|
sl@0
|
169 |
{
|
sl@0
|
170 |
// No Impl
|
sl@0
|
171 |
}
|
sl@0
|
172 |
|
sl@0
|
173 |
// ---------------------------------------------------------------------------
|
sl@0
|
174 |
// Second phase constructor
|
sl@0
|
175 |
// ---------------------------------------------------------------------------
|
sl@0
|
176 |
//
|
sl@0
|
177 |
void CCIPlatformMsgHndlrPlugin::ConstructL()
|
sl@0
|
178 |
{
|
sl@0
|
179 |
// No Impl
|
sl@0
|
180 |
}
|
sl@0
|
181 |
|
sl@0
|
182 |
// ---------------------------------------------------------------------------
|
sl@0
|
183 |
// Initializes objects required for Custom Interface Framework.
|
sl@0
|
184 |
// ---------------------------------------------------------------------------
|
sl@0
|
185 |
//
|
sl@0
|
186 |
void CCIPlatformMsgHndlrPlugin::InitializeCIFWObjectsL()
|
sl@0
|
187 |
{
|
sl@0
|
188 |
DEB_TRACE0(_L("*CI* CCIPlatformMsgHndlrPlugin::InitializeCIFWObjectsL"));
|
sl@0
|
189 |
|
sl@0
|
190 |
iMMFObjectContainer = new(ELeave) CMMFObjectContainer;
|
sl@0
|
191 |
|
sl@0
|
192 |
iCustomCommandParserManager = CMMFCustomCommandParserManager::NewL();
|
sl@0
|
193 |
|
sl@0
|
194 |
CCustomInterfaceCustomCommandParser* ciccParser = CCustomInterfaceCustomCommandParser::NewL(*this);
|
sl@0
|
195 |
CleanupStack::PushL( ciccParser );
|
sl@0
|
196 |
|
sl@0
|
197 |
iCustomCommandParserManager->AddCustomCommandParserL(*ciccParser);
|
sl@0
|
198 |
CleanupStack::Pop( ciccParser );
|
sl@0
|
199 |
|
sl@0
|
200 |
iCustomInterfaceBuilder = CCustomInterfaceBuilder::NewL( *iMMFObjectContainer, *iMCustomInterface);
|
sl@0
|
201 |
iMMFObjectContainer->AddMMFObject(*iCustomInterfaceBuilder);
|
sl@0
|
202 |
|
sl@0
|
203 |
iCIFWObjectsInitialized = ETrue;
|
sl@0
|
204 |
}
|