00001 /***************************************************************************** 00002 * Copyright (C) 2004 by Michael Schulze * 00003 * mike.s@genion.de * 00004 * * 00005 * The code contained in this file is free software; you can redistribute * 00006 * it and/or modify it under the terms of the GNU Lesser General Public * 00007 * License as published by the Free Software Foundation; either version * 00008 * 2.1 of the License, or (at your option) any later version. * 00009 * * 00010 * This file is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00013 * Lesser General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU Lesser General Public * 00016 * License along with this code; if not, write to the Free Software * 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 00018 * * 00019 * iTunes and iPod are trademarks of Apple * 00020 * * 00021 * This product is not supported/written/published by Apple! * 00022 *****************************************************************************/ 00023 00024 #ifndef ITUNESDBITUNESDBPARSER_H 00025 #define ITUNESDBITUNESDBPARSER_H 00026 00027 #define ITUNESDBPARSER_BUFFERSIZE 1024 00028 00029 #include "itunesdblistener.h" 00030 #include "track.h" 00031 #include "playlistitem.h" 00032 #include "playlist.h" 00033 00034 #include <qfile.h> 00035 00036 namespace itunesdb { 00037 #define ITUNESDB_MHDP 0x7064686D 00038 00039 00040 /** 00041 * parses an iTunesDB file and calls the appropriate methods of a given ITunesDBListener 00042 @author Michael Schulze 00043 */ 00044 class ItunesDBParser { 00045 private: 00046 ItunesDBListener * listener; 00047 Playlist * current_playlist; 00048 00049 public: 00050 /** 00051 * creates a new parser that calls the appropriate methods on the given listener during the parse process 00052 */ 00053 ItunesDBParser(ItunesDBListener& listener); 00054 00055 virtual ~ItunesDBParser(); 00056 00057 /** 00058 * parses the given iTunesDB file 00059 * @param file the file that should be parsed. 00060 */ 00061 void parse(QFile& file); 00062 00063 /** 00064 * parses the given Playcount File 00065 * the iPod writes playcounts NOT into the iTunesDB 00066 * but to a file called "Play Count" 00067 * @param file the file that should be parsed. 00068 */ 00069 void parsePlaycount(QFile& file); 00070 00071 /** 00072 * parses the given On the Go Playlist 00073 * @param file the file that should be parsed. 00074 */ 00075 void parseOTG(QFile& file); 00076 00077 private: 00078 // static void setTrackInfo( Track& track, QString data, Q_UINT32 field); 00079 void handleItem( ListItem& item ); 00080 }; 00081 00082 } 00083 00084 #endif