0
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2008 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: Class definition of plugin implementing devsound server
|
|
15 |
* side custom interface extension.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// Include files
|
|
22 |
#include "ciextnserverplugin.h"
|
|
23 |
#include "citraces.h"
|
|
24 |
#include <ecom.h>
|
|
25 |
#include <mmf/common/mmfcontrollerpluginresolver.h>
|
|
26 |
#include <cimsghndlrintfc.h>
|
|
27 |
#include <cimsghndlrintfc.hrh>
|
|
28 |
#include <e32const.h>
|
|
29 |
|
|
30 |
// ---------------------------------------------------------------------------
|
|
31 |
// Constructs and returns an application object.
|
|
32 |
// ---------------------------------------------------------------------------
|
|
33 |
//
|
|
34 |
MDevSoundCIServerExtension* CCIExtnServerPlugin::NewL()
|
|
35 |
{
|
|
36 |
DEB_TRACE0(_L("*CI* CCIExtnServerPlugin::NewL"));
|
|
37 |
CCIExtnServerPlugin* self = new (ELeave)CCIExtnServerPlugin;
|
|
38 |
CleanupStack::PushL( self );
|
|
39 |
self->ConstructL();
|
|
40 |
CleanupStack::Pop( self );
|
|
41 |
MDevSoundCIServerExtension* ptr = static_cast<MDevSoundCIServerExtension*>(self);
|
|
42 |
return ptr;
|
|
43 |
}
|
|
44 |
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
// Destructor
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
CCIExtnServerPlugin::~CCIExtnServerPlugin()
|
|
50 |
{
|
|
51 |
DEB_TRACE0(_L("*CI* CCIExtnServerPlugin::~CCIExtnServerPlugin"));
|
|
52 |
}
|
|
53 |
|
|
54 |
// ---------------------------------------------------------------------------
|
|
55 |
// Called by framework when plugin is constructed
|
|
56 |
// ---------------------------------------------------------------------------
|
|
57 |
//
|
|
58 |
TInt CCIExtnServerPlugin::Setup( MCustomInterface& aInterface )
|
|
59 |
{
|
|
60 |
DEB_TRACE0(_L("*CI* CCIExtnServerPlugin::Setup"));
|
|
61 |
TInt status(KErrNone);
|
4
|
62 |
iMCustomInterface = &aInterface;
|
0
|
63 |
TRAP_IGNORE(InitializeMsgHndlrPluginsL());
|
|
64 |
return status;
|
|
65 |
}
|
|
66 |
|
|
67 |
// ---------------------------------------------------------------------------
|
|
68 |
// Called by framework forwarding passing aMessage to handle
|
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
//
|
|
71 |
TInt CCIExtnServerPlugin::HandleMessageL(const RMmfIpcMessage& aMessage)
|
|
72 |
{
|
|
73 |
DEB_TRACE0(_L("*CI* CCIExtnServerPlugin::HandleMessageL"));
|
|
74 |
|
|
75 |
TInt status(KErrNotSupported);
|
|
76 |
|
|
77 |
// Forward request to each message handler plugin in the list,
|
|
78 |
TBool msgHandled(EFalse);
|
|
79 |
for ( TInt index = 0; index < iMCIMsgHndlrIntfcList.Count(); index++ )
|
|
80 |
{
|
|
81 |
msgHandled = iMCIMsgHndlrIntfcList[index]->HandleMessage( aMessage );
|
|
82 |
// If the plugin handled aMessage, stop forwarding the request to
|
|
83 |
// other plugins in the list and break out of loop.
|
|
84 |
if ( msgHandled == TBool(ETrue) )
|
|
85 |
{
|
|
86 |
status = KErrNone;
|
|
87 |
break;
|
|
88 |
}
|
|
89 |
}
|
|
90 |
|
|
91 |
return status;
|
|
92 |
}
|
|
93 |
|
|
94 |
// ---------------------------------------------------------------------------
|
|
95 |
// Called by framework when plugin is to be deleted
|
|
96 |
// ---------------------------------------------------------------------------
|
|
97 |
//
|
|
98 |
void CCIExtnServerPlugin::Release()
|
|
99 |
{
|
|
100 |
DEB_TRACE0(_L("*CI* CCIExtnServerPlugin::Release"));
|
|
101 |
|
|
102 |
for ( TInt index = 0; index < iMCIMsgHndlrIntfcList.Count(); index++ )
|
|
103 |
{
|
|
104 |
iMCIMsgHndlrIntfcList[index]->Close();
|
|
105 |
}
|
|
106 |
|
|
107 |
iMCIMsgHndlrIntfcList.Reset();
|
|
108 |
iMCIMsgHndlrIntfcList.Close();
|
|
109 |
|
|
110 |
|
|
111 |
REComSession::DestroyedImplementation(iDestructorKey);
|
|
112 |
|
|
113 |
delete this;
|
|
114 |
}
|
|
115 |
|
|
116 |
// ---------------------------------------------------------------------------
|
|
117 |
// Called by framework after plugin is created
|
|
118 |
// ---------------------------------------------------------------------------
|
|
119 |
//
|
|
120 |
void CCIExtnServerPlugin::PassDestructorKey( TUid aDestructorKey )
|
|
121 |
{
|
|
122 |
iDestructorKey = aDestructorKey;
|
|
123 |
}
|
|
124 |
|
|
125 |
// ---------------------------------------------------------------------------
|
|
126 |
// Constructor
|
|
127 |
// ---------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
CCIExtnServerPlugin::CCIExtnServerPlugin()
|
|
130 |
{
|
|
131 |
// No impl
|
|
132 |
}
|
|
133 |
|
|
134 |
// ---------------------------------------------------------------------------
|
|
135 |
// Second phase constructor.
|
|
136 |
// ---------------------------------------------------------------------------
|
|
137 |
//
|
|
138 |
void CCIExtnServerPlugin::ConstructL()
|
|
139 |
{
|
|
140 |
// No impl
|
|
141 |
}
|
|
142 |
|
|
143 |
// ---------------------------------------------------------------------------
|
|
144 |
// Initializes factory plugins list.
|
|
145 |
// ---------------------------------------------------------------------------
|
|
146 |
//
|
|
147 |
void CCIExtnServerPlugin::InitializeMsgHndlrPluginsL()
|
|
148 |
{
|
|
149 |
// 1. Query the implementation ids of plugins implementing
|
|
150 |
// KUidCIMsgHndlrIntfcInterface
|
|
151 |
// 2. Instantiate it and add it to the list of plugins
|
|
152 |
DEB_TRACE0(_L("*CI* CCIExtnServerPlugin::InitializeMsgHndlrPluginsL"));
|
|
153 |
|
|
154 |
iMCIMsgHndlrIntfcList.Reset();
|
|
155 |
|
|
156 |
RImplInfoPtrArray msgHndlrEComUids;
|
|
157 |
CleanupResetAndDestroyPushL(msgHndlrEComUids);
|
|
158 |
|
|
159 |
|
|
160 |
// List all the factory plugins
|
|
161 |
TUid msgHndlrPluginInterfaceUid = {KUidCIMsgHndlrIntfcInterface};
|
|
162 |
TEComResolverParams resParams;
|
|
163 |
REComSession::ListImplementationsL( msgHndlrPluginInterfaceUid, resParams,
|
|
164 |
KRomOnlyResolverUid, msgHndlrEComUids );
|
|
165 |
|
|
166 |
// Instantiate and add it to the list of factories
|
|
167 |
TUid destructorKey;
|
|
168 |
MCIMsgHndlrIntfc* msgHndlrPlugin(NULL);
|
|
169 |
TInt status(KErrNone);
|
|
170 |
|
|
171 |
for ( TInt index = 0; index < msgHndlrEComUids.Count(); index++)
|
|
172 |
{
|
|
173 |
TRAP( status ,
|
|
174 |
msgHndlrPlugin = static_cast<MCIMsgHndlrIntfc*>
|
|
175 |
(REComSession::CreateImplementationL(
|
|
176 |
msgHndlrEComUids[index]->ImplementationUid(),
|
|
177 |
destructorKey ) ) );
|
|
178 |
// If there was problem instantiating factory plugin, continue trying
|
|
179 |
// next one.
|
|
180 |
if ( status != KErrNone)
|
|
181 |
{
|
|
182 |
DEB_TRACE1(_L("*CI* CCIExtnServerPlugin::InitializeMsgHndlrPluginsL creation status=%d"),status);
|
|
183 |
continue;
|
|
184 |
}
|
|
185 |
|
|
186 |
// Initialize the factory plugin
|
|
187 |
if ( msgHndlrPlugin->Initialize( *iMCustomInterface, destructorKey ) == KErrNone )
|
|
188 |
{
|
|
189 |
status = iMCIMsgHndlrIntfcList.Append(msgHndlrPlugin);
|
|
190 |
if ( status != KErrNone )
|
|
191 |
{// There was problem adding plugin to list, there was a system
|
|
192 |
// wide error. Stop trying and return error code.
|
|
193 |
msgHndlrPlugin->Close();
|
|
194 |
User::Leave( status );
|
|
195 |
}
|
|
196 |
}
|
|
197 |
else
|
|
198 |
{// There was problem initializing the factory plugin instance, close
|
|
199 |
// it and continue instantiating the rest
|
|
200 |
msgHndlrPlugin->Close();
|
|
201 |
}
|
|
202 |
}
|
|
203 |
CleanupStack::PopAndDestroy(&msgHndlrEComUids);
|
|
204 |
}
|