41 |
41 |
42 #include "mpxcollectioncachedhelper.h" |
42 #include "mpxcollectioncachedhelper.h" |
43 #include "mpxcollectionhelpercommon.h" |
43 #include "mpxcollectionhelpercommon.h" |
44 #include <mpxmetadataextractor.h> |
44 #include <mpxmetadataextractor.h> |
45 |
45 |
|
46 #include <MetaDataUtility.h> // for SetMissingMetadataL |
|
47 #include <MetaDataFieldContainer.h> // for SetMissingMetadataL |
|
48 |
46 // CONSTANTS |
49 // CONSTANTS |
47 const TInt KCacheCount = 10; |
50 const TInt KCacheCount = 10; |
|
51 |
|
52 _LIT( K3GPFileExt, ".3gp" ); |
|
53 _LIT( K3G2FileExt, ".3g2" ); |
|
54 _LIT( KODFFileExt, ".odf" ); |
|
55 _LIT( KO4AFileExt, ".o4a" ); |
48 |
56 |
49 // ======== MEMBER FUNCTIONS ======== |
57 // ======== MEMBER FUNCTIONS ======== |
50 |
58 |
51 // --------------------------------------------------------------------------- |
59 // --------------------------------------------------------------------------- |
52 // Constructor |
60 // Constructor |
1186 { |
1197 { |
1187 TUint16 val = aSrc.ValueTObjectL<TUint16>(KMPXMediaMTPDrmStatus); |
1198 TUint16 val = aSrc.ValueTObjectL<TUint16>(KMPXMediaMTPDrmStatus); |
1188 aDestination.SetTObjectValueL( KMPXMediaMTPDrmStatus, val ); |
1199 aDestination.SetTObjectValueL( KMPXMediaMTPDrmStatus, val ); |
1189 } |
1200 } |
1190 } |
1201 } |
|
1202 |
|
1203 // --------------------------------------------------------------------------- |
|
1204 // Attempt to set missing Metadata info in specific case |
|
1205 // --------------------------------------------------------------------------- |
|
1206 // |
|
1207 void CMPXCollectionCachedHelper::SetMissingMetadataL(CMPXMedia* aMedia) |
|
1208 { |
|
1209 MPX_FUNC("CMPXCollectionCachedHelper::SetMissingMetadataL"); |
|
1210 |
|
1211 const TDesC& path = aMedia->ValueText(KMPXMediaGeneralUri); |
|
1212 TParsePtrC parse( path ); |
|
1213 |
|
1214 // only do this for file that might not be natively supported by PC |
|
1215 if ( ( parse.Ext().CompareF(K3GPFileExt) == 0 ) |
|
1216 || ( parse.Ext().CompareF(K3G2FileExt) == 0 ) |
|
1217 || ( parse.Ext().CompareF(KODFFileExt) == 0 ) |
|
1218 || ( parse.Ext().CompareF(KO4AFileExt) == 0 ) ) |
|
1219 { |
|
1220 TBool isTitleMissing = EFalse; |
|
1221 TBool isArtistMissing = EFalse; |
|
1222 TBool isAlbumMissing = EFalse; |
|
1223 |
|
1224 if ( aMedia->ValueText( KMPXMediaGeneralTitle ).Length() == 0 ) |
|
1225 isTitleMissing = ETrue; |
|
1226 |
|
1227 if ( aMedia->ValueText( KMPXMediaMusicArtist ).Length() == 0 ) |
|
1228 isArtistMissing = ETrue; |
|
1229 |
|
1230 if ( aMedia->ValueText( KMPXMediaMusicAlbum ).Length() == 0 ) |
|
1231 isAlbumMissing = ETrue; |
|
1232 |
|
1233 MPX_DEBUG4("CMPXCollectionCachedHelper::SetMissingMetadataL, isTitleMissing = %d, isArtistMissing = %d, isAlbumMissing = %d", isTitleMissing, isArtistMissing, isAlbumMissing); |
|
1234 |
|
1235 // only do this if one of the following is missing: |
|
1236 // - Title |
|
1237 // - Artist |
|
1238 // - Album |
|
1239 // but can easily be extended to support any category field like: composer, genre |
|
1240 if ( isTitleMissing || isArtistMissing || isAlbumMissing ) |
|
1241 { |
|
1242 // metadataextractor should be used instead, but not until CreateMediaL can be called without add/TN of the embedded art |
|
1243 // CR is needed to add parameter (TBool aAlbumArtNeeded = ETrue) // ETrue by default, for all existing caller |
|
1244 // for now use MDU instead |
|
1245 CMetaDataUtility* metadataUtility = CMetaDataUtility::NewL(); |
|
1246 |
|
1247 CleanupStack::PushL( metadataUtility ); |
|
1248 metadataUtility->OpenFileL( path ); |
|
1249 |
|
1250 MPX_DEBUG1( "CMPXCollectionCachedHelper::SetMissingMetadataL, CMetaDataUtility::OpenFileL succeed" ); |
|
1251 |
|
1252 const CMetaDataFieldContainer& metaCont = metadataUtility->MetaDataFieldsL(); |
|
1253 |
|
1254 for ( TInt i = 0; i < metaCont.Count(); i++ ) |
|
1255 { |
|
1256 TMetaDataFieldId fieldType; |
|
1257 TMPXAttributeData attribute; |
|
1258 |
|
1259 metaCont.FieldIdAt( i, fieldType ); // get the field type |
|
1260 |
|
1261 switch ( fieldType ) |
|
1262 { |
|
1263 case EMetaDataSongTitle: // fall through |
|
1264 case EMetaDataArtist: // fall through |
|
1265 case EMetaDataAlbum: |
|
1266 { |
|
1267 if ( ( isTitleMissing && ( fieldType == EMetaDataSongTitle ) ) |
|
1268 || ( isArtistMissing && ( fieldType == EMetaDataArtist ) ) |
|
1269 || ( isAlbumMissing && ( fieldType == EMetaDataAlbum ) ) ) |
|
1270 { |
|
1271 HBufC* value = metaCont.At( i, fieldType ).AllocL(); |
|
1272 CleanupStack::PushL( value ); |
|
1273 |
|
1274 TPtr valptr = value->Des(); |
|
1275 valptr.Trim(); |
|
1276 |
|
1277 // replace '\t' as ' ' |
|
1278 for ( TInt i = 0; i < value->Length(); i++ ) |
|
1279 { |
|
1280 if ( valptr[i] == TText( '\t' ) ) |
|
1281 valptr[i] = TText( ' ' ); |
|
1282 } |
|
1283 |
|
1284 if ( fieldType == EMetaDataSongTitle ) |
|
1285 attribute = KMPXMediaGeneralTitle; |
|
1286 else if ( fieldType == EMetaDataArtist ) |
|
1287 attribute = KMPXMediaMusicArtist; |
|
1288 else |
|
1289 attribute = KMPXMediaMusicAlbum; |
|
1290 |
|
1291 MPX_DEBUG3( "fieldType = %d, value = %S", fieldType, &valptr ); |
|
1292 aMedia->SetTextValueL( attribute , *value ); |
|
1293 CleanupStack::PopAndDestroy( value ); |
|
1294 } |
|
1295 } |
|
1296 |
|
1297 break; |
|
1298 |
|
1299 default: |
|
1300 |
|
1301 break; |
|
1302 } |
|
1303 } |
|
1304 |
|
1305 metadataUtility->ResetL(); |
|
1306 CleanupStack::PopAndDestroy( metadataUtility ); |
|
1307 } |
|
1308 } |
|
1309 } |
1191 |
1310 |
1192 // END OF FILE |
1311 // END OF FILE |