176 iDbPlaylist = CMPXDbPlaylist::NewL(*iDbManager, *this); |
176 iDbPlaylist = CMPXDbPlaylist::NewL(*iDbManager, *this); |
177 iDbArtist = CMPXDbArtist::NewL(*iDbManager, EMPXArtist, *this); |
177 iDbArtist = CMPXDbArtist::NewL(*iDbManager, EMPXArtist, *this); |
178 iDbAlbum = CMPXDbAlbum::NewL(*iDbManager, EMPXAlbum, *this); |
178 iDbAlbum = CMPXDbAlbum::NewL(*iDbManager, EMPXAlbum, *this); |
179 iDbGenre = CMPXDbGenre::NewL(*iDbManager, EMPXGenre); |
179 iDbGenre = CMPXDbGenre::NewL(*iDbManager, EMPXGenre); |
180 iDbComposer = CMPXDbComposer::NewL(*iDbManager, EMPXComposer); |
180 iDbComposer = CMPXDbComposer::NewL(*iDbManager, EMPXComposer); |
181 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
181 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
182 iDbAbstractAlbum = CMPXDbAbstractAlbum::NewL(*iDbManager, EMPXAbstractAlbum); |
182 iDbAbstractAlbum = CMPXDbAbstractAlbum::NewL(*iDbManager, EMPXAbstractAlbum, iFs); |
183 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
183 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
184 iAutoPlaylist = CMPXDbAutoPlaylist::NewL(*iDbManager, iFs, iResource); |
184 iAutoPlaylist = CMPXDbAutoPlaylist::NewL(*iDbManager, iFs, iResource); |
185 iDbAuxiliary = CMPXDbAuxiliary::NewL(*iDbManager); |
185 iDbAuxiliary = CMPXDbAuxiliary::NewL(*iDbManager); |
186 |
186 |
187 MPX_TRAPD(err, iDbManager->InitDatabasesL(iDbDrives)); |
187 MPX_TRAPD(err, iDbManager->InitDatabasesL(iDbDrives)); |
188 |
188 |
313 CMPXMessageArray* aMessageArray) |
313 CMPXMessageArray* aMessageArray) |
314 { |
314 { |
315 MPX_FUNC("CMPXDbHandler::AddAbstractAlbumL"); |
315 MPX_FUNC("CMPXDbHandler::AddAbstractAlbumL"); |
316 |
316 |
317 BeginTransactionL(); |
317 BeginTransactionL(); |
318 // TUint32 abstractAlbumId(0); |
|
319 TBool newRecord(EFalse); |
318 TBool newRecord(EFalse); |
320 TInt err(KErrNone); |
319 TInt err(KErrNone); |
321 |
320 |
322 TDriveUnit drive(aMedia.ValueText(KMPXMediaGeneralUri)); |
321 TDriveUnit drive(aMedia.ValueText(KMPXMediaGeneralUri)); |
323 TPtrC name(aMedia.ValueText(KMPXMediaGeneralUri).Left(KMCMaxTextLen)); |
322 TPtrC uri(aMedia.ValueText(KMPXMediaGeneralUri).Left(KMCMaxTextLen)); |
|
323 TPtrC name(aMedia.ValueText(KMPXMediaGeneralTitle).Left(KMCMaxTextLen)); |
324 TPtrC albumartist(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen)); |
324 TPtrC albumartist(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen)); |
325 TPtrC genre(aMedia.ValueText(KMPXMediaMusicGenre).Left(KMCMaxTextLen)); |
325 |
326 |
326 //only insert to AbstractAlbum table when it is new item |
327 //only insert to AbstractAlbum table when it is new item |
327 TUint32 abstractAlbumId(MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXAbstractAlbum, uri, EFalse)); |
328 TUint32 abstractAlbumId(MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXAbstractAlbum, name, (EMPXAbstractAlbum!=EMPXGenre))); |
328 |
329 |
|
330 newRecord = !iDbAbstractAlbum->CategoryItemExistsL(drive, abstractAlbumId); |
329 newRecord = !iDbAbstractAlbum->CategoryItemExistsL(drive, abstractAlbumId); |
331 |
330 |
332 |
331 if (newRecord) |
333 if (newRecord) |
332 { |
334 { |
333 MPX_TRAP(err, abstractAlbumId = iDbAbstractAlbum->AddItemL(uri, name, albumartist, drive, newRecord, EFalse)); |
335 MPX_TRAP(err, abstractAlbumId = iDbAbstractAlbum->AddItemL( name, albumartist, genre, drive, newRecord, (EMPXAbstractAlbum != EMPXGenre))); |
|
336 if (iOutOfDisk && (err == KErrNotFound)) |
334 if (iOutOfDisk && (err == KErrNotFound)) |
337 { |
335 { |
338 err = KErrDiskFull; |
336 err = KErrDiskFull; |
339 } |
337 } |
340 if (aMessageArray) |
338 if (aMessageArray) |
343 EMPXAbstractAlbum, KDBPluginUid); |
341 EMPXAbstractAlbum, KDBPluginUid); |
344 } |
342 } |
345 } |
343 } |
346 EndTransactionL(err); |
344 EndTransactionL(err); |
347 |
345 |
348 return abstractAlbumId; |
346 return abstractAlbumId; |
349 } |
347 } |
350 |
348 |
351 // ---------------------------------------------------------------------------- |
349 // ---------------------------------------------------------------------------- |
352 // Update all songs which associate with AbstractAlbum in the collection |
350 // Update abstractalbum info to AbstractAlbum table and all songs which associate |
353 // ---------------------------------------------------------------------------- |
351 // with AbstractAlbum in the collection |
354 // |
352 // ---------------------------------------------------------------------------- |
355 CMPXDbActiveTask::TChangeVisibility CMPXDbHandler::UpdateAbstractAlbumSongsL( |
353 // |
|
354 CMPXDbActiveTask::TChangeVisibility CMPXDbHandler::UpdateAbstractAlbumL( |
356 const CMPXMedia& aMedia, |
355 const CMPXMedia& aMedia, |
357 CMPXMessageArray& aItemChangedMessages) |
356 CMPXMessageArray& aItemChangedMessages) |
358 { |
357 { |
359 MPX_FUNC("CMPXDbHandler::UpdateAbstractAlbumSongsL"); |
358 MPX_FUNC("CMPXDbHandler::UpdateAbstractAlbumL"); |
360 |
359 |
361 CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile); |
360 CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile); |
362 |
361 TUint32 itemId(0); |
363 if (aMedia.IsSupported(KMPXMediaGeneralUri)) |
362 if (aMedia.IsSupported(KMPXMediaGeneralUri)) |
364 { |
363 { |
365 const TDesC& art(aMedia.ValueText (KMPXMediaGeneralUri)); |
364 const TDesC& uri(aMedia.ValueText (KMPXMediaGeneralUri)); |
366 |
|
367 TBool existRecord(EFalse); |
|
368 TDriveUnit drive(aMedia.ValueText(KMPXMediaGeneralUri)); |
365 TDriveUnit drive(aMedia.ValueText(KMPXMediaGeneralUri)); |
369 TUint32 rowId(MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXAbstractAlbum, art, (EMPXAbstractAlbum != EMPXGenre))); |
366 |
370 //check if abstractAlbum in ABSTRACTALBUM table before update songs |
367 //get Id based on new uri |
371 existRecord = iDbAbstractAlbum->CategoryItemExistsL(drive, rowId); |
368 itemId = MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXAbstractAlbum, uri, EFalse); |
372 |
369 if (!itemId) |
373 //update songs associated with abstractalbum only when abstractalbum associated already |
370 { |
374 //in the AbstractAlbum table |
371 User::Leave(KErrNotSupported); |
375 if (existRecord) |
372 } |
376 { |
373 |
377 if (aMedia.IsSupported(KMPXMediaArrayContents)) |
374 //if updating to new item, need do renaming for AbstractAlbum: delete old one and insert a new entry to AbstractAlbum table |
|
375 //if a new item, need update songs associated and renaming albstractalbum table |
|
376 if (aMedia.IsSupported(KMPXMediaGeneralId)) |
|
377 { |
|
378 MPX_DEBUG1("CMPXDbHandler::UpdateAbstractAlbumL, rename case"); |
|
379 |
|
380 BeginTransactionL(); |
|
381 //get old id, for renaming |
|
382 TInt err(KErrNone); |
|
383 TUint32 oldId = (aMedia.ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)).iId2; |
|
384 if (oldId && (oldId != itemId) ) //pass the old UID for renaming, do not care if new itemId exist or not |
378 { |
385 { |
379 |
386 //get old Uri based on old Id |
380 CMPXMediaArray* mediaArray = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents); |
387 HBufC* oldUri = iDbAbstractAlbum->GetUriL(oldId); |
381 User::LeaveIfNull(mediaArray); |
388 CleanupStack::PushL(oldUri); |
|
389 |
|
390 //add and update new item to AbstractAlbum table |
|
391 //old existing item field values need to be saved and added when adding new item |
|
392 MPX_TRAP(err, itemId = iDbAbstractAlbum->AddUpdatedItemL(oldId, uri )); |
|
393 |
|
394 if (iOutOfDisk && (err == KErrNotFound)) |
|
395 { |
|
396 err = KErrDiskFull; |
|
397 } |
|
398 |
|
399 MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, itemId, EMPXItemInserted, |
|
400 EMPXAbstractAlbum, KDBPluginUid); |
|
401 |
|
402 //find and update all songs associated with oldId |
|
403 RArray<TMPXAttribute> songAttributes; |
|
404 CleanupClosePushL(songAttributes); |
|
405 songAttributes.AppendL(KMPXMediaGeneralId); |
|
406 |
|
407 CMPXMediaArray* mediaArray = CMPXMediaArray::NewL(); |
|
408 CleanupStack::PushL(mediaArray); |
|
409 |
|
410 //get all songs associated |
|
411 MPX_TRAP(err, iDbMusic->GetAllSongsForAbstractAlbumL(oldId, songAttributes.Array(), *mediaArray)); |
|
412 if (err == KErrNotFound) |
|
413 { |
|
414 // Leave with KErrNotFound |
|
415 MPX_DEBUG1("CMPXDbHandler::UpdateAbstractAlbumL, leave with not found"); |
|
416 User::Leave(KErrNotFound); |
|
417 } |
|
418 |
382 TInt count(mediaArray->Count()); |
419 TInt count(mediaArray->Count()); |
|
420 MPX_DEBUG2("CMPXDbHandler::UpdateAbstractAlbumL, [%d] songs associated", count); |
|
421 //go through all songs for updating |
383 for (TInt i = 0; i < count; i++) |
422 for (TInt i = 0; i < count; i++) |
384 { |
423 { |
385 CMPXMedia* element = mediaArray->AtL(i); |
424 CMPXMedia* song = mediaArray->AtL(i); |
386 element->SetTextValueL(KMPXMediaMusicAlbumArtFileName, art ); |
425 song->SetTextValueL(KMPXMediaMusicAlbumArtFileName, uri ); |
387 visibleChange = UpdateSongL(*element, aItemChangedMessages); |
426 visibleChange = UpdateSongL(*song, aItemChangedMessages); |
388 } |
427 } |
389 } |
428 CleanupStack::PopAndDestroy(mediaArray); |
390 else |
429 CleanupStack::PopAndDestroy(&songAttributes); |
391 { |
430 |
392 iDbAbstractAlbum->UpdateItemL(rowId, aMedia, drive, &aItemChangedMessages); |
431 //rename TN |
|
432 iDbAbstractAlbum->HandleTNL(*oldUri, uri, 0); |
|
433 CleanupStack::PopAndDestroy(oldUri); |
393 } |
434 } |
394 } |
435 EndTransactionL(err); |
|
436 }//renaming |
|
437 |
|
438 //check if abstractAlbum exist in ABSTRACTALBUM table before update it |
|
439 else if (iDbAbstractAlbum->CategoryItemExistsL(drive, itemId)) |
|
440 { |
|
441 //support updating Name, AlbumArtist fields for AbstractAlbum table |
|
442 iDbAbstractAlbum->UpdateItemL(itemId, aMedia, drive, &aItemChangedMessages); |
|
443 } |
395 } |
444 } |
396 return visibleChange; |
445 return visibleChange; |
397 } |
446 } |
|
447 |
|
448 // ---------------------------------------------------------------------------- |
|
449 // Update all songs which associate with AbstractAlbum to new AbstractAlbum info |
|
450 // in the collection |
|
451 // ---------------------------------------------------------------------------- |
|
452 // |
|
453 CMPXDbActiveTask::TChangeVisibility CMPXDbHandler::UpdateSongsAbstractAlbumInfoL( |
|
454 const CMPXMedia& aMedia, |
|
455 CMPXMessageArray& aItemChangedMessages) |
|
456 { |
|
457 MPX_FUNC("CMPXDbHandler::UpdateSongsAbstractAlbumInfoL"); |
|
458 const TDesC& uri(aMedia.ValueText (KMPXMediaGeneralUri)); |
|
459 //need to update songs information to music table |
|
460 CMPXMediaArray* mediaArray = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents); |
|
461 User::LeaveIfNull(mediaArray); |
|
462 TInt count(mediaArray->Count()); |
|
463 CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile); |
|
464 for (TInt i = 0; i < count; i++) |
|
465 { |
|
466 CMPXMedia* mediaSong = mediaArray->AtL(i); |
|
467 mediaSong->SetTextValueL(KMPXMediaMusicAlbumArtFileName, uri ); |
|
468 visibleChange = UpdateSongL(*mediaSong, aItemChangedMessages); |
|
469 } |
|
470 return visibleChange; |
|
471 } |
398 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
472 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
473 |
399 // ---------------------------------------------------------------------------- |
474 // ---------------------------------------------------------------------------- |
400 // Update a song in the collection |
475 // Update a song in the collection |
401 // ---------------------------------------------------------------------------- |
476 // ---------------------------------------------------------------------------- |
402 // |
477 // |
403 CMPXDbActiveTask::TChangeVisibility CMPXDbHandler::UpdateSongL( |
478 CMPXDbActiveTask::TChangeVisibility CMPXDbHandler::UpdateSongL( |
587 // Remove specified abstractalbum |
662 // Remove specified abstractalbum |
588 // ---------------------------------------------------------------------------- |
663 // ---------------------------------------------------------------------------- |
589 // |
664 // |
590 void CMPXDbHandler::RemoveAbstractAlbumL( |
665 void CMPXDbHandler::RemoveAbstractAlbumL( |
591 TUint32 aAbstractAlbumId, |
666 TUint32 aAbstractAlbumId, |
592 CDesCArray& aUriArray, |
667 CMPXMessageArray& aItemChangedMessages, TBool aFileDeleted) |
593 CMPXMessageArray& aItemChangedMessages) |
|
594 { |
668 { |
595 MPX_FUNC("CMPXDbHandler::RemoveAbstractAlbumL"); |
669 MPX_FUNC("CMPXDbHandler::RemoveAbstractAlbumL"); |
596 |
670 iDbAbstractAlbum->RemoveAbstractAlbumL(aAbstractAlbumId, aItemChangedMessages, aFileDeleted); |
597 BeginTransactionL(); |
|
598 MPX_TRAPD(err, DoRemoveAbstractAlbumL(aAbstractAlbumId, aUriArray, aItemChangedMessages)); |
|
599 EndTransactionL(err); |
|
600 } |
|
601 |
|
602 // ---------------------------------------------------------------------------- |
|
603 // Remove specified abstractalbum |
|
604 // ---------------------------------------------------------------------------- |
|
605 // |
|
606 void CMPXDbHandler::DoRemoveAbstractAlbumL( |
|
607 TUint32 aAbstractAlbumId, |
|
608 CDesCArray& aUriArray, |
|
609 CMPXMessageArray& aItemChangedMessages) |
|
610 { |
|
611 MPX_FUNC("CMPXDbHandler::DoRemoveAbstractAlbumL"); |
|
612 |
|
613 |
|
614 HBufC* uri(iDbAbstractAlbum->DeleteAbstractAlbumL(aAbstractAlbumId)); |
|
615 if (uri) |
|
616 { |
|
617 CleanupStack::PushL(uri); |
|
618 aUriArray.AppendL(*uri); |
|
619 CleanupStack::PopAndDestroy(uri); |
|
620 } |
|
621 |
|
622 MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, aAbstractAlbumId, EMPXItemDeleted, |
|
623 EMPXAbstractAlbum, KDBPluginUid); |
|
624 |
|
625 |
|
626 } |
671 } |
627 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
672 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
628 |
673 |
629 // ---------------------------------------------------------------------------- |
674 // ---------------------------------------------------------------------------- |
630 // Cleanup records marked as deleted. This is designated for MTP to clean up records marked as deleted |
675 // Cleanup records marked as deleted. This is designated for MTP to clean up records marked as deleted |
2300 |
2360 |
2301 // Send a message on the song in the playlist that is deleted |
2361 // Send a message on the song in the playlist that is deleted |
2302 MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, aSongId, EMPXItemDeleted, |
2362 MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, aSongId, EMPXItemDeleted, |
2303 EMPXSong, KDBPluginUid); |
2363 EMPXSong, KDBPluginUid); |
2304 } |
2364 } |
|
2365 |
|
2366 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
2367 // ---------------------------------------------------------------------------- |
|
2368 // Remove abstractalbums which have no songs associated. |
|
2369 // ---------------------------------------------------------------------------- |
|
2370 // |
|
2371 void CMPXDbHandler::RemoveAbstractAlbumsWithNoSongL() |
|
2372 { |
|
2373 MPX_FUNC("CMPXDbHandler::RemoveAbstractAlbumsWithNoSongL"); |
|
2374 |
|
2375 BeginTransactionL(); |
|
2376 RArray<TUint32> iItemsIds; |
|
2377 CleanupClosePushL(iItemsIds); |
|
2378 //get all abstractalbum with no songs associated. |
|
2379 iDbAbstractAlbum->GetAllItemsWithNoSongL(iItemsIds); |
|
2380 TInt count = iItemsIds.Count(); |
|
2381 TInt err = KErrNone; |
|
2382 if (count) |
|
2383 { |
|
2384 MPX_DEBUG2("CMPXDbHandler::RemoveAbstractAlbumsWithNoSongL, abstractalbum count[%d] ", iItemsIds.Count()); |
|
2385 CMPXMessageArray* itemChangedMessages = CMPXMediaArray::NewL(); |
|
2386 CleanupStack::PushL(itemChangedMessages); |
|
2387 |
|
2388 //go through each one to delete |
|
2389 for (TInt i=0; i< count; i++) |
|
2390 { |
|
2391 TRAP(err, RemoveAbstractAlbumL(iItemsIds[i], *itemChangedMessages, EFalse)); |
|
2392 if (err != KErrNone) |
|
2393 { |
|
2394 MPX_DEBUG2("CMPXDbHandler::RemoveAbstractAlbumsWithNoSongL, error happens when delete abstractalbum, err ", err); |
|
2395 } |
|
2396 } |
|
2397 CleanupStack::PopAndDestroy(itemChangedMessages); |
|
2398 } |
|
2399 CleanupStack::PopAndDestroy(&iItemsIds); |
|
2400 EndTransactionL(err); |
|
2401 } |
|
2402 |
|
2403 // ---------------------------------------------------------------------------- |
|
2404 // Remove .alb entry from AbstractAlnum table, TN table if .alb files deleted |
|
2405 // from file manager when refresh library |
|
2406 // ---------------------------------------------------------------------------- |
|
2407 // |
|
2408 void CMPXDbHandler::AbstractAlbumCleanUpL() |
|
2409 { |
|
2410 MPX_FUNC("CMPXDbHandler::AbstractAlbumCleanUpL"); |
|
2411 RArray<TMPXAttribute> attributes; |
|
2412 CleanupClosePushL(attributes); |
|
2413 attributes.AppendL(KMPXMediaGeneralUri); |
|
2414 CMPXMediaArray* mediaArray = CMPXMediaArray::NewL(); |
|
2415 CleanupStack::PushL(mediaArray); |
|
2416 |
|
2417 iDbAbstractAlbum->GetAllCategoryItemsL(attributes.Array(), *mediaArray); |
|
2418 |
|
2419 TInt count(mediaArray->Count()); |
|
2420 if (count) |
|
2421 { |
|
2422 CMPXMessageArray* itemChangedMessages = CMPXMediaArray::NewL(); |
|
2423 CleanupStack::PushL(itemChangedMessages); |
|
2424 for (TInt i = 0; i < count; i++) |
|
2425 { |
|
2426 CMPXMedia* element = mediaArray->AtL(i); |
|
2427 const TDesC& uri = element->ValueText(KMPXMediaGeneralUri); |
|
2428 |
|
2429 //check if the file exists in file system |
|
2430 if (!(BaflUtils::FileExists(iFs, uri))) |
|
2431 { |
|
2432 //generate abstractalbum UID with the Uri |
|
2433 TUint32 abstractAlbumId(MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXAbstractAlbum, uri, EFalse)); |
|
2434 RemoveAbstractAlbumL(abstractAlbumId, *itemChangedMessages, ETrue); |
|
2435 } |
|
2436 } |
|
2437 CleanupStack::PopAndDestroy(itemChangedMessages); |
|
2438 } |
|
2439 CleanupStack::PopAndDestroy(mediaArray); |
|
2440 CleanupStack::PopAndDestroy(&attributes); |
|
2441 } |
|
2442 #endif //ABSTRACTAUDIOALBUM_INCLUDED |
2305 |
2443 |
2306 // ---------------------------------------------------------------------------- |
2444 // ---------------------------------------------------------------------------- |
2307 // CMPXDbHandler::DoCleanupDeletedRecordsL |
2445 // CMPXDbHandler::DoCleanupDeletedRecordsL |
2308 // ---------------------------------------------------------------------------- |
2446 // ---------------------------------------------------------------------------- |
2309 // |
2447 // |
2985 TMPXGeneralCategory aCategory, |
3122 TMPXGeneralCategory aCategory, |
2986 const TDesC& aName, |
3123 const TDesC& aName, |
2987 TInt aDriveId, |
3124 TInt aDriveId, |
2988 CMPXMessageArray* aItemChangedMessages, |
3125 CMPXMessageArray* aItemChangedMessages, |
2989 TBool& aItemExist |
3126 TBool& aItemExist |
2990 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
3127 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
2991 ,const TDesC& aAlbumArtist, |
3128 ,const TDesC& aUri |
2992 const TDesC& aGenre |
3129 ,const TDesC& aAlbumArtist |
2993 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
3130 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
2994 ) |
3131 ) |
2995 { |
3132 { |
2996 MPX_FUNC("CMPXDbHandler::AddCategoryItemL()"); |
3133 MPX_FUNC("CMPXDbHandler::AddCategoryItemL()"); |
2997 |
3134 |
2998 MPX_PERF_START(CMPXDbHandler_AddCategoryItemL); |
3135 MPX_PERF_START(CMPXDbHandler_AddCategoryItemL); |
2999 |
3136 |
3000 TBool newRecord(EFalse); |
3137 TBool newRecord(EFalse); |
3001 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
3138 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
3002 TUint32 id(0); |
3139 TUint32 id(0); |
3003 //for AbstractAlbum, SetAbstractAlbum, associate songs with abstractalbum. |
3140 //for AbstractAlbum, SetAbstractAlbum, associate songs with abstractalbum. |
3004 //only called with newRecord as EFalse |
3141 //only called with newRecord as EFalse |
3005 //increment songCount if id exist in AbstractAlbum table, otherwise do nothing. |
3142 //increment songCount if id exist in AbstractAlbum table, otherwise do nothing. |
|
3143 |
|
3144 //only Genre, AbstractAlbum are not case sensitive |
|
3145 TBool caseSensitive = ETrue; |
|
3146 if ((aCategory == EMPXGenre) || (aCategory == EMPXAbstractAlbum)) |
|
3147 caseSensitive = EFalse; |
|
3148 |
3006 if (aCategory == EMPXAbstractAlbum) |
3149 if (aCategory == EMPXAbstractAlbum) |
3007 { |
3150 { |
3008 id = iDbAbstractAlbum->AddItemL( aName, aAlbumArtist, aGenre, aDriveId, newRecord, (aCategory != EMPXGenre)); |
3151 id = iDbAbstractAlbum->AddItemL(aUri, aName, aAlbumArtist, aDriveId, newRecord, caseSensitive); |
3009 } |
3152 } |
3010 else |
3153 else |
3011 { |
3154 { |
3012 id = DbCategoryL(aCategory)->AddItemL(aName, aDriveId, newRecord, (aCategory != EMPXGenre)); |
3155 id = DbCategoryL(aCategory)->AddItemL(aName, aDriveId, newRecord, caseSensitive); |
3013 #else |
3156 #else |
3014 TUint32 id(DbCategoryL(aCategory)->AddItemL(aName, aDriveId, newRecord, (aCategory != EMPXGenre))); |
3157 TUint32 id(DbCategoryL(aCategory)->AddItemL(aName, aDriveId, newRecord, (aCategory != EMPXGenre))); |
3015 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
3158 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
3159 |
3016 if (newRecord && aItemChangedMessages) |
3160 if (newRecord && aItemChangedMessages) |
3017 { |
3161 { |
3018 MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemInserted, |
3162 MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemInserted, |
3019 aCategory, KDBPluginUid); |
3163 aCategory, KDBPluginUid); |
3020 } |
3164 } |
3021 // when the added item's category is Genre or Composer, |
3165 // when the added item's category is Genre or Composer, |
3022 // and it is NOT a new record, |
3166 // and it is NOT a new record, |
3023 // we should send the item number changed message |
3167 // we should send the item number changed message |
3024 else if ( ( aCategory == EMPXGenre || aCategory == EMPXComposer ) && |
3168 else if ( ( aCategory == EMPXGenre || aCategory == EMPXComposer ) && |
3025 !newRecord && aItemChangedMessages ) |
3169 !newRecord && aItemChangedMessages ) |
3026 { |
3170 { |
3027 MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemModified, |
3171 MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemModified, |
3028 aCategory, KDBPluginUid); |
3172 aCategory, KDBPluginUid); |
3029 } |
3173 } |
3030 aItemExist = !newRecord; |
3174 aItemExist = !newRecord; |
3031 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
3175 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
3032 } |
3176 } |
3033 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
3177 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
3034 MPX_PERF_END(CMPXDbHandler_AddCategoryItemL); |
3178 MPX_PERF_END(CMPXDbHandler_AddCategoryItemL); |
3035 |
|
3036 return id; |
3179 return id; |
3037 } |
3180 } |
3038 |
3181 |
3039 TUint32 CMPXDbHandler::AddCategoryItemL( |
3182 TUint32 CMPXDbHandler::AddCategoryItemL( |
3040 TMPXGeneralCategory aCategory, |
3183 TMPXGeneralCategory aCategory, |