16 */ |
16 */ |
17 |
17 |
18 // System includes |
18 // System includes |
19 #include <ecom/ecom.h> |
19 #include <ecom/ecom.h> |
20 #include <ecom/implementationinformation.h> |
20 #include <ecom/implementationinformation.h> |
21 #include <AknGlobalNote.h> |
|
22 #include <StringLoader.h> |
|
23 #include <e32property.h> // For RProperty |
|
24 |
21 |
25 // User includes |
22 // User includes |
|
23 #include <aisystemuids.hrh> |
|
24 #include <hscontentpublisher.h> |
|
25 #include <hspublisherinfo.h> |
26 #include <aicontentobserver.h> |
26 #include <aicontentobserver.h> |
27 #include <aiutility.h> |
27 #include <aiuicontroller.h> |
28 #include <aiplugintool.h> |
28 |
29 #include <activeidle2domainpskeys.h> // PubSub category |
29 #include "aiuicontrollermanager.h" |
30 #include <activeidle2internalpskeys.h> // PubSub category key and values |
|
31 |
|
32 #include "aipluginfactory.h" |
30 #include "aipluginfactory.h" |
33 #include "aicontentpluginmanager.h" |
|
34 #include "aipluginlifecycleobserver.h" |
|
35 |
|
36 #include "aiuicontroller.h" |
|
37 #include "aifwpanic.h" |
|
38 #include "debug.h" |
31 #include "debug.h" |
39 |
32 |
|
33 // Constants |
|
34 const TUid KDeviceStatusPluginUid = |
|
35 { AI_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_DEVSTAPLUGIN }; |
|
36 |
|
37 _LIT( KDeviceStatusPluginName, "DeviceStatus" ); |
|
38 |
40 |
39 |
41 // ======== LOCAL FUNCTIONS ======== |
40 // ======== LOCAL FUNCTIONS ======== |
42 // ---------------------------------------------------------------------------- |
41 // ---------------------------------------------------------------------------- |
|
42 // IsDeviceStatus() |
|
43 // |
|
44 // ---------------------------------------------------------------------------- |
|
45 // |
|
46 TBool IsDeviceStatus( const THsPublisherInfo& aInfo ) |
|
47 { |
|
48 return ( aInfo.Name() == KDeviceStatusPluginName && |
|
49 aInfo.Uid() == KDeviceStatusPluginUid ); |
|
50 } |
|
51 |
|
52 // ---------------------------------------------------------------------------- |
43 // CleanupResetAndDestroy() |
53 // CleanupResetAndDestroy() |
44 // ---------------------------------------------------------------------------- |
54 // |
45 // |
55 // ---------------------------------------------------------------------------- |
46 template<class T> |
56 // |
|
57 template< class T > |
47 static void CleanupResetAndDestroy( TAny* aObj ) |
58 static void CleanupResetAndDestroy( TAny* aObj ) |
48 { |
59 { |
49 if( aObj ) |
60 static_cast< T* >( aObj )->ResetAndDestroy(); |
50 { |
|
51 static_cast<T*>( aObj )->ResetAndDestroy(); |
|
52 } |
|
53 } |
61 } |
54 |
62 |
55 // ---------------------------------------------------------------------------- |
63 // ---------------------------------------------------------------------------- |
56 // CleanupResetAndDestroyPushL() |
64 // CleanupResetAndDestroyPushL() |
57 // ---------------------------------------------------------------------------- |
65 // |
58 // |
66 // ---------------------------------------------------------------------------- |
59 template<class T> |
67 // |
60 static void CleanupResetAndDestroyPushL(T& aArray) |
68 template< class T > |
61 { |
69 static void CleanupResetAndDestroyPushL( T& aArray ) |
62 CleanupStack::PushL( TCleanupItem( &CleanupResetAndDestroy<T>, &aArray ) ); |
70 { |
|
71 CleanupStack::PushL( |
|
72 TCleanupItem( &CleanupResetAndDestroy< T >, &aArray ) ); |
63 } |
73 } |
64 |
74 |
65 // ======== MEMBER FUNCTIONS ======== |
75 // ======== MEMBER FUNCTIONS ======== |
66 |
76 |
67 // ---------------------------------------------------------------------------- |
77 // ---------------------------------------------------------------------------- |
68 // CAiPluginFactory::CAiPluginFactory() |
78 // CAiPluginFactory::CAiPluginFactory() |
69 // ---------------------------------------------------------------------------- |
79 // |
70 // |
80 // ---------------------------------------------------------------------------- |
71 CAiPluginFactory::CAiPluginFactory( |
81 // |
72 RPointerArray<CAiContentPublisher>& aPlugins, |
82 CAiPluginFactory::CAiPluginFactory( CAiUiControllerManager& aManager ) |
73 CAiContentPluginManager& aManager ) |
83 : iUiControllerManager( aManager ) |
74 : iPlugins( aPlugins ), iManager( aManager ) |
|
75 { |
84 { |
76 } |
85 } |
77 |
86 |
78 // ---------------------------------------------------------------------------- |
87 // ---------------------------------------------------------------------------- |
79 // CAiPluginFactory::~CAiPluginFactory() |
88 // CAiPluginFactory::~CAiPluginFactory() |
|
89 // |
80 // ---------------------------------------------------------------------------- |
90 // ---------------------------------------------------------------------------- |
81 // |
91 // |
82 CAiPluginFactory::~CAiPluginFactory() |
92 CAiPluginFactory::~CAiPluginFactory() |
83 { |
93 { |
84 Release( iPluginTool ); |
94 // All publishers should be already deleted from CAiFw::HandleUiShutdown |
85 |
95 iPublishers.ResetAndDestroy(); |
86 iEComPlugins.ResetAndDestroy(); |
96 |
87 |
97 iEComPlugins.ResetAndDestroy(); |
88 iLifecycleObservers.Reset(); |
98 |
|
99 REComSession::FinalClose(); |
89 } |
100 } |
90 |
101 |
91 // ---------------------------------------------------------------------------- |
102 // ---------------------------------------------------------------------------- |
92 // CAiPluginFactory::NewL() |
103 // CAiPluginFactory::NewL() |
93 // ---------------------------------------------------------------------------- |
104 // |
94 // |
105 // ---------------------------------------------------------------------------- |
95 CAiPluginFactory* CAiPluginFactory::NewL( |
106 // |
96 RPointerArray<CAiContentPublisher>& aPlugins, |
107 CAiPluginFactory* CAiPluginFactory::NewL( CAiUiControllerManager& aManager ) |
97 CAiContentPluginManager& aManager ) |
|
98 { |
108 { |
99 CAiPluginFactory* self = |
109 CAiPluginFactory* self = |
100 new ( ELeave ) CAiPluginFactory( aPlugins, aManager ); |
110 new ( ELeave ) CAiPluginFactory( aManager ); |
101 |
111 |
102 CleanupStack::PushL( self ); |
112 CleanupStack::PushL( self ); |
103 self->ConstructL(); |
113 self->ConstructL(); |
104 CleanupStack::Pop( self ); |
114 CleanupStack::Pop( self ); |
105 return self; |
115 return self; |
106 } |
116 } |
107 |
117 |
108 // ---------------------------------------------------------------------------- |
118 // ---------------------------------------------------------------------------- |
109 // CAiPluginFactory::ConstructL() |
119 // CAiPluginFactory::ConstructL() |
|
120 // |
110 // ---------------------------------------------------------------------------- |
121 // ---------------------------------------------------------------------------- |
111 // |
122 // |
112 void CAiPluginFactory::ConstructL() |
123 void CAiPluginFactory::ConstructL() |
113 { |
124 { |
114 iPluginTool = AiUtility::CreatePluginToolL(); |
125 REComSession::ListImplementationsL( |
115 } |
126 KInterfaceUidHsContentPlugin, iEComPlugins ); |
116 |
127 } |
117 // ---------------------------------------------------------------------------- |
128 |
118 // CAiPluginFactory::AddLifecycleObserverL() |
|
119 // ---------------------------------------------------------------------------- |
|
120 // |
|
121 void CAiPluginFactory::AddLifecycleObserverL( |
|
122 MAiPluginLifecycleObserver& aObserver ) |
|
123 { |
|
124 if( iLifecycleObservers.Find( &aObserver ) == KErrNotFound ) |
|
125 { |
|
126 iLifecycleObservers.AppendL( &aObserver ); |
|
127 } |
|
128 } |
|
129 |
|
130 // ---------------------------------------------------------------------------- |
129 // ---------------------------------------------------------------------------- |
131 // CAiPluginFactory::CreatePluginL() |
130 // CAiPluginFactory::CreatePluginL() |
132 // ---------------------------------------------------------------------------- |
131 // |
133 // |
132 // ---------------------------------------------------------------------------- |
134 void CAiPluginFactory::CreatePluginL( |
133 // |
135 const TAiPublisherInfo& aPublisherInfo, |
134 TInt CAiPluginFactory::CreatePlugin( |
136 RPointerArray<CAiUiController>& aControllerArray ) |
135 const THsPublisherInfo& aPublisherInfo ) |
137 { |
136 { |
138 iEComPlugins.ResetAndDestroy(); |
137 __PRINTS( "*** CAiPluginFactory::CreatePlugin: Start ***" ); |
139 |
138 |
140 // Discover Plugin implementations. |
139 if ( IsDeviceStatus( aPublisherInfo ) ) |
141 __TIME_MARK( ecomOverhead ); |
140 { |
142 |
141 CHsContentPublisher* plugin( PluginByUid( aPublisherInfo.Uid() ) ); |
143 REComSession::ListImplementationsL( |
142 |
144 KInterfaceUidContentPlugin, iEComPlugins ); |
143 if ( plugin ) |
145 |
144 { |
146 __TIME_ENDMARK( "FW: ECom Discover plug-ins", ecomOverhead ); |
145 // Devicestatus plugin already exists, update its namespace |
147 |
146 THsPublisherInfo& info( |
148 iPlugins.ReserveL( iPlugins.Count() + 1 ); |
147 const_cast< THsPublisherInfo& >( plugin->PublisherInfo() ) ); |
149 |
148 |
|
149 info.iNamespace.Copy( aPublisherInfo.Namespace() ); |
|
150 |
|
151 __PRINTS( "*** CAiPluginFactory::CreatePlugin: Done - DeviceStatus plugin updated ***" ); |
|
152 |
|
153 return KErrNone; |
|
154 } |
|
155 } |
|
156 |
150 TBool implFound( EFalse ); |
157 TBool implFound( EFalse ); |
151 |
158 |
152 for( TInt i = 0; i < iEComPlugins.Count(); i++ ) |
159 for( TInt i = 0; i < iEComPlugins.Count(); i++ ) |
153 { |
160 { |
154 CImplementationInformation* information( iEComPlugins[i] ); |
161 CImplementationInformation* information( iEComPlugins[i] ); |
155 |
162 |
156 if( information->ImplementationUid().iUid == aPublisherInfo.iUid.iUid ) |
163 if( information->ImplementationUid().iUid == aPublisherInfo.Uid().iUid ) |
157 { |
164 { |
158 implFound = ETrue; |
165 implFound = ETrue; |
159 break; |
166 break; |
160 } |
167 } |
161 } |
168 } |
162 |
169 |
163 if( aPublisherInfo.iNamespace == KNullDesC8 || !implFound ) |
170 if( aPublisherInfo.Namespace() == KNullDesC8 || !implFound ) |
164 { |
171 { |
165 // No namespace available or no ecom implementation available |
172 // No namespace available or no ecom implementation available |
166 User::Leave( KErrNotSupported ); |
173 __PRINTS( "*** CAiPluginFactory::CreatePlugin: Done - Failed to Load Plug-in: KErrNotSupported ***" ); |
|
174 |
|
175 return KErrNotSupported; |
167 } |
176 } |
168 |
177 |
169 CAiContentPublisher* plugin( PluginByInfoL( aPublisherInfo ) ); |
178 CHsContentPublisher* plugin( PluginByInfo( aPublisherInfo ) ); |
170 |
179 |
171 if( plugin ) |
180 if( plugin ) |
172 { |
181 { |
173 User::Leave( KErrAlreadyExists ); |
182 __PRINTS( "*** CAiPluginFactory::CreatePlugin: Done - Failed to Load Plug-in: KErrAlreadyExists ***" ); |
174 } |
183 |
175 |
184 return KErrAlreadyExists; |
|
185 } |
|
186 |
|
187 TInt err( KErrNone ); |
|
188 |
|
189 TRAP( err, CreatePluginL( aPublisherInfo ) ); |
|
190 |
|
191 __PRINTS( "*** CAiPluginFactory::CreatePlugin: Done - Load Plug-in ***" ); |
|
192 |
|
193 return err; |
|
194 } |
|
195 |
|
196 // ---------------------------------------------------------------------------- |
|
197 // CAiPluginFactory::DestroyPlugin() |
|
198 // |
|
199 // ---------------------------------------------------------------------------- |
|
200 // |
|
201 void CAiPluginFactory::DestroyPlugin( const THsPublisherInfo& aPublisherInfo ) |
|
202 { |
|
203 __PRINTS( "*** CAiPluginFactory::DestroyPlugin: Start ***" ); |
|
204 |
|
205 if ( IsDeviceStatus( aPublisherInfo ) ) |
|
206 { |
|
207 // Don't destroy device status plugin |
|
208 __PRINTS( "*** CAiPluginFactory::DestroyPlugin: Done - Keepind DeviceStatus Plug-in ***" ); |
|
209 |
|
210 return; |
|
211 } |
|
212 |
|
213 CHsContentPublisher* plugin( PluginByInfo( aPublisherInfo ) ); |
|
214 |
|
215 if ( plugin ) |
|
216 { |
|
217 iPublishers.Remove( iPublishers.Find( plugin ) ); |
|
218 |
|
219 delete plugin; |
|
220 plugin = NULL; |
|
221 } |
|
222 |
|
223 __PRINTS( "*** CAiPluginFactory::DestroyPlugin: Done ***" ); |
|
224 } |
|
225 |
|
226 // ---------------------------------------------------------------------------- |
|
227 // CAiPluginFactory::CreatePluginL() |
|
228 // |
|
229 // ---------------------------------------------------------------------------- |
|
230 // |
|
231 void CAiPluginFactory::CreatePluginL( |
|
232 const THsPublisherInfo& aPublisherInfo ) |
|
233 { |
176 __PRINT( __DBG_FORMAT( "\t[I]\t Loading plug-in uid=%x name=%S"), |
234 __PRINT( __DBG_FORMAT( "\t[I]\t Loading plug-in uid=%x name=%S"), |
177 aPublisherInfo.iUid, &(aPublisherInfo.iName) ); |
235 aPublisherInfo.Uid(), &(aPublisherInfo.Name() ) ); |
178 |
236 |
179 __TIME( "FW: Create plug-in:", |
237 __TIME( "FW: Create plug-in:", |
180 plugin = CreatePluginLC( aPublisherInfo ); |
238 |
181 ) // __TIME |
239 iPublishers.ReserveL( iPublishers.Count() + 1 ); |
182 |
240 |
|
241 CHsContentPublisher* plugin = |
|
242 CHsContentPublisher::NewL( aPublisherInfo ) ); |
|
243 CleanupStack::PushL( plugin ); |
|
244 |
183 __TIME( "FW: Subscribe content observers", |
245 __TIME( "FW: Subscribe content observers", |
184 SubscribeContentObserversL( *plugin, |
246 SubscribeContentObserversL( *plugin, aPublisherInfo ) ); |
185 aPublisherInfo, aControllerArray ); |
247 |
186 ) // __TIME |
|
187 |
|
188 // Plug-in settings |
|
189 __TIME( "FW: Configure Plugin", |
248 __TIME( "FW: Configure Plugin", |
190 ConfigurePluginL( aControllerArray, *plugin, aPublisherInfo ); |
249 ConfigurePluginL( *plugin, aPublisherInfo ) ); |
191 ) // __TIME |
250 |
192 |
251 // Take plugin's ownership |
193 __PRINTS( "*** FW: Done - Load Plug-in ***" ); |
252 iPublishers.Append( plugin ); |
194 |
|
195 // This might fail and the plugin ends up destroyed |
|
196 for( TInt i = 0; i < iLifecycleObservers.Count(); ++i ) |
|
197 { |
|
198 iLifecycleObservers[i]->PluginCreatedL( *plugin ); |
|
199 } |
|
200 |
|
201 for( TInt i = 0; i < iLifecycleObservers.Count(); ++i ) |
|
202 { |
|
203 iLifecycleObservers[i]->AllPluginsCreated(); |
|
204 } |
|
205 |
|
206 // Move plugins to manager |
|
207 iPlugins.Append( plugin ); |
|
208 CleanupStack::Pop( plugin ); |
253 CleanupStack::Pop( plugin ); |
209 |
|
210 iEComPlugins.ResetAndDestroy(); |
|
211 } |
|
212 |
|
213 // ---------------------------------------------------------------------------- |
|
214 // CAiPluginFactory::DestroyPluginL() |
|
215 // ---------------------------------------------------------------------------- |
|
216 // |
|
217 void CAiPluginFactory::DestroyPluginL( |
|
218 const TAiPublisherInfo& aPublisherInfo, |
|
219 RPointerArray< CAiUiController >& /*aControllerArray*/ ) |
|
220 { |
|
221 // TODO: check is there need to call |
|
222 // iUiControllerManager->RemovePluginFromUI( aPlugin ); |
|
223 // it will clean the published content. |
|
224 |
|
225 if( iPlugins.Count() == 0 ) |
|
226 { |
|
227 return; |
|
228 } |
|
229 |
|
230 CAiContentPublisher* plugin( PluginByInfoL( aPublisherInfo ) ); |
|
231 |
|
232 TInt index( iPlugins.Find( plugin ) ); |
|
233 |
|
234 if( plugin && index != KErrNotFound ) |
|
235 { |
|
236 for( TInt i = 0; i < iLifecycleObservers.Count(); i++ ) |
|
237 { |
|
238 iLifecycleObservers[i]->PluginDestroyed( *plugin ); |
|
239 } |
|
240 |
|
241 iPlugins.Remove( index ); |
|
242 |
|
243 delete plugin; |
|
244 plugin = NULL; |
|
245 } |
|
246 |
|
247 if( iPlugins.Count() == 0 ) |
|
248 { |
|
249 for( TInt i = 0; i < iLifecycleObservers.Count(); i++ ) |
|
250 { |
|
251 iLifecycleObservers[i]->AllPluginsDestroyed(); |
|
252 } |
|
253 } |
|
254 } |
|
255 |
|
256 // ---------------------------------------------------------------------------- |
|
257 // CAiPluginFactory::DestroyPlugins() |
|
258 // ---------------------------------------------------------------------------- |
|
259 // |
|
260 void CAiPluginFactory::DestroyPlugins() |
|
261 { |
|
262 for( TInt i = 0; i < iPlugins.Count(); i++ ) |
|
263 { |
|
264 CAiContentPublisher* plugin( iPlugins[i] ); |
|
265 |
|
266 for( TInt i = 0; i < iLifecycleObservers.Count(); i++ ) |
|
267 { |
|
268 iLifecycleObservers[i]->PluginDestroyed( *plugin ); |
|
269 } |
|
270 } |
|
271 |
|
272 iPlugins.ResetAndDestroy(); |
|
273 |
|
274 for( TInt i = 0; i < iLifecycleObservers.Count(); i++ ) |
|
275 { |
|
276 iLifecycleObservers[i]->AllPluginsDestroyed(); |
|
277 } |
|
278 } |
|
279 |
|
280 // ---------------------------------------------------------------------------- |
|
281 // CAiPluginFactory::CreatePluginLC() |
|
282 // ---------------------------------------------------------------------------- |
|
283 // |
|
284 CAiContentPublisher* CAiPluginFactory::CreatePluginLC( |
|
285 const TAiPublisherInfo& aPluginInfo ) |
|
286 { |
|
287 CAiContentPublisher* plugin = |
|
288 CAiContentPublisher::NewL( aPluginInfo.iUid ); |
|
289 |
|
290 CleanupStack::PushL( plugin ); |
|
291 |
|
292 MAiPropertyExtension* ext( iPluginTool->PropertyExt( *plugin ) ); |
|
293 |
|
294 if( !ext ) |
|
295 { |
|
296 User::Leave( KErrNotFound ); |
|
297 } |
|
298 |
|
299 ext->SetPropertyL( EAiPublisherInfo, (TAny*)&aPluginInfo ); |
|
300 |
|
301 const TAiPublisherInfo* info( ext->PublisherInfoL() ); |
|
302 |
|
303 if( info->iNamespace != aPluginInfo.iNamespace ) |
|
304 { |
|
305 // SetPropertyL is not implemented correctly |
|
306 User::Leave( KErrNotSupported ); |
|
307 } |
|
308 |
|
309 return plugin; |
|
310 } |
254 } |
311 |
255 |
312 // ---------------------------------------------------------------------------- |
256 // ---------------------------------------------------------------------------- |
313 // CAiPluginFactory::SubscribeContentObserversL() |
257 // CAiPluginFactory::SubscribeContentObserversL() |
|
258 // |
314 // ---------------------------------------------------------------------------- |
259 // ---------------------------------------------------------------------------- |
315 // |
260 // |
316 void CAiPluginFactory::SubscribeContentObserversL( |
261 void CAiPluginFactory::SubscribeContentObserversL( |
317 CAiContentPublisher& aContentPublisher, |
262 CHsContentPublisher& aContentPublisher, |
318 const TAiPublisherInfo& aPublisherInfo, |
263 const THsPublisherInfo& aPublisherInfo ) |
319 RPointerArray<CAiUiController>& aControllerArray ) |
264 { |
320 { |
265 RPointerArray< CAiUiController >& |
321 |
266 controllers( iUiControllerManager.UiControllers() ); |
322 for( TInt i = 0; i < aControllerArray.Count(); i++ ) |
267 |
|
268 for( TInt i = 0; i < controllers.Count(); i++ ) |
323 { |
269 { |
324 MAiContentObserver& observer( |
270 MAiContentObserver& observer( |
325 aControllerArray[i]->GetContentObserver() ); |
271 controllers[i]->GetContentObserver() ); |
326 |
272 |
327 if ( observer.RequiresSubscription( aPublisherInfo ) ) |
273 if ( observer.RequiresSubscription( aPublisherInfo ) ) |
328 { |
274 { |
329 // Subscribe observer only if it understands the plugin |
275 // Subscribe observer only if it understands the plugin |
330 aContentPublisher.SubscribeL( observer ); |
276 aContentPublisher.SubscribeL( observer ); |
332 } |
278 } |
333 } |
279 } |
334 |
280 |
335 // ---------------------------------------------------------------------------- |
281 // ---------------------------------------------------------------------------- |
336 // CAiPluginFactory::ConfigurePluginL() |
282 // CAiPluginFactory::ConfigurePluginL() |
337 // ---------------------------------------------------------------------------- |
283 // |
338 // |
284 // ---------------------------------------------------------------------------- |
339 void CAiPluginFactory::ConfigurePluginL( |
285 // |
340 RPointerArray<CAiUiController>& aControllerArray, |
286 void CAiPluginFactory::ConfigurePluginL( |
341 CAiContentPublisher& aContentPublisher, |
287 CHsContentPublisher& aContentPublisher, |
342 const TAiPublisherInfo& aPubInfo ) |
288 const THsPublisherInfo& aPublisherInfo ) |
343 { |
289 { |
344 RAiSettingsItemArray pluginSettings; |
290 RAiSettingsItemArray settings; |
345 CleanupResetAndDestroyPushL( pluginSettings ); |
291 CleanupResetAndDestroyPushL( settings ); |
346 |
292 |
347 for( TInt i = 0; i < aControllerArray.Count(); i++ ) |
293 RPointerArray< CAiUiController >& |
|
294 controllers( iUiControllerManager.UiControllers() ); |
|
295 |
|
296 for( TInt i = 0; i < controllers.Count(); i++ ) |
348 { |
297 { |
349 // Get settings for plug-in |
298 // Get settings for plug-in |
350 aControllerArray[i]->GetSettingsL( aPubInfo, pluginSettings ); |
299 controllers[i]->GetSettingsL( aPublisherInfo, settings ); |
351 } |
300 } |
352 |
301 |
353 // Configure plug-in with its settings |
302 // Configure plug-in with its settings |
354 aContentPublisher.ConfigureL( pluginSettings ); |
303 aContentPublisher.ConfigureL( settings ); |
355 |
304 |
356 CleanupStack::PopAndDestroy( &pluginSettings ); |
305 CleanupStack::PopAndDestroy( &settings ); |
357 } |
306 } |
358 |
307 |
359 // ---------------------------------------------------------------------------- |
308 // ---------------------------------------------------------------------------- |
360 // CAiPluginFactory::PluginByInfoL() |
309 // CAiPluginFactory::PluginByInfo() |
361 // ---------------------------------------------------------------------------- |
310 // Gets plugin by publisher info. Only this overload returns the exact match |
362 // |
311 // ---------------------------------------------------------------------------- |
363 CAiContentPublisher* CAiPluginFactory::PluginByInfoL( |
312 // |
364 const TAiPublisherInfo& aInfo ) const |
313 CHsContentPublisher* CAiPluginFactory::PluginByInfo( |
|
314 const THsPublisherInfo& aPublisherInfo ) const |
365 { |
315 { |
366 for( TInt i = 0; i < iPlugins.Count(); i++ ) |
316 for( TInt i = 0; i < iPublishers.Count(); i++ ) |
367 { |
317 { |
368 const TAiPublisherInfo* info( NULL ); |
318 const THsPublisherInfo& info( iPublishers[i]->PublisherInfo() ); |
369 |
319 |
370 info = iPluginTool->PublisherInfoL( *iPlugins[i] ); |
320 if( aPublisherInfo == info ) |
371 |
321 { |
372 if( info && ( aInfo == *info ) ) |
322 return iPublishers[i]; |
373 { |
|
374 return iPlugins[i]; |
|
375 } |
323 } |
376 } |
324 } |
377 |
325 |
378 return NULL; |
326 return NULL; |
379 } |
327 } |
380 |
328 |
381 // ---------------------------------------------------------------------------- |
329 // ---------------------------------------------------------------------------- |
382 // CAiPluginFactory::PluginByNameL() |
330 // CAiPluginFactory::PluginByUid() |
383 // ---------------------------------------------------------------------------- |
331 // Gets plugin by UID |
384 // |
332 // ---------------------------------------------------------------------------- |
385 CAiContentPublisher* CAiPluginFactory::PluginByNameL( |
333 // |
|
334 CHsContentPublisher* CAiPluginFactory::PluginByUid( const TUid& aUid ) const |
|
335 { |
|
336 for( TInt i = 0; i < iPublishers.Count(); i++ ) |
|
337 { |
|
338 const THsPublisherInfo& info( iPublishers[i]->PublisherInfo() ); |
|
339 |
|
340 if( info.Uid() == aUid ) |
|
341 { |
|
342 return iPublishers[i]; |
|
343 } |
|
344 } |
|
345 |
|
346 return NULL; |
|
347 } |
|
348 |
|
349 // ---------------------------------------------------------------------------- |
|
350 // CAiPluginFactory::PluginByName() |
|
351 // Gets plugin by name |
|
352 // ---------------------------------------------------------------------------- |
|
353 // |
|
354 CHsContentPublisher* CAiPluginFactory::PluginByName( |
386 const TDesC& aName ) const |
355 const TDesC& aName ) const |
387 { |
356 { |
388 for( TInt i = 0; i < iPlugins.Count(); i++ ) |
357 for( TInt i = 0; i < iPublishers.Count(); i++ ) |
389 { |
358 { |
390 const TAiPublisherInfo* info( NULL ); |
359 const THsPublisherInfo& info( iPublishers[i]->PublisherInfo() ); |
391 |
360 |
392 TRAP_IGNORE( info = iPluginTool->PublisherInfoL( *iPlugins[i] ) ); |
361 if( info.Name() == aName ) |
393 |
362 { |
394 if( info && info->iName == aName ) |
363 return iPublishers[i]; |
395 { |
|
396 return iPlugins[i]; |
|
397 } |
364 } |
398 } |
365 } |
399 |
366 |
400 return NULL; |
367 return NULL; |
401 } |
368 } |
402 |
369 |
|
370 // ---------------------------------------------------------------------------- |
|
371 // CAiPluginFactory::Publishers() |
|
372 // |
|
373 // ---------------------------------------------------------------------------- |
|
374 // |
|
375 RPointerArray< CHsContentPublisher >& CAiPluginFactory::Publishers() const |
|
376 { |
|
377 return iPublishers; |
|
378 } |
|
379 |
|
380 // ---------------------------------------------------------------------------- |
|
381 // CAiPluginFactory::ResolvePluginsToUpgradeL() |
|
382 // |
|
383 // ---------------------------------------------------------------------------- |
|
384 // |
|
385 void CAiPluginFactory::ResolvePluginsToUpgradeL( |
|
386 RArray< THsPublisherInfo >& aArray ) |
|
387 { |
|
388 RImplInfoPtrArray ecomPlugins; |
|
389 CleanupResetAndDestroyPushL( ecomPlugins ); |
|
390 |
|
391 REComSession::ListImplementationsL( |
|
392 KInterfaceUidHsContentPlugin, ecomPlugins ); |
|
393 |
|
394 for ( TInt i = 0; i < ecomPlugins.Count(); i++ ) |
|
395 { |
|
396 CImplementationInformation* newInformation( ecomPlugins[i] ); |
|
397 |
|
398 for( TInt j = 0; j < iEComPlugins.Count(); j++ ) |
|
399 { |
|
400 CImplementationInformation* oldInformation( iEComPlugins[j] ); |
|
401 |
|
402 if( newInformation->ImplementationUid() == oldInformation->ImplementationUid() ) |
|
403 { |
|
404 if( newInformation->Version() != oldInformation->Version() ) |
|
405 { |
|
406 for ( TInt k = 0; k < iPublishers.Count(); k++ ) |
|
407 { |
|
408 const THsPublisherInfo& info( |
|
409 iPublishers[k]->PublisherInfo() ); |
|
410 |
|
411 if ( info.Uid() == newInformation->ImplementationUid() ) |
|
412 { |
|
413 __PRINT( __DBG_FORMAT( "\t[I]\t Plug-in to update uid=%x name=%S namespace=%S, version update %d to %d"), |
|
414 info.Uid(), &(info.Name()), &(info.Namespace()), oldInformation->Version(), newInformation->Version() ); |
|
415 |
|
416 aArray.Append( info ); |
|
417 } |
|
418 } |
|
419 |
|
420 break; |
|
421 } |
|
422 } |
|
423 } |
|
424 } |
|
425 |
|
426 CleanupStack::PopAndDestroy( &ecomPlugins ); |
|
427 |
|
428 // Update ecom plugin array |
|
429 iEComPlugins.ResetAndDestroy(); |
|
430 |
|
431 REComSession::ListImplementationsL( |
|
432 KInterfaceUidHsContentPlugin, iEComPlugins ); |
|
433 } |
|
434 |
403 // End of file |
435 // End of file |