23 #include <mpxmedia.h> |
23 #include <mpxmedia.h> |
24 #include <mpxmediaarray.h> |
24 #include <mpxmediaarray.h> |
25 #include <mpxcollectionutility.h> |
25 #include <mpxcollectionutility.h> |
26 #include <mpxharvesterutility.h> |
26 #include <mpxharvesterutility.h> |
27 #include <mpxmediageneraldefs.h> |
27 #include <mpxmediageneraldefs.h> |
|
28 #include <mpxmediamusicdefs.h> |
28 #include <mpxmediacontainerdefs.h> |
29 #include <mpxmediacontainerdefs.h> |
29 #include <mpxuser.h> |
30 #include <mpxuser.h> |
30 #include <mpxcollectionplugin.hrh> |
31 #include <mpxcollectionplugin.hrh> |
31 #include <mpxcommandgeneraldefs.h> |
32 #include <mpxcommandgeneraldefs.h> |
32 #include <mpxcollectioncommanddefs.h> |
33 #include <mpxcollectioncommanddefs.h> |
43 // --------------------------------------------------------------------------- |
44 // --------------------------------------------------------------------------- |
44 // Constructor |
45 // Constructor |
45 // --------------------------------------------------------------------------- |
46 // --------------------------------------------------------------------------- |
46 // |
47 // |
47 CMPXCollectionHelperImp::CMPXCollectionHelperImp() |
48 CMPXCollectionHelperImp::CMPXCollectionHelperImp() |
|
49 : iTNManager(NULL) |
48 { |
50 { |
49 } |
51 } |
50 |
52 |
51 |
53 |
52 // --------------------------------------------------------------------------- |
54 // --------------------------------------------------------------------------- |
57 { |
59 { |
58 iHvsUtility = CMPXHarvesterFactory::NewL(); |
60 iHvsUtility = CMPXHarvesterFactory::NewL(); |
59 iCollectionUtil = MMPXCollectionUtility::NewL(); |
61 iCollectionUtil = MMPXCollectionUtility::NewL(); |
60 iMediator = CMPXCollectionMediator::NewL( iCollectionUtil->Collection(), |
62 iMediator = CMPXCollectionMediator::NewL( iCollectionUtil->Collection(), |
61 this ); |
63 this ); |
62 |
64 |
63 RArray<TUid> ary; |
65 RArray<TUid> ary; |
64 CleanupClosePushL( ary ); |
66 CleanupClosePushL( ary ); |
65 ary.AppendL( TUid::Uid(EMPXCollectionPluginMusic) ); |
67 ary.AppendL( TUid::Uid(EMPXCollectionPluginMusic) ); |
66 iMusicCollectionId = iCollectionUtil->CollectionIDL( ary.Array() ); |
68 iMusicCollectionId = iCollectionUtil->CollectionIDL( ary.Array() ); |
67 CleanupStack::PopAndDestroy( &ary ); |
69 CleanupStack::PopAndDestroy( &ary ); |
414 |
418 |
415 // find the media using the old URI |
419 // find the media using the old URI |
416 RArray<TMPXAttribute> attributes; |
420 RArray<TMPXAttribute> attributes; |
417 CleanupClosePushL( attributes ); |
421 CleanupClosePushL( attributes ); |
418 attributes.AppendL(KMPXMediaGeneralId); |
422 attributes.AppendL(KMPXMediaGeneralId); |
|
423 attributes.AppendL(KMPXMediaMusicAlbumArtFileName); |
419 |
424 |
420 CMPXMedia* media = GetL(aOldUri, attributes.Array(), aItemCat); |
425 CMPXMedia* media = GetL(aOldUri, attributes.Array(), aItemCat); |
421 CleanupStack::PopAndDestroy(&attributes); |
426 CleanupStack::PopAndDestroy(&attributes); |
422 CleanupStack::PushL(media); |
427 CleanupStack::PushL(media); |
|
428 |
|
429 const TDesC& fileName(media->ValueText(KMPXMediaMusicAlbumArtFileName)); |
|
430 |
|
431 // the songs have embedded albumart. |
|
432 if(fileName.CompareF(aOldUri) == 0) |
|
433 { |
|
434 // change the Art filename to the new Uri |
|
435 media->SetTextValueL(KMPXMediaMusicAlbumArtFileName, aNewUri); |
|
436 |
|
437 // Rename the thumbnail |
|
438 TRAPD(err, RenameThumbnailL(aOldUri, aNewUri)); |
|
439 if(KErrNone != err) |
|
440 { |
|
441 MPX_DEBUG2("Thumbnail renames failed. Err: %d", err); |
|
442 } |
|
443 } |
423 |
444 |
424 // change file path to the new file path |
445 // change file path to the new file path |
425 media->SetTextValueL(KMPXMediaGeneralUri, aNewUri); |
446 media->SetTextValueL(KMPXMediaGeneralUri, aNewUri); |
426 |
447 |
427 // ask harvester to rename the file if any of the following is true: |
448 // ask harvester to rename the file if any of the following is true: |
526 } |
547 } |
527 } |
548 } |
528 |
549 |
529 CMPXMedia* foundMedia(NULL); |
550 CMPXMedia* foundMedia(NULL); |
530 |
551 |
531 switch ( ary && ary->Count() ) //lint !e961 |
552 if ( ary && ary->Count() ) |
532 { |
553 { |
533 case 0: |
554 foundMedia = CMPXMedia::NewL(*ary->AtL(0)); |
534 User::Leave(KErrNotFound); |
555 CleanupStack::PushL(foundMedia); |
535 case 1: |
556 foundMedia->SetTObjectValueL<TUid>( KMPXMediaGeneralCollectionId, TUid::Uid(col) ); |
536 { |
557 CleanupStack::Pop(foundMedia); |
537 foundMedia = CMPXMedia::NewL(*ary->AtL(0)); |
558 } |
538 CleanupStack::PushL(foundMedia); |
559 else |
539 foundMedia->SetTObjectValueL<TUid>( |
560 { |
540 KMPXMediaGeneralCollectionId, TUid::Uid(col) ); |
561 User::Leave(KErrNotFound); |
541 CleanupStack::Pop(foundMedia); |
562 } |
542 break; |
563 |
543 } |
|
544 default: |
|
545 User::Leave(KErrCorrupt); |
|
546 } |
|
547 |
|
548 CleanupStack::PopAndDestroy(result); |
564 CleanupStack::PopAndDestroy(result); |
549 |
|
550 return foundMedia; |
565 return foundMedia; |
551 } |
566 } |
552 |
567 |
553 // --------------------------------------------------------------------------- |
568 // --------------------------------------------------------------------------- |
554 // Gets the attributes of some media object |
569 // Gets the attributes of some media object |
733 void CMPXCollectionHelperImp::Close() |
748 void CMPXCollectionHelperImp::Close() |
734 { |
749 { |
735 delete this; |
750 delete this; |
736 } |
751 } |
737 |
752 |
|
753 // --------------------------------------------------------------------------- |
|
754 // Rename the thumbnail through TNM |
|
755 // --------------------------------------------------------------------------- |
|
756 // |
|
757 void CMPXCollectionHelperImp::RenameThumbnailL( const TDesC& aOldUri, |
|
758 const TDesC& aNewUri ) |
|
759 { |
|
760 MPX_FUNC("CMPXCollectionHelperImp::RenameThumbnailL"); |
|
761 |
|
762 // Create Thumbnail Manager instance when use first time. |
|
763 if(NULL == iTNManager) |
|
764 { |
|
765 iTNManager = CThumbnailManager::NewL( *this ); |
|
766 } |
|
767 |
|
768 // Rename thumbnail |
|
769 iTNManager->RenameThumbnailsL(aOldUri, aNewUri, 0); |
|
770 } |
|
771 |
|
772 // --------------------------------------------------------------------------- |
|
773 // CMPXDbAbstractAlbum::ThumbnailReady |
|
774 // Callback but not used here |
|
775 // --------------------------------------------------------------------------- |
|
776 void CMPXCollectionHelperImp::ThumbnailPreviewReady( |
|
777 MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ ) |
|
778 { |
|
779 } |
|
780 |
|
781 |
|
782 // --------------------------------------------------------------------------- |
|
783 // CMPXDbAbstractAlbum::ThumbnailReady |
|
784 // Callback but not used here |
|
785 // --------------------------------------------------------------------------- |
|
786 void CMPXCollectionHelperImp::ThumbnailReady( TInt /*aError*/, |
|
787 MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ ) |
|
788 { |
|
789 } |
738 // End of file |
790 // End of file |