258 |
258 |
259 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
259 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
260 if(iArtNeedUpdated) |
260 if(iArtNeedUpdated) |
261 { |
261 { |
262 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
262 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
263 // Update Album table |
263 // Update Album table |
264 if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) || aMedia.IsSupported(KMPXMediaMusicArtist)) |
264 if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) || aMedia.IsSupported(KMPXMediaMusicArtist)) |
265 { |
265 { |
266 TUint32 albumId = recordset.ColumnInt64(EMusicAlbum); |
266 TUint32 albumId = recordset.ColumnInt64(EMusicAlbum); |
267 iObserver.UpdateCategoryItemL(EMPXAlbum, albumId, aMedia, driveUnit, aItemChangedMessages); |
267 iObserver.UpdateCategoryItemL(EMPXAlbum, albumId, aMedia, driveUnit, aItemChangedMessages); |
268 } |
268 } |
269 |
269 |
270 // Update Artist table |
270 // Update Artist table |
271 if ( aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) ) |
271 if ( aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName) ) |
272 { |
272 { |
273 TUint32 artistId = recordset.ColumnInt64(EMusicArtist); |
273 TUint32 artistId = recordset.ColumnInt64(EMusicArtist); |
274 iObserver.UpdateCategoryItemL(EMPXArtist, artistId, aMedia, driveUnit, aItemChangedMessages); |
274 iObserver.UpdateCategoryItemL(EMPXArtist, artistId, aMedia, driveUnit, aItemChangedMessages); |
275 } |
275 } |
276 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
276 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
277 } |
277 } |
278 iArtNeedUpdated = ETrue; //reset flag |
278 iArtNeedUpdated = ETrue; //reset flag |
279 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
279 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
280 CleanupStack::PopAndDestroy(&recordset); |
280 CleanupStack::PopAndDestroy(&recordset); |
820 // ---------------------------------------------------------------------------- |
820 // ---------------------------------------------------------------------------- |
821 // CMPXDbMusic::GetAllSongsForAbstractAlbumL |
821 // CMPXDbMusic::GetAllSongsForAbstractAlbumL |
822 // ---------------------------------------------------------------------------- |
822 // ---------------------------------------------------------------------------- |
823 // |
823 // |
824 void CMPXDbMusic::GetAllSongsForAbstractAlbumL( |
824 void CMPXDbMusic::GetAllSongsForAbstractAlbumL( |
825 TInt aDrive, |
825 TUint aAbstractAlbumId, |
826 TInt aAbstractAlbumId, |
|
827 const TArray<TMPXAttribute>& aAttrs, |
826 const TArray<TMPXAttribute>& aAttrs, |
828 CMPXMediaArray& aMediaArray) |
827 CMPXMediaArray& aMediaArray) |
829 { |
828 { |
830 MPX_FUNC("CMPXDbMusic::GetAllSongsL"); |
829 MPX_FUNC("CMPXDbMusic::GetAllSongsForAbstractAlbumL"); |
831 ExecuteMediaQueryL(aDrive, aAttrs, aMediaArray, KQueryMusicGetSongsForAbstractAlbum(), aAbstractAlbumId); |
830 ExecuteMediaQueryL(aAttrs, aMediaArray, KQueryMusicGetSongsForAbstractAlbum(), aAbstractAlbumId); |
832 } |
831 } |
833 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
832 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
834 |
833 |
835 // ---------------------------------------------------------------------------- |
834 // ---------------------------------------------------------------------------- |
836 // CMPXDbMusic::AllSongsDurationL |
835 // CMPXDbMusic::AllSongsDurationL |
1864 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
1863 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
1865 const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen); |
1864 const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen); |
1866 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
1865 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
1867 TParsePtrC parse(albumArtFilename); |
1866 TParsePtrC parse(albumArtFilename); |
1868 TPtrC ext(parse.Ext()); |
1867 TPtrC ext(parse.Ext()); |
1869 //set flag to false, so .alb will not overwrite art field in album, artist table |
1868 //set flag to false, so .alb will not overwrite art field in album, artist table |
1870 // when song with embedded art |
1869 // when song with embedded art |
1871 if ((ext.CompareF(KAbstractAlbumExt)== 0) && containEmbeddedArt) |
1870 if ((ext.CompareF(KAbstractAlbumExt)== 0) && containEmbeddedArt) |
1872 { |
1871 { |
1873 iArtNeedUpdated = EFalse; |
1872 iArtNeedUpdated = EFalse; |
1874 } |
1873 } |
1875 |
1874 |
1876 if ( ((ext.CompareF(KAbstractAlbumExt)== 0) && !containEmbeddedArt) || (ext.CompareF(KAbstractAlbumExt)!= 0)) |
1875 if ( ((ext.CompareF(KAbstractAlbumExt)== 0) && !containEmbeddedArt) || (ext.CompareF(KAbstractAlbumExt)!= 0)) |
1877 { |
1876 { |
1878 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
1877 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
1879 if (!aMusicTable || (albumArtFilename != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicArt))) |
1878 if (!aMusicTable || (albumArtFilename != MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicArt))) |
2265 { |
2264 { |
2266 if (!volumeAdded) |
2265 if (!volumeAdded) |
2267 { |
2266 { |
2268 // validate the drive letter, TDriveUnit panics if given drive isn't between |
2267 // validate the drive letter, TDriveUnit panics if given drive isn't between |
2269 // 'A' to 'Z' |
2268 // 'A' to 'Z' |
2270 TDriveUnit driveUnit(aCriteria.ValueText(KMPXMediaGeneralDrive)); |
2269 const TDesC& drive = aCriteria.ValueText(KMPXMediaGeneralDrive); |
|
2270 TInt driveInt = 0; |
|
2271 if( drive == KNullDesC || RFs::CharToDrive( drive[0], driveInt )!= KErrNone ) |
|
2272 { |
|
2273 User::Leave(KErrArgument); |
|
2274 } |
|
2275 TDriveUnit driveUnit(drive); |
2271 MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicVolume, |
2276 MPXDbCommonUtil::AddSqlCriterionL(*sqlCriteria, KCriterionMusicVolume, |
2272 MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), driveUnit)); |
2277 MPXDbCommonUtil::GetVolIdMatchDriveIdL(iDbManager.Fs(), driveUnit)); |
2273 volumeAdded = ETrue; |
2278 volumeAdded = ETrue; |
2274 } |
2279 } |
2275 } |
2280 } |
2387 if (aMedia.IsSupported(aAttribute)) |
2392 if (aMedia.IsSupported(aAttribute)) |
2388 { |
2393 { |
2389 TPtrC name(aMedia.ValueText(aAttribute).Left(KMCMaxTextLen)); |
2394 TPtrC name(aMedia.ValueText(aAttribute).Left(KMCMaxTextLen)); |
2390 |
2395 |
2391 // construct the new ID for the category record |
2396 // construct the new ID for the category record |
|
2397 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
2398 // genre and abstractalbum are not case sensitive |
|
2399 TBool caseSensitive = ETrue; |
|
2400 if ((aCategory == EMPXGenre) || (aCategory == EMPXAbstractAlbum)) |
|
2401 caseSensitive = EFalse; |
|
2402 |
|
2403 aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, |
|
2404 name, caseSensitive); |
|
2405 |
|
2406 #else |
2392 // only genre is not case sensitive |
2407 // only genre is not case sensitive |
2393 aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, |
2408 aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, |
2394 name, (aCategory != EMPXGenre)); |
2409 name, (aCategory != EMPXGenre)); |
|
2410 #endif |
2395 if (!aOldId || (aOldId != aItemId)) |
2411 if (!aOldId || (aOldId != aItemId)) |
2396 { |
2412 { |
2397 // only add if the ID changed, |
2413 // only add if the ID changed, |
2398 // otherwise the song was updated but the artist name was not |
2414 // otherwise the song was updated but the artist name was not |
2399 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
2415 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
2400 if(aCategory == EMPXAbstractAlbum) |
2416 if(aCategory == EMPXAbstractAlbum) |
2401 { |
2417 { |
2402 if (aMedia.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory) == EMPXSong ) |
2418 if (aMedia.ValueTObjectL<TMPXGeneralCategory>(KMPXMediaGeneralCategory) == EMPXSong ) |
2403 { |
2419 { |
2404 iObserver.AddCategoryItemL(aCategory, name, aDriveId, |
2420 iObserver.AddCategoryItemL(aCategory, KNullDesC, aDriveId, |
2405 aItemChangedMessages, itemAdded, KNullDesC, KNullDesC); |
2421 aItemChangedMessages, itemAdded, name, KNullDesC); |
2406 } |
2422 } |
2407 else |
2423 else |
2408 { |
2424 { |
2409 TPtrC albumartist(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen)); |
2425 TPtrC albumartist(KNullDesC); |
2410 //get AlbumArt, Genre for AbstractAlbum |
2426 TPtrC abstractAlbumName(KNullDesC); |
2411 MPX_DEBUG2(" Music albumartist[%S]", &albumartist); |
2427 if (aMedia.IsSupported(KMPXMediaMusicAlbumArtist) ) |
2412 TPtrC genre(aMedia.ValueText(KMPXMediaMusicGenre).Left(KMCMaxTextLen)); |
2428 { |
2413 MPX_DEBUG2(" Music Genre[%S]", &genre); |
2429 albumartist.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen)); |
2414 |
2430 //get AlbumArt AbstractAlbum |
2415 // ignore the return value |
2431 MPX_DEBUG2(" albumartist[%S]", &albumartist); |
2416 iObserver.AddCategoryItemL(aCategory, name, aDriveId, |
2432 } |
2417 aItemChangedMessages, itemAdded, albumartist, genre); |
2433 if (aMedia.IsSupported(KMPXMediaGeneralTitle) ) |
|
2434 { |
|
2435 abstractAlbumName.Set(aMedia.ValueText(KMPXMediaGeneralTitle).Left(KMCMaxTextLen)); |
|
2436 MPX_DEBUG2(" abstractAlbumName[%S]", &abstractAlbumName); |
|
2437 } |
|
2438 // ignore the return value |
|
2439 |
|
2440 iObserver.AddCategoryItemL(aCategory, abstractAlbumName, aDriveId, |
|
2441 aItemChangedMessages, itemAdded, name, albumartist); |
2418 } |
2442 } |
2419 } |
2443 } |
2420 else |
2444 else |
2421 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
2445 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
2422 { |
2446 { |
2427 updated = ETrue; |
2451 updated = ETrue; |
2428 } |
2452 } |
2429 } |
2453 } |
2430 else |
2454 else |
2431 { |
2455 { |
|
2456 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
2457 // genre and abstractalbum are not case sensitive |
|
2458 aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, KNullDesC, |
|
2459 (aCategory != EMPXGenre)&&(aCategory != EMPXAbstractAlbum)); |
|
2460 #else |
2432 // only genre is not case sensitive |
2461 // only genre is not case sensitive |
2433 aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, KNullDesC, |
2462 aItemId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), aCategory, KNullDesC, |
2434 (aCategory != EMPXGenre)); |
2463 (aCategory != EMPXGenre)); |
|
2464 #endif |
2435 if (!aOldId || (aOldId != aItemId)) |
2465 if (!aOldId || (aOldId != aItemId)) |
2436 { |
2466 { |
2437 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
2467 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
2438 if(aCategory == EMPXAbstractAlbum) |
2468 if(aCategory == EMPXAbstractAlbum) |
2439 { |
2469 { |
2440 //get AlbumArt, Genre for AbstractAlbum |
2470 //get AlbumArt for AbstractAlbum |
2441 TPtrC albumartist(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen)); |
2471 TPtrC albumartist(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen)); |
2442 MPX_DEBUG2(" Music albumartist[%S]", &albumartist); |
2472 MPX_DEBUG2(" Music albumartist[%S]", &albumartist); |
2443 TPtrC genre(aMedia.ValueText(KMPXMediaMusicGenre).Left(KMCMaxTextLen)); |
2473 TPtrC abstractAlbumName(aMedia.ValueText(KMPXMediaGeneralTitle).Left(KMCMaxTextLen)); |
2444 MPX_DEBUG2(" Music Genre[%S]", &genre); |
2474 MPX_DEBUG2(" Music abstractAlbumName[%S]", &abstractAlbumName); |
2445 |
|
2446 // ignore the return value |
2475 // ignore the return value |
2447 iObserver.AddCategoryItemL(aCategory, KNullDesC, aDriveId, |
2476 iObserver.AddCategoryItemL(aCategory, abstractAlbumName, aDriveId, |
2448 aItemChangedMessages, itemAdded, albumartist, genre); |
2477 aItemChangedMessages, itemAdded, KNullDesC, albumartist); |
2449 } |
2478 } |
2450 else |
2479 else |
2451 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
2480 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
2452 { |
2481 { |
2453 // ignore the return value |
2482 // ignore the return value |
2454 iObserver.AddCategoryItemL(aCategory, KNullDesC, aDriveId, |
2483 iObserver.AddCategoryItemL(aCategory, KNullDesC, aDriveId, |
2455 aItemChangedMessages, itemAdded); |
2484 aItemChangedMessages, itemAdded); |
2456 } |
2485 } |
2457 updated = ETrue; |
2486 updated = ETrue; |
2458 } |
2487 } |
2459 } |
2488 } |
2460 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
2489 |
2461 //no need to delete old item for abstractalbum |
2490 if (aOldId && (aOldId != aItemId)) |
2462 if (aOldId && (aOldId != aItemId) && (aCategory != EMPXAbstractAlbum)) |
|
2463 #else |
|
2464 if (aOldId && (aOldId != aItemId)) |
|
2465 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
2466 { |
2491 { |
2467 iObserver.DeleteSongForCategoryL(aCategory, aOldId, aDriveId, |
2492 iObserver.DeleteSongForCategoryL(aCategory, aOldId, aDriveId, |
2468 aItemChangedMessages, itemNotRemoved); |
2493 aItemChangedMessages, itemNotRemoved); |
2469 updated = ETrue; |
2494 updated = ETrue; |
2470 } |
2495 } |