149 // Post an event to the available plugins. |
149 // Post an event to the available plugins. |
150 // |
150 // |
151 // Status : Approved |
151 // Status : Approved |
152 // --------------------------------------------------------- |
152 // --------------------------------------------------------- |
153 // |
153 // |
154 CSCPParamObject* CSCPPluginManager :: PostEvent(TInt aID, CSCPParamObject& aParam) { |
154 CSCPParamObject* CSCPPluginManager::PostEvent( TInt aID, CSCPParamObject& aParam ) |
|
155 { |
155 Dprint(_L("[CSCPPluginManager]-> PostEvent() >>>")); |
156 Dprint(_L("[CSCPPluginManager]-> PostEvent() >>>")); |
156 // If the plugins aren't loaded, load them here |
157 // If the plugins aren't loaded, load them here |
157 TBool okToPost = ETrue; |
158 TBool okToPost = ETrue; |
158 TInt lErr = KErrNone; |
159 |
159 |
160 if ( !iPluginsLoaded ) |
160 if(!iPluginsLoaded) { |
161 { |
161 TRAP(lErr, LoadPluginsL()); |
162 TRAPD( err, LoadPluginsL() ); |
162 |
163 if ( err != KErrNone ) |
163 if(lErr != KErrNone) { |
164 { |
164 Dprint((_L("CSCPPluginManager::PostEvent(): ERROR loading plugins: %d"), lErr)); |
165 Dprint( (_L("CSCPPluginManager::PostEvent(): ERROR loading plugins: %d"), err )); |
165 okToPost = EFalse; |
166 okToPost = EFalse; |
|
167 } |
166 } |
168 } |
167 } |
169 |
168 |
|
169 lErr = KErrNone; |
|
170 CSCPParamObject* reply = NULL; |
170 CSCPParamObject* reply = NULL; |
171 |
171 |
172 TRAP(lErr, reply = CSCPParamObject :: NewL()); |
172 if ( okToPost ) |
173 |
173 { |
174 if(lErr != KErrNone) { |
174 // Send the incoming event to all plugins |
175 return NULL; |
175 TBool continueProcessing = ETrue; |
176 } |
176 |
177 |
177 for ( TInt i = 0; i < iPlugins.Count(); i++ ) |
178 lErr = KErrNone; |
178 { |
179 TInt lPolicyRunStatus = KErrNone; |
|
180 |
|
181 if(okToPost) { |
|
182 // Send the incoming event to all plugins |
|
183 for(TInt i = 0; i < iPlugins.Count(); i++) { |
|
184 // The method shouldn't leave, but make sure |
179 // The method shouldn't leave, but make sure |
185 TRAP(lErr, iPlugins[i]->HandleEventL(aID, aParam, *reply)); |
180 TRAPD( err, reply = iPlugins[i]->HandleEvent( aID, aParam ) ); |
186 |
181 if ( err != KErrNone ) |
187 if(reply->Get(KSCPParamStatus, lPolicyRunStatus) == KErrNone) { |
182 { |
188 if(lPolicyRunStatus != KErrNone) { |
183 // Plugin error |
189 lErr = lPolicyRunStatus; |
184 continue; |
190 } |
185 } |
191 } |
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 } |
192 } |
203 } |
193 |
|
194 reply->Set(KSCPParamStatus, lErr); |
|
195 } |
|
196 |
204 |
197 Dprint(_L("[CSCPPluginManager]-> PostEvent() okToPost=%d<<<"), okToPost); |
205 Dprint(_L("[CSCPPluginManager]-> PostEvent() okToPost=%d<<<"), okToPost); |
198 return reply; |
206 return reply; |
199 } |
207 } |
200 |
208 |
201 // --------------------------------------------------------- |
209 // --------------------------------------------------------- |
202 // void CSCPPluginManager::~CSCPPluginManager() |
210 // void CSCPPluginManager::~CSCPPluginManager() |
203 // Destructor |
211 // Destructor |
204 // |
212 // |