53
|
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 the functionality related to
|
|
15 |
* playlist songs. The class operates on two tables: PlaylistSongs
|
|
16 |
* and PlaylistSongInfo.
|
|
17 |
*
|
|
18 |
* The PlaylistSongs table contains records for all song instances in
|
|
19 |
* playlists. For example if a playlist contains 7 songs, there will be 7
|
|
20 |
* corresponding records in the PlaylistSongs table, even if one song has
|
|
21 |
* multiple instances in the playlist.
|
|
22 |
*
|
|
23 |
* The PlaylistSongInfo table contains one record for each song included
|
|
24 |
* in at least one playlist. Redundant song information is stored in this
|
|
25 |
* table to help with songs on different drives than the playlist.
|
|
26 |
*
|
|
27 |
*
|
|
28 |
*/
|
|
29 |
|
|
30 |
|
|
31 |
#ifndef MPXDBPLAYLISTSONGS_H
|
|
32 |
#define MPXDBPLAYLISTSONGS_H
|
|
33 |
|
|
34 |
// INCLUDES
|
|
35 |
#include "mpxdbtable.h"
|
|
36 |
|
|
37 |
// CLASS FORWARDS
|
|
38 |
class CMPXMedia;
|
|
39 |
class CMPXMediaArray;
|
|
40 |
|
|
41 |
// CLASS DECLARATION
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Responsible for managing the music table
|
|
45 |
*
|
|
46 |
* @lib MPXDbPlugin.lib
|
|
47 |
*/
|
|
48 |
class CMPXDbPlaylistSongs :
|
|
49 |
public CMPXDbTable
|
|
50 |
{
|
|
51 |
public:
|
|
52 |
|
|
53 |
/**
|
|
54 |
* Two-phased constructor.
|
|
55 |
* @param aDbManager database manager to use for database interactions
|
|
56 |
* @return New CMPXDbPlaylistSongs instance.
|
|
57 |
*/
|
|
58 |
static CMPXDbPlaylistSongs* NewL(CMPXDbManager& aDbManager);
|
|
59 |
|
|
60 |
/**
|
|
61 |
* Two-phased constructor.
|
|
62 |
* @param aDbManager database manager to use for database interactions
|
|
63 |
* @return New CMPXDbPlaylistSongs instance on the cleanup stack.
|
|
64 |
*/
|
|
65 |
static CMPXDbPlaylistSongs* NewLC(CMPXDbManager& aDbManager);
|
|
66 |
|
|
67 |
/**
|
|
68 |
* Destructor
|
|
69 |
*/
|
|
70 |
virtual ~CMPXDbPlaylistSongs();
|
|
71 |
|
|
72 |
public:
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Add a song/songs to the given playlist
|
|
76 |
* @param aPlaylistId playlist id
|
|
77 |
* @param aMediaArray media array which contains the tracks to be added to the playlist
|
|
78 |
* @param aDriveId Drive Id of corresponding playlist
|
|
79 |
*/
|
|
80 |
void AddSongsL(TUint32 aPlaylistId, const CMPXMediaArray& aMediaArray, TInt aDriveId);
|
|
81 |
|
|
82 |
/**
|
|
83 |
* Add a song to playlist songs table for the given playlist
|
|
84 |
* @param aPlaylistId id of the playlist to add the song to
|
|
85 |
* @param aDriveId drive the song is on
|
|
86 |
* @param aMedia song media to be added to the playlist songs table for the playlist
|
|
87 |
* @return song ID
|
|
88 |
*/
|
|
89 |
TUint32 AddSongL(TUint32 aPlaylistId, const CMPXMedia& aMedia, TInt aDriveId);
|
|
90 |
|
|
91 |
/**
|
|
92 |
* Add a song to playlist songs table for the given playlist
|
|
93 |
* @param aPlaylistId id of the playlist to add the song to
|
|
94 |
* @param aOrdinal ordinal of the song to be added
|
|
95 |
* @param aDriveId drive the song is on
|
|
96 |
* @param aMedia song media to be added to the playlist songs table for the playlist
|
|
97 |
* @return song ID
|
|
98 |
*/
|
|
99 |
TUint32 AddSongL(TUint32 aPlaylistId, TInt aOrdinal, const CMPXMedia& aMedia,
|
|
100 |
TInt aDriveId);
|
|
101 |
|
|
102 |
/**
|
|
103 |
* Update song info for a song in the playlist songs table
|
|
104 |
* @param aSongId identifies the song
|
|
105 |
* @param aMedia song information
|
|
106 |
* @param aResetFlags indicates whether the song db flags should be reset or just updated
|
|
107 |
* @param aUpdated returns ETrue if the song information has changed
|
|
108 |
*/
|
|
109 |
TBool UpdateSongL(TUint32 aSongId, const CMPXMedia& aMedia, TBool aResetFlags,
|
|
110 |
TBool& aUpdated);
|
|
111 |
|
|
112 |
/**
|
|
113 |
* Update songs in a playlist to reflect playlist id change
|
|
114 |
* @param aPlaylistId identifies the songs in the playlist
|
|
115 |
* @param aNewPlaylistId specifies the new playlist id the songs should be associated with
|
|
116 |
*/
|
|
117 |
void UpdateSongsL(TUint32 aPlaylistId, TUint32 aNewPlaylistId);
|
|
118 |
|
|
119 |
/**
|
|
120 |
* Reorder the song in the playlist
|
|
121 |
* @param aPlaylistId id of the playlist which contains the song to be reordered
|
|
122 |
* @param aSongId id of the song to be reordered
|
|
123 |
* @param aOriginalOrdinal the original ordinal of the song within the playlist.
|
|
124 |
* Ordinal starts from 0.
|
|
125 |
* @param aNewOrdinal the new ordinal of the song within the playlist. Ordinal
|
|
126 |
* starts from 0.
|
|
127 |
*/
|
|
128 |
void ReorderSongL(const TMPXItemId& aPlaylistId, const TMPXItemId& aSongId,
|
|
129 |
TUint aOriginalOrdinal, TUint aNewOrdinal);
|
|
130 |
|
|
131 |
/**
|
|
132 |
* Remove the given song from all playlists
|
|
133 |
* @param aSongId ID of the song to remove
|
|
134 |
* @param aDriveId identifies the database to be updated
|
|
135 |
*/
|
|
136 |
void DeleteSongL(TUint32 aSongId);
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Remove a song from the playlist.
|
|
140 |
* @param aPlaylistId ID of the playlist to remove the song from
|
|
141 |
* @param aSongId Id of the song in the playlist to be removed
|
|
142 |
* @param aOrdinal the ordinal of the song in the playlist. This uniquely
|
|
143 |
* identifies which song in the playlist to be removed; whereas song
|
|
144 |
* ID doesn't because duplicate tracks in the playlist are allowed.
|
|
145 |
* The position is relative to zero, i.e. zero implies that the song
|
|
146 |
* at the beginning of the playlist is to be removed.
|
|
147 |
* @param aDriveId identifies the database to be updated
|
|
148 |
*/
|
|
149 |
void DeleteSongL(TUint32 aPlaylistId, TUint32 aSongId, TInt aOrdinal, TInt aDriveId);
|
|
150 |
|
|
151 |
/**
|
|
152 |
* Remove all songs from the specified playlist
|
|
153 |
* @param aPlaylistId ID of the playlist.
|
|
154 |
* @param aDriveId identifies the database.
|
|
155 |
*/
|
|
156 |
void DeleteSongsL(TUint32 aPlaylistId, TInt aDriveId);
|
|
157 |
|
|
158 |
/**
|
|
159 |
* Remove the songs for a given category from all playlists.
|
|
160 |
* @param aCategory identifies the category
|
|
161 |
* @param aCategoryId identifies the category item
|
|
162 |
* @param aDriveId identifies the database to be updated
|
|
163 |
*/
|
|
164 |
void DeleteSongsForCategoryL(TMPXGeneralCategory aCategory, TUint32 aCategoryId,
|
|
165 |
TInt aDriveId);
|
|
166 |
|
|
167 |
/**
|
|
168 |
* Remove the songs for a given category from all playlists.
|
|
169 |
* @param aCategory identifies the category
|
|
170 |
* @param aCategoryId identifies the category item
|
|
171 |
* @param aDriveId identifies the database to be updated
|
|
172 |
*/
|
|
173 |
void DeleteSongsForArtistAndAlbumL(TUint32 aArtistId, TUint32 aAlbumId, TInt aDriveId);
|
|
174 |
|
|
175 |
/**
|
|
176 |
* Remove all songs from the playlist songs table
|
|
177 |
*/
|
|
178 |
void DeleteAllSongsL();
|
|
179 |
|
|
180 |
/**
|
|
181 |
* Get ids of all songs in a playlist
|
|
182 |
* @param aPlaylistId identifies the playlist
|
|
183 |
* @param aMediaArray returns songs' id
|
|
184 |
*/
|
|
185 |
void GetSongsL(TUint32 aPlaylistId, CMPXMediaArray& aMediaArray);
|
|
186 |
|
|
187 |
/**
|
|
188 |
* Get ids of all songs in a playlist
|
|
189 |
* @param aPlaylistId identifies the playlist
|
|
190 |
* @param aAttrs attributes to return
|
|
191 |
* @param aMediaArray returns songs' id
|
|
192 |
*/
|
|
193 |
TBool GetSongsL( TUint32 aPlaylistId,
|
|
194 |
const TArray<TMPXAttribute>& aAttrs, CMPXMediaArray& aMediaArray);
|
|
195 |
|
|
196 |
/**
|
|
197 |
* Get information on a song in a playlist
|
|
198 |
* @param aPlaylistId identifies the playlist
|
|
199 |
* @param aSongId identifies the song
|
|
200 |
* @param aAttrs attributes to return
|
|
201 |
* @param aMedia returns song info
|
|
202 |
*/
|
|
203 |
TBool GetSongL(TUint32 aPlaylistId, TUint32 aSongId,
|
|
204 |
const TArray<TMPXAttribute>& aAttrs, CMPXMedia& aMedia);
|
|
205 |
|
|
206 |
/**
|
|
207 |
* Get information on a song
|
|
208 |
* @param aSongId identifies the song
|
|
209 |
* @param aAttrs attributes to return
|
|
210 |
* @param aMedia returns song info
|
|
211 |
*/
|
|
212 |
TBool GetSongL(const TMPXItemId& aSongId, const TArray<TMPXAttribute>& aAttrs,
|
|
213 |
CMPXMedia*& aMedia);
|
|
214 |
|
|
215 |
|
|
216 |
/**
|
|
217 |
* Get the number of songs for a playlist
|
|
218 |
* @param aPlaylistId identifies the playlist
|
|
219 |
* @param aDriveId identifies the database to be query
|
|
220 |
* @return number of songs
|
|
221 |
*/
|
|
222 |
TInt CountL(TUint32 aPlaylistId, TInt aDriveId);
|
|
223 |
|
|
224 |
private:
|
|
225 |
|
|
226 |
/**
|
|
227 |
* Update the media from the table
|
|
228 |
* @param aRecord playlist table view
|
|
229 |
* @param aAttrs the attributes to return
|
|
230 |
* @param aMedia updated with the playlist song info
|
|
231 |
*/
|
|
232 |
void UpdateMediaL(RSqlStatement& aRecord, const TArray<TMPXAttribute>& aAttrs,
|
|
233 |
CMPXMedia& aMedia);
|
|
234 |
|
|
235 |
/**
|
|
236 |
* Get the number of instances of a song in a playlist
|
|
237 |
* @param aPlaylistId identifies the playlist
|
|
238 |
* @param aSongId identifies the song
|
|
239 |
* @return number of instances
|
|
240 |
*/
|
|
241 |
TInt SongInstanceCountL(TUint32 aPlaylistId, TUint32 aSongId);
|
|
242 |
|
|
243 |
/**
|
|
244 |
* Get the number of instances of a song in the PlaylistSongs table.
|
|
245 |
* @param aSongId identifies the song
|
|
246 |
* @return number of instances
|
|
247 |
*/
|
|
248 |
TInt SongCountL(TUint32 aSongId);
|
|
249 |
|
|
250 |
/**
|
|
251 |
* Checks if the specified song exists in the PlaylisySongInfo table.
|
|
252 |
* @param aDriveId drive to check or KDbManagerAllDrives
|
|
253 |
* @param aSongId identifies the song
|
|
254 |
* @return ETrue if it exists, EFalse otherwise
|
|
255 |
*/
|
|
256 |
TBool SongInfoExistsL(TInt aDriveId, TUint32 aSongId);
|
|
257 |
|
|
258 |
/**
|
|
259 |
* Deletes all orphaned records in the PlaylistSongInfo table
|
|
260 |
* (songs not included in any playlist).
|
|
261 |
* @param aDriveId database to cleanup
|
|
262 |
*/
|
|
263 |
void CleanupSongInfoL(TInt aDriveId);
|
|
264 |
|
|
265 |
private: // from MMPXTable
|
|
266 |
|
|
267 |
/**
|
|
268 |
* @see MMPXTable
|
|
269 |
*/
|
|
270 |
virtual void CreateTableL(RSqlDatabase& aDatabase, TBool aCorruptTable);
|
|
271 |
|
|
272 |
/**
|
|
273 |
* @see MMPXTable
|
|
274 |
*/
|
|
275 |
virtual void DropTableL(RSqlDatabase& aDatabase);
|
|
276 |
|
|
277 |
/**
|
|
278 |
* @see MMPXTable
|
|
279 |
*/
|
|
280 |
virtual TBool CheckTableL(RSqlDatabase& aDatabase);
|
|
281 |
|
|
282 |
private:
|
|
283 |
|
|
284 |
/**
|
|
285 |
* C++ constructor
|
|
286 |
* @param aDbManager database manager to use for database interactions
|
|
287 |
*/
|
|
288 |
CMPXDbPlaylistSongs(CMPXDbManager& aDbManager);
|
|
289 |
|
|
290 |
/**
|
|
291 |
* Safely construct things that can leave
|
|
292 |
*/
|
|
293 |
void ConstructL();
|
|
294 |
|
|
295 |
private:
|
|
296 |
|
|
297 |
/**
|
|
298 |
* Column indexes in the playlist songs query
|
|
299 |
*/
|
|
300 |
enum TPlaylistSongsColumns
|
|
301 |
{
|
|
302 |
EPlaylistSongsUniqueId = KMPXTableDefaultIndex,
|
|
303 |
EPlaylistSongsSongId,
|
|
304 |
EPlaylistSongsPlaylistId,
|
|
305 |
EPlaylistSongsOrdinal,
|
|
306 |
EPlaylistSongsVolumeId,
|
|
307 |
EPlaylistSongsDbFlag,
|
|
308 |
EPlaylistSongsUri,
|
|
309 |
EPlaylistSongsTitle
|
|
310 |
};
|
|
311 |
|
|
312 |
/**
|
|
313 |
* Column indexes in the playlist song info table
|
|
314 |
*/
|
|
315 |
enum TPlaylistSongInfoColumns
|
|
316 |
{
|
|
317 |
EPlaylistSongInfoSongId = KMPXTableDefaultIndex,
|
|
318 |
EPlaylistSongInfoVolumeId,
|
|
319 |
EPlaylistSongInfoDbFlag,
|
|
320 |
EPlaylistSongInfoUri,
|
|
321 |
EPlaylistSongInfoTitle
|
|
322 |
};
|
|
323 |
|
|
324 |
};
|
|
325 |
|
|
326 |
#endif // MPXDBPLAYLISTSONGS_H
|
|
327 |
|
|
328 |
// End of File
|