mmappcomponents/collectionhelper/src/mpxcollectionhelperimp.cpp
branchRCL_3
changeset 23 e42293e811d8
parent 13 4740b34b83ce
child 24 6c1dfe4da5dd
equal deleted inserted replaced
22:b034b1c214c2 23:e42293e811d8
    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 );
   109     if( iCollectionUtil )
   111     if( iCollectionUtil )
   110         {
   112         {
   111         iCollectionUtil->Close();
   113         iCollectionUtil->Close();
   112         }
   114         }
   113     delete iMediator;
   115     delete iMediator;
       
   116     
       
   117     delete iTNManager;
   114     }
   118     }
   115 
   119 
   116 
   120 
   117 // ---------------------------------------------------------------------------
   121 // ---------------------------------------------------------------------------
   118 // Issue collection initialization command to collection framework.
   122 // Issue collection initialization command to collection framework.
   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:
   733 void CMPXCollectionHelperImp::Close()
   754 void CMPXCollectionHelperImp::Close()
   734     {
   755     {
   735     delete this;
   756     delete this;
   736     }
   757     }
   737 
   758 
       
   759 // ---------------------------------------------------------------------------
       
   760 // Rename the thumbnail through TNM
       
   761 // ---------------------------------------------------------------------------
       
   762 //
       
   763 void CMPXCollectionHelperImp::RenameThumbnailL( const TDesC& aOldUri, 
       
   764                                          const TDesC& aNewUri )
       
   765     {
       
   766     MPX_FUNC("CMPXCollectionHelperImp::RenameThumbnailL");
       
   767     
       
   768     // Create Thumbnail Manager instance when use first time.
       
   769     if(NULL == iTNManager)
       
   770         {      
       
   771         iTNManager = CThumbnailManager::NewL( *this ); 
       
   772         }
       
   773     
       
   774     // Rename thumbnail
       
   775     iTNManager->RenameThumbnailsL(aOldUri, aNewUri, 0);
       
   776     }
       
   777 
       
   778 // ---------------------------------------------------------------------------
       
   779 // CMPXDbAbstractAlbum::ThumbnailReady
       
   780 // Callback but not used here
       
   781 // ---------------------------------------------------------------------------
       
   782 void CMPXCollectionHelperImp::ThumbnailPreviewReady(
       
   783         MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ )
       
   784     {
       
   785     }
       
   786 
       
   787 
       
   788 // ---------------------------------------------------------------------------
       
   789 // CMPXDbAbstractAlbum::ThumbnailReady
       
   790 // Callback but not used here
       
   791 // ---------------------------------------------------------------------------
       
   792 void CMPXCollectionHelperImp::ThumbnailReady( TInt /*aError*/,
       
   793         MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ )
       
   794     {
       
   795     }
   738 // End of file
   796 // End of file