151 iMusicMenuTitle = iResource->ReadHBufCL(R_MPX_QTN_MP_TITLE_MY_MUSIC_MENU_NSERIES); |
151 iMusicMenuTitle = iResource->ReadHBufCL(R_MPX_QTN_MP_TITLE_MY_MUSIC_MENU_NSERIES); |
152 #else |
152 #else |
153 iMusicMenuTitle = iResource->ReadHBufCL(R_MPX_QTN_MUS_TITLE_MUSIC_MENU); |
153 iMusicMenuTitle = iResource->ReadHBufCL(R_MPX_QTN_MUS_TITLE_MUSIC_MENU); |
154 #endif // __ENABLE_MUSIC_TEXT_ALIGNMENT |
154 #endif // __ENABLE_MUSIC_TEXT_ALIGNMENT |
155 |
155 |
|
156 |
156 iActiveTask = CMPXDbActiveTask::NewL(*this); |
157 iActiveTask = CMPXDbActiveTask::NewL(*this); |
157 |
158 |
158 CRepository* cenrep(NULL); |
159 CRepository* cenrep(NULL); |
159 TRAPD( err, cenrep = CRepository::NewL( KCRUIDMusicPlayerFeatures ) ); |
160 TRAPD( err, cenrep = CRepository::NewL( KCRUIDMusicPlayerFeatures ) ); |
160 if( err == KErrNone ) |
161 if( err == KErrNone ) |
333 // Remove EVERYthing from the collection |
334 // Remove EVERYthing from the collection |
334 iDbHandler->RemoveEntireCollectionL(); |
335 iDbHandler->RemoveEntireCollectionL(); |
335 break; |
336 break; |
336 } |
337 } |
337 case EMcCmdClose: |
338 case EMcCmdClose: |
|
339 // called before destructing this plug-in: no actions required |
|
340 break; |
338 case EMcCloseCollection: |
341 case EMcCloseCollection: |
339 { |
342 { |
340 MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcCloseCollection"); |
343 MPX_DEBUG2("CMPXDbPlugin::CommandL - EMcCloseCollection %d", aArg); |
341 // Close the specified database |
344 // Close the specified database |
342 TRAP_IGNORE(iDbHandler->PreCloseCollectionL()); |
345 TRAP_IGNORE(iDbHandler->PreCloseCollectionL()); |
343 #ifdef RD_MULTIPLE_DRIVE |
346 #ifdef RD_MULTIPLE_DRIVE |
344 MPX_DEBUG1("Multiple drives closing databases"); |
347 MPX_DEBUG1("Multiple drives closing databases"); |
345 if ( aArg <0) |
348 if ( aArg <0) |
348 User::LeaveIfError ( DriveInfo::GetUserVisibleDrives( iFs, driveArray)); |
351 User::LeaveIfError ( DriveInfo::GetUserVisibleDrives( iFs, driveArray)); |
349 TInt count( driveArray.Count ()); |
352 TInt count( driveArray.Count ()); |
350 for (TInt i=0; i<count; ++i) |
353 for (TInt i=0; i<count; ++i) |
351 { |
354 { |
352 MPX_DEBUG2("At drive %i", driveArray[i]); |
355 MPX_DEBUG2("At drive %i", driveArray[i]); |
353 if (( driveArray[i] != EDriveC) && (!iDbHandler->IsRemoteDrive(static_cast<TDriveNumber>(driveArray[i])))) |
356 if (( driveArray[i] != EDriveC) && (!iDbHandler->IsRemoteDrive(static_cast<TDriveNumber>(driveArray[i])))) |
354 { |
357 { |
355 MPX_DEBUG2("Closing database %i", driveArray[i]); |
358 MPX_DEBUG2("Closing database %i", driveArray[i]); |
356 TRAP_IGNORE( iDbHandler->CloseDatabaseL( driveArray[i] ) ); |
359 TRAP_IGNORE( iDbHandler->CloseDatabaseL( driveArray[i] ) ); |
357 } |
360 } |
358 } |
361 } |
359 } |
362 } |
360 else |
363 else |
361 { |
364 { |
362 iDbHandler->CloseDatabaseL(aArg); |
365 TRAP_IGNORE( iDbHandler->CloseDatabaseL(aArg) ); //Closing can fail if physical media has been removed or forced disk dismount has occurred. |
363 } |
366 } |
364 #else |
367 #else |
365 iDbHandler->CloseDatabaseL(aArg); |
368 iDbHandler->CloseDatabaseL(aArg); |
366 #endif // RD_MULTIPLE_DRIVE |
369 #endif // RD_MULTIPLE_DRIVE |
367 iDbHandler->CollectionClosed(); |
|
368 break; |
370 break; |
369 } |
371 } |
370 case EMcReOpenCollection: |
372 case EMcReOpenCollection: |
371 { |
373 { |
372 MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcReOpenCollection"); |
374 MPX_DEBUG1("CMPXDbPlugin::CommandL - EMcReOpenCollection"); |
377 User::LeaveIfError( DriveInfo::GetUserVisibleDrives( iFs, driveArray ) ); |
379 User::LeaveIfError( DriveInfo::GetUserVisibleDrives( iFs, driveArray ) ); |
378 TInt count( driveArray.Count() ); |
380 TInt count( driveArray.Count() ); |
379 for( TInt i=0; i<count; ++i ) |
381 for( TInt i=0; i<count; ++i ) |
380 { |
382 { |
381 MPX_DEBUG2("At drive %i", driveArray[i]); |
383 MPX_DEBUG2("At drive %i", driveArray[i]); |
382 if( (driveArray[i] != EDriveC) && (!iDbHandler->IsRemoteDrive(static_cast<TDriveNumber>(driveArray[i])))) |
384 if( (driveArray[i] != EDriveC) && (!iDbHandler->IsRemoteDrive(static_cast<TDriveNumber>(driveArray[i])))) |
383 { |
385 { |
384 TUint driveStatus(0); |
386 TUint driveStatus(0); |
385 User::LeaveIfError( DriveInfo::GetDriveStatus( |
387 User::LeaveIfError( DriveInfo::GetDriveStatus( |
386 iFs, driveArray[i], driveStatus ) ); |
388 iFs, driveArray[i], driveStatus ) ); |
387 if( driveStatus & DriveInfo::EDrivePresent ) |
389 if( driveStatus & DriveInfo::EDrivePresent ) |
436 break; |
437 break; |
437 } |
438 } |
438 case EMcCmdMtpStart: |
439 case EMcCmdMtpStart: |
439 iDbHandler->CheckDiskSpaceOnDrivesL(); |
440 iDbHandler->CheckDiskSpaceOnDrivesL(); |
440 iMtpInUse = ETrue; |
441 iMtpInUse = ETrue; |
441 iDbHandler->MtpStartL(); |
442 iDbHandler->MtpStartL(); |
442 break; |
443 break; |
443 case EMcCmdMtpEnd: |
444 case EMcCmdMtpEnd: |
444 iDbHandler->CheckDiskSpaceOnDrivesL(); |
445 iDbHandler->CheckDiskSpaceOnDrivesL(); |
445 iMtpInUse = EFalse; |
446 iMtpInUse = EFalse; |
446 iDbHandler->MtpEndL(); |
447 iDbHandler->MtpEndL(); |
447 break; |
448 break; |
448 default: |
449 default: |
449 { |
450 { |
450 User::Leave(KErrNotSupported); |
451 User::Leave(KErrNotSupported); |
451 } |
452 } |
1144 total += temp; |
1144 total += temp; |
1145 } |
1145 } |
1146 // Add "all" item under an artist |
1146 // Add "all" item under an artist |
1147 MPXDbCommonUtil::PrependMediaL(*aArray, *iAllSongsForArtistTitle, EMPXItem, EMPXAlbum, |
1147 MPXDbCommonUtil::PrependMediaL(*aArray, *iAllSongsForArtistTitle, EMPXItem, EMPXAlbum, |
1148 aPath.Id(idIndex), 0, 0, 1); |
1148 aPath.Id(idIndex), 0, 0, 1); |
1149 |
1149 |
1150 (*aArray)[1]->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, total); |
1150 (*aArray)[1]->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, total); |
1151 |
1151 |
1152 TMPXItemId allId = ((*aArray)[1]->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
1152 TMPXItemId allId = ((*aArray)[1]->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
1153 if (aArray->Count() > 2) |
1153 if (aArray->Count() > 2) |
1154 { // path media, all id and at least one media |
1154 { // path media, all id and at least one media |
1155 ((CMPXCollectionPath*)pPath)->InsertL(allId, 0); |
1155 ((CMPXCollectionPath*)pPath)->InsertL(allId, 0); |
1156 } |
1156 } |
1395 } |
1395 } |
1396 else |
1396 else |
1397 { |
1397 { |
1398 iDbHandler->GetSongsMatchingPlaylistL(aPath.Id (idIndex).iId2, aAttrs, aArray); |
1398 iDbHandler->GetSongsMatchingPlaylistL(aPath.Id (idIndex).iId2, aAttrs, aArray); |
1399 } |
1399 } |
|
1400 |
1400 |
1401 |
1401 SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXPlaylist, aPath.Id(idIndex).iId2); |
1402 SetMediaGeneralAttributesL(aEntries, EMPXItem, EMPXPlaylist, aPath.Id(idIndex).iId2); |
1402 |
1403 |
1403 // populate EMPXMediaGeneralNonPermissibleActions |
1404 // populate EMPXMediaGeneralNonPermissibleActions |
1404 if (iDbHandler->IsAutoPlaylistL(aPath.Id(idIndex).iId2)) |
1405 if (iDbHandler->IsAutoPlaylistL(aPath.Id(idIndex).iId2)) |
2587 else if (category == EMPXPlaylist) |
2588 else if (category == EMPXPlaylist) |
2588 { |
2589 { |
2589 mediaId = iDbHandler->GetPlaylistIdMatchingUriL(uri); |
2590 mediaId = iDbHandler->GetPlaylistIdMatchingUriL(uri); |
2590 iDbHandler->RemovePlaylistL(mediaId, *fp, *itemChangedMessages); |
2591 iDbHandler->RemovePlaylistL(mediaId, *fp, *itemChangedMessages); |
2591 } |
2592 } |
2592 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
2593 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
2593 else if (category == EMPXAbstractAlbum ) |
2594 else if (category == EMPXAbstractAlbum ) |
2594 { |
2595 { |
2595 mediaId = iDbHandler->GetAbstractAlbumIdMatchingUriL(uri); |
2596 mediaId = iDbHandler->GetAbstractAlbumIdMatchingUriL(uri); |
2596 iDbHandler->RemoveAbstractAlbumL(mediaId, *fp, *itemChangedMessages); |
2597 iDbHandler->RemoveAbstractAlbumL(mediaId, *itemChangedMessages, EFalse); |
2597 } |
2598 } |
2598 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
2599 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
2599 else |
2600 else |
2600 { |
2601 { |
2601 // otherwise unable to process this item |
2602 // otherwise unable to process this item |
3443 |
3444 |
3444 TUint32 itemId(0); |
3445 TUint32 itemId(0); |
3445 CMPXMessageArray* changeMsgAry = CMPXMessageArray::NewL(); |
3446 CMPXMessageArray* changeMsgAry = CMPXMessageArray::NewL(); |
3446 CleanupStack::PushL(changeMsgAry); |
3447 CleanupStack::PushL(changeMsgAry); |
3447 |
3448 |
3448 // start a transaction here |
3449 // start a transaction here |
3449 if (!iDbHandler->InTransaction()) |
3450 if (!iDbHandler->InTransaction()) |
3450 { |
3451 { |
3451 iDbHandler->BeginTransactionL(); |
3452 iDbHandler->BeginTransactionL(); |
3452 } |
3453 } |
3453 |
3454 |
3454 // Group of items |
3455 // Group of items |
3455 if (aMedia.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) == EMPXGroup) |
3456 if (aMedia.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) == EMPXGroup) |
3456 { |
3457 { |
3457 CMPXMediaArray* array = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents); |
3458 CMPXMediaArray* array = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents); |
3469 else // single item |
3470 else // single item |
3470 { |
3471 { |
3471 itemId = DoAddItemL(aMedia, *changeMsgAry); |
3472 itemId = DoAddItemL(aMedia, *changeMsgAry); |
3472 } |
3473 } |
3473 |
3474 |
3474 // end transaction here. |
3475 // end transaction here. |
3475 iDbHandler->EndTransactionL(KErrNone); |
3476 iDbHandler->EndTransactionL(KErrNone); |
3476 |
3477 |
3477 iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible); |
3478 iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible); |
3478 DoHandleChangeL(changeMsgAry); |
3479 DoHandleChangeL(changeMsgAry); |
3479 CleanupStack::PopAndDestroy(changeMsgAry); |
3480 CleanupStack::PopAndDestroy(changeMsgAry); |
3480 |
3481 |
3527 break; |
3528 break; |
3528 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
3529 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
3529 case EMPXAbstractAlbum: |
3530 case EMPXAbstractAlbum: |
3530 { |
3531 { |
3531 if (aMedia.IsSupported(KMPXMediaGeneralUri)) |
3532 if (aMedia.IsSupported(KMPXMediaGeneralUri)) |
3532 { |
3533 { |
3533 |
3534 //add abstractalbum to AbstractAlbum table |
3534 itemId = iDbHandler->AddAbstractAlbumL(aMedia, &aMessageArray); |
3535 itemId = iDbHandler->AddAbstractAlbumL(aMedia, &aMessageArray); |
3535 |
3536 |
|
3537 //in case aMedia as mediaArray which contains songs as arrayContents, need to update all songs associated |
3536 if ( aMedia.IsSupported(KMPXMediaArrayContents)) |
3538 if ( aMedia.IsSupported(KMPXMediaArrayContents)) |
3537 { |
3539 { |
3538 //need to update songs information to music table |
3540 iDbHandler->UpdateSongsAbstractAlbumInfoL(aMedia, aMessageArray); |
3539 CMPXMediaArray* array = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents); |
|
3540 if (array->Count()) |
|
3541 { |
|
3542 iDbHandler->UpdateAbstractAlbumSongsL(aMedia, aMessageArray); |
|
3543 } |
|
3544 } |
3541 } |
3545 } |
3542 } |
3546 else |
3543 else |
3547 { |
3544 { |
3548 User::Leave(KErrArgument); |
3545 User::Leave(KErrArgument); |
3551 break; |
3548 break; |
3552 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
3549 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
3553 case EMPXSong: |
3550 case EMPXSong: |
3554 { |
3551 { |
3555 // For the use case of adding thousands of songs at once, |
3552 // For the use case of adding thousands of songs at once, |
3556 // we do not create a new database transaction for each song; |
3553 // we do not create a new database transaction for each song; |
3557 // Instead DoAddL() will batch 100 songs under a single transaction. |
3554 // Instead DoAddL() will batch 100 songs under a single transaction. |
3558 // This enhancement improves performance with MMC-based databases. |
3555 // This enhancement improves performance with MMC-based databases. |
3559 if (aBatchCommit) |
3556 if (aBatchCommit) |
3560 { |
3557 { |
3561 itemId = iDbHandler->AddSongWithNoTransactionL(aMedia, &aMessageArray); |
3558 itemId = iDbHandler->AddSongWithNoTransactionL(aMedia, &aMessageArray); |
3562 } |
3559 } |
3563 else |
3560 else |
3564 { |
3561 { |
3565 itemId = iDbHandler->AddSongL(aMedia, &aMessageArray); |
3562 itemId = iDbHandler->AddSongL(aMedia, &aMessageArray); |
3566 } |
3563 } |
3567 |
3564 |
3568 MPXDbCommonUtil::AddItemChangedMessageL(aMessageArray, itemId, EMPXItemInserted, |
3565 MPXDbCommonUtil::AddItemChangedMessageL(aMessageArray, itemId, EMPXItemInserted, |
3569 EMPXSong, KDBPluginUid); |
3566 EMPXSong, KDBPluginUid); |
3570 } |
3567 } |
3571 break; |
3568 break; |
3572 |
3569 |
3716 } |
3713 } |
3717 break; |
3714 break; |
3718 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
3715 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
3719 case EMPXAbstractAlbum: |
3716 case EMPXAbstractAlbum: |
3720 { |
3717 { |
3721 visibleChange = iDbHandler->UpdateAbstractAlbumSongsL(aMedia, aMessageArray); |
3718 //update all songes which associate with ABSTRACTALBUM |
|
3719 if (aMedia.IsSupported(KMPXMediaGeneralUri)) |
|
3720 { |
|
3721 //in case aMedia as mediaArray which contains songs as arrayContents, need to update all songs associated |
|
3722 if ( aMedia.IsSupported(KMPXMediaArrayContents)) |
|
3723 { |
|
3724 iDbHandler->UpdateSongsAbstractAlbumInfoL(aMedia, aMessageArray); |
|
3725 } |
|
3726 //only update field values in abstractalbum table, or renaming (change uri) for abstractalbum table |
|
3727 else |
|
3728 { |
|
3729 visibleChange = iDbHandler->UpdateAbstractAlbumL(aMedia, aMessageArray); |
|
3730 } |
|
3731 } |
3722 } |
3732 } |
3723 break; |
3733 break; |
3724 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
3734 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
3725 case EMPXSong: |
3735 case EMPXSong: |
3726 { |
3736 { |
4380 case EBrowsePlaylist: |
4390 case EBrowsePlaylist: |
4381 case EBrowseGenre: |
4391 case EBrowseGenre: |
4382 case EBrowseComposer: |
4392 case EBrowseComposer: |
4383 { |
4393 { |
4384 aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic, |
4394 aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic, |
4385 // EMPXMediaMusicArtist | EMPXMediaMusicAlbumArtFileName ) ); |
4395 // EMPXMediaMusicArtist | EMPXMediaMusicAlbumArtFileName ) ); |
4386 //added ganes |
4396 //added ganes |
4387 EMPXMediaMusicArtist | EMPXMediaMusicAlbumArtFileName | EMPXMediaMusicAlbum) ); |
4397 EMPXMediaMusicArtist | EMPXMediaMusicAlbumArtFileName | EMPXMediaMusicAlbum) ); |
4388 aSupportedIds.AppendL( KMPXMediaIdMusic ); |
4398 aSupportedIds.AppendL( KMPXMediaIdMusic ); |
4389 break; |
4399 break; |
4390 } |
4400 } |
4391 } |
4401 } |
4392 } |
4402 } |