192 // ----------------------------------------------------------------------------- |
192 // ----------------------------------------------------------------------------- |
193 CShwThumbnailLoader* CShwThumbnailLoader::NewL( |
193 CShwThumbnailLoader* CShwThumbnailLoader::NewL( |
194 MGlxMediaList& aMedialist, MShwThumbnailLoadObserver& aErrorHandler ) |
194 MGlxMediaList& aMedialist, MShwThumbnailLoadObserver& aErrorHandler ) |
195 { |
195 { |
196 TRACER("CShwThumbnailLoader::NewLs"); |
196 TRACER("CShwThumbnailLoader::NewLs"); |
197 GLX_LOG_INFO( "CShwThumbnailLoader::NewL" ); |
|
198 CShwThumbnailLoader* self = new( ELeave ) CShwThumbnailLoader; |
197 CShwThumbnailLoader* self = new( ELeave ) CShwThumbnailLoader; |
199 CleanupStack::PushL( self ); |
198 CleanupStack::PushL( self ); |
200 |
199 |
201 // 2nd phase >> |
200 // 2nd phase >> |
202 // create implementation |
201 // create implementation |
203 self->iImpl = |
202 self->iImpl = |
204 new( ELeave ) CShwThumbnailLoaderImpl( aMedialist, aErrorHandler ); |
203 new( ELeave ) CShwThumbnailLoaderImpl( aMedialist, aErrorHandler ); |
205 // call 2nd phase |
204 // call 2nd phase |
206 self->iImpl->ConstructL(); |
205 self->iImpl->ConstructL(); |
207 // << 2nd phase |
206 // << 2nd phase |
208 |
|
209 // pop the stack |
207 // pop the stack |
210 CleanupStack::Pop( self ); |
208 CleanupStack::Pop( self ); |
211 return self; |
209 return self; |
212 } |
210 } |
213 |
211 |
215 // Destructor |
213 // Destructor |
216 // ----------------------------------------------------------------------------- |
214 // ----------------------------------------------------------------------------- |
217 CShwThumbnailLoader::~CShwThumbnailLoader() |
215 CShwThumbnailLoader::~CShwThumbnailLoader() |
218 { |
216 { |
219 TRACER("CShwThumbnailLoader::~CShwThumbnailLoader"); |
217 TRACER("CShwThumbnailLoader::~CShwThumbnailLoader"); |
220 GLX_LOG_INFO( "CShwThumbnailLoader::~CShwThumbnailLoader" ); |
|
221 delete iImpl; |
218 delete iImpl; |
222 } |
219 } |
223 |
220 |
224 // ----------------------------------------------------------------------------- |
221 // ----------------------------------------------------------------------------- |
225 // LoadThumbnailAndNotifyL. |
222 // LoadThumbnailAndNotifyL. |
226 // ----------------------------------------------------------------------------- |
223 // ----------------------------------------------------------------------------- |
227 void CShwThumbnailLoader::LoadAndNotifyL( TInt aIndex, TSize aSize ) |
224 void CShwThumbnailLoader::LoadAndNotifyL( TInt aIndex, TSize aSize ) |
228 { |
225 { |
229 TRACER("CShwThumbnailLoader::LoadAndNotifyL"); |
226 TRACER("CShwThumbnailLoader::LoadAndNotifyL"); |
230 GLX_LOG_INFO( "CShwThumbnailLoader::LoadAndNotifyL" ); |
|
231 // forward |
227 // forward |
232 iImpl->LoadAndNotifyL( aIndex, aSize ); |
228 iImpl->LoadAndNotifyL( aIndex, aSize ); |
233 } |
229 } |
234 |
230 |
235 // ----------------------------------------------------------------------------- |
231 // ----------------------------------------------------------------------------- |
236 // Unload. |
232 // Unload. |
237 // ----------------------------------------------------------------------------- |
233 // ----------------------------------------------------------------------------- |
238 void CShwThumbnailLoader::Unload( TInt aIndex ) |
234 void CShwThumbnailLoader::Unload( TInt aIndex ) |
239 { |
235 { |
240 TRACER("CShwThumbnailLoader::Unload"); |
236 TRACER("CShwThumbnailLoader::Unload"); |
241 GLX_LOG_INFO( "CShwThumbnailLoader::Unload" ); |
|
242 // forward |
237 // forward |
243 iImpl->Unload( aIndex ); |
238 iImpl->Unload( aIndex ); |
244 } |
239 } |
245 |
240 |
246 // ----------------------------------------------------------------------------- |
241 // ----------------------------------------------------------------------------- |
247 // CShwThumbnailLoaderImpl::ImageSizeL. |
242 // CShwThumbnailLoaderImpl::ImageSizeL. |
248 // ----------------------------------------------------------------------------- |
243 // ----------------------------------------------------------------------------- |
249 TSize CShwThumbnailLoader::ImageSizeL( TInt aIndex ) |
244 TSize CShwThumbnailLoader::ImageSizeL( TInt aIndex ) |
250 { |
245 { |
251 TRACER("CShwThumbnailLoader::ImageSizeL"); |
246 TRACER("CShwThumbnailLoader::ImageSizeL"); |
252 GLX_LOG_INFO( "CShwThumbnailLoader::ImageSizeL" ); |
|
253 // forward |
247 // forward |
254 return iImpl->ImageSizeL( aIndex ); |
248 return iImpl->ImageSizeL( aIndex ); |
255 } |
249 } |
256 |
250 |
257 // ----------------------------------------------------------------------------- |
251 // ----------------------------------------------------------------------------- |
269 // CShwThumbnailLoaderImpl::Destructor. |
263 // CShwThumbnailLoaderImpl::Destructor. |
270 // ----------------------------------------------------------------------------- |
264 // ----------------------------------------------------------------------------- |
271 inline CShwThumbnailLoader::CShwThumbnailLoaderImpl::~CShwThumbnailLoaderImpl() |
265 inline CShwThumbnailLoader::CShwThumbnailLoaderImpl::~CShwThumbnailLoaderImpl() |
272 { |
266 { |
273 TRACER("CShwThumbnailLoader::CShwThumbnailLoaderImpl::~CShwThumbnailLoaderImpl()"); |
267 TRACER("CShwThumbnailLoader::CShwThumbnailLoaderImpl::~CShwThumbnailLoaderImpl()"); |
274 GLX_LOG_INFO( "CShwThumbnailLoaderImpl::~CShwThumbnailLoaderImpl" ); |
|
275 // delete asynch callbacks, delete also cancels them |
268 // delete asynch callbacks, delete also cancels them |
276 delete iCompletedCallBack; |
269 delete iCompletedCallBack; |
277 delete iErrorCallBack; |
270 delete iErrorCallBack; |
278 delete iErrorHandlerCallBack; |
271 delete iErrorHandlerCallBack; |
279 |
272 |
308 // CShwThumbnailLoaderImpl::ConstructL |
301 // CShwThumbnailLoaderImpl::ConstructL |
309 // ----------------------------------------------------------------------------- |
302 // ----------------------------------------------------------------------------- |
310 inline void CShwThumbnailLoader::CShwThumbnailLoaderImpl::ConstructL() |
303 inline void CShwThumbnailLoader::CShwThumbnailLoaderImpl::ConstructL() |
311 { |
304 { |
312 TRACER("CShwThumbnailLoader::CShwThumbnailLoaderImpl::ConstructL"); |
305 TRACER("CShwThumbnailLoader::CShwThumbnailLoaderImpl::ConstructL"); |
313 GLX_LOG_INFO( "CShwThumbnailLoader::CShwThumbnailLoaderImpl::ConstructL" ); |
|
314 // retrieve the size of images with own context |
306 // retrieve the size of images with own context |
315 AddSizeContextL(); |
307 AddSizeContextL(); |
316 |
308 |
317 // add us as media list observer |
309 // add us as media list observer |
318 iMedialist.AddMediaListObserverL( this ); |
310 iMedialist.AddMediaListObserverL( this ); |
388 // check whether a context already exists for this index |
380 // check whether a context already exists for this index |
389 CShwThumbnailContext* context = FindContext( aIndex ); |
381 CShwThumbnailContext* context = FindContext( aIndex ); |
390 if( !context ) |
382 if( !context ) |
391 { |
383 { |
392 // create new context for the index with the given size |
384 // create new context for the index with the given size |
393 context = CShwThumbnailContext::NewLC( aIndex, aSize ); |
385 context = CShwThumbnailContext::NewLC( aIndex, aSize, iMedialist ); |
394 iHighQualityContexts.AppendL( context ); |
386 iHighQualityContexts.AppendL( context ); |
395 CleanupStack::Pop( context ); |
387 CleanupStack::Pop( context ); |
396 // add the context to the medialist with priority |
388 // add the context to the medialist with priority |
397 iMedialist.AddContextL( |
389 iMedialist.AddContextL( |
398 context->Context(), KHighQualityContextPriority ); |
390 context->Context(), KHighQualityContextPriority ); |
479 // ----------------------------------------------------------------------------- |
471 // ----------------------------------------------------------------------------- |
480 void CShwThumbnailLoader::CShwThumbnailLoaderImpl::HandleItemRemovedL( |
472 void CShwThumbnailLoader::CShwThumbnailLoaderImpl::HandleItemRemovedL( |
481 TInt /*aStartIndex*/, TInt /*aEndIndex*/, MGlxMediaList* /*aList*/ ) |
473 TInt /*aStartIndex*/, TInt /*aEndIndex*/, MGlxMediaList* /*aList*/ ) |
482 { |
474 { |
483 TRACER("CShwThumbnailLoader::CShwThumbnailLoaderImpl::HandleItemRemovedL"); |
475 TRACER("CShwThumbnailLoader::CShwThumbnailLoaderImpl::HandleItemRemovedL"); |
484 GLX_LOG_INFO( "CShwThumbnailLoader::CShwThumbnailLoaderImpl::HandleItemRemovedL" ); |
|
485 // check if we still got some items to show |
476 // check if we still got some items to show |
486 if( iMedialist.Count() < 1 ) |
477 if( iMedialist.Count() < 1 ) |
487 { |
478 { |
488 // the media list is empty so call our error handler |
479 // the media list is empty so call our error handler |
489 iThumbnailObserver.HandleMediaListEmpty(); |
480 iThumbnailObserver.HandleMediaListEmpty(); |
504 void CShwThumbnailLoader::CShwThumbnailLoaderImpl::HandleAttributesAvailableL( |
495 void CShwThumbnailLoader::CShwThumbnailLoaderImpl::HandleAttributesAvailableL( |
505 TInt aItemIndex, const RArray<TMPXAttribute>& aAttributes/**/, |
496 TInt aItemIndex, const RArray<TMPXAttribute>& aAttributes/**/, |
506 MGlxMediaList* /*aList*/ ) |
497 MGlxMediaList* /*aList*/ ) |
507 { |
498 { |
508 TRACER("CShwThumbnailLoader::CShwThumbnailLoaderImpl::HandleAttributesAvailableL"); |
499 TRACER("CShwThumbnailLoader::CShwThumbnailLoaderImpl::HandleAttributesAvailableL"); |
509 GLX_LOG_INFO( "CShwThumbnailLoader::CShwThumbnailLoaderImpl::HandleAttributesAvailableL" ); |
|
510 //done to verify context availability |
500 //done to verify context availability |
511 TInt attributeCount = aAttributes.Count(); |
501 TInt attributeCount = aAttributes.Count(); |
512 for(TInt i = 0; i < attributeCount; i++ ) |
502 for(TInt i = 0; i < attributeCount; i++ ) |
513 { |
503 { |
514 TMPXAttribute attr = aAttributes[i]; |
504 TMPXAttribute attr = aAttributes[i]; |
678 // CShwThumbnailLoaderImpl::AddSizeContextL |
668 // CShwThumbnailLoaderImpl::AddSizeContextL |
679 // ----------------------------------------------------------------------------- |
669 // ----------------------------------------------------------------------------- |
680 inline void CShwThumbnailLoader::CShwThumbnailLoaderImpl::AddSizeContextL() |
670 inline void CShwThumbnailLoader::CShwThumbnailLoaderImpl::AddSizeContextL() |
681 { |
671 { |
682 TRACER("CShwThumbnailLoader::CShwThumbnailLoaderImpl::AddSizeContextL"); |
672 TRACER("CShwThumbnailLoader::CShwThumbnailLoaderImpl::AddSizeContextL"); |
683 GLX_LOG_INFO( "CShwThumbnailLoader::FindContext "); |
|
684 // Create the fetch context to retrieve the attribute |
673 // Create the fetch context to retrieve the attribute |
685 iSizeContext = CGlxDefaultAttributeContext::NewL(); |
674 iSizeContext = CGlxDefaultAttributeContext::NewL(); |
686 // Set the range offsets relative to the focus item |
675 // Set the range offsets relative to the focus item |
687 // e.g. 0, 1, [2], 3, 4. Focus @ 2 => frontOffset = 2, rearOffset = 2 |
676 // e.g. 0, 1, [2], 3, 4. Focus @ 2 => frontOffset = 2, rearOffset = 2 |
688 iSizeContext->SetRangeOffsets( KSizeContextOffset, KSizeContextOffset ); |
677 iSizeContext->SetRangeOffsets( KSizeContextOffset, KSizeContextOffset ); |
754 // CShwThumbnailLoaderImpl::CompletedNotifyL |
743 // CShwThumbnailLoaderImpl::CompletedNotifyL |
755 // ----------------------------------------------------------------------------- |
744 // ----------------------------------------------------------------------------- |
756 inline TInt CShwThumbnailLoader::CShwThumbnailLoaderImpl::CompletedNotifyL() |
745 inline TInt CShwThumbnailLoader::CShwThumbnailLoaderImpl::CompletedNotifyL() |
757 { |
746 { |
758 TRACER("CShwThumbnailLoader::CShwThumbnailLoaderImpl::CompletedNotifyL"); |
747 TRACER("CShwThumbnailLoader::CShwThumbnailLoaderImpl::CompletedNotifyL"); |
759 GLX_LOG_INFO( "CShwThumbnailLoader::CompletedNotifyL" ); |
|
760 // then we need to also remove all notifications for the given index |
748 // then we need to also remove all notifications for the given index |
761 TInt count = iCompletedIndexes.Count(); |
749 TInt count = iCompletedIndexes.Count(); |
762 while( count-- > 0 ) |
750 while( count-- > 0 ) |
763 { |
751 { |
764 // take the index |
752 // take the index |
777 // CShwThumbnailLoaderImpl::ErrorNotifyL |
765 // CShwThumbnailLoaderImpl::ErrorNotifyL |
778 // ----------------------------------------------------------------------------- |
766 // ----------------------------------------------------------------------------- |
779 inline TInt CShwThumbnailLoader::CShwThumbnailLoaderImpl::ErrorNotifyL() |
767 inline TInt CShwThumbnailLoader::CShwThumbnailLoaderImpl::ErrorNotifyL() |
780 { |
768 { |
781 TRACER("CShwThumbnailLoader::CShwThumbnailLoaderImpl::ErrorNotifyL"); |
769 TRACER("CShwThumbnailLoader::CShwThumbnailLoaderImpl::ErrorNotifyL"); |
782 GLX_LOG_INFO( "CShwThumbnailLoader::ErrorNotifyL" ); |
|
783 // then we need to also remove all notifications for the given index |
770 // then we need to also remove all notifications for the given index |
784 TInt count = iErrorIndexes.Count(); |
771 TInt count = iErrorIndexes.Count(); |
785 while( count-- > 0 ) |
772 while( count-- > 0 ) |
786 { |
773 { |
787 // take the index |
774 // take the index |
803 // CShwThumbnailLoaderImpl::AsyncErrorHandleL |
790 // CShwThumbnailLoaderImpl::AsyncErrorHandleL |
804 // ----------------------------------------------------------------------------- |
791 // ----------------------------------------------------------------------------- |
805 inline TInt CShwThumbnailLoader::CShwThumbnailLoaderImpl::AsyncErrorHandleL() |
792 inline TInt CShwThumbnailLoader::CShwThumbnailLoaderImpl::AsyncErrorHandleL() |
806 { |
793 { |
807 TRACER("CShwThumbnailLoader::CShwThumbnailLoaderImpl::AsyncErrorHandleL"); |
794 TRACER("CShwThumbnailLoader::CShwThumbnailLoaderImpl::AsyncErrorHandleL"); |
808 GLX_LOG_INFO( "CShwThumbnailLoader::AsyncErrorHandleL" ); |
|
809 // handle the error |
795 // handle the error |
810 DoHandleErrorL(); |
796 DoHandleErrorL(); |
811 // need to return value to please TCallBack API |
797 // need to return value to please TCallBack API |
812 return KErrNone; |
798 return KErrNone; |
813 } |
799 } |