22 #include <aicontentobserver.h> |
22 #include <aicontentobserver.h> |
23 #include <aiutility.h> |
23 #include <aiutility.h> |
24 #include <aistrcnv.h> |
24 #include <aistrcnv.h> |
25 #include <mcsmenuitem.h> |
25 #include <mcsmenuitem.h> |
26 |
26 |
|
27 #include <aknskinsinternalcrkeys.h> // For working with settings API |
|
28 #include <centralrepository.h> // Headers Used for CRepository |
|
29 |
27 #include "mcspluginuids.hrh" |
30 #include "mcspluginuids.hrh" |
28 #include "mcsplugin.h" |
31 #include "mcsplugin.h" |
29 #include "mcsplugindata.h" |
32 #include "mcsplugindata.h" |
30 #include "mcspluginengine.h" |
33 #include "mcspluginengine.h" |
31 #include "aipluginsettings.h" |
34 #include "aipluginsettings.h" |
76 // --------------------------------------------------------------------------- |
79 // --------------------------------------------------------------------------- |
77 // |
80 // |
78 void CMCSPlugin::ConstructL() |
81 void CMCSPlugin::ConstructL() |
79 { |
82 { |
80 iInfo.iUid.iUid = AI_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_MCSPLUGIN; |
83 iInfo.iUid.iUid = AI_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_MCSPLUGIN; |
|
84 // We need to Query Central Repository |
|
85 iRepository = CRepository::NewL( KCRUidPersonalisation ); |
|
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 ); |
81 } |
117 } |
82 |
118 |
83 // --------------------------------------------------------------------------- |
119 // --------------------------------------------------------------------------- |
84 // Destructor |
120 // Destructor |
85 // Deletes all data created to heap |
121 // Deletes all data created to heap |
96 |
132 |
97 delete iEngine; |
133 delete iEngine; |
98 iObservers.Close(); |
134 iObservers.Close(); |
99 |
135 |
100 DeleteContentModel(); |
136 DeleteContentModel(); |
|
137 |
|
138 if ( iRepository ) |
|
139 { |
|
140 delete iRepository; |
|
141 iRepository = NULL; |
|
142 } |
|
143 |
|
144 if ( iRepositoryWatcher ) |
|
145 { |
|
146 iRepositoryWatcher->Cancel(); |
|
147 delete iRepositoryWatcher; |
|
148 iRepositoryWatcher = NULL; |
|
149 } |
101 } |
150 } |
102 |
151 |
103 // --------------------------------------------------------------------------- |
152 // --------------------------------------------------------------------------- |
104 // Publishes the all the items |
153 // Publishes the all the items |
105 // --------------------------------------------------------------------------- |
154 // --------------------------------------------------------------------------- |
152 // Publishes one item to given index |
201 // Publishes one item to given index |
153 // --------------------------------------------------------------------------- |
202 // --------------------------------------------------------------------------- |
154 // |
203 // |
155 void CMCSPlugin::PublishLItemL( MAiContentObserver& aObserver, TMCSData& aData, TInt aIndex ) |
204 void CMCSPlugin::PublishLItemL( MAiContentObserver& aObserver, TMCSData& aData, TInt aIndex ) |
156 { |
205 { |
|
206 |
157 if( !aData.IsDirty() ) |
207 if( !aData.IsDirty() ) |
158 { |
208 { |
159 return; |
209 return; |
160 } |
210 } |
161 |
211 |
272 // --------------------------------------------------------------------------- |
322 // --------------------------------------------------------------------------- |
273 // |
323 // |
274 void CMCSPlugin::ConfigureL( RAiSettingsItemArray& aSettings ) |
324 void CMCSPlugin::ConfigureL( RAiSettingsItemArray& aSettings ) |
275 { |
325 { |
276 |
326 |
277 TLinearOrder<MAiPluginSettings> sortMethod(CMCSPlugin::CompareItems); |
327 TLinearOrder<MAiPluginSettings> sortMethod( CMCSPlugin::CompareItems ); |
278 RAiSettingsItemArray contentItemsArr; |
328 RAiSettingsItemArray contentItemsArr; |
279 |
329 |
280 TInt count = aSettings.Count(); |
330 TInt count = aSettings.Count(); |
281 for(TInt i = 0; i < count; i++ ) |
331 for ( TInt i = 0; i < count; i++ ) |
282 { |
332 { |
283 MAiPluginSettings* pluginSetting = aSettings[i]; |
333 MAiPluginSettings* pluginSetting = aSettings[ i ]; |
284 if( pluginSetting->AiPluginItemType() == EAiPluginContentItem ) |
334 if( pluginSetting->AiPluginItemType() == EAiPluginContentItem ) |
285 { |
335 { |
286 MAiPluginContentItem& contItem = pluginSetting->AiPluginContentItem(); |
336 MAiPluginContentItem& contItem = pluginSetting->AiPluginContentItem(); |
287 TPtrC name = contItem.Name(); |
337 TPtrC name = contItem.Name(); |
288 TPtrC type = contItem.Type(); |
338 TPtrC type = contItem.Type(); |
289 contentItemsArr.InsertInOrder( pluginSetting, sortMethod ); |
339 contentItemsArr.InsertInOrder( pluginSetting, sortMethod ); |
290 } |
340 } |
291 |
341 |
292 } |
342 } |
293 iDataCount = contentItemsArr.Count(); |
343 iDataCount = contentItemsArr.Count(); |
294 if(iDataCount > 0 ) |
344 if ( iDataCount > 0 ) |
295 { |
345 { |
296 // Create the dynamic content Model |
346 // Create the dynamic content Model |
297 DeleteContentModel(); |
347 DeleteContentModel(); |
298 iContentModel = new ( ELeave ) TAiContentItem[iDataCount]; |
348 iContentModel = new ( ELeave ) TAiContentItem[ iDataCount ]; |
299 for(TInt i = 0; i < iDataCount; i++) |
349 for ( TInt i = 0; i < iDataCount; i++ ) |
300 { |
350 { |
301 iContentModel[i].id = i; |
351 iContentModel[i].id = i; |
302 MAiPluginContentItem& contentItem = (contentItemsArr[i])->AiPluginContentItem(); |
352 MAiPluginContentItem& contentItem = ( contentItemsArr[ i ] )->AiPluginContentItem(); |
303 |
353 |
304 if( contentItem.Type() == KContentItemTypeText ) |
354 if( contentItem.Type() == KContentItemTypeText ) |
305 { |
355 { |
306 // text |
356 // text |
307 iContentModel[i].type = KAiContentTypeText; |
357 iContentModel[i].type = KAiContentTypeText; |
311 // image |
361 // image |
312 iContentModel[i].type = KAiContentTypeBitmap; |
362 iContentModel[i].type = KAiContentTypeBitmap; |
313 } |
363 } |
314 TInt pos = contentItem.Name().Locate( KPluginNameSeprator ); |
364 TInt pos = contentItem.Name().Locate( KPluginNameSeprator ); |
315 |
365 |
316 HBufC* contentId = HBufC::NewL( contentItem.Name().Length()); |
366 HBufC* contentId = HBufC::NewL( contentItem.Name().Length() ); |
317 CleanupStack::PushL( contentId ); |
367 CleanupStack::PushL( contentId ); |
318 TPtr ptr = contentId->Des(); |
368 TPtr ptr = contentId->Des(); |
319 ptr = contentItem.Name().Mid( pos + 1 ); |
369 ptr = contentItem.Name().Mid( pos + 1 ); |
320 TInt sizeOfContentId = ptr.Size() +sizeof(wchar_t); |
370 TInt sizeOfContentId = ptr.Size() +sizeof( wchar_t ); |
321 iContentModel[i].cid = static_cast<const wchar_t*>( User::AllocL( sizeOfContentId ) ); |
371 iContentModel[i].cid = static_cast<const wchar_t*>( User::AllocL( sizeOfContentId ) ); |
322 Mem::Copy((TAny*)iContentModel[i].cid, ptr.PtrZ(), sizeOfContentId); |
372 Mem::Copy((TAny*)iContentModel[i].cid, ptr.PtrZ(), sizeOfContentId); |
323 CleanupStack::PopAndDestroy( contentId ); |
373 CleanupStack::PopAndDestroy( contentId ); |
324 } |
374 } |
325 iContent = AiUtility::CreateContentItemArrayIteratorL( iContentModel, iDataCount ); |
375 iContent = AiUtility::CreateContentItemArrayIteratorL( iContentModel, iDataCount ); |