1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Updates CPS storage for all collection |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 |
|
20 #include <mmf/common/mmfcontrollerpluginresolver.h> |
|
21 #include <liwservicehandler.h> |
|
22 |
|
23 #include <glxuistd.h> |
|
24 #include <glxicons.mbg> // Glx Icons |
|
25 #include <glxthumbnailattributeinfo.h> // for KGlxMediaIdThumbnail |
|
26 #include <glxattributecontext.h> |
|
27 #include <glxthumbnailcontext.h> |
|
28 #include <glxcollectionpluginall.hrh> //for KGlxCollectionPluginAllImplementationUid |
|
29 #include <glxtracer.h> //for Traces |
|
30 #include <glxlog.h> //for Log |
|
31 #include <mglxmedialist.h> // for MGlxMediaList |
|
32 #include <glxcollectiongeneraldefs.h> |
|
33 #include <glxgallery.hrh> // for KGlxGalleryApplicationUid |
|
34 #include <glxmediaid.h> |
|
35 #include <glxerrormanager.h> |
|
36 |
|
37 #include "glxcontentharvesterplugin.hrh" |
|
38 #include "glxcontentharvesterpluginall.h" |
|
39 |
|
40 #include "glxmapconstants.h" |
|
41 |
|
42 |
|
43 // ---------------------------------------------------------------------------- |
|
44 // Constructor |
|
45 // ---------------------------------------------------------------------------- |
|
46 // |
|
47 CGlxContentHarvesterPluginAll::CGlxContentHarvesterPluginAll( |
|
48 MLiwInterface* aCPSInterface, |
|
49 MGlxContentHarvesterPlugin *aCHplugin ) |
|
50 { |
|
51 TRACER( "CGlxContentHarvesterPluginAll::CGlxContentHarvesterPluginAll" ); |
|
52 iCPSInterface = aCPSInterface; |
|
53 SetCHPlugin(aCHplugin); |
|
54 } |
|
55 |
|
56 // ---------------------------------------------------------------------------- |
|
57 // Symbian 2nd phase constructor can leave. |
|
58 // ---------------------------------------------------------------------------- |
|
59 // |
|
60 void CGlxContentHarvesterPluginAll::ConstructL() |
|
61 { |
|
62 TRACER( "CGlxContentHarvesterPluginAll::ConstructL" ); |
|
63 |
|
64 //Call the base class ConstructL,to create the default thumbnail |
|
65 CGlxContentHarvesterPluginBase::ConstructL(EMbmGlxiconsQgn_prop_image_notcreated); |
|
66 |
|
67 iUriAttributeContext = new (ELeave) CGlxAttributeContext(&iThumbnailIterator); |
|
68 iThumbnailAttributeContext = new (ELeave) CGlxAttributeContext(&iThumbnailIterator); |
|
69 |
|
70 //Register/Subscribe with matrix menu for the notifications |
|
71 GetInterfaceForNotificationL(); |
|
72 SetupPublisherL(KItemIndexAll); |
|
73 RequestCpsNotificationL(KItemIndexAll); |
|
74 HandleStateChangeL(KItemIndexAll); |
|
75 } |
|
76 |
|
77 // ---------------------------------------------------------------------------- |
|
78 // Two-phased constructor. |
|
79 // ---------------------------------------------------------------------------- |
|
80 // |
|
81 CGlxContentHarvesterPluginAll* CGlxContentHarvesterPluginAll::NewLC( |
|
82 MLiwInterface* aCPSInterface, |
|
83 MGlxContentHarvesterPlugin *aCHplugin ) |
|
84 { |
|
85 TRACER( "CGlxContentHarvesterPluginAll::NewL" ); |
|
86 CGlxContentHarvesterPluginAll* self = new ( ELeave ) CGlxContentHarvesterPluginAll( aCPSInterface,aCHplugin ); |
|
87 CleanupStack::PushL(self); |
|
88 self->ConstructL(); |
|
89 return self; |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // Destructor |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 CGlxContentHarvesterPluginAll::~CGlxContentHarvesterPluginAll() |
|
97 { |
|
98 TRACER( "CGlxContentHarvesterPluginAll::~CGlxContentHarvesterPluginAll" ); |
|
99 |
|
100 DestroyMedialist(); |
|
101 } |
|
102 |
|
103 // ---------------------------------------------------------------------------- |
|
104 // CGlxContentHarvesterPluginAll::UpdateDataL() |
|
105 // ---------------------------------------------------------------------------- |
|
106 // |
|
107 void CGlxContentHarvesterPluginAll::UpdateDataL() |
|
108 { |
|
109 TRACER( "CGlxContentHarvesterPluginAll::UpdateDataL" ); |
|
110 |
|
111 if (!iMediaList) |
|
112 { |
|
113 return; |
|
114 } |
|
115 |
|
116 if (iMediaList->Count()) |
|
117 { |
|
118 TInt ret = UpdateItem(KPreviewItemIndex); |
|
119 if (ret != KErrNotFound) |
|
120 { |
|
121 //Updates the thumbnail in the collection |
|
122 UpdateDataInCPSL(ret); |
|
123 } |
|
124 } |
|
125 else |
|
126 { |
|
127 // Show previous thumbnail until the new thumbnail is |
|
128 // fecthed.Added this check to avoid flicker |
|
129 if (iMediaList->Count() == 0) |
|
130 { |
|
131 //Don't Show the Thumbnail/Show nothing |
|
132 GLX_LOG_INFO("CGlxContentHarvesterPluginAll::UpdateDataL() --O"); |
|
133 UpdateDataInCPSL(GetBitmapHandle()); |
|
134 } |
|
135 } |
|
136 } |
|
137 |
|
138 // ---------------------------------------------------------------------------- |
|
139 // CGlxContentHarvesterPluginAll::HandleNotifyL() |
|
140 // ---------------------------------------------------------------------------- |
|
141 // |
|
142 TInt CGlxContentHarvesterPluginAll::HandleNotifyL( |
|
143 TInt /* aCmdId*/, |
|
144 TInt/* aEventId */, |
|
145 CLiwGenericParamList& /*aEventParamList*/, |
|
146 const CLiwGenericParamList& /*aInParamList*/ ) |
|
147 { |
|
148 TRACER( "CGlxContentHarvesterPluginAll::HandleNotifyL" ); |
|
149 |
|
150 // First time when we enter matrix menu from shortcut or app. launcher, set |
|
151 // IsRefreshNeeded flag to ETrue. so that thumbnail attributes are fetched again |
|
152 // for all containers. This is to avoid preview thumbnails not getting shown in |
|
153 // matirix menu under low memory conditions. |
|
154 GetCHPlugin()->SetRefreshNeeded(ETrue); |
|
155 |
|
156 HandleStateChangeL(KItemIndexAll); |
|
157 return KErrNone; |
|
158 } |
|
159 |
|
160 // ---------------------------------------------------------------------------- |
|
161 // CGlxContentHarvesterPluginAll::UpdateDataInCPSL() |
|
162 // ---------------------------------------------------------------------------- |
|
163 // |
|
164 void CGlxContentHarvesterPluginAll::UpdateDataInCPSL(TInt aHandle) |
|
165 { |
|
166 TRACER( "CGlxContentHarvesterPluginAll::UpdateDataInCPSL" ); |
|
167 //update data in CPS |
|
168 _LIT(KExamplePluginPub,"photossuite"); |
|
169 _LIT(KContentActivation,"allcs"); |
|
170 _LIT(KContId1,"category1"); |
|
171 |
|
172 if(iCPSInterface && iMediaList ) |
|
173 { |
|
174 CLiwGenericParamList* inParamList = CLiwGenericParamList::NewLC(); |
|
175 CLiwGenericParamList* outParamList = CLiwGenericParamList::NewLC(); |
|
176 |
|
177 //Shows the thumbnail in the matrix view |
|
178 FillInputListWithDataL(inParamList, KExamplePluginPub, KContentActivation , |
|
179 KContId1, aHandle); |
|
180 |
|
181 iCPSInterface->ExecuteCmdL( KAdd, *inParamList, *outParamList ); |
|
182 CleanupStack::PopAndDestroy(outParamList); |
|
183 CleanupStack::PopAndDestroy(inParamList); |
|
184 } |
|
185 } |
|
186 |
|
187 // ---------------------------------------------------------------------------- |
|
188 // CGlxContentHarvesterPluginAll::UpdateItem() |
|
189 // ---------------------------------------------------------------------------- |
|
190 // |
|
191 TInt CGlxContentHarvesterPluginAll::UpdateItem(TInt aItemIndex) |
|
192 { |
|
193 TRACER( "CGlxContentHarvesterPluginAll::UpdateItem" ); |
|
194 const TGlxMedia& item = iMediaList->Item(aItemIndex); |
|
195 TSize gridIconSize = GetGridIconSize(); |
|
196 TMPXAttribute thumbnailAttribute(KGlxMediaIdThumbnail, |
|
197 GlxFullThumbnailAttributeId( ETrue, gridIconSize.iWidth, gridIconSize.iHeight ) ); |
|
198 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll::UpdateItem,aItemIndex=%d ",aItemIndex); |
|
199 const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute ); |
|
200 if (value) |
|
201 { |
|
202 return value->iBitmap->Handle(); |
|
203 } |
|
204 return KErrNotFound; |
|
205 } |
|
206 |
|
207 // ---------------------------------------------------------------------------- |
|
208 // CGlxContentHarvesterPluginAll::ActivateL() |
|
209 // ---------------------------------------------------------------------------- |
|
210 // |
|
211 void CGlxContentHarvesterPluginAll::ActivateL( TBool aOn ) |
|
212 { |
|
213 TRACER( "CGlxContentHarvesterPluginAll::ActivateL" ); |
|
214 |
|
215 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll::ActivateL aOn =%d",aOn); |
|
216 SetFocus(aOn); |
|
217 |
|
218 if (IsMatrixMenuInForegroundL() && aOn ) |
|
219 { |
|
220 if(GetCHPlugin()->IsRefreshNeeded()) |
|
221 { |
|
222 //Update the rest of all the collections on receving the focus... |
|
223 GetCHPlugin()->UpdatePlugins(aOn); |
|
224 } |
|
225 else |
|
226 { |
|
227 //As the collection is not updated by the contentharvester plugin |
|
228 //to update the thumbnails on the focus , need to call the below function |
|
229 UpdatePreviewThumbnailListL(); |
|
230 } |
|
231 } |
|
232 else if ( !aOn ) |
|
233 { |
|
234 if(!IsMatrixMenuInForegroundL()) |
|
235 { |
|
236 //use case:Matrix Menu is exited, by entering into grid view,application view,capture mode... |
|
237 //Need to destroy all the collection's observers and context |
|
238 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll::ActivateL !aOn =%d and matrix not in foreground",aOn); |
|
239 GetCHPlugin()->UpdatePlugins(aOn); |
|
240 } |
|
241 } |
|
242 } |
|
243 |
|
244 // ---------------------------------------------------------------------------- |
|
245 // CGlxContentHarvesterPluginAll::HandleItemAddedL |
|
246 // ---------------------------------------------------------------------------- |
|
247 // |
|
248 void CGlxContentHarvesterPluginAll::HandleItemAddedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/, |
|
249 MGlxMediaList*/*aList*/) |
|
250 { |
|
251 TRACER( "CGlxContentHarvesterPluginAll::HandleItemAddedL" ); |
|
252 } |
|
253 |
|
254 // --------------------------------------------------------------------------- |
|
255 // CGlxContentHarvesterPluginAll::HandleMediaL |
|
256 // --------------------------------------------------------------------------- |
|
257 // |
|
258 void CGlxContentHarvesterPluginAll::HandleMediaL(TInt /*aListIndex*/, |
|
259 MGlxMediaList* /*aList*/) |
|
260 { |
|
261 TRACER( "CGlxContentHarvesterPluginAll::HandleMediaL" ); |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------------------------- |
|
265 // CGlxContentHarvesterPluginAll::HandleItemRemovedL |
|
266 // --------------------------------------------------------------------------- |
|
267 // |
|
268 void CGlxContentHarvesterPluginAll::HandleItemRemovedL(TInt /*aStartIndex*/, |
|
269 TInt /* aEndIndex */, MGlxMediaList* /*aList*/) |
|
270 { |
|
271 TRACER( "CGlxContentHarvesterPluginAll::HandleItemRemovedL" ); |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------------------------- |
|
275 // CGlxContentHarvesterPluginAll::HandleItemModifiedL |
|
276 // --------------------------------------------------------------------------- |
|
277 // |
|
278 void CGlxContentHarvesterPluginAll::HandleItemModifiedL( |
|
279 const RArray<TInt>& /*aItemIndexes*/, |
|
280 MGlxMediaList* /*aList*/) |
|
281 { |
|
282 TRACER( "CGlxContentHarvesterPluginAll::HandleItemModifiedL" ); |
|
283 } |
|
284 |
|
285 // --------------------------------------------------------------------------- |
|
286 // CGlxContentHarvesterPluginAll::HandleAttributesAvailableL |
|
287 // --------------------------------------------------------------------------- |
|
288 // |
|
289 void CGlxContentHarvesterPluginAll::HandleAttributesAvailableL(TInt aItemIndex, |
|
290 const RArray<TMPXAttribute>& aAttributes, MGlxMediaList* aList) |
|
291 { |
|
292 TRACER( "CGlxContentHarvesterPluginAll::HandleAttributesAvailableL" ); |
|
293 TSize gridIconSize = GetGridIconSize(); |
|
294 TMPXAttribute thumbnailAttribute(KGlxMediaIdThumbnail, |
|
295 GlxFullThumbnailAttributeId( ETrue, gridIconSize.iWidth, gridIconSize.iHeight ) ); |
|
296 |
|
297 TIdentityRelation< TMPXAttribute > match ( &TMPXAttribute::Match ); |
|
298 |
|
299 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll::HandleAttributesAvailableL =%d ",aItemIndex); |
|
300 if (KErrNotFound != aAttributes.Find( thumbnailAttribute, match )) |
|
301 { |
|
302 const TGlxMedia& item = aList->Item( aItemIndex ); |
|
303 const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute ); |
|
304 if (value) |
|
305 { |
|
306 GLX_LOG_INFO("CGlxContentHarvesterPluginAll::HandleAttributesAvailableL Thumbnail is present "); |
|
307 |
|
308 // Update the preview thumbnail |
|
309 //remove the observer as client need not listen to the callbacks |
|
310 GLX_LOG_INFO("CGlxContentHarvesterPluginAll::HandleAttributesAvailableL,one thumbnail fetched"); |
|
311 UpdateDataInCPSL( value->iBitmap->Handle()); |
|
312 iMediaList->RemoveMediaListObserver( this ); |
|
313 }//end of check against value |
|
314 }//end of attribute match |
|
315 } |
|
316 |
|
317 // --------------------------------------------------------------------------- |
|
318 // CGlxContentHarvesterPluginAll::HandleFocusChangedL |
|
319 // --------------------------------------------------------------------------- |
|
320 // |
|
321 void CGlxContentHarvesterPluginAll::HandleFocusChangedL( |
|
322 NGlxListDefs::TFocusChangeType /*aType*/, |
|
323 TInt /*aNewIndex*/, |
|
324 TInt /*aOldIndex*/, |
|
325 MGlxMediaList* /*aList*/) |
|
326 { |
|
327 TRACER( "CGlxContentHarvesterPluginAll::HandleFocusChangedL" ); |
|
328 } |
|
329 |
|
330 |
|
331 // --------------------------------------------------------------------------- |
|
332 // CGlxContentHarvesterPluginAll::HandleItemSelectedL |
|
333 // --------------------------------------------------------------------------- |
|
334 // |
|
335 void CGlxContentHarvesterPluginAll::HandleItemSelectedL(TInt /*aIndex*/, |
|
336 TBool /*aSelected*/, |
|
337 MGlxMediaList* /*aList*/) |
|
338 { |
|
339 TRACER( "CGlxContentHarvesterPluginAll::HandleItemSelectedL" ); |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------------------------- |
|
343 // CGlxContentHarvesterPluginAll::HandleMessageL |
|
344 // --------------------------------------------------------------------------- |
|
345 // |
|
346 void CGlxContentHarvesterPluginAll::HandleMessageL(const CMPXMessage& /*aMessage*/, |
|
347 MGlxMediaList* /*aList*/) |
|
348 { |
|
349 // Do nothing |
|
350 TRACER( "CGlxContentHarvesterPluginAll::HandleMessageL" ); |
|
351 } |
|
352 |
|
353 // --------------------------------------------------------------------------- |
|
354 // CGlxContentHarvesterPluginAll::DestroyMedialistL |
|
355 // --------------------------------------------------------------------------- |
|
356 // |
|
357 void CGlxContentHarvesterPluginAll::DestroyMedialist() |
|
358 { |
|
359 TRACER( "CGlxContentHarvesterPluginAll::DestroyMedialist" ); |
|
360 if( iMediaList ) |
|
361 { |
|
362 GLX_LOG_INFO("CGlxContentHarvesterPluginAll::DestroyMedialist,media list deleted"); |
|
363 RemoveContextAndObserver(); |
|
364 |
|
365 delete iUriAttributeContext; |
|
366 iUriAttributeContext = NULL; |
|
367 delete iThumbnailAttributeContext; |
|
368 iThumbnailAttributeContext = NULL; |
|
369 |
|
370 iMediaList->Close(); |
|
371 iMediaList = NULL; |
|
372 } |
|
373 } |
|
374 |
|
375 // --------------------------------------------------------------------------- |
|
376 // CGlxContentHarvesterPluginAll::CreateSingleItemMedialist |
|
377 // --------------------------------------------------------------------------- |
|
378 // |
|
379 void CGlxContentHarvesterPluginAll::CreateMedialistL( ) |
|
380 { |
|
381 TRACER( "CGlxContentHarvesterPluginAll::CreateMedialistL" ); |
|
382 if(!iMediaList) |
|
383 { |
|
384 iThumbnailIterator.SetRange( KSinglePreviewThumbnail ); |
|
385 |
|
386 iMediaList = CreateMedialistAndAttributeContextL( TGlxMediaId( |
|
387 KGlxCollectionPluginAllImplementationUid ), |
|
388 iUriAttributeContext,iThumbnailAttributeContext); |
|
389 |
|
390 AddContextAndObserverL(); |
|
391 } |
|
392 } |
|
393 |
|
394 // --------------------------------------------------------------------------- |
|
395 // CGlxContentHarvesterPluginAll::UpdateMedialistContext |
|
396 // --------------------------------------------------------------------------- |
|
397 // |
|
398 void CGlxContentHarvesterPluginAll::UpdatePreviewThumbnailListL( ) |
|
399 { |
|
400 TRACER( "CGlxContentHarvesterPluginAll::UpdatePreviewThumbnailListL" ); |
|
401 |
|
402 //when there is an update of content in the collection |
|
403 //this function is executed or when the collection recives the focus. |
|
404 if(!iMediaList) |
|
405 { |
|
406 //medis list is not created yet,create it. |
|
407 CreateMedialistL( ); |
|
408 UpdateDataL(); |
|
409 } |
|
410 else |
|
411 { |
|
412 UpdateDataL(); |
|
413 |
|
414 //Adding the context doesn't gaurantee we get a call back for |
|
415 //Handle attributes available,if the latest item is already fetched. |
|
416 //and for the content added for this collection,if it is not latest |
|
417 //we will not recieve the attributes .so show the first available thumbnail |
|
418 //in the media list.if there is any new latest content added,the thumbnail will be |
|
419 //fetched and shown. |
|
420 |
|
421 |
|
422 iThumbnailIterator.SetRange( KSinglePreviewThumbnail ); |
|
423 RemoveContextAndObserver(); |
|
424 AddContextAndObserverL(); |
|
425 } |
|
426 } |
|
427 |
|
428 // --------------------------------------------------------------------------- |
|
429 // CGlxContentHarvesterPluginAll::AddContextAndObserverL |
|
430 // --------------------------------------------------------------------------- |
|
431 // |
|
432 void CGlxContentHarvesterPluginAll::AddContextAndObserverL() |
|
433 { |
|
434 TRACER( "CGlxContentHarvesterPluginAll::AddRemoveContextAndObserverL" ); |
|
435 if(iMediaList) |
|
436 { |
|
437 iMediaList->AddMediaListObserverL( this ); |
|
438 iMediaList->AddContextL(iUriAttributeContext, KGlxFetchContextPriorityNormal); |
|
439 iMediaList->AddContextL(iThumbnailAttributeContext, KGlxFetchContextPriorityLow); |
|
440 } |
|
441 } |
|
442 |
|
443 // --------------------------------------------------------------------------- |
|
444 // CGlxContentHarvesterPluginAll::RemoveContextAndObserver |
|
445 // --------------------------------------------------------------------------- |
|
446 // |
|
447 void CGlxContentHarvesterPluginAll::RemoveContextAndObserver() |
|
448 { |
|
449 TRACER( "CGlxContentHarvesterPluginAll::RemoveContextAndObserver" ); |
|
450 if(iMediaList) |
|
451 { |
|
452 iMediaList->RemoveMediaListObserver( this ); |
|
453 iMediaList->RemoveContext(iUriAttributeContext); |
|
454 iMediaList->RemoveContext(iThumbnailAttributeContext); |
|
455 } |
|
456 } |
|
457 |
|
458 // --------------------------------------------------------------------------- |
|
459 // CGlxContentHarvesterPluginAll::HandleError |
|
460 // --------------------------------------------------------------------------- |
|
461 // |
|
462 void CGlxContentHarvesterPluginAll::HandleError(TInt /*aError*/) |
|
463 { |
|
464 TRACER( "CGlxContentHarvesterPluginAll::HandleError" ); |
|
465 |
|
466 #ifdef _DEBUG |
|
467 if(iMediaList) |
|
468 { |
|
469 TInt count=iMediaList->Count(); |
|
470 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll::HandleError,count=%d",count); |
|
471 for ( TInt i = 0; i < count ; i++ ) |
|
472 { |
|
473 const TGlxMedia& item = iMediaList->Item( i ); |
|
474 TInt thumbnailError = GlxErrorManager::HasAttributeErrorL( |
|
475 item.Properties(), KGlxMediaIdThumbnail ); |
|
476 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll::HandleError,Error=%d ",thumbnailError); |
|
477 |
|
478 } |
|
479 } |
|
480 #endif |
|
481 } |
|
482 |
|
483 // --------------------------------------------------------------------------- |
|
484 // CGlxContentHarvesterPluginAll::Count |
|
485 // --------------------------------------------------------------------------- |
|
486 // |
|
487 TInt CGlxContentHarvesterPluginAll::Count() |
|
488 { |
|
489 TRACER( "CGlxContentHarvesterPluginAll::Count" ); |
|
490 TInt count = KErrNone; |
|
491 if(iMediaList) |
|
492 { |
|
493 count = iMediaList->Count(); |
|
494 GLX_LOG_INFO1("GlxCHP:All::Count(%d)",count); |
|
495 } |
|
496 return count; |
|
497 } |
|
498 // End of File |
|
499 |
|