38 #include "glxcontentharvesterpluginall.h" |
38 #include "glxcontentharvesterpluginall.h" |
39 |
39 |
40 #include "glxmapconstants.h" |
40 #include "glxmapconstants.h" |
41 |
41 |
42 |
42 |
43 // ============================ MEMBER FUNCTIONS ============================== |
|
44 LOCAL_C TInt TimerCallbackL( TAny* aPtr ) |
|
45 { |
|
46 TRACER( "CGlxContentHarvesterPluginAll::TimerCallbackL" ); |
|
47 static_cast<CGlxContentHarvesterPluginAll*>(aPtr)->UpdateDataL(); |
|
48 return KErrNone; |
|
49 } |
|
50 |
|
51 // ---------------------------------------------------------------------------- |
43 // ---------------------------------------------------------------------------- |
52 // Constructor |
44 // Constructor |
53 // ---------------------------------------------------------------------------- |
45 // ---------------------------------------------------------------------------- |
54 // |
46 // |
55 CGlxContentHarvesterPluginAll::CGlxContentHarvesterPluginAll( |
47 CGlxContentHarvesterPluginAll::CGlxContentHarvesterPluginAll( |
69 { |
61 { |
70 TRACER( "CGlxContentHarvesterPluginAll::ConstructL" ); |
62 TRACER( "CGlxContentHarvesterPluginAll::ConstructL" ); |
71 |
63 |
72 //Call the base class ConstructL,to create the default thumbnail |
64 //Call the base class ConstructL,to create the default thumbnail |
73 CGlxContentHarvesterPluginBase::ConstructL(EMbmGlxiconsQgn_prop_image_notcreated); |
65 CGlxContentHarvesterPluginBase::ConstructL(EMbmGlxiconsQgn_prop_image_notcreated); |
74 |
66 |
75 iPeriodic = CPeriodic::NewL( CActive::EPriorityLow ); |
|
76 |
|
77 iUriAttributeContext = new (ELeave) CGlxAttributeContext(&iThumbnailIterator); |
67 iUriAttributeContext = new (ELeave) CGlxAttributeContext(&iThumbnailIterator); |
78 iThumbnailAttributeContext = new (ELeave) CGlxAttributeContext(&iThumbnailIterator); |
68 iThumbnailAttributeContext = new (ELeave) CGlxAttributeContext(&iThumbnailIterator); |
79 |
69 |
80 //Register/Subscribe with matrix menu for the notifications |
70 //Register/Subscribe with matrix menu for the notifications |
81 GetInterfaceForNotificationL(); |
71 GetInterfaceForNotificationL(); |
106 CGlxContentHarvesterPluginAll::~CGlxContentHarvesterPluginAll() |
96 CGlxContentHarvesterPluginAll::~CGlxContentHarvesterPluginAll() |
107 { |
97 { |
108 TRACER( "CGlxContentHarvesterPluginAll::~CGlxContentHarvesterPluginAll" ); |
98 TRACER( "CGlxContentHarvesterPluginAll::~CGlxContentHarvesterPluginAll" ); |
109 |
99 |
110 DestroyMedialist(); |
100 DestroyMedialist(); |
111 |
|
112 if ( iPeriodic ) |
|
113 { |
|
114 iPeriodic->Cancel(); |
|
115 } |
|
116 delete iPeriodic; |
|
117 } |
101 } |
118 |
102 |
119 // ---------------------------------------------------------------------------- |
103 // ---------------------------------------------------------------------------- |
120 // CGlxContentHarvesterPluginAll::UpdateDataL() |
104 // CGlxContentHarvesterPluginAll::UpdateDataL() |
121 // ---------------------------------------------------------------------------- |
105 // ---------------------------------------------------------------------------- |
122 // |
106 // |
123 void CGlxContentHarvesterPluginAll::UpdateDataL() |
107 void CGlxContentHarvesterPluginAll::UpdateDataL() |
124 { |
108 { |
125 TRACER( "CGlxContentHarvesterPluginAll::UpdateDataL" ); |
109 TRACER( "CGlxContentHarvesterPluginAll::UpdateDataL" ); |
126 if(iMediaList && iMediaList->Count() && iPreviewItemCount.Count() ) |
110 |
127 { |
111 if (!iMediaList) |
128 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll::UpdateDataL(),iProgressIndex=%d",iProgressIndex); |
112 { |
129 TInt ret = UpdateItem(iPreviewItemCount[iProgressIndex]); |
113 return; |
130 if(ret != KErrNotFound) |
114 } |
|
115 |
|
116 if (iMediaList->Count()) |
|
117 { |
|
118 TInt ret = UpdateItem(KPreviewItemIndex); |
|
119 if (ret != KErrNotFound) |
131 { |
120 { |
132 //Updates the thumbnail in the collection |
121 //Updates the thumbnail in the collection |
133 UpdateDataInCPSL(ret); |
122 UpdateDataInCPSL(ret); |
134 } |
123 } |
135 else |
|
136 { |
|
137 UpdateDataInCPSL(GetBitmapHandle()); |
|
138 } |
|
139 } |
124 } |
140 else |
125 else |
141 { |
126 { |
142 // Show previous thumbnail until the new thumbnail is |
127 // Show previous thumbnail until the new thumbnail is |
143 // fecthed.Added this check to avoid flicker |
128 // fecthed.Added this check to avoid flicker |
144 if(iMediaList->Count() == 0) |
129 if (iMediaList->Count() == 0) |
145 { |
130 { |
146 //Don't Show the Thumbnail/Show nothing |
131 //Don't Show the Thumbnail/Show nothing |
147 GLX_LOG_INFO("CGlxContentHarvesterPluginAll::UpdateDataL() --O"); |
132 GLX_LOG_INFO("CGlxContentHarvesterPluginAll::UpdateDataL() --O"); |
148 UpdateDataInCPSL(GetBitmapHandle()); |
133 UpdateDataInCPSL(GetBitmapHandle()); |
149 } |
134 } |
150 } |
135 } |
151 } |
136 } |
152 |
137 |
153 // ---------------------------------------------------------------------------- |
138 // ---------------------------------------------------------------------------- |
154 // CGlxContentHarvesterPluginAll::HandleNotifyL() |
139 // CGlxContentHarvesterPluginAll::HandleNotifyL() |
168 // matirix menu under low memory conditions. |
153 // matirix menu under low memory conditions. |
169 GetCHPlugin()->SetRefreshNeeded(ETrue); |
154 GetCHPlugin()->SetRefreshNeeded(ETrue); |
170 |
155 |
171 HandleStateChangeL(KItemIndexAll); |
156 HandleStateChangeL(KItemIndexAll); |
172 return KErrNone; |
157 return KErrNone; |
173 } |
|
174 |
|
175 // ---------------------------------------------------------------------------- |
|
176 // CGlxContentHarvesterPluginAll::HandleItemChanged() |
|
177 // ---------------------------------------------------------------------------- |
|
178 // |
|
179 void CGlxContentHarvesterPluginAll::HandleItemChanged() |
|
180 { |
|
181 TRACER("CGlxContentHarvesterPluginAll::HandleItemChanged"); |
|
182 |
|
183 iProgressIndex = 0; |
|
184 iPreviewItemCount.Reset(); |
|
185 |
|
186 TSize gridIconSize = GetGridIconSize(); |
|
187 TMPXAttribute thumbnailAttribute(KGlxMediaIdThumbnail, |
|
188 GlxFullThumbnailAttributeId( ETrue, gridIconSize.iWidth, gridIconSize.iHeight ) ); |
|
189 if(iMediaList) |
|
190 { |
|
191 TInt count = iMediaList->Count(); |
|
192 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll:: HandleItemChanged ,count=%d",count); |
|
193 |
|
194 TBool inFocus = IsFocused(); |
|
195 for(TInt aItemIndex = 0; aItemIndex < count; aItemIndex++) |
|
196 { |
|
197 const TGlxMedia& item = iMediaList->Item( aItemIndex ); |
|
198 const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute ); |
|
199 if (value) |
|
200 { |
|
201 iPreviewItemCount.InsertInOrder(aItemIndex); |
|
202 if(!inFocus) |
|
203 { |
|
204 //if the collection is NOT in Focus,retrive only one thumbnail and break |
|
205 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll::HandleItemChanged,Range=1,aItemIndex=%d",aItemIndex); |
|
206 break; |
|
207 } |
|
208 else if(iPreviewItemCount.Count() == KPreviewThumbnailFetchCount || |
|
209 iPreviewItemCount.Count() == count ) |
|
210 { |
|
211 //if the collection is not in Focus,retrive 15 thumbnail and break |
|
212 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll::HandleItemChanged,Range=15,aItemIndex=%d",aItemIndex); |
|
213 break; |
|
214 } |
|
215 |
|
216 } |
|
217 } |
|
218 } |
|
219 } |
158 } |
220 |
159 |
221 // ---------------------------------------------------------------------------- |
160 // ---------------------------------------------------------------------------- |
222 // CGlxContentHarvesterPluginAll::UpdateDataInCPSL() |
161 // CGlxContentHarvesterPluginAll::UpdateDataInCPSL() |
223 // ---------------------------------------------------------------------------- |
162 // ---------------------------------------------------------------------------- |
258 GlxFullThumbnailAttributeId( ETrue, gridIconSize.iWidth, gridIconSize.iHeight ) ); |
197 GlxFullThumbnailAttributeId( ETrue, gridIconSize.iWidth, gridIconSize.iHeight ) ); |
259 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll::UpdateItem,aItemIndex=%d ",aItemIndex); |
198 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll::UpdateItem,aItemIndex=%d ",aItemIndex); |
260 const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute ); |
199 const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute ); |
261 if (value) |
200 if (value) |
262 { |
201 { |
263 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll::UpdateItem,iProgressIndex=%d ",iProgressIndex); |
|
264 iProgressIndex++; |
|
265 if (iProgressIndex >= KPreviewThumbnailFetchCount || |
|
266 iProgressIndex >= iPreviewItemCount.Count() || |
|
267 iProgressIndex >= iMediaList->Count()) |
|
268 { |
|
269 iProgressIndex = 0; |
|
270 } |
|
271 return value->iBitmap->Handle(); |
202 return value->iBitmap->Handle(); |
272 } |
203 } |
273 return KErrNotFound; |
204 return KErrNotFound; |
274 } |
205 } |
275 |
206 |
282 TRACER( "CGlxContentHarvesterPluginAll::ActivateL" ); |
213 TRACER( "CGlxContentHarvesterPluginAll::ActivateL" ); |
283 |
214 |
284 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll::ActivateL aOn =%d",aOn); |
215 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll::ActivateL aOn =%d",aOn); |
285 SetFocus(aOn); |
216 SetFocus(aOn); |
286 |
217 |
287 if (IsMatrixMenuInForegroundL() && aOn && !iPeriodic->IsActive() ) |
218 if (IsMatrixMenuInForegroundL() && aOn ) |
288 { |
219 { |
289 if(GetCHPlugin()->IsRefreshNeeded()) |
220 if(GetCHPlugin()->IsRefreshNeeded()) |
290 { |
221 { |
291 //Update the rest of all the collections on receving the focus... |
222 //Update the rest of all the collections on receving the focus... |
292 GetCHPlugin()->UpdatePlugins(aOn); |
223 GetCHPlugin()->UpdatePlugins(aOn); |
295 { |
226 { |
296 //As the collection is not updated by the contentharvester plugin |
227 //As the collection is not updated by the contentharvester plugin |
297 //to update the thumbnails on the focus , need to call the below function |
228 //to update the thumbnails on the focus , need to call the below function |
298 UpdatePreviewThumbnailListL(); |
229 UpdatePreviewThumbnailListL(); |
299 } |
230 } |
300 |
|
301 iPeriodic->Start( KTimerInterval, |
|
302 KTimerInterval, |
|
303 TCallBack( TimerCallbackL, this ) ); |
|
304 } |
231 } |
305 else if ( !aOn ) |
232 else if ( !aOn ) |
306 { |
233 { |
307 if(!IsMatrixMenuInForegroundL()) |
234 if(!IsMatrixMenuInForegroundL()) |
308 { |
235 { |
309 //use case:Matrix Menu is exited, by entering into grid view,application view,capture mode... |
236 //use case:Matrix Menu is exited, by entering into grid view,application view,capture mode... |
310 //Need to destroy all the collection's observers and context |
237 //Need to destroy all the collection's observers and context |
311 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll::ActivateL !aOn =%d and matrix not in foreground",aOn); |
238 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll::ActivateL !aOn =%d and matrix not in foreground",aOn); |
312 GetCHPlugin()->UpdatePlugins(aOn); |
239 GetCHPlugin()->UpdatePlugins(aOn); |
313 } |
240 } |
314 iPeriodic->Cancel(); |
|
315 } |
241 } |
316 } |
242 } |
317 |
243 |
318 // ---------------------------------------------------------------------------- |
244 // ---------------------------------------------------------------------------- |
319 // CGlxContentHarvesterPluginAll::HandleItemAddedL |
245 // CGlxContentHarvesterPluginAll::HandleItemAddedL |
376 const TGlxMedia& item = aList->Item( aItemIndex ); |
302 const TGlxMedia& item = aList->Item( aItemIndex ); |
377 const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute ); |
303 const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute ); |
378 if (value) |
304 if (value) |
379 { |
305 { |
380 GLX_LOG_INFO("CGlxContentHarvesterPluginAll::HandleAttributesAvailableL Thumbnail is present "); |
306 GLX_LOG_INFO("CGlxContentHarvesterPluginAll::HandleAttributesAvailableL Thumbnail is present "); |
381 iPreviewItemCount.InsertInOrder(aItemIndex); |
307 |
382 |
308 // Update the preview thumbnail |
383 //if the collection on the matrix menu is not focused,then show only one thumbnail |
309 //remove the observer as client need not listen to the callbacks |
384 if(!IsFocused()) |
310 GLX_LOG_INFO("CGlxContentHarvesterPluginAll::HandleAttributesAvailableL,one thumbnail fetched"); |
385 { |
311 UpdateDataInCPSL( value->iBitmap->Handle()); |
386 //if one thumbnail is fetched,it is sufficent when the collection is not in focus. |
312 iMediaList->RemoveMediaListObserver( this ); |
387 //remove the observer as client need not listen to the callbacks |
|
388 GLX_LOG_INFO("CGlxContentHarvesterPluginAll::HandleAttributesAvailableL,one thumbnail fetched"); |
|
389 UpdateDataInCPSL( value->iBitmap->Handle()); |
|
390 iMediaList->RemoveMediaListObserver( this ); |
|
391 } |
|
392 else if (iPreviewItemCount.Count() == KPreviewThumbnailFetchCount || |
|
393 iPreviewItemCount.Count() == aList->Count() ) |
|
394 { |
|
395 //if the PreviewItemCount equals 15 or if it is eqaul to the total count |
|
396 //remove the observer as client need not listen to the callbacks |
|
397 GLX_LOG_INFO1("CGlxContentHarvesterPluginAll::HandleAttributesAvailableL,media list count=%d",aList->Count()); |
|
398 iMediaList->RemoveMediaListObserver( this ); |
|
399 } |
|
400 }//end of check against value |
313 }//end of check against value |
401 }//end of attribute match |
314 }//end of attribute match |
402 } |
315 } |
403 |
316 |
404 // --------------------------------------------------------------------------- |
317 // --------------------------------------------------------------------------- |
466 void CGlxContentHarvesterPluginAll::CreateMedialistL( ) |
379 void CGlxContentHarvesterPluginAll::CreateMedialistL( ) |
467 { |
380 { |
468 TRACER( "CGlxContentHarvesterPluginAll::CreateMedialistL" ); |
381 TRACER( "CGlxContentHarvesterPluginAll::CreateMedialistL" ); |
469 if(!iMediaList) |
382 if(!iMediaList) |
470 { |
383 { |
471 //if the collection is in focus then , create media list with context of 15 items else |
384 iThumbnailIterator.SetRange( KSinglePreviewThumbnail ); |
472 // with context of single item. |
|
473 if(IsFocused()) |
|
474 { |
|
475 iThumbnailIterator.SetRange( KPreviewThumbnailFetchCount ); |
|
476 } |
|
477 else |
|
478 { |
|
479 iThumbnailIterator.SetRange( KSinglePreviewThumbnail ); |
|
480 } |
|
481 |
385 |
482 iMediaList = CreateMedialistAndAttributeContextL( TGlxMediaId( |
386 iMediaList = CreateMedialistAndAttributeContextL( TGlxMediaId( |
483 KGlxCollectionPluginAllImplementationUid ), |
387 KGlxCollectionPluginAllImplementationUid ), |
484 iUriAttributeContext,iThumbnailAttributeContext); |
388 iUriAttributeContext,iThumbnailAttributeContext); |
485 |
389 |
486 AddContextAndObserverL(); |
390 AddContextAndObserverL(); |
487 } |
391 } |
488 } |
392 } |
489 |
393 |
490 // --------------------------------------------------------------------------- |
394 // --------------------------------------------------------------------------- |
499 //this function is executed or when the collection recives the focus. |
403 //this function is executed or when the collection recives the focus. |
500 if(!iMediaList) |
404 if(!iMediaList) |
501 { |
405 { |
502 //medis list is not created yet,create it. |
406 //medis list is not created yet,create it. |
503 CreateMedialistL( ); |
407 CreateMedialistL( ); |
504 //This is called to show the preview thumbnails. If no thumbnails are |
|
505 //present, display nothing |
|
506 UpdateDataL(); |
408 UpdateDataL(); |
507 } |
409 } |
508 else if(IsFocused()) |
|
509 { |
|
510 //1.This loop is executed,when the collection gets focus |
|
511 //2.This loop is executed,when the contents are added/deleted for this collection |
|
512 //and this collection has focus,so 15 thumbnails are fetched. |
|
513 //say for example |
|
514 //1.focus is on "All" collection/view and you insert MMC |
|
515 //2.capture in burst mode and return quickly to photos suite and focus on "All" |
|
516 HandleItemChanged(); |
|
517 iThumbnailIterator.SetRange( KPreviewThumbnailFetchCount ); |
|
518 RemoveContextAndObserver(); |
|
519 AddContextAndObserverL(); |
|
520 } |
|
521 else |
410 else |
522 { |
411 { |
523 //1.This loop is executed,when the contents are updated for this collection |
|
524 //and this collection doesn't have the focus,so only one thumbnail is fetched. |
|
525 |
|
526 //here we need to fetch only one item |
|
527 //1.if the content is deleted,then creating a context doesn't fetch the attributes |
|
528 //2.if the content is added and the content is not the latest as per the sorted order of the |
|
529 // media list,then the thumbnails are not fetched. |
|
530 // so show the first available thumbnail in the media list. |
|
531 |
|
532 HandleItemChanged(); |
|
533 UpdateDataL(); |
412 UpdateDataL(); |
534 |
413 |
535 //Adding the context doesn't gaurantee we get a call back for |
414 //Adding the context doesn't gaurantee we get a call back for |
536 //Handle attributes available,if the latest item is already fetched. |
415 //Handle attributes available,if the latest item is already fetched. |
537 //and for the content added for this collection,if it is not latest |
416 //and for the content added for this collection,if it is not latest |