mmappfw_plat/collection_helper_api/tsrc/CollectionHelperTestClass/src/CollectionHelperTestClassBlocks.cpp
branchRCL_3
changeset 42 4aca42fa4eb1
parent 17 780c925249c1
child 55 6c1dfe4da5dd
equal deleted inserted replaced
34:e257e2b6459d 42:4aca42fa4eb1
   786 TInt CCollectionHelperTestClass::GetSongAlbumArtistL(CStifItemParser& /*aItem*/)
   786 TInt CCollectionHelperTestClass::GetSongAlbumArtistL(CStifItemParser& /*aItem*/)
   787 {
   787 {
   788     FTRACE(FPrint(_L("CCollectionHelperTest::GetSongAlbumArtistL")));
   788     FTRACE(FPrint(_L("CCollectionHelperTest::GetSongAlbumArtistL")));
   789     TMPXGeneralCategory category = EMPXSong;
   789     TMPXGeneralCategory category = EMPXSong;
   790    // CMPXMedia* foundMedia= NULL;
   790    // CMPXMedia* foundMedia= NULL;
   791 
   791    TInt result(KErrNotFound);
   792    const CMPXMedia& foundMedia = iCachedHelper->GetL( KFileWmaSong(), category );
   792    const CMPXMedia& foundMedia = iCachedHelper->GetL( KFileWmaSong(), category );
   793 
   793 
   794     if (foundMedia.IsSupported(KMPXMediaMusicAlbumArtist))
   794     if (foundMedia.IsSupported(KMPXMediaMusicAlbumArtist))
   795         {
   795         {
   796         const TDesC& albumartist = foundMedia.ValueText( KMPXMediaMusicAlbumArtist );
   796         const TDesC& albumartist = foundMedia.ValueText( KMPXMediaMusicAlbumArtist );
       
   797         result = KErrNone;
   797 	    }
   798 	    }
   798    iLog->Log(_L("CCollectionHelperTestClass::GetSongAlbumArtistL done "));
   799    iLog->Log(_L("CCollectionHelperTestClass::GetSongAlbumArtistL done "));
   799 
   800 
   800    return 1;
   801    return result;
   801 }
   802 }
   802 
   803 
   803 
   804 
   804 
   805 
   805 //Update ABSTRACTALBUM.AlbumArtist
   806 //Update ABSTRACTALBUM.AlbumArtist
   846 TInt CCollectionHelperTestClass::GetAbstractAlbumArtistL(CStifItemParser& /*aItem*/)
   847 TInt CCollectionHelperTestClass::GetAbstractAlbumArtistL(CStifItemParser& /*aItem*/)
   847     {
   848     {
   848 	FTRACE(FPrint(_L("CCollectionHelperTest::GetAbstractAlbumArtistL")));
   849 	FTRACE(FPrint(_L("CCollectionHelperTest::GetAbstractAlbumArtistL")));
   849     TMPXGeneralCategory category = EMPXAbstractAlbum;
   850     TMPXGeneralCategory category = EMPXAbstractAlbum;
   850     const CMPXMedia& foundMedia = iCachedHelper->GetL( KAbstractalbum1(), category );   //wma test file
   851     const CMPXMedia& foundMedia = iCachedHelper->GetL( KAbstractalbum1(), category );   //wma test file
   851 
   852     TInt result(0);
   852 
   853 
   853     //print out foundMedia attributes
   854     //print out foundMedia attributes
   854     if (foundMedia.IsSupported(KMPXMediaMusicAlbumArtist))
   855     if (foundMedia.IsSupported(KMPXMediaMusicAlbumArtist))
   855         {
   856         {
   856 		iLog->Log(_L("CCollectionHelperTestClass::GetAbstractAlbumArtistL, ABSTRACTALBUM.AlbumArtist retrived"));
   857 		iLog->Log(_L("CCollectionHelperTestClass::GetAbstractAlbumArtistL, ABSTRACTALBUM.AlbumArtist retrived"));
   857 
   858 
   858 
   859 
   859         
   860         
   860 
   861 
   861          const TDesC& albumartist = foundMedia.ValueText( KMPXMediaMusicAlbumArtist );
   862          const TDesC& albumartist = foundMedia.ValueText( KMPXMediaMusicAlbumArtist );
   862 
   863          result++;
   863         }
   864         }
   864 
   865 
   865 		if (foundMedia.IsSupported(KMPXMediaGeneralTitle))
   866 		if (foundMedia.IsSupported(KMPXMediaGeneralTitle))
   866 		 {
   867 		 {
   867 
   868 
   869 			  //  HBufC* albumartist;
   870 			  //  HBufC* albumartist;
   870 			   //     albumartist = foundMedia.ValueText( KMPXMediaMusicAlbumArtist ).AllocLC(); // + data
   871 			   //     albumartist = foundMedia.ValueText( KMPXMediaMusicAlbumArtist ).AllocLC(); // + data
   871 				 const TDesC& name = foundMedia.ValueText( KMPXMediaGeneralTitle );
   872 				 const TDesC& name = foundMedia.ValueText( KMPXMediaGeneralTitle );
   872 				 iLog->Log(_L("CCollectionHelperTestClass::GetAbstractAlbumArtistL, ABSTRACTALBUM.name retrived"));
   873 				 iLog->Log(_L("CCollectionHelperTestClass::GetAbstractAlbumArtistL, ABSTRACTALBUM.name retrived"));
   873 				 
   874 				 
   874 	
   875 				 result++;
   875 
   876 
   876 		}
   877 		}
   877 		if (foundMedia.IsSupported(KMPXMediaGeneralUri))
   878 		if (foundMedia.IsSupported(KMPXMediaGeneralUri))
   878 			 {
   879 			 {
   879 
   880 
   880 			  
   881 			  
   881 				  //  HBufC* albumartist;
   882 				  //  HBufC* albumartist;
   882 				   //     albumartist = foundMedia.ValueText( KMPXMediaMusicAlbumArtist ).AllocLC(); // + data
   883 				   //     albumartist = foundMedia.ValueText( KMPXMediaMusicAlbumArtist ).AllocLC(); // + data
   883 		     const TDesC& uri = foundMedia.ValueText( KMPXMediaGeneralUri );
   884 		     const TDesC& uri = foundMedia.ValueText( KMPXMediaGeneralUri );
   884 			 iLog->Log(_L("CCollectionHelperTestClass::GetAbstractAlbumArtistL, ABSTRACTALBUM.uri retrived"));
   885 			 iLog->Log(_L("CCollectionHelperTestClass::GetAbstractAlbumArtistL, ABSTRACTALBUM.uri retrived"));
   885 					  
   886 			 result++;	  
   886 			}
   887 			}
   887 	iLog->Log(_L("CCollectionHelperTestClass::GetAbstractAlbumArtistL done"));
   888 	iLog->Log(_L("CCollectionHelperTestClass::GetAbstractAlbumArtistL done"));
   888 	return 1;
   889 	if(result == 3)
       
   890 		return KErrNone;
       
   891 	else
       
   892 	    return KErrNotFound;
   889 	}
   893 	}
   890 
   894 
   891 
   895 
   892 //Update ABSTRACTALBUM.Name
   896 //Update ABSTRACTALBUM.Name
   893 //Update Name field in Abstractalbum table
   897 //Update Name field in Abstractalbum table
   988    TInt foundItemCount = *foundMedia->Value<TInt>(KMPXMediaArrayCount);
   992    TInt foundItemCount = *foundMedia->Value<TInt>(KMPXMediaArrayCount);
   989    iLog->Log(_L("CCollectionHelperTestClass::GetAlbumAndSongsL, foundItemCount=%d"), foundItemCount );
   993    iLog->Log(_L("CCollectionHelperTestClass::GetAlbumAndSongsL, foundItemCount=%d"), foundItemCount );
   990 
   994 
   991    CMPXMediaArray* foundArray =
   995    CMPXMediaArray* foundArray =
   992        foundMedia->Value<CMPXMediaArray>(KMPXMediaArrayContents);
   996        foundMedia->Value<CMPXMediaArray>(KMPXMediaArrayContents);
   993    CleanupStack::PopAndDestroy(foundMedia);
   997    
   994 
   998 
   995    for (TInt j = 0; j < foundItemCount; ++j)
   999    for (TInt j = 0; j < foundItemCount; ++j)
   996         {
  1000         {
   997         CMPXMedia* abstractalbumMedia = CMPXMedia::NewL(*(*foundArray)[j]);
  1001         CMPXMedia* abstractalbumMedia = CMPXMedia::NewL(*(*foundArray)[j]);
   998         CleanupStack::PushL(abstractalbumMedia);
  1002         CleanupStack::PushL(abstractalbumMedia);
   999 
  1003 
  1000         //to print out founded media attributes
  1004         //to print out founded media attributes
  1001         if (abstractalbumMedia->IsSupported(KMPXMediaGeneralTitle))
  1005         if (abstractalbumMedia->IsSupported(KMPXMediaGeneralTitle))
  1002             {
  1006             {
  1003 	        const TDesC& name = abstractalbumMedia->ValueText( KMPXMediaGeneralTitle );
  1007 	        const TDesC& name = abstractalbumMedia->ValueText( KMPXMediaGeneralTitle );
  1004             iLog->Log(_L("CCollectionHelperTestClass::GetAlbumAndSongsL, found abstractalbumName = [%s]"), name );
  1008        //     iLog->Log(_L("CCollectionHelperTestClass::GetAlbumAndSongsL, found abstractalbumName = [%s]"), name );
  1005 	        }
  1009 	        }
  1006 
  1010 
  1007         if (abstractalbumMedia->IsSupported(KMPXMediaGeneralId))
  1011         if (abstractalbumMedia->IsSupported(KMPXMediaGeneralId))
  1008             {
  1012             {
  1009             abstractalbumId = abstractalbumMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
  1013             abstractalbumId = abstractalbumMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
  1034             *searchMediaSong, songAttributes.Array()));
  1038             *searchMediaSong, songAttributes.Array()));
  1035 
  1039 
  1036         CleanupStack::PopAndDestroy(&songAttributes);
  1040         CleanupStack::PopAndDestroy(&songAttributes);
  1037         CleanupStack::PopAndDestroy(searchMediaSong);
  1041         CleanupStack::PopAndDestroy(searchMediaSong);
  1038         CleanupStack::PopAndDestroy(abstractalbumMedia);
  1042         CleanupStack::PopAndDestroy(abstractalbumMedia);
       
  1043         CleanupStack::PopAndDestroy(foundMedia);
  1039 
  1044 
  1040         CleanupStack::PushL( foundSongs ); // + foundSongs
  1045         CleanupStack::PushL( foundSongs ); // + foundSongs
  1041         if ( err != KErrNone )
  1046         if ( err != KErrNone )
  1042             {
  1047             {
  1043             iLog->Log(_L("CCollectionHelperTestClass::GetAlbumAndSongsL, err = [%d]"), err );
  1048             iLog->Log(_L("CCollectionHelperTestClass::GetAlbumAndSongsL, err = [%d]"), err );
  1054         // Number of references
  1059         // Number of references
  1055         TInt numOfSongsRefs = *foundSongs->Value<TInt>(KMPXMediaArrayCount);
  1060         TInt numOfSongsRefs = *foundSongs->Value<TInt>(KMPXMediaArrayCount);
  1056         iLog->Log(_L("CCollectionHelperTestClass::GetAlbumAndSongsL, numOfSongsRefs=%d"), numOfSongsRefs );
  1061         iLog->Log(_L("CCollectionHelperTestClass::GetAlbumAndSongsL, numOfSongsRefs=%d"), numOfSongsRefs );
  1057         CleanupStack::PopAndDestroy( foundSongs ); // - foundSong
  1062         CleanupStack::PopAndDestroy( foundSongs ); // - foundSong
  1058     }
  1063     }
  1059    return 1;
  1064    return err;
  1060  }
  1065  }
  1061 
  1066 
  1062 
  1067 
  1063 //By calling CMPXCollectionCachedHelper API RenameL
  1068 //By calling CMPXCollectionCachedHelper API RenameL
  1064 //precondition on emulator:  c:\\data\\sounds\\digital\\1.wma
  1069 //precondition on emulator:  c:\\data\\sounds\\digital\\1.wma