31 #include "mpxdbpluginqueries.h" |
31 #include "mpxdbpluginqueries.h" |
32 #include "mpxdbutil.h" |
32 #include "mpxdbutil.h" |
33 #include "mpxdbalbum.h" |
33 #include "mpxdbalbum.h" |
34 |
34 |
35 // CONSTANTS |
35 // CONSTANTS |
|
36 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
37 _LIT( KAbstractAlbumExt, ".alb" ); |
|
38 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
36 |
39 |
37 // ============================ MEMBER FUNCTIONS ============================== |
40 // ============================ MEMBER FUNCTIONS ============================== |
38 |
41 |
39 // ---------------------------------------------------------------------------- |
42 // ---------------------------------------------------------------------------- |
40 // Two-phased constructor. |
43 // Two-phased constructor. |
250 HBufC* setStr = HBufC::NewLC(KFormatArtistId().Length() + KMCIntegerLen); |
253 HBufC* setStr = HBufC::NewLC(KFormatArtistId().Length() + KMCIntegerLen); |
251 setStr->Des().Format(KFormatArtistId, newArtistId); |
254 setStr->Des().Format(KFormatArtistId, newArtistId); |
252 |
255 |
253 iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, aId); |
256 iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, aId); |
254 CleanupStack::PopAndDestroy(setStr); |
257 CleanupStack::PopAndDestroy(setStr); |
255 |
258 itemModified = ETrue; |
256 if (aItemChangedMessages) |
|
257 { |
|
258 // add the item changed message |
|
259 MPXDbCommonUtil::AddItemAlbumChangedMessageL(*aItemChangedMessages, aId, EMPXItemModified, |
|
260 EMPXAlbum, KDBPluginUid, ETrue, 0 ); |
|
261 } |
|
262 } |
259 } |
263 } |
260 } |
|
261 |
|
262 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
263 TBool nonEmbeddedArt = EFalse; |
|
264 if (aArt.Length()>0) |
|
265 { |
|
266 TParsePtrC parse(aArt); |
|
267 TPtrC ext(parse.Ext()); |
|
268 //set flag to false, so .alb will not overwrite art field in album, artist table |
|
269 // when song with embedded art |
|
270 if (ext.CompareF(KAbstractAlbumExt)== 0) |
|
271 { |
|
272 nonEmbeddedArt = ETrue; |
|
273 } |
|
274 } |
|
275 if (!nonEmbeddedArt) |
|
276 { |
|
277 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
278 TPtrC art(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumArt)); |
|
279 // the current art is equal to deleted song's art |
|
280 if(aArt.Length()>0 && art.Length()>0 && aArt.CompareF(art) ==0 ) |
|
281 { |
|
282 MPX_DEBUG2("AlbumArt of the Song to be deleted is [%S]", &aArt); |
|
283 |
|
284 //need to get alternative art in the same album to display |
|
285 HBufC* newArt = AlbumartForAlbumL(aId, aArt); |
|
286 CleanupStack::PushL(newArt); |
|
287 |
|
288 //update Album table only if alternative albumart found |
|
289 if (newArt) |
|
290 { |
|
291 MPX_DEBUG1("CMPXDbAlbum::DecrementSongsForCategoryL, get newArt"); |
|
292 HBufC* artReplaceSingleQuote = MPXDbCommonUtil::ProcessSingleQuotesLC( *newArt ); |
|
293 _LIT( KFormatArt, "Art=\'%S\'" ); |
|
294 HBufC* setStr = HBufC::NewLC(256); |
|
295 setStr->Des().Format( KFormatArt, artReplaceSingleQuote ); |
|
296 |
|
297 iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, aId); |
|
298 CleanupStack::PopAndDestroy(setStr); |
|
299 CleanupStack::PopAndDestroy(artReplaceSingleQuote); |
|
300 itemModified = ETrue; |
|
301 } |
|
302 CleanupStack::PopAndDestroy(newArt); |
|
303 } |
|
304 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
305 } |
|
306 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
307 if (aItemChangedMessages && itemModified) |
|
308 { |
|
309 // add the item changed message |
|
310 MPXDbCommonUtil::AddItemAlbumChangedMessageL(*aItemChangedMessages, aId, EMPXItemModified, |
|
311 EMPXAlbum, KDBPluginUid, ETrue, 0 ); |
|
312 } |
|
313 CleanupStack::PopAndDestroy(&recordset); |
264 |
314 |
265 // decrement the number of songs for the category |
315 // decrement the number of songs for the category |
266 query = PreProcessStringLC(KQueryCategoryDecrementSongCount); |
316 query = PreProcessStringLC(KQueryCategoryDecrementSongCount); |
267 iDbManager.ExecuteQueryL(aDriveId, *query, aId); |
317 iDbManager.ExecuteQueryL(aDriveId, *query, aId); |
268 CleanupStack::PopAndDestroy(query); |
318 CleanupStack::PopAndDestroy(query); |
508 { |
558 { |
509 return iObserver.HandleArtistForAlbumL(aId); |
559 return iObserver.HandleArtistForAlbumL(aId); |
510 } |
560 } |
511 |
561 |
512 // ---------------------------------------------------------------------------- |
562 // ---------------------------------------------------------------------------- |
|
563 // CMPXDbAlbum::AlbumartForAlbumL |
|
564 // ---------------------------------------------------------------------------- |
|
565 // |
|
566 HBufC* CMPXDbAlbum::AlbumartForAlbumL(const TUint32 aId, TPtrC aArt) |
|
567 { |
|
568 return iObserver.HandleAlbumartForAlbumL(aId, aArt); |
|
569 } |
|
570 |
|
571 // ---------------------------------------------------------------------------- |
513 // CMPXDbAlbum::CreateTableL |
572 // CMPXDbAlbum::CreateTableL |
514 // ---------------------------------------------------------------------------- |
573 // ---------------------------------------------------------------------------- |
515 // |
574 // |
516 void CMPXDbAlbum::CreateTableL( |
575 void CMPXDbAlbum::CreateTableL( |
517 RSqlDatabase& aDatabase, |
576 RSqlDatabase& aDatabase, |