1 /* |
|
2 * Copyright (c) 2006 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 provides the functions to manipulate the music collection |
|
15 * database. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef MPXDBHANDLER_H |
|
21 #define MPXDBHANDLER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <f32file.h> |
|
26 |
|
27 #include <mpxattribute.h> |
|
28 #include <mpxmessage2.h> |
|
29 #include <mpxmediageneraldefs.h> |
|
30 #include <mpxcollectionframeworkdefs.h> |
|
31 #include <mpxmessagegeneraldefs.h> |
|
32 #include <mpxcollectionmessagedefs.h> |
|
33 |
|
34 #include "mpxcollectiondbstd.h" |
|
35 #include "mpxcollectiondb.hrh" |
|
36 #include "mpxdbactivetask.h" |
|
37 #include "mpxdbmusic.h" // for MMPXDbMusicObserver |
|
38 #include "mpxdbartist.h" // for MMPXDbArtistObserver |
|
39 #include "mpxdbalbum.h" // for MMPXDbAlbumObserver |
|
40 #include "mpxdbplaylist.h" // for MMPXDbPlaylistObserver |
|
41 |
|
42 // FORWARD DECLARATIONS |
|
43 class CMPXMedia; |
|
44 class CMPXMediaArray; |
|
45 class CMPXCollectionDbManager; |
|
46 class CMPXDbPlaylist; |
|
47 class CMPXDbCategory; |
|
48 class CMPXDbAuxiliary; |
|
49 class CMPXDbAutoPlaylist; |
|
50 class CMPXDbArtist; |
|
51 class CMPXDbAlbum; |
|
52 class CMPXDbGenre; |
|
53 class CMPXDbComposer; |
|
54 |
|
55 // CLASS DECLARATION |
|
56 |
|
57 /** |
|
58 * Music collection database handler |
|
59 * |
|
60 * @lib MPXDbPlugin.lib |
|
61 */ |
|
62 class CMPXDbHandler : |
|
63 public CBase, |
|
64 public MMPXDbMusicObserver, |
|
65 public MMPXDbArtistObserver, |
|
66 public MMPXDbAlbumObserver, |
|
67 public MMPXDbPlaylistObserver |
|
68 { |
|
69 public: // Constructors and destructor |
|
70 |
|
71 /** |
|
72 * Two-phased constructor. |
|
73 * @param aFs file server session |
|
74 * @return a new CMPXDbHandler instance |
|
75 */ |
|
76 static CMPXDbHandler* NewL(RFs& aFs, CMPXResource& aResource); |
|
77 |
|
78 /** |
|
79 * Two-phased constructor. |
|
80 * @param aFs file server session |
|
81 * @return a new CMPXDbHandler instance |
|
82 */ |
|
83 static CMPXDbHandler* NewLC(RFs& aFs, CMPXResource& aResource); |
|
84 |
|
85 /** |
|
86 * Destructor. |
|
87 */ |
|
88 virtual ~CMPXDbHandler(); |
|
89 |
|
90 public: |
|
91 |
|
92 /** |
|
93 * Add a song to the music collection database |
|
94 * @param aMedia media object which contains file path, |
|
95 * artist, composer, name(title), track, etc... |
|
96 * @param aMessageArray change event message to notify client of the changes |
|
97 * @return TUint32 id of the item added |
|
98 */ |
|
99 TUint32 AddSongL(const CMPXMedia& aMedia, CMPXMessageArray* aMessageArray=NULL); |
|
100 |
|
101 /** |
|
102 * Add a song to the music collection without a database transaction; it |
|
103 * is assumed the transaction is created at a higher leve |
|
104 * @param aMedia media object which contains file path, |
|
105 * artist, composer, name(title), track, etc... |
|
106 * @param aMessageArray change event message to notify client of the changes |
|
107 * @return TUint32 id of the item added |
|
108 */ |
|
109 TUint32 AddSongWithNoTransactionL(const CMPXMedia& aMedia, CMPXMessageArray* aMessageArray=NULL); |
|
110 |
|
111 /** |
|
112 * Add a playlist to the collection |
|
113 * @param aMedia playlist media object with title and URI of the playlist. |
|
114 * @return playlist Id of the playlist created |
|
115 */ |
|
116 TUint32 AddPlaylistL(const CMPXMedia& aMedia); |
|
117 |
|
118 /** |
|
119 * Add songs to the specified playlist |
|
120 * @param aMedia playlist media object with playlist Id. |
|
121 * @return playlist Id of the playlist |
|
122 */ |
|
123 TUint32 AddSongToPlaylistL(const CMPXMedia& aMedia); |
|
124 |
|
125 /** |
|
126 * Update song info for a song in the music collection database |
|
127 * @param aMedia songDetails object which contains file path, |
|
128 * artist, composer, name(title), track, etc... |
|
129 * @param aItemChangedMessages a list of change events as a result of the |
|
130 * song update |
|
131 * @return ETrue if UI visible change else EFalse |
|
132 */ |
|
133 CMPXDbActiveTask::TChangeVisibility UpdateSongL(const CMPXMedia& aMedia, |
|
134 CMPXMessageArray& aItemChangedMessages); |
|
135 |
|
136 /** |
|
137 * Update playlist info in the music collection database |
|
138 * @param aMedia playlist details object which contains file path, |
|
139 * timestamps etc. |
|
140 * @param aMessageArray change event messages for the playlist update |
|
141 */ |
|
142 void UpdatePlaylistL(const CMPXMedia& aMedia, CMPXMessageArray& aMessageArray); |
|
143 |
|
144 /** |
|
145 * Update the songs for a playlist in the music collection database |
|
146 * @param aMedia playlist details object which contains the playlist songs. |
|
147 * @param aMessage change event message for the playlist update |
|
148 */ |
|
149 void UpdatePlaylistSongsL(const CMPXMedia& aMedia, CMPXMessage& aMessage); |
|
150 |
|
151 /** |
|
152 * Reorder the specified song in the specified playlist |
|
153 * @param aPlaylistId id of the playlist which contains the song to be reordered |
|
154 * @param aSongId id of the song to be reordered |
|
155 * @param aOriginalOrdinal the original ordinal of the song within the playlist. |
|
156 * Ordinal starts from 0. |
|
157 * @param aNewOrdinal the new ordinal of the song within the playlist. Ordinal |
|
158 * starts from 0. |
|
159 * @param aMessage change event message for the playlist update |
|
160 */ |
|
161 void ReorderPlaylistL(const TMPXItemId& aPlaylistId, const TMPXItemId& aSongId, |
|
162 TUint aOriginalOrdinal, TUint aNewOrdinal, CMPXMessage& aMessage); |
|
163 |
|
164 /** |
|
165 * Remove all songs within music collection database |
|
166 */ |
|
167 void RemoveEntireCollectionL(); |
|
168 |
|
169 /** |
|
170 * Remove a song from the music collection database |
|
171 * @param aSongId ID of the song to be removed |
|
172 * @param aUriArray a descriptor array to contain the URI of the deleted file |
|
173 * @param aItemChangedMessages a list of change events as a result of the song removal |
|
174 * @param aDeleteRecord indicates whether the client has explictly requested |
|
175 * to delete the records from the database. If ETrue, records |
|
176 * associated with the media will be deleted from the database; |
|
177 * if EFalse, whether to mark the records as deleted or to delete |
|
178 * the records will be based on other deciding factors. |
|
179 */ |
|
180 void RemoveSongL(TUint32 aSongId, CDesCArray& aUriArray, |
|
181 CMPXMessageArray& aItemChangedMessages, TBool aDeleteRecord = EFalse); |
|
182 |
|
183 /** |
|
184 * Removes a category of songs from the music collection, and its |
|
185 * corresponding category in the lookup table |
|
186 * @param aCategory the category to remove |
|
187 * @param aCategoryId ID of the category to remove |
|
188 * @param aUriArray a descriptor array to contain the URI of the deleted songs |
|
189 * @param aItemChangedMessages a list of change events as a result of the song removal |
|
190 */ |
|
191 void RemoveSongsMatchingCategoryL(TMPXGeneralCategory aCategory, TUint32 aCategoryId, |
|
192 CDesCArray& aUriArray, CMPXMessageArray& aItemChangedMessages); |
|
193 |
|
194 /** |
|
195 * Removes songs from the music collection belonging to the |
|
196 * specified artist and album as well as the actual category |
|
197 * in the lookup table |
|
198 * @param aArtistId id of the artist |
|
199 * @param aAlbumId id of the album |
|
200 * @param aUriArray a descriptor array to contain the URI of the deleted file(s) |
|
201 * @param aItemChangedMessages a list of change events as a result of the song removal |
|
202 */ |
|
203 void RemoveSongsMatchingArtistAndAlbumL(TUint32 aArtistId, TUint32 aAlbumId, |
|
204 CDesCArray& aUriArray, CMPXMessageArray& aItemChangedMessages); |
|
205 |
|
206 /** |
|
207 * Remove all playlists from the collection |
|
208 */ |
|
209 void RemoveAllPlaylistsL(); |
|
210 |
|
211 /** |
|
212 * Remove a playlist This will remove all the songs from the playlist |
|
213 * @param aPlaylistId ID of the playlist to remove |
|
214 * @param aUriArray a descriptor array to contain the URI of the deleted file |
|
215 * @param aItemChangedMessages a list of change events as a result of the |
|
216 * playlist removal |
|
217 */ |
|
218 void RemovePlaylistL(TUint32 aPlaylistId, CDesCArray& aUriArray, |
|
219 CMPXMessageArray& aItemChangedMessages); |
|
220 |
|
221 /** |
|
222 * Remove a song from the specified playlist. |
|
223 * @param aPlaylistId ID of the playlist to remove the song from |
|
224 * @param aSongId Id of the song in the playlist to be removed |
|
225 * @param aOrdinal the ordinal of the song in the playlist. This uniquely |
|
226 * identifies which song in the playlist to be removed; whereas song |
|
227 * Id doesn't because duplicate tracks in the playlist are allowed. |
|
228 * The position is relative to zero, i.e. zero implies that the song |
|
229 * at the beginning of the playlist is to be removed. |
|
230 * @param aItemChangedMessages a list of change events as a result of the |
|
231 * song removal |
|
232 */ |
|
233 void RemoveSongFromPlaylistL(TUint32 aPlaylist, const TMPXItemId& aSongId, |
|
234 TInt aOrdinal, CMPXMessageArray& aItemChangedMessages); |
|
235 |
|
236 /** |
|
237 * Delete records in all databases which have been marked as deleted |
|
238 */ |
|
239 void CleanupDeletedRecordsL(); |
|
240 |
|
241 /** |
|
242 * Get all songs from the music collection databasee |
|
243 * @param aMediaArray Array to place all the songs' required info |
|
244 * @param aAttrs required attributes |
|
245 */ |
|
246 void GetAllSongsL(CMPXMediaArray* aMediaArray, |
|
247 const TArray<TMPXAttribute>& aAttrs); |
|
248 |
|
249 /** |
|
250 * Get a limited number of songs from the music collection databasee |
|
251 * @param aMediaArray Array to place all the songs' required info |
|
252 * @param aAttrs required attributes |
|
253 * @param aLimit maximum number of songs to retrieve |
|
254 */ |
|
255 void GetAllSongsLimitedL(const TArray<TMPXAttribute>& aAttrs, |
|
256 CMPXMediaArray& aMediaArray, TInt aLimit); |
|
257 |
|
258 /** |
|
259 * Get songs from the music collection database incrementally |
|
260 * @param aMediaArray Array to place all the songs' required info |
|
261 * @param aAttrs required attributes |
|
262 * @param aTitle title to use as a key |
|
263 * @param aNumOfSongs number of songs to read |
|
264 * @param aAsc ascending or descending data read |
|
265 */ |
|
266 void GetSongsInBlockL(CMPXMediaArray* aMediaArray, |
|
267 const TArray<TMPXAttribute>& aAttrs, |
|
268 TPtrC aTitle, |
|
269 TUint aNumOfSongs, |
|
270 TBool aAsc); |
|
271 |
|
272 |
|
273 /** |
|
274 * Get songs from the music collection starting at a particular offset |
|
275 * ONLY use this as the first query to locate particular item. Should use |
|
276 * GetSongsInBlockL() to fetch in blocks with a particular index |
|
277 * @param aMediaArray Array to store the results |
|
278 * @param aAttrs attributes to fetch |
|
279 * @param aOffset offset to start reading |
|
280 * @param aCount number of items to get |
|
281 */ |
|
282 void GetSongsAtOffsetL( CMPXMediaArray* aMediaArray, |
|
283 const TArray<TMPXAttribute>& aAttrs, |
|
284 TInt aOffset, |
|
285 TInt aCount ); |
|
286 |
|
287 /** |
|
288 * Get all the songs that match the given artist ID |
|
289 * @param aArtistId ID of the artist to match |
|
290 * @param aAttrs required attributes |
|
291 * @param aMediaArray Array to place all the matching songs' required |
|
292 * attributes |
|
293 */ |
|
294 void GetSongsMatchingArtistL(TUint aArtistId, |
|
295 const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray); |
|
296 |
|
297 /** |
|
298 * Get all the songs that match the given album ID |
|
299 * @param aAlbumId ID of the album to match |
|
300 * @param aAttrs required attributes |
|
301 * @param aMediaArray Array to place all the matching songs' required info |
|
302 */ |
|
303 void GetSongsMatchingAlbumL(TUint aAlbumId, |
|
304 const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray); |
|
305 |
|
306 /** |
|
307 * Get all the songs that match the given artist and album ID |
|
308 * @param aArtistId ID of the artist to match |
|
309 * @param aAlbumId ID of the album to match |
|
310 * @param aAttrs required attributes |
|
311 * @param aMediaArray Array to place all the matching songs' required info |
|
312 */ |
|
313 void GetSongsMatchingArtistAndAlbumL(TUint aArtistId, TUint aAlbumId, |
|
314 const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray); |
|
315 |
|
316 /** |
|
317 * Get all the songs that match the given genre ID |
|
318 * @param aGenreId ID of the genre to match |
|
319 * @param aAttrs required attributes |
|
320 * @param aMediaArray Array to place all the matching songs' required info |
|
321 */ |
|
322 void GetSongsMatchingGenreL(TUint aGenreId, |
|
323 const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray); |
|
324 |
|
325 /** |
|
326 * Get all the songs that match the given composer ID |
|
327 * @param aComposerId ID of the composer to match |
|
328 * @param aAttrs required attributes |
|
329 * @param aMediaArray Array to place all the matching songs' required info |
|
330 */ |
|
331 void GetSongsMatchingComposerL(TUint aComposerId, |
|
332 const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray); |
|
333 |
|
334 /** |
|
335 * Get all the songs that match the given playlist ID |
|
336 * @param aPlaylistId ID of the playlist to match |
|
337 * @param aAttrs required attributes |
|
338 * @param aMediaArray Array to place all the required song info |
|
339 */ |
|
340 void GetSongsMatchingPlaylistL(TUint aPlaylistId, |
|
341 const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray* aMediaArray); |
|
342 |
|
343 /** |
|
344 * Get the song info that matches the given song ID from Songs table. |
|
345 * @param aSongId ID of the song |
|
346 * @param aAttrs required attributes |
|
347 * @param aMedia returns the song info |
|
348 */ |
|
349 void GetSongL(TUint32 aSongId, const TArray<TMPXAttribute>& aAttrs, |
|
350 CMPXMedia& aMedia); |
|
351 |
|
352 /** |
|
353 * Appends the media object with the song information to the specified array. |
|
354 * @param aSongId ID of the song |
|
355 * @param aAttrs required attributes |
|
356 * @param aMediaArray on return the song info is appended to this array |
|
357 */ |
|
358 void GetSongL(TUint32 aSongId, const TArray<TMPXAttribute>& aAttrs, |
|
359 CMPXMediaArray& aMediaArray); |
|
360 |
|
361 /** |
|
362 * Get the song info that matches the given song ID from Songs table. |
|
363 * The song info will first be populated from Playlist table and |
|
364 * if the Songs table exists in the drive where the song is located, |
|
365 * song info will be overwritten from Songs table. This enables the |
|
366 * support for displaying song title in a playlist when the drive |
|
367 * where the song is located is not present. |
|
368 * @aSongId ID of the song |
|
369 * @aPlaylistId ID of the playlist the song belongs to. |
|
370 * @param aAttrs required attributes |
|
371 * @param aMediaArray Array to place all the required song info |
|
372 * @leave KErrNotFound if the song could not be found in the |
|
373 * PlaylistSongs table |
|
374 */ |
|
375 void GetPlaylistSongL(TUint32 aSongId, TUint32 aPlaylistId, |
|
376 const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aMedia); |
|
377 |
|
378 /** |
|
379 * Appends the a media object with the song information to the specified array. |
|
380 * @param aSongId ID of the song |
|
381 * @param aPlaylistId ID of the playlist |
|
382 * @param aAttrs required attributes |
|
383 * @param aMediaArray on return the song info is appended to this array |
|
384 */ |
|
385 void GetPlaylistSongL(TUint32 aSongId, TUint32 aPlaylistId, |
|
386 const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray); |
|
387 |
|
388 /** |
|
389 * Get the song ID of the song that matches the given URI |
|
390 * @param aUri URI to match |
|
391 * @return song ID |
|
392 */ |
|
393 TUint32 GetSongIdMatchingUriL(const TDesC& aUri); |
|
394 |
|
395 /** |
|
396 * Get all the artist names from the music collection database sorted by name. |
|
397 * @param aAttrs required attributes |
|
398 * @param aMediaArray Array to place all the artists' required info |
|
399 */ |
|
400 void GetAllArtistsL(const TArray<TMPXAttribute>& aAttrs, |
|
401 CMPXMediaArray* aMediaArray); |
|
402 |
|
403 /** |
|
404 * Get all the album names from the music collection database sorted by name. |
|
405 * @param aAttrs required attributes |
|
406 * @param aMediaArray Array to place all the albums' required info |
|
407 */ |
|
408 void GetAllAlbumsL(const TArray<TMPXAttribute>& aAttrs, |
|
409 CMPXMediaArray* aMediaArray); |
|
410 |
|
411 /** |
|
412 * Get all the albums that match the given artist ID sorted by name. |
|
413 * @param aArtistId ID of the artist to match |
|
414 * @param aAttrs required attributes |
|
415 * @param aMediaArray Array to place all the matching albums' required info |
|
416 */ |
|
417 void GetAlbumsMatchingArtistL(TUint aArtistId, |
|
418 const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray); |
|
419 |
|
420 /** |
|
421 * Get all the genre names from the collection |
|
422 * @param aAttrs required attributes |
|
423 * @param aMediaArray Array to place all the genres' required info |
|
424 */ |
|
425 void GetAllGenresL(const TArray<TMPXAttribute>& aAttrs, |
|
426 CMPXMediaArray* aMediaArray); |
|
427 |
|
428 /** |
|
429 * Get all the composer names from the collection |
|
430 * @param aAttrs required attributes |
|
431 * @param aMediaArray Array to place all the composers' required info |
|
432 */ |
|
433 void GetAllComposersL(const TArray<TMPXAttribute>& aAttrs, |
|
434 CMPXMediaArray* aMediaArray); |
|
435 |
|
436 /** |
|
437 * Get the playlist ID of the playlist that matches the given URI |
|
438 * @param aUri URI to match |
|
439 * @return playlist ID to return |
|
440 */ |
|
441 TUint32 GetPlaylistIdMatchingUriL(const TDesC& aUri); |
|
442 |
|
443 /** |
|
444 * Checks if the specified ID corresponds to an auto playlist. |
|
445 * @param aPlaylistId ID to be checked |
|
446 * @return ETrue if it corresponds to an auto playlist, EFalse otherwise |
|
447 */ |
|
448 TBool IsAutoPlaylistL(TUint32 aPlaylistId); |
|
449 |
|
450 /** |
|
451 * Get all the playlist names from the collection |
|
452 * @param aMediaArray Array to place all the playlists' required info |
|
453 * @param aAttrs required attributes |
|
454 */ |
|
455 void GetAllPlaylistsL(CMPXMediaArray* aMediaArray, |
|
456 const TArray<TMPXAttribute>& aAttrs); |
|
457 |
|
458 /** |
|
459 * Get all the system playlist names from the collection |
|
460 * @param aMediaArray Array to place all the system playlists' required info |
|
461 */ |
|
462 void GetAllSystemPlaylistNamesL(CMPXMediaArray* aMediaArray); |
|
463 |
|
464 /** |
|
465 * Get title from the Id |
|
466 * @param Id to search for |
|
467 * @return name matching the ID |
|
468 */ |
|
469 HBufC* GetNameMatchingIdL(const TUint32 aId) const; |
|
470 |
|
471 /** |
|
472 * Get URI from the Id |
|
473 * @param Id to search for |
|
474 * @return URI matching the ID |
|
475 * @leave KErrNotSupported if the ID refers to an invalid category |
|
476 */ |
|
477 HBufC* GetUriMatchingIdL(const TUint32 aId) const; |
|
478 |
|
479 /** |
|
480 * Retrieve category record with information as specified in the given |
|
481 * attributes |
|
482 * @param aCategoryId Id of the record to be retrieved |
|
483 * @param aCategory category type |
|
484 * @param aAttrs information to return about the specified category |
|
485 * @param aMedia returns the category information |
|
486 */ |
|
487 void GetCategoryL(const TUint32 aCategoryId, TMPXGeneralCategory aCategory, |
|
488 const TArray<TMPXAttribute>& aAttrs, CMPXMedia* aMedia); |
|
489 |
|
490 /** |
|
491 * Get the duration for all songs |
|
492 * @return duration |
|
493 */ |
|
494 TInt GetAllSongsDurationL(); |
|
495 |
|
496 /** |
|
497 * Get the duration for all songs for a specified artist |
|
498 * @param aArtistId identifies the artist |
|
499 * @return duration |
|
500 */ |
|
501 TInt GetArtistDurationL(TInt aArtistId); |
|
502 |
|
503 /** |
|
504 * Get the duration for all songs in a specified album |
|
505 * @param aAlbumId identifies the album |
|
506 * @return duration |
|
507 */ |
|
508 TInt GetAlbumDurationL(TInt aAlbumId); |
|
509 |
|
510 /** |
|
511 * Get the duration for all songs for a specified artist and album |
|
512 * @param aArtistId identifies the artist |
|
513 * @param aAlbumId identifies the album |
|
514 * @return duration |
|
515 */ |
|
516 TInt GetArtistAlbumDurationL(TInt aArtistId, TInt aAlbumId); |
|
517 |
|
518 /** |
|
519 * Get the duration for all songs for a specified composer |
|
520 * @param aComposerId identifies the composer |
|
521 * @return duration |
|
522 */ |
|
523 TInt GetComposerDurationL(TInt aComposerId); |
|
524 |
|
525 /** |
|
526 * Get the duration for all songs for a specified genre |
|
527 * @param aGenreId identifies the genre |
|
528 * @return duration |
|
529 */ |
|
530 TInt GetGenreDurationL(TInt aGenreId); |
|
531 |
|
532 /** |
|
533 * Get the duration for all songs in a user playlist |
|
534 * @param aPlaylistId identifies the playlist |
|
535 * @return duration |
|
536 */ |
|
537 TInt GetUserPlaylistDurationL(TInt aPlaylistId); |
|
538 |
|
539 /** |
|
540 * Get the duration for all songs for a specified playlist |
|
541 * @param aPlaylistId identifies the playlist |
|
542 * @return duration |
|
543 */ |
|
544 TInt GetPlaylistDurationL(TInt aPlaylistId); |
|
545 |
|
546 /** |
|
547 * Fetch the total number of items in the specified category |
|
548 * @param aCategory category to be queried |
|
549 * @return number of items. |
|
550 */ |
|
551 TInt NumberOfItemsL(TMPXGeneralCategory aCategory); |
|
552 |
|
553 /** |
|
554 * Find media(s) from the collection |
|
555 * @param aCriteria selection criteria |
|
556 * @param aAttrs attributes for the matching media |
|
557 * @return matching media. Ownership is transferred. |
|
558 * @leave KErrArgument if the criteria do not include a type |
|
559 * or category |
|
560 */ |
|
561 CMPXMedia* FindAllLC(const CMPXMedia& aCriteria, |
|
562 const TArray<TMPXAttribute>& aAttrs); |
|
563 |
|
564 /** |
|
565 * Set the last refreshed time |
|
566 * @param aTime the updated last refresh time |
|
567 */ |
|
568 void SetLastRefreshedTimeL(TTime aTime); |
|
569 |
|
570 /** |
|
571 * Get the last refreshed time |
|
572 * @return last refreshed time |
|
573 */ |
|
574 TTime GetLastRefreshedTimeL(); |
|
575 |
|
576 /** |
|
577 * Set the db corrupted bit in the aux table for all drives |
|
578 * @param aCorrupted flag indicating whether or not the db is corrupted |
|
579 */ |
|
580 void SetDBCorruptedL(TBool aCorrupted); |
|
581 |
|
582 /** |
|
583 * Get the db corrupted bit in the aux table ( or of all drives ) |
|
584 * @return ETrue if database is corrupted, else EFalse |
|
585 */ |
|
586 TBool IsDBCorruptedL(); |
|
587 |
|
588 /** |
|
589 * Checks if the database has been created |
|
590 * @return ETrue if file has been created |
|
591 */ |
|
592 TBool DatabaseCreated(); |
|
593 |
|
594 /** |
|
595 * Close and re-open the music collection database stored on the |
|
596 * specified drive |
|
597 * @param aDrive drive containing the music collection database to re-open |
|
598 */ |
|
599 void OpenDatabaseL(TInt aDrive); |
|
600 |
|
601 /** |
|
602 * Close a database for a particular drive |
|
603 * @param aDrive drive to close |
|
604 */ |
|
605 void CloseDatabaseL(TInt aDrive); |
|
606 |
|
607 /** |
|
608 * Recreate all databases. |
|
609 */ |
|
610 void ReCreateDatabasesL(); |
|
611 |
|
612 /** |
|
613 * Starts a refresh operation. |
|
614 */ |
|
615 void RefreshStartL(); |
|
616 |
|
617 /** |
|
618 * Ends a refresh operation. |
|
619 */ |
|
620 void RefreshEndL(); |
|
621 |
|
622 /** |
|
623 * Notification of mtp start |
|
624 */ |
|
625 void MtpStartL(); |
|
626 |
|
627 /** |
|
628 * Notification of mtp end |
|
629 */ |
|
630 void MtpEndL(); |
|
631 /** |
|
632 * Get total record count for music in db |
|
633 * @param aDrive, specifies drive number for db selection |
|
634 * @return count |
|
635 */ |
|
636 TUint GetMusicCountL(TInt aDrive); |
|
637 |
|
638 /** |
|
639 * Get total record count for playlists in db |
|
640 * @param aDrive, specifies drive number for db selection |
|
641 * @return count |
|
642 */ |
|
643 TUint GetPlaylistCountL(TInt aDrive); |
|
644 |
|
645 /** |
|
646 * Get total record count for music and playlists in db |
|
647 * @param aDrive, specifies drive number for db selection |
|
648 * @return count |
|
649 */ |
|
650 TUint GetTotalCountL(TInt aDrive); |
|
651 |
|
652 /** |
|
653 * Get URIs for a given amount of songs |
|
654 * @param aDrive, specifies drive number for db selection |
|
655 * @param aFromID, specifies unique ID of last record retrieved |
|
656 * @param aRecords, specifies the number of records to get |
|
657 * @param aUriArr, will contain all URIs on return |
|
658 * @param aLastID, will contain unique ID of a last record in the array |
|
659 */ |
|
660 void GetMusicUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords, |
|
661 CDesCArray& aUriArr, TInt& aLastID); |
|
662 |
|
663 /** |
|
664 * Get URIs for a given amount of playlists |
|
665 * @param aDrive, specifies drive number for db selection |
|
666 * @param aFromID, specifies unique ID of last record retrieved |
|
667 * @param aRecords, specifies the number of records to get |
|
668 * @param aUriArr, will contain all URIs on return |
|
669 * @param aLastID, will contain unique ID of a last record in the array |
|
670 */ |
|
671 void GetPlaylistUriArrayL(TInt aDrive, TInt aFromID, TInt aRecords, |
|
672 CDesCArray& aUriArr, TInt& aLastID); |
|
673 |
|
674 /** |
|
675 * Starts a transaction on all open databases. |
|
676 */ |
|
677 void BeginTransactionL(); |
|
678 |
|
679 /** |
|
680 * Commits or rolls back a transaction. |
|
681 * @param aError if error then rolls back the transaction and leaves |
|
682 * if KErrNone it commits the transaction |
|
683 */ |
|
684 void EndTransactionL(TInt aError); |
|
685 |
|
686 /** |
|
687 * Checks if the database is currently in a transaction. |
|
688 * |
|
689 * @return ETrue if database is currently in a transaction, EFalse otherwise |
|
690 */ |
|
691 TBool InTransaction(); |
|
692 |
|
693 /** |
|
694 * Notifies the handler that the collection will be closed. |
|
695 * It is called before closing the collection. |
|
696 */ |
|
697 void PreCloseCollectionL(); |
|
698 |
|
699 /** |
|
700 * Notifies the handler that the collection was closed. |
|
701 */ |
|
702 void CollectionClosed(); |
|
703 |
|
704 /** |
|
705 * Notifies the handler that the collection was opened. |
|
706 */ |
|
707 void CollectionOpenedL(); |
|
708 |
|
709 /** |
|
710 * Checks if the spefified drive is a remove drive |
|
711 */ |
|
712 TBool IsRemoteDrive(TDriveNumber aDrive); |
|
713 |
|
714 /** |
|
715 * Checks if there is a drive that has a low disk space |
|
716 * @leave KErrDiskFull if the space on one of the drives is below the |
|
717 * critical level |
|
718 */ |
|
719 void CheckDiskSpaceOnDrivesL(); |
|
720 |
|
721 private: |
|
722 |
|
723 /** |
|
724 * Add a song to the music collection database |
|
725 * @param aMedia: media object which contains file path, |
|
726 * artist, composer, name(title), track, etc... |
|
727 * @param aMessage change event message to notify client of the changes |
|
728 * @return Id of the song added |
|
729 * @leave KErrArgument if the media doe snot include the song URI |
|
730 */ |
|
731 TUint32 DoAddSongL(const CMPXMedia& aMedia, CMPXMessageArray* aMessageArray); |
|
732 |
|
733 /** |
|
734 * Add a playlist to the collection |
|
735 * @param aMedia playlist media object with title and URI of the playlist. |
|
736 * @return ID of the playlist created |
|
737 */ |
|
738 TUint32 DoAddPlaylistL(const CMPXMedia& aMedia); |
|
739 |
|
740 /** |
|
741 * Add songs to the specified playlist |
|
742 * @param aMedia playlist media object with playlist Id. |
|
743 * @return playlist Id of the playlist |
|
744 */ |
|
745 TUint32 DoAddSongToPlaylistL(const CMPXMedia& aMedia); |
|
746 |
|
747 /** |
|
748 * Update song info for a song in the music collection database |
|
749 * @param aMedia songDetails object which contains file path, |
|
750 * artist, composer, name(title), track, etc... |
|
751 * @param aItemChangedMessages a list of items changed |
|
752 * @return ETrue if UI visible change |
|
753 * @leave KErrNotSupported if the song ID could not be constructed |
|
754 */ |
|
755 CMPXDbActiveTask::TChangeVisibility DoUpdateSongL(const CMPXMedia& aMedia, |
|
756 CMPXMessageArray& aItemChangedMessages); |
|
757 |
|
758 /** |
|
759 * Update playlist info in the music collection database |
|
760 * @param aMedia playlist details object which contains file path, |
|
761 * timestamps etc... |
|
762 * @param aMessage change event message for the playlist update |
|
763 */ |
|
764 void DoUpdatePlaylistL(const CMPXMedia& aMedia, CMPXMessageArray& aMessageArray); |
|
765 |
|
766 /** |
|
767 * Replace all songs for a playlist. This method is called when harvester |
|
768 * scans an updated playlist. This will also be called if MTP wants to |
|
769 * replace the contents of an existing playlist. The implementation deleted the |
|
770 * existing songs first and then inserts the new ones. |
|
771 * @param aMedia playlist and songs details object which contains file path, |
|
772 * timestamps etc... |
|
773 * @param aMessage change event message for the playlist update |
|
774 */ |
|
775 void DoUpdatePlaylistSongsL(const CMPXMedia& aMedia, CMPXMessage& aMessage); |
|
776 |
|
777 /** |
|
778 * Reorder the specified song in the specified playlist |
|
779 * @param aPlaylistId id of the playlist which contains the song to be reordered |
|
780 * @param aSongId id of the song to be reordered |
|
781 * @param aOriginalOrdinal the original ordinal of the song within the playlist. |
|
782 * Ordinal starts from 0. |
|
783 * @param aNewOrdinal the new ordinal of the song within the playlist. Ordinal |
|
784 * starts from 0. |
|
785 * @param aMessage change event message for the playlist update |
|
786 */ |
|
787 void DoReorderPlaylistL(const TMPXItemId& aPlaylistId, const TMPXItemId& aSongId, |
|
788 TUint aOriginalOrdinal, TUint aNewOrdinal, CMPXMessage& aMessage); |
|
789 |
|
790 /** |
|
791 * Deletes a song. In addition to deleting the song record from the music |
|
792 * table takes care of updating the category and playlist tables. |
|
793 * @param aSongId song to be deleted |
|
794 * @param aUriArray on return contains the URIs of the song deleted. |
|
795 * @param aItemChangedMessages on return contains changed messages for all |
|
796 * affected items |
|
797 * @param aDeleteRecord ETrue if the record is to be deleted, EFalse if it is |
|
798 * to be marked as deleted. |
|
799 */ |
|
800 void DoRemoveSongL(TUint32 aSongId, CDesCArray& aUriArray, |
|
801 CMPXMessageArray& aItemChangedMessages, TBool aDeleteRecord); |
|
802 |
|
803 /** |
|
804 * Deletes the song from the playlist tables |
|
805 * @param aSongId song to be deleted |
|
806 * @param aItemChangedMessages on return contains changed messages for all |
|
807 * affected items |
|
808 */ |
|
809 void DoRemoveSongFromPlaylistL(TUint32 aSongId,CMPXMessageArray& aItemChangedMessages); |
|
810 |
|
811 /** |
|
812 * Deletes all the songs for a given category. The implementation uses |
|
813 * DoRemoveSongL for the business logic. |
|
814 * @param aCategory category type (artist/album/genre/composer) |
|
815 * @param aCategoryId identifies the category item |
|
816 * @param aUriArray on return contains the URIs of the songs deleted. |
|
817 * @param aItemChangedMessages on return contains changed messages for all |
|
818 * affected items |
|
819 * @leave KErrNotSupported if invalid category |
|
820 */ |
|
821 void DoRemoveSongsMatchingCategoryL(TMPXGeneralCategory aCategory, |
|
822 TUint32 aCategoryId, CDesCArray& aUriArray, |
|
823 CMPXMessageArray& aItemChangedMessages); |
|
824 |
|
825 /** |
|
826 * Deletes all the songs for a given artist and album. |
|
827 * The implementation uses DoRemoveSongL for the business logic. |
|
828 * @param aArtistId identifies the artist |
|
829 * @param aAlbumId identifies the album |
|
830 * @param aUriArray on return contains the URIs of the songs deleted. |
|
831 * @param aItemChangedMessages on return contains changed messages for all affected items |
|
832 */ |
|
833 void DoRemoveSongsMatchingArtistAndAlbumL(TUint32 aArtistId, TUint32 aAlbumId, |
|
834 CDesCArray& aUriArray, CMPXMessageArray& aItemChangedMessages); |
|
835 |
|
836 /** |
|
837 * Deletes all the playlists in all databases. Note that the songs are not affected. |
|
838 */ |
|
839 void DoRemoveAllPlaylistsL(); |
|
840 |
|
841 /** |
|
842 * Deletes a specified playlist. |
|
843 * @param aPlaylistId the playlist to be deleted. |
|
844 * @param aUriArray on return contains the URIs of the items deleted. |
|
845 * @param aItemChangedMessages on return contains changed messages for all |
|
846 * affected items |
|
847 */ |
|
848 void DoRemovePlaylistL(TUint32 aPlaylistId, CDesCArray& aUriArray, |
|
849 CMPXMessageArray& aItemChangedMessages); |
|
850 |
|
851 /** |
|
852 * Deletes a song from a playlist. |
|
853 * @param aPlaylistId identifies the playlist. |
|
854 * @param aSongId song to be deleted. |
|
855 * @param aOrdinal song ordinal in case there are multiple instances of the same |
|
856 * song in the playlist. |
|
857 * @param aItemChangedMessages on return contains changed messages for all |
|
858 * affected items |
|
859 */ |
|
860 void DoRemoveSongFromPlaylistL(TUint32 aPlaylistId, const TMPXItemId& aSongId, |
|
861 TInt aOrdinal, CMPXMessageArray& aItemChangedMessages); |
|
862 |
|
863 /** |
|
864 * Deletes all song records marked as deleted. |
|
865 */ |
|
866 void DoCleanupDeletedRecordsL(); |
|
867 |
|
868 /** |
|
869 * Find items in the collection |
|
870 * @param aCriteria selection criteria |
|
871 * @param aAttrs attributes for the matching media |
|
872 * @param aMediaArray returns the matching entries |
|
873 */ |
|
874 void FindAllL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs, |
|
875 CMPXMediaArray* aMediaArray); |
|
876 |
|
877 /** |
|
878 * Find a song. |
|
879 * @param aCriteria selection criteria |
|
880 * @param aAttrs attributes for the matching media |
|
881 * @param aMediaArray returns the matching entries |
|
882 */ |
|
883 void FindSongL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs, |
|
884 CMPXMediaArray& aMediaArray); |
|
885 |
|
886 /** |
|
887 * Gets the songs for a specified playlist |
|
888 * @param aPlaylistId identifies the playlist |
|
889 * @param aAttrs attributes to be returned |
|
890 * @param aMediaArray returns the matching entries |
|
891 */ |
|
892 void GetPlaylistSongsL(TUint32 aPlaylistId, const TArray<TMPXAttribute>& aAttrs, |
|
893 CMPXMediaArray& aMediaArray); |
|
894 |
|
895 /** |
|
896 * Find an album |
|
897 * @param aCriteria selection criteria |
|
898 * @param aAttrs attributes to be returned |
|
899 * @param aMediaArray returns the matching entries |
|
900 */ |
|
901 void FindAlbumL(const CMPXMedia& aCriteria, const TArray<TMPXAttribute>& aAttrs, |
|
902 CMPXMediaArray& aMediaArray); |
|
903 |
|
904 /** |
|
905 * Extracts the playlist ID and drive ID from the media object. |
|
906 * @param aMedia playlist information |
|
907 * @param aPlaylistId returns the playlist ID |
|
908 * @param aPlaylistDriveId returns the drive ID |
|
909 * @leave KErrArgument if the media does not include the ID and URI |
|
910 */ |
|
911 void ProcessPlaylistMediaL(CMPXMedia& aMedia, TUint32& aPlaylistId, |
|
912 TInt& aPlaylistDriveId); |
|
913 |
|
914 /** |
|
915 * Updates all the song entries in the playlist media with extra |
|
916 * information from the music table. |
|
917 * @param aMedia inout, contains the playlist/songs information |
|
918 * @leave KErrArgument if the song does not exist in the music table and |
|
919 * the media does not include a URI |
|
920 */ |
|
921 void UpdatePlaylistSongInfoL(CMPXMedia& aMedia); |
|
922 |
|
923 /** |
|
924 * Makes sure all the folders specified in the array parameter are created, |
|
925 * otherwise it tries to create them. Updates the iDbDrives member variable |
|
926 * with the drives corresponding to the folders. |
|
927 * @param aFolders contains all the folders to be processed |
|
928 */ |
|
929 void ProcessMusicFoldersL(const CDesCArray& aFolders); |
|
930 |
|
931 /** |
|
932 * Returns the CMPXDbCategory instance associated with the specified |
|
933 * category type |
|
934 * @param aCategory category type |
|
935 * @return corresponding CMPXDbCategory instance |
|
936 * @leave KErrNotSupported if invalid category |
|
937 */ |
|
938 CMPXDbCategory* DbCategoryL(TMPXGeneralCategory aCategory) const; |
|
939 |
|
940 /** |
|
941 * Verify the volume id for the databases |
|
942 */ |
|
943 void VerifyVolumeIdL(); |
|
944 |
|
945 |
|
946 #if defined (__MTP_PROTOCOL_SUPPORT) |
|
947 /** |
|
948 * Reads the "save deleted records" MTP flag from CenRep and returns |
|
949 * the value. |
|
950 * @return value of the "save deleted records" MTP flag |
|
951 */ |
|
952 TBool SaveDeletedSongs(); |
|
953 #endif |
|
954 |
|
955 #ifdef RD_MULTIPLE_DRIVE |
|
956 /** |
|
957 * Retrieve all visible music folder locations. |
|
958 */ |
|
959 CDesCArrayFlat* GetMusicFoldersL(); |
|
960 #endif // RD_MULTIPLE_DRIVE |
|
961 |
|
962 private: // From MMPXDbMusicObserver |
|
963 |
|
964 /** |
|
965 * @see MMPXDbMusicObserver |
|
966 */ |
|
967 virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, |
|
968 const TDesC& aName, TInt aDriveId, |
|
969 CMPXMessageArray* aItemChangedMessages, TBool& aItemExist); |
|
970 |
|
971 virtual TUint32 AddCategoryItemL(TMPXGeneralCategory aCategory, const TDesC& aName, |
|
972 TUint32 aArtist, const TDesC& aArt, |
|
973 TInt aDrive, CMPXMessageArray* aItemChangedMessages, TBool& aItemExist); |
|
974 |
|
975 virtual void UpdateCategoryItemL(TMPXGeneralCategory aCategory, TUint32 aCategoryId, |
|
976 const CMPXMedia& aMedia, TInt aDrive, CMPXMessageArray* aItemChangedMessages); |
|
977 |
|
978 /** |
|
979 * @see MMPXDbMusicObserver |
|
980 */ |
|
981 virtual void DeleteSongForCategoryL(TMPXGeneralCategory aCategory, |
|
982 TUint32 aCategoryId, TInt aDriveId, CMPXMessageArray* aItemChangedMessages, |
|
983 TBool& aItemExist); |
|
984 |
|
985 /** |
|
986 * @see MMPXDbMusicObserver |
|
987 */ |
|
988 virtual void HandlePlayCountModifiedL(CMPXMessageArray& aItemChangedMessages); |
|
989 |
|
990 /** |
|
991 * @see MMPXDbMusicObserver |
|
992 */ |
|
993 virtual void HandlePlaybackTimeModifiedL(CMPXMessageArray& aItemChangedMessages); |
|
994 private: // From MMPXDbArtistObserver |
|
995 /** |
|
996 * @see MMPXDbArtistObser |
|
997 */ |
|
998 virtual TInt HandleGetAlbumsCountForArtistL(TUint32 aArtistId); |
|
999 |
|
1000 private: // From MMPXDbAlbumObserver |
|
1001 /** |
|
1002 * @see MMPXDbAlbumObserver |
|
1003 */ |
|
1004 virtual TBool HandleIsUnknownArtistL(TUint32 aArtistId); |
|
1005 virtual TUint32 HandleArtistForAlbumL(const TUint32 aAlbumId); |
|
1006 |
|
1007 private: // From MMPXDbPlaylistObserver |
|
1008 /** |
|
1009 * @see MMPXDbPlaylistObserver |
|
1010 */ |
|
1011 virtual TInt HandlePlaylistDurationL(TUint32 aPlaylistId); |
|
1012 |
|
1013 private: |
|
1014 |
|
1015 /** |
|
1016 * C++ constructor. |
|
1017 * @param file session |
|
1018 */ |
|
1019 CMPXDbHandler(RFs& aFs, CMPXResource& aResource); |
|
1020 |
|
1021 /** |
|
1022 * Symbian 2nd phase constructor.. |
|
1023 */ |
|
1024 void ConstructL(); |
|
1025 |
|
1026 private: // Data |
|
1027 |
|
1028 // owned member variables |
|
1029 CMPXCollectionDbManager* iDbManager; |
|
1030 CMPXDbMusic* iDbMusic; |
|
1031 CMPXDbPlaylist* iDbPlaylist; |
|
1032 CMPXDbArtist* iDbArtist; |
|
1033 CMPXDbAlbum* iDbAlbum; |
|
1034 CMPXDbGenre* iDbGenre; |
|
1035 CMPXDbComposer* iDbComposer; |
|
1036 CMPXDbAuxiliary* iDbAuxiliary; |
|
1037 |
|
1038 CMPXDbAutoPlaylist* iAutoPlaylist; |
|
1039 |
|
1040 CDesCArrayFlat* iMimeTypes; // MIME types supported |
|
1041 CDesCArrayFlat* iExtensions; // file extensions supported |
|
1042 CDesCArrayFlat* iExtensionsMime; // file extensions to check MIME |
|
1043 CDesCArrayFlat* iExtensionsDrm; // file extensions to check DRM type |
|
1044 RArray<TInt> iDbDrives; |
|
1045 |
|
1046 // not owned member variables |
|
1047 RFs& iFs; |
|
1048 CMPXResource& iResource; |
|
1049 TBool iOutOfDisk; // Are we in out of disk mode? |
|
1050 TBool iSynchronizeBasicTable; // Basic music table was not updated during last refresh |
|
1051 TBool iCollectionOpen; // Databases opened |
|
1052 TBool iRefresh; // Refresh operation currently performed |
|
1053 TBool iMtpInUse; // Flag for MTP operation |
|
1054 TInt iOpOnDbCount; // Count to provide a min op amount in one transaction |
|
1055 }; |
|
1056 |
|
1057 #endif // MPXDBHANDLER_H |
|
1058 |
|
1059 // End of File |
|