|
1 /* |
|
2 * Copyright (c) 2000 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: Implementation of terminalsecurity components |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32debug.h> |
|
21 #include <ecom/ecom.h> |
|
22 #include <SCPParamObject.h> |
|
23 #include "SCP_IDs.h" |
|
24 #include "SCPServer.h" |
|
25 #include "SCPPluginManager.h" |
|
26 #include "SCPPlugin.h" |
|
27 |
|
28 // ================= MEMBER FUNCTIONS ======================= |
|
29 |
|
30 // --------------------------------------------------------- |
|
31 // void CSCPPluginManager::CSCPPluginManager() |
|
32 // Destructor |
|
33 // |
|
34 // Status : Approved |
|
35 // --------------------------------------------------------- |
|
36 // |
|
37 CSCPPluginManager::CSCPPluginManager( CSCPServer* aServer ) |
|
38 :iServer( aServer ), |
|
39 iPluginsLoaded( EFalse ) |
|
40 { |
|
41 // No implementation required |
|
42 } |
|
43 |
|
44 |
|
45 // --------------------------------------------------------- |
|
46 // void CSCPPluginManager::NewL() |
|
47 // Static constructor |
|
48 // |
|
49 // Status : Approved |
|
50 // --------------------------------------------------------- |
|
51 // |
|
52 CSCPPluginManager* CSCPPluginManager::NewL( CSCPServer* aServer ) |
|
53 { |
|
54 CSCPPluginManager* self = CSCPPluginManager::NewLC( aServer ); |
|
55 CleanupStack::Pop( self ); |
|
56 |
|
57 return self; |
|
58 } |
|
59 |
|
60 |
|
61 // --------------------------------------------------------- |
|
62 // void CSCPPluginManager::NewLC() |
|
63 // Static constructor |
|
64 // |
|
65 // Status : Approved |
|
66 // --------------------------------------------------------- |
|
67 // |
|
68 CSCPPluginManager* CSCPPluginManager::NewLC( CSCPServer* aServer ) |
|
69 { |
|
70 CSCPPluginManager* self = new (ELeave) CSCPPluginManager( aServer ); |
|
71 |
|
72 CleanupStack::PushL( self ); |
|
73 self->ConstructL(); |
|
74 |
|
75 return self; |
|
76 } |
|
77 |
|
78 |
|
79 // --------------------------------------------------------- |
|
80 // void CSCPPluginManager::ConstructL() |
|
81 // Symbian 2nd phase constructor |
|
82 // |
|
83 // Status : Approved |
|
84 // --------------------------------------------------------- |
|
85 // |
|
86 void CSCPPluginManager::ConstructL() |
|
87 { |
|
88 TEComResolverParams resParams; |
|
89 |
|
90 TRAPD( err, REComSession::ListImplementationsL( |
|
91 KSCPPluginInterfaceUID, |
|
92 resParams, |
|
93 KRomOnlyResolverUid, |
|
94 iImplementations ) ); |
|
95 |
|
96 if ( err != KErrNone ) |
|
97 { |
|
98 // Fatal, we can't get the plugin list |
|
99 Dprint( (_L("CSCPPluginManager::ConstructL(): Failed to get \ |
|
100 the list of plugins: %d"), err )); |
|
101 User::Leave( err ); |
|
102 } |
|
103 } |
|
104 |
|
105 |
|
106 // --------------------------------------------------------- |
|
107 // void CSCPPluginManager::LoadPlugins() |
|
108 // Loop through the availble ROM-based plugins and create the |
|
109 // implementations. |
|
110 // |
|
111 // Status : Approved |
|
112 // --------------------------------------------------------- |
|
113 // |
|
114 void CSCPPluginManager::LoadPluginsL() |
|
115 { |
|
116 CSCPPlugin* thisPlugin = NULL; |
|
117 // Loop through the array and create the implementations |
|
118 for ( TInt i = 0; i < iImplementations.Count(); i++ ) |
|
119 { |
|
120 // We use the implementation UID as the default data |
|
121 // to create each allowed implementation |
|
122 |
|
123 // The buffer should be the UID of the implementation |
|
124 TBuf8<KSCPMaxIntLength> curData = iImplementations[i]->DataType(); |
|
125 |
|
126 TRAPD( err, thisPlugin = CSCPPlugin::NewL( curData ) ); |
|
127 if ( err != KErrNone ) |
|
128 { |
|
129 Dprint( (_L("CSCPPluginManager::LoadPluginsL(): Failed to create\ |
|
130 plugin, UID: %x"), iImplementations[i]->ImplementationUid().iUid )); |
|
131 } |
|
132 else |
|
133 { |
|
134 iPlugins.Append( thisPlugin ); |
|
135 thisPlugin->SetEventHandler( iServer->GetEventHandlerL() ); |
|
136 |
|
137 Dprint( (_L("CSCPPluginManager::LoadPluginsL(): Plugin active,\ |
|
138 UID: %x"), iImplementations[i]->ImplementationUid().iUid )); |
|
139 } |
|
140 } // for |
|
141 |
|
142 // Plugins loaded |
|
143 iPluginsLoaded = ETrue; |
|
144 } |
|
145 |
|
146 |
|
147 // --------------------------------------------------------- |
|
148 // void CSCPPluginManager::PostEvent() |
|
149 // Post an event to the available plugins. |
|
150 // |
|
151 // Status : Approved |
|
152 // --------------------------------------------------------- |
|
153 // |
|
154 CSCPParamObject* CSCPPluginManager::PostEvent( TInt aID, CSCPParamObject& aParam ) |
|
155 { |
|
156 Dprint(_L("[CSCPPluginManager]-> PostEvent() >>>")); |
|
157 // If the plugins aren't loaded, load them here |
|
158 TBool okToPost = ETrue; |
|
159 |
|
160 if ( !iPluginsLoaded ) |
|
161 { |
|
162 TRAPD( err, LoadPluginsL() ); |
|
163 if ( err != KErrNone ) |
|
164 { |
|
165 Dprint( (_L("CSCPPluginManager::PostEvent(): ERROR loading plugins: %d"), err )); |
|
166 okToPost = EFalse; |
|
167 } |
|
168 } |
|
169 |
|
170 CSCPParamObject* reply = NULL; |
|
171 |
|
172 if ( okToPost ) |
|
173 { |
|
174 // Send the incoming event to all plugins |
|
175 TBool continueProcessing = ETrue; |
|
176 |
|
177 for ( TInt i = 0; i < iPlugins.Count(); i++ ) |
|
178 { |
|
179 // The method shouldn't leave, but make sure |
|
180 TRAPD( err, reply = iPlugins[i]->HandleEvent( aID, aParam ) ); |
|
181 if ( err != KErrNone ) |
|
182 { |
|
183 // Plugin error |
|
184 continue; |
|
185 } |
|
186 |
|
187 // Check reply |
|
188 if ( reply != NULL ) |
|
189 { |
|
190 Dprint(_L("[CSCPPluginManager]-> The event '%d' was consumed..."), aID); |
|
191 continueProcessing = EFalse; |
|
192 } |
|
193 else |
|
194 { |
|
195 // No action requested |
|
196 } |
|
197 |
|
198 if ( !continueProcessing ) |
|
199 { |
|
200 break; // Event consumed, don't continue |
|
201 } |
|
202 } |
|
203 } |
|
204 |
|
205 Dprint(_L("[CSCPPluginManager]-> PostEvent() okToPost=%d<<<"), okToPost); |
|
206 return reply; |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------- |
|
210 // void CSCPPluginManager::~CSCPPluginManager() |
|
211 // Destructor |
|
212 // |
|
213 // Status : Approved |
|
214 // --------------------------------------------------------- |
|
215 // |
|
216 CSCPPluginManager::~CSCPPluginManager() |
|
217 { |
|
218 Dprint( (_L("--> CSCPPluginManager::~CSCPPluginManager()") )); |
|
219 |
|
220 // Delete the plugins and infos, and reset the arrays |
|
221 iPlugins.ResetAndDestroy(); |
|
222 iImplementations.ResetAndDestroy(); |
|
223 |
|
224 REComSession::FinalClose(); |
|
225 |
|
226 Dprint( (_L("<-- CSCPPluginManager::~CSCPPluginManager()") )); |
|
227 } |
|
228 |
|
229 |
|
230 // End of File |
|
231 |