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