add mp3 and ogg torrent url info to JamendoAlbum
[amarok.git] / src / PlaylistHandler.h
blobc1b90c69a7ffd14160750c5dd8cbee81ef0a506a
1 /***************************************************************************
2 * Copyright (c) 2007 Nikolaj Hald Nielsen <nhnFreespirit@gmail.com> *
3 * *
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. *
8 * *
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. *
13 * *
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
23 #include "amarok.h"
24 #include "debug.h" //stack allocated
25 #include "meta/meta.h"
27 #include <kio/job.h>
28 #include <kio/jobclasses.h>
30 #include <QTime>
32 class KJob;
35 /**
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
43 Q_OBJECT
44 public:
46 PlaylistHandler();
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 );
56 private:
58 Format m_format;
59 KIO::StoredTransferJob * m_downloadJob;
60 QString m_contents;
61 QString m_path;
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&);
85 private slots:
87 void downloadComplete( KJob *job );
91 #endif