13 * |
13 * |
14 * Description: MCS plugin publisher |
14 * Description: MCS plugin publisher |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 // System includes |
19 #include <ecom/ecom.h> |
19 #include <ecom/ecom.h> |
20 #include <ecom/implementationproxy.h> |
20 #include <ecom/implementationproxy.h> |
21 #include <gulicon.h> |
21 #include <gulicon.h> |
|
22 #include <mcsmenuitem.h> |
|
23 |
|
24 // User includes |
22 #include <aicontentobserver.h> |
25 #include <aicontentobserver.h> |
23 #include <aiutility.h> |
26 #include <aiutility.h> |
24 #include <aistrcnv.h> |
27 #include <aistrcnv.h> |
25 #include <mcsmenuitem.h> |
|
26 |
|
27 #include <aknskinsinternalcrkeys.h> // For working with settings API |
|
28 #include <centralrepository.h> // Headers Used for CRepository |
|
29 |
|
30 #include "mcspluginuids.hrh" |
28 #include "mcspluginuids.hrh" |
31 #include "mcsplugin.h" |
29 #include "mcsplugin.h" |
32 #include "mcsplugindata.h" |
30 #include "mcsplugindata.h" |
33 #include "mcspluginengine.h" |
31 #include "mcspluginengine.h" |
34 #include "aipluginsettings.h" |
32 #include "aipluginsettings.h" |
35 |
33 |
36 |
34 // Constants |
37 const TUint KPluginNameSeprator = '/'; |
35 const TUint KPluginNameSeprator = '/'; |
38 |
36 |
39 const TInt KImplUidMCSPlugin = AI_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_MCSPLUGIN; |
37 const TInt KImplUidMCSPlugin = AI_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_MCSPLUGIN; |
40 // CONST CLASS VARIABLES |
|
41 const TImplementationProxy KImplementationTable[] = |
|
42 { |
|
43 IMPLEMENTATION_PROXY_ENTRY( KImplUidMCSPlugin, CMCSPlugin::NewL ) |
|
44 }; |
|
45 |
38 |
46 _LIT( KEventNameLaunchByIndex, "LaunchByIndex" ); |
39 _LIT( KEventNameLaunchByIndex, "LaunchByIndex" ); |
47 _LIT( KEventNameShowSettings, "ShowSettings" ); |
40 _LIT( KEventNameShowSettings, "ShowSettings" ); |
48 _LIT( KContentItemTypeText, "text" ); |
41 _LIT( KContentItemTypeText, "text" ); |
49 _LIT( KContentItemTypeImage, "image" ); |
42 _LIT( KContentItemTypeImage, "image" ); |
50 |
43 |
|
44 const TImplementationProxy KImplementationTable[] = |
|
45 { |
|
46 IMPLEMENTATION_PROXY_ENTRY( KImplUidMCSPlugin, CMCSPlugin::NewL ) |
|
47 }; |
|
48 |
51 // ======== LOCAL FUNCTIONS ======== |
49 // ======== LOCAL FUNCTIONS ======== |
52 |
50 |
53 // ======== MEMBER FUNCTIONS ======== |
51 // ======== MEMBER FUNCTIONS ======== |
54 |
52 // ---------------------------------------------------------------------------- |
55 // --------------------------------------------------------------------------- |
53 // CMCSPlugin::NewL |
56 // Symbian 2nd phase constructor can leave |
54 // |
57 // --------------------------------------------------------------------------- |
55 // ---------------------------------------------------------------------------- |
58 // |
56 // |
59 CMCSPlugin* CMCSPlugin::NewL() |
57 CMCSPlugin* CMCSPlugin::NewL() |
60 { |
58 { |
61 CMCSPlugin* self = new (ELeave) CMCSPlugin; |
59 CMCSPlugin* self = new ( ELeave ) CMCSPlugin; |
62 CleanupStack::PushL( self ); |
60 CleanupStack::PushL( self ); |
63 self->ConstructL(); |
61 self->ConstructL(); |
64 CleanupStack::Pop( self ); |
62 CleanupStack::Pop( self ); |
65 |
63 |
66 return self; |
64 return self; |
67 } |
65 } |
68 |
66 |
69 // --------------------------------------------------------------------------- |
67 // ---------------------------------------------------------------------------- |
70 // Default constructor |
68 // CMCSPlugin::CMCSPlugin |
71 // --------------------------------------------------------------------------- |
69 // |
|
70 // ---------------------------------------------------------------------------- |
72 // |
71 // |
73 CMCSPlugin::CMCSPlugin() |
72 CMCSPlugin::CMCSPlugin() |
74 { |
73 { |
75 } |
74 } |
76 |
75 |
77 // --------------------------------------------------------------------------- |
76 // ---------------------------------------------------------------------------- |
78 // Symbian 2nd phase constructor can leave |
77 // CMCSPlugin::ConstructL |
79 // --------------------------------------------------------------------------- |
78 // |
|
79 // ---------------------------------------------------------------------------- |
80 // |
80 // |
81 void CMCSPlugin::ConstructL() |
81 void CMCSPlugin::ConstructL() |
82 { |
82 { |
83 iInfo.iUid.iUid = AI_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_MCSPLUGIN; |
83 } |
84 // We need to Query Central Repository |
84 |
85 iRepository = CRepository::NewL( KCRUidPersonalisation ); |
85 // ---------------------------------------------------------------------------- |
86 |
|
87 // Setting up watcher which calls HandleNotifyL method |
|
88 // everytime the SkinUID changes in central repository |
|
89 iRepositoryWatcher = CMCSPluginWatcher::NewL( CMCSPluginWatcher::ENotify ); |
|
90 iRepository->NotifyRequest( KPslnActiveSkinUid, iRepositoryWatcher->iStatus ); |
|
91 iRepositoryWatcher->WatchNotify( this ); |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // Handle Skin UID change |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 void CMCSPlugin::HandleNotifyL() |
|
99 { |
|
100 |
|
101 // Skin ID has changed. Set all MenuItems on Widget dirty |
|
102 // and re-publish to update icons |
|
103 if ( iEngine ) |
|
104 { |
|
105 TInt dataCount = iEngine->MenuItemCount(); |
|
106 for ( TInt i = 0; i < dataCount; i++ ) |
|
107 { |
|
108 iEngine->MenuDataL( i ).SetDirty( ETrue ); |
|
109 } |
|
110 PublishL(); |
|
111 } |
|
112 |
|
113 // Skin ID Notification must be activated again |
|
114 iRepositoryWatcher->Cancel(); |
|
115 iRepository->NotifyRequest( KPslnActiveSkinUid, iRepositoryWatcher->iStatus ); |
|
116 iRepositoryWatcher->WatchNotify( this ); |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // Destructor |
86 // Destructor |
121 // Deletes all data created to heap |
87 // Deletes all data created to heap |
122 // --------------------------------------------------------------------------- |
88 // ---------------------------------------------------------------------------- |
123 // |
89 // |
124 CMCSPlugin::~CMCSPlugin() |
90 CMCSPlugin::~CMCSPlugin() |
125 { |
91 { |
126 Release( iContent ); |
92 Release( iContent ); |
127 |
93 |
195 { |
147 { |
196 iEngine->MenuDataL( j ).SetDirty( EFalse ); |
148 iEngine->MenuDataL( j ).SetDirty( EFalse ); |
197 } |
149 } |
198 } |
150 } |
199 |
151 |
200 // --------------------------------------------------------------------------- |
152 // ---------------------------------------------------------------------------- |
|
153 // CMCSPlugin::PublishLItemL |
201 // Publishes one item to given index |
154 // Publishes one item to given index |
202 // --------------------------------------------------------------------------- |
155 // ---------------------------------------------------------------------------- |
203 // |
156 // |
204 void CMCSPlugin::PublishLItemL( MAiContentObserver& aObserver, TMCSData& aData, TInt aIndex ) |
157 void CMCSPlugin::PublishLItemL( MAiContentObserver& aObserver, |
205 { |
158 TMCSData& aData, TInt aIndex ) |
206 |
159 { |
207 if( !aData.IsDirty() ) |
160 if( !aData.IsDirty() ) |
208 { |
161 { |
209 return; |
162 return; |
210 } |
163 } |
211 |
164 |
212 CMenuItem* item = iEngine->FetchMenuItemL( aData.MenuItem() ); |
165 CMenuItem* item( iEngine->FetchMenuItemL( aData.MenuItem() ) ); |
213 CleanupStack::PushL( item ); |
166 CleanupStack::PushL( item ); |
|
167 |
214 // One widget item has iDataCount number of elements |
168 // One widget item has iDataCount number of elements |
215 for ( TInt i = 0; i < iDataCount; i++ ) |
169 for ( TInt i = 0; i < iDataCount; i++ ) |
216 { |
170 { |
217 if ( iContentModel[i].type == KAiContentTypeBitmap ) |
171 if ( iContentModel[i].type == KAiContentTypeBitmap ) |
218 { |
172 { |
219 //Publish image |
173 //Publish image |
220 if ( aObserver.CanPublish( *this, i, aIndex ) ) |
174 if ( aObserver.CanPublish( *this, i, aIndex ) ) |
221 { |
175 { |
222 CGulIcon* icon = iEngine->ItemIconL( *item, TPtrC16( ( const TText16* ) iContentModel[ i ].cid ) ); |
176 CGulIcon* icon( iEngine->ItemIconL( *item, |
|
177 TPtrC16( ( const TText16* ) iContentModel[ i ].cid ) ) ); |
|
178 |
223 aObserver.PublishPtr( *this, i, icon , aIndex ); |
179 aObserver.PublishPtr( *this, i, icon , aIndex ); |
224 } |
180 } |
225 } |
181 } |
226 else if ( iContentModel[ i ].type == KAiContentTypeText ) |
182 else if ( iContentModel[i].type == KAiContentTypeText ) |
227 { |
183 { |
228 //Publish text |
184 //Publish text |
229 if ( aObserver.CanPublish( *this, i, aIndex ) ) |
185 if ( aObserver.CanPublish( *this, i, aIndex ) ) |
230 { |
186 { |
231 TPtrC name = iEngine->ItemTextL( *item, TPtrC16( ( const TText16* ) iContentModel[ i ].cid ) ); |
187 TPtrC name( iEngine->ItemTextL( *item, |
|
188 TPtrC16( ( const TText16* ) iContentModel[ i ].cid ) ) ); |
|
189 |
232 aObserver.Publish( *this, i, name, aIndex ); |
190 aObserver.Publish( *this, i, name, aIndex ); |
233 } |
191 } |
234 } |
192 } |
235 }//content items |
193 }//content items |
236 |
194 |
237 CleanupStack::PopAndDestroy( item ); |
195 CleanupStack::PopAndDestroy( item ); |
238 |
196 } |
239 } |
197 |
240 |
198 // ---------------------------------------------------------------------------- |
241 // --------------------------------------------------------------------------- |
199 // CMCSPlugin::Start |
242 // From class CAiContentPublisher |
200 // |
243 // Plug-in is requested to unload its engines due backup operation |
201 // ---------------------------------------------------------------------------- |
244 // --------------------------------------------------------------------------- |
202 // |
245 // |
203 void CMCSPlugin::Start( TStartReason /*aReason*/ ) |
246 void CMCSPlugin::Stop( TAiTransitionReason aReason ) |
204 { |
247 { |
205 } |
248 |
206 |
249 if ( aReason == EAiBackupRestoreStarted ) |
207 // ---------------------------------------------------------------------------- |
250 { |
208 // CMCSPlugin::Stop |
251 Suspend( aReason ); |
209 // |
252 } |
210 // ---------------------------------------------------------------------------- |
253 |
211 // |
254 } |
212 void CMCSPlugin::Stop( TStopReason /*aReason*/ ) |
255 |
213 { |
256 // --------------------------------------------------------------------------- |
214 } |
257 // From class CAiContentPublisher |
215 |
258 // Plug-in is instructed that it is allowed to consume CPU resources |
216 // ---------------------------------------------------------------------------- |
259 // --------------------------------------------------------------------------- |
217 // CMCSPlugin::Resume |
260 // |
218 // |
261 void CMCSPlugin::Resume( TAiTransitionReason aReason ) |
219 // ---------------------------------------------------------------------------- |
262 { |
220 // |
263 if( aReason == EAiIdleBackground ) |
221 void CMCSPlugin::Resume( TResumeReason aReason ) |
264 { |
222 { |
265 return; |
223 if ( aReason == EForeground ) |
266 } |
224 { |
267 |
225 iEngine->SetBackupRestore( EFalse ); |
268 if ( aReason == EAiBackupRestoreEnded ) |
226 |
269 { |
227 if ( PublishRequired() ) |
270 if ( iEngine ) |
228 { |
271 { |
229 TRAP_IGNORE( PublishL() ); |
272 TRAP_IGNORE( iEngine->ResumeL() ); |
230 } |
273 } |
231 } |
274 } |
232 } |
275 |
233 |
276 TRAP_IGNORE( DoResumeL( aReason ) ); |
234 // ---------------------------------------------------------------------------- |
277 return; |
235 // CMCSPlugin::Suspend |
278 } |
236 // |
279 |
237 // ---------------------------------------------------------------------------- |
280 // --------------------------------------------------------------------------- |
238 // |
281 // From class CAiContentPublisher |
239 void CMCSPlugin::Suspend( TSuspendReason aReason ) |
282 // Plug-in is instructed that it is not allowed to consume CPU resources |
240 { |
283 // --------------------------------------------------------------------------- |
241 if ( aReason == EGeneralThemeChange ) |
284 // |
242 { |
285 void CMCSPlugin::Suspend( TAiTransitionReason aReason ) |
243 TInt dataCount( iEngine->MenuItemCount() ); |
286 { |
244 |
287 if ( aReason == EAiBackupRestoreStarted && iEngine ) |
245 for ( TInt i = 0; i < dataCount; i++ ) |
288 { |
246 { |
289 iEngine->Suspend(); |
247 TRAP_IGNORE( iEngine->MenuDataL( i ).SetDirty( ETrue ) ); |
290 } |
248 } |
291 } |
249 } |
292 |
250 else if ( aReason == EBackupRestore ) |
293 // --------------------------------------------------------------------------- |
251 { |
294 // From class CAiContentPublisher |
252 // Prevent item launching during backup / restore |
295 // The plug-in MUST maintain a registry of subscribers and send |
253 iEngine->SetBackupRestore( ETrue ); |
296 // notification to all of them whenever the state changes or new content |
254 } |
297 // is available |
255 } |
298 // --------------------------------------------------------------------------- |
256 |
|
257 // ---------------------------------------------------------------------------- |
|
258 // CMCSPlugin::SubscribeL |
|
259 // |
|
260 // ---------------------------------------------------------------------------- |
299 // |
261 // |
300 void CMCSPlugin::SubscribeL( MAiContentObserver& aObserver ) |
262 void CMCSPlugin::SubscribeL( MAiContentObserver& aObserver ) |
301 { |
263 { |
302 iObservers.AppendL( &aObserver ); |
264 iObservers.AppendL( &aObserver ); |
303 } |
265 } |
304 |
266 |
305 // --------------------------------------------------------------------------- |
267 // ---------------------------------------------------------------------------- |
306 // Compare method to exclude the similar content items from array. |
268 // CMCSPlugin::ConfigureL |
307 // --------------------------------------------------------------------------- |
269 // |
|
270 // ---------------------------------------------------------------------------- |
|
271 // |
|
272 void CMCSPlugin::ConfigureL( RAiSettingsItemArray& aSettings ) |
|
273 { |
|
274 iEngine = CMCSPluginEngine::NewL( *this, PublisherInfo().Namespace() ); |
|
275 |
|
276 TLinearOrder<MAiPluginSettings> sortMethod( CMCSPlugin::CompareItems ); |
|
277 RAiSettingsItemArray contentItemsArr; |
|
278 |
|
279 TInt count( aSettings.Count() ); |
|
280 |
|
281 for ( TInt i = 0; i < count; i++ ) |
|
282 { |
|
283 MAiPluginSettings* setting( aSettings[ i ] ); |
|
284 |
|
285 if( setting->AiPluginItemType() == EAiPluginContentItem ) |
|
286 { |
|
287 MAiPluginContentItem& contItem( setting->AiPluginContentItem() ); |
|
288 TPtrC name( contItem.Name() ); |
|
289 TPtrC type( contItem.Type() ); |
|
290 |
|
291 contentItemsArr.InsertInOrder( setting, sortMethod ); |
|
292 } |
|
293 } |
|
294 |
|
295 iDataCount = contentItemsArr.Count(); |
|
296 |
|
297 if ( iDataCount > 0 ) |
|
298 { |
|
299 // Create the dynamic content Model |
|
300 DeleteContentModel(); |
|
301 |
|
302 iContentModel = new ( ELeave ) TAiContentItem[ iDataCount ]; |
|
303 |
|
304 for ( TInt i = 0; i < iDataCount; i++ ) |
|
305 { |
|
306 iContentModel[i].id = i; |
|
307 |
|
308 MAiPluginContentItem& contentItem( |
|
309 contentItemsArr[ i ]->AiPluginContentItem() ); |
|
310 |
|
311 if( contentItem.Type() == KContentItemTypeText ) |
|
312 { |
|
313 // text |
|
314 iContentModel[i].type = KAiContentTypeText; |
|
315 } |
|
316 if( contentItem.Type() == KContentItemTypeImage ) |
|
317 { |
|
318 // image |
|
319 iContentModel[i].type = KAiContentTypeBitmap; |
|
320 } |
|
321 |
|
322 TInt pos( contentItem.Name().Locate( KPluginNameSeprator ) ); |
|
323 |
|
324 HBufC* contentId = HBufC::NewL( contentItem.Name().Length() ); |
|
325 CleanupStack::PushL( contentId ); |
|
326 |
|
327 TPtr ptr( contentId->Des() ); |
|
328 ptr = contentItem.Name().Mid( pos + 1 ); |
|
329 |
|
330 TInt sizeOfContentId( ptr.Size() + sizeof( wchar_t ) ); |
|
331 |
|
332 iContentModel[i].cid = |
|
333 static_cast<const wchar_t*>( User::AllocL( sizeOfContentId ) ); |
|
334 |
|
335 Mem::Copy( ( TAny* )iContentModel[i].cid, |
|
336 ptr.PtrZ(), sizeOfContentId ); |
|
337 |
|
338 CleanupStack::PopAndDestroy( contentId ); |
|
339 } |
|
340 |
|
341 iContent = AiUtility::CreateContentItemArrayIteratorL( |
|
342 iContentModel, iDataCount ); |
|
343 } |
|
344 |
|
345 contentItemsArr.Reset(); |
|
346 // We own the array so destroy it |
|
347 aSettings.ResetAndDestroy(); |
|
348 } |
|
349 |
|
350 // ---------------------------------------------------------------------------- |
|
351 // CMCSPlugin::GetProperty |
|
352 // |
|
353 // ---------------------------------------------------------------------------- |
|
354 // |
|
355 TAny* CMCSPlugin::GetProperty( TProperty aProperty ) |
|
356 { |
|
357 if( aProperty == EPublisherContent ) |
|
358 { |
|
359 return static_cast< MAiContentItemIterator* >( iContent ); |
|
360 } |
|
361 |
|
362 return NULL; |
|
363 } |
|
364 |
|
365 // ---------------------------------------------------------------------------- |
|
366 // CMCSPlugin::HandleEvent |
|
367 // |
|
368 // ---------------------------------------------------------------------------- |
|
369 // |
|
370 void CMCSPlugin::HandleEvent( const TDesC& aEventName, const TDesC& aParam ) |
|
371 { |
|
372 if( aEventName == KEventNameLaunchByIndex ) |
|
373 { |
|
374 TInt32 index; |
|
375 AiUtility::ParseInt( index, aParam ); |
|
376 |
|
377 TRAP_IGNORE( iEngine->LaunchItemL( index - 1 ) ); |
|
378 } |
|
379 else if( aEventName == KEventNameShowSettings ) |
|
380 { |
|
381 TRAP_IGNORE( iEngine->ShowSettingsL() ); |
|
382 } |
|
383 } |
|
384 |
|
385 // ---------------------------------------------------------------------------- |
|
386 // CMCSPlugin::CompareItems |
|
387 // |
|
388 // ---------------------------------------------------------------------------- |
308 // |
389 // |
309 TInt CMCSPlugin::CompareItems( const MAiPluginSettings& aFirst, |
390 TInt CMCSPlugin::CompareItems( const MAiPluginSettings& aFirst, |
310 const MAiPluginSettings& aSecond ) |
391 const MAiPluginSettings& aSecond ) |
311 { |
392 { |
312 MAiPluginSettings& first = const_cast<MAiPluginSettings&>(aFirst); |
393 MAiPluginSettings& first = const_cast<MAiPluginSettings&>(aFirst); |
313 MAiPluginSettings& second = const_cast<MAiPluginSettings&>(aSecond); |
394 MAiPluginSettings& second = const_cast<MAiPluginSettings&>(aSecond); |
314 return first.AiPluginContentItem().Name().CompareC(second.AiPluginContentItem().Name()); |
395 return first.AiPluginContentItem().Name().CompareC(second.AiPluginContentItem().Name()); |
315 } |
396 } |
316 |
397 |
317 // --------------------------------------------------------------------------- |
398 // ---------------------------------------------------------------------------- |
318 // From class CAiContentPublisher |
399 // CMCSPlugin::DeleteContentModel |
319 // Plug-ins take ownership of the settings array, so it must either |
400 // |
320 // store it in a member or free it. |
401 // ---------------------------------------------------------------------------- |
321 // Creates dynamic content model. |
|
322 // --------------------------------------------------------------------------- |
|
323 // |
|
324 void CMCSPlugin::ConfigureL( RAiSettingsItemArray& aSettings ) |
|
325 { |
|
326 |
|
327 TLinearOrder<MAiPluginSettings> sortMethod( CMCSPlugin::CompareItems ); |
|
328 RAiSettingsItemArray contentItemsArr; |
|
329 |
|
330 TInt count = aSettings.Count(); |
|
331 for ( TInt i = 0; i < count; i++ ) |
|
332 { |
|
333 MAiPluginSettings* pluginSetting = aSettings[ i ]; |
|
334 if( pluginSetting->AiPluginItemType() == EAiPluginContentItem ) |
|
335 { |
|
336 MAiPluginContentItem& contItem = pluginSetting->AiPluginContentItem(); |
|
337 TPtrC name = contItem.Name(); |
|
338 TPtrC type = contItem.Type(); |
|
339 contentItemsArr.InsertInOrder( pluginSetting, sortMethod ); |
|
340 } |
|
341 |
|
342 } |
|
343 iDataCount = contentItemsArr.Count(); |
|
344 if ( iDataCount > 0 ) |
|
345 { |
|
346 // Create the dynamic content Model |
|
347 DeleteContentModel(); |
|
348 iContentModel = new ( ELeave ) TAiContentItem[ iDataCount ]; |
|
349 for ( TInt i = 0; i < iDataCount; i++ ) |
|
350 { |
|
351 iContentModel[i].id = i; |
|
352 MAiPluginContentItem& contentItem = ( contentItemsArr[ i ] )->AiPluginContentItem(); |
|
353 |
|
354 if( contentItem.Type() == KContentItemTypeText ) |
|
355 { |
|
356 // text |
|
357 iContentModel[i].type = KAiContentTypeText; |
|
358 } |
|
359 if( contentItem.Type() == KContentItemTypeImage ) |
|
360 { |
|
361 // image |
|
362 iContentModel[i].type = KAiContentTypeBitmap; |
|
363 } |
|
364 TInt pos = contentItem.Name().Locate( KPluginNameSeprator ); |
|
365 |
|
366 HBufC* contentId = HBufC::NewL( contentItem.Name().Length() ); |
|
367 CleanupStack::PushL( contentId ); |
|
368 TPtr ptr = contentId->Des(); |
|
369 ptr = contentItem.Name().Mid( pos + 1 ); |
|
370 TInt sizeOfContentId = ptr.Size() +sizeof( wchar_t ); |
|
371 iContentModel[i].cid = static_cast<const wchar_t*>( User::AllocL( sizeOfContentId ) ); |
|
372 Mem::Copy((TAny*)iContentModel[i].cid, ptr.PtrZ(), sizeOfContentId); |
|
373 CleanupStack::PopAndDestroy( contentId ); |
|
374 } |
|
375 iContent = AiUtility::CreateContentItemArrayIteratorL( iContentModel, iDataCount ); |
|
376 } |
|
377 contentItemsArr.Reset(); |
|
378 // We own the array so destroy it |
|
379 aSettings.ResetAndDestroy(); |
|
380 } |
|
381 |
|
382 // --------------------------------------------------------------------------- |
|
383 // From class CAiContentPublisher |
|
384 // Returns the extension interface. Actual type depends on the passed |
|
385 // aUid argument. |
|
386 // --------------------------------------------------------------------------- |
|
387 // |
|
388 TAny* CMCSPlugin::Extension( TUid aUid ) |
|
389 { |
|
390 if (aUid == KExtensionUidProperty) |
|
391 { |
|
392 return static_cast<MAiPropertyExtension*>(this); |
|
393 } |
|
394 else if (aUid == KExtensionUidEventHandler) |
|
395 { |
|
396 return static_cast<MAiEventHandlerExtension*>(this); |
|
397 } |
|
398 else |
|
399 { |
|
400 return NULL; |
|
401 } |
|
402 } |
|
403 |
|
404 // --------------------------------------------------------------------------- |
|
405 // From class MAiPropertyExtension |
|
406 // Read property of publisher plug-in. |
|
407 // --------------------------------------------------------------------------- |
|
408 // |
|
409 TAny* CMCSPlugin::GetPropertyL( TInt aProperty ) |
|
410 { |
|
411 TAny* property = NULL; |
|
412 |
|
413 switch ( aProperty ) |
|
414 { |
|
415 case EAiPublisherInfo: |
|
416 { |
|
417 property = static_cast<TAiPublisherInfo*>( &iInfo ); |
|
418 break; |
|
419 } |
|
420 |
|
421 case EAiPublisherContent: |
|
422 { |
|
423 property = static_cast<MAiContentItemIterator*>( iContent ); |
|
424 break; |
|
425 } |
|
426 } |
|
427 return property; |
|
428 } |
|
429 |
|
430 // --------------------------------------------------------------------------- |
|
431 // From class MAiPropertyExtension |
|
432 // Write property value to optimize the content model. |
|
433 // --------------------------------------------------------------------------- |
|
434 // |
|
435 void CMCSPlugin::SetPropertyL( TInt aProperty, TAny* aValue ) |
|
436 { |
|
437 switch ( aProperty ) |
|
438 { |
|
439 case EAiPublisherInfo: |
|
440 { |
|
441 if( aValue ) |
|
442 { |
|
443 const TAiPublisherInfo* info = static_cast<const TAiPublisherInfo*>( aValue ); |
|
444 iInfo.iName.Copy(info->iName); |
|
445 iInfo.iNamespace.Copy(info->iNamespace); |
|
446 } |
|
447 break; |
|
448 } |
|
449 default: |
|
450 break; |
|
451 } |
|
452 } |
|
453 |
|
454 // --------------------------------------------------------------------------- |
|
455 // From class MAiEventHandlerExtension. |
|
456 // Handles an event sent by the AI framework. |
|
457 // --------------------------------------------------------------------------- |
|
458 // |
|
459 void CMCSPlugin::HandleEvent( TInt /*aEvent*/, const TDesC& /*aParam*/ ) |
|
460 { |
|
461 // We have no way of reporting errors to framework so just ignore them. |
|
462 //TRAP_IGNORE( iEngine->HandleEventL(aEvent, aParam )); |
|
463 } |
|
464 |
|
465 // --------------------------------------------------------------------------- |
|
466 // From class MAiEventHandlerExtension. |
|
467 // Handles an event sent by the AI framework. |
|
468 // --------------------------------------------------------------------------- |
|
469 // |
|
470 void CMCSPlugin::HandleEvent( const TDesC& aEventName, const TDesC& aParam ) |
|
471 { |
|
472 if ( iEngine ) |
|
473 { |
|
474 if( aEventName == KEventNameLaunchByIndex ) |
|
475 { |
|
476 // We have no way of reporting errors to framework so just ignore them. |
|
477 TInt32 index; |
|
478 AiUtility::ParseInt( index, aParam ); |
|
479 TRAP_IGNORE( iEngine->LaunchItemL( index - 1 )); |
|
480 } |
|
481 else if( aEventName == KEventNameShowSettings ) |
|
482 { |
|
483 TRAP_IGNORE( iEngine->ShowSettingsL() ); |
|
484 } |
|
485 } |
|
486 } |
|
487 |
|
488 // --------------------------------------------------------------------------- |
|
489 // From class CAiContentPublisher |
|
490 // framework instructs plug-in that it is allowed to consume CPU resources |
|
491 // --------------------------------------------------------------------------- |
|
492 // |
|
493 void CMCSPlugin::DoResumeL( TAiTransitionReason /*aReason*/ ) |
|
494 { |
|
495 PublishL(); |
|
496 } |
|
497 |
|
498 // --------------------------------------------------------------------------- |
|
499 // Frees engine resources |
|
500 // --------------------------------------------------------------------------- |
|
501 // |
|
502 void CMCSPlugin::FreeEngine() |
|
503 { |
|
504 delete iEngine; |
|
505 iEngine = NULL; |
|
506 } |
|
507 |
|
508 // --------------------------------------------------------------------------- |
|
509 // Delete content model |
|
510 // --------------------------------------------------------------------------- |
|
511 // |
402 // |
512 void CMCSPlugin::DeleteContentModel() |
403 void CMCSPlugin::DeleteContentModel() |
513 { |
404 { |
514 if( iContentModel ) |
405 if( iContentModel ) |
515 { |
406 { |