Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

playlistsaver.h

Go to the documentation of this file.
00001 #ifndef NOATUNPLAYLISTSAVER_H
00002 #define NOATUNPLAYLISTSAVER_H
00003 
00004 #include <kurl.h>
00005 #include <qmap.h>
00006 #include <noatun/playlist.h>
00007 
00008 class Structure;
00009 
00010 /**
00011  * a simple one-group implementatio of
00012  * the standard XML playlist format:
00013  * 
00014  * http://noatun.kde.org/formats/xmlplaylist.phtml
00015  * 
00016  * A custom implemenation like yours should have a 
00017  * different "client" attribute for the playlist tag
00018  **/
00019 class PlaylistSaver
00020 {
00021     friend class Structure;
00022 public:
00023     enum Options
00024     {
00025         XMLPlaylist=1,
00026         M3U=2,
00027         PLS=4
00028     };
00029     
00030     PlaylistSaver();
00031     virtual ~PlaylistSaver();
00032     
00033     bool save(const KURL &file, int options=0);
00034     bool load(const KURL &file, int options=0);
00035 
00036     /**
00037      * guess the list's content between M3U or
00038      * PLS, and give it to you
00039      *
00040      * this is also the way to make icecast work.
00041      * you can also pass true icecast urls
00042      * here and it'l do its magic.
00043      *
00044      * This calls readItem
00045      **/
00046     bool metalist(const KURL &url);
00047 
00048     /**
00049      * unused, for future expansion, do not use
00050      * @internal
00051      **/
00052     virtual void setGroup(const QString &);
00053 
00054 protected:
00055     /**
00056      * read the item, and add it to your list
00057      * Given is a list of properties which coincide
00058      * with the standard noatun ones
00059      **/
00060     virtual void readItem(const QMap<QString,QString> &properties) = 0;
00061 
00062     /**
00063      * add this item to the XML file
00064      * or a null item if we're at the end
00065      **/
00066     virtual PlaylistItem writeItem() = 0;
00067 
00068     /**
00069      * unused, for future expansion
00070      * @internal
00071      **/
00072     virtual void changeGroup(const QString &) {}
00073 
00074     /**
00075      * this is called when you should either
00076      * clear your list, or start writing from the start of the list
00077      *
00078      * You usually don't need to implement this, since it'l always
00079      * be called immediately after load() or save()
00080      **/
00081     virtual void reset() {}
00082 
00083 private:
00084     bool loadXML(const KURL &file, int x=0);
00085     bool saveXML(const KURL &file, int x=0);
00086     
00087     bool loadM3U(const KURL &file, int x=0);
00088     bool saveM3U(const KURL &file, int x=0);
00089     
00090     bool loadPLS(const KURL &file, int x=0);
00091     bool savePLS(const KURL &file, int x=0);
00092 
00093 private:
00094     class Private;
00095     PlaylistSaver::Private *d; // unused
00096 
00097 };
00098 
00099 #endif

Generated at Mon Apr 1 11:45:00 2002 for noatun by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001