mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbplugin.cpp
branchRCL_3
changeset 17 c8156a91d13c
parent 15 171e07ac910f
child 18 c54d95799c80
equal deleted inserted replaced
15:171e07ac910f 17:c8156a91d13c
  1261         // All Albums
  1261         // All Albums
  1262         case 2:
  1262         case 2:
  1263             {
  1263             {
  1264             MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseAlbumL_All);
  1264             MPX_PERF_START(CMPXDbPlugin_DoOpenBrowseAlbumL_All);
  1265 
  1265 
  1266             iDbHandler->GetAllAlbumsL(aAttrs, aArray);
  1266             TRAPD(err, iDbHandler->GetAllAlbumsL(aAttrs, aArray) );
       
  1267             // in error case, return empty list and append empty id to path 
       
  1268             // in order to increase one level 
       
  1269             if ( err != KErrNone )
       
  1270                 {
       
  1271                 TInt pPath(0);
       
  1272                 if (aArray->Count())
       
  1273                     {
       
  1274                     CMPXMedia* pMedia = (*aArray)[0];
       
  1275                     if (pMedia->IsSupported(KMPXMediaGeneralValue))
       
  1276                         {
       
  1277                         pPath = pMedia->ValueTObjectL<TInt>(KMPXMediaGeneralValue);
       
  1278                         MPX_ASSERT(pPath);
       
  1279                         }                   
       
  1280                     }
       
  1281 
       
  1282                 RArray<TMPXItemId> ids;
       
  1283                 CleanupClosePushL(ids);
       
  1284             
       
  1285                 // Append ids to the returned path
       
  1286                 if (pPath)
       
  1287                     {
       
  1288                     ((CMPXCollectionPath*)pPath)->AppendL(ids.Array());
       
  1289                     }
       
  1290                 CleanupStack::PopAndDestroy(&ids);
       
  1291                 }
       
  1292             
  1267             SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXAlbum,
  1293             SetMediaGeneralAttributesL(aEntries, EMPXGroup, EMPXAlbum,
  1268                 iMusicLibraryTitles->MdcaPoint(EBrowseAlbum));
  1294                 iMusicLibraryTitles->MdcaPoint(EBrowseAlbum));
  1269 
  1295 
  1270             MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseAlbumL_All);
  1296             MPX_PERF_END(CMPXDbPlugin_DoOpenBrowseAlbumL_All);
  1271             break;
  1297             break;
  2563         else if (category == EMPXPlaylist)
  2589         else if (category == EMPXPlaylist)
  2564             {
  2590             {
  2565             mediaId = iDbHandler->GetPlaylistIdMatchingUriL(uri);
  2591             mediaId = iDbHandler->GetPlaylistIdMatchingUriL(uri);
  2566             iDbHandler->RemovePlaylistL(mediaId, *fp, *itemChangedMessages);
  2592             iDbHandler->RemovePlaylistL(mediaId, *fp, *itemChangedMessages);
  2567             }
  2593             }
       
  2594 #ifdef ABSTRACTAUDIOALBUM_INCLUDED            
       
  2595         else if (category == EMPXAbstractAlbum )
       
  2596             {
       
  2597             mediaId = iDbHandler->GetAbstractAlbumIdMatchingUriL(uri);
       
  2598             iDbHandler->RemoveAbstractAlbumL(mediaId, *fp, *itemChangedMessages);            
       
  2599             }
       
  2600 #endif // ABSTRACTAUDIOALBUM_INCLUDED
  2568         else
  2601         else
  2569             {
  2602             {
  2570             // otherwise unable to process this item
  2603             // otherwise unable to process this item
  2571             }
  2604             }
  2572         }
  2605         }
  3412 
  3445 
  3413     TUint32 itemId(0);
  3446     TUint32 itemId(0);
  3414     CMPXMessageArray* changeMsgAry = CMPXMessageArray::NewL();
  3447     CMPXMessageArray* changeMsgAry = CMPXMessageArray::NewL();
  3415     CleanupStack::PushL(changeMsgAry);
  3448     CleanupStack::PushL(changeMsgAry);
  3416 
  3449 
  3417 	// start a transaction here
  3450     // start a transaction here
  3418 	if (!iDbHandler->InTransaction())
  3451     if (!iDbHandler->InTransaction())
  3419 		{
  3452         {
  3420 		iDbHandler->BeginTransactionL();
  3453         iDbHandler->BeginTransactionL();
  3421 		}
  3454         }
  3422 
  3455 
  3423     // Group of items
  3456     // Group of items
  3424     if (aMedia.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) == EMPXGroup)
  3457     if (aMedia.ValueTObjectL<TMPXGeneralType>(KMPXMediaGeneralType) == EMPXGroup)
  3425         {
  3458         {
  3426         CMPXMediaArray* array = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);
  3459         CMPXMediaArray* array = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);
  3438     else // single item
  3471     else // single item
  3439         {
  3472         {
  3440         itemId = DoAddItemL(aMedia, *changeMsgAry);
  3473         itemId = DoAddItemL(aMedia, *changeMsgAry);
  3441         }
  3474         }
  3442 
  3475 
  3443 	// end transaction here.
  3476     // end transaction here.
  3444 	iDbHandler->EndTransactionL(KErrNone);
  3477     iDbHandler->EndTransactionL(KErrNone);
  3445 
  3478 
  3446     iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible);
  3479     iActiveTask->SetVisibleChange(CMPXDbActiveTask::EAllVisible);
  3447     DoHandleChangeL(changeMsgAry);
  3480     DoHandleChangeL(changeMsgAry);
  3448     CleanupStack::PopAndDestroy(changeMsgAry);
  3481     CleanupStack::PopAndDestroy(changeMsgAry);
  3449 
  3482 
  3492                 {
  3525                 {
  3493                 User::Leave(KErrArgument);
  3526                 User::Leave(KErrArgument);
  3494                 }
  3527                 }
  3495             }
  3528             }
  3496             break;
  3529             break;
  3497 
  3530 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
       
  3531        case EMPXAbstractAlbum:
       
  3532             {
       
  3533             if (aMedia.IsSupported(KMPXMediaGeneralUri))
       
  3534                 { 
       
  3535                    
       
  3536                 itemId = iDbHandler->AddAbstractAlbumL(aMedia, &aMessageArray);
       
  3537             
       
  3538                 if ( aMedia.IsSupported(KMPXMediaArrayContents))
       
  3539                     {
       
  3540                     //need to update songs information to music table           
       
  3541                     CMPXMediaArray* array = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);                        
       
  3542                     if (array->Count())            
       
  3543                         {                  
       
  3544                         iDbHandler->UpdateAbstractAlbumSongsL(aMedia, aMessageArray);
       
  3545                         }
       
  3546                     }
       
  3547                 }
       
  3548             else
       
  3549                 {
       
  3550                 User::Leave(KErrArgument);
       
  3551                 }
       
  3552             }
       
  3553             break;
       
  3554 #endif // ABSTRACTAUDIOALBUM_INCLUDED
  3498         case EMPXSong:
  3555         case EMPXSong:
  3499             {
  3556             {
  3500             // For the use case of adding thousands of songs at once,
  3557             // For the use case of adding thousands of songs at once,
  3501             // we do not create a new database transaction for each song;
  3558             // we do not create a new database transaction for each song;
  3502             // Instead DoAddL() will batch 100 songs under a single transaction.
  3559             // Instead DoAddL() will batch 100 songs under a single transaction.
  3658                 }
  3715                 }
  3659 
  3716 
  3660             visibleChange = CMPXDbActiveTask::ESingleVisible;
  3717             visibleChange = CMPXDbActiveTask::ESingleVisible;
  3661             }
  3718             }
  3662             break;
  3719             break;
  3663 
  3720 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
       
  3721         case EMPXAbstractAlbum:
       
  3722             {
       
  3723             visibleChange = iDbHandler->UpdateAbstractAlbumSongsL(aMedia, aMessageArray);
       
  3724             }
       
  3725             break;
       
  3726 #endif // ABSTRACTAUDIOALBUM_INCLUDED
  3664         case EMPXSong:
  3727         case EMPXSong:
  3665             {
  3728             {
  3666             // a list of changed messages as a result of the song being updated
  3729             // a list of changed messages as a result of the song being updated
  3667             visibleChange = iDbHandler->UpdateSongL(aMedia, aMessageArray);
  3730             visibleChange = iDbHandler->UpdateSongL(aMedia, aMessageArray);
  3668             }
  3731             }
  4307                 aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic, EMPXMediaMusicAlbumArtFileName ) );
  4370                 aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic, EMPXMediaMusicAlbumArtFileName ) );
  4308                 aSupportedIds.AppendL( KMPXMediaIdMusic );
  4371                 aSupportedIds.AppendL( KMPXMediaIdMusic );
  4309                 break;
  4372                 break;
  4310                 }
  4373                 }
  4311             case EBrowseAlbum:
  4374             case EBrowseAlbum:
  4312             	{
  4375                 {
  4313 
  4376 
  4314                 aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
  4377                 aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
  4315                     EMPXMediaMusicArtist | EMPXMediaMusicAlbum | EMPXMediaMusicAlbumArtFileName ) );
  4378                     EMPXMediaMusicArtist | EMPXMediaMusicAlbum | EMPXMediaMusicAlbumArtFileName ) );
  4316                 aSupportedIds.AppendL( KMPXMediaIdMusic );
  4379                 aSupportedIds.AppendL( KMPXMediaIdMusic );
  4317                 break;
  4380                 break;
  4318 				}
  4381                 }
  4319             case EBrowsePlaylist:
  4382             case EBrowsePlaylist:
  4320             case EBrowseGenre:
  4383             case EBrowseGenre:
  4321             case EBrowseComposer:
  4384             case EBrowseComposer:
  4322                 {
  4385                 {
  4323                 aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,
  4386                 aAttrs.AppendL( TMPXAttribute(KMPXMediaIdMusic,