mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbhandler.cpp
branchRCL_3
changeset 17 c8156a91d13c
parent 15 171e07ac910f
child 18 c54d95799c80
equal deleted inserted replaced
15:171e07ac910f 17:c8156a91d13c
   116     delete iDbAlbum;
   116     delete iDbAlbum;
   117     delete iDbGenre;
   117     delete iDbGenre;
   118     delete iDbComposer;
   118     delete iDbComposer;
   119     delete iDbAuxiliary;
   119     delete iDbAuxiliary;
   120     delete iDbManager;
   120     delete iDbManager;
   121 
   121 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
       
   122     delete iDbAbstractAlbum;
       
   123 #endif // ABSTRACTAUDIOALBUM_INCLUDED
   122     delete iMimeTypes;
   124     delete iMimeTypes;
   123     delete iExtensions;
   125     delete iExtensions;
   124     delete iExtensionsMime;
   126     delete iExtensionsMime;
   125     delete iExtensionsDrm;
   127     delete iExtensionsDrm;
   126 
   128 
   171     // Create the db infrastructure,
   173     // Create the db infrastructure,
   172     //
   174     //
   173     iDbMusic = CMPXDbMusic::NewL(*iDbManager, iResource, *this);
   175     iDbMusic = CMPXDbMusic::NewL(*iDbManager, iResource, *this);
   174     iDbPlaylist = CMPXDbPlaylist::NewL(*iDbManager, *this);
   176     iDbPlaylist = CMPXDbPlaylist::NewL(*iDbManager, *this);
   175     iDbArtist = CMPXDbArtist::NewL(*iDbManager, EMPXArtist, *this);
   177     iDbArtist = CMPXDbArtist::NewL(*iDbManager, EMPXArtist, *this);
   176 	iDbAlbum = CMPXDbAlbum::NewL(*iDbManager, EMPXAlbum, *this);
   178     iDbAlbum = CMPXDbAlbum::NewL(*iDbManager, EMPXAlbum, *this);
   177     iDbGenre = CMPXDbGenre::NewL(*iDbManager, EMPXGenre);
   179     iDbGenre = CMPXDbGenre::NewL(*iDbManager, EMPXGenre);
   178     iDbComposer = CMPXDbComposer::NewL(*iDbManager, EMPXComposer);
   180     iDbComposer = CMPXDbComposer::NewL(*iDbManager, EMPXComposer);
       
   181 #ifdef ABSTRACTAUDIOALBUM_INCLUDED  
       
   182     iDbAbstractAlbum = CMPXDbAbstractAlbum::NewL(*iDbManager, EMPXAbstractAlbum);
       
   183 #endif // ABSTRACTAUDIOALBUM_INCLUDED 
   179     iAutoPlaylist = CMPXDbAutoPlaylist::NewL(*iDbManager, iFs, iResource);
   184     iAutoPlaylist = CMPXDbAutoPlaylist::NewL(*iDbManager, iFs, iResource);
   180     iDbAuxiliary = CMPXDbAuxiliary::NewL(*iDbManager);
   185     iDbAuxiliary = CMPXDbAuxiliary::NewL(*iDbManager);
   181 
   186 
   182     MPX_TRAPD(err, iDbManager->InitDatabasesL(iDbDrives));
   187     MPX_TRAPD(err, iDbManager->InitDatabasesL(iDbDrives));
   183     iCollectionOpen = ETrue;
   188     iCollectionOpen = ETrue;
   297     EndTransactionL(err);
   302     EndTransactionL(err);
   298 
   303 
   299     return playlistId;
   304     return playlistId;
   300     }
   305     }
   301 
   306 
       
   307 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
       
   308 // ----------------------------------------------------------------------------
       
   309 // Add AbstractAlbum to collection
       
   310 // ----------------------------------------------------------------------------
       
   311 //
       
   312 TUint32 CMPXDbHandler::AddAbstractAlbumL(
       
   313     const CMPXMedia& aMedia,
       
   314     CMPXMessageArray* aMessageArray)
       
   315     {
       
   316     MPX_FUNC("CMPXDbHandler::AddAbstractAlbumL");
       
   317 
       
   318     BeginTransactionL();
       
   319    // TUint32 abstractAlbumId(0);
       
   320     TBool newRecord(EFalse);
       
   321     TInt err(KErrNone);
       
   322 
       
   323     TDriveUnit drive(aMedia.ValueText(KMPXMediaGeneralUri));
       
   324     TPtrC name(aMedia.ValueText(KMPXMediaGeneralUri).Left(KMCMaxTextLen));
       
   325     TPtrC albumartist(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen));
       
   326     TPtrC genre(aMedia.ValueText(KMPXMediaMusicGenre).Left(KMCMaxTextLen));
       
   327     
       
   328     //only insert to AbstractAlbum table when it is new item  
       
   329      TUint32 abstractAlbumId(MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXAbstractAlbum, name, (EMPXAbstractAlbum!=EMPXGenre)));      
       
   330    
       
   331     newRecord = !iDbAbstractAlbum->CategoryItemExistsL(drive, abstractAlbumId);
       
   332    
       
   333     
       
   334     if (newRecord)   
       
   335         {
       
   336         MPX_TRAP(err, abstractAlbumId = iDbAbstractAlbum->AddItemL( name, albumartist, genre, drive, newRecord, (EMPXAbstractAlbum != EMPXGenre)));      
       
   337         if (iOutOfDisk && (err == KErrNotFound))
       
   338             {
       
   339             err = KErrDiskFull;
       
   340             }
       
   341         if (aMessageArray)
       
   342             {
       
   343             MPXDbCommonUtil::AddItemChangedMessageL(*aMessageArray, abstractAlbumId, EMPXItemInserted,
       
   344             EMPXAbstractAlbum, KDBPluginUid);
       
   345             }
       
   346         }
       
   347     EndTransactionL(err);
       
   348 
       
   349     return abstractAlbumId;  
       
   350     }
       
   351 
       
   352 // ----------------------------------------------------------------------------
       
   353 // Update all songs which associate with AbstractAlbum in the collection
       
   354 // ----------------------------------------------------------------------------
       
   355 //
       
   356 CMPXDbActiveTask::TChangeVisibility CMPXDbHandler::UpdateAbstractAlbumSongsL(
       
   357     const CMPXMedia& aMedia,
       
   358     CMPXMessageArray& aItemChangedMessages)
       
   359     {
       
   360     MPX_FUNC("CMPXDbHandler::UpdateAbstractAlbumSongsL");
       
   361 
       
   362     CMPXDbActiveTask::TChangeVisibility visibleChange(CMPXDbActiveTask::ENotVisibile);
       
   363 
       
   364     if (aMedia.IsSupported(KMPXMediaGeneralUri))
       
   365         {
       
   366         const TDesC& art(aMedia.ValueText (KMPXMediaGeneralUri));
       
   367     
       
   368         TBool existRecord(EFalse); 
       
   369         TDriveUnit drive(aMedia.ValueText(KMPXMediaGeneralUri));
       
   370         TUint32 rowId(MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXAbstractAlbum, art, (EMPXAbstractAlbum != EMPXGenre)));    
       
   371         //check if abstractAlbum in ABSTRACTALBUM table before update songs
       
   372         existRecord = iDbAbstractAlbum->CategoryItemExistsL(drive, rowId);
       
   373          
       
   374         //update songs associated with abstractalbum only when abstractalbum associated already
       
   375         //in the AbstractAlbum table     
       
   376         if (existRecord)
       
   377             {         
       
   378             if (aMedia.IsSupported(KMPXMediaArrayContents))
       
   379                 {
       
   380 
       
   381                 CMPXMediaArray* mediaArray = aMedia.Value<CMPXMediaArray>(KMPXMediaArrayContents);
       
   382                 User::LeaveIfNull(mediaArray);
       
   383                 TInt count(mediaArray->Count());
       
   384                 for (TInt i = 0; i < count; i++)
       
   385                     {
       
   386                     CMPXMedia* element = mediaArray->AtL(i);
       
   387                     element->SetTextValueL(KMPXMediaMusicAlbumArtFileName, art );
       
   388                     visibleChange = UpdateSongL(*element, aItemChangedMessages);
       
   389                     }
       
   390                }
       
   391             else
       
   392                 {
       
   393                 iDbAbstractAlbum->UpdateItemL(rowId, aMedia, drive, &aItemChangedMessages);
       
   394                 }
       
   395           }
       
   396         }
       
   397     return visibleChange;
       
   398 }
       
   399 #endif // ABSTRACTAUDIOALBUM_INCLUDED
   302 // ----------------------------------------------------------------------------
   400 // ----------------------------------------------------------------------------
   303 // Update a song in the collection
   401 // Update a song in the collection
   304 // ----------------------------------------------------------------------------
   402 // ----------------------------------------------------------------------------
   305 //
   403 //
   306 CMPXDbActiveTask::TChangeVisibility CMPXDbHandler::UpdateSongL(
   404 CMPXDbActiveTask::TChangeVisibility CMPXDbHandler::UpdateSongL(
   482         {
   580         {
   483         // only end transaction if there's an error
   581         // only end transaction if there's an error
   484         EndTransactionL( err );
   582         EndTransactionL( err );
   485         }
   583         }
   486     }
   584     }
       
   585 
       
   586 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
       
   587 // ----------------------------------------------------------------------------
       
   588 // Remove specified abstractalbum
       
   589 // ----------------------------------------------------------------------------
       
   590 //
       
   591 void CMPXDbHandler::RemoveAbstractAlbumL(
       
   592     TUint32 aAbstractAlbumId,
       
   593     CDesCArray& aUriArray,
       
   594     CMPXMessageArray& aItemChangedMessages)
       
   595     {
       
   596     MPX_FUNC("CMPXDbHandler::RemoveAbstractAlbumL");
       
   597 
       
   598     BeginTransactionL();
       
   599     MPX_TRAPD(err, DoRemoveAbstractAlbumL(aAbstractAlbumId, aUriArray, aItemChangedMessages));
       
   600     EndTransactionL(err);
       
   601     }
       
   602 
       
   603 // ----------------------------------------------------------------------------
       
   604 // Remove specified abstractalbum
       
   605 // ----------------------------------------------------------------------------
       
   606 //
       
   607 void CMPXDbHandler::DoRemoveAbstractAlbumL(
       
   608     TUint32 aAbstractAlbumId,
       
   609     CDesCArray& aUriArray,
       
   610     CMPXMessageArray& aItemChangedMessages)
       
   611     {
       
   612     MPX_FUNC("CMPXDbHandler::DoRemoveAbstractAlbumL");
       
   613 
       
   614 
       
   615     HBufC* uri(iDbAbstractAlbum->DeleteAbstractAlbumL(aAbstractAlbumId));
       
   616     if (uri)
       
   617         {
       
   618         CleanupStack::PushL(uri);
       
   619         aUriArray.AppendL(*uri);
       
   620         CleanupStack::PopAndDestroy(uri);
       
   621         }
       
   622 
       
   623     MPXDbCommonUtil::AddItemChangedMessageL(aItemChangedMessages, aAbstractAlbumId, EMPXItemDeleted,
       
   624         EMPXAbstractAlbum, KDBPluginUid);
       
   625 
       
   626    
       
   627     }
       
   628 #endif // ABSTRACTAUDIOALBUM_INCLUDED
   487 
   629 
   488 // ----------------------------------------------------------------------------
   630 // ----------------------------------------------------------------------------
   489 // Cleanup records marked as deleted. This is designated for MTP to clean up records marked as deleted
   631 // Cleanup records marked as deleted. This is designated for MTP to clean up records marked as deleted
   490 // at the end of its session.
   632 // at the end of its session.
   491 // ----------------------------------------------------------------------------
   633 // ----------------------------------------------------------------------------
   737     {
   879     {
   738     MPX_FUNC("CMPXDbHandler::GetSongIdMatchingUriL");
   880     MPX_FUNC("CMPXDbHandler::GetSongIdMatchingUriL");
   739     return MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXCollection, aUri, EFalse);
   881     return MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXCollection, aUri, EFalse);
   740     }
   882     }
   741 
   883 
       
   884 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
       
   885 // ----------------------------------------------------------------------------
       
   886 // Get abstractalbum Id matching the given URI
       
   887 // ----------------------------------------------------------------------------
       
   888 //
       
   889 TUint32 CMPXDbHandler::GetAbstractAlbumIdMatchingUriL(
       
   890     const TDesC& aUri)
       
   891     {
       
   892     MPX_FUNC("CMPXDbHandler::GetAbstractAlbumIdMatchingUriL");
       
   893     return MPXDbCommonUtil::GenerateUniqueIdL(iFs, EMPXAbstractAlbum, aUri, ETrue);
       
   894     }
       
   895 #endif // ABSTRACTAUDIOALBUM_INCLUDED
       
   896 
   742 // ----------------------------------------------------------------------------
   897 // ----------------------------------------------------------------------------
   743 // Get all artists
   898 // Get all artists
   744 // ----------------------------------------------------------------------------
   899 // ----------------------------------------------------------------------------
   745 //
   900 //
   746 void CMPXDbHandler::GetAllArtistsL(
   901 void CMPXDbHandler::GetAllArtistsL(
   825             for (TInt i = startIndex; i < albumCount; i++)
   980             for (TInt i = startIndex; i < albumCount; i++)
   826                 {
   981                 {
   827                 CMPXMedia* media = aMediaArray[i];
   982                 CMPXMedia* media = aMediaArray[i];
   828                 TUint32 albumId((media->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)));
   983                 TUint32 albumId((media->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)));
   829 
   984 
   830 				TInt songCount = iDbAlbum->GetSongsCountInAlbumMatchingArtistL(aArtistId, albumId);
   985                 TInt songCount = iDbAlbum->GetSongsCountInAlbumMatchingArtistL(aArtistId, albumId);
   831 
   986 
   832                 media->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount );
   987                 media->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount );
   833 				MPX_DEBUG2("	SongCount[%d]", songCount );
   988                 MPX_DEBUG2("    SongCount[%d]", songCount );
   834                 }
   989                 }
   835             }
   990             }
   836         }
   991         }
   837     }
   992     }
   838 
   993 
  1355             iOutOfDisk = ETrue;
  1510             iOutOfDisk = ETrue;
  1356             }
  1511             }
  1357     }
  1512     }
  1358     
  1513     
  1359 #ifdef __RAMDISK_PERF_ENABLE
  1514 #ifdef __RAMDISK_PERF_ENABLE
  1360 	iDbManager->CopyDBsToRamL();
  1515     iDbManager->CopyDBsToRamL();
  1361 #endif //__RAMDISK_PERF_ENABLE
  1516 #endif //__RAMDISK_PERF_ENABLE
  1362     iDbMusic->RefreshStartL();
  1517     iDbMusic->RefreshStartL();
  1363 
  1518 
  1364     BeginTransactionL();
  1519     BeginTransactionL();
  1365     iRefresh = ETrue;
  1520     iRefresh = ETrue;
  1431     iOpOnDbCount = 0;
  1586     iOpOnDbCount = 0;
  1432     iDbManager->CommitL();
  1587     iDbManager->CommitL();
  1433 
  1588 
  1434 #ifdef __RAMDISK_PERF_ENABLE
  1589 #ifdef __RAMDISK_PERF_ENABLE
  1435     TRAPD(err, iDbManager->CopyDBsFromRamL());
  1590     TRAPD(err, iDbManager->CopyDBsFromRamL());
  1436 	if ( err != KErrNone )
  1591     if ( err != KErrNone )
  1437 	    {
  1592         {
  1438         MPX_DEBUG2("CMPXDbHandler::MtpEndL error=%d", err);
  1593         MPX_DEBUG2("CMPXDbHandler::MtpEndL error=%d", err);
  1439 	    }
  1594         }
  1440 #endif //__RAMDISK_PERF_ENABLE
  1595 #endif //__RAMDISK_PERF_ENABLE
  1441     
  1596     
  1442     MPX_DEBUG1("<--CMPXDbHandler::MtpEndL");
  1597     MPX_DEBUG1("<--CMPXDbHandler::MtpEndL");
  1443     }
  1598     }
  1444 
  1599 
  1944     // Get the song drive
  2099     // Get the song drive
  1945     TUint32 artistID(0);
  2100     TUint32 artistID(0);
  1946     TUint32 albumID(0);
  2101     TUint32 albumID(0);
  1947     TUint32 genreID(0);
  2102     TUint32 genreID(0);
  1948     TUint32 composerID(0);
  2103     TUint32 composerID(0);
       
  2104 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
       
  2105     TUint32 abstractAlbumID(0);
       
  2106 #endif // ABSTRACTAUDIOALBUM_INCLUDED
  1949     TInt drive(0);
  2107     TInt drive(0);
  1950 
  2108 
  1951     // Get information from the Music table first
  2109 // Get information from the Music table first
       
  2110 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
       
  2111     HBufC* uri = iDbMusic->GetSongInfoL(aSongId, artistID, albumID, genreID, composerID, abstractAlbumID, drive);
       
  2112 #else
  1952     HBufC* uri = iDbMusic->GetSongInfoL(aSongId, artistID, albumID, genreID, composerID, drive);
  2113     HBufC* uri = iDbMusic->GetSongInfoL(aSongId, artistID, albumID, genreID, composerID, drive);
       
  2114 #endif // ABSTRACTAUDIOALBUM_INCLUDED
  1953 
  2115 
  1954     // add the URI to the return array
  2116     // add the URI to the return array
  1955     CleanupStack::PushL(uri);
  2117     CleanupStack::PushL(uri);
  1956     aUriArray.AppendL(*uri);
  2118     aUriArray.AppendL(*uri);
  1957     CleanupStack::PopAndDestroy(uri);
  2119     CleanupStack::PopAndDestroy(uri);
  1960     TBool categoryExist( EFalse );
  2122     TBool categoryExist( EFalse );
  1961     iDbArtist->DecrementSongsForCategoryL(artistID, drive, &aItemChangedMessages, categoryExist);
  2123     iDbArtist->DecrementSongsForCategoryL(artistID, drive, &aItemChangedMessages, categoryExist);
  1962     iDbAlbum->DecrementSongsForCategoryL(albumID, drive, &aItemChangedMessages, categoryExist, artistID);
  2124     iDbAlbum->DecrementSongsForCategoryL(albumID, drive, &aItemChangedMessages, categoryExist, artistID);
  1963     iDbGenre->DecrementSongsForCategoryL(genreID, drive, &aItemChangedMessages, categoryExist);
  2125     iDbGenre->DecrementSongsForCategoryL(genreID, drive, &aItemChangedMessages, categoryExist);
  1964     iDbComposer->DecrementSongsForCategoryL(composerID, drive, &aItemChangedMessages, categoryExist);
  2126     iDbComposer->DecrementSongsForCategoryL(composerID, drive, &aItemChangedMessages, categoryExist);
  1965 
  2127 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
       
  2128     if (abstractAlbumID)
       
  2129         {
       
  2130         iDbAbstractAlbum->DecrementSongsForCategoryL(abstractAlbumID, drive, &aItemChangedMessages, categoryExist, iMtpInUse);
       
  2131         }
       
  2132 #endif // ABSTRACTAUDIOALBUM_INCLUDED
  1966     // Update the music table
  2133     // Update the music table
  1967     TBool deleteRecord(ETrue);
  2134     TBool deleteRecord(ETrue);
  1968 
  2135 
  1969 #if defined (__MTP_PROTOCOL_SUPPORT)
  2136 #if defined (__MTP_PROTOCOL_SUPPORT)
  1970     // Mark the song record as deleted if the following is true; otherwise, delete the
  2137     // Mark the song record as deleted if the following is true; otherwise, delete the
  2293         TUint32 playlistId = (cat == EMPXPlaylist) ?
  2460         TUint32 playlistId = (cat == EMPXPlaylist) ?
  2294             id : (containerId & KMCCategoryMask);
  2461             id : (containerId & KMCCategoryMask);
  2295 
  2462 
  2296         GetPlaylistSongsL(playlistId, aAttrs, aMediaArray);
  2463         GetPlaylistSongsL(playlistId, aAttrs, aMediaArray);
  2297         }
  2464         }
  2298 
  2465 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
       
  2466     else if (type == EMPXGroup &&
       
  2467         (cat == EMPXAbstractAlbum ||
       
  2468         MPX_ITEM_CATEGORY(containerId) == EMPXAbstractAlbum))
       
  2469         {
       
  2470         TUint32 abstractAlbumId = (cat == EMPXAbstractAlbum) ?
       
  2471             id : (containerId & KMCCategoryMask);
       
  2472         TInt attrCount(aAttrs.Count());
       
  2473         if ( attrCount > 1 || (attrCount == 1 && !(aAttrs[0] == KMPXMediaGeneralId)) )
       
  2474             {
       
  2475             TInt abstractAlbumDrive(iDbAbstractAlbum->GetDriveIdL(abstractAlbumId));
       
  2476             MPX_TRAPD(err, iDbMusic->GetAllSongsForAbstractAlbumL(abstractAlbumDrive, abstractAlbumId, aAttrs, aMediaArray));
       
  2477         if (err == KErrNotFound)
       
  2478             {
       
  2479             //
       
  2480             // Leave with KErrNotFound
       
  2481             User::Leave(KErrNotFound);
       
  2482             }
       
  2483         else
       
  2484             {
       
  2485             // Leave if error
       
  2486             User::LeaveIfError(err);
       
  2487             }
       
  2488         }
       
  2489     }
       
  2490 #endif // ABSTRACTAUDIOALBUM_INCLUDED
  2299     //////////////////////////////////////////////////////////////////////
  2491     //////////////////////////////////////////////////////////////////////
  2300     // Find a particular song in the specified playlist. This fills the
  2492     // Find a particular song in the specified playlist. This fills the
  2301     // song with info from Playlist table first then overwrites it with
  2493     // song with info from Playlist table first then overwrites it with
  2302     // info from Songs table if Songs table where this song is located
  2494     // info from Songs table if Songs table where this song is located
  2303     // is present in order to support the display of song titles in a
  2495     // is present in order to support the display of song titles in a
  2658         case EMPXComposer:
  2850         case EMPXComposer:
  2659             {
  2851             {
  2660             dbCategory = (CMPXDbCategory*)iDbComposer;
  2852             dbCategory = (CMPXDbCategory*)iDbComposer;
  2661             break;
  2853             break;
  2662             }
  2854             }
       
  2855 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
       
  2856         case EMPXAbstractAlbum:
       
  2857             {
       
  2858             dbCategory = (CMPXDbCategory*)iDbAbstractAlbum;
       
  2859             break;
       
  2860             }
       
  2861 #endif // ABSTRACTAUDIOALBUM_INCLUDED
  2663         default:
  2862         default:
  2664             User::Leave(KErrNotSupported);
  2863             User::Leave(KErrNotSupported);
  2665         }
  2864         }
  2666 
  2865 
  2667     return dbCategory;
  2866     return dbCategory;
  2832 TUint32 CMPXDbHandler::AddCategoryItemL(
  3031 TUint32 CMPXDbHandler::AddCategoryItemL(
  2833     TMPXGeneralCategory aCategory,
  3032     TMPXGeneralCategory aCategory,
  2834     const TDesC& aName,
  3033     const TDesC& aName,
  2835     TInt aDriveId,
  3034     TInt aDriveId,
  2836     CMPXMessageArray* aItemChangedMessages,
  3035     CMPXMessageArray* aItemChangedMessages,
  2837     TBool& aItemExist)
  3036     TBool& aItemExist
       
  3037 #ifdef ABSTRACTAUDIOALBUM_INCLUDED    
       
  3038       ,const TDesC& aAlbumArtist,
       
  3039     const TDesC& aGenre
       
  3040 #endif // ABSTRACTAUDIOALBUM_INCLUDED
       
  3041     )
  2838     {
  3042     {
  2839     MPX_FUNC("CMPXDbHandler::AddCategoryItemL()");
  3043     MPX_FUNC("CMPXDbHandler::AddCategoryItemL()");
  2840 
  3044 
  2841     MPX_PERF_START(CMPXDbHandler_AddCategoryItemL);
  3045     MPX_PERF_START(CMPXDbHandler_AddCategoryItemL);
  2842 
  3046 
  2843     TBool newRecord(EFalse);
  3047     TBool newRecord(EFalse);
       
  3048 #ifdef ABSTRACTAUDIOALBUM_INCLUDED    
       
  3049     TUint32 id(0);   
       
  3050     //for AbstractAlbum, SetAbstractAlbum, associate songs with abstractalbum.
       
  3051     //only called with newRecord as EFalse
       
  3052     //increment songCount if id exist in AbstractAlbum table, otherwise do nothing.
       
  3053     if (aCategory == EMPXAbstractAlbum)
       
  3054         {     
       
  3055         id = iDbAbstractAlbum->AddItemL( aName, aAlbumArtist, aGenre, aDriveId, newRecord, (aCategory != EMPXGenre));     
       
  3056         }    
       
  3057     else
       
  3058         {
       
  3059         id = DbCategoryL(aCategory)->AddItemL(aName, aDriveId, newRecord, (aCategory != EMPXGenre));
       
  3060 #else 
  2844     TUint32 id(DbCategoryL(aCategory)->AddItemL(aName, aDriveId, newRecord, (aCategory != EMPXGenre)));
  3061     TUint32 id(DbCategoryL(aCategory)->AddItemL(aName, aDriveId, newRecord, (aCategory != EMPXGenre)));
       
  3062 #endif // ABSTRACTAUDIOALBUM_INCLUDED
  2845     if (newRecord && aItemChangedMessages)
  3063     if (newRecord && aItemChangedMessages)
  2846         {
  3064         {
  2847         MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemInserted,
  3065         MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemInserted,
  2848             aCategory, KDBPluginUid);
  3066             aCategory, KDBPluginUid);
  2849         }
  3067         }
  2855         {
  3073         {
  2856         MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemModified,
  3074         MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemModified,
  2857             aCategory, KDBPluginUid);
  3075             aCategory, KDBPluginUid);
  2858         }
  3076         }
  2859     aItemExist = !newRecord;
  3077     aItemExist = !newRecord;
       
  3078 #ifdef ABSTRACTAUDIOALBUM_INCLUDED      
       
  3079        }
       
  3080 #endif // ABSTRACTAUDIOALBUM_INCLUDED
  2860     MPX_PERF_END(CMPXDbHandler_AddCategoryItemL);
  3081     MPX_PERF_END(CMPXDbHandler_AddCategoryItemL);
  2861 
  3082 
  2862     return id;
  3083     return id;
  2863     }
  3084     }
  2864 
  3085 
  2893             aCategory, KDBPluginUid);
  3114             aCategory, KDBPluginUid);
  2894         }
  3115         }
  2895     // when the added item's category is Artist, and it is NOT a new record,
  3116     // when the added item's category is Artist, and it is NOT a new record,
  2896     // we should send the item number changed message
  3117     // we should send the item number changed message
  2897     else if (  aCategory == EMPXArtist &&
  3118     else if (  aCategory == EMPXArtist &&
  2898     		!newRecord && aItemChangedMessages )
  3119             !newRecord && aItemChangedMessages )
  2899         {
  3120         {
  2900         MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemModified,
  3121         MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, id, EMPXItemModified,
  2901             aCategory, KDBPluginUid);
  3122             aCategory, KDBPluginUid);
  2902         }
  3123         }
  2903     aItemExist = !newRecord;
  3124     aItemExist = !newRecord;
  2904     MPX_PERF_END(CMPXDbHandler_AddCategoryItemL);
  3125     MPX_PERF_END(CMPXDbHandler_AddCategoryItemL);
  2905 
  3126 
  2906     return id;
  3127     return id;
  2907 	}
  3128     }
  2908 
  3129 
  2909 void CMPXDbHandler::UpdateCategoryItemL(
  3130 void CMPXDbHandler::UpdateCategoryItemL(
  2910 		TMPXGeneralCategory aCategory,
  3131         TMPXGeneralCategory aCategory,
  2911 		TUint32 aCategoryId,
  3132         TUint32 aCategoryId,
  2912 		const CMPXMedia& aMedia,
  3133         const CMPXMedia& aMedia,
  2913 		TInt aDrive,
  3134         TInt aDrive,
  2914 		CMPXMessageArray* aItemChangedMessages)
  3135         CMPXMessageArray* aItemChangedMessages)
  2915 	{
  3136     {
  2916 	switch(aCategory)
  3137     switch(aCategory)
  2917 	    {
  3138         {
  2918 	    case EMPXAlbum:
  3139         case EMPXAlbum:
  2919             iDbAlbum->UpdateItemL(aCategoryId, aMedia, aDrive, aItemChangedMessages);
  3140             iDbAlbum->UpdateItemL(aCategoryId, aMedia, aDrive, aItemChangedMessages);
  2920 	        break;
  3141             break;
  2921 
  3142 
  2922 	    case EMPXArtist:
  3143         case EMPXArtist:
  2923 	        iDbArtist->UpdateItemL(aCategoryId, aMedia, aDrive, aItemChangedMessages);
  3144             iDbArtist->UpdateItemL(aCategoryId, aMedia, aDrive, aItemChangedMessages);
  2924 	        break;
  3145             break;
  2925 
  3146 
  2926 	    default:
  3147         default:
  2927             DbCategoryL(aCategory)->UpdateItemL(aCategoryId, aMedia, aDrive, aItemChangedMessages);
  3148             DbCategoryL(aCategory)->UpdateItemL(aCategoryId, aMedia, aDrive, aItemChangedMessages);
  2928 	        break;
  3149             break;
  2929 	    }
  3150         }
  2930 	}
  3151     }
  2931 // ----------------------------------------------------------------------------
  3152 // ----------------------------------------------------------------------------
  2932 // CMPXDbHandler::DeleteSongForCategoryL
  3153 // CMPXDbHandler::DeleteSongForCategoryL
  2933 // ----------------------------------------------------------------------------
  3154 // ----------------------------------------------------------------------------
  2934 //
  3155 //
  2935 void CMPXDbHandler::DeleteSongForCategoryL(
  3156 void CMPXDbHandler::DeleteSongForCategoryL(
  2991     {
  3212     {
  2992     return iDbManager->IsRemoteDrive(aDrive);
  3213     return iDbManager->IsRemoteDrive(aDrive);
  2993     }
  3214     }
  2994 
  3215 
  2995 TInt CMPXDbHandler::HandlePlaylistDurationL(TUint32 aPlaylistId)
  3216 TInt CMPXDbHandler::HandlePlaylistDurationL(TUint32 aPlaylistId)
  2996 	{
  3217     {
  2997 	return GetPlaylistDurationL(aPlaylistId);
  3218     return GetPlaylistDurationL(aPlaylistId);
  2998 	}
  3219     }
  2999 void CMPXDbHandler::HandlePlaylistInfoL(
  3220 void CMPXDbHandler::HandlePlaylistInfoL(
  3000     TUint32 aPlaylistId, 
  3221     TUint32 aPlaylistId, 
  3001     TInt& aCount, 
  3222     TInt& aCount, 
  3002     TInt& aDuration)
  3223     TInt& aDuration)
  3003     {
  3224     {
  3027     CleanupStack::PopAndDestroy(mediaArray);
  3248     CleanupStack::PopAndDestroy(mediaArray);
  3028     CleanupStack::PopAndDestroy(&attributes);        
  3249     CleanupStack::PopAndDestroy(&attributes);        
  3029     }
  3250     }
  3030 
  3251 
  3031 TInt CMPXDbHandler::HandleGetAlbumsCountForArtistL(TUint32 aArtistId)
  3252 TInt CMPXDbHandler::HandleGetAlbumsCountForArtistL(TUint32 aArtistId)
  3032 	{
  3253     {
  3033 	return iDbAlbum->GetAlbumsCountForArtistL(aArtistId);
  3254     return iDbAlbum->GetAlbumsCountForArtistL(aArtistId);
  3034 	}
  3255     }
  3035 
  3256 
  3036 TBool CMPXDbHandler::HandleIsUnknownArtistL(TUint32 aArtistId)
  3257 TBool CMPXDbHandler::HandleIsUnknownArtistL(TUint32 aArtistId)
  3037     {
  3258     {
  3038     return iDbArtist->IsUnknownArtistL(aArtistId);
  3259     return iDbArtist->IsUnknownArtistL(aArtistId);
  3039     }
  3260     }
  3040 
  3261 
  3041 TUint32 CMPXDbHandler::HandleArtistForAlbumL(const TUint32 aAlbumId)
  3262 TUint32 CMPXDbHandler::HandleArtistForAlbumL(const TUint32 aAlbumId)
  3042     {
  3263     {
  3043     return iDbMusic->ArtistForAlbumL(aAlbumId);
  3264     return iDbMusic->ArtistForAlbumL(aAlbumId);
  3044     }
  3265     }
       
  3266 #ifdef ABSTRACTAUDIOALBUM_INCLUDED   
       
  3267 // ----------------------------------------------------------------------------------------------------------
       
  3268 // CMPXDbHandler::HandleGetAlbumNameForSongL
       
  3269 // ----------------------------------------------------------------------------------------------------------
       
  3270 // 
       
  3271 HBufC* CMPXDbHandler::HandleGetAlbumNameFromIdL(TUint32 aId)
       
  3272     {
       
  3273     return iDbAbstractAlbum->GetNameL(aId);
       
  3274     }
       
  3275 #endif // ABSTRACTAUDIOALBUM_INCLUDED
  3045 // End of file
  3276 // End of file