|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Responsible for interation with the category tables: |
|
15 * Artist, Album, Genre and Composer |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <sqldb.h> |
|
22 |
|
23 #include <mpxlog.h> |
|
24 |
|
25 #include "mpxdbcommonutil.h" |
|
26 #include "mpxdbcommondef.h" |
|
27 #include "mpxdbmanager.h" |
|
28 |
|
29 #include "mpxcollectiondbdef.h" |
|
30 #include "mpxmediamusicdefs.h" |
|
31 #include "mpxdbpluginqueries.h" |
|
32 #include "mpxdbutil.h" |
|
33 #include "mpxdbalbum.h" |
|
34 |
|
35 // CONSTANTS |
|
36 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
37 _LIT( KAbstractAlbumExt, ".alb" ); |
|
38 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
39 |
|
40 _LIT( KAlbumAlbumArtistSeperator, "\t1"); |
|
41 _LIT( KAlbumArtistSeperator, "\t2"); |
|
42 |
|
43 const TInt KUnknownAlbumsGranularity = 250; |
|
44 |
|
45 // ============================ MEMBER FUNCTIONS ============================== |
|
46 |
|
47 // ---------------------------------------------------------------------------- |
|
48 // Two-phased constructor. |
|
49 // ---------------------------------------------------------------------------- |
|
50 // |
|
51 CMPXDbAlbum* CMPXDbAlbum::NewL( |
|
52 CMPXDbManager& aDbManager, |
|
53 TMPXGeneralCategory aCategory, |
|
54 MMPXDbAlbumObserver& aObserver) |
|
55 { |
|
56 MPX_FUNC("CMPXDbAlbum::NewL"); |
|
57 |
|
58 CMPXDbAlbum* self = CMPXDbAlbum::NewLC(aDbManager, aCategory, aObserver); |
|
59 CleanupStack::Pop(self); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // ---------------------------------------------------------------------------- |
|
64 // Two-phased constructor. |
|
65 // ---------------------------------------------------------------------------- |
|
66 // |
|
67 CMPXDbAlbum* CMPXDbAlbum::NewLC( |
|
68 CMPXDbManager& aDbManager, |
|
69 TMPXGeneralCategory aCategory, |
|
70 MMPXDbAlbumObserver& aObserver) |
|
71 { |
|
72 MPX_FUNC("CMPXDbAlbum::NewLC"); |
|
73 |
|
74 CMPXDbAlbum* self = new (ELeave) CMPXDbAlbum(aDbManager, aCategory, aObserver); |
|
75 CleanupStack::PushL(self); |
|
76 self->ConstructL(); |
|
77 return self; |
|
78 } |
|
79 |
|
80 // ---------------------------------------------------------------------------- |
|
81 // Destructor |
|
82 // ---------------------------------------------------------------------------- |
|
83 // |
|
84 CMPXDbAlbum::~CMPXDbAlbum() |
|
85 { |
|
86 MPX_FUNC("CMPXDbAlbum::~CMPXDbAlbum"); |
|
87 |
|
88 iUnknownArtists.ResetAndDestroy(); |
|
89 iUnknownAlbums.ResetAndDestroy(); |
|
90 } |
|
91 |
|
92 // ---------------------------------------------------------------------------- |
|
93 // Constructor |
|
94 // ---------------------------------------------------------------------------- |
|
95 // |
|
96 CMPXDbAlbum::CMPXDbAlbum( |
|
97 CMPXDbManager& aDbManager, |
|
98 TMPXGeneralCategory aCategory, |
|
99 MMPXDbAlbumObserver& aObserver) : |
|
100 CMPXDbCategory(aDbManager, aCategory), |
|
101 iObserver(aObserver), |
|
102 iUnknownArtists(KUnknownAlbumsGranularity), |
|
103 iUnknownAlbums(KUnknownAlbumsGranularity) |
|
104 { |
|
105 MPX_FUNC("CMPXDbAlbum::CMPXDbAlbum"); |
|
106 } |
|
107 |
|
108 // ---------------------------------------------------------------------------- |
|
109 // Second phase constructor. |
|
110 // ---------------------------------------------------------------------------- |
|
111 // |
|
112 void CMPXDbAlbum::ConstructL() |
|
113 { |
|
114 MPX_FUNC("CMPXDbAlbum::ConstructL"); |
|
115 |
|
116 BaseConstructL(); |
|
117 } |
|
118 |
|
119 // ---------------------------------------------------------------------------- |
|
120 // CMPXDbAlbum::AddItemL |
|
121 // ---------------------------------------------------------------------------- |
|
122 // |
|
123 TUint32 CMPXDbAlbum::AddItemL( |
|
124 TMPXGeneralCategory /*aCategory*/, |
|
125 const CMPXMedia& aMedia, |
|
126 TInt aDriveId, |
|
127 TBool& aNewRecord, |
|
128 TBool aCaseSensitive) |
|
129 { |
|
130 MPX_FUNC("CMPXDbAlbum::AddItemL"); |
|
131 |
|
132 TPtrC album(KNullDesC); |
|
133 TPtrC albumArtist(KNullDesC); |
|
134 TPtrC artist(KNullDesC); |
|
135 TPtrC albumArt(KNullDesC); |
|
136 |
|
137 // try to find the item first |
|
138 TUint32 rowId(GenerateUniqueIdL(aMedia)); |
|
139 |
|
140 // retrieve the existing record |
|
141 HBufC* query = PreProcessStringLC(KQueryCategoryItem); |
|
142 RSqlStatement recordset( |
|
143 iDbManager.ExecuteSelectQueryL(aDriveId, *query, rowId)); |
|
144 CleanupStack::PopAndDestroy(query); |
|
145 CleanupClosePushL(recordset); |
|
146 |
|
147 TInt result = recordset.Next(); |
|
148 if (result == KSqlAtEnd) |
|
149 { |
|
150 aNewRecord = result; |
|
151 |
|
152 // check Album attribute |
|
153 if (aMedia.IsSupported(KMPXMediaMusicAlbum)) |
|
154 { |
|
155 album.Set(aMedia.ValueText(KMPXMediaMusicAlbum).Left(KMCMaxTextLen)); |
|
156 } |
|
157 |
|
158 // check AlbumArt attirbute |
|
159 if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName)) |
|
160 { |
|
161 albumArt.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen)); |
|
162 } |
|
163 |
|
164 // insert new |
|
165 HBufC* name = MPXDbCommonUtil::ProcessSingleQuotesLC(album); |
|
166 TUint32 artistId(0); |
|
167 HBufC* artistName = NULL; |
|
168 if (RetrieveAlbumArtistL(aMedia, albumArtist)) |
|
169 { |
|
170 artistId = iObserver.AddAlbumArtistL(albumArtist, albumArt, aDriveId); |
|
171 artistName = MPXDbCommonUtil::ProcessSingleQuotesLC(albumArtist); |
|
172 } |
|
173 else |
|
174 { |
|
175 RetrieveArtist(aMedia, artist); |
|
176 artistId = iObserver.AddAlbumArtistL(artist, albumArt, aDriveId); |
|
177 artistName = MPXDbCommonUtil::ProcessSingleQuotesLC(artist); |
|
178 } |
|
179 |
|
180 HBufC* art = MPXDbCommonUtil::ProcessSingleQuotesLC(albumArt); |
|
181 |
|
182 iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumInsert, rowId, name, 1, artistId, artistName,art); |
|
183 |
|
184 CleanupStack::PopAndDestroy(art); |
|
185 CleanupStack::PopAndDestroy(artistName); |
|
186 CleanupStack::PopAndDestroy(name); |
|
187 } |
|
188 else if (result == KSqlAtRow) |
|
189 { |
|
190 // retrieve Art from Album table |
|
191 TPtrC art(KNullDesC); |
|
192 art.Set(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumArt)); |
|
193 |
|
194 // the current one is Unknown and the new one is Not Unknown |
|
195 if ( art == KNullDesC && albumArt != KNullDesC ) |
|
196 { |
|
197 HBufC* artReplaceSingleQuote = |
|
198 MPXDbCommonUtil::ProcessSingleQuotesLC( albumArt ); |
|
199 |
|
200 TPtrC criteria(KCriterionArt); |
|
201 HBufC* setStr = HBufC::NewLC(criteria.Length() + artReplaceSingleQuote->Length()); |
|
202 setStr->Des().Format( KCriterionArt, artReplaceSingleQuote ); |
|
203 |
|
204 iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, rowId); |
|
205 CleanupStack::PopAndDestroy(setStr); |
|
206 CleanupStack::PopAndDestroy(artReplaceSingleQuote); |
|
207 } |
|
208 |
|
209 // increment the number of songs for the category |
|
210 query = PreProcessStringLC(KQueryCategoryIncrementSongCount); |
|
211 iDbManager.ExecuteQueryL(aDriveId, *query, rowId); |
|
212 CleanupStack::PopAndDestroy(query); |
|
213 } // existing record |
|
214 else |
|
215 { |
|
216 MPX_DEBUG2("SQL error %d", result); |
|
217 User::Leave(result); |
|
218 } |
|
219 |
|
220 CleanupStack::PopAndDestroy(&recordset); |
|
221 |
|
222 return rowId; |
|
223 } |
|
224 |
|
225 // ---------------------------------------------------------------------------- |
|
226 // CMPXDbAlbum::DecrementSongsForAlbumL |
|
227 // ---------------------------------------------------------------------------- |
|
228 // |
|
229 void CMPXDbAlbum::DecrementSongsForAlbumL( |
|
230 const TUint32 aId, |
|
231 TInt aDriveId, |
|
232 CMPXMessageArray* aItemChangedMessages, |
|
233 TBool& aItemExist, |
|
234 const TDesC& aArt) |
|
235 { |
|
236 MPX_FUNC("CMPXDbAlbum::DecrementSongsForAlbumL"); |
|
237 |
|
238 // retrieve the existing record |
|
239 HBufC* query = PreProcessStringLC(KQueryCategoryItem); |
|
240 RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, aId)); |
|
241 CleanupStack::PopAndDestroy(query); |
|
242 |
|
243 CleanupClosePushL(recordset); |
|
244 |
|
245 if (recordset.Next() != KSqlAtRow) |
|
246 { |
|
247 User::Leave(KErrNotFound); |
|
248 } |
|
249 |
|
250 // if just one song uses this category. Use <= just in case |
|
251 if (recordset.ColumnInt64(EAlbumSongCount) <= 1) |
|
252 { |
|
253 aItemExist = EFalse; |
|
254 |
|
255 // Decrement albums count on artist |
|
256 TUint32 albumArtistId = recordset.ColumnInt64(EAlbumArtist); |
|
257 iObserver.DeleteAlbumForArtistL(albumArtistId, aDriveId, aItemChangedMessages); |
|
258 CleanupStack::PopAndDestroy(&recordset); |
|
259 |
|
260 // delete the category |
|
261 DeleteCategoryL(aId, aDriveId); |
|
262 |
|
263 if (aItemChangedMessages) |
|
264 { |
|
265 // add the item changed message |
|
266 MPXDbCommonUtil::AddItemChangedMessageL(*aItemChangedMessages, aId, EMPXItemDeleted, |
|
267 iCategory, KDBPluginUid); |
|
268 } |
|
269 } |
|
270 else |
|
271 { |
|
272 aItemExist = ETrue; |
|
273 |
|
274 TBool itemModified = EFalse; |
|
275 |
|
276 TPtrC art(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumArt)); |
|
277 if (NeedToUpdateArt(aArt, art)) |
|
278 { |
|
279 MPX_DEBUG2("AlbumArt of the Song to be deleted is [%S]", &aArt); |
|
280 |
|
281 //need to get alternative art in the same album to display |
|
282 HBufC* newArt = AlbumartForAlbumL(aId, aArt); |
|
283 CleanupStack::PushL(newArt); |
|
284 |
|
285 //update Album table only if alternative albumart found |
|
286 if (newArt) |
|
287 { |
|
288 MPX_DEBUG1("CMPXDbAlbum::DecrementSongsForAlbumL, get newArt"); |
|
289 HBufC* artReplaceSingleQuote = MPXDbCommonUtil::ProcessSingleQuotesLC( *newArt ); |
|
290 TPtrC criteria(KCriterionArt); |
|
291 HBufC* setStr = HBufC::NewLC(criteria.Length() + artReplaceSingleQuote->Length()); |
|
292 setStr->Des().Format( KCriterionArt, artReplaceSingleQuote ); |
|
293 |
|
294 iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, aId); |
|
295 CleanupStack::PopAndDestroy(setStr); |
|
296 CleanupStack::PopAndDestroy(artReplaceSingleQuote); |
|
297 itemModified = ETrue; |
|
298 } |
|
299 CleanupStack::PopAndDestroy(newArt); |
|
300 } |
|
301 |
|
302 if (aItemChangedMessages && itemModified) |
|
303 { |
|
304 // add the item changed message |
|
305 MPXDbCommonUtil::AddItemAlbumChangedMessageL(*aItemChangedMessages, aId, EMPXItemModified, |
|
306 EMPXAlbum, KDBPluginUid, ETrue, 0 ); |
|
307 } |
|
308 CleanupStack::PopAndDestroy(&recordset); |
|
309 |
|
310 // decrement the number of songs for the category |
|
311 query = PreProcessStringLC(KQueryCategoryDecrementSongCount); |
|
312 iDbManager.ExecuteQueryL(aDriveId, *query, aId); |
|
313 CleanupStack::PopAndDestroy(query); |
|
314 } |
|
315 } |
|
316 |
|
317 // ---------------------------------------------------------------------------- |
|
318 // CMPXDbAlbum::GetAllCategoryItemsL |
|
319 // ---------------------------------------------------------------------------- |
|
320 // |
|
321 void CMPXDbAlbum::GetAllCategoryItemsL( |
|
322 const TArray<TMPXAttribute>& aAttrs, |
|
323 CMPXMediaArray& aMediaArray) |
|
324 { |
|
325 MPX_FUNC("CMPXDbAlbum::GetAllCategoryItemsL"); |
|
326 |
|
327 RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAlbumAll)); |
|
328 |
|
329 CleanupClosePushL(recordset); |
|
330 TRAPD(err, ProcessAlbumRecordSetL(aAttrs, recordset, aMediaArray)); |
|
331 if (err != KErrNone) |
|
332 { |
|
333 iUnknownArtists.ResetAndDestroy(); |
|
334 iUnknownAlbums.ResetAndDestroy(); |
|
335 |
|
336 User::LeaveIfError(err); |
|
337 } |
|
338 CleanupStack::PopAndDestroy(&recordset); |
|
339 } |
|
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 RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryAlbumAllMediaWall)); |
|
352 |
|
353 CleanupClosePushL(recordset); |
|
354 TRAPD(err, ProcessMediaWallAlbumRecordSetL(aAttrs, recordset, aMediaArray)); |
|
355 if (err != KErrNone) |
|
356 { |
|
357 iUnknownArtists.ResetAndDestroy(); |
|
358 iUnknownAlbums.ResetAndDestroy(); |
|
359 |
|
360 User::LeaveIfError(err); |
|
361 } |
|
362 CleanupStack::PopAndDestroy(&recordset); |
|
363 } |
|
364 |
|
365 // ---------------------------------------------------------------------------- |
|
366 // CMPXDbCategory::GetSubCategoryItemsL |
|
367 // ---------------------------------------------------------------------------- |
|
368 // |
|
369 void CMPXDbAlbum::GetSubCategoryItemsL( |
|
370 TMPXGeneralCategory aParentCategory, |
|
371 TUint32 aParentId, |
|
372 const TArray<TMPXAttribute>& aAttrs, |
|
373 CMPXMediaArray& aMediaArray) |
|
374 { |
|
375 MPX_FUNC("CMPXDbCategory::GetSubCategoryItemsL"); |
|
376 |
|
377 // this is only valid for albums belonging to an artist |
|
378 ASSERT((iCategory == EMPXAlbum) && (aParentCategory == EMPXArtist)); |
|
379 |
|
380 // to handle the UREL warning |
|
381 (void)aParentCategory; |
|
382 |
|
383 RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(KQueryMusicGetAlbumsforArtist, aParentId)); |
|
384 CleanupClosePushL(recordset); |
|
385 ProcessAlbumRecordSetL(aAttrs, recordset, aMediaArray); |
|
386 CleanupStack::PopAndDestroy(&recordset); |
|
387 } |
|
388 |
|
389 // ---------------------------------------------------------------------------- |
|
390 // CMPXDbAlbum::UpdateItemL |
|
391 // ---------------------------------------------------------------------------- |
|
392 // |
|
393 void CMPXDbAlbum::UpdateItemL( |
|
394 TUint32 aId, |
|
395 const CMPXMedia& aMedia, |
|
396 TInt aDriveId, |
|
397 CMPXMessageArray* aItemChangedMessages) |
|
398 { |
|
399 MPX_FUNC("CMPXDbAlbum::UpdateItemL"); |
|
400 |
|
401 CDesCArrayFlat* fields = new (ELeave) CDesCArrayFlat(EAlbumFieldCount); |
|
402 CleanupStack::PushL(fields); |
|
403 CDesCArrayFlat* values = new (ELeave) CDesCArrayFlat(EAlbumFieldCount); |
|
404 CleanupStack::PushL(values); |
|
405 |
|
406 // process the media parameter and construct the fields and values array |
|
407 GenerateAlbumFieldsValuesL(aMedia, *fields, *values); |
|
408 |
|
409 // construct the SET string |
|
410 HBufC* setStr = MPXDbCommonUtil::StringFromArraysLC(*fields, *values, KMCEqualSign, KMCCommaSign); |
|
411 |
|
412 if (setStr->Length()) |
|
413 { |
|
414 // execute the query |
|
415 iDbManager.ExecuteQueryL(aDriveId, KQueryAlbumUpdate, setStr, aId); |
|
416 MPXDbCommonUtil::AddItemAlbumChangedMessageL(*aItemChangedMessages, aId, EMPXItemModified, |
|
417 EMPXAlbum, KDBPluginUid, ETrue, 0 ); |
|
418 } |
|
419 |
|
420 CleanupStack::PopAndDestroy(setStr); |
|
421 CleanupStack::PopAndDestroy(values); |
|
422 CleanupStack::PopAndDestroy(fields); |
|
423 } |
|
424 |
|
425 // ---------------------------------------------------------------------------- |
|
426 // CMPXDbAlbum::GetSongsCountInAlbumMatchingArtistL |
|
427 // ---------------------------------------------------------------------------- |
|
428 // |
|
429 TInt CMPXDbAlbum::GetSongsCountInAlbumMatchingArtistL(TUint32 aArtistId, TUint32 aAlbumId) |
|
430 { |
|
431 MPX_FUNC("CMPXDbAlbum::GetSongsCountInAlbumMatchingArtistL"); |
|
432 |
|
433 return ExecuteSumQueryL(KQuerySongsInArtistAlbum, aArtistId, aAlbumId); |
|
434 } |
|
435 |
|
436 // ---------------------------------------------------------------------------- |
|
437 // CMPXDbAlbum::UpdateMediaL |
|
438 // ---------------------------------------------------------------------------- |
|
439 // |
|
440 void CMPXDbAlbum::UpdateMediaL( |
|
441 RSqlStatement& aRecord, |
|
442 const TArray<TMPXAttribute>& aAttrs, |
|
443 CMPXMedia& aMedia) |
|
444 { |
|
445 MPX_FUNC("CMPXDbAlbum::UpdateMediaL"); |
|
446 |
|
447 TInt count(aAttrs.Count()); |
|
448 for (TInt i = 0; i < count; ++i) |
|
449 { |
|
450 TInt contentId(aAttrs[i].ContentId()); |
|
451 TUint attributeId(aAttrs[i].AttributeId()); |
|
452 |
|
453 if (contentId == KMPXMediaIdGeneral) |
|
454 { |
|
455 if (attributeId & EMPXMediaGeneralId) |
|
456 { |
|
457 MPX_DEBUG1(" EMPXMediaGeneralId"); |
|
458 |
|
459 aMedia.SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, |
|
460 aRecord.ColumnInt64(EAlbumUniqueId)); |
|
461 } |
|
462 if (attributeId & EMPXMediaGeneralTitle) |
|
463 { |
|
464 MPX_DEBUG1(" EMPXMediaGeneralTitle"); |
|
465 |
|
466 TPtrC album( MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumName) ); |
|
467 aMedia.SetTextValueL(KMPXMediaGeneralTitle, |
|
468 MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumName)); |
|
469 MPX_DEBUG2(" Album[%S]", &album ); |
|
470 } |
|
471 if (attributeId & EMPXMediaGeneralCount) |
|
472 { |
|
473 MPX_DEBUG1(" EMPXMediaGeneralCount"); |
|
474 |
|
475 TInt songCount = GetSongsCountL(KDbManagerAllDrives, |
|
476 aRecord.ColumnInt64(EAlbumUniqueId)); |
|
477 aMedia.SetTObjectValueL<TInt>(KMPXMediaGeneralCount, songCount ); |
|
478 MPX_DEBUG2(" SongCount[%d]", songCount ); |
|
479 } |
|
480 } // end if contentId == KMPXMediaIdGeneral |
|
481 else if ( contentId == KMPXMediaIdMusic ) |
|
482 { |
|
483 if (attributeId & EMPXMediaMusicArtist) |
|
484 { |
|
485 MPX_DEBUG1(" EMPXMediaMusicArtist"); |
|
486 |
|
487 TPtrC artistName(MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumArtistName)); |
|
488 aMedia.SetTextValueL(KMPXMediaMusicArtist, artistName); |
|
489 MPX_DEBUG2(" Artist[%S]", &artistName); |
|
490 } |
|
491 |
|
492 if (attributeId & EMPXMediaMusicAlbum) |
|
493 { |
|
494 MPX_DEBUG1(" EMPXMediaMusicAlbum"); |
|
495 |
|
496 TPtrC albumName(KNullDesC); |
|
497 TPtrC album( MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumName) ); |
|
498 |
|
499 |
|
500 // if album is unknown |
|
501 if ( album != KNullDesC) |
|
502 { |
|
503 albumName.Set(album); |
|
504 } |
|
505 |
|
506 aMedia.SetTextValueL(KMPXMediaMusicAlbum, albumName); |
|
507 MPX_DEBUG2(" Album[%S]", &albumName); |
|
508 } |
|
509 if (attributeId & EMPXMediaMusicAlbumArtFileName) |
|
510 { |
|
511 MPX_DEBUG1(" EMPXMediaMusicAlbumArtFileName"); |
|
512 |
|
513 TPtrC art(MPXDbCommonUtil::GetColumnTextL(aRecord, EAlbumArt)); |
|
514 aMedia.SetTextValueL(KMPXMediaMusicAlbumArtFileName, art); |
|
515 MPX_DEBUG2(" Art[%S]", &art); |
|
516 } |
|
517 } |
|
518 } // end for |
|
519 |
|
520 aMedia.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXItem); |
|
521 aMedia.SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, iCategory); |
|
522 } |
|
523 |
|
524 // ---------------------------------------------------------------------------- |
|
525 // CMPXDbAlbum::GenerateAlbumFieldsValuesL |
|
526 // ---------------------------------------------------------------------------- |
|
527 // |
|
528 void CMPXDbAlbum::GenerateAlbumFieldsValuesL(const CMPXMedia& aMedia, CDesCArray& aFields, CDesCArray& aValues) |
|
529 { |
|
530 if (aMedia.IsSupported(KMPXMediaMusicAlbumArtFileName)) |
|
531 { |
|
532 const TDesC& albumArtFilename = aMedia.ValueText(KMPXMediaMusicAlbumArtFileName).Left(KMCMaxTextLen); |
|
533 MPXDbCommonUtil::AppendValueL(aFields, aValues, KMCMusicArt, albumArtFilename); |
|
534 } |
|
535 } |
|
536 |
|
537 // ---------------------------------------------------------------------------- |
|
538 // CMPXDbAlbum::AlbumartForAlbumL |
|
539 // ---------------------------------------------------------------------------- |
|
540 // |
|
541 HBufC* CMPXDbAlbum::AlbumartForAlbumL(const TUint32 aId, TPtrC aArt) |
|
542 { |
|
543 return iObserver.HandleAlbumartForAlbumL(aId, aArt); |
|
544 } |
|
545 |
|
546 // ---------------------------------------------------------------------------- |
|
547 // CMPXDbAlbum::ProcessAlbumRecordSetL |
|
548 // Unknown album or Unknown artist are stored in the database as NULL (Name field and ArtistName field). |
|
549 // The available unknown artist is saved for later and will be appended to the array |
|
550 // as the last item among items which have the same artist. |
|
551 // The available unknown albums are saved for later and will be appended to the array |
|
552 // as the last items after all known albums are appended. |
|
553 // The unknown album and unknown artist is saved for later and will be appended to the array |
|
554 // as the last item. |
|
555 // |
|
556 // NOTE: putting unknown album to the end of the array only takes place when title |
|
557 // field is requested. normal sorting algorithm occurs if title isn't |
|
558 // requested. |
|
559 // |
|
560 // Example: |
|
561 // Album X of artist A |
|
562 // Album X of artist B |
|
563 // Album X of unknown artist |
|
564 // Album Y of artist A |
|
565 // Album Y of unknown artist |
|
566 // Unknown album of artist A |
|
567 // Unknown album of artist B |
|
568 // Unknown album of unknown artist |
|
569 // ---------------------------------------------------------------------------- |
|
570 // |
|
571 void CMPXDbAlbum::ProcessAlbumRecordSetL( |
|
572 const TArray<TMPXAttribute>& aAttrs, |
|
573 RSqlStatement& aRecordset, |
|
574 CMPXMediaArray& aMediaArray) |
|
575 { |
|
576 // populate the array |
|
577 TBool firstRecord(ETrue); |
|
578 CMPXMedia* unknownAlbumUnknownArtistMedia(NULL); |
|
579 CMPXMedia* unknownMedia(NULL); |
|
580 TUint32 prevId(0); |
|
581 TUint32 albumId(0); |
|
582 TUint32 prevAlbumId(0); |
|
583 TInt count(0); |
|
584 TInt err(KErrNone); |
|
585 |
|
586 // Reset array for unknown artists |
|
587 if (iUnknownArtists.Count() > 0) |
|
588 { |
|
589 iUnknownArtists.ResetAndDestroy(); |
|
590 } |
|
591 |
|
592 // Reset array for unknown albums |
|
593 if (iUnknownAlbums.Count() > 0) |
|
594 { |
|
595 iUnknownAlbums.ResetAndDestroy(); |
|
596 } |
|
597 |
|
598 TInt pPath(0); |
|
599 if (aMediaArray.Count()) |
|
600 { |
|
601 CMPXMedia* pMedia = aMediaArray[0]; |
|
602 if (pMedia->IsSupported(KMPXMediaGeneralValue)) |
|
603 { // Query excuted by OpenL |
|
604 pPath = pMedia->ValueTObjectL<TInt>(KMPXMediaGeneralValue); |
|
605 MPX_ASSERT(pPath); |
|
606 } |
|
607 } |
|
608 |
|
609 RArray<TMPXItemId> ids; |
|
610 CleanupClosePushL(ids); |
|
611 |
|
612 while ((err = aRecordset.Next()) == KSqlAtRow) |
|
613 { |
|
614 TUint32 rowId(aRecordset.ColumnInt64(EAlbumUniqueId)); |
|
615 if (prevId == rowId) |
|
616 { |
|
617 continue; |
|
618 } |
|
619 |
|
620 prevId = rowId; |
|
621 CMPXMedia* media = CMPXMedia::NewL(); |
|
622 CleanupStack::PushL(media); |
|
623 |
|
624 UpdateMediaL(aRecordset, aAttrs, *media); |
|
625 |
|
626 albumId = MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXAlbum, |
|
627 MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumName), ETrue); |
|
628 |
|
629 // Append Known album and Unknown artists |
|
630 count = iUnknownArtists.Count(); |
|
631 if ( prevAlbumId != albumId && count > 0) |
|
632 { |
|
633 unknownMedia = NULL; |
|
634 |
|
635 for (TInt i = 0; i < count; i++) |
|
636 { |
|
637 unknownMedia = iUnknownArtists[i]; |
|
638 if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath) |
|
639 { |
|
640 ids.Append(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
641 } |
|
642 aMediaArray.AppendL(*unknownMedia); |
|
643 } |
|
644 |
|
645 iUnknownArtists.ResetAndDestroy(); |
|
646 } |
|
647 |
|
648 // for Unknown album and Unknown artist |
|
649 if (firstRecord && (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumArtistName).Length() == 0) && |
|
650 (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumName).Length() == 0)) |
|
651 { |
|
652 unknownAlbumUnknownArtistMedia = media; |
|
653 } |
|
654 // for Unknown albums and Known artists |
|
655 else if (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumName).Length() == 0) |
|
656 { |
|
657 iUnknownAlbums.Append(media); |
|
658 CleanupStack::Pop(media); |
|
659 } |
|
660 // for Known album and Unknown artist |
|
661 else if (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumArtistName).Length() == 0) |
|
662 { |
|
663 iUnknownArtists.Append(media); |
|
664 CleanupStack::Pop(media); |
|
665 |
|
666 prevAlbumId = albumId; |
|
667 } |
|
668 else |
|
669 { |
|
670 if (media->IsSupported(KMPXMediaGeneralId) && pPath) |
|
671 { |
|
672 ids.AppendL(media->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
673 } |
|
674 aMediaArray.AppendL(*media); |
|
675 CleanupStack::PopAndDestroy(media); |
|
676 } |
|
677 |
|
678 firstRecord = EFalse; |
|
679 } // end while |
|
680 |
|
681 if (err != KSqlAtEnd) |
|
682 { |
|
683 User::LeaveIfError(err); |
|
684 } |
|
685 |
|
686 // Append Known artist and Unknown albums |
|
687 count = iUnknownArtists.Count(); |
|
688 if ( count > 0) |
|
689 { |
|
690 unknownMedia = NULL; |
|
691 |
|
692 for (TInt i = 0; i < count; i++) |
|
693 { |
|
694 unknownMedia = iUnknownArtists[i]; |
|
695 if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath) |
|
696 { |
|
697 ids.Append(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
698 } |
|
699 aMediaArray.AppendL(*unknownMedia); |
|
700 } |
|
701 |
|
702 iUnknownArtists.ResetAndDestroy(); |
|
703 } |
|
704 |
|
705 // Append Unknown artists to MediaArray |
|
706 count = iUnknownAlbums.Count(); |
|
707 if ( count > 0) |
|
708 { |
|
709 CMPXMedia* unknownMedia = NULL; |
|
710 |
|
711 for (TInt i = 0; i < count; i++) |
|
712 { |
|
713 unknownMedia = iUnknownAlbums[i]; |
|
714 if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath) |
|
715 { |
|
716 ids.Append(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
717 } |
|
718 aMediaArray.AppendL(*unknownMedia); |
|
719 } |
|
720 |
|
721 iUnknownAlbums.ResetAndDestroy(); |
|
722 } |
|
723 |
|
724 // the last item in the list |
|
725 if (unknownAlbumUnknownArtistMedia) |
|
726 { |
|
727 if (unknownAlbumUnknownArtistMedia->IsSupported(KMPXMediaGeneralId) && pPath) |
|
728 { |
|
729 ids.AppendL(unknownAlbumUnknownArtistMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
730 } |
|
731 aMediaArray.AppendL(*unknownAlbumUnknownArtistMedia); |
|
732 CleanupStack::PopAndDestroy(unknownAlbumUnknownArtistMedia); |
|
733 } |
|
734 |
|
735 // Append ids to the returned path |
|
736 if (pPath) |
|
737 { |
|
738 ((CMPXCollectionPath*)pPath)->AppendL(ids.Array()); |
|
739 } |
|
740 CleanupStack::PopAndDestroy(&ids); |
|
741 } |
|
742 |
|
743 // ---------------------------------------------------------------------------- |
|
744 // CMPXDbAlbum::ProcessMediaWallAlbumRecordSetL |
|
745 // Unknown album or Unknown artist are stored in the database as NULL (Name field and ArtistName field). |
|
746 // The available unknown album is saved for later and will be appended to the array |
|
747 // as the last item among items which have the same artist. |
|
748 // The available unknown artists are saved for later and will be appended to the array |
|
749 // as the last items after all known artists are appended. |
|
750 // The unknown album and unknown artist is saved for later and will be appended to the array |
|
751 // as the last item. |
|
752 // |
|
753 // NOTE: putting unknown album to the end of the array only takes place when title |
|
754 // field is requested. normal sorting algorithm occurs if title isn't |
|
755 // requested. |
|
756 // |
|
757 // Example: |
|
758 // Album X of artist A |
|
759 // Album Y of artist A |
|
760 // Unknown album of artist A |
|
761 // Album X of artist B |
|
762 // Album Z of artist B |
|
763 // Unknown album of artist B |
|
764 // Album X of unknown artist |
|
765 // Album Y of unknown artist |
|
766 // Unknown album of unknown artist |
|
767 // ---------------------------------------------------------------------------- |
|
768 // |
|
769 // |
|
770 void CMPXDbAlbum::ProcessMediaWallAlbumRecordSetL( |
|
771 const TArray<TMPXAttribute>& aAttrs, |
|
772 RSqlStatement& aRecordset, |
|
773 CMPXMediaArray& aMediaArray) |
|
774 { |
|
775 // populate the array |
|
776 TBool firstRecord(ETrue); |
|
777 CMPXMedia* unknownAlbumUnknownArtistMedia(NULL); |
|
778 CMPXMedia* unknownMedia(NULL); |
|
779 TUint32 prevId(0); |
|
780 TUint32 artistId(0); |
|
781 TUint32 prevArtistId(0); |
|
782 TInt count(0); |
|
783 TInt err(KErrNone); |
|
784 |
|
785 // Reset array for unknown artists |
|
786 if (iUnknownArtists.Count() > 0) |
|
787 { |
|
788 iUnknownArtists.ResetAndDestroy(); |
|
789 } |
|
790 |
|
791 // Reset array for unknown albums |
|
792 if (iUnknownAlbums.Count() > 0) |
|
793 { |
|
794 iUnknownAlbums.ResetAndDestroy(); |
|
795 } |
|
796 |
|
797 TInt pPath(0); |
|
798 if (aMediaArray.Count()) |
|
799 { |
|
800 CMPXMedia* pMedia = aMediaArray[0]; |
|
801 if (pMedia->IsSupported(KMPXMediaGeneralValue)) |
|
802 { // Query excuted by OpenL |
|
803 pPath = pMedia->ValueTObjectL<TInt>(KMPXMediaGeneralValue); |
|
804 MPX_ASSERT(pPath); |
|
805 } |
|
806 } |
|
807 |
|
808 RArray<TMPXItemId> ids; |
|
809 CleanupClosePushL(ids); |
|
810 |
|
811 while ((err = aRecordset.Next()) == KSqlAtRow) |
|
812 { |
|
813 TUint32 rowId(aRecordset.ColumnInt64(EAlbumUniqueId)); |
|
814 if (prevId == rowId) |
|
815 { |
|
816 continue; |
|
817 } |
|
818 |
|
819 prevId = rowId; |
|
820 CMPXMedia* media = CMPXMedia::NewL(); |
|
821 CleanupStack::PushL(media); |
|
822 |
|
823 UpdateMediaL(aRecordset, aAttrs, *media); |
|
824 |
|
825 artistId = aRecordset.ColumnInt64(EAlbumArtist); |
|
826 |
|
827 // Append Known artist and Unknown albums |
|
828 count = iUnknownAlbums.Count(); |
|
829 if (prevArtistId != artistId && count > 0) |
|
830 { |
|
831 unknownMedia = NULL; |
|
832 |
|
833 for (TInt i = 0; i < count; i++) |
|
834 { |
|
835 unknownMedia = iUnknownAlbums[i]; |
|
836 if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath) |
|
837 { |
|
838 ids.Append(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
839 } |
|
840 aMediaArray.AppendL(*unknownMedia); |
|
841 } |
|
842 |
|
843 iUnknownAlbums.ResetAndDestroy(); |
|
844 } |
|
845 |
|
846 // for Unknown artist and Unknown album |
|
847 if (firstRecord && (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumName).Length() == 0) && |
|
848 (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumArtistName).Length() == 0)) |
|
849 { |
|
850 unknownAlbumUnknownArtistMedia = media; |
|
851 } |
|
852 // for Unknown artists and Known albums |
|
853 else if (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumArtistName).Length() == 0) |
|
854 { |
|
855 iUnknownArtists.Append(media); |
|
856 CleanupStack::Pop(media); |
|
857 } |
|
858 // for Known artist and Unknown album |
|
859 else if (MPXDbCommonUtil::GetColumnTextL(aRecordset, EAlbumName).Length() == 0) |
|
860 { |
|
861 iUnknownAlbums.Append(media); |
|
862 CleanupStack::Pop(media); |
|
863 prevArtistId = artistId; |
|
864 } |
|
865 else |
|
866 { |
|
867 if (media->IsSupported(KMPXMediaGeneralId) && pPath) |
|
868 { |
|
869 ids.AppendL(media->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
870 } |
|
871 aMediaArray.AppendL(*media); |
|
872 CleanupStack::PopAndDestroy(media); |
|
873 } |
|
874 |
|
875 firstRecord = EFalse; |
|
876 } // end while |
|
877 |
|
878 if (err != KSqlAtEnd) |
|
879 { |
|
880 User::LeaveIfError(err); |
|
881 } |
|
882 |
|
883 // Append Known artist and Unknown albums |
|
884 count = iUnknownAlbums.Count(); |
|
885 if ( count > 0) |
|
886 { |
|
887 unknownMedia = NULL; |
|
888 |
|
889 for (TInt i = 0; i < count; i++) |
|
890 { |
|
891 unknownMedia = iUnknownAlbums[i]; |
|
892 if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath) |
|
893 { |
|
894 ids.Append(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
895 } |
|
896 aMediaArray.AppendL(*unknownMedia); |
|
897 } |
|
898 |
|
899 iUnknownAlbums.ResetAndDestroy(); |
|
900 } |
|
901 |
|
902 // Append Unknown artists to MediaArray |
|
903 count = iUnknownArtists.Count(); |
|
904 if ( count > 0) |
|
905 { |
|
906 CMPXMedia* unknownMedia = NULL; |
|
907 |
|
908 for (TInt i = 0; i < count; i++) |
|
909 { |
|
910 unknownMedia = iUnknownArtists[i]; |
|
911 if (unknownMedia->IsSupported(KMPXMediaGeneralId) && pPath) |
|
912 { |
|
913 ids.Append(unknownMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
914 } |
|
915 aMediaArray.AppendL(*unknownMedia); |
|
916 } |
|
917 |
|
918 iUnknownArtists.ResetAndDestroy(); |
|
919 } |
|
920 |
|
921 // the last item in the list |
|
922 if (unknownAlbumUnknownArtistMedia) |
|
923 { |
|
924 if (unknownAlbumUnknownArtistMedia->IsSupported(KMPXMediaGeneralId) && pPath) |
|
925 { |
|
926 ids.AppendL(unknownAlbumUnknownArtistMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
|
927 } |
|
928 aMediaArray.AppendL(*unknownAlbumUnknownArtistMedia); |
|
929 CleanupStack::PopAndDestroy(unknownAlbumUnknownArtistMedia); |
|
930 } |
|
931 |
|
932 // Append ids to the returned path |
|
933 if (pPath) |
|
934 { |
|
935 ((CMPXCollectionPath*)pPath)->AppendL(ids.Array()); |
|
936 } |
|
937 CleanupStack::PopAndDestroy(&ids); |
|
938 } |
|
939 |
|
940 // ---------------------------------------------------------------------------- |
|
941 // CMPXDbAlbum::GenerateUniqueIdL |
|
942 // ---------------------------------------------------------------------------- |
|
943 // |
|
944 TUint32 CMPXDbAlbum::GenerateUniqueIdL(const CMPXMedia& aMedia) |
|
945 { |
|
946 TPtrC album(KNullDesC); |
|
947 TPtrC albumArtist(KNullDesC); |
|
948 TPtrC artist(KNullDesC); |
|
949 |
|
950 // check Album attirbute |
|
951 if (aMedia.IsSupported(KMPXMediaMusicAlbum)) |
|
952 { |
|
953 album.Set(aMedia.ValueText(KMPXMediaMusicAlbum).Left(KMCMaxTextLen)); |
|
954 } |
|
955 |
|
956 HBufC* buf(NULL); |
|
957 if (RetrieveAlbumArtistL(aMedia, albumArtist)) |
|
958 { |
|
959 buf = HBufC::NewLC(album.Length() + albumArtist.Length() + KAlbumAlbumArtistSeperator().Length()); |
|
960 |
|
961 buf->Des().Append(album); |
|
962 buf->Des().Append(KAlbumAlbumArtistSeperator); |
|
963 buf->Des().Append(albumArtist); |
|
964 } |
|
965 else |
|
966 { |
|
967 RetrieveArtist(aMedia, artist); |
|
968 |
|
969 buf = HBufC::NewLC(album.Length() + artist.Length() + KAlbumArtistSeperator().Length()); |
|
970 |
|
971 buf->Des().Append(album); |
|
972 buf->Des().Append(KAlbumArtistSeperator); |
|
973 buf->Des().Append(artist); |
|
974 } |
|
975 |
|
976 // try to find the item first |
|
977 TUint32 id(MPXDbCommonUtil::GenerateUniqueIdL(iDbManager.Fs(), EMPXAlbum, |
|
978 *buf, ETrue)); |
|
979 CleanupStack::PopAndDestroy(buf); |
|
980 |
|
981 return id; |
|
982 } |
|
983 |
|
984 // ---------------------------------------------------------------------------- |
|
985 // CMPXDbAlbum::IsUnknownAlbumL |
|
986 // ---------------------------------------------------------------------------- |
|
987 // |
|
988 TBool CMPXDbAlbum::IsUnknownAlbumL(const TUint32 aId) |
|
989 { |
|
990 HBufC* query = PreProcessStringLC(KQueryCategoryItem); |
|
991 RSqlStatement recordset(iDbManager.ExecuteSelectQueryL(*query, aId)); |
|
992 CleanupStack::PopAndDestroy(query); |
|
993 CleanupClosePushL(recordset); |
|
994 |
|
995 if (recordset.Next() != KSqlAtRow) |
|
996 { |
|
997 User::Leave(KErrNotFound); |
|
998 } |
|
999 |
|
1000 TPtrC album(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumName)); |
|
1001 TPtrC artistName(MPXDbCommonUtil::GetColumnTextL(recordset, EAlbumArtistName)); |
|
1002 |
|
1003 TBool ret = EFalse; |
|
1004 if (album.Length() == 0 || artistName.Length() == 0) |
|
1005 { |
|
1006 ret = ETrue; |
|
1007 } |
|
1008 else |
|
1009 { |
|
1010 ret = EFalse; |
|
1011 } |
|
1012 |
|
1013 CleanupStack::PopAndDestroy(&recordset); |
|
1014 |
|
1015 return ret; |
|
1016 } |
|
1017 |
|
1018 // ---------------------------------------------------------------------------- |
|
1019 // CMPXDbAlbum::RetrieveAlbumArtistL |
|
1020 // ---------------------------------------------------------------------------- |
|
1021 // |
|
1022 TBool CMPXDbAlbum::RetrieveAlbumArtistL(const CMPXMedia& aMedia, TPtrC& aName) |
|
1023 { |
|
1024 // check AlbumArtist attribute |
|
1025 if (aMedia.IsSupported(KMPXMediaMusicAlbumArtist)) |
|
1026 { |
|
1027 aName.Set(aMedia.ValueText(KMPXMediaMusicAlbumArtist).Left(KMCMaxTextLen)); |
|
1028 } |
|
1029 else |
|
1030 { |
|
1031 aName.Set(KNullDesC); |
|
1032 } |
|
1033 |
|
1034 if (aName.Length() > 0 ) |
|
1035 { |
|
1036 return ETrue; |
|
1037 } |
|
1038 else |
|
1039 { |
|
1040 return EFalse; |
|
1041 } |
|
1042 } |
|
1043 |
|
1044 // ---------------------------------------------------------------------------- |
|
1045 // CMPXDbAlbum::RetrieveArtist |
|
1046 // ---------------------------------------------------------------------------- |
|
1047 // |
|
1048 void CMPXDbAlbum::RetrieveArtist(const CMPXMedia& aMedia, TPtrC& aName) |
|
1049 { |
|
1050 // check Artist attribute |
|
1051 if (aMedia.IsSupported(KMPXMediaMusicArtist)) |
|
1052 { |
|
1053 aName.Set(aMedia.ValueText(KMPXMediaMusicArtist).Left(KMCMaxTextLen)); |
|
1054 } |
|
1055 else |
|
1056 { |
|
1057 aName.Set(KNullDesC); |
|
1058 } |
|
1059 } |
|
1060 |
|
1061 // ---------------------------------------------------------------------------- |
|
1062 // CMPXDbAlbum::NeedToUpdateArt |
|
1063 // ---------------------------------------------------------------------------- |
|
1064 // |
|
1065 TBool CMPXDbAlbum::NeedToUpdateArt(const TDesC& aDeletedSongArt, const TDesC& aCurrentAlbumArt) |
|
1066 { |
|
1067 if (aDeletedSongArt.Length() == 0) |
|
1068 { |
|
1069 // Deleted song's art has default album art |
|
1070 return EFalse; |
|
1071 } |
|
1072 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
1073 else |
|
1074 if (aDeletedSongArt.Length() > 0) |
|
1075 { |
|
1076 TParsePtrC parse(aDeletedSongArt); |
|
1077 TPtrC ext(parse.Ext()); |
|
1078 //set flag to false, so .alb will not overwrite art field in album, artist table |
|
1079 // when song with embedded art |
|
1080 if (ext.CompareF(KAbstractAlbumExt) == 0) |
|
1081 { |
|
1082 // Deleted song's art is Non-embedded album art |
|
1083 return EFalse; |
|
1084 } |
|
1085 } |
|
1086 else |
|
1087 #endif |
|
1088 if (aDeletedSongArt.Length() > 0 && aCurrentAlbumArt.Length() > 0 && aDeletedSongArt.CompareF(aCurrentAlbumArt) == 0) |
|
1089 { |
|
1090 // Deleted song's art is Embedded album art and it is the same as Album's current art |
|
1091 return ETrue; |
|
1092 } |
|
1093 else |
|
1094 { |
|
1095 return EFalse; |
|
1096 } |
|
1097 } |
|
1098 |
|
1099 // ---------------------------------------------------------------------------- |
|
1100 // CMPXDbAlbum::CreateTableL |
|
1101 // ---------------------------------------------------------------------------- |
|
1102 // |
|
1103 void CMPXDbAlbum::CreateTableL( |
|
1104 RSqlDatabase& aDatabase, |
|
1105 TBool /* aCorruptTable */) |
|
1106 { |
|
1107 MPX_FUNC("CMPXDbCategory::CreateTableL"); |
|
1108 |
|
1109 // create the table |
|
1110 User::LeaveIfError(aDatabase.Exec(KAlbumCreateTable)); |
|
1111 |
|
1112 // do not create an index on the Name field |
|
1113 // as it only slows down the insert/update queries overall |
|
1114 } |
|
1115 |
|
1116 // ---------------------------------------------------------------------------- |
|
1117 // CMPXDbAlbum::CheckTableL |
|
1118 // ---------------------------------------------------------------------------- |
|
1119 // |
|
1120 TBool CMPXDbAlbum::CheckTableL( |
|
1121 RSqlDatabase& aDatabase) |
|
1122 { |
|
1123 MPX_FUNC("CMPXDbCategory::CheckTableL"); |
|
1124 |
|
1125 TBool check(DoCheckTable(aDatabase, KAlbumCheckTable)); |
|
1126 |
|
1127 return check; |
|
1128 } |
|
1129 |
|
1130 // End of File |