diff -r ea59c434026a -r 79c49924ae23 mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbhandler.cpp --- a/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbhandler.cpp Wed Jun 23 18:10:13 2010 +0300 +++ b/mpserviceplugins/mpxsqlitedbhgplugin/src/mpxdbhandler.cpp Tue Jul 06 14:13:36 2010 +0300 @@ -1589,9 +1589,8 @@ } #ifdef ABSTRACTAUDIOALBUM_INCLUDED - //for AbstractAlbum garbage collection - //can not leave - TRAP_IGNORE( AbstractAlbumCleanUpL() ); + //for AbstractAlbum garbage collection + TRAP_IGNORE( iDbAbstractAlbum->AbstractAlbumCleanUpL() ); #endif #ifdef __RAMDISK_PERF_ENABLE @@ -1622,6 +1621,12 @@ iDbManager->BeginL(); } + //create Thumbnail manager session for cleanup for abstractalbum when MTP end. + //because when MTP end comes, in case of mode switching, we need to do it as fast as possible, + //hence we don’t want the delay happens on that time. +#ifdef RD_MPX_TNM_INTEGRATION + iDbAbstractAlbum->CreateTNMSessionL(); +#endif //RD_MPX_TNM_INTEGRATION MPX_DEBUG1("<--CMPXDbHandler::MtpStartL"); } @@ -1647,11 +1652,13 @@ #endif //__RAMDISK_PERF_ENABLE #ifdef ABSTRACTAUDIOALBUM_INCLUDED - TRAP(err, RemoveAbstractAlbumsWithNoSongL()); + BeginTransactionL(); + TRAP(err, iDbAbstractAlbum->RemoveAbstractAlbumsWithNoSongL()); if ( err != KErrNone ) { MPX_DEBUG2("CMPXDbHandler::MtpEndL error happened when cleanup albstractalbum with no songs association[%d]", err); } + EndTransactionL(err); #endif MPX_DEBUG1("<--CMPXDbHandler::MtpEndL"); } @@ -2383,83 +2390,6 @@ EMPXSong, KDBPluginUid); } -#ifdef ABSTRACTAUDIOALBUM_INCLUDED -// ---------------------------------------------------------------------------- -// Remove abstractalbums which have no songs associated. -// ---------------------------------------------------------------------------- -// -void CMPXDbHandler::RemoveAbstractAlbumsWithNoSongL() - { - MPX_FUNC("CMPXDbHandler::RemoveAbstractAlbumsWithNoSongL"); - - BeginTransactionL(); - RArray iItemsIds; - CleanupClosePushL(iItemsIds); - //get all abstractalbum with no songs associated. - iDbAbstractAlbum->GetAllItemsWithNoSongL(iItemsIds); - TInt count = iItemsIds.Count(); - TInt err = KErrNone; - if (count) - { - MPX_DEBUG2("CMPXDbHandler::RemoveAbstractAlbumsWithNoSongL, abstractalbum count[%d] ", iItemsIds.Count()); - CMPXMessageArray* itemChangedMessages = CMPXMediaArray::NewL(); - CleanupStack::PushL(itemChangedMessages); - - //go through each one to delete - for (TInt i=0; i< count; i++) - { - TRAP(err, RemoveAbstractAlbumL(iItemsIds[i], *itemChangedMessages, EFalse)); - if (err != KErrNone) - { - MPX_DEBUG2("CMPXDbHandler::RemoveAbstractAlbumsWithNoSongL, error happens when delete abstractalbum, err ", err); - } - } - CleanupStack::PopAndDestroy(itemChangedMessages); - } - CleanupStack::PopAndDestroy(&iItemsIds); - EndTransactionL(err); - } - -// ---------------------------------------------------------------------------- -// Remove .alb entry from AbstractAlnum table, TN table if .alb files deleted -// from file manager when refresh library -// ---------------------------------------------------------------------------- -// -void CMPXDbHandler::AbstractAlbumCleanUpL() - { - MPX_FUNC("CMPXDbHandler::AbstractAlbumCleanUpL"); - RArray attributes; - CleanupClosePushL(attributes); - attributes.AppendL(KMPXMediaGeneralUri); - CMPXMediaArray* mediaArray = CMPXMediaArray::NewL(); - CleanupStack::PushL(mediaArray); - - iDbAbstractAlbum->GetAllCategoryItemsL(attributes.Array(), *mediaArray); - - TInt count(mediaArray->Count()); - if (count) - { - CMPXMessageArray* itemChangedMessages = CMPXMediaArray::NewL(); - CleanupStack::PushL(itemChangedMessages); - for (TInt i = 0; i < count; i++) - { - CMPXMedia* element = mediaArray->AtL(i); - const TDesC& uri = element->ValueText(KMPXMediaGeneralUri); - - //check if the file exists in file system - if (!(BaflUtils::FileExists(iFs, uri))) - { - //generate abstractalbum UID with the Uri - TUint32 abstractAlbumId(MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXAbstractAlbum, uri, EFalse)); - RemoveAbstractAlbumL(abstractAlbumId, *itemChangedMessages, ETrue); - } - } - CleanupStack::PopAndDestroy(itemChangedMessages); - } - CleanupStack::PopAndDestroy(mediaArray); - CleanupStack::PopAndDestroy(&attributes); - } -#endif //ABSTRACTAUDIOALBUM_INCLUDED // ---------------------------------------------------------------------------- // CMPXDbHandler::DoCleanupDeletedRecordsL @@ -2911,22 +2841,6 @@ // append the drive to the drive list iDbDrives.AppendL(driveUnit); - - // make sure the folder is created - TVolumeInfo info; - if (iFs.Volume(info, driveUnit) == KErrNone) - { - if (!BaflUtils::PathExists(iFs, folder)) - { - // create music folder if necessary - TInt err(iFs.MkDirAll(folder)); - MPX_DEBUG3("Try to create music folder %S return code %d", &folder, err); - if (err != KErrAlreadyExists) - { - User::LeaveIfError(err); - } - } - } } } @@ -3202,7 +3116,7 @@ TUint32 CMPXDbHandler::AddCategoryItemL( TMPXGeneralCategory aCategory, const TDesC& aName, - TUint32 aArtist, + const TDesC& aArtistName, const TDesC& aArt, TInt aDriveId, CMPXMessageArray* aItemChangedMessages, @@ -3215,9 +3129,9 @@ TBool newRecord(EFalse); TUint32 id = 0; - if ( aArtist ) + if(aCategory == EMPXAlbum) { - id = iDbAlbum->AddItemL(aName, aArtist, aArt, aDriveId, newRecord, (aCategory != EMPXGenre)); + id = iDbAlbum->AddItemL(aName, aArtistName, aArt, aDriveId, newRecord, (aCategory != EMPXGenre)); } else { @@ -3379,9 +3293,12 @@ // CMPXDbHandler::HandleArtistForAlbumL // --------------------------------------------------------------------------- // -TUint32 CMPXDbHandler::HandleArtistForAlbumL(const TUint32 aAlbumId) +HBufC* CMPXDbHandler::HandleArtistForAlbumL(const TUint32 aAlbumId) { - return iDbMusic->ArtistForAlbumL(aAlbumId); + + TUint32 artistId = iDbMusic->ArtistForAlbumL(aAlbumId); + HBufC* artistname = GetNameMatchingIdL(artistId); + return artistname; } // ---------------------------------------------------------------------------