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