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
This commit is contained in:
Clemens Zeidler
2010-10-29 13:03:03 +00:00
parent 2ad1d63bf9
commit 1a794e7f63
9 changed files with 129 additions and 3 deletions
+2 -1
View File
@@ -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 ;
@@ -0,0 +1,76 @@
#include "AudioTagAnalyser.h"
#include <new>
#include <Path.h>
#include <audioproperties.h>
#include <tag.h>
#include <fileref.h>
AudioTagAnalyser::AudioTagAnalyser(BString name, const BVolume& volume)
:
FileAnalyser(name, volume)
{
}
status_t
AudioTagAnalyser::InitCheck()
{
return B_OK;
}
#include <stdio.h>
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);
}
@@ -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
@@ -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) ] ;
@@ -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 ]