From 24627d849334da0c3e0ea8acf89723fe28f449a1 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Tue, 22 Sep 2009 23:12:19 +0200 Subject: [PATCH] fix compilation --with-taglib --- src/browser.cpp | 7 +++---- src/song.cpp | 5 +++++ src/song.h | 1 + src/tag_editor.cpp | 41 +++++++++++++++-------------------------- src/tag_editor.h | 2 +- 5 files changed, 25 insertions(+), 31 deletions(-) diff --git a/src/browser.cpp b/src/browser.cpp index 49d7efc1..3cb3ad11 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -329,13 +329,12 @@ void Browser::GetLocalDirectory(ItemList &v, const std::string &directory, bool else if (hasSupportedExtension(file->d_name)) { new_item.type = itSong; - mpd_pair file_pair = { "file", strdup(full_path.c_str()) }; - mpd_song *s = mpd_song_begin(&file_pair); + mpd_pair file_pair = { "file", full_path.c_str() }; + new_item.song = new Song(mpd_song_begin(&file_pair)); # ifdef HAVE_TAGLIB_H if (!recursively) - TagEditor::ReadTags(s); + TagEditor::ReadTags(*new_item.song); # endif // HAVE_TAGLIB_H - new_item.song = new Song(s); v.push_back(new_item); } } diff --git a/src/song.cpp b/src/song.cpp index 2c132a33..6b6a79d1 100644 --- a/src/song.cpp +++ b/src/song.cpp @@ -344,6 +344,11 @@ void MPD::Song::SetPosition(unsigned pos) mpd_song_set_pos(itsSong, pos); } +void MPD::Song::SetLength(unsigned len) +{ + mpd_song_set_duration(itsSong, len); +} + std::string MPD::Song::ParseFormat(std::string::const_iterator &it) const { std::string result; diff --git a/src/song.h b/src/song.h index bc8442f9..d710ca0a 100644 --- a/src/song.h +++ b/src/song.h @@ -74,6 +74,7 @@ namespace MPD void SetDisc(const std::string &); void SetComment(const std::string &); void SetPosition(unsigned); + void SetLength(unsigned); void SetNewName(const std::string &name) { itsNewName = name == GetName() ? "" : name; } std::string GetNewName() const { return itsNewName; } diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp index 7b9445fb..5c6d3ca5 100644 --- a/src/tag_editor.cpp +++ b/src/tag_editor.cpp @@ -29,6 +29,7 @@ #include "textidentificationframe.h" #include "mpegfile.h" +#include "browser.h" #include "charset.h" #include "display.h" #include "global.h" @@ -873,40 +874,28 @@ void TagEditor::PrevColumn() } } -void TagEditor::ReadTags(mpd_Song *s) +void TagEditor::ReadTags(MPD::Song &s) { - TagLib::FileRef f(s->file); + TagLib::FileRef f(s.GetFile().c_str()); if (f.isNull()) return; TagLib::MPEG::File *mpegf = dynamic_cast(f.file()); - s->artist = !f.tag()->artist().isEmpty() ? str_pool_get(f.tag()->artist().toCString(1)) : 0; - s->title = !f.tag()->title().isEmpty() ? str_pool_get(f.tag()->title().toCString(1)) : 0; - s->album = !f.tag()->album().isEmpty() ? str_pool_get(f.tag()->album().toCString(1)) : 0; - s->track = f.tag()->track() ? str_pool_get(IntoStr(f.tag()->track()).c_str()) : 0; - s->date = f.tag()->year() ? str_pool_get(IntoStr(f.tag()->year()).c_str()) : 0; - s->genre = !f.tag()->genre().isEmpty() ? str_pool_get(f.tag()->genre().toCString(1)) : 0; + s.SetArtist(f.tag()->artist().to8Bit(1)); + s.SetTitle(f.tag()->title().to8Bit(1)); + s.SetAlbum(f.tag()->album().to8Bit(1)); + s.SetTrack(IntoStr(f.tag()->track())); + s.SetDate(IntoStr(f.tag()->year())); + s.SetGenre(f.tag()->genre().to8Bit(1)); if (mpegf) { - s->composer = !mpegf->ID3v2Tag()->frameListMap()["TCOM"].isEmpty() - ? (!mpegf->ID3v2Tag()->frameListMap()["TCOM"].front()->toString().isEmpty() - ? str_pool_get(mpegf->ID3v2Tag()->frameListMap()["TCOM"].front()->toString().toCString(1)) - : 0) - : 0; - s->performer = !mpegf->ID3v2Tag()->frameListMap()["TOPE"].isEmpty() - ? (!mpegf->ID3v2Tag()->frameListMap()["TOPE"].front()->toString().isEmpty() - ? str_pool_get(mpegf->ID3v2Tag()->frameListMap()["TOPE"].front()->toString().toCString(1)) - : 0) - : 0; - s->disc = !mpegf->ID3v2Tag()->frameListMap()["TPOS"].isEmpty() - ? (!mpegf->ID3v2Tag()->frameListMap()["TPOS"].front()->toString().isEmpty() - ? str_pool_get(mpegf->ID3v2Tag()->frameListMap()["TPOS"].front()->toString().toCString(1)) - : 0) - : 0; + s.SetComposer(!mpegf->ID3v2Tag()->frameListMap()["TCOM"].isEmpty() ? mpegf->ID3v2Tag()->frameListMap()["TCOM"].front()->toString().to8Bit(1) : ""); + s.SetPerformer(!mpegf->ID3v2Tag()->frameListMap()["TOPE"].isEmpty() ? mpegf->ID3v2Tag()->frameListMap()["TOPE"].front()->toString().to8Bit(1) : ""); + s.SetDisc(!mpegf->ID3v2Tag()->frameListMap()["TPOS"].isEmpty() ? mpegf->ID3v2Tag()->frameListMap()["TPOS"].front()->toString().to8Bit(1) : ""); } - s->comment = !f.tag()->comment().isEmpty() ? str_pool_get(f.tag()->comment().toCString(1)) : 0; - s->time = f.audioProperties()->length(); + s.SetComment(f.tag()->comment().to8Bit(1)); + s.SetLength(f.audioProperties()->length()); } namespace @@ -1001,7 +990,7 @@ bool TagEditor::WriteTags(MPD::Song &s) Mpd.CommitCommandsList(); } else // only myBrowser->Main() - s.SetFile(new_name); + myBrowser->GetDirectory(myBrowser->CurrentDir()); } } return true; diff --git a/src/tag_editor.h b/src/tag_editor.h index fbc70393..1dff989b 100644 --- a/src/tag_editor.h +++ b/src/tag_editor.h @@ -75,7 +75,7 @@ class TagEditor : public Screen /// NOTICE: this string is always in utf8, no need to convert it const std::string &CurrentDir() { return itsBrowsedDir; } - static void ReadTags(mpd_Song *); + static void ReadTags(MPD::Song &); static bool WriteTags(MPD::Song &); protected: