1 /***************************************************************************
2 * Copyright (c) 2007 Nikolaj Hald Nielsen <nhnFreespirit@gmail.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. *
18 ***************************************************************************/
20 #ifndef PlaylistHandler_H
21 #define PlaylistHandler_H
24 #include "debug.h" //stack allocated
25 #include "meta/meta.h"
28 #include <kio/jobclasses.h>
36 * @class PlaylistHandler
37 * @author Nikolaj Hald Nielsen <nhnFreespirit@gmail.com>
38 * @short Class for dealing with playlists (both loading and saving)
41 class PlaylistHandler
: public QObject
48 bool isPlaylist( const KUrl
&path
);
49 void load( const QString
&path
);
51 enum Format
{ M3U
, PLS
, XML
, RAM
, SMIL
, ASX
, XSPF
, Unknown
, NotPlaylist
= Unknown
};
53 bool save( Meta::TrackList tracks
, const QString
&location
);
59 KIO::StoredTransferJob
* m_downloadJob
;
64 void downloadPlaylist( const KUrl
& path
);
66 bool loadPls( QTextStream
&stream
);
67 bool savePls( Meta::TrackList tracks
, const QString
&location
);
68 unsigned int loadPls_extractIndex( const QString
&str
) const;
69 bool loadM3u( QTextStream
&stream
);
70 bool saveM3u( Meta::TrackList tracks
, const QString
&location
);
71 bool loadRealAudioRam( QTextStream
& );
72 bool loadASX( QTextStream
& );
73 bool loadSMIL( QTextStream
& );
74 bool loadXSPF( QTextStream
& );
75 bool saveXSPF( Meta::TrackList tracks
, const QString
&location
);
77 KUrl::List
recurse( const KUrl
& url
);
79 Format
getFormat( const KUrl
&path
);
80 void handleByFormat( QTextStream
&stream
, Format format
);
81 Format
getType( QString
&contents
);
83 static QTime
stringToTime(const QString
&);
87 void downloadComplete( KJob
*job
);