mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbmusic.cpp
branchRCL_3
changeset 24 26a1709b9fec
parent 21 cb96c29156b2
equal deleted inserted replaced
23:455f89b7fcc5 24:26a1709b9fec
   710 void CMPXDbMusic::ExecuteQueryAllSongsL(const TArray<TMPXAttribute>& aAttrs)
   710 void CMPXDbMusic::ExecuteQueryAllSongsL(const TArray<TMPXAttribute>& aAttrs)
   711     {
   711     {
   712     // Run query and add result media objects to the cache array.
   712     // Run query and add result media objects to the cache array.
   713     MPX_FUNC("CMPXDbMusic::ExecuteQueryAllSongsL");
   713     MPX_FUNC("CMPXDbMusic::ExecuteQueryAllSongsL");
   714 
   714 
   715     RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetAllSongs));
   715     RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetAllSongsMinimum));
   716     CleanupClosePushL(recordset);
   716     CleanupClosePushL(recordset);
   717 
   717 
   718     TInt err(KErrNone);
   718     TInt err(KErrNone);
   719     while ((err = recordset.Next()) == KSqlAtRow)
   719     while ((err = recordset.Next()) == KSqlAtRow)
   720         {
   720         {
  2116     TUint32 genreId(0);
  2116     TUint32 genreId(0);
  2117     TUint32 composerId(0);
  2117     TUint32 composerId(0);
  2118 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
  2118 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
  2119     TUint32 abstractAlbumId(0);
  2119     TUint32 abstractAlbumId(0);
  2120 #endif // ABSTRACTAUDIOALBUM_INCLUDED
  2120 #endif // ABSTRACTAUDIOALBUM_INCLUDED
       
  2121     //need to get song art for updating art field in Album and Artist tables
       
  2122     TPtrC art(KNullDesC);
  2121     if (aMusicTable)
  2123     if (aMusicTable)
  2122         {
  2124         {
  2123         artistId = aMusicTable->ColumnInt64(EMusicArtist);
  2125         artistId = aMusicTable->ColumnInt64(EMusicArtist);
  2124         albumId = aMusicTable->ColumnInt64(EMusicAlbum);
  2126         albumId = aMusicTable->ColumnInt64(EMusicAlbum);
  2125         genreId = aMusicTable->ColumnInt64(EMusicGenre);
  2127         genreId = aMusicTable->ColumnInt64(EMusicGenre);
  2126         composerId = aMusicTable->ColumnInt64(EMusicComposer);
  2128         composerId = aMusicTable->ColumnInt64(EMusicComposer);
  2127 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
  2129 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
  2128         abstractAlbumId = aMusicTable->ColumnInt64(EMusicAbstractAlbum);
  2130         abstractAlbumId = aMusicTable->ColumnInt64(EMusicAbstractAlbum);
  2129 #endif // ABSTRACTAUDIOALBUM_INCLUDED        
  2131 #endif // ABSTRACTAUDIOALBUM_INCLUDED        
       
  2132         art.Set(MPXDbCommonUtil::GetColumnTextL(*aMusicTable, EMusicArt));
  2130         }
  2133         }
  2131 
  2134 
  2132     // update the artist field
  2135     // update the artist field
  2133     TUint32 id(0);
  2136     TUint32 id(0);
  2134     TUint32 artistIdForAlbum(artistId);
  2137     TUint32 artistIdForAlbum(artistId);
  2135     if (UpdateCategoryFieldL(EMPXArtist, aMedia, KMPXMediaMusicArtist, artistId,
  2138     if (UpdateCategoryFieldL(EMPXArtist, aMedia, KMPXMediaMusicArtist, artistId,
  2136         aDrive, aItemChangedMessages, id))
  2139         aDrive, aItemChangedMessages, id, art))
  2137         {
  2140         {
  2138         MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArtist, id);
  2141         MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArtist, id);
  2139         metaDataModified = (aMusicTable != NULL);
  2142         metaDataModified = (aMusicTable != NULL);
  2140         visibleChange = CMPXDbActiveTask::EAllVisible;
  2143         visibleChange = CMPXDbActiveTask::EAllVisible;
  2141         artistIdForAlbum = id;
  2144         artistIdForAlbum = id;
  2142         }
  2145         }
  2143 
  2146 
  2144     // update the album field
  2147     // update the album field
  2145     if (UpdateCategoryFieldL(EMPXAlbum, aMedia, KMPXMediaMusicAlbum, albumId,
  2148     if (UpdateCategoryFieldL(EMPXAlbum, aMedia, KMPXMediaMusicAlbum, albumId,
  2146         aDrive, aItemChangedMessages, id))
  2149         aDrive, aItemChangedMessages, id, art))
  2147         {
  2150         {
  2148         MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicAlbum, id);
  2151         MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicAlbum, id);
  2149         metaDataModified = (aMusicTable != NULL);
  2152         metaDataModified = (aMusicTable != NULL);
  2150         visibleChange = CMPXDbActiveTask::EAllVisible;
  2153         visibleChange = CMPXDbActiveTask::EAllVisible;
  2151 
  2154 
  2427     // Create the table
  2430     // Create the table
  2428     User::LeaveIfError(aDatabase.Exec(KMusicCreateTable));
  2431     User::LeaveIfError(aDatabase.Exec(KMusicCreateTable));
  2429 
  2432 
  2430     // Do not create any other indexes than the one on UniqueId
  2433     // Do not create any other indexes than the one on UniqueId
  2431     // as they only slow down the database overall
  2434     // as they only slow down the database overall
       
  2435     User::LeaveIfError(aDatabase.Exec(KMusicDeletedTitleIndex));
  2432     }
  2436     }
  2433 
  2437 
  2434 // ----------------------------------------------------------------------------
  2438 // ----------------------------------------------------------------------------
  2435 // CMPXDbMusic::DropTableL
  2439 // CMPXDbMusic::DropTableL
  2436 // ----------------------------------------------------------------------------
  2440 // ----------------------------------------------------------------------------
  2462     const CMPXMedia& aMedia,
  2466     const CMPXMedia& aMedia,
  2463     const TMPXAttribute& aAttribute,
  2467     const TMPXAttribute& aAttribute,
  2464     TUint32 aOldId,
  2468     TUint32 aOldId,
  2465     TInt aDriveId,
  2469     TInt aDriveId,
  2466     CMPXMessageArray* aItemChangedMessages,
  2470     CMPXMessageArray* aItemChangedMessages,
  2467     TUint32& aItemId)
  2471     TUint32& aItemId, const TDesC& aArt)
  2468     {
  2472     {
  2469     TBool updated(EFalse);
  2473     TBool updated(EFalse);
  2470     TBool itemNotRemoved( EFalse );
  2474     TBool itemNotRemoved( EFalse );
  2471     TBool itemAdded( EFalse );
  2475     TBool itemAdded( EFalse );
  2472 
  2476 
  2547                         if (aMedia.IsSupported(KMPXMediaMusicArtist))
  2551                         if (aMedia.IsSupported(KMPXMediaMusicArtist))
  2548                             {
  2552                             {
  2549                             artistname.Set(aMedia.ValueText(KMPXMediaMusicArtist).Left(KMCMaxTextLen));
  2553                             artistname.Set(aMedia.ValueText(KMPXMediaMusicArtist).Left(KMCMaxTextLen));
  2550                             }
  2554                             }
  2551                         }
  2555                         }
  2552                     iObserver.AddCategoryItemL(aCategory, name, artistname, art, aDriveId, aItemChangedMessages, itemAdded);
  2556                     //for the update case, need to maitain art field for Artist/Album table.
       
  2557                     if (aOldId && (aOldId != aItemId))
       
  2558                        {
       
  2559                        iObserver.AddCategoryItemL(aCategory, name, artistname, aArt, aDriveId, aItemChangedMessages, itemAdded);  
       
  2560                        } 
       
  2561                     else
       
  2562                        {      
       
  2563                        iObserver.AddCategoryItemL(aCategory, name, artistname, art, aDriveId, aItemChangedMessages, itemAdded);
       
  2564                        }
  2553                     }
  2565                     }
  2554                 else
  2566                 else
  2555                     {
  2567                     {
  2556                     // ignore the return value
  2568                     // ignore the return value
  2557                     iObserver.AddCategoryItemL(aCategory, name, aDriveId,
  2569                     iObserver.AddCategoryItemL(aCategory, name, aDriveId,