|
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 months 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 <glxcollectionpluginmonths.hrh> |
|
26 #include <glxthumbnailattributeinfo.h> // for KGlxMediaIdThumbnail |
|
27 #include <glxattributecontext.h> |
|
28 #include <glxthumbnailcontext.h> |
|
29 |
|
30 #include <glxtracer.h> |
|
31 #include <glxlog.h> |
|
32 #include <mglxmedialist.h> // for MGlxMediaList |
|
33 #include <glxcollectiongeneraldefs.h> |
|
34 #include <glxgallery.hrh> // for KGlxGalleryApplicationUid |
|
35 #include <glxmediaid.h> |
|
36 #include <glxerrormanager.h> |
|
37 |
|
38 #include "glxcontentharvesterpluginmonths.h" |
|
39 #include "glxcontentharvesterplugin.hrh" |
|
40 #include "glxmapconstants.h" |
|
41 |
|
42 // ============================ MEMBER FUNCTIONS ============================== |
|
43 LOCAL_C TInt TimerCallbackL( TAny* aPtr ) |
|
44 { |
|
45 TRACER( "CGlxContentHarvesterPluginMonths::TimerCallbackL" ); |
|
46 static_cast<CGlxContentHarvesterPluginMonths*>(aPtr)->UpdateDataL(); |
|
47 return KErrNone; |
|
48 } |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // Constructor |
|
52 // ---------------------------------------------------------------------------- |
|
53 // |
|
54 CGlxContentHarvesterPluginMonths::CGlxContentHarvesterPluginMonths( |
|
55 MLiwInterface* aCPSInterface, |
|
56 MGlxContentHarvesterPlugin *aCHplugin ) |
|
57 |
|
58 { |
|
59 TRACER( "CGlxContentHarvesterPluginMonths::CGlxContentHarvesterPluginMonths" ); |
|
60 iCPSInterface = aCPSInterface; |
|
61 SetCHPlugin(aCHplugin); |
|
62 } |
|
63 |
|
64 // ---------------------------------------------------------------------------- |
|
65 // Symbian 2nd phase constructor can leave. |
|
66 // ---------------------------------------------------------------------------- |
|
67 // |
|
68 void CGlxContentHarvesterPluginMonths::ConstructL() |
|
69 { |
|
70 TRACER( "CGlxContentHarvesterPluginMonths::ConstructL" ); |
|
71 |
|
72 //Call the base class ConstructL to create default bitmap |
|
73 CGlxContentHarvesterPluginBase::ConstructL(EMbmGlxiconsQgn_prop_image_notcreated); |
|
74 |
|
75 iPeriodic = CPeriodic::NewL( CActive::EPriorityLow ); |
|
76 iThumbnailContext = CGlxThumbnailContext::NewL(&iThumbnailIterator); |
|
77 |
|
78 //Register/Subscribe with matrix menu for the notifications |
|
79 GetInterfaceForNotificationL(); |
|
80 SetupPublisherL(KItemIndexMonths); |
|
81 RequestCpsNotificationL(KItemIndexMonths); |
|
82 HandleStateChangeL(KItemIndexMonths); |
|
83 } |
|
84 |
|
85 // ---------------------------------------------------------------------------- |
|
86 // Two-phased constructor. |
|
87 // ---------------------------------------------------------------------------- |
|
88 // |
|
89 CGlxContentHarvesterPluginMonths* CGlxContentHarvesterPluginMonths::NewLC( |
|
90 MLiwInterface* aCPSInterface, |
|
91 MGlxContentHarvesterPlugin *aCHplugin ) |
|
92 { |
|
93 TRACER( "CGlxContentHarvesterPluginMonths::NewL" ); |
|
94 CGlxContentHarvesterPluginMonths* self = new ( ELeave ) CGlxContentHarvesterPluginMonths( aCPSInterface,aCHplugin ); |
|
95 CleanupStack::PushL(self); |
|
96 self->ConstructL(); |
|
97 return self; |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // Destructor |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 CGlxContentHarvesterPluginMonths::~CGlxContentHarvesterPluginMonths() |
|
105 { |
|
106 TRACER( "CGlxContentHarvesterPluginMonths::~CGlxContentHarvesterPluginMonths" ); |
|
107 DestroyMedialist(); |
|
108 if ( iPeriodic ) |
|
109 { |
|
110 iPeriodic->Cancel(); |
|
111 } |
|
112 delete iPeriodic; |
|
113 |
|
114 } |
|
115 |
|
116 // ---------------------------------------------------------------------------- |
|
117 // CGlxContentHarvesterPluginMonths::UpdateDataL() |
|
118 // ---------------------------------------------------------------------------- |
|
119 // |
|
120 void CGlxContentHarvesterPluginMonths::UpdateDataL() |
|
121 { |
|
122 TRACER( "CGlxContentHarvesterPluginMonths::UpdateDataL" ); |
|
123 if(iMediaList && iMediaList->Count() && iPreviewItemCount.Count() ) |
|
124 { |
|
125 GLX_LOG_INFO1("CGlxContentHarvesterPluginMonths::UpdateDataL(),iProgressIndex=%d",iProgressIndex); |
|
126 TInt ret = UpdateItem(iPreviewItemCount[iProgressIndex]); |
|
127 if(ret != KErrNotFound) |
|
128 { |
|
129 //Updates the thumbnail in the collection |
|
130 UpdateDataInCPSL(ret); |
|
131 } |
|
132 else |
|
133 { |
|
134 UpdateDataInCPSL(GetBitmapHandle()); |
|
135 } |
|
136 } |
|
137 else |
|
138 { |
|
139 // Show previous thumbnail until the new thumbnail is |
|
140 // fecthed.Added this check to avoid flicker |
|
141 if(!GetCHPlugin()->IsRefreshNeeded() || (iMediaList->Count() == 0)) |
|
142 { |
|
143 //Don't Show the Thumbnail/Show nothing |
|
144 GLX_LOG_INFO("CGlxContentHarvesterPluginMonths::UpdateDataL() --O"); |
|
145 UpdateDataInCPSL(GetBitmapHandle()); |
|
146 } |
|
147 } |
|
148 } |
|
149 |
|
150 // ---------------------------------------------------------------------------- |
|
151 // CGlxContentHarvesterPluginMonths::HandleNotifyL() |
|
152 // ---------------------------------------------------------------------------- |
|
153 // |
|
154 TInt CGlxContentHarvesterPluginMonths::HandleNotifyL( |
|
155 TInt /* aCmdId*/, |
|
156 TInt/* aEventId */, |
|
157 CLiwGenericParamList& /*aEventParamList*/, |
|
158 const CLiwGenericParamList& /*aInParamList*/ ) |
|
159 { |
|
160 TRACER( "CGlxContentHarvesterPluginMonths::HandleNotifyL" ); |
|
161 HandleStateChangeL(KItemIndexMonths); |
|
162 return KErrNone; |
|
163 } |
|
164 |
|
165 // ---------------------------------------------------------------------------- |
|
166 // CGlxContentHarvesterPluginMonths::HandleItemChanged() |
|
167 // ---------------------------------------------------------------------------- |
|
168 // |
|
169 void CGlxContentHarvesterPluginMonths::HandleItemChanged() |
|
170 { |
|
171 TRACER("CGlxContentHarvesterPluginMonths::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("CGlxContentHarvesterPluginMonths:: 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 NOT in Focus,retrieve only one thumbnail and break |
|
195 GLX_LOG_INFO1("CGlxContentHarvesterPluginMonths::HandleItemChanged,Range=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("CGlxContentHarvesterPluginMonths::HandleItemChanged,Range=15,aItemIndex=%d",aItemIndex); |
|
203 break; |
|
204 } |
|
205 |
|
206 } |
|
207 } |
|
208 } |
|
209 } |
|
210 |
|
211 // ---------------------------------------------------------------------------- |
|
212 // CGlxContentHarvesterPluginMonths::UpdateDataInCPSL() |
|
213 // ---------------------------------------------------------------------------- |
|
214 // |
|
215 void CGlxContentHarvesterPluginMonths::UpdateDataInCPSL(TInt aHandle) |
|
216 { |
|
217 TRACER( "CGlxContentHarvesterPluginMonths::UpdateDataInCPSL" ); |
|
218 //update data in CPS |
|
219 _LIT(KExamplePluginPub,"photossuite"); |
|
220 _LIT(KContTypeText,"months"); |
|
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 // CGlxContentHarvesterPluginMonths::UpdateItem() |
|
239 // ---------------------------------------------------------------------------- |
|
240 // |
|
241 TInt CGlxContentHarvesterPluginMonths::UpdateItem(TInt aItemIndex) |
|
242 { |
|
243 TRACER( "CGlxContentHarvesterPluginMonths::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("CGlxContentHarvesterPluginMonths::UpdateItem,aItemIndex=%d ",aItemIndex); |
|
249 const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute ); |
|
250 if (value) |
|
251 { |
|
252 GLX_LOG_INFO1("CGlxContentHarvesterPluginMonths::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 // CGlxContentHarvesterPluginMonths::ActivateL() |
|
267 // ---------------------------------------------------------------------------- |
|
268 // |
|
269 void CGlxContentHarvesterPluginMonths::ActivateL( TBool aOn ) |
|
270 { |
|
271 TRACER( "CGlxContentHarvesterPluginMonths::ActivateL" ); |
|
272 |
|
273 GLX_LOG_INFO1("CGlxContentHarvesterPluginMonths::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("CGlxContentHarvesterPluginMonths::ActivateL !aOn =%d and matrix not in foreground",aOn); |
|
301 GetCHPlugin()->UpdatePlugins(aOn); |
|
302 } |
|
303 iPeriodic->Cancel(); |
|
304 } |
|
305 } |
|
306 |
|
307 // ---------------------------------------------------------------------------- |
|
308 // CGlxContentHarvesterPluginMonths::HandleItemAddedL |
|
309 // ---------------------------------------------------------------------------- |
|
310 // |
|
311 void CGlxContentHarvesterPluginMonths::HandleItemAddedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/, |
|
312 MGlxMediaList* /*aList*/) |
|
313 { |
|
314 TRACER( "CGlxContentHarvesterPluginMonths::HandleItemAddedL" ); |
|
315 } |
|
316 |
|
317 // --------------------------------------------------------------------------- |
|
318 // CGlxContentHarvesterPluginMonths::HandleMediaL |
|
319 // --------------------------------------------------------------------------- |
|
320 // |
|
321 void CGlxContentHarvesterPluginMonths::HandleMediaL(TInt /*aListIndex*/, |
|
322 MGlxMediaList* /*aList*/) |
|
323 { |
|
324 TRACER( "CGlxContentHarvesterPluginMonths::HandleMediaL" ); |
|
325 } |
|
326 |
|
327 // --------------------------------------------------------------------------- |
|
328 // CGlxContentHarvesterPluginMonths::HandleItemRemovedL |
|
329 // --------------------------------------------------------------------------- |
|
330 // |
|
331 void CGlxContentHarvesterPluginMonths::HandleItemRemovedL(TInt /*aStartIndex*/, |
|
332 TInt /* aEndIndex */, MGlxMediaList* /*aList*/) |
|
333 { |
|
334 TRACER( "CGlxContentHarvesterPluginMonths::HandleItemRemovedL" ); |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------------------------- |
|
338 // CGlxContentHarvesterPluginMonths::HandleItemModifiedL |
|
339 // --------------------------------------------------------------------------- |
|
340 // |
|
341 void CGlxContentHarvesterPluginMonths::HandleItemModifiedL( |
|
342 const RArray<TInt>& /*aItemIndexes*/, |
|
343 MGlxMediaList* /*aList*/) |
|
344 { |
|
345 TRACER( "CGlxContentHarvesterPluginMonths::HandleItemModifiedL" ); |
|
346 } |
|
347 |
|
348 // --------------------------------------------------------------------------- |
|
349 // CGlxContentHarvesterPluginMonths::HandleAttributesAvailableL |
|
350 // --------------------------------------------------------------------------- |
|
351 // |
|
352 void CGlxContentHarvesterPluginMonths::HandleAttributesAvailableL(TInt aItemIndex, |
|
353 const RArray<TMPXAttribute>& aAttributes, MGlxMediaList* aList) |
|
354 { |
|
355 TRACER( "CGlxContentHarvesterPluginMonths::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("CGlxContentHarvesterPluginMonths::HandleAttributesAvailableL =%d ",aItemIndex); |
|
363 if (KErrNotFound != aAttributes.Find( thumbnailAttribute, match )) |
|
364 { |
|
365 const TGlxMedia& item = aList->Item( aItemIndex ); |
|
366 const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute ); |
|
367 if (value) |
|
368 { |
|
369 GLX_LOG_INFO("CGlxContentHarvesterPluginMonths::HandleAttributesAvailableL Thumbnail is present "); |
|
370 iPreviewItemCount.InsertInOrder(aItemIndex); |
|
371 |
|
372 //if the collection on the matrix menu is not focused,then show only one thumbnail |
|
373 if(!IsFocused()) |
|
374 { |
|
375 GLX_LOG_INFO("CGlxContentHarvesterPluginMonths::HandleAttributesAvailableL,one thumbnail fetched"); |
|
376 UpdateDataInCPSL( value->iBitmap->Handle()); |
|
377 //if one thumbnail is fetched,it is sufficent when the collection is not in focus. |
|
378 //remove the observer as client need not listen to the callbacks |
|
379 iMediaList->RemoveMediaListObserver( this ); |
|
380 } |
|
381 else if (iPreviewItemCount.Count() == KPreviewThumbnailFetchCount || |
|
382 iPreviewItemCount.Count() == aList->Count() ) |
|
383 { |
|
384 GLX_LOG_INFO1("CGlxContentHarvesterPluginMonths::HandleAttributesAvailableL,media list count=%d",aList->Count()); |
|
385 //if the PreviewItemCount equals 15 or if it is eqaul to the total count |
|
386 //remove the observer as client need not listen to the callbacks |
|
387 iMediaList->RemoveMediaListObserver( this ); |
|
388 } |
|
389 }//end of check against value |
|
390 }//end of attribute match |
|
391 } |
|
392 |
|
393 // --------------------------------------------------------------------------- |
|
394 // CGlxContentHarvesterPluginMonths::HandleFocusChangedL |
|
395 // --------------------------------------------------------------------------- |
|
396 // |
|
397 void CGlxContentHarvesterPluginMonths::HandleFocusChangedL( |
|
398 NGlxListDefs::TFocusChangeType /*aType*/, |
|
399 TInt /*aNewIndex*/, |
|
400 TInt /*aOldIndex*/, |
|
401 MGlxMediaList* /*aList*/) |
|
402 { |
|
403 TRACER( "CGlxContentHarvesterPluginMonths::HandleFocusChangedL" ); |
|
404 } |
|
405 |
|
406 |
|
407 // --------------------------------------------------------------------------- |
|
408 // CGlxContentHarvesterPluginMonths::HandleItemSelectedL |
|
409 // --------------------------------------------------------------------------- |
|
410 // |
|
411 void CGlxContentHarvesterPluginMonths::HandleItemSelectedL(TInt /*aIndex*/, |
|
412 TBool /*aSelected*/, |
|
413 MGlxMediaList* /*aList*/) |
|
414 { |
|
415 TRACER( "CGlxContentHarvesterPluginMonths::HandleItemSelectedL" ); |
|
416 } |
|
417 |
|
418 // --------------------------------------------------------------------------- |
|
419 // CGlxContentHarvesterPluginMonths::HandleMessageL |
|
420 // --------------------------------------------------------------------------- |
|
421 // |
|
422 void CGlxContentHarvesterPluginMonths::HandleMessageL(const CMPXMessage& /*aMessage*/, |
|
423 MGlxMediaList* /*aList*/) |
|
424 { |
|
425 // Do nothing |
|
426 TRACER( "CGlxContentHarvesterPluginMonths::HandleMessageL" ); |
|
427 } |
|
428 |
|
429 // --------------------------------------------------------------------------- |
|
430 // CGlxContentHarvesterPluginMonths::DestroyMedialist |
|
431 // --------------------------------------------------------------------------- |
|
432 // |
|
433 void CGlxContentHarvesterPluginMonths::DestroyMedialist() |
|
434 { |
|
435 TRACER( "CGlxContentHarvesterPluginMonths::DestroyMedialist" ); |
|
436 if( iMediaList ) |
|
437 { |
|
438 GLX_LOG_INFO("CGlxContentHarvesterPluginMonths::DestroyMedialist,media list deleted"); |
|
439 RemoveContextAndObserver(); |
|
440 delete iThumbnailContext; |
|
441 iThumbnailContext = NULL; |
|
442 iMediaList->Close(); |
|
443 iMediaList = NULL; |
|
444 } |
|
445 } |
|
446 |
|
447 // --------------------------------------------------------------------------- |
|
448 // CGlxContentHarvesterPluginMonths::CreateMedialistL |
|
449 // --------------------------------------------------------------------------- |
|
450 // |
|
451 void CGlxContentHarvesterPluginMonths::CreateMedialistL( ) |
|
452 { |
|
453 TRACER( "CGlxContentHarvesterPluginMonths::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 KGlxCollectionPluginMonthsImplementationUid ),iThumbnailContext); |
|
469 AddContextAndObserverL(); |
|
470 } |
|
471 } |
|
472 |
|
473 // --------------------------------------------------------------------------- |
|
474 // CGlxContentHarvesterPluginMonths::UpdatePreviewThumbnailListL |
|
475 // --------------------------------------------------------------------------- |
|
476 // |
|
477 void CGlxContentHarvesterPluginMonths::UpdatePreviewThumbnailListL( ) |
|
478 { |
|
479 TRACER( "CGlxContentHarvesterPluginMonths::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 //medis 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 // --------------------------------------------------------------------------- |
|
537 // CGlxContentHarvesterPluginAlbums::AddContextAndObserverL |
|
538 // --------------------------------------------------------------------------- |
|
539 // |
|
540 void CGlxContentHarvesterPluginMonths::AddContextAndObserverL() |
|
541 { |
|
542 TRACER( "CGlxContentHarvesterPluginMonths::AddRemoveContextAndObserverL" ); |
|
543 if(iMediaList) |
|
544 { |
|
545 iMediaList->AddMediaListObserverL( this ); |
|
546 iMediaList->AddContextL(iThumbnailContext, KGlxFetchContextPriorityNormal); |
|
547 } |
|
548 } |
|
549 |
|
550 // --------------------------------------------------------------------------- |
|
551 // CGlxContentHarvesterPluginAlbums::RemoveContextAndObserver |
|
552 // --------------------------------------------------------------------------- |
|
553 // |
|
554 void CGlxContentHarvesterPluginMonths::RemoveContextAndObserver() |
|
555 { |
|
556 TRACER( "CGlxContentHarvesterPluginMonths::RemoveContextAndObserver" ); |
|
557 if(iMediaList) |
|
558 { |
|
559 iMediaList->RemoveMediaListObserver( this ); |
|
560 iMediaList->RemoveContext(iThumbnailContext); |
|
561 } |
|
562 } |
|
563 |
|
564 // --------------------------------------------------------------------------- |
|
565 // CGlxContentHarvesterPluginMonths::HandleError |
|
566 // --------------------------------------------------------------------------- |
|
567 // |
|
568 void CGlxContentHarvesterPluginMonths::HandleError(TInt /*aError*/) |
|
569 { |
|
570 TRACER( "CGlxContentHarvesterPluginMonths::HandleError" ); |
|
571 |
|
572 #ifdef _DEBUG |
|
573 if(iMediaList) |
|
574 { |
|
575 TInt count=iMediaList->Count(); |
|
576 GLX_LOG_INFO1("CGlxContentHarvesterPluginMonths::HandleError,count=%d",count); |
|
577 for ( TInt i = 0; i < count ; i++ ) |
|
578 { |
|
579 const TGlxMedia& item = iMediaList->Item( i ); |
|
580 TInt thumbnailError = GlxErrorManager::HasAttributeErrorL( |
|
581 item.Properties(), KGlxMediaIdThumbnail ); |
|
582 GLX_LOG_INFO1("CGlxContentHarvesterPluginMonths::HandleError,Error=%d ",thumbnailError); |
|
583 |
|
584 } |
|
585 } |
|
586 #endif |
|
587 } |
|
588 |
|
589 // --------------------------------------------------------------------------- |
|
590 // CGlxContentHarvesterPluginMonths::Count |
|
591 // --------------------------------------------------------------------------- |
|
592 // |
|
593 TInt CGlxContentHarvesterPluginMonths::Count() |
|
594 { |
|
595 TRACER( "CGlxContentHarvesterPluginMonths::Count" ); |
|
596 TInt count = KErrNone; |
|
597 if(iMediaList) |
|
598 { |
|
599 count = iMediaList->Count(); |
|
600 GLX_LOG_INFO1("GlxCHP:Months::Count(%d)",count); |
|
601 } |
|
602 return count; |
|
603 } |
|
604 // End of File |
|
605 |