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 |
595 // 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. |
596 // 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 |
597 // as there is NOT a separate database for deleted files. |
595 // as there is NOT a separate database for deleted files. |
598 PRINT( _L( "MM MTP <> Deleting metadata for deleted files" ) ); |
596 PRINT( _L( "MM MTP <> Deleting metadata for deleted files" ) ); |
599 |
597 |
600 PERFLOGSTART( KMpxCollectionCleanupDeletedMediasL ); |
598 if ( !iHasCleanUp ) |
601 CollectionHelperL()->CleanupDeletedMediasL(); |
599 { |
602 PERFLOGSTOP( KMpxCollectionCleanupDeletedMediasL ); |
600 PERFLOGSTART( KMpxCollectionCleanupDeletedMediasL ); |
|
601 CollectionHelperL()->CleanupDeletedMediasL(); |
|
602 PERFLOGSTOP( KMpxCollectionCleanupDeletedMediasL ); |
|
603 |
|
604 iHasCleanUp = ETrue; |
|
605 } |
603 |
606 |
604 PRINT( _L( "MM MTP <= CMmMtpDpMetadataMpxAccess::UpdateMusicCollectionL" ) ); |
607 PRINT( _L( "MM MTP <= CMmMtpDpMetadataMpxAccess::UpdateMusicCollectionL" ) ); |
605 } |
608 } |
606 |
609 |
607 // ----------------------------------------------------------------------------- |
610 // ----------------------------------------------------------------------------- |
998 EMPXItem ); |
1001 EMPXItem ); |
999 media->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, |
1002 media->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, |
1000 EMPXSong ); |
1003 EMPXSong ); |
1001 // File Path |
1004 // File Path |
1002 // |
1005 // |
1003 TParsePtrC parse( aFullFileName ); |
|
1004 media->SetTextValueL( KMPXMediaGeneralUri, aFullFileName ); |
1006 media->SetTextValueL( KMPXMediaGeneralUri, aFullFileName ); |
1005 media->SetTextValueL( KMPXMediaGeneralDrive, parse.Drive() ); |
1007 media->SetTextValueL( KMPXMediaGeneralDrive, parse.Drive() ); |
1006 |
1008 |
1007 if ( foundItemCount == 0 ) |
1009 if ( foundItemCount == 0 ) |
1008 { |
1010 { |
1334 // CMmMtpDpMetadataMpxAccess::GetAllAbstractMediaL |
1336 // CMmMtpDpMetadataMpxAccess::GetAllAbstractMediaL |
1335 // Get all abstract medias from MPX database in the assigned store |
1337 // Get all abstract medias from MPX database in the assigned store |
1336 // --------------------------------------------------------------------------- |
1338 // --------------------------------------------------------------------------- |
1337 // |
1339 // |
1338 void CMmMtpDpMetadataMpxAccess::GetAllAbstractMediaL( const TDesC& aStoreRoot, |
1340 void CMmMtpDpMetadataMpxAccess::GetAllAbstractMediaL( const TDesC& aStoreRoot, |
1339 CMPXMediaArray** aAbstractMedias, |
1341 CDesCArray& aAbstractMedias, |
1340 TMPXGeneralCategory aCategory ) |
1342 TMPXGeneralCategory aCategory ) |
1341 { |
1343 { |
1342 PRINT( _L( "MM MTP => CMmMtpDpMetadataMpxAccess::GetAllAbstractMediaL" ) ); |
1344 PRINT( _L( "MM MTP => CMmMtpDpMetadataMpxAccess::GetAllAbstractMediaL" ) ); |
1343 |
1345 |
1344 SetStorageRootL( aStoreRoot ); |
1346 SetStorageRootL( aStoreRoot ); |
1385 if ( !foundMedia->IsSupported( KMPXMediaArrayContents ) ) |
1387 if ( !foundMedia->IsSupported( KMPXMediaArrayContents ) ) |
1386 { |
1388 { |
1387 User::Leave( KErrNotSupported ); |
1389 User::Leave( KErrNotSupported ); |
1388 } |
1390 } |
1389 |
1391 |
1390 *aAbstractMedias = |
1392 CMPXMediaArray* mediaArray = foundMedia->Value<CMPXMediaArray> ( KMPXMediaArrayContents ); |
1391 CMPXMediaArray::NewL( *( foundMedia->Value<CMPXMediaArray> ( KMPXMediaArrayContents ) ) ); |
1393 for ( TInt i = 0; i < count; i++ ) |
|
1394 aAbstractMedias.AppendL( ( *mediaArray )[i]->ValueText( KMPXMediaGeneralUri ) ); |
1392 } |
1395 } |
1393 |
1396 |
1394 CleanupStack::PopAndDestroy( foundMedia ); // - foundMedia |
1397 CleanupStack::PopAndDestroy( foundMedia ); // - foundMedia |
1395 |
1398 |
1396 PRINT( _L( "MM MTP <= CMmMtpDpMetadataMpxAccess::GetAllAbstractMediaL" ) ); |
1399 PRINT( _L( "MM MTP <= CMmMtpDpMetadataMpxAccess::GetAllAbstractMediaL" ) ); |
1399 // --------------------------------------------------------------------------- |
1402 // --------------------------------------------------------------------------- |
1400 // CMmMtpDpMetadataMpxAccess::GetAllReferenceL |
1403 // CMmMtpDpMetadataMpxAccess::GetAllReferenceL |
1401 // Get all references of specified playlist |
1404 // Get all references of specified playlist |
1402 // --------------------------------------------------------------------------- |
1405 // --------------------------------------------------------------------------- |
1403 // |
1406 // |
1404 void CMmMtpDpMetadataMpxAccess::GetAllReferenceL( CMPXMedia* aAbstractMedia, |
1407 void CMmMtpDpMetadataMpxAccess::GetAllReferenceL( const TDesC& aRefOwnerSuid, |
|
1408 TMPXGeneralCategory aCategory, |
1405 CDesCArray& aReferences ) |
1409 CDesCArray& aReferences ) |
1406 { |
1410 { |
1407 PRINT( _L( "MM MTP => CMmMtpDpMetadataMpxAccess::GetAllReferenceL" ) ); |
1411 PRINT( _L( "MM MTP => CMmMtpDpMetadataMpxAccess::GetAllReferenceL" ) ); |
1408 |
1412 |
1409 __ASSERT_DEBUG( aAbstractMedia, User::Panic( KMtpMpxPanic, KErrArgument ) ); |
1413 // 1. Get CMPXMedia object by the reference owner suid |
1410 |
1414 RArray<TMPXAttribute> attributes; |
1411 // Extract the playlist id from the found object |
1415 CleanupClosePushL( attributes ); // + attributes |
1412 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 |
1413 |
1437 |
1414 // 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 |
1415 RArray<TInt> contentIDs; |
1439 RArray<TInt> contentIDs; |
1416 CleanupClosePushL( contentIDs ); // + contentIDs |
1440 CleanupClosePushL( contentIDs ); // + contentIDs |
1417 contentIDs.AppendL( KMPXMediaIdGeneral ); |
1441 contentIDs.AppendL( KMPXMediaIdGeneral ); |
1465 User::Leave( KErrNotSupported ); |
1489 User::Leave( KErrNotSupported ); |
1466 } |
1490 } |
1467 |
1491 |
1468 // may replace the following 3 statements into the following: |
1492 // may replace the following 3 statements into the following: |
1469 // AppendL(refMedia->ValueText(KMPXMediaGeneralUri)); |
1493 // AppendL(refMedia->ValueText(KMPXMediaGeneralUri)); |
1470 HBufC* musicFileLocation = refMedia->ValueText( KMPXMediaGeneralUri ).AllocLC(); |
1494 HBufC* musicFileLocation = refMedia->ValueText( KMPXMediaGeneralUri ).AllocLC(); // + musicFileLocation |
1471 aReferences.AppendL( *musicFileLocation ); |
1495 aReferences.AppendL( *musicFileLocation ); |
1472 |
1496 |
1473 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 ); |
1474 |
1498 |
1475 CleanupStack::PopAndDestroy( musicFileLocation ); // - musicFileLocation |
1499 CleanupStack::PopAndDestroy( musicFileLocation ); // - musicFileLocation |
1477 } |
1501 } |
1478 |
1502 |
1479 CleanupStack::PopAndDestroy( foundMedia ); // - foundMedia |
1503 CleanupStack::PopAndDestroy( foundMedia ); // - foundMedia |
1480 |
1504 |
1481 PRINT( _L( "MM MTP <= CMmMtpDpMetadataMpxAccess::GetAllReferenceL" ) ); |
1505 PRINT( _L( "MM MTP <= CMmMtpDpMetadataMpxAccess::GetAllReferenceL" ) ); |
1482 } |
|
1483 |
|
1484 // --------------------------------------------------------------------------- |
|
1485 // CMmMtpDpMetadataMpxAccess::GetAbstractMediaNameL |
|
1486 // |
|
1487 // --------------------------------------------------------------------------- |
|
1488 // |
|
1489 HBufC* CMmMtpDpMetadataMpxAccess::GetAbstractMediaNameL( CMPXMedia* aAbstractMedia, |
|
1490 TMPXGeneralCategory aCategory ) |
|
1491 { |
|
1492 PRINT( _L( "MM MTP => CMmMtpDpMetadataMpxAccess::GetAbstractMediaNameL" ) ); |
|
1493 HBufC* name = NULL; |
|
1494 if ( aCategory == EMPXPlaylist || aCategory == EMPXAbstractAlbum ) |
|
1495 { |
|
1496 if( !aAbstractMedia->IsSupported( KMPXMediaGeneralUri ) ) |
|
1497 { |
|
1498 User::Leave( KErrNotSupported ); |
|
1499 } |
|
1500 name = aAbstractMedia->ValueText( KMPXMediaGeneralUri ).AllocL(); |
|
1501 } |
|
1502 else |
|
1503 { |
|
1504 User::Leave( KErrNotSupported ); |
|
1505 } |
|
1506 |
|
1507 PRINT( _L( "MM MTP <= CMmMtpDpMetadataMpxAccess::GetAbstractMediaNameL" ) ); |
|
1508 return name; |
|
1509 } |
1506 } |
1510 |
1507 |
1511 // --------------------------------------------------------------------------- |
1508 // --------------------------------------------------------------------------- |
1512 // CMmMtpDpMetadataMpxAccess::GetModifiedContentL |
1509 // CMmMtpDpMetadataMpxAccess::GetModifiedContentL |
1513 // Get modified content |
1510 // Get modified content |