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