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