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); |
286 CleanupClosePushL(recordset); |
336 CleanupClosePushL(recordset); |
287 ProcessRecordsetL(aAttrs, recordset, aMediaArray); |
337 ProcessRecordsetL(aAttrs, recordset, aMediaArray); |
288 CleanupStack::PopAndDestroy(&recordset); |
338 CleanupStack::PopAndDestroy(&recordset); |
289 } |
339 } |
290 |
340 |
|
341 // ---------------------------------------------------------------------------- |
|
342 // CMPXDbAlbum::GetAllCategoryItemsMediaWallL |
|
343 // ---------------------------------------------------------------------------- |
|
344 // |
|
345 void CMPXDbAlbum::GetAllCategoryItemsMediaWallL( |
|
346 const TArray<TMPXAttribute>& aAttrs, |
|
347 CMPXMediaArray& aMediaArray) |
|
348 { |
|
349 MPX_FUNC("CMPXDbAlbum::GetAllCategoryItemsL"); |
|
350 |
|
351 HBufC* query = PreProcessStringLC(KQueryAlbumAllMediaWall); |
|
352 RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query)); |
|
353 CleanupStack::PopAndDestroy(query); |
|
354 |
|
355 CleanupClosePushL(recordset); |
|
356 ProcessRecordsetL(aAttrs, recordset, aMediaArray); |
|
357 CleanupStack::PopAndDestroy(&recordset); |
|
358 } |
291 // ---------------------------------------------------------------------------- |
359 // ---------------------------------------------------------------------------- |
292 // CMPXDbAlbum::UpdateItemL |
360 // CMPXDbAlbum::UpdateItemL |
293 // ---------------------------------------------------------------------------- |
361 // ---------------------------------------------------------------------------- |
294 // |
362 // |
295 void CMPXDbAlbum::UpdateItemL( |
363 void CMPXDbAlbum::UpdateItemL( |
508 { |
576 { |
509 return iObserver.HandleArtistForAlbumL(aId); |
577 return iObserver.HandleArtistForAlbumL(aId); |
510 } |
578 } |
511 |
579 |
512 // ---------------------------------------------------------------------------- |
580 // ---------------------------------------------------------------------------- |
|
581 // CMPXDbAlbum::AlbumartForAlbumL |
|
582 // ---------------------------------------------------------------------------- |
|
583 // |
|
584 HBufC* CMPXDbAlbum::AlbumartForAlbumL(const TUint32 aId, TPtrC aArt) |
|
585 { |
|
586 return iObserver.HandleAlbumartForAlbumL(aId, aArt); |
|
587 } |
|
588 |
|
589 // ---------------------------------------------------------------------------- |
513 // CMPXDbAlbum::CreateTableL |
590 // CMPXDbAlbum::CreateTableL |
514 // ---------------------------------------------------------------------------- |
591 // ---------------------------------------------------------------------------- |
515 // |
592 // |
516 void CMPXDbAlbum::CreateTableL( |
593 void CMPXDbAlbum::CreateTableL( |
517 RSqlDatabase& aDatabase, |
594 RSqlDatabase& aDatabase, |