00001 #ifndef METAIOID3_H_
00002 #define METAIOID3_H_
00003
00004
00005 #include "metaiotaglib.h"
00006 #include "metadata.h"
00007
00008
00009 #include <id3v1tag.h>
00010 #include <id3v2tag.h>
00011 #include <textidentificationframe.h>
00012 #include <attachedpictureframe.h>
00013 #include <popularimeterframe.h>
00014 #include <tfile.h>
00015
00016
00017 #include <QList>
00018
00019 using TagLib::ID3v2::UserTextIdentificationFrame;
00020 using TagLib::ID3v2::TextIdentificationFrame;
00021 using TagLib::ID3v2::PopularimeterFrame;
00022 using TagLib::ID3v2::AttachedPictureFrame;
00023
00033 class MetaIOID3 : public MetaIOTagLib
00034 {
00035 public:
00036 MetaIOID3(void);
00037 virtual ~MetaIOID3(void);
00038
00039 virtual bool write(const Metadata* mdata);
00040 bool writeVolatileMetadata(const Metadata* mdata);
00041
00042 bool writeAlbumArt(const QString &filename, const AlbumArtImage *albumart);
00043 bool removeAlbumArt(const QString &filename, const AlbumArtImage *albumart);
00044
00045 Metadata* read(const QString &filename);
00046 AlbumArtList getAlbumArtList(const QString &filename);
00047 QImage *getAlbumArt(const QString &filename, ImageType type);
00048
00049 bool supportsEmbeddedImages(void) { return true; }
00050
00051 bool changeImageType(const QString &filename, const AlbumArtImage *albumart,
00052 ImageType newType);
00053
00054 virtual bool TagExists(const QString &filename);
00055
00056 private:
00057 bool OpenFile(const QString &filename, bool forWriting = false);
00058 bool SaveFile();
00059 void CloseFile();
00060
00061 TagLib::ID3v2::Tag* GetID3v2Tag(bool create = false);
00062 TagLib::ID3v1::Tag* GetID3v1Tag(bool create = false);
00063
00064 bool writePlayCount(TagLib::ID3v2::Tag *tag, int playcount);
00065 bool writeRating(TagLib::ID3v2::Tag *tag, int rating);
00066
00067 AlbumArtList readAlbumArt(TagLib::ID3v2::Tag *tag);
00068 UserTextIdentificationFrame* find(TagLib::ID3v2::Tag *tag,
00069 const String &description);
00070 PopularimeterFrame* findPOPM(TagLib::ID3v2::Tag *tag, const String &email);
00071 AttachedPictureFrame* findAPIC(TagLib::ID3v2::Tag *tag,
00072 const AttachedPictureFrame::Type &type,
00073 const String &description = String::null);
00074 QString getExtFromMimeType(const QString &mimeType);
00075
00076 TagLib::File *m_file;
00077 QString m_filename;
00078
00079 typedef enum { kMPEG, kFLAC } TagType;
00080 TagType m_fileType;
00081 };
00082
00083 #endif