183 } |
183 } |
184 } |
184 } |
185 } |
185 } |
186 |
186 |
187 // ---------------------------------------------------------------------------- |
187 // ---------------------------------------------------------------------------- |
|
188 // PointerArrayCleanup() |
|
189 // |
|
190 // An utility function to handle cleanup of RImplInfoPtrArray instances |
|
191 // @param aArray Pointer to RImpInfoPtrArray to be deleted. |
|
192 // Guaranteed not to be NULL. |
|
193 // ---------------------------------------------------------------------------- |
|
194 // |
|
195 static void PointerArrayCleanup( TAny* aArray ) |
|
196 { |
|
197 static_cast< RImplInfoPtrArray* >( aArray )->ResetAndDestroy(); |
|
198 } |
|
199 |
|
200 // ---------------------------------------------------------------------------- |
188 // LoadPluginsL() |
201 // LoadPluginsL() |
189 // ---------------------------------------------------------------------------- |
202 // ---------------------------------------------------------------------------- |
190 // |
203 // |
191 void CAlwaysOnlineManager::LoadPluginsL() |
204 void CAlwaysOnlineManager::LoadPluginsL() |
192 { |
205 { |
193 RImplInfoPtrArray pluginArray; |
206 RImplInfoPtrArray pluginArray; |
|
207 TCleanupItem arrayCleanup( PointerArrayCleanup, &pluginArray ); |
|
208 CleanupStack::PushL( arrayCleanup ); |
194 |
209 |
195 //List all plugins which implement AlwaysOnlineManagerInterface |
210 //List all plugins which implement AlwaysOnlineManagerInterface |
196 REComSession::ListImplementationsL( KCEComInterfaceUid, pluginArray ); |
211 REComSession::ListImplementationsL( KCEComInterfaceUid, pluginArray ); |
197 |
212 |
198 KAOMANAGER_LOGGER_WRITE_FORMAT("CAlwaysOnlineManager::LoadPluginsL() Count of plugins found: %d", pluginArray.Count() ); |
213 KAOMANAGER_LOGGER_WRITE_FORMAT("CAlwaysOnlineManager::LoadPluginsL() Count of plugins found: %d", pluginArray.Count() ); |
202 |
217 |
203 if ( pluginArray.Count() ) |
218 if ( pluginArray.Count() ) |
204 { |
219 { |
205 TInt index = -1; |
220 TInt index = -1; |
206 TKeyArrayFix key( 0, ECmpTInt32 ); |
221 TKeyArrayFix key( 0, ECmpTInt32 ); |
207 TInt result = KErrNotFound; |
|
208 |
222 |
209 for( TInt i = 0; i < pluginArray.Count(); i++ ) |
223 for( TInt i = 0; i < pluginArray.Count(); i++ ) |
210 { |
224 { |
211 CImplementationInformation* info = pluginArray[ i ]; |
225 CImplementationInformation* info = pluginArray[ i ]; |
212 |
226 |
213 TUid id = info->ImplementationUid(); |
227 TUid id = info->ImplementationUid(); |
214 delete info; |
228 |
215 info = NULL; |
229 TInt result( iDisabledPluginUidsArray->Find( id, key, index ) ); |
216 |
|
217 result = iDisabledPluginUidsArray->Find( id, key, index ); |
|
218 // if id is found from disabled plugins list, then we don't |
230 // if id is found from disabled plugins list, then we don't |
219 // load it. |
231 // load it. |
220 if ( result == 0 ) |
232 if ( result == 0 ) |
221 { |
233 { |
222 KAOMANAGER_LOGGER_WRITE_FORMAT("CAlwaysOnlineManager::LoadPluginsL() disabled plugin: 0x%x", id ); |
234 KAOMANAGER_LOGGER_WRITE_FORMAT( "CAlwaysOnlineManager::LoadPluginsL() disabled plugin: 0x%x", id ); |
223 } |
235 } |
224 else |
236 else |
225 { |
237 { |
226 CAlwaysOnlineEComInterface* implementation = NULL; |
238 CAlwaysOnlineEComInterface* implementation( NULL ); |
227 |
239 |
228 //be sure that if plugin leaves, manager doesn't. |
240 //be sure that if plugin leaves, manager doesn't. |
229 //This applies in every place! |
241 //This applies in every place! |
230 TRAPD( err, implementation = |
242 TRAP_IGNORE( implementation = CAlwaysOnlineEComInterface::NewL( id ) ); |
231 CAlwaysOnlineEComInterface::NewL( id ) ); |
243 CleanupStack::PushL( implementation ); |
232 |
244 if ( implementation ) |
233 if ( err == KErrNone ) |
245 { |
234 { |
246 implementation->SetStatusQueryObject( this ); |
235 implementation->SetStatusQueryObject( this ); |
|
236 iPluginArray->AppendL( implementation ); |
247 iPluginArray->AppendL( implementation ); |
237 |
248 |
238 KAOMANAGER_LOGGER_WRITE_FORMAT("CAlwaysOnlineManager::LoadPluginsL() plugin loaded succesfully: 0x%x", id); |
249 KAOMANAGER_LOGGER_WRITE_FORMAT("CAlwaysOnlineManager::LoadPluginsL() plugin loaded succesfully: 0x%x", id); |
239 } |
250 } |
240 else |
251 else |
241 { |
252 { |
242 // Just write to debug log, that all the plugins could not be loaded. |
253 // Just write to debug log, that all the plugins could not be loaded. |
243 // Perhaps there should be some nice way to acknoledge the user or the system! |
254 // Perhaps there should be some nice way to acknoledge the user or the system! |
244 KAOMANAGER_LOGGER_WRITE_FORMAT("CAlwaysOnlineManager::LoadPluginsL() plugin load failed: 0x%x", id); |
255 KAOMANAGER_LOGGER_WRITE_FORMAT("CAlwaysOnlineManager::LoadPluginsL() plugin load failed: 0x%x", id); |
245 } |
256 } |
|
257 CleanupStack::Pop( implementation ); |
246 } |
258 } |
247 }//for |
259 }//for |
248 |
260 |
249 //plugins should be loaded |
261 //plugins should be loaded |
250 iPluginsLoaded = ETrue; |
262 iPluginsLoaded = ETrue; |
254 { |
266 { |
255 KAOMANAGER_LOGGER_WRITE("CAlwaysOnlineManager::LoadPluginsL() NO PLUGINS FOUND!"); |
267 KAOMANAGER_LOGGER_WRITE("CAlwaysOnlineManager::LoadPluginsL() NO PLUGINS FOUND!"); |
256 //no plugins. This shouldn't be, there's something wrong with build. |
268 //no plugins. This shouldn't be, there's something wrong with build. |
257 //if plugins are not in build, server shouldn't be either! |
269 //if plugins are not in build, server shouldn't be either! |
258 } |
270 } |
|
271 CleanupStack::PopAndDestroy(); // arrayCleanup |
259 } |
272 } |
260 |
273 |
261 // ---------------------------------------------------------------------------- |
274 // ---------------------------------------------------------------------------- |
262 // StartPluginsL() |
275 // StartPluginsL() |
263 // ---------------------------------------------------------------------------- |
276 // ---------------------------------------------------------------------------- |