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 ITUNESDBITUNESDBWRITER_H 00025 #define ITUNESDBITUNESDBWRITER_H 00026 00027 #include <qfile.h> 00028 00029 #include "itunesdbdatasource.h" 00030 #include "listitem.h" 00031 00032 namespace itunesdb { 00033 00034 /** 00035 Writes an iTunesDB file 00036 Documentation about the iTunesDB and iTunesSD formats from 00037 http://www.ipodlinux.org/ITunesDB 00038 00039 @author Michael Schulze 00040 */ 00041 class ItunesDBWriter{ 00042 public: 00043 ItunesDBWriter(ItunesDBDataSource & trackdatasource); 00044 00045 ~ItunesDBWriter(); 00046 00047 /** 00048 * Writes the given string data to the stream 00049 * @return the number of bytes written 00050 */ 00051 static uint writeUTF16StringTypeMHOD( QDataStream& stream, Q_UINT32 type, QString data ); 00052 00053 /** 00054 * Writes the contents of the ItunesDBDataSource to the given file 00055 * @param file the file to write the information to 00056 */ 00057 void write(QFile& file); 00058 00059 /** 00060 * Writes the iTunesSD contents to the given file 00061 * @param file the file to write the information to 00062 */ 00063 void writeSD( QFile& file ); 00064 00065 private: 00066 ItunesDBDataSource& m_datasource; 00067 00068 void fillTrackBuffer( QByteArray& buffer); 00069 //void fillPodcastBuffer( QByteArray& buffer ); 00070 void fillPlaylistBuffer( QByteArray& buffer); 00071 void fillTrackBufferSD( QByteArray& buffer ); 00072 00073 void write3ByteLittle( QDataStream &stream, int v ); 00074 }; 00075 00076 } 00077 00078 #endif