mpxmusicplayer/commonui/src/mpxalbumartutil.cpp
changeset 2 b70d77332e66
parent 0 ff3acec5bc43
child 4 beaa16f65879
equal deleted inserted replaced
1:8118492f1bdf 2:b70d77332e66
    62 //
    62 //
    63 EXPORT_C CMPXAlbumArtUtil::~CMPXAlbumArtUtil()
    63 EXPORT_C CMPXAlbumArtUtil::~CMPXAlbumArtUtil()
    64     {
    64     {
    65     if (iArtUtil)
    65     if (iArtUtil)
    66         {
    66         {
       
    67 		iArtUtil->CancelRequest();
    67         delete iArtUtil;
    68         delete iArtUtil;
    68         }
    69         }
    69     if(iFilename)
    70     if(iFilename)
    70         {   
    71         {   
    71         delete iFilename;
    72         delete iFilename;
   119                                             const TSize& aSize,
   120                                             const TSize& aSize,
   120                                             TDisplayMode aDisplayMode /*= EColor64K*/)
   121                                             TDisplayMode aDisplayMode /*= EColor64K*/)
   121     {
   122     {
   122     MPX_DEBUG1("CMPXAlbumArtUtil::ExtractAlbumArtL(): Entering");
   123     MPX_DEBUG1("CMPXAlbumArtUtil::ExtractAlbumArtL(): Entering");
   123     MPX_DEBUG_THREAD("CMPXAlbumArtUtil::ExtractAlbumArtL()");
   124     MPX_DEBUG_THREAD("CMPXAlbumArtUtil::ExtractAlbumArtL()");
   124     delete iArtUtil;
   125     if(iFilename)
   125     iArtUtil = NULL;
   126         {  
       
   127         delete iFilename;
       
   128         iFilename = NULL;
       
   129         } 
       
   130     if ( iArtUtil )
       
   131         {
       
   132         delete iArtUtil;
       
   133         iArtUtil = NULL;
       
   134         }
   126     iArtUtil = CMPXImageUtil::NewL(aObs);
   135     iArtUtil = CMPXImageUtil::NewL(aObs);
   127     iDisplayMode = aDisplayMode;
   136     iDisplayMode = aDisplayMode;
   128     iImageSize = aSize;
   137     iImageSize = aSize;
   129     iObserver = &aObs;
   138     iObserver = &aObs;
   130     
   139     
   131     if (aMedia.IsSupported( KMPXMediaMusicAlbumArtFileName ))
   140     if (aMedia.IsSupported( KMPXMediaMusicAlbumArtFileName ))
   132         {
   141         {
   133         if ( aMedia.ValueText( KMPXMediaMusicAlbumArtFileName ).Length() == 0)
   142         if ( aMedia.ValueText( KMPXMediaMusicAlbumArtFileName ).Length() == 0)
   134             {
   143             {
       
   144             iReqId = 0;  
   135             User::Leave( KErrNotFound );
   145             User::Leave( KErrNotFound );
   136             }
   146             }
   137         }
   147         }
   138 
   148 
   139     if ( aMedia.IsSupported( KMPXMediaGeneralUri ) &&
   149     if ( aMedia.IsSupported( KMPXMediaGeneralUri ) &&
   140          aMedia.IsSupported( KMPXMediaMusicAlbumArtFileName ))
   150          aMedia.IsSupported( KMPXMediaMusicAlbumArtFileName ))
   141         {
   151         {
   142         delete iFilename;
       
   143         iFilename = NULL;
       
   144         iFilename = aMedia.ValueText( KMPXMediaMusicAlbumArtFileName ).AllocL();
   152         iFilename = aMedia.ValueText( KMPXMediaMusicAlbumArtFileName ).AllocL();
   145         if(aSize == iFullScreenImageSize)
   153         if(aSize == iFullScreenImageSize)
   146             {
   154             {
   147             iThumbnailManager->SetThumbnailSizeL(EAudioFullScreenThumbnailSize);
   155             iThumbnailManager->SetThumbnailSizeL(EAudioFullScreenThumbnailSize);
   148             }
   156             }
   171     {
   179     {
   172     MPX_DEBUG1("CMPXAlbumArtUtil::CancelRequest(): Entering");
   180     MPX_DEBUG1("CMPXAlbumArtUtil::CancelRequest(): Entering");
   173     if ( iArtUtil )
   181     if ( iArtUtil )
   174         {
   182         {
   175         iArtUtil->CancelRequest();
   183         iArtUtil->CancelRequest();
       
   184         delete iArtUtil;
       
   185         iArtUtil = 0;
       
   186         }
       
   187 	if ( iThumbnailManager && iReqId > 0 )
       
   188         {
       
   189          iThumbnailManager->CancelRequest(iReqId);
   176         }
   190         }
   177     iReqId = 0;
   191     iReqId = 0;
   178     MPX_DEBUG1("CMPXAlbumArtUtil::CancelRequest(): Exiting");
   192     MPX_DEBUG1("CMPXAlbumArtUtil::CancelRequest(): Exiting");
   179     }
   193     }
   180 
   194 
   201         const CMetaDataFieldContainer& metaCont =
   215         const CMetaDataFieldContainer& metaCont =
   202                                         metaDataUtil->MetaDataFieldsL();
   216                                         metaDataUtil->MetaDataFieldsL();
   203         TPtrC data = metaCont.Field( aFieldId );
   217         TPtrC data = metaCont.Field( aFieldId );
   204         if(data.Length()==0)
   218         if(data.Length()==0)
   205             {
   219             {
   206             iObserver->ExtractAlbumArtCompleted( NULL, KErrNotFound );            
   220             User::Leave( KErrNotFound );          
   207             }
   221             }
   208         ret = MPXUser::Alloc8L(data);
   222         ret = MPXUser::Alloc8L(data);
   209 
   223 
   210         CleanupStack::PopAndDestroy(&wantedFields);
   224         CleanupStack::PopAndDestroy(&wantedFields);
   211         CleanupStack::PopAndDestroy(metaDataUtil);
   225         CleanupStack::PopAndDestroy(metaDataUtil);
   256             else
   270             else
   257                 {
   271                 {
   258                 delete tempBitmap;
   272                 delete tempBitmap;
   259                 } 
   273                 } 
   260             }
   274             }
   261         else
   275         else if(iReqId == aId)
   262             {
   276             {
   263             iObserver->ExtractAlbumArtCompleted( NULL, KErrNotFound );
   277             iObserver->ExtractAlbumArtCompleted( NULL, KErrNotFound );
   264             }
   278             }
   265         } 	
   279         } 	
   266     else
   280     else if (iArtUtil && iFilename)
   267         {
   281         {
   268         TRAPD( err,
   282         TRAPD( err,
   269             HBufC8* art( ExtractBinaryMetaDataLC(iFilename->Des(),EMetaDataJpeg ));
   283             HBufC8* art( ExtractBinaryMetaDataLC(iFilename->Des(),EMetaDataJpeg ));
   270             CleanupStack::Pop(art);
   284             CleanupStack::Pop(art);
   271             iArtUtil->StartToDecodeL(iImageSize, art, iDisplayMode) );
   285             iArtUtil->StartToDecodeL(iImageSize, art, iDisplayMode) );
   274             {
   288             {
   275             iObserver->ExtractAlbumArtCompleted( NULL, KErrNotFound );
   289             iObserver->ExtractAlbumArtCompleted( NULL, KErrNotFound );
   276             }  
   290             }  
   277         } 
   291         } 
   278 
   292 
       
   293     iReqId = 0;
   279     }
   294     }
   280 
   295 
   281 // -----------------------------------------------------------------------------
   296 // -----------------------------------------------------------------------------
   282 //     Extract Thumbnail for the current song
   297 //     Extract Thumbnail for the current song
   283 // -----------------------------------------------------------------------------
   298 // -----------------------------------------------------------------------------
   300 #endif
   315 #endif
   301         if (album.Compare( KNullDesC) != 0 )
   316         if (album.Compare( KNullDesC) != 0 )
   302             {
   317             {
   303             CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC( album, KMPXAlbumMimeType );
   318             CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC( album, KMPXAlbumMimeType );
   304             TInt ret = NULL;
   319             TInt ret = NULL;
       
   320             if(iThumbnailManager && iReqId >0)
       
   321                 {
       
   322                 iThumbnailManager->CancelRequest( iReqId );
       
   323                 }   
   305             TRAPD(err, iReqId = TInt (iThumbnailManager->GetThumbnailL( *source, (TAny*)ret)));
   324             TRAPD(err, iReqId = TInt (iThumbnailManager->GetThumbnailL( *source, (TAny*)ret)));
   306             if( err != KErrNone)
   325             if( err != KErrNone)
   307                 {
   326                 {
   308                 User::Leave( KErrNotFound );
   327                 User::Leave( KErrNotFound );
   309                 }  
   328                 }