smf/smfservermodule/smfclient/common/smfplaylist.cpp
changeset 14 a469c0e6e7fb
parent 7 be09cf1f39dd
equal deleted inserted replaced
13:b5d63d5fc252 14:a469c0e6e7fb
    11  *
    11  *
    12  * Contributors:
    12  * Contributors:
    13  * Manasij Roy, Nalina Hariharan
    13  * Manasij Roy, Nalina Hariharan
    14  * 
    14  * 
    15  * Description:
    15  * Description:
    16  * The playlist class represents an instance of a playlist
    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
    17  *
    19  *
    18  */
    20  */
    19 
    21 
    20 #include <smfplaylist.h>
    22 #include <smfplaylist.h>
    21 #include <smfplaylist_p.h>
    23 #include <smfplaylist_p.h>
    42  * @param aOther The reference object
    44  * @param aOther The reference object
    43  * @return The target reference value
    45  * @return The target reference value
    44  */
    46  */
    45 SmfPlaylist& SmfPlaylist::operator=( const SmfPlaylist &aOther )
    47 SmfPlaylist& SmfPlaylist::operator=( const SmfPlaylist &aOther )
    46 	{
    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;
    47 	d->m_trackList = aOther.d->m_trackList;
    62 	d->m_trackList = aOther.d->m_trackList;
    48 	d->m_title = aOther.d->m_title;
       
    49 	d->m_creationDate = aOther.d->m_creationDate;
       
    50 	d->m_playlistId = aOther.d->m_playlistId;
       
    51 	return *this;
    63 	return *this;
    52 	}
    64 	}
    53 
    65 
    54 /**
    66 /**
    55  * Destructor
    67  * Destructor
    56  */
    68  */
    57 SmfPlaylist::~SmfPlaylist( )
    69 SmfPlaylist::~SmfPlaylist( )
    58 	{
    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;
    59 	}
   192 	}
    60 
   193 
    61 /**
   194 /**
    62  * Method to get the list of tracks in the playlist
   195  * Method to get the list of tracks in the playlist
    63  * @return The list of tracks in the playlist
   196  * @return The list of tracks in the playlist
    66 	{
   199 	{
    67 	return d->m_trackList;
   200 	return d->m_trackList;
    68 	}
   201 	}
    69 
   202 
    70 /**
   203 /**
    71  * Method to get the playlist title
   204  * Method to set the version of the playlist
    72  * @return The title of the playlist
   205  * @param aVersion The version of the playlist
    73  */
   206  */
    74 QString SmfPlaylist::playListTitle( ) const
   207 void SmfPlaylist::setVersion( const QString& aVersion )
    75 	{
   208 	{
    76 	return d->m_title;
   209 	d->m_version = aVersion;
    77 	}
   210 	}
    78 
   211 
    79 /**
   212 /**
    80  * Method to get the creation date of the playlist
   213  * Method to set the playlist title
    81  * @return The date and time of creation of the playlist
   214  * @param aTitle The title of the playlist
    82  */
   215  */
    83 QDateTime SmfPlaylist::creationDate( ) const
   216 void SmfPlaylist::setPlayListTitle( const QString &aTitle )
    84 	{
   217 	{
    85 	return d->m_creationDate;
   218 	d->m_title = aTitle;
    86 	}
   219 	}
    87 /**
   220 
    88  * Method to get the id of the playlist
   221 /**
    89  * @return The ID value 
   222  * Method to set the author of the playlist
    90  */
   223  * @param aAuthor The author of the playlist
    91 QString SmfPlaylist::id( ) const
   224  */
    92 	{
   225 void SmfPlaylist::setAuthor( const QString& aAuthor )
    93 	return d->m_playlistId;
   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;
    94 	}
   322 	}
    95 
   323 
    96 /**
   324 /**
    97  * Method to set the list of tracks in the playlist
   325  * Method to set the list of tracks in the playlist
    98  * @param aList The new list of tracks in the playlist
   326  * @param aList The new list of tracks in the playlist
    99  */
   327  */
   100 void SmfPlaylist::setTrackList( const QList<SmfTrackInfo> &aList )
   328 void SmfPlaylist::setTrackList( const QList<SmfTrackInfo> &aList )
   101 	{
   329 	{
   102 	d->m_trackList = aList;
   330 	d->m_trackList = aList;
   103 	}
   331 	}
   104 
       
   105 /**
       
   106  * Method to set the playlist title
       
   107  * @param aTitle The new title of the playlist
       
   108  */
       
   109 void SmfPlaylist::setPlayListTitle( const QString &aTitle )
       
   110 	{
       
   111 	d->m_title = aTitle;
       
   112 	}
       
   113 
       
   114 /**
       
   115  * Method to set the creation date of the playlist
       
   116  * @param aDate The new date and time of creation of the playlist
       
   117  */
       
   118 void SmfPlaylist::setCreationDate( const QDateTime &aDate )
       
   119 	{
       
   120 	d->m_creationDate = aDate;
       
   121 	}
       
   122 
       
   123 /**
       
   124  * Method to set the id of the playlist
       
   125  * @param aId The ID value 
       
   126  */
       
   127 void SmfPlaylist::setId( const QString &aId)
       
   128 	{
       
   129 	d->m_playlistId = aId;
       
   130 	}
       
   131 
       
   132 
   332 
   133 /**
   333 /**
   134  * Method for Externalization. Writes the SmfPlaylist object to 
   334  * Method for Externalization. Writes the SmfPlaylist object to 
   135  * the stream and returns a reference to the stream.
   335  * the stream and returns a reference to the stream.
   136  * @param aDataStream Stream to be written
   336  * @param aDataStream Stream to be written
   138  * @return reference to the written stream
   338  * @return reference to the written stream
   139  */
   339  */
   140  QDataStream &operator<<( QDataStream &aDataStream, 
   340  QDataStream &operator<<( QDataStream &aDataStream, 
   141 		const SmfPlaylist &aPlaylist )
   341 		const SmfPlaylist &aPlaylist )
   142 	{
   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 	
   143 	// Serialize d->m_trackList
   382 	// Serialize d->m_trackList
   144 	aDataStream<<aPlaylist.d->m_trackList;
   383 	aDataStream<<aPlaylist.d->m_trackList;
   145 	
       
   146 	// Serialize d->m_title
       
   147 	aDataStream<<aPlaylist.d->m_title;
       
   148 	
       
   149 	// Serialize d->m_creationDate
       
   150 	aDataStream<<aPlaylist.d->m_creationDate;
       
   151 	
       
   152 	// Serialize d->m_playlistId
       
   153 	aDataStream<<aPlaylist.d->m_playlistId;
       
   154 	
   384 	
   155 	return aDataStream;
   385 	return aDataStream;
   156 	}
   386 	}
   157 
   387 
   158 /**
   388 /**
   163  * @return reference to the stream
   393  * @return reference to the stream
   164  */
   394  */
   165 QDataStream &operator>>( QDataStream &aDataStream, 
   395 QDataStream &operator>>( QDataStream &aDataStream, 
   166 		SmfPlaylist &aPlaylist)
   396 		SmfPlaylist &aPlaylist)
   167 	{
   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 	
   168 	// Deserialize d->m_trackList
   437 	// Deserialize d->m_trackList
   169 	aDataStream>>aPlaylist.d->m_trackList;
   438 	aDataStream>>aPlaylist.d->m_trackList;
   170 	
   439 	
   171 	// Deserialize d->m_title
       
   172 	aDataStream>>aPlaylist.d->m_title;
       
   173 	
       
   174 	// Deserialize d->m_creationDate
       
   175 	aDataStream>>aPlaylist.d->m_creationDate;
       
   176 	
       
   177 	// Deserialize d->m_playlistId
       
   178 	aDataStream>>aPlaylist.d->m_playlistId;
       
   179 	
       
   180 	return aDataStream;
   440 	return aDataStream;
   181 	}
   441 	}