|
1 /** |
|
2 * Copyright (c) 2010 Sasken Communication Technologies Ltd. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Manasij Roy, Nalina Hariharan |
|
14 * |
|
15 * Description: |
|
16 * The playlist class represents an instance of a playlist. |
|
17 * SmfPlaylist class is in accordance with the XML Shareable Playlist Format (XSPF) |
|
18 * as mentioned in http://xspf.org/xspf-v1.html |
|
19 * |
|
20 */ |
|
21 |
|
22 #include <smfplaylist.h> |
|
23 #include <smfplaylist_p.h> |
|
24 |
|
25 /** |
|
26 * Constructor with default argument |
|
27 */ |
|
28 SmfPlaylist::SmfPlaylist( ) |
|
29 { |
|
30 d = new SmfPlaylistPrivate; |
|
31 } |
|
32 |
|
33 /** |
|
34 * Copy Constructor |
|
35 * @param aOther The reference object |
|
36 */ |
|
37 SmfPlaylist::SmfPlaylist( const SmfPlaylist &aOther ) |
|
38 : d( aOther.d ) |
|
39 { |
|
40 } |
|
41 |
|
42 /** |
|
43 * Overloaded = operator |
|
44 * @param aOther The reference object |
|
45 * @return The target reference value |
|
46 */ |
|
47 SmfPlaylist& SmfPlaylist::operator=( const SmfPlaylist &aOther ) |
|
48 { |
|
49 d->m_version = aOther.d->m_version; |
|
50 d->m_title = aOther.d->m_title; |
|
51 d->m_author = aOther.d->m_author; |
|
52 d->m_comments = aOther.d->m_comments; |
|
53 d->m_info = aOther.d->m_info; |
|
54 d->m_location = aOther.d->m_location; |
|
55 d->m_playlistId = aOther.d->m_playlistId; |
|
56 d->m_image = aOther.d->m_image; |
|
57 d->m_creationDate = aOther.d->m_creationDate; |
|
58 d->m_license = aOther.d->m_license; |
|
59 d->m_attribution = aOther.d->m_attribution; |
|
60 d->m_metadata = aOther.d->m_metadata; |
|
61 d->m_extension = aOther.d->m_extension; |
|
62 d->m_trackList = aOther.d->m_trackList; |
|
63 return *this; |
|
64 } |
|
65 |
|
66 /** |
|
67 * Destructor |
|
68 */ |
|
69 SmfPlaylist::~SmfPlaylist( ) |
|
70 { |
|
71 } |
|
72 |
|
73 /** |
|
74 * Method to get the version of the playlist |
|
75 * @return The version of the playlist |
|
76 */ |
|
77 QString SmfPlaylist::version( ) const |
|
78 { |
|
79 return d->m_version; |
|
80 } |
|
81 |
|
82 /** |
|
83 * Method to get the playlist title |
|
84 * @return The title of the playlist |
|
85 */ |
|
86 QString SmfPlaylist::playListTitle( ) const |
|
87 { |
|
88 return d->m_title; |
|
89 } |
|
90 |
|
91 /** |
|
92 * Method to get the author of the playlist |
|
93 * @return The author of the playlist |
|
94 */ |
|
95 QString SmfPlaylist::author( ) const |
|
96 { |
|
97 return d->m_author; |
|
98 } |
|
99 |
|
100 /** |
|
101 * Method to get the comments on the playlist |
|
102 * @return The comments on the playlist |
|
103 */ |
|
104 QList<SmfComment> SmfPlaylist::comments( ) const |
|
105 { |
|
106 return d->m_comments; |
|
107 } |
|
108 |
|
109 /** |
|
110 * Method to get the URI of a web page to find out more about this playlist |
|
111 * @return The info Url |
|
112 */ |
|
113 QUrl SmfPlaylist::info( ) const |
|
114 { |
|
115 return d->m_info; |
|
116 } |
|
117 |
|
118 /** |
|
119 * Method to get the Source URI for this playlist |
|
120 * @return The Source URI for this playlist |
|
121 */ |
|
122 QUrl SmfPlaylist::location( ) const |
|
123 { |
|
124 return d->m_location; |
|
125 } |
|
126 |
|
127 /** |
|
128 * Method to get the id of the playlist |
|
129 * @return The ID value |
|
130 */ |
|
131 QString SmfPlaylist::id( ) const |
|
132 { |
|
133 return d->m_playlistId; |
|
134 } |
|
135 |
|
136 /** |
|
137 * Method to get the URI of an image to display in the absence |
|
138 * of an image for playlist's tracks |
|
139 * @return The deafult image Url |
|
140 */ |
|
141 QUrl SmfPlaylist::image( ) const |
|
142 { |
|
143 return d->m_image; |
|
144 } |
|
145 |
|
146 /** |
|
147 * Method to get the creation date of the playlist |
|
148 * @return The date and time of creation of the playlist |
|
149 */ |
|
150 QDateTime SmfPlaylist::creationDate( ) const |
|
151 { |
|
152 return d->m_creationDate; |
|
153 } |
|
154 |
|
155 /** |
|
156 * Method to get the URI of a resource that describes the license |
|
157 * under which this playlist was released |
|
158 * @return The license Url |
|
159 */ |
|
160 QUrl SmfPlaylist::license( ) const |
|
161 { |
|
162 return d->m_license; |
|
163 } |
|
164 |
|
165 /** |
|
166 * Method to get the ordered list of URIs. The purpose is to satisfy |
|
167 * licenses allowing modification but requiring attribution |
|
168 * @return The list of license Urls |
|
169 */ |
|
170 QList<QUrl> SmfPlaylist::attribution( ) const |
|
171 { |
|
172 return d->m_attribution; |
|
173 } |
|
174 |
|
175 /** |
|
176 * Method to get the meta element that allows metadata fields to be added to XSPF |
|
177 * @return The meta elements as a QVarintMap |
|
178 */ |
|
179 QVariantMap SmfPlaylist::metadata( ) const |
|
180 { |
|
181 return d->m_metadata; |
|
182 } |
|
183 |
|
184 /** |
|
185 * Method to get the extension element that allows non-XSPF XML |
|
186 * to be included in XSPF documents |
|
187 * @return The extension elements as a QVarintMap |
|
188 */ |
|
189 QVariantMap SmfPlaylist::extension( ) const |
|
190 { |
|
191 return d->m_extension; |
|
192 } |
|
193 |
|
194 /** |
|
195 * Method to get the list of tracks in the playlist |
|
196 * @return The list of tracks in the playlist |
|
197 */ |
|
198 QList<SmfTrackInfo> SmfPlaylist::trackList( ) const |
|
199 { |
|
200 return d->m_trackList; |
|
201 } |
|
202 |
|
203 /** |
|
204 * Method to set the version of the playlist |
|
205 * @param aVersion The version of the playlist |
|
206 */ |
|
207 void SmfPlaylist::setVersion( const QString& aVersion ) |
|
208 { |
|
209 d->m_version = aVersion; |
|
210 } |
|
211 |
|
212 /** |
|
213 * Method to set the playlist title |
|
214 * @param aTitle The title of the playlist |
|
215 */ |
|
216 void SmfPlaylist::setPlayListTitle( const QString &aTitle ) |
|
217 { |
|
218 d->m_title = aTitle; |
|
219 } |
|
220 |
|
221 /** |
|
222 * Method to set the author of the playlist |
|
223 * @param aAuthor The author of the playlist |
|
224 */ |
|
225 void SmfPlaylist::setAuthor( const QString& aAuthor ) |
|
226 { |
|
227 d->m_author = aAuthor; |
|
228 } |
|
229 |
|
230 /** |
|
231 * Method to set the comments on the playlist |
|
232 * @param aComments The comments on the playlist |
|
233 */ |
|
234 void SmfPlaylist::setComments( const QList<SmfComment>& aComments ) |
|
235 { |
|
236 d->m_comments = aComments; |
|
237 } |
|
238 |
|
239 /** |
|
240 * Method to set the URI of a web page to find out more about this playlist |
|
241 * @param aInfoUrl The info Url |
|
242 */ |
|
243 void SmfPlaylist::setInfo( const QUrl& aInfoUrl ) |
|
244 { |
|
245 d->m_info = aInfoUrl; |
|
246 } |
|
247 |
|
248 /** |
|
249 * Method to set the Source URI for this playlist |
|
250 * @param aLocation The Source URI for this playlist |
|
251 */ |
|
252 void SmfPlaylist::setLocation( const QUrl& aLocation ) |
|
253 { |
|
254 d->m_location = aLocation; |
|
255 } |
|
256 |
|
257 /** |
|
258 * Method to set the id of the playlist |
|
259 * @param aId The ID value |
|
260 */ |
|
261 void SmfPlaylist::setId( const QString &aId) |
|
262 { |
|
263 d->m_playlistId = aId; |
|
264 } |
|
265 |
|
266 /** |
|
267 * Method to set the URI of an image to display in the absence |
|
268 * of an image for playlist's tracks |
|
269 * @param aImage The default image Url |
|
270 */ |
|
271 void SmfPlaylist::setImage( const QUrl& aImage ) |
|
272 { |
|
273 d->m_image = aImage; |
|
274 } |
|
275 |
|
276 /** |
|
277 * Method to set the creation date of the playlist |
|
278 * @param aDate The date and time of creation of the playlist |
|
279 */ |
|
280 void SmfPlaylist::setCreationDate( const QDateTime& aDate ) |
|
281 { |
|
282 d->m_creationDate = aDate; |
|
283 } |
|
284 |
|
285 /** |
|
286 * Method to set the URI of a resource that describes the license |
|
287 * under which this playlist was released |
|
288 * @param aLicense The license Url |
|
289 */ |
|
290 void SmfPlaylist::setLicense( const QUrl& aLicense ) |
|
291 { |
|
292 d->m_license = aLicense; |
|
293 } |
|
294 |
|
295 /** |
|
296 * Method to set the ordered list of URIs. The purpose is to satisfy |
|
297 * licenses allowing modification but requiring attribution |
|
298 * @param aAttribution The list of license Urls |
|
299 */ |
|
300 void SmfPlaylist::setAttribution( const QList<QUrl>& aAttribution ) |
|
301 { |
|
302 d->m_attribution = aAttribution; |
|
303 } |
|
304 |
|
305 /** |
|
306 * Method to set the meta element that allows metadata fields to be added to XSPF |
|
307 * @param aMetaData The meta elements as a QVarintMap |
|
308 */ |
|
309 void SmfPlaylist::setMetadata( const QVariantMap& aMetaData ) |
|
310 { |
|
311 d->m_metadata = aMetaData; |
|
312 } |
|
313 |
|
314 /** |
|
315 * Method to set the extension element that allows non-XSPF XML |
|
316 * to be included in XSPF documents |
|
317 * @param aExtension The extension elements as a QVarintMap |
|
318 */ |
|
319 void SmfPlaylist::setExtension( const QVariantMap& aExtension ) |
|
320 { |
|
321 d->m_extension = aExtension; |
|
322 } |
|
323 |
|
324 /** |
|
325 * Method to set the list of tracks in the playlist |
|
326 * @param aList The new list of tracks in the playlist |
|
327 */ |
|
328 void SmfPlaylist::setTrackList( const QList<SmfTrackInfo> &aList ) |
|
329 { |
|
330 d->m_trackList = aList; |
|
331 } |
|
332 |
|
333 /** |
|
334 * Method for Externalization. Writes the SmfPlaylist object to |
|
335 * the stream and returns a reference to the stream. |
|
336 * @param aDataStream Stream to be written |
|
337 * @param aPlaylist The SmfPlaylist object to be externalized |
|
338 * @return reference to the written stream |
|
339 */ |
|
340 QDataStream &operator<<( QDataStream &aDataStream, |
|
341 const SmfPlaylist &aPlaylist ) |
|
342 { |
|
343 // Serialize d->m_version |
|
344 aDataStream<<aPlaylist.d->m_version; |
|
345 |
|
346 // Serialize d->m_title |
|
347 aDataStream<<aPlaylist.d->m_title; |
|
348 |
|
349 // Serialize d->m_author |
|
350 aDataStream<<aPlaylist.d->m_author; |
|
351 |
|
352 // Serialize d->m_comments |
|
353 aDataStream<<aPlaylist.d->m_comments; |
|
354 |
|
355 // Serialize d->m_info |
|
356 aDataStream<<aPlaylist.d->m_info; |
|
357 |
|
358 // Serialize d->m_location |
|
359 aDataStream<<aPlaylist.d->m_location; |
|
360 |
|
361 // Serialize d->m_playlistId |
|
362 aDataStream<<aPlaylist.d->m_playlistId; |
|
363 |
|
364 // Serialize d->m_image |
|
365 aDataStream<<aPlaylist.d->m_image; |
|
366 |
|
367 // Serialize d->m_creationDate |
|
368 aDataStream<<aPlaylist.d->m_creationDate; |
|
369 |
|
370 // Serialize d->m_license |
|
371 aDataStream<<aPlaylist.d->m_license; |
|
372 |
|
373 // Serialize d->m_attribution |
|
374 aDataStream<<aPlaylist.d->m_attribution; |
|
375 |
|
376 // Serialize d->m_metadata |
|
377 aDataStream<<aPlaylist.d->m_metadata; |
|
378 |
|
379 // Serialize d->m_extension |
|
380 aDataStream<<aPlaylist.d->m_extension; |
|
381 |
|
382 // Serialize d->m_trackList |
|
383 aDataStream<<aPlaylist.d->m_trackList; |
|
384 |
|
385 return aDataStream; |
|
386 } |
|
387 |
|
388 /** |
|
389 * Method for Internalization. Reads a SmfPlaylist object from |
|
390 * the stream and returns a reference to the stream. |
|
391 * @param aDataStream Stream to be read |
|
392 * @param aPlaylist The SmfPlaylist object to be internalized |
|
393 * @return reference to the stream |
|
394 */ |
|
395 QDataStream &operator>>( QDataStream &aDataStream, |
|
396 SmfPlaylist &aPlaylist) |
|
397 { |
|
398 // Deserialize d->m_version |
|
399 aDataStream>>aPlaylist.d->m_version; |
|
400 |
|
401 // Deserialize d->m_title |
|
402 aDataStream>>aPlaylist.d->m_title; |
|
403 |
|
404 // Deserialize d->m_author |
|
405 aDataStream>>aPlaylist.d->m_author; |
|
406 |
|
407 // Deserialize d->m_comments |
|
408 aDataStream>>aPlaylist.d->m_comments; |
|
409 |
|
410 // Deserialize d->m_info |
|
411 aDataStream>>aPlaylist.d->m_info; |
|
412 |
|
413 // Deserialize d->m_location |
|
414 aDataStream>>aPlaylist.d->m_location; |
|
415 |
|
416 // Deserialize d->m_playlistId |
|
417 aDataStream>>aPlaylist.d->m_playlistId; |
|
418 |
|
419 // Deserialize d->m_image |
|
420 aDataStream>>aPlaylist.d->m_image; |
|
421 |
|
422 // Deserialize d->m_creationDate |
|
423 aDataStream>>aPlaylist.d->m_creationDate; |
|
424 |
|
425 // Deserialize d->m_license |
|
426 aDataStream>>aPlaylist.d->m_license; |
|
427 |
|
428 // Deserialize d->m_attribution |
|
429 aDataStream>>aPlaylist.d->m_attribution; |
|
430 |
|
431 // Deserialize d->m_metadata |
|
432 aDataStream>>aPlaylist.d->m_metadata; |
|
433 |
|
434 // Deserialize d->m_extension |
|
435 aDataStream>>aPlaylist.d->m_extension; |
|
436 |
|
437 // Deserialize d->m_trackList |
|
438 aDataStream>>aPlaylist.d->m_trackList; |
|
439 |
|
440 return aDataStream; |
|
441 } |