65 _LIT( KMpxCollectionFindAllLModified, "MpxCollectionFindAllLModified" ); |
65 _LIT( KMpxCollectionFindAllLModified, "MpxCollectionFindAllLModified" ); |
66 _LIT( KMpxCollectionCleanupDeletedMediasL, "KMpxCollectionCleanupDeletedMediasL" ); |
66 _LIT( KMpxCollectionCleanupDeletedMediasL, "KMpxCollectionCleanupDeletedMediasL" ); |
67 _LIT( KSetMetadataValue, "SetMetadataValueL" ); |
67 _LIT( KSetMetadataValue, "SetMetadataValueL" ); |
68 #endif |
68 #endif |
69 |
69 |
70 #ifdef _DEBUG |
|
71 _LIT( KMtpMpxPanic, "CMmMtpDpMetadataMpxAccess" ); |
|
72 #endif |
|
73 |
|
74 CMmMtpDpMetadataMpxAccess* CMmMtpDpMetadataMpxAccess::NewL( RFs& aRfs ) |
70 CMmMtpDpMetadataMpxAccess* CMmMtpDpMetadataMpxAccess::NewL( RFs& aRfs ) |
75 { |
71 { |
76 CMmMtpDpMetadataMpxAccess* self = new( ELeave ) CMmMtpDpMetadataMpxAccess( aRfs ); |
72 CMmMtpDpMetadataMpxAccess* self = new( ELeave ) CMmMtpDpMetadataMpxAccess( aRfs ); |
77 CleanupStack::PushL( self ); |
73 CleanupStack::PushL( self ); |
78 self->ConstructL(); |
74 self->ConstructL(); |
79 CleanupStack::Pop( self ); |
75 CleanupStack::Pop( self ); |
80 |
76 |
81 return self; |
77 return self; |
82 } |
78 } |
83 |
79 |
84 CMmMtpDpMetadataMpxAccess::CMmMtpDpMetadataMpxAccess( RFs& aRfs ): |
80 CMmMtpDpMetadataMpxAccess::CMmMtpDpMetadataMpxAccess( RFs& aRfs ) : |
85 iRfs( aRfs ), |
81 iRfs( aRfs ), |
86 iSampleData( NULL ) |
82 iSampleData( NULL ), |
|
83 iHasCleanUp( EFalse ) |
87 { |
84 { |
88 // Do nothing |
85 // Do nothing |
89 } |
86 } |
90 |
87 |
91 // --------------------------------------------------------------------------- |
88 // --------------------------------------------------------------------------- |
147 PRINT( _L( "MM MTP <> Delete & Close CollectionHelper" ) ); |
144 PRINT( _L( "MM MTP <> Delete & Close CollectionHelper" ) ); |
148 iCollectionHelper->Close(); |
145 iCollectionHelper->Close(); |
149 iCollectionHelper = NULL; |
146 iCollectionHelper = NULL; |
150 } |
147 } |
151 |
148 |
|
149 iHasCleanUp = EFalse; // must reset, as class is not always destoryed |
152 PRINT( _L( "MM MTP <= CMmMtpDpMetadataMpxAccess::CloseSession" ) ); |
150 PRINT( _L( "MM MTP <= CMmMtpDpMetadataMpxAccess::CloseSession" ) ); |
153 } |
151 } |
154 |
152 |
155 // --------------------------------------------------------------------------- |
153 // --------------------------------------------------------------------------- |
156 // CMmMtpDpMetadataMpxAccess::GetObjectMetadataValueL |
154 // CMmMtpDpMetadataMpxAccess::GetObjectMetadataValueL |
396 |
394 |
397 searchMedia->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem ); |
395 searchMedia->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem ); |
398 searchMedia->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXSong ); |
396 searchMedia->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXSong ); |
399 searchMedia->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, |
397 searchMedia->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, |
400 KMtpInvalidSongID ); |
398 KMtpInvalidSongID ); |
401 searchMedia->SetTextValueL( KMPXMediaGeneralDrive, iStoreRoot ); |
399 if ( iStoreRoot.Length() > 0 ) |
|
400 { |
|
401 searchMedia->SetTextValueL( KMPXMediaGeneralDrive, iStoreRoot ); |
|
402 } |
402 |
403 |
403 RArray<TMPXAttribute> songAttributes; |
404 RArray<TMPXAttribute> songAttributes; |
404 CleanupClosePushL( songAttributes ); // + songAttributes |
405 CleanupClosePushL( songAttributes ); // + songAttributes |
405 songAttributes.AppendL( KMPXMediaGeneralId ); |
406 songAttributes.AppendL( KMPXMediaGeneralId ); |
406 |
407 |
592 // Delete stale records from the audio collection, for files that have been deleted. |
593 // Delete stale records from the audio collection, for files that have been deleted. |
593 // Records are deleted everytime in CloseSession to improve the audio database performance |
594 // Records are deleted everytime in CloseSession to improve the audio database performance |
594 // as there is NOT a separate database for deleted files. |
595 // as there is NOT a separate database for deleted files. |
595 PRINT( _L( "MM MTP <> Deleting metadata for deleted files" ) ); |
596 PRINT( _L( "MM MTP <> Deleting metadata for deleted files" ) ); |
596 |
597 |
597 PERFLOGSTART( KMpxCollectionCleanupDeletedMediasL ); |
598 if ( !iHasCleanUp ) |
598 CollectionHelperL()->CleanupDeletedMediasL(); |
599 { |
599 PERFLOGSTOP( KMpxCollectionCleanupDeletedMediasL ); |
600 PERFLOGSTART( KMpxCollectionCleanupDeletedMediasL ); |
|
601 CollectionHelperL()->CleanupDeletedMediasL(); |
|
602 PERFLOGSTOP( KMpxCollectionCleanupDeletedMediasL ); |
|
603 |
|
604 iHasCleanUp = ETrue; |
|
605 } |
600 |
606 |
601 PRINT( _L( "MM MTP <= CMmMtpDpMetadataMpxAccess::UpdateMusicCollectionL" ) ); |
607 PRINT( _L( "MM MTP <= CMmMtpDpMetadataMpxAccess::UpdateMusicCollectionL" ) ); |
602 } |
608 } |
603 |
609 |
604 // ----------------------------------------------------------------------------- |
610 // ----------------------------------------------------------------------------- |
939 CleanupStack::PushL( searchMedia ); // + searchMedia |
945 CleanupStack::PushL( searchMedia ); // + searchMedia |
940 |
946 |
941 searchMedia->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem ); |
947 searchMedia->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem ); |
942 searchMedia->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXSong ); |
948 searchMedia->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXSong ); |
943 searchMedia->SetTextValueL( KMPXMediaGeneralUri, aFullFileName ); |
949 searchMedia->SetTextValueL( KMPXMediaGeneralUri, aFullFileName ); |
944 searchMedia->SetTextValueL( KMPXMediaGeneralDrive, iStoreRoot ); |
950 |
|
951 TParsePtrC parse( aFullFileName ); |
|
952 searchMedia->SetTextValueL( KMPXMediaGeneralDrive, parse.Drive() ); |
945 |
953 |
946 RArray<TMPXAttribute> songAttributes; |
954 RArray<TMPXAttribute> songAttributes; |
947 CleanupClosePushL( songAttributes ); // + songAttributes |
955 CleanupClosePushL( songAttributes ); // + songAttributes |
948 songAttributes.AppendL( KMPXMediaGeneralUri ); |
956 songAttributes.AppendL( KMPXMediaGeneralUri ); |
949 |
957 |
993 EMPXItem ); |
1001 EMPXItem ); |
994 media->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, |
1002 media->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, |
995 EMPXSong ); |
1003 EMPXSong ); |
996 // File Path |
1004 // File Path |
997 // |
1005 // |
998 TParsePtrC parse( aFullFileName ); |
|
999 media->SetTextValueL( KMPXMediaGeneralUri, aFullFileName ); |
1006 media->SetTextValueL( KMPXMediaGeneralUri, aFullFileName ); |
1000 media->SetTextValueL( KMPXMediaGeneralDrive, parse.Drive() ); |
1007 media->SetTextValueL( KMPXMediaGeneralDrive, parse.Drive() ); |
1001 |
1008 |
1002 if ( foundItemCount == 0 ) |
1009 if ( foundItemCount == 0 ) |
1003 { |
1010 { |
1171 media->SetTextValueL( KMPXMediaGeneralUri, aRefFileArray[j] ); |
1178 media->SetTextValueL( KMPXMediaGeneralUri, aRefFileArray[j] ); |
1172 // TODO: need to confirm that should set drive letter or storage root path. |
1179 // TODO: need to confirm that should set drive letter or storage root path. |
1173 TParsePtrC parse( aRefFileArray[j] ); |
1180 TParsePtrC parse( aRefFileArray[j] ); |
1174 media->SetTextValueL( KMPXMediaGeneralDrive, parse.Drive() ); |
1181 media->SetTextValueL( KMPXMediaGeneralDrive, parse.Drive() ); |
1175 media->SetTObjectValueL( KMPXMediaGeneralModified, EFalse ); |
1182 media->SetTObjectValueL( KMPXMediaGeneralModified, EFalse ); |
1176 |
1183 |
1177 // Add media into array contents |
1184 // Add media into array contents |
1178 abstractMediaArray->AppendL( media ); |
1185 abstractMediaArray->AppendL( media ); |
1179 |
1186 |
1180 CleanupStack::Pop( media ); // - media |
1187 CleanupStack::Pop( media ); // - media |
1181 } |
1188 } |
1329 // CMmMtpDpMetadataMpxAccess::GetAllAbstractMediaL |
1336 // CMmMtpDpMetadataMpxAccess::GetAllAbstractMediaL |
1330 // Get all abstract medias from MPX database in the assigned store |
1337 // Get all abstract medias from MPX database in the assigned store |
1331 // --------------------------------------------------------------------------- |
1338 // --------------------------------------------------------------------------- |
1332 // |
1339 // |
1333 void CMmMtpDpMetadataMpxAccess::GetAllAbstractMediaL( const TDesC& aStoreRoot, |
1340 void CMmMtpDpMetadataMpxAccess::GetAllAbstractMediaL( const TDesC& aStoreRoot, |
1334 CMPXMediaArray** aAbstractMedias, |
1341 CDesCArray& aAbstractMedias, |
1335 TMPXGeneralCategory aCategory ) |
1342 TMPXGeneralCategory aCategory ) |
1336 { |
1343 { |
1337 PRINT( _L( "MM MTP => CMmMtpDpMetadataMpxAccess::GetAllAbstractMediaL" ) ); |
1344 PRINT( _L( "MM MTP => CMmMtpDpMetadataMpxAccess::GetAllAbstractMediaL" ) ); |
1338 |
1345 |
1339 SetStorageRootL( aStoreRoot ); |
1346 SetStorageRootL( aStoreRoot ); |
1380 if ( !foundMedia->IsSupported( KMPXMediaArrayContents ) ) |
1387 if ( !foundMedia->IsSupported( KMPXMediaArrayContents ) ) |
1381 { |
1388 { |
1382 User::Leave( KErrNotSupported ); |
1389 User::Leave( KErrNotSupported ); |
1383 } |
1390 } |
1384 |
1391 |
1385 *aAbstractMedias = |
1392 CMPXMediaArray* mediaArray = foundMedia->Value<CMPXMediaArray> ( KMPXMediaArrayContents ); |
1386 CMPXMediaArray::NewL( *( foundMedia->Value<CMPXMediaArray> ( KMPXMediaArrayContents ) ) ); |
1393 for ( TInt i = 0; i < count; i++ ) |
|
1394 aAbstractMedias.AppendL( ( *mediaArray )[i]->ValueText( KMPXMediaGeneralUri ) ); |
1387 } |
1395 } |
1388 |
1396 |
1389 CleanupStack::PopAndDestroy( foundMedia ); // - foundMedia |
1397 CleanupStack::PopAndDestroy( foundMedia ); // - foundMedia |
1390 |
1398 |
1391 PRINT( _L( "MM MTP <= CMmMtpDpMetadataMpxAccess::GetAllAbstractMediaL" ) ); |
1399 PRINT( _L( "MM MTP <= CMmMtpDpMetadataMpxAccess::GetAllAbstractMediaL" ) ); |
1394 // --------------------------------------------------------------------------- |
1402 // --------------------------------------------------------------------------- |
1395 // CMmMtpDpMetadataMpxAccess::GetAllReferenceL |
1403 // CMmMtpDpMetadataMpxAccess::GetAllReferenceL |
1396 // Get all references of specified playlist |
1404 // Get all references of specified playlist |
1397 // --------------------------------------------------------------------------- |
1405 // --------------------------------------------------------------------------- |
1398 // |
1406 // |
1399 void CMmMtpDpMetadataMpxAccess::GetAllReferenceL( CMPXMedia* aAbstractMedia, |
1407 void CMmMtpDpMetadataMpxAccess::GetAllReferenceL( const TDesC& aRefOwnerSuid, |
|
1408 TMPXGeneralCategory aCategory, |
1400 CDesCArray& aReferences ) |
1409 CDesCArray& aReferences ) |
1401 { |
1410 { |
1402 PRINT( _L( "MM MTP => CMmMtpDpMetadataMpxAccess::GetAllReferenceL" ) ); |
1411 PRINT( _L( "MM MTP => CMmMtpDpMetadataMpxAccess::GetAllReferenceL" ) ); |
1403 |
1412 |
1404 __ASSERT_DEBUG( aAbstractMedia, User::Panic( KMtpMpxPanic, KErrArgument ) ); |
1413 // 1. Get CMPXMedia object by the reference owner suid |
1405 |
1414 RArray<TMPXAttribute> attributes; |
1406 // Extract the playlist id from the found object |
1415 CleanupClosePushL( attributes ); // + attributes |
1407 TUint32 abstractMediaId = *( *aAbstractMedia ).Value<TMPXItemId>( KMPXMediaGeneralId ); |
1416 attributes.AppendL( KMPXMediaGeneralId ); |
|
1417 attributes.AppendL( KMPXMediaGeneralTitle ); |
|
1418 attributes.AppendL( KMPXMediaGeneralUri ); |
|
1419 |
|
1420 CMPXMedia* refOwner = CollectionHelperL()->GetL( aRefOwnerSuid, |
|
1421 attributes.Array(), |
|
1422 aCategory ); |
|
1423 |
|
1424 __ASSERT_DEBUG( refOwner, Panic( EMmMTPDpObjectNull ) ); |
|
1425 |
|
1426 CleanupStack::PushL( refOwner ); // + refOwner |
|
1427 |
|
1428 // 2. Extract the general id from the found object |
|
1429 if ( !refOwner->IsSupported( KMPXMediaGeneralId ) ) |
|
1430 PRINT( _L( "MM MTP => CMmMtpDpMetadataMpxAccess::GetAllReferenceL Before GeneralId" ) ); |
|
1431 |
|
1432 TUint32 abstractMediaId = *( *refOwner ).Value<TMPXItemId>( KMPXMediaGeneralId ); |
|
1433 PRINT( _L( "MM MTP => CMmMtpDpMetadataMpxAccess::GetAllReferenceL After GeneralId" ) ); |
|
1434 |
|
1435 CleanupStack::PopAndDestroy( refOwner ); // - refOwner |
|
1436 CleanupStack::PopAndDestroy( &attributes ); // - attributes |
1408 |
1437 |
1409 // find the media object that contains a list of songs in the playlist |
1438 // find the media object that contains a list of songs in the playlist |
1410 RArray<TInt> contentIDs; |
1439 RArray<TInt> contentIDs; |
1411 CleanupClosePushL( contentIDs ); // + contentIDs |
1440 CleanupClosePushL( contentIDs ); // + contentIDs |
1412 contentIDs.AppendL( KMPXMediaIdGeneral ); |
1441 contentIDs.AppendL( KMPXMediaIdGeneral ); |
1460 User::Leave( KErrNotSupported ); |
1489 User::Leave( KErrNotSupported ); |
1461 } |
1490 } |
1462 |
1491 |
1463 // may replace the following 3 statements into the following: |
1492 // may replace the following 3 statements into the following: |
1464 // AppendL(refMedia->ValueText(KMPXMediaGeneralUri)); |
1493 // AppendL(refMedia->ValueText(KMPXMediaGeneralUri)); |
1465 HBufC* musicFileLocation = refMedia->ValueText( KMPXMediaGeneralUri ).AllocLC(); |
1494 HBufC* musicFileLocation = refMedia->ValueText( KMPXMediaGeneralUri ).AllocLC(); // + musicFileLocation |
1466 aReferences.AppendL( *musicFileLocation ); |
1495 aReferences.AppendL( *musicFileLocation ); |
1467 |
1496 |
1468 PRINT1( _L("MM MTP <> CMmMtpDpMetadataMpxAccess::GetAllReferenceL, [%S] found from MPX db"), musicFileLocation ); |
1497 PRINT1( _L("MM MTP <> CMmMtpDpMetadataMpxAccess::GetAllReferenceL, [%S] found from MPX db"), musicFileLocation ); |
1469 |
1498 |
1470 CleanupStack::PopAndDestroy( musicFileLocation ); // - musicFileLocation |
1499 CleanupStack::PopAndDestroy( musicFileLocation ); // - musicFileLocation |
1472 } |
1501 } |
1473 |
1502 |
1474 CleanupStack::PopAndDestroy( foundMedia ); // - foundMedia |
1503 CleanupStack::PopAndDestroy( foundMedia ); // - foundMedia |
1475 |
1504 |
1476 PRINT( _L( "MM MTP <= CMmMtpDpMetadataMpxAccess::GetAllReferenceL" ) ); |
1505 PRINT( _L( "MM MTP <= CMmMtpDpMetadataMpxAccess::GetAllReferenceL" ) ); |
1477 } |
|
1478 |
|
1479 // --------------------------------------------------------------------------- |
|
1480 // CMmMtpDpMetadataMpxAccess::GetAbstractMediaNameL |
|
1481 // |
|
1482 // --------------------------------------------------------------------------- |
|
1483 // |
|
1484 HBufC* CMmMtpDpMetadataMpxAccess::GetAbstractMediaNameL( CMPXMedia* aAbstractMedia, |
|
1485 TMPXGeneralCategory aCategory ) |
|
1486 { |
|
1487 PRINT( _L( "MM MTP => CMmMtpDpMetadataMpxAccess::GetAbstractMediaNameL" ) ); |
|
1488 HBufC* name = NULL; |
|
1489 if ( aCategory == EMPXPlaylist || aCategory == EMPXAbstractAlbum ) |
|
1490 { |
|
1491 if( !aAbstractMedia->IsSupported( KMPXMediaGeneralUri ) ) |
|
1492 { |
|
1493 User::Leave( KErrNotSupported ); |
|
1494 } |
|
1495 name = aAbstractMedia->ValueText( KMPXMediaGeneralUri ).AllocL(); |
|
1496 } |
|
1497 else |
|
1498 { |
|
1499 User::Leave( KErrNotSupported ); |
|
1500 } |
|
1501 |
|
1502 PRINT( _L( "MM MTP <= CMmMtpDpMetadataMpxAccess::GetAbstractMediaNameL" ) ); |
|
1503 return name; |
|
1504 } |
1506 } |
1505 |
1507 |
1506 // --------------------------------------------------------------------------- |
1508 // --------------------------------------------------------------------------- |
1507 // CMmMtpDpMetadataMpxAccess::GetModifiedContentL |
1509 // CMmMtpDpMetadataMpxAccess::GetModifiedContentL |
1508 // Get modified content |
1510 // Get modified content |
1581 CleanupStack::PushL( searchMedia ); // + searchMedia |
1583 CleanupStack::PushL( searchMedia ); // + searchMedia |
1582 |
1584 |
1583 searchMedia->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem ); |
1585 searchMedia->SetTObjectValueL( KMPXMediaGeneralType, EMPXItem ); |
1584 searchMedia->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXPlaylist ); |
1586 searchMedia->SetTObjectValueL( KMPXMediaGeneralCategory, EMPXPlaylist ); |
1585 searchMedia->SetTextValueL( KMPXMediaGeneralUri, aSuid ); |
1587 searchMedia->SetTextValueL( KMPXMediaGeneralUri, aSuid ); |
1586 searchMedia->SetTextValueL( KMPXMediaGeneralDrive, iStoreRoot ); |
1588 |
|
1589 TParsePtrC parse( aSuid ); |
|
1590 searchMedia->SetTextValueL( KMPXMediaGeneralDrive, parse.Drive() ); |
1587 |
1591 |
1588 RArray<TMPXAttribute> playlistAttributes; |
1592 RArray<TMPXAttribute> playlistAttributes; |
1589 CleanupClosePushL( playlistAttributes ); // + playlistAttributes |
1593 CleanupClosePushL( playlistAttributes ); // + playlistAttributes |
1590 playlistAttributes.AppendL( KMPXMediaGeneralId ); |
1594 playlistAttributes.AppendL( KMPXMediaGeneralId ); |
1591 playlistAttributes.AppendL( KMPXMediaGeneralTitle ); |
1595 playlistAttributes.AppendL( KMPXMediaGeneralTitle ); |