38 #include "glxcontentharvesterplugin.hrh" |
38 #include "glxcontentharvesterplugin.hrh" |
39 #include "glxmapconstants.h" |
39 #include "glxmapconstants.h" |
40 |
40 |
41 |
41 |
42 // ============================ MEMBER FUNCTIONS ============================== |
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 |
43 |
50 // ---------------------------------------------------------------------------- |
44 // ---------------------------------------------------------------------------- |
51 // Constructor |
45 // Constructor |
52 // ---------------------------------------------------------------------------- |
46 // ---------------------------------------------------------------------------- |
53 // |
47 // |
68 { |
62 { |
69 TRACER( "CGlxContentHarvesterPluginAlbums::ConstructL" ); |
63 TRACER( "CGlxContentHarvesterPluginAlbums::ConstructL" ); |
70 |
64 |
71 //Call the base class ConstructL |
65 //Call the base class ConstructL |
72 CGlxContentHarvesterPluginBase::ConstructL(EMbmGlxiconsQgn_prop_image_notcreated); |
66 CGlxContentHarvesterPluginBase::ConstructL(EMbmGlxiconsQgn_prop_image_notcreated); |
73 |
|
74 iPeriodic = CPeriodic::NewL( CActive::EPriorityLow ); |
|
75 |
|
76 iUriAttributeContext = new (ELeave) CGlxAttributeContext(&iThumbnailIterator); |
67 iUriAttributeContext = new (ELeave) CGlxAttributeContext(&iThumbnailIterator); |
77 iThumbnailAttributeContext = new (ELeave) CGlxAttributeContext(&iThumbnailIterator); |
68 iThumbnailAttributeContext = new (ELeave) CGlxAttributeContext(&iThumbnailIterator); |
78 |
69 |
79 //Register/Subscribe with matrix menu for the notifications |
70 //Register/Subscribe with matrix menu for the notifications |
80 GetInterfaceForNotificationL(); |
71 GetInterfaceForNotificationL(); |
105 CGlxContentHarvesterPluginAlbums::~CGlxContentHarvesterPluginAlbums() |
96 CGlxContentHarvesterPluginAlbums::~CGlxContentHarvesterPluginAlbums() |
106 { |
97 { |
107 TRACER( "CGlxContentHarvesterPluginAlbums::~CGlxContentHarvesterPluginAlbums" ); |
98 TRACER( "CGlxContentHarvesterPluginAlbums::~CGlxContentHarvesterPluginAlbums" ); |
108 |
99 |
109 DestroyMedialist(); |
100 DestroyMedialist(); |
110 if ( iPeriodic ) |
|
111 { |
|
112 iPeriodic->Cancel(); |
|
113 } |
|
114 delete iPeriodic; |
|
115 } |
101 } |
116 |
102 |
117 // ---------------------------------------------------------------------------- |
103 // ---------------------------------------------------------------------------- |
118 // CGlxContentHarvesterPluginAlbums::UpdateDataL() |
104 // CGlxContentHarvesterPluginAlbums::UpdateDataL() |
119 // ---------------------------------------------------------------------------- |
105 // ---------------------------------------------------------------------------- |
120 // |
106 // |
121 void CGlxContentHarvesterPluginAlbums::UpdateDataL() |
107 void CGlxContentHarvesterPluginAlbums::UpdateDataL() |
122 { |
108 { |
123 TRACER( "CGlxContentHarvesterPluginAlbums::UpdateDataL" ); |
109 TRACER( "CGlxContentHarvesterPluginAlbums::UpdateDataL" ); |
124 if(iMediaList && iMediaList->Count() && iPreviewItemCount.Count() ) |
110 |
125 { |
111 if (!iMediaList) |
126 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::UpdateDataL(),iProgressIndex=%d",iProgressIndex); |
112 { |
127 TInt ret = UpdateItem(iPreviewItemCount[iProgressIndex]); |
113 return; |
128 if(ret != KErrNotFound) |
114 } |
|
115 |
|
116 if (iMediaList->Count()) |
|
117 { |
|
118 TInt ret = UpdateItem(KPreviewItemIndex); |
|
119 if (ret != KErrNotFound) |
129 { |
120 { |
130 //Updates the thumbnail in the collection |
121 //Updates the thumbnail in the collection |
131 UpdateDataInCPSL(ret); |
122 UpdateDataInCPSL(ret); |
132 } |
123 } |
133 else |
|
134 { |
|
135 UpdateDataInCPSL(GetBitmapHandle()); |
|
136 } |
|
137 } |
124 } |
138 else |
125 else |
139 { |
126 { |
140 // Show previous thumbnail until the new thumbnail is |
127 // Show previous thumbnail until the new thumbnail is |
141 // fecthed.Added this check to avoid flicker |
128 // fecthed.Added this check to avoid flicker |
142 if(!GetCHPlugin()->IsRefreshNeeded() || (iMediaList->Count() == 0)) |
129 if (!GetCHPlugin()->IsRefreshNeeded() || (iMediaList->Count() == 0)) |
143 { |
130 { |
144 //Don't Show the Thumbnail/Show nothing |
131 //Don't Show the Thumbnail/Show nothing |
145 GLX_LOG_INFO("CGlxContentHarvesterPluginAlbums::UpdateDataL() --O"); |
132 GLX_LOG_INFO("CGlxContentHarvesterPluginAlbums::UpdateDataL() --O"); |
146 UpdateDataInCPSL(GetBitmapHandle()); |
133 UpdateDataInCPSL(GetBitmapHandle()); |
147 } |
134 } |
148 |
|
149 } |
135 } |
150 } |
136 } |
151 |
137 |
152 // ---------------------------------------------------------------------------- |
138 // ---------------------------------------------------------------------------- |
153 // CGlxContentHarvesterPluginAlbums::HandleNotifyL() |
139 // CGlxContentHarvesterPluginAlbums::HandleNotifyL() |
160 const CLiwGenericParamList& /*aInParamList*/ ) |
146 const CLiwGenericParamList& /*aInParamList*/ ) |
161 { |
147 { |
162 TRACER( "CGlxContentHarvesterPluginAlbums::HandleNotifyL" ); |
148 TRACER( "CGlxContentHarvesterPluginAlbums::HandleNotifyL" ); |
163 HandleStateChangeL(KItemIndexAlbums); |
149 HandleStateChangeL(KItemIndexAlbums); |
164 return KErrNone; |
150 return KErrNone; |
165 } |
|
166 |
|
167 // ---------------------------------------------------------------------------- |
|
168 // CGlxContentHarvesterPluginAlbums::HandleItemChanged() |
|
169 // ---------------------------------------------------------------------------- |
|
170 // |
|
171 void CGlxContentHarvesterPluginAlbums::HandleItemChanged() |
|
172 { |
|
173 TRACER("CGlxContentHarvesterPluginAlbums::HandleItemChanged"); |
|
174 |
|
175 iProgressIndex = 0; |
|
176 iPreviewItemCount.Reset(); |
|
177 |
|
178 TSize gridIconSize = GetGridIconSize(); |
|
179 TMPXAttribute thumbnailAttribute(KGlxMediaIdThumbnail, |
|
180 GlxFullThumbnailAttributeId( ETrue, gridIconSize.iWidth, gridIconSize.iHeight ) ); |
|
181 if(iMediaList) |
|
182 { |
|
183 TInt count = iMediaList->Count(); |
|
184 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums:: HandleItemChanged ,count=%d",count); |
|
185 |
|
186 TBool inFocus = IsFocused(); |
|
187 for(TInt aItemIndex = 0; aItemIndex < count; aItemIndex++) |
|
188 { |
|
189 const TGlxMedia& item = iMediaList->Item( aItemIndex ); |
|
190 const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute ); |
|
191 if (value) |
|
192 { |
|
193 iPreviewItemCount.InsertInOrder(aItemIndex); |
|
194 if(!inFocus) |
|
195 { |
|
196 //if the collection is in Focus,retrieve only one thumbnail and break |
|
197 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::HandleItemChanged,iRange=1,aItemIndex=%d",aItemIndex); |
|
198 break; |
|
199 } |
|
200 else if(iPreviewItemCount.Count() == KPreviewThumbnailFetchCount || |
|
201 iPreviewItemCount.Count() == count ) |
|
202 { |
|
203 //if the collection is not in Focus,retrieve 15 thumbnail and break |
|
204 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::HandleItemChanged,iRange=15,aItemIndex=%d",aItemIndex); |
|
205 break; |
|
206 } |
|
207 |
|
208 } |
|
209 } |
|
210 } |
|
211 } |
151 } |
212 |
152 |
213 // ---------------------------------------------------------------------------- |
153 // ---------------------------------------------------------------------------- |
214 // CGlxContentHarvesterPluginAlbums::UpdateDataInCPSL() |
154 // CGlxContentHarvesterPluginAlbums::UpdateDataInCPSL() |
215 // ---------------------------------------------------------------------------- |
155 // ---------------------------------------------------------------------------- |
249 GlxFullThumbnailAttributeId( ETrue, gridIconSize.iWidth, gridIconSize.iHeight ) ); |
189 GlxFullThumbnailAttributeId( ETrue, gridIconSize.iWidth, gridIconSize.iHeight ) ); |
250 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::UpdateItem,aItemIndex=%d ",aItemIndex); |
190 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::UpdateItem,aItemIndex=%d ",aItemIndex); |
251 const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute ); |
191 const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute ); |
252 if (value) |
192 if (value) |
253 { |
193 { |
254 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::UpdateItem,iProgressIndex=%d ",iProgressIndex); |
|
255 iProgressIndex++; |
|
256 if (iProgressIndex >= KPreviewThumbnailFetchCount || |
|
257 iProgressIndex >= iPreviewItemCount.Count() || |
|
258 iProgressIndex >= iMediaList->Count()) |
|
259 { |
|
260 iProgressIndex = 0; |
|
261 } |
|
262 return value->iBitmap->Handle(); |
194 return value->iBitmap->Handle(); |
263 } |
195 } |
264 return KErrNotFound; |
196 return KErrNotFound; |
265 } |
197 } |
266 |
198 |
273 TRACER( "CGlxContentHarvesterPluginAlbums::ActivateL" ); |
205 TRACER( "CGlxContentHarvesterPluginAlbums::ActivateL" ); |
274 |
206 |
275 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::ActivateL aOn =%d",aOn); |
207 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::ActivateL aOn =%d",aOn); |
276 SetFocus(aOn); |
208 SetFocus(aOn); |
277 |
209 |
278 if (IsMatrixMenuInForegroundL() && aOn && !iPeriodic->IsActive() ) |
210 if (IsMatrixMenuInForegroundL() && aOn ) |
279 { |
211 { |
280 if(GetCHPlugin()->IsRefreshNeeded()) |
212 if(GetCHPlugin()->IsRefreshNeeded()) |
281 { |
213 { |
282 //Update the rest of all the collections on receving the focus... |
214 //Update the rest of all the collections on receving the focus... |
283 GetCHPlugin()->UpdatePlugins(aOn); |
215 GetCHPlugin()->UpdatePlugins(aOn); |
286 { |
218 { |
287 //As the collection is not updated by the contentharvester plugin |
219 //As the collection is not updated by the contentharvester plugin |
288 //to update the thumbnails on the focus , need to call the below function |
220 //to update the thumbnails on the focus , need to call the below function |
289 UpdatePreviewThumbnailListL(); |
221 UpdatePreviewThumbnailListL(); |
290 } |
222 } |
291 |
|
292 iPeriodic->Start( KTimerInterval, |
|
293 KTimerInterval, |
|
294 TCallBack( TimerCallbackL, this ) ); |
|
295 } |
223 } |
296 else if ( !aOn ) |
224 else if ( !aOn ) |
297 { |
225 { |
298 if(!IsMatrixMenuInForegroundL()) |
226 if(!IsMatrixMenuInForegroundL()) |
299 { |
227 { |
300 //use case:Matrix Menu is exited, by entering into grid view,application view,capture mode... |
228 //use case:Matrix Menu is exited, by entering into grid view,application view,capture mode... |
301 //Need to destroy all the collection's observers and context |
229 //Need to destroy all the collection's observers and context |
302 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::ActivateL !aOn =%d and matrix not in foreground",aOn); |
230 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::ActivateL !aOn =%d and matrix not in foreground",aOn); |
303 GetCHPlugin()->UpdatePlugins(aOn); |
231 GetCHPlugin()->UpdatePlugins(aOn); |
304 } |
232 } |
305 iPeriodic->Cancel(); |
|
306 } |
233 } |
307 } |
234 } |
308 |
235 |
309 // ---------------------------------------------------------------------------- |
236 // ---------------------------------------------------------------------------- |
310 // CGlxContentHarvesterPluginAlbums::HandleItemAddedL |
237 // CGlxContentHarvesterPluginAlbums::HandleItemAddedL |
368 const TGlxMedia& item = aList->Item( aItemIndex ); |
295 const TGlxMedia& item = aList->Item( aItemIndex ); |
369 const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute ); |
296 const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute ); |
370 if (value) |
297 if (value) |
371 { |
298 { |
372 GLX_LOG_INFO("CGlxContentHarvesterPluginAlbums::HandleAttributesAvailableL Thumbnail is present "); |
299 GLX_LOG_INFO("CGlxContentHarvesterPluginAlbums::HandleAttributesAvailableL Thumbnail is present "); |
373 iPreviewItemCount.InsertInOrder(aItemIndex); |
300 |
374 //if the collection on the matrix menu is not focused,then show only one thumbnail |
301 // Update the preview thumbnail |
375 if(!IsFocused()) |
302 //remove the observer as client need not listen to the callbacks |
376 { |
303 GLX_LOG_INFO("CGlxContentHarvesterPluginAll::HandleAttributesAvailableL,one thumbnail fetched"); |
377 //if one thumbnail is fetched,it is sufficent when the collection is not in focus. |
304 UpdateDataInCPSL( value->iBitmap->Handle()); |
378 //remove the observer as client need not listen to the callbacks |
305 iMediaList->RemoveMediaListObserver( this ); |
379 GLX_LOG_INFO("CGlxContentHarvesterPluginAll::HandleAttributesAvailableL,one thumbnail fetched"); |
|
380 UpdateDataInCPSL( value->iBitmap->Handle()); |
|
381 iMediaList->RemoveMediaListObserver( this ); |
|
382 } |
|
383 else if (iPreviewItemCount.Count() == KPreviewThumbnailFetchCount || |
|
384 iPreviewItemCount.Count() == aList->Count() ) |
|
385 { |
|
386 |
|
387 GLX_LOG_INFO1("CGlxContentHarvesterPluginAlbums::HandleAttributesAvailableL,media list count=%d",aList->Count()); |
|
388 //if the PreviewItemCount equals 15 or if it is eqaul to the total count |
|
389 //remove the observer as client need not listen to the callbacks |
|
390 iMediaList->RemoveMediaListObserver( this ); |
|
391 } |
|
392 }//end of check against value |
306 }//end of check against value |
393 }//end of attribute match |
307 }//end of attribute match |
394 } |
308 } |
395 |
309 |
396 // --------------------------------------------------------------------------- |
310 // --------------------------------------------------------------------------- |
457 void CGlxContentHarvesterPluginAlbums::CreateMedialistL( ) |
371 void CGlxContentHarvesterPluginAlbums::CreateMedialistL( ) |
458 { |
372 { |
459 TRACER( "CGlxContentHarvesterPluginAlbums::CreateMedialistL" ); |
373 TRACER( "CGlxContentHarvesterPluginAlbums::CreateMedialistL" ); |
460 if(!iMediaList) |
374 if(!iMediaList) |
461 { |
375 { |
462 //if the collection is in focus then , create media list with context of 15 items else |
376 iThumbnailIterator.SetRange( KSinglePreviewThumbnail ); |
463 // with context of single item. |
377 |
464 if(IsFocused()) |
|
465 { |
|
466 iThumbnailIterator.SetRange( KPreviewThumbnailFetchCount ); |
|
467 } |
|
468 else |
|
469 { |
|
470 iThumbnailIterator.SetRange( KSinglePreviewThumbnail ); |
|
471 } |
|
472 iMediaList = CreateMedialistAndAttributeContextL( TGlxMediaId( |
378 iMediaList = CreateMedialistAndAttributeContextL( TGlxMediaId( |
473 KGlxCollectionPluginAlbumsImplementationUid ), |
379 KGlxCollectionPluginAlbumsImplementationUid ), |
474 iUriAttributeContext,iThumbnailAttributeContext); |
380 iUriAttributeContext,iThumbnailAttributeContext); |
475 |
381 |
476 AddContextAndObserverL(); |
382 AddContextAndObserverL(); |
489 //this function is executed or when the collection recives the focus. |
395 //this function is executed or when the collection recives the focus. |
490 if(!iMediaList) |
396 if(!iMediaList) |
491 { |
397 { |
492 //media list is not created yet,create it. |
398 //media list is not created yet,create it. |
493 CreateMedialistL( ); |
399 CreateMedialistL( ); |
494 //This is called to show the preview thumbnails. If no thumbnails are |
|
495 //present, display nothing |
|
496 UpdateDataL(); |
400 UpdateDataL(); |
497 } |
401 } |
498 else |
402 else |
499 { |
403 { |
500 if(GetCHPlugin()->IsRefreshNeeded()) |
404 if(GetCHPlugin()->IsRefreshNeeded()) |
501 { |
405 { |
502 ContainerCacheCleanupL(iMediaList); |
406 ContainerCacheCleanupL(iMediaList); |
503 } |
407 } |
504 if(IsFocused()) |
408 |
505 { |
|
506 //1.This loop is executed,when the collection gets focus |
|
507 //2.This loop is executed,when the contents are updated for this collection |
|
508 //and this collection has focus,so 15 thumbnails are fetched. |
|
509 HandleItemChanged(); |
|
510 iThumbnailIterator.SetRange( KPreviewThumbnailFetchCount ); |
|
511 RemoveContextAndObserver(); |
|
512 AddContextAndObserverL(); |
|
513 } |
|
514 else |
|
515 { |
|
516 //1.This loop is executed,when the contents are updated for this collection |
|
517 //and this collection doesn't have the focus,so only one thumbnail is fetched. |
|
518 |
|
519 //here we need to fetch only one item |
|
520 //1.if the content is deleted,then creating a context doesn't fetch the attributes |
409 //1.if the content is deleted,then creating a context doesn't fetch the attributes |
521 //2.if the content is added and the content is not the latest as per the sorted order of the |
410 //2.if the content is added and the content is not the latest as per the sorted order of the |
522 // media list,then the thumbnails are not fetched. |
411 // media list,then the thumbnails are not fetched. |
523 // so show the first available thumbnail in the media list. |
412 // so show the first available thumbnail in the media list. |
524 |
413 |
525 HandleItemChanged(); |
|
526 UpdateDataL(); |
414 UpdateDataL(); |
527 |
415 |
528 //Adding the context doesn't gaurantee we get a call back for |
416 //Adding the context doesn't gaurantee we get a call back for |
529 //Handle attributes available,if the latest item is already fetched. |
417 //Handle attributes available,if the latest item is already fetched. |
530 //and for the content added for this collection,if it is not latest |
418 //and for the content added for this collection,if it is not latest |
534 |
422 |
535 iThumbnailIterator.SetRange( KSinglePreviewThumbnail ); |
423 iThumbnailIterator.SetRange( KSinglePreviewThumbnail ); |
536 RemoveContextAndObserver(); |
424 RemoveContextAndObserver(); |
537 AddContextAndObserverL(); |
425 AddContextAndObserverL(); |
538 } |
426 } |
539 } |
427 |
540 } |
428 } |
541 |
429 |
542 // --------------------------------------------------------------------------- |
430 // --------------------------------------------------------------------------- |
543 // CGlxContentHarvesterPluginAlbums::AddContextAndObserverL |
431 // CGlxContentHarvesterPluginAlbums::AddContextAndObserverL |
544 // --------------------------------------------------------------------------- |
432 // --------------------------------------------------------------------------- |