|
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: This class is responsible for all music table functionality. |
|
15 * The Music table contains one record for each song on the database |
|
16 * drive. |
|
17 * |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 #ifndef MPXDBMUSIC_H |
|
23 #define MPXDBMUSIC_H |
|
24 |
|
25 // INCLUDES |
|
26 #include "mpxdbtable.h" |
|
27 #include "mpxdbcommonstd.h" |
|
28 #include "mpxdbactivetask.h" |
|
29 |
|
30 // CLASS FORWARDS |
|
31 class CMPXMedia; |
|
32 class CMPXMediaArray; |
|
33 |
|
34 // CLASS DECLARATION |
|
35 |
|
36 /** |
|
37 * Observer interface for handling the category ID functionality. |
|
38 * This is needed because the incoming CMPXMedia parameters in Add and Update methods |
|
39 * contain the names for the category items and the music table has to use IDs linking |
|
40 * to the category tables. Using this interface removes the dependency to the category |
|
41 * class. |
|
42 * |
|
43 * Note that this interface is only used when information is written to the Music table, |
|
44 * when information is retrieved the query takes care of also retrieving the names from |
|
45 * the corresponding category tables so the outgoing CMPXMedia will contain the correct |
|
46 * information. |
|
47 */ |
|
48 class MMPXDbMusicObserver |
|
49 { |
|
50 public: |
|
51 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
52 /** |
|
53 * Called when a new category item has to be added to a category table. |
|
54 * @param aName Abstract Album art name |
|
55 * @param aDrive drive to add the category to |
|
56 * @param aItemChangedMessages changed mesages array to be updated or NULL |
|
57 * @param aItemExist Out parameter, ETrue if the item already exist before the add, |
|
58 * EFalse otherwise |
|
59 * @param aUri Abstract Album art Uri |
|
60 * @param aAlbumArtist AlbumArtist string |
|
61 * @return the ID of the category item (new or existing) |
|
62 */ |
|
63 virtual TUint32 AddAbstractAlbumItemL(const TDesC& aName, |
|
64 TInt aDriveId, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, |
|
65 const TDesC& aUri, const TDesC& aAlbumArtist=KNullDesC) = 0; |
|
66 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
67 |
|
68 /** |
|
69 * Called when a new category item has to be added to a category table. |
|
70 * @param aCategory category type |
|
71 * @param aMedia media object |
|
72 * @param aDrive drive to add the category to |
|
73 * @param aItemChangedMessages changed mesages array to be updated or NULL |
|
74 * @param aItemExist Out parameter, ETrue if the item already exist before the add, |
|
75 * EFalse otherwise |
|
76 * @return the ID of the category item (new or existing) |
|
77 */ |
|
78 virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, const CMPXMedia& aMedia, |
|
79 TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist) = 0; |
|
80 |
|
81 /** |
|
82 * Called when the ID of a category item changed for a Music record, for example when |
|
83 * the artist name changed for a song. The implementation is supposed to update the |
|
84 * category record and add corresponding item changed messages to the array parameter. |
|
85 * @param aCategory category type |
|
86 * @param aCategoryId old category item ID |
|
87 * @param aDrive drive the category item is on |
|
88 * @param aItemChangedMessages changed mesages array to be updated or NULL |
|
89 * @param aItemExist Out parameter, ETrue if the category is not deleted after the delete, |
|
90 * EFalse otherwise |
|
91 * @param aArt Art of the music record. |
|
92 * Art needs to be given so that the cateogry can switch over to different art |
|
93 * if necessary |
|
94 * |
|
95 */ |
|
96 virtual void DeleteSongForCategoryL(TMPXGeneralCategory aCategory, TUint32 aCategoryId, |
|
97 TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist, const TDesC& aArt = KNullDesC) = 0; |
|
98 |
|
99 /** |
|
100 * Called when the play count attribute of a song is changed. Should add an item changed |
|
101 * message to the array. |
|
102 * @param aItemChangedMessages array of item changed messages to add to |
|
103 */ |
|
104 virtual void HandlePlayCountModifiedL(CMPXMessageArray& aItemChangedMessages) = 0; |
|
105 |
|
106 /** |
|
107 * Called when the playback time attribute of a song is changed. Should add an item changed |
|
108 * message to the array. |
|
109 * @param aItemChangedMessages array of item changed messages to add to |
|
110 */ |
|
111 virtual void HandlePlaybackTimeModifiedL(CMPXMessageArray& aItemChangedMessages) = 0; |
|
112 |
|
113 /** |
|
114 * Called when category item is changed. Should add an item changed |
|
115 * message to the array. |
|
116 * @param aCategory category type |
|
117 * @param aCategoryId old category item ID |
|
118 * @param aDrive drive the category item is on |
|
119 * @param aMedia media data |
|
120 * @param aItemChangedMessages changed mesages array to be updated or NULL |
|
121 */ |
|
122 virtual void UpdateCategoryItemL(TMPXGeneralCategory aCategory, TUint32 aCategoryId, |
|
123 const CMPXMedia& aMedia, TInt aDrive, CMPXMessageArray* aItemChangedMessages) = 0; |
|
124 |
|
125 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
126 /** |
|
127 * Get title from the Id |
|
128 * @param Id to search for |
|
129 * @return name matching the ID |
|
130 */ |
|
131 virtual HBufC* HandleGetAlbumNameFromIdL( TUint32 aId ) = 0; |
|
132 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
133 |
|
134 /** |
|
135 * Generate Unique ID for Album |
|
136 * @param aMedia media object |
|
137 * @param aCaseSensitive indicates whether case sensitivity should be taken |
|
138 * into consideration when generating the unique row id |
|
139 * @return the ID of album |
|
140 */ |
|
141 virtual TUint32 GenerateUniqueIdForAlbumL(const CMPXMedia& aMedia) = 0; |
|
142 |
|
143 /** |
|
144 * Check if the specified album ID is Unknown album |
|
145 * @param aId: The ID of the album |
|
146 * @return ETrue if it's Unknown album |
|
147 */ |
|
148 virtual TBool IsUnknownAlbumL(const TUint32 aId) = 0; |
|
149 }; |
|
150 |
|
151 /** |
|
152 * Responsible for managing the Music table |
|
153 * |
|
154 * @lib MPXDbPlugin.lib |
|
155 */ |
|
156 class CMPXDbMusic : |
|
157 public CMPXDbTable |
|
158 { |
|
159 public: |
|
160 |
|
161 /** |
|
162 * Two-phased constructor. |
|
163 * @param aDbManager database manager to use for database interactions |
|
164 * @param aObserver observer reference |
|
165 * @return New CMPXDbMusic instance. |
|
166 */ |
|
167 static CMPXDbMusic* NewL(CMPXDbManager& aDbManager, CMPXResource& aResource, |
|
168 MMPXDbMusicObserver& aObserver); |
|
169 |
|
170 /** |
|
171 * Two-phased constructor. |
|
172 * @param aDbManager database manager to use for database interactions |
|
173 * @param aObserver observer reference |
|
174 * @return New CMPXDbMusic instance on the cleanup stack. |
|
175 */ |
|
176 static CMPXDbMusic* NewLC(CMPXDbManager& aDbManager, CMPXResource& aResource, |
|
177 MMPXDbMusicObserver& aObserver); |
|
178 |
|
179 /** |
|
180 * Destructor |
|
181 */ |
|
182 virtual ~CMPXDbMusic(); |
|
183 |
|
184 public: |
|
185 |
|
186 /** |
|
187 * Add a song to the music table |
|
188 * @param aMedia contains the song details |
|
189 * @param aDrive drive to add the song to |
|
190 * @param aMessageArray change event message to notify client of the changes |
|
191 * @return The unique ID of the song added. |
|
192 */ |
|
193 TUint32 AddSongL(const CMPXMedia& aMedia, TInt aDrive, CMPXMessageArray* aMessageArray=NULL); |
|
194 |
|
195 /** |
|
196 * Remove a song from the music table |
|
197 * @param aSongId the ID of the song to be removed |
|
198 * @param aDrive song drive |
|
199 * @param aDeleteRecord indicates whether the client has explictly requested |
|
200 * to delete the records from the database. If ETrue, records |
|
201 * associated with the media will be deleted from the database; |
|
202 * if EFalse, whether to mark the records as deleted or to delete |
|
203 * the records will be based on other deciding factors. |
|
204 */ |
|
205 void DeleteSongL(TUint32 aSongId, TInt aDrive, TBool aDeleteRecord = EFalse); |
|
206 |
|
207 /** |
|
208 * Remove songs matching a category from the music table |
|
209 * @param aCategory the category to remove |
|
210 * @param aCategoryId ID of the category to remove |
|
211 * @param aUriArray on return will be filled with all the paths that were removed |
|
212 * @param aItemChangedMessages a list of change events as a result of the song removal |
|
213 * @param aDrive drive the category record is on |
|
214 */ |
|
215 void DeleteCategoryL(TMPXGeneralCategory aCategory, TUint32 aCategoryId, |
|
216 CDesCArray& aUriArray, CMPXMessageArray& aItemChangedMessages, TInt aDrive); |
|
217 |
|
218 /** |
|
219 * Deletes all songs marked as deleted |
|
220 */ |
|
221 void CleanupL(); |
|
222 |
|
223 /** |
|
224 * Update song info for a song in the music table |
|
225 * @param aSongId song ID |
|
226 * @param aMedia media object which contains file path, |
|
227 * artist, composer, name(title), track, etc... |
|
228 * @param aItemChangedMessages a list of change events as a result of the song removal |
|
229 * @return ETrue if the change is visible in the UI |
|
230 */ |
|
231 CMPXDbActiveTask::TChangeVisibility UpdateSongL(TUint32 aSongId, const CMPXMedia& aMedia, |
|
232 CMPXMessageArray& aItemChangedMessages); |
|
233 |
|
234 /** |
|
235 * Get the name of the song that matches the given song ID |
|
236 * @param aSongId ID of the song |
|
237 * @return Song name, ownership is transferred to the caller. |
|
238 */ |
|
239 HBufC* GetNameL(TUint32 aSongId); |
|
240 |
|
241 /** |
|
242 * Get URI of the song |
|
243 * @param aSongId ID of the song |
|
244 * @return Song URI, ownership is transferred to the caller. |
|
245 */ |
|
246 HBufC* GetUriL(TUint32 aSongId); |
|
247 |
|
248 /** |
|
249 * Get the drive of the song |
|
250 * @param aSongId ID of the song |
|
251 * @return Song drive |
|
252 */ |
|
253 TInt GetDriveL(TUint32 aSongId); |
|
254 |
|
255 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
256 /** |
|
257 * Get the drive and category IDs for a specified song |
|
258 * @param aSongId song to be retrieved |
|
259 * @param aArtistId returns the artist ID |
|
260 * @param aAlbumId returns the artist ID |
|
261 * @param aGenreId returns the artist ID |
|
262 * @param aComposerId returns the artist ID |
|
263 * @param aAbstractAlbumId returns the AbstractAlbum ID |
|
264 * @param aDriveId returns the song drive |
|
265 * @param aArt returns the albumart uri |
|
266 * @return song URI. The ownership is transferred. |
|
267 */ |
|
268 HBufC* GetSongInfoL(TUint32 aSongId, TUint32& aArtistId, TUint32& aAlbumId, |
|
269 TUint32& aGenreId, TUint32& aComposerId, TUint32& aAbstractAlbumId, TInt& aDriveId, HBufC*& aArt); |
|
270 #else |
|
271 /** |
|
272 * Get the drive and category IDs for a specified song |
|
273 * @param aSongId song to be retrieved |
|
274 * @param aArtistId returns the artist ID |
|
275 * @param aAlbumId returns the artist ID |
|
276 * @param aGenreId returns the artist ID |
|
277 * @param aComposerId returns the artist ID |
|
278 * @param aDriveId returns the song drive |
|
279 * @param aArt returns the albumart uri |
|
280 * @return song URI. The ownership is transferred. |
|
281 */ |
|
282 HBufC* GetSongInfoL(TUint32 aSongId, TUint32& aArtistId, TUint32& aAlbumId, |
|
283 TUint32& aGenreId, TUint32& aComposerId, TInt& aDriveId, HBufC*& aArt); |
|
284 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
285 /** |
|
286 * Get the song Id, title, URI, and general flags from the given song Id and/or URI |
|
287 * @param aCriteria search the media by song Id and/or URI |
|
288 * @param aMedia returns the song details |
|
289 * @return error code KErrNotFound if unable to find the specified song in the |
|
290 * collection; otherwise KErrNone |
|
291 */ |
|
292 TInt GetSongL(const CMPXMedia& aCriteria, CMPXMedia*& aMedia); |
|
293 |
|
294 /** |
|
295 * Get the most recently played songs. Returns a maximum of KMPXMaxRecentlyPlayedSongs |
|
296 * songs. |
|
297 * @param aAttrs attributes to include |
|
298 * @param aMediaArray returns the songs' info |
|
299 */ |
|
300 void GetRecentlyPlayedSongsL(const TArray<TMPXAttribute>& aAttrs, |
|
301 CMPXMediaArray& aMediaArray); |
|
302 |
|
303 /** |
|
304 * Get the most played songs from the music table. Returns a maximum of |
|
305 * KMPXMaxMostPlayedSongs songs. |
|
306 * @param aAttrs attributes to include |
|
307 * @param aMediaArray returns the songs' info |
|
308 */ |
|
309 void GetMostPlayedSongsL(const TArray<TMPXAttribute>& aAttrs, |
|
310 CMPXMediaArray& aMediaArray); |
|
311 |
|
312 /** |
|
313 * Get the recently added songs from the music table (7 days) |
|
314 * @param aAttrs attributes to include |
|
315 * @param aMediaArray returns the songs' info |
|
316 */ |
|
317 void GetRecentlyAddedSongsL(const TArray<TMPXAttribute>& aAttrs, |
|
318 CMPXMediaArray& aMediaArray); |
|
319 |
|
320 /** |
|
321 * Get the total number of songs |
|
322 * @return total number of songs |
|
323 */ |
|
324 TInt CountL(); |
|
325 |
|
326 /** |
|
327 * Get all the albums for a specified artist |
|
328 * @param aArtistId artist ID |
|
329 * @param aMediaArray returns the album(s) matching the artist |
|
330 */ |
|
331 void GetAlbumsForArtistL(TUint32 aArtistId, CMPXMediaArray& aMediaArray); |
|
332 |
|
333 /** |
|
334 * Returns details about the specified song. |
|
335 * @param aSongId identifies the song |
|
336 * @param aAttrs attributes to be retrieved |
|
337 * @param aMedia returns the song information |
|
338 */ |
|
339 void GetSongL(TInt aSongId, const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aMedia); |
|
340 |
|
341 /** |
|
342 * Returns all songs in the playlist. |
|
343 * @param aDrive identifies in db |
|
344 * @param aPlaylistId identifies the playlist |
|
345 * @param aAttrs attributes to be retrieved |
|
346 * @param aMediaArray returns the song attributes. |
|
347 */ |
|
348 void GetAllSongsL(TInt aDrive,TInt aPlaylistId,const TArray<TMPXAttribute>& aAttrs, |
|
349 CMPXMediaArray& aMediaArray); |
|
350 |
|
351 /** |
|
352 * Returns all songs in the database. |
|
353 * @param aAttrs attributes to be retrieved |
|
354 * @param aMediaArray returns the song attributes. |
|
355 */ |
|
356 void GetAllSongsL(const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray); |
|
357 |
|
358 /** |
|
359 * Get from all songs with a limit (first N items) |
|
360 * @param aAttrs attributes to be retrieved |
|
361 * @param aMediaArray returns the song attributes. |
|
362 * @param aLimit maximum number of songs to retrieve |
|
363 */ |
|
364 void GetAllSongsLimitedL(const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray, TInt aLimit); |
|
365 |
|
366 /** |
|
367 * Returns a block of songs as specified |
|
368 * @param aAttrs attributes to be retrieved |
|
369 * @param aMediaArray returns the song attributes. |
|
370 * @param aTitle title of the song that marks the beginning of the block |
|
371 * @param aNumOfSongs the number of songs in the block |
|
372 * @param aAsc |
|
373 */ |
|
374 void GetSongsInBlockL( const TArray<TMPXAttribute>& aAttrs, |
|
375 CMPXMediaArray& aMediaArray, |
|
376 TPtrC aTitle, |
|
377 TUint aNumOfSongs, |
|
378 TBool aAsc); |
|
379 |
|
380 |
|
381 /** |
|
382 * Get songs from the music collection starting at a particular offset |
|
383 * ONLY use this as the first query to locate particular item. Should use |
|
384 * GetSongsInBlockL() to fetch in blocks with a particular index |
|
385 * @param aMediaArray Array to store the results |
|
386 * @param aAttrs attributes to fetch |
|
387 * @param aOffset offset to start reading |
|
388 * @param aCount number of items to get |
|
389 */ |
|
390 void GetSongsAtOffsetL( CMPXMediaArray& aMediaArray, |
|
391 const TArray<TMPXAttribute>& aAttrs, |
|
392 TInt aOffset, |
|
393 TInt aCount ); |
|
394 |
|
395 /** |
|
396 * Returns all songs for a given artist. |
|
397 * @param aArtistId artist to get the songs for |
|
398 * @param aAttrs attributes to be retrieved |
|
399 * @param aMediaArray returns the song attributes. |
|
400 */ |
|
401 void GetSongsForArtistL(TUint aArtistId, const TArray<TMPXAttribute>& aAttrs, |
|
402 CMPXMediaArray& aMediaArray); |
|
403 |
|
404 /** |
|
405 * Returns all songs for a given album. |
|
406 * @param aAlbumId album to get the songs for |
|
407 * @param aAttrs attributes to be retrieved |
|
408 * @param aMediaArray returns the song attributes. |
|
409 */ |
|
410 void GetSongsForAlbumL(TUint aAlbumId, const TArray<TMPXAttribute>& aAttrs, |
|
411 CMPXMediaArray& aMediaArray); |
|
412 |
|
413 /** |
|
414 * Returns all songs for a given artist and album. |
|
415 * @param aArtistId artist to get the songs for |
|
416 * @param aAlbumId album to get the songs for |
|
417 * @param aAttrs attributes to be retrieved |
|
418 * @param aMediaArray returns the song attributes. |
|
419 */ |
|
420 void GetSongsForArtistAndAlbumL(TUint aArtistId, TUint aAlbumId, |
|
421 const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray); |
|
422 |
|
423 /** |
|
424 * Returns all songs for a given genre. |
|
425 * @param aGenreId genre to get the songs for |
|
426 * @param aAttrs attributes to be retrieved |
|
427 * @param aMediaArray returns the song attributes. |
|
428 */ |
|
429 void GetSongsForGenreL(TUint aGenreId, const TArray<TMPXAttribute>& aAttrs, |
|
430 CMPXMediaArray& aMediaArray); |
|
431 |
|
432 /** |
|
433 * Returns all songs for a given composer. |
|
434 * @param aComposerId composer to get the songs for |
|
435 * @param aAttrs attributes to be retrieved |
|
436 * @param aMediaArray returns the song attributes. |
|
437 */ |
|
438 void GetSongsForComposerL(TUint aComposerId, const TArray<TMPXAttribute>& aAttrs, |
|
439 CMPXMediaArray& aMediaArray); |
|
440 |
|
441 |
|
442 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
443 /** |
|
444 * Returns all songs for a given abstractalbum. |
|
445 * @param aAbstractAlbumId abstractalbum to get the songs for |
|
446 * @param aAttrs attributes to be retrieved |
|
447 * @param aMediaArray returns the song attributes. |
|
448 */ |
|
449 void GetAllSongsForAbstractAlbumL(TUint aAbstractAlbumId, |
|
450 const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray); |
|
451 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
452 /** |
|
453 * Returns the duration of all songs. |
|
454 * @return the duration value |
|
455 */ |
|
456 TInt AllSongsDurationL(); |
|
457 |
|
458 /** |
|
459 * Returns the duration for a specified artist. |
|
460 * @param aArtistId artist to get the duration for |
|
461 * @return the duration value |
|
462 */ |
|
463 TInt ArtistDurationL(TUint aArtistId); |
|
464 |
|
465 /** |
|
466 * Returns the duration for a specified album. |
|
467 * @param aAlbumId album to get the duration for |
|
468 * @return the duration value |
|
469 */ |
|
470 TInt AlbumDurationL(TUint aAlbumId); |
|
471 |
|
472 /** |
|
473 * Returns the duration for a specified artist and album. |
|
474 * @param aArtistId artist to get the duration for |
|
475 * @param aAlbumId album to get the duration for |
|
476 * @return the duration value |
|
477 */ |
|
478 TInt ArtistAlbumDurationL(TUint aArtistId, TUint aAlbumId); |
|
479 |
|
480 /** |
|
481 * Returns the duration for a specified genre. |
|
482 * @param aGenreId genre to get the duration for |
|
483 * @return the duration value |
|
484 */ |
|
485 TInt GenreDurationL(TUint aGenreId); |
|
486 |
|
487 /** |
|
488 * Returns the duration for a specified composer. |
|
489 * @param aComposerId composer to get the duration for |
|
490 * @return the duration value |
|
491 */ |
|
492 TInt ComposerDurationL(TUint aComposerId); |
|
493 |
|
494 /** |
|
495 * Returns the duration for the recently played songs. |
|
496 * @return the duration value |
|
497 */ |
|
498 TInt RecentlyPlayedDurationL(); |
|
499 |
|
500 /** |
|
501 * Returns the duration for the most played songs. |
|
502 * @return the duration value |
|
503 */ |
|
504 TInt MostPlayedDurationL(); |
|
505 |
|
506 /** |
|
507 * Returns the duration for the recently added songs. |
|
508 * @return the duration value |
|
509 */ |
|
510 TInt RecentlyAddedDurationL(); |
|
511 |
|
512 /** |
|
513 * Find the songs for the selection criteria |
|
514 * @param aGeneralId selection criteria (could be song/album/artist/genre/composer ID) |
|
515 * @param aContainerId selection criteria (could be artist/album id) |
|
516 * @param aType criteria type (EMPXItem or EMPXGroup) |
|
517 * @param aCriteria selection criteria |
|
518 * @param aAttrs the attributes to include for the artist(s) matching the |
|
519 * selection criteria |
|
520 * @param aMediaArray returns the songs |
|
521 * @param aSortByTrackOrder if TRUE sorts tracks according to their track numbers, |
|
522 * if FALSE using track titles or filename |
|
523 */ |
|
524 void FindSongsL(TUint32 aGeneralId, TUint32 aContainerId, TMPXGeneralType aType, |
|
525 const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs, |
|
526 CMPXMediaArray& aMediaArray, TBool aSortByTrackOrder = EFalse); |
|
527 |
|
528 /** |
|
529 * Returns the track count for a given drive |
|
530 * @param aDrive drive |
|
531 * @return the count |
|
532 */ |
|
533 TUint GetDriveTrackCountL(TInt aDrive); |
|
534 |
|
535 /** |
|
536 * Get URIs for a given number of tracks |
|
537 * @param aDrive, specifies drive number for db selection |
|
538 * @param aFromID, specifies unique ID of last record retrieved |
|
539 * @param aRecords, specifies the number of records to get |
|
540 * @param aUriArr, will contain all URIs on return |
|
541 * @param aLastID, will contain unique ID of a last record in the array |
|
542 */ |
|
543 void GetMusicUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords, |
|
544 CDesCArray& aUriArr, TInt& aLastID); |
|
545 |
|
546 /** |
|
547 * Get the Albumart of song which belongs to the specified Album |
|
548 * @param aId, the ID of Album |
|
549 * @param aArt, AlbumArt uri |
|
550 * @returns alternative albumart retrieved in the specified Album. |
|
551 */ |
|
552 HBufC* AlbumartForAlbumL(const TUint32 aAlbumId, TPtrC aArt); |
|
553 |
|
554 |
|
555 /* |
|
556 * Check the integrity of the music basic table |
|
557 */ |
|
558 void CheckMusicBasicTableL(); |
|
559 |
|
560 private: |
|
561 |
|
562 /** |
|
563 * Checks if the specified song exists. |
|
564 * @param aId identifies the song |
|
565 * @return ETrue if it exists, EFalse otherwise |
|
566 */ |
|
567 TBool SongExistsL(TUint32 aSongId); |
|
568 |
|
569 /** |
|
570 * Update the media with information found in the Music table |
|
571 * @param aMusicTable music table record |
|
572 * @param aAttrs the attributes to include |
|
573 * @param aMedia returns the song details |
|
574 */ |
|
575 void UpdateMediaL(RSqlStatement& aMusicTable, const TArray<TMPXAttribute>& aAttrs, |
|
576 CMPXMedia& aMedia); |
|
577 |
|
578 /** |
|
579 * Update the media general attributes from the Music table |
|
580 * @param aMusicTable music table view |
|
581 * @param aAttrId the required attributes |
|
582 * @param aMedia the media object to set |
|
583 */ |
|
584 void UpdateMediaGeneralL(RSqlStatement& aMusicTable, const TUint aAttrId, |
|
585 CMPXMedia& aMedia); |
|
586 |
|
587 /** |
|
588 * Update the media music attributes from the Music table |
|
589 * @param aMusicTable music table view |
|
590 * @param aAttrId the required attributes |
|
591 * @param aMedia the media object to set |
|
592 */ |
|
593 void UpdateMediaMusicL(RSqlStatement& aMusicTable, const TUint aAttrId, |
|
594 CMPXMedia& aMedia); |
|
595 |
|
596 /** |
|
597 * Update the media audio attributes from the Music table |
|
598 * @param aMusicTable music table view |
|
599 * @param aAttrId the required attributes |
|
600 * @param aMedia the media object to set |
|
601 */ |
|
602 void UpdateMediaAudioL(RSqlStatement& aMusicTable, const TUint aAttrId, |
|
603 CMPXMedia& aMedia); |
|
604 |
|
605 /** |
|
606 * Update the media MTP attributes from the Music table |
|
607 * @param aMusicTable music table view |
|
608 * @param aAttrId the required attributes |
|
609 * @param aMedia the media object to set |
|
610 */ |
|
611 void UpdateMediaMTPL(RSqlStatement& aMusicTable, const TUint aAttrId, |
|
612 CMPXMedia& aMedia); |
|
613 |
|
614 /** |
|
615 * Adds a song to the Music table |
|
616 * @param aSongId identifies the song |
|
617 * @param aMedia contains the song attributes |
|
618 * @param aDrive drive to add the song to |
|
619 * @param aItemChangedMessages item changed messages to update |
|
620 */ |
|
621 TBool DoAddSongL(TUint32 aSongId, const CMPXMedia& aMedia, TInt aDrive, |
|
622 CMPXMessageArray* aItemChangedMessages); |
|
623 |
|
624 /** |
|
625 * Updates a song in the Music table |
|
626 * @param aSongId identifies the song |
|
627 * @param aMedia contains the song attributes |
|
628 * @param aItemChangedMessages item changed messages to update or NULL |
|
629 */ |
|
630 CMPXDbActiveTask::TChangeVisibility DoUpdateSongL(TUint32 aSongId, const CMPXMedia& aMedia, |
|
631 CMPXMessageArray* aItemChangedMessages); |
|
632 |
|
633 /** |
|
634 * Updates a song in the Music table |
|
635 * @param aSongId identifies the song |
|
636 * @param aMedia contains the song attributes |
|
637 * @param aDrive drive to add the song to |
|
638 * @param aItemChangedMessages item changed messages to update |
|
639 * @param aRecordset current song record in the Music table. |
|
640 * Required to detect any field changes. |
|
641 */ |
|
642 CMPXDbActiveTask::TChangeVisibility DoUpdateSongL(TUint32 aSongId, const CMPXMedia& aMedia, TInt aDrive, |
|
643 CMPXMessageArray* aItemChangedMessages, RSqlStatement& aRecordset); |
|
644 |
|
645 /** |
|
646 * Get the DRM type of the given file |
|
647 * @param aFile file |
|
648 * @return DRM type. |
|
649 */ |
|
650 TMCDrmType DRMTypeL(const TDesC& aFile); |
|
651 |
|
652 /** |
|
653 * Generate searching criteria for music table from the given criteria |
|
654 * @param aGeneralId selection criteria (could be song/album/artist/genre/composer Id) |
|
655 * @param aContainerId selection criteria (could be artist/album id) |
|
656 * @param aType criteria type (EMPXItem or EMPXGroup) |
|
657 * @param aCriteria input criteria |
|
658 * @return a string containing the selection criteria. The ownership is passed to the caller. |
|
659 */ |
|
660 HBufC* GenerateMusicMatchingCriteriaLC(TUint32 aGeneralId, TUint32 aContainerId, |
|
661 TMPXGeneralType aType, const CMPXMedia& aCriteria); |
|
662 |
|
663 /** |
|
664 * Constructs the fields and corresponding values to be written into the music |
|
665 * table for update and insert statements. |
|
666 * @param aSongId identifies the song |
|
667 * @param aMedia contains the new song attributes |
|
668 * @param aItemChangedMessages item changed mesages to add to |
|
669 * @param aMusicTable points to the existing record in the Music table for updates or NULL |
|
670 * for inserts |
|
671 * @param aFields returns the field names to be updated |
|
672 * @param aValues returns the field values to be updated |
|
673 * @param aDrive drive the song is on |
|
674 * @return ETrue if the change is visible in the UI |
|
675 */ |
|
676 CMPXDbActiveTask::TChangeVisibility GenerateMusicFieldsValuesL(TUint32 aSongId, const CMPXMedia& aMedia, |
|
677 CMPXMessageArray* aItemChangedMessages, RSqlStatement* aMusicTable, |
|
678 CDesCArray& aFields, CDesCArray& aValues, TInt aDrive); |
|
679 |
|
680 /** |
|
681 * Generates the full URI from a music record. |
|
682 * @param aMusicTable music table record |
|
683 * @return Full URI string. The ownership is passed to the caller. |
|
684 */ |
|
685 HBufC* ConstructUriL(RSqlStatement& aMusicTable, TUint32 aMediaId); |
|
686 |
|
687 /** |
|
688 * Checks if the specified category field (artist/genre/composer/abstractalbum) |
|
689 * will change and notifies the observer if so. |
|
690 * @param aCategory identifies the category |
|
691 * @param aMedia contains the new record attributes |
|
692 * @param aAttribute corresponding attribute in the media parameter |
|
693 * @param aOldId the current category item ID |
|
694 * @param aDriveId drive ID the update is for |
|
695 * @param aItemChangedMessages item changed messages to append to |
|
696 * @param aItemId returns the category item ID |
|
697 * @return ETrue if the field was modified |
|
698 */ |
|
699 TBool UpdateCategoryFieldL(TMPXGeneralCategory aCategory, const CMPXMedia& aMedia, |
|
700 const TMPXAttribute& aAttribute, TUint32 aOldId, TInt aDriveId, |
|
701 CMPXMessageArray* aItemChangedMessages, TUint32& aItemId, const TDesC& aArt = KNullDesC); |
|
702 |
|
703 /** |
|
704 * Checks if album will change and notifies the observer if so. |
|
705 * @param aMedia contains the new record attributes |
|
706 * @param aAttribute corresponding attribute in the media parameter |
|
707 * @param aOldId the current category item ID |
|
708 * @param aDriveId drive ID the update is for |
|
709 * @param aItemChangedMessages item changed messages to append to |
|
710 * @param aItemId returns the album item ID |
|
711 * @param aArt old art of the music record |
|
712 * @param aCaseSensitive indicates whether case sensitivity should be taken |
|
713 * @return ETrue if the field was modified |
|
714 */ |
|
715 TBool UpdateCategoryFieldForAlbumL(const CMPXMedia& aMedia, |
|
716 const TMPXAttribute& aAttribute, TUint32 aOldId, TInt aDriveId, |
|
717 CMPXMessageArray* aItemChangedMessages, TUint32& aItemId, const TDesC& aArt = KNullDesC); |
|
718 |
|
719 /** |
|
720 * Checks if extra attributes are required. The "standard attribute set includes: |
|
721 * EMPXMediaGeneralId, EMPXMediaGeneralType, EMPXMediaGeneralCategory, |
|
722 * EMPXMediaGeneralTitle, EMPXMediaGeneralUri, and EMPXMediaGeneralFlags |
|
723 * @param aAttrs attributes to be checked |
|
724 * @return ETrue if extra attributes are required |
|
725 */ |
|
726 TBool ExtraFieldsRequired(const TArray<TMPXAttribute>& aAttrs); |
|
727 |
|
728 /** |
|
729 * Test whether the given media contains any supported attribute |
|
730 * @param aMedia media to be tested |
|
731 * @return ETrue if the media contains one or more supported attribute; |
|
732 * otherwise EFalse. |
|
733 */ |
|
734 TBool IsSupported(const CMPXMedia& aMedia); |
|
735 |
|
736 /** |
|
737 * Query all songs from the database and add results to the |
|
738 * iAllSongsQueryResult cache array. |
|
739 */ |
|
740 void ExecuteQueryAllSongsL(const TArray<TMPXAttribute>& aAttrs); |
|
741 |
|
742 private: // from MMPXTable |
|
743 |
|
744 /** |
|
745 * @see MMPXTable |
|
746 */ |
|
747 virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable); |
|
748 |
|
749 /** |
|
750 * @see MMPXTable |
|
751 */ |
|
752 virtual void DropTableL(RSqlDatabase& aDatabase); |
|
753 |
|
754 /** |
|
755 * @see MMPXTable |
|
756 */ |
|
757 virtual TBool CheckTableL(RSqlDatabase& aDatabase); |
|
758 |
|
759 private: |
|
760 |
|
761 /** |
|
762 * C++ constructor |
|
763 * @param aDbManager database manager to use for database interactions |
|
764 */ |
|
765 CMPXDbMusic(CMPXDbManager& aDbManager, MMPXDbMusicObserver& aObserver); |
|
766 |
|
767 /** |
|
768 * Second phase constructor. |
|
769 */ |
|
770 void ConstructL(CMPXResource& aResource); |
|
771 |
|
772 private: |
|
773 |
|
774 /** |
|
775 * Column indexes in the music table |
|
776 */ |
|
777 enum TMusicColumns |
|
778 { |
|
779 EMusicUniqueId = KMPXTableDefaultIndex, |
|
780 EMusicDbFlag, |
|
781 EMusicVolumeId, |
|
782 EMusicTitle, |
|
783 EMusicArtist, |
|
784 EMusicArt, |
|
785 EMusicDeleted, |
|
786 EMusicLocation, |
|
787 EMusicAlbumTrack, |
|
788 EMusicPlayCount, |
|
789 EMusicTimeAdded, |
|
790 EMusicTimePlayed, |
|
791 EMusicDuration, |
|
792 EMusicSync, |
|
793 EMusicModified, |
|
794 EMusicAlbum, |
|
795 EMusicGenre, |
|
796 EMusicComposer, |
|
797 EMusicReleaseDate, |
|
798 EMusicRating, |
|
799 EMusicComment, |
|
800 EMusicCopyright, |
|
801 EMusicUrl, |
|
802 EMusicDRM, |
|
803 EMusicLastPlayPosition, |
|
804 EMusicSampleRate, |
|
805 EMusicBitRate, |
|
806 EMusicNumChannels, |
|
807 EMusicCodec, |
|
808 EMusicMimeType, |
|
809 EMusicMTPDrmStatus, |
|
810 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
811 EMusicAlbumArtist, |
|
812 EMusicContainEmbeddedArt, |
|
813 EMusicAbstractAlbum, |
|
814 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
815 EMusicArtistName, |
|
816 EMusicAlbumName, |
|
817 EMusicGenreName, |
|
818 EMusicComposerName, |
|
819 EMusicFieldCount |
|
820 }; |
|
821 |
|
822 /* |
|
823 * Unique ID for Queries with a lifetime |
|
824 */ |
|
825 enum TMusicStatements |
|
826 { |
|
827 EOffsetQueryBasic = 0xabcd0001, |
|
828 EAscQueryBasic = 0xabcd0002, |
|
829 EDscQueryBasic = 0xabcd0003, |
|
830 EOffSetQuery = 0xabcd0004, |
|
831 EAscQuery = 0xabcd0005, |
|
832 EDscQuery = 0xabcd0006 |
|
833 }; |
|
834 |
|
835 private: // Data |
|
836 |
|
837 // file extensions to check DRM type, owned |
|
838 CDesCArrayFlat* iExtensionsDrm; |
|
839 MMPXDbMusicObserver& iObserver; |
|
840 #ifdef ABSTRACTAUDIOALBUM_INCLUDED |
|
841 TBool iArtNeedUpdated; |
|
842 #endif // ABSTRACTAUDIOALBUM_INCLUDED |
|
843 RPointerArray<CMPXMedia> iAllSongsQueryResult; |
|
844 }; |
|
845 |
|
846 #endif // MPXDBMUSIC_H |
|
847 |
|
848 // End of File |