diff -r d141fc1ad77b -r e61a04404bdf mmappcomponents/collectionhelper/src/mpxcollectionhelperimp.cpp --- a/mmappcomponents/collectionhelper/src/mpxcollectionhelperimp.cpp Tue Jul 06 14:48:59 2010 +0300 +++ b/mmappcomponents/collectionhelper/src/mpxcollectionhelperimp.cpp Wed Aug 18 10:16:02 2010 +0300 @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,7 @@ // --------------------------------------------------------------------------- // CMPXCollectionHelperImp::CMPXCollectionHelperImp() + : iTNManager(NULL) { } @@ -59,7 +61,7 @@ iCollectionUtil = MMPXCollectionUtility::NewL(); iMediator = CMPXCollectionMediator::NewL( iCollectionUtil->Collection(), this ); - + RArray ary; CleanupClosePushL( ary ); ary.AppendL( TUid::Uid(EMPXCollectionPluginMusic) ); @@ -111,6 +113,8 @@ iCollectionUtil->Close(); } delete iMediator; + + delete iTNManager; } @@ -416,11 +420,28 @@ RArray attributes; CleanupClosePushL( attributes ); attributes.AppendL(KMPXMediaGeneralId); + attributes.AppendL(KMPXMediaMusicAlbumArtFileName); CMPXMedia* media = GetL(aOldUri, attributes.Array(), aItemCat); CleanupStack::PopAndDestroy(&attributes); CleanupStack::PushL(media); + const TDesC& fileName(media->ValueText(KMPXMediaMusicAlbumArtFileName)); + + // the songs have embedded albumart. + if(fileName.CompareF(aOldUri) == 0) + { + // change the Art filename to the new Uri + media->SetTextValueL(KMPXMediaMusicAlbumArtFileName, aNewUri); + + // Rename the thumbnail + TRAPD(err, RenameThumbnailL(aOldUri, aNewUri)); + if(KErrNone != err) + { + MPX_DEBUG2("Thumbnail renames failed. Err: %d", err); + } + } + // change file path to the new file path media->SetTextValueL(KMPXMediaGeneralUri, aNewUri); @@ -528,25 +549,19 @@ CMPXMedia* foundMedia(NULL); - switch ( ary && ary->Count() ) //lint !e961 + if ( ary && ary->Count() ) { - case 0: - User::Leave(KErrNotFound); - case 1: - { - foundMedia = CMPXMedia::NewL(*ary->AtL(0)); - CleanupStack::PushL(foundMedia); - foundMedia->SetTObjectValueL( - KMPXMediaGeneralCollectionId, TUid::Uid(col) ); - CleanupStack::Pop(foundMedia); - break; - } - default: - User::Leave(KErrCorrupt); + foundMedia = CMPXMedia::NewL(*ary->AtL(0)); + CleanupStack::PushL(foundMedia); + foundMedia->SetTObjectValueL( KMPXMediaGeneralCollectionId, TUid::Uid(col) ); + CleanupStack::Pop(foundMedia); } - + else + { + User::Leave(KErrNotFound); + } + CleanupStack::PopAndDestroy(result); - return foundMedia; } @@ -735,4 +750,41 @@ delete this; } +// --------------------------------------------------------------------------- +// Rename the thumbnail through TNM +// --------------------------------------------------------------------------- +// +void CMPXCollectionHelperImp::RenameThumbnailL( const TDesC& aOldUri, + const TDesC& aNewUri ) + { + MPX_FUNC("CMPXCollectionHelperImp::RenameThumbnailL"); + + // Create Thumbnail Manager instance when use first time. + if(NULL == iTNManager) + { + iTNManager = CThumbnailManager::NewL( *this ); + } + + // Rename thumbnail + iTNManager->RenameThumbnailsL(aOldUri, aNewUri, 0); + } + +// --------------------------------------------------------------------------- +// CMPXDbAbstractAlbum::ThumbnailReady +// Callback but not used here +// --------------------------------------------------------------------------- +void CMPXCollectionHelperImp::ThumbnailPreviewReady( + MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ ) + { + } + + +// --------------------------------------------------------------------------- +// CMPXDbAbstractAlbum::ThumbnailReady +// Callback but not used here +// --------------------------------------------------------------------------- +void CMPXCollectionHelperImp::ThumbnailReady( TInt /*aError*/, + MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ ) + { + } // End of file