|
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 albums 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 <glxcollectionpluginalbums.hrh> //for KGlxCollectionPluginAlbumsImplementationUid |
|
26 #include <glxthumbnailattributeinfo.h> // for KGlxMediaIdThumbnail |
|
27 #include <glxattributecontext.h> |
|
28 #include <glxthumbnailcontext.h> |
|
29 #include <glxtracer.h> //for tracer |
|
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 "glxcontentharvesterpluginalbums.h" |
|
38 #include "glxcontentharvesterplugin.hrh" |
|
39 #include "glxmapconstants.h" |
|
40 |
|
41 |
|
42 // ============================ MEMBER FUNCTIONS ============================== |
|
43 LOCAL_C TInt TimerCallbackL( TAny* aPtr ) |
|
44 { |
|
45 TRACER( "CGlxContentHarvesterPluginAlbums::TimerCallbackL" ); |
|
46 static_cast<CGlxContentHarvesterPluginAlbums*>(aPtr)->UpdateDataL(); |
|
47 return KErrNone; |
|
48 } |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // Constructor |
|
52 // ---------------------------------------------------------------------------- |
|
53 // |
|
54 CGlxContentHarvesterPluginAlbums::CGlxContentHarvesterPluginAlbums( |
|
55 MLiwInterface* aCPSInterface, |
|
56 MGlxContentHarvesterPlugin* aCHplugin ) |
|
57 { |
|
58 TRACER( "CGlxContentHarvesterPluginAlbums::CGlxContentHarvesterPluginAlbums" ); |
|
59 iCPSInterface = aCPSInterface; |
|
60 SetCHPlugin(aCHplugin); |
|
61 } |
|
62 |
|
63 // ---------------------------------------------------------------------------- |
|
64 // Symbian 2nd phase constructor can leave. |
|
65 // ---------------------------------------------------------------------------- |
|
66 // |
|
67 void CGlxContentHarvesterPluginAlbums::ConstructL() |
|
68 { |
|
69 TRACER( "CGlxContentHarvesterPluginAlbums::ConstructL" ); |
|
70 |
|
71 //Call the base class ConstructL |
|
72 CGlxContentHarvesterPluginBase::ConstructL(EMbmGlxiconsQgn_prop_image_notcreated); |
|
73 |
|
74 iPeriodic = CPeriodic::NewL( CActive::EPriorityLow ); |
|
75 iThumbnailContext = CGlxThumbnailContext::NewL(&iThumbnailIterator); |
|
76 |
|
77 //Register/Subscribe with matrix menu for the notifications |
|
78 GetInterfaceForNotificationL(); |
|
79 SetupPublisherL(KItemIndexAlbums); |
|
80 RequestCpsNotificationL(KItemIndexAlbums); |
|
81 HandleStateChangeL(KItemIndexAlbums); |
|
82 } |
|
83 |
|
84 // ---------------------------------------------------------------------------- |
|
85 // Two-phased constructor. |
|
86 // ---------------------------------------------------------------------------- |
|
87 // |
|
88 CGlxContentHarvesterPluginAlbums* CGlxContentHarvesterPluginAlbums::NewLC( |
|
89 MLiwInterface* aCPSInterface, |
|
90 MGlxContentHarvesterPlugin* aCHplugin ) |
|
91 { |
|
92 TRACER( "CGlxContentHarvesterPluginAlbums::NewL" ); |
|
93 CGlxContentHarvesterPluginAlbums* self = new ( ELeave ) CGlxContentHarvesterPluginAlbums( aCPSInterface,aCHplugin ); |
|
94 CleanupStack::PushL(self); |
|
95 self->ConstructL(); |
|
96 return self; |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // Destructor |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 CGlxContentHarvesterPluginAlbums::~CGlxContentHarvesterPluginAlbums() |
|
104 { |
|
105 TRACER( "CGlxContentHarvesterPluginAlbums::~CGlxContentHarvesterPluginAlbums" ); |
|
106 |
|
107 DestroyMedialist(); |
|
108 if ( iPeriodic ) |
|
109 { |
|
110 iPeriodic->Cancel(); |
|
111 } |
|
112 delete iPeriodic; |
|
113 } |
|
114 |
|
115 // ---------------------------------------------------------------------------- |
|
116 // CGlxContentHarvesterPluginAlbums::UpdateDataL() |
|
117 // ---------------------------------------------------------------------------- |
|
118 // |
|
119 void CGlxContentHarvesterPluginAlbums::UpdateDataL() |
|
120 { |
|
121 TRACER( "CGlxContentHarvesterPluginAlbums::UpdateDataL" ); |
|
122 if(iMediaList && iMediaList->Count() && iPreviewItemCount.Count() ) |
|
123 { |
|
124 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::UpdateDataL(),iProgressIndex=%d",iProgressIndex); |
|
125 TInt ret = UpdateItem(iPreviewItemCount[iProgressIndex]); |
|
126 if(ret != KErrNotFound) |
|
127 { |
|
128 //Updates the thumbnail in the collection |
|
129 UpdateDataInCPSL(ret); |
|
130 } |
|
131 else |
|
132 { |
|
133 UpdateDataInCPSL(GetBitmapHandle()); |
|
134 } |
|
135 } |
|
136 else |
|
137 { |
|
138 // Show previous thumbnail until the new thumbnail is |
|
139 // fecthed.Added this check to avoid flicker |
|
140 if(!GetCHPlugin()->IsRefreshNeeded() || (iMediaList->Count() == 0)) |
|
141 { |
|
142 //Don't Show the Thumbnail/Show nothing |
|
143 GLX_LOG_INFO("CGlxContentHarvesterPluginAlbums::UpdateDataL() --O"); |
|
144 UpdateDataInCPSL(GetBitmapHandle()); |
|
145 } |
|
146 |
|
147 } |
|
148 } |
|
149 |
|
150 // ---------------------------------------------------------------------------- |
|
151 // CGlxContentHarvesterPluginAlbums::HandleNotifyL() |
|
152 // ---------------------------------------------------------------------------- |
|
153 // |
|
154 TInt CGlxContentHarvesterPluginAlbums::HandleNotifyL( |
|
155 TInt /* aCmdId*/, |
|
156 TInt/* aEventId */, |
|
157 CLiwGenericParamList& /*aEventParamList*/, |
|
158 const CLiwGenericParamList& /*aInParamList*/ ) |
|
159 { |
|
160 TRACER( "CGlxContentHarvesterPluginAlbums::HandleNotifyL" ); |
|
161 HandleStateChangeL(KItemIndexAlbums); |
|
162 return KErrNone; |
|
163 } |
|
164 |
|
165 // ---------------------------------------------------------------------------- |
|
166 // CGlxContentHarvesterPluginAlbums::HandleItemChanged() |
|
167 // ---------------------------------------------------------------------------- |
|
168 // |
|
169 void CGlxContentHarvesterPluginAlbums::HandleItemChanged() |
|
170 { |
|
171 TRACER("CGlxContentHarvesterPluginAlbums::HandleItemChanged"); |
|
172 |
|
173 iProgressIndex = 0; |
|
174 iPreviewItemCount.Reset(); |
|
175 |
|
176 TSize gridIconSize = GetGridIconSize(); |
|
177 TMPXAttribute thumbnailAttribute(KGlxMediaIdThumbnail, |
|
178 GlxFullThumbnailAttributeId( ETrue, gridIconSize.iWidth, gridIconSize.iHeight ) ); |
|
179 if(iMediaList) |
|
180 { |
|
181 TInt count = iMediaList->Count(); |
|
182 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums:: HandleItemChanged ,count=%d",count); |
|
183 |
|
184 TBool inFocus = IsFocused(); |
|
185 for(TInt aItemIndex = 0; aItemIndex < count; aItemIndex++) |
|
186 { |
|
187 const TGlxMedia& item = iMediaList->Item( aItemIndex ); |
|
188 const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute ); |
|
189 if (value) |
|
190 { |
|
191 iPreviewItemCount.InsertInOrder(aItemIndex); |
|
192 if(!inFocus) |
|
193 { |
|
194 //if the collection is in Focus,retrieve only one thumbnail and break |
|
195 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::HandleItemChanged,iRange=1,aItemIndex=%d",aItemIndex); |
|
196 break; |
|
197 } |
|
198 else if(iPreviewItemCount.Count() == KPreviewThumbnailFetchCount || |
|
199 iPreviewItemCount.Count() == count ) |
|
200 { |
|
201 //if the collection is not in Focus,retrieve 15 thumbnail and break |
|
202 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::HandleItemChanged,iRange=15,aItemIndex=%d",aItemIndex); |
|
203 break; |
|
204 } |
|
205 |
|
206 } |
|
207 } |
|
208 } |
|
209 } |
|
210 |
|
211 // ---------------------------------------------------------------------------- |
|
212 // CGlxContentHarvesterPluginAlbums::UpdateDataInCPSL() |
|
213 // ---------------------------------------------------------------------------- |
|
214 // |
|
215 void CGlxContentHarvesterPluginAlbums::UpdateDataInCPSL(TInt aHandle) |
|
216 { |
|
217 TRACER( "CGlxContentHarvesterPluginAlbums::UpdateDataInCPSL" ); |
|
218 //update data in CPS |
|
219 _LIT(KExamplePluginPub,"photossuite"); |
|
220 _LIT(KContTypeText,"albums"); |
|
221 _LIT(KContId1,"category1"); |
|
222 |
|
223 if(iCPSInterface && iMediaList ) |
|
224 { |
|
225 CLiwGenericParamList* inParamList = CLiwGenericParamList::NewLC(); |
|
226 CLiwGenericParamList* outParamList = CLiwGenericParamList::NewLC(); |
|
227 |
|
228 FillInputListWithDataL(inParamList, KExamplePluginPub, KContTypeText , |
|
229 KContId1, aHandle); |
|
230 |
|
231 iCPSInterface->ExecuteCmdL( KAdd, *inParamList, *outParamList ); |
|
232 CleanupStack::PopAndDestroy(outParamList); |
|
233 CleanupStack::PopAndDestroy(inParamList); |
|
234 } |
|
235 } |
|
236 |
|
237 // ---------------------------------------------------------------------------- |
|
238 // CGlxContentHarvesterPluginAlbums::UpdateItem() |
|
239 // ---------------------------------------------------------------------------- |
|
240 // |
|
241 TInt CGlxContentHarvesterPluginAlbums::UpdateItem(TInt aItemIndex) |
|
242 { |
|
243 TRACER( "CGlxContentHarvesterPluginAlbums::UpdateItem" ); |
|
244 const TGlxMedia& item = iMediaList->Item(aItemIndex); |
|
245 TSize gridIconSize = GetGridIconSize(); |
|
246 TMPXAttribute thumbnailAttribute(KGlxMediaIdThumbnail, |
|
247 GlxFullThumbnailAttributeId( ETrue, gridIconSize.iWidth, gridIconSize.iHeight ) ); |
|
248 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::UpdateItem,aItemIndex=%d ",aItemIndex); |
|
249 const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute ); |
|
250 if (value) |
|
251 { |
|
252 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::UpdateItem,iProgressIndex=%d ",iProgressIndex); |
|
253 iProgressIndex++; |
|
254 if (iProgressIndex >= KPreviewThumbnailFetchCount || |
|
255 iProgressIndex >= iPreviewItemCount.Count() || |
|
256 iProgressIndex >= iMediaList->Count()) |
|
257 { |
|
258 iProgressIndex = 0; |
|
259 } |
|
260 return value->iBitmap->Handle(); |
|
261 } |
|
262 return KErrNotFound; |
|
263 } |
|
264 |
|
265 // ---------------------------------------------------------------------------- |
|
266 // CGlxContentHarvesterPluginAlbums::ActivateL() |
|
267 // ---------------------------------------------------------------------------- |
|
268 // |
|
269 void CGlxContentHarvesterPluginAlbums::ActivateL( TBool aOn ) |
|
270 { |
|
271 TRACER( "CGlxContentHarvesterPluginAlbums::ActivateL" ); |
|
272 |
|
273 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::ActivateL aOn =%d",aOn); |
|
274 SetFocus(aOn); |
|
275 |
|
276 if (IsMatrixMenuInForegroundL() && aOn && !iPeriodic->IsActive() ) |
|
277 { |
|
278 if(GetCHPlugin()->IsRefreshNeeded()) |
|
279 { |
|
280 //Update the rest of all the collections on receving the focus... |
|
281 GetCHPlugin()->UpdatePlugins(aOn); |
|
282 } |
|
283 else |
|
284 { |
|
285 //As the collection is not updated by the contentharvester plugin |
|
286 //to update the thumbnails on the focus , need to call the below function |
|
287 UpdatePreviewThumbnailListL(); |
|
288 } |
|
289 |
|
290 iPeriodic->Start( KTimerInterval, |
|
291 KTimerInterval, |
|
292 TCallBack( TimerCallbackL, this ) ); |
|
293 } |
|
294 else if ( !aOn ) |
|
295 { |
|
296 if(!IsMatrixMenuInForegroundL()) |
|
297 { |
|
298 //use case:Matrix Menu is exited, by entering into grid view,application view,capture mode... |
|
299 //Need to destroy all the collection's observers and context |
|
300 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::ActivateL !aOn =%d and matrix not in foreground",aOn); |
|
301 GetCHPlugin()->UpdatePlugins(aOn); |
|
302 } |
|
303 iPeriodic->Cancel(); |
|
304 } |
|
305 } |
|
306 |
|
307 // ---------------------------------------------------------------------------- |
|
308 // CGlxContentHarvesterPluginAlbums::HandleItemAddedL |
|
309 // ---------------------------------------------------------------------------- |
|
310 // |
|
311 void CGlxContentHarvesterPluginAlbums::HandleItemAddedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/, |
|
312 MGlxMediaList* /*aList*/) |
|
313 { |
|
314 TRACER( "CGlxContentHarvesterPluginAlbums::HandleItemAddedL" ); |
|
315 } |
|
316 |
|
317 // --------------------------------------------------------------------------- |
|
318 // CGlxContentHarvesterPluginAlbums::HandleMediaL |
|
319 // --------------------------------------------------------------------------- |
|
320 // |
|
321 void CGlxContentHarvesterPluginAlbums::HandleMediaL(TInt /*aListIndex*/, |
|
322 MGlxMediaList* /*aList*/) |
|
323 { |
|
324 TRACER( "CGlxContentHarvesterPluginAlbums::HandleMediaL" ); |
|
325 } |
|
326 |
|
327 // --------------------------------------------------------------------------- |
|
328 // CGlxContentHarvesterPluginAlbums::HandleItemRemovedL |
|
329 // --------------------------------------------------------------------------- |
|
330 // |
|
331 void CGlxContentHarvesterPluginAlbums::HandleItemRemovedL(TInt /*aStartIndex*/, |
|
332 TInt /* aEndIndex */, MGlxMediaList* /*aList*/) |
|
333 { |
|
334 TRACER( "CGlxContentHarvesterPluginAlbums::HandleItemRemovedL" ); |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------------------------- |
|
338 // CGlxContentHarvesterPluginAlbums::HandleItemModifiedL |
|
339 // --------------------------------------------------------------------------- |
|
340 // |
|
341 void CGlxContentHarvesterPluginAlbums::HandleItemModifiedL( |
|
342 const RArray<TInt>& /*aItemIndexes*/, |
|
343 MGlxMediaList* /*aList*/) |
|
344 { |
|
345 TRACER( "CGlxContentHarvesterPluginAlbums::HandleItemModifiedL" ); |
|
346 } |
|
347 |
|
348 // --------------------------------------------------------------------------- |
|
349 // CGlxContentHarvesterPluginAlbums::HandleAttributesAvailableL |
|
350 // --------------------------------------------------------------------------- |
|
351 // |
|
352 void CGlxContentHarvesterPluginAlbums::HandleAttributesAvailableL(TInt aItemIndex, |
|
353 const RArray<TMPXAttribute>& aAttributes, MGlxMediaList* aList) |
|
354 { |
|
355 TRACER( "CGlxContentHarvesterPluginAlbums::HandleAttributesAvailableL" ); |
|
356 TSize gridIconSize = GetGridIconSize(); |
|
357 TMPXAttribute thumbnailAttribute(KGlxMediaIdThumbnail, |
|
358 GlxFullThumbnailAttributeId( ETrue, gridIconSize.iWidth, gridIconSize.iHeight ) ); |
|
359 |
|
360 TIdentityRelation< TMPXAttribute > match ( &TMPXAttribute::Match ); |
|
361 |
|
362 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::HandleAttributesAvailableL =%d ",aItemIndex); |
|
363 |
|
364 if (KErrNotFound != aAttributes.Find( thumbnailAttribute, match )) |
|
365 { |
|
366 const TGlxMedia& item = aList->Item( aItemIndex ); |
|
367 const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute ); |
|
368 if (value) |
|
369 { |
|
370 GLX_LOG_INFO("CGlxContentHarvesterPluginAlbums::HandleAttributesAvailableL Thumbnail is present "); |
|
371 iPreviewItemCount.InsertInOrder(aItemIndex); |
|
372 //if the collection on the matrix menu is not focused,then show only one thumbnail |
|
373 if(!IsFocused()) |
|
374 { |
|
375 //if one thumbnail is fetched,it is sufficent when the collection is not in focus. |
|
376 //remove the observer as client need not listen to the callbacks |
|
377 GLX_LOG_INFO("CGlxContentHarvesterPluginAll::HandleAttributesAvailableL,one thumbnail fetched"); |
|
378 UpdateDataInCPSL( value->iBitmap->Handle()); |
|
379 iMediaList->RemoveMediaListObserver( this ); |
|
380 } |
|
381 else if (iPreviewItemCount.Count() == KPreviewThumbnailFetchCount || |
|
382 iPreviewItemCount.Count() == aList->Count() ) |
|
383 { |
|
384 |
|
385 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::HandleAttributesAvailableL,media list count=%d",aList->Count()); |
|
386 //if the PreviewItemCount equals 15 or if it is eqaul to the total count |
|
387 //remove the observer as client need not listen to the callbacks |
|
388 iMediaList->RemoveMediaListObserver( this ); |
|
389 } |
|
390 }//end of check against value |
|
391 }//end of attribute match |
|
392 } |
|
393 |
|
394 // --------------------------------------------------------------------------- |
|
395 // CGlxContentHarvesterPluginAlbums::HandleFocusChangedL |
|
396 // --------------------------------------------------------------------------- |
|
397 // |
|
398 void CGlxContentHarvesterPluginAlbums::HandleFocusChangedL( |
|
399 NGlxListDefs::TFocusChangeType /*aType*/, |
|
400 TInt /*aNewIndex*/, |
|
401 TInt /*aOldIndex*/, |
|
402 MGlxMediaList* /*aList*/) |
|
403 { |
|
404 TRACER( "CGlxContentHarvesterPluginAlbums::HandleFocusChangedL" ); |
|
405 } |
|
406 |
|
407 |
|
408 // --------------------------------------------------------------------------- |
|
409 // CGlxContentHarvesterPluginAlbums::HandleItemSelectedL |
|
410 // --------------------------------------------------------------------------- |
|
411 // |
|
412 void CGlxContentHarvesterPluginAlbums::HandleItemSelectedL(TInt /*aIndex*/, |
|
413 TBool /*aSelected*/, |
|
414 MGlxMediaList* /*aList*/) |
|
415 { |
|
416 TRACER( "CGlxContentHarvesterPluginAlbums::HandleItemSelectedL" ); |
|
417 } |
|
418 |
|
419 // --------------------------------------------------------------------------- |
|
420 // CGlxContentHarvesterPluginAlbums::HandleMessageL |
|
421 // --------------------------------------------------------------------------- |
|
422 // |
|
423 void CGlxContentHarvesterPluginAlbums::HandleMessageL(const CMPXMessage& /*aMessage*/, |
|
424 MGlxMediaList* /*aList*/) |
|
425 { |
|
426 TRACER( "CGlxContentHarvesterPluginAlbums::HandleMessageL" ); |
|
427 } |
|
428 |
|
429 // --------------------------------------------------------------------------- |
|
430 // CGlxContentHarvesterPluginAlbums::DestroyMedialist |
|
431 // --------------------------------------------------------------------------- |
|
432 // |
|
433 void CGlxContentHarvesterPluginAlbums::DestroyMedialist() |
|
434 { |
|
435 TRACER( "CGlxContentHarvesterPluginAlbums::DestroyMedialist" ); |
|
436 if( iMediaList ) |
|
437 { |
|
438 GLX_LOG_INFO("CGlxContentHarvesterPluginAlbums::DestroyMedialist,media list deleted"); |
|
439 RemoveContextAndObserver(); |
|
440 delete iThumbnailContext; |
|
441 iThumbnailContext = NULL; |
|
442 iMediaList->Close(); |
|
443 iMediaList = NULL; |
|
444 } |
|
445 } |
|
446 |
|
447 // --------------------------------------------------------------------------- |
|
448 // CGlxContentHarvesterPluginAlbums::CreateMedialistL |
|
449 // --------------------------------------------------------------------------- |
|
450 // |
|
451 void CGlxContentHarvesterPluginAlbums::CreateMedialistL( ) |
|
452 { |
|
453 TRACER( "CGlxContentHarvesterPluginAlbums::CreateMedialistL" ); |
|
454 if(!iMediaList) |
|
455 { |
|
456 //if the collection is in focus then , create media list with context of 15 items else |
|
457 // with context of single item. |
|
458 if(IsFocused()) |
|
459 { |
|
460 iThumbnailIterator.SetRange( KPreviewThumbnailFetchCount ); |
|
461 } |
|
462 else |
|
463 { |
|
464 iThumbnailIterator.SetRange( KSinglePreviewThumbnail ); |
|
465 } |
|
466 |
|
467 iMediaList = CreateMedialistAndThumbnailContextL( TGlxMediaId( |
|
468 KGlxCollectionPluginAlbumsImplementationUid ),iThumbnailContext); |
|
469 AddContextAndObserverL(); |
|
470 } |
|
471 } |
|
472 |
|
473 // --------------------------------------------------------------------------- |
|
474 // CGlxContentHarvesterPluginAlbums::UpdatePreviewThumbnailListL |
|
475 // --------------------------------------------------------------------------- |
|
476 // |
|
477 void CGlxContentHarvesterPluginAlbums::UpdatePreviewThumbnailListL( ) |
|
478 { |
|
479 TRACER( "CGlxContentHarvesterPluginAlbums::UpdatePreviewThumbnailListL" ); |
|
480 |
|
481 //when there is an update of content in the collection |
|
482 //this function is executed or when the collection recives the focus. |
|
483 if(!iMediaList) |
|
484 { |
|
485 //media list is not created yet,create it. |
|
486 CreateMedialistL( ); |
|
487 //This is called to show the preview thumbnails. If no thumbnails are |
|
488 //present, display nothing |
|
489 UpdateDataL(); |
|
490 } |
|
491 else |
|
492 { |
|
493 if(GetCHPlugin()->IsRefreshNeeded()) |
|
494 { |
|
495 ContainerCacheCleanupL(iMediaList); |
|
496 } |
|
497 if(IsFocused()) |
|
498 { |
|
499 //1.This loop is executed,when the collection gets focus |
|
500 //2.This loop is executed,when the contents are updated for this collection |
|
501 //and this collection has focus,so 15 thumbnails are fetched. |
|
502 HandleItemChanged(); |
|
503 iThumbnailIterator.SetRange( KPreviewThumbnailFetchCount ); |
|
504 RemoveContextAndObserver(); |
|
505 AddContextAndObserverL(); |
|
506 } |
|
507 else |
|
508 { |
|
509 //1.This loop is executed,when the contents are updated for this collection |
|
510 //and this collection doesn't have the focus,so only one thumbnail is fetched. |
|
511 |
|
512 //here we need to fetch only one item |
|
513 //1.if the content is deleted,then creating a context doesn't fetch the attributes |
|
514 //2.if the content is added and the content is not the latest as per the sorted order of the |
|
515 // media list,then the thumbnails are not fetched. |
|
516 // so show the first available thumbnail in the media list. |
|
517 |
|
518 HandleItemChanged(); |
|
519 UpdateDataL(); |
|
520 |
|
521 //Adding the context doesn't gaurantee we get a call back for |
|
522 //Handle attributes available,if the latest item is already fetched. |
|
523 //and for the content added for this collection,if it is not latest |
|
524 //we will not recieve the attributes .so show the first available thumbnail |
|
525 //in the media list.if there is any new latest content added,the thumbnail will be |
|
526 //fetched and shown. |
|
527 |
|
528 iThumbnailIterator.SetRange( KSinglePreviewThumbnail ); |
|
529 RemoveContextAndObserver(); |
|
530 AddContextAndObserverL(); |
|
531 } |
|
532 } |
|
533 } |
|
534 |
|
535 // --------------------------------------------------------------------------- |
|
536 // CGlxContentHarvesterPluginAlbums::AddContextAndObserverL |
|
537 // --------------------------------------------------------------------------- |
|
538 // |
|
539 void CGlxContentHarvesterPluginAlbums::AddContextAndObserverL() |
|
540 { |
|
541 TRACER( "CGlxContentHarvesterPluginAlbums::AddRemoveContextAndObserverL" ); |
|
542 if(iMediaList) |
|
543 { |
|
544 iMediaList->AddMediaListObserverL( this ); |
|
545 iMediaList->AddContextL(iThumbnailContext, KGlxFetchContextPriorityNormal); |
|
546 } |
|
547 } |
|
548 |
|
549 // --------------------------------------------------------------------------- |
|
550 // CGlxContentHarvesterPluginAlbums::RemoveContextAndObserver |
|
551 // --------------------------------------------------------------------------- |
|
552 // |
|
553 void CGlxContentHarvesterPluginAlbums::RemoveContextAndObserver() |
|
554 { |
|
555 TRACER( "CGlxContentHarvesterPluginAlbums::RemoveContextAndObserver" ); |
|
556 if(iMediaList) |
|
557 { |
|
558 iMediaList->RemoveMediaListObserver( this ); |
|
559 iMediaList->RemoveContext(iThumbnailContext); |
|
560 } |
|
561 } |
|
562 |
|
563 // --------------------------------------------------------------------------- |
|
564 // CGlxContentHarvesterPluginAlbums::HandleError |
|
565 // --------------------------------------------------------------------------- |
|
566 // |
|
567 void CGlxContentHarvesterPluginAlbums::HandleError(TInt /*aError*/) |
|
568 { |
|
569 TRACER( "CGlxContentHarvesterPluginAlbums::HandleError" ); |
|
570 |
|
571 #ifdef _DEBUG |
|
572 if(iMediaList) |
|
573 { |
|
574 TInt count=iMediaList->Count(); |
|
575 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::HandleError,count=%d",count); |
|
576 for ( TInt i = 0; i < count ; i++ ) |
|
577 { |
|
578 const TGlxMedia& item = iMediaList->Item( i ); |
|
579 TInt thumbnailError = GlxErrorManager::HasAttributeErrorL( |
|
580 item.Properties(), KGlxMediaIdThumbnail ); |
|
581 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::HandleError,Error=%d ",thumbnailError); |
|
582 |
|
583 } |
|
584 } |
|
585 #endif |
|
586 } |
|
587 |
|
588 // --------------------------------------------------------------------------- |
|
589 // CGlxContentHarvesterPluginAlbums::Count |
|
590 // --------------------------------------------------------------------------- |
|
591 // |
|
592 TInt CGlxContentHarvesterPluginAlbums::Count() |
|
593 { |
|
594 TRACER( "CGlxContentHarvesterPluginAlbums::Count" ); |
|
595 TInt count = KErrNone; |
|
596 if(iMediaList) |
|
597 { |
|
598 count = iMediaList->Count(); |
|
599 GLX_LOG_INFO1("GlxCHP:Albums::Count(%d)",count); |
|
600 } |
|
601 return count; |
|
602 } |
|
603 // End of File |
|
604 |