From 1a794e7f63846baa8c52bbed5506052cc02db331 Mon Sep 17 00:00:00 2001 From: Clemens Zeidler Date: Fri, 29 Oct 2010 13:03:03 +0000 Subject: [PATCH] Add simple audio tag add-on and rename FullText dir to fulltext. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39185 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/index_server/Jamfile | 3 +- .../audiotags/AudioTagAnalyser.cpp | 76 +++++++++++++++++++ .../index_server/audiotags/AudioTagAnalyser.h | 26 +++++++ src/add-ons/index_server/audiotags/Jamfile | 23 ++++++ .../CLuceneDataBase.cpp | 0 .../{FullText => fulltext}/CLuceneDataBase.h | 0 .../FullTextAnalyser.cpp | 0 .../{FullText => fulltext}/FullTextAnalyser.h | 0 .../{FullText => fulltext}/Jamfile | 4 +- 9 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 src/add-ons/index_server/audiotags/AudioTagAnalyser.cpp create mode 100644 src/add-ons/index_server/audiotags/AudioTagAnalyser.h create mode 100644 src/add-ons/index_server/audiotags/Jamfile rename src/add-ons/index_server/{FullText => fulltext}/CLuceneDataBase.cpp (100%) rename src/add-ons/index_server/{FullText => fulltext}/CLuceneDataBase.h (100%) rename src/add-ons/index_server/{FullText => fulltext}/FullTextAnalyser.cpp (100%) rename src/add-ons/index_server/{FullText => fulltext}/FullTextAnalyser.h (100%) rename src/add-ons/index_server/{FullText => fulltext}/Jamfile (81%) diff --git a/src/add-ons/index_server/Jamfile b/src/add-ons/index_server/Jamfile index ce2e1162fc..171027c7f2 100644 --- a/src/add-ons/index_server/Jamfile +++ b/src/add-ons/index_server/Jamfile @@ -1,3 +1,4 @@ SubDir HAIKU_TOP src add-ons index_server ; -SubInclude HAIKU_TOP src add-ons index_server FullText ; +SubInclude HAIKU_TOP src add-ons index_server fulltext ; +SubInclude HAIKU_TOP src add-ons index_server audiotags ; diff --git a/src/add-ons/index_server/audiotags/AudioTagAnalyser.cpp b/src/add-ons/index_server/audiotags/AudioTagAnalyser.cpp new file mode 100644 index 0000000000..da96a64ea9 --- /dev/null +++ b/src/add-ons/index_server/audiotags/AudioTagAnalyser.cpp @@ -0,0 +1,76 @@ +#include "AudioTagAnalyser.h" + +#include + +#include + +#include +#include +#include + + +AudioTagAnalyser::AudioTagAnalyser(BString name, const BVolume& volume) + : + FileAnalyser(name, volume) +{ + +} + + +status_t +AudioTagAnalyser::InitCheck() +{ + return B_OK; +} + + +#include +void +AudioTagAnalyser::AnalyseEntry(const entry_ref& ref) +{ + BPath path(&ref); + + TagLib::FileRef tagFile(path.Path()); + TagLib::Tag* tag = tagFile.tag(); + if (!tag) + return; + + TagLib::String artist = tag->artist(); + TagLib::String title = tag->title(); + TagLib::String album = tag->album(); + printf("artist: %s, title: %s, album: %s\n", artist.toCString(), + title.toCString(), album.toCString()); + + BFile file(path.Path(), B_READ_ONLY); + if (file.InitCheck() != B_OK) + return; + + const char* cArtist = artist.toCString(true); + file.WriteAttr("Media:Artist", B_STRING_TYPE, 0, cArtist, strlen(cArtist)); + const char* cTitle = title.toCString(true); + file.WriteAttr("Media:Title", B_STRING_TYPE, 0, cTitle, strlen(cTitle)); + const char* cAlbum = album.toCString(true); + file.WriteAttr("Media:Album", B_STRING_TYPE, 0, cAlbum, strlen(cAlbum)); +} + + +AudioTagAddOn::AudioTagAddOn(image_id id, const char* name) + : + IndexServerAddOn(id, name) +{ + +} + + +FileAnalyser* +AudioTagAddOn::CreateFileAnalyser(const BVolume& volume) +{ + return new (std::nothrow)AudioTagAnalyser(Name(), volume); +} + + +extern "C" IndexServerAddOn* (instantiate_index_server_addon)(image_id id, + const char* name) +{ + return new (std::nothrow)AudioTagAddOn(id, name); +} diff --git a/src/add-ons/index_server/audiotags/AudioTagAnalyser.h b/src/add-ons/index_server/audiotags/AudioTagAnalyser.h new file mode 100644 index 0000000000..010242a92a --- /dev/null +++ b/src/add-ons/index_server/audiotags/AudioTagAnalyser.h @@ -0,0 +1,26 @@ +#ifndef AUDIO_TAG_ANALYSER_H +#define AUDIO_TAG_ANALYSER_H + + +#include "IndexServerAddOn.h" + + +class AudioTagAnalyser : public FileAnalyser { +public: + AudioTagAnalyser(BString name, + const BVolume& volume); + + status_t InitCheck(); + + void AnalyseEntry(const entry_ref& ref); +}; + + +class AudioTagAddOn : public IndexServerAddOn { +public: + AudioTagAddOn(image_id id, const char* name); + + FileAnalyser* CreateFileAnalyser(const BVolume& volume); +}; + +#endif diff --git a/src/add-ons/index_server/audiotags/Jamfile b/src/add-ons/index_server/audiotags/Jamfile new file mode 100644 index 0000000000..8273c72ce4 --- /dev/null +++ b/src/add-ons/index_server/audiotags/Jamfile @@ -0,0 +1,23 @@ +SubDir HAIKU_TOP src add-ons index_server audiotags ; + +UsePrivateHeaders index_server shared ; + +local sources = + AudioTagAnalyser.cpp + + IndexServerAddOn.cpp + ; + +SubDirSysHdrs $(HAIKU_TAGLIB_HEADERS) ; +Includes [ FGristFiles $(sources) ] : $(HAIKU_TAGLIB_HEADERS_DEPENDENCY) ; + # Dependency needed to trigger downloading/unzipping the package before + # compiling the files. + +Addon AudioTagAnalyser : + $(sources) + : + be $(HAIKU_TAGLIB_LIBS) $(TARGET_LIBSTDC++) + ; + +SEARCH on [ FGristFiles IndexServerAddOn.cpp ] + += [ FDirName $(SUBDIR) $(DOTDOT) ] ; diff --git a/src/add-ons/index_server/FullText/CLuceneDataBase.cpp b/src/add-ons/index_server/fulltext/CLuceneDataBase.cpp similarity index 100% rename from src/add-ons/index_server/FullText/CLuceneDataBase.cpp rename to src/add-ons/index_server/fulltext/CLuceneDataBase.cpp diff --git a/src/add-ons/index_server/FullText/CLuceneDataBase.h b/src/add-ons/index_server/fulltext/CLuceneDataBase.h similarity index 100% rename from src/add-ons/index_server/FullText/CLuceneDataBase.h rename to src/add-ons/index_server/fulltext/CLuceneDataBase.h diff --git a/src/add-ons/index_server/FullText/FullTextAnalyser.cpp b/src/add-ons/index_server/fulltext/FullTextAnalyser.cpp similarity index 100% rename from src/add-ons/index_server/FullText/FullTextAnalyser.cpp rename to src/add-ons/index_server/fulltext/FullTextAnalyser.cpp diff --git a/src/add-ons/index_server/FullText/FullTextAnalyser.h b/src/add-ons/index_server/fulltext/FullTextAnalyser.h similarity index 100% rename from src/add-ons/index_server/FullText/FullTextAnalyser.h rename to src/add-ons/index_server/fulltext/FullTextAnalyser.h diff --git a/src/add-ons/index_server/FullText/Jamfile b/src/add-ons/index_server/fulltext/Jamfile similarity index 81% rename from src/add-ons/index_server/FullText/Jamfile rename to src/add-ons/index_server/fulltext/Jamfile index c35bb7d23e..3de659ac9f 100644 --- a/src/add-ons/index_server/FullText/Jamfile +++ b/src/add-ons/index_server/fulltext/Jamfile @@ -1,4 +1,4 @@ -SubDir HAIKU_TOP src add-ons index_server FullText ; +SubDir HAIKU_TOP src add-ons index_server fulltext ; UsePrivateHeaders index_server shared ; @@ -17,7 +17,7 @@ Includes [ FGristFiles $(sources) ] : $(HAIKU_CLUCENE_HEADERS_DEPENDENCY) ; Addon FullTextAnalyser : $(sources) : - be translation $(HAIKU_CLUCENE_LIBS) $(TARGET_LIBSTDC++) + be $(HAIKU_CLUCENE_LIBS) $(TARGET_LIBSTDC++) ; SEARCH on [ FGristFiles IndexServerAddOn.cpp ]