diff options
Diffstat (limited to 'kfile-plugins/flac')
-rw-r--r-- | kfile-plugins/flac/Makefile.am | 22 | ||||
-rw-r--r-- | kfile-plugins/flac/configure.in.in | 1 | ||||
-rw-r--r-- | kfile-plugins/flac/kfile_flac.cpp | 282 | ||||
-rw-r--r-- | kfile-plugins/flac/kfile_flac.desktop | 62 | ||||
-rw-r--r-- | kfile-plugins/flac/kfile_flac.h | 51 |
5 files changed, 0 insertions, 418 deletions
diff --git a/kfile-plugins/flac/Makefile.am b/kfile-plugins/flac/Makefile.am deleted file mode 100644 index 34a0ffb3..00000000 --- a/kfile-plugins/flac/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -## Makefile.am for FLAC file meta info plugin - -# set the include path for X, qt, KDE and TagLib -INCLUDES = $(all_includes) $(taglib_includes) - -# these are the headers for your project -noinst_HEADERS = kfile_flac.h - -kde_module_LTLIBRARIES = kfile_flac.la - -kfile_flac_la_SOURCES = kfile_flac.cpp -kfile_flac_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor $(taglib_libs) -module $(KDE_PLUGIN) -kfile_flac_la_LIBADD = $(LIB_KIO) - -# let automoc handle all of the meta source files (moc) -METASOURCES = AUTO - -messages: rc.cpp - $(XGETTEXT) kfile_flac.cpp -o $(podir)/kfile_flac.pot - -services_DATA = kfile_flac.desktop -servicesdir = $(kde_servicesdir) diff --git a/kfile-plugins/flac/configure.in.in b/kfile-plugins/flac/configure.in.in deleted file mode 100644 index eeaeebf5..00000000 --- a/kfile-plugins/flac/configure.in.in +++ /dev/null @@ -1 +0,0 @@ -AM_CONDITIONAL(include_flac_SUBDIR, test "x$have_taglib" = xyes) diff --git a/kfile-plugins/flac/kfile_flac.cpp b/kfile-plugins/flac/kfile_flac.cpp deleted file mode 100644 index c621f74c..00000000 --- a/kfile-plugins/flac/kfile_flac.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/* This file is part of the KDE project - * Copyright (C) 2003-2004 Allan Sandfeld Jensen <kde@carewolf.com> - * - * Originally based upon the kfile_ogg plugin: - * Copyright (C) 2001, 2002 Rolf Magnus <ramagnus@kde.org> - * Interfacing to TagLib is copied from kfile_mp3 plugin: - * Copyright (C) 2003 Scott Wheeler <wheeler@kde.org> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation version 2. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "kfile_flac.h" - -#include <tqcstring.h> -#include <tqfile.h> -#include <tqdatetime.h> -#include <tqdict.h> -#include <tqvalidator.h> -#include <tqfileinfo.h> - -#include <kdebug.h> -#include <kurl.h> -#include <kprocess.h> -#include <klocale.h> -#include <kgenericfactory.h> -#include <ksavefile.h> - -#include <tag.h> -#if (TAGLIB_MAJOR_VERSION>1) || \ - ((TAGLIB_MAJOR_VERSION==1) && (TAGLIB_MINOR_VERSION>=2)) -#define TAGLIB_1_2 -#endif - -#include <tstring.h> -#include <tfile.h> -#include <flacfile.h> -#ifdef TAGLIB_1_2 -#include <oggflacfile.h> -#endif - -#include <sys/stat.h> -#include <unistd.h> -#include <ctype.h> - -K_EXPORT_COMPONENT_FACTORY(kfile_flac, KGenericFactory<KFlacPlugin>("kfile_flac")) - -KFlacPlugin::KFlacPlugin( TQObject *parent, const char *name, - const TQStringList &args ) - : KFilePlugin( parent, name, args ) -{ - kdDebug(7034) << "flac plugin\n"; - - makeMimeTypeInfo( "audio/x-flac" ); -#ifdef TAGLIB_1_2 - makeMimeTypeInfo( "audio/x-oggflac" ); -#endif - -} - -void KFlacPlugin::makeMimeTypeInfo(const TQString& mimeType) -{ - KFileMimeTypeInfo* info = addMimeTypeInfo( mimeType ); - - KFileMimeTypeInfo::GroupInfo* group = 0; - - // comment group - group = addGroupInfo(info, "Comment", i18n("Comment")); - setAttributes(group, KFileMimeTypeInfo::Addable | - KFileMimeTypeInfo::Removable); - - KFileMimeTypeInfo::ItemInfo* item = 0; - - item = addItemInfo(group, "Artist", i18n("Artist"), TQVariant::String); - setHint(item, KFileMimeTypeInfo::Author); - setAttributes(item, KFileMimeTypeInfo::Modifiable); - - item = addItemInfo(group, "Title", i18n("Title"), TQVariant::String); - setHint(item, KFileMimeTypeInfo::Name); - setAttributes(item, KFileMimeTypeInfo::Modifiable); - - item = addItemInfo(group, "Album", i18n("Album"), TQVariant::String); - setAttributes(item, KFileMimeTypeInfo::Modifiable); - - item = addItemInfo(group, "Genre", i18n("Genre"), TQVariant::String); - setAttributes(item, KFileMimeTypeInfo::Modifiable); - - item = addItemInfo(group, "Tracknumber", i18n("Track Number"), TQVariant::String); - setAttributes(item, KFileMimeTypeInfo::Modifiable); - - item = addItemInfo(group, "Date", i18n("Date"), TQVariant::String); - setAttributes(item, KFileMimeTypeInfo::Modifiable); - - item = addItemInfo(group, "Description", i18n("Description"), TQVariant::String); - setAttributes(item, KFileMimeTypeInfo::Modifiable); - - item = addItemInfo(group, "Organization", i18n("Organization"), TQVariant::String); - setAttributes(item, KFileMimeTypeInfo::Modifiable); - - item = addItemInfo(group, "Location", i18n("Location"), TQVariant::String); - setAttributes(item, KFileMimeTypeInfo::Modifiable); - - item = addItemInfo(group, "Copyright", i18n("Copyright"), TQVariant::String); - setAttributes(item, KFileMimeTypeInfo::Modifiable); - - - addVariableInfo(group, TQVariant::String, KFileMimeTypeInfo::Addable | - KFileMimeTypeInfo::Removable | - KFileMimeTypeInfo::Modifiable); - - // technical group - group = addGroupInfo(info, "Technical", i18n("Technical Details")); - setAttributes(group, 0); - - addItemInfo(group, "Channels", i18n("Channels"), TQVariant::Int); - - item = addItemInfo(group, "Sample Rate", i18n("Sample Rate"), TQVariant::Int); - setSuffix(item, i18n(" Hz")); - - item = addItemInfo(group, "Sample Width", i18n("Sample Width"), TQVariant::Int); - setSuffix(item, i18n(" bits")); - - item = addItemInfo(group, "Bitrate", i18n("Average Bitrate"), - TQVariant::Int); - setAttributes(item, KFileMimeTypeInfo::Averaged); - setHint(item, KFileMimeTypeInfo::Bitrate); - setSuffix(item, i18n( " kbps")); - - item = addItemInfo(group, "Length", i18n("Length"), TQVariant::Int); - setAttributes(item, KFileMimeTypeInfo::Cummulative); - setHint(item, KFileMimeTypeInfo::Length); - setUnit(item, KFileMimeTypeInfo::Seconds); -} - -bool KFlacPlugin::readInfo( KFileMetaInfo& info, uint what ) -{ - if ( info.path().isEmpty() ) // remote file - return false; - - bool readComment = false; - bool readTech = false; - if (what & (KFileMetaInfo::Fastest | - KFileMetaInfo::DontCare | - KFileMetaInfo::ContentInfo)) readComment = true; - - if (what & (KFileMetaInfo::Fastest | - KFileMetaInfo::DontCare | - KFileMetaInfo::TechnicalInfo)) readTech = true; - - TagLib::File *file = 0; - - if (info.mimeType() == "audio/x-flac") - file = new TagLib::FLAC::File(TQFile::encodeName(info.path()).data(), readTech); -#ifdef TAGLIB_1_2 - else - file = new TagLib::Ogg::FLAC::File(TQFile::encodeName(info.path()).data(), readTech); -#endif - - if (!file || !file->isValid()) - { - kdDebug(7034) << "Couldn't open " << file->name() << endl; - delete file; - return false; - } - - if(readComment && file->tag()) - { - KFileMetaInfoGroup commentgroup = appendGroup(info, "Comment"); - - TQString date = file->tag()->year() > 0 ? TQString::number(file->tag()->year()) : TQString(); - TQString track = file->tag()->track() > 0 ? TQString::number(file->tag()->track()) : TQString(); - - appendItem(commentgroup, "Title", TQString(TStringToQString(file->tag()->title())).stripWhiteSpace()); - appendItem(commentgroup, "Artist", TQString(TStringToQString(file->tag()->artist())).stripWhiteSpace()); - appendItem(commentgroup, "Album", TQString(TStringToQString(file->tag()->album())).stripWhiteSpace()); - appendItem(commentgroup, "Date", date); - appendItem(commentgroup, "Comment", TQString(TStringToQString(file->tag()->comment())).stripWhiteSpace()); - appendItem(commentgroup, "Tracknumber", track); - appendItem(commentgroup, "Genre", TQString(TStringToQString(file->tag()->genre())).stripWhiteSpace()); - } - - if (readTech && file->audioProperties()) - { - KFileMetaInfoGroup techgroup = appendGroup(info, "Technical"); - TagLib::FLAC::Properties *properties = - (TagLib::FLAC::Properties*)(file->audioProperties()); - - appendItem(techgroup, "Bitrate", properties->bitrate()); - appendItem(techgroup, "Sample Rate", properties->sampleRate()); - appendItem(techgroup, "Sample Width", properties->sampleWidth()); - appendItem(techgroup, "Channels", properties->channels()); - appendItem(techgroup, "Length", properties->length()); - } - - delete file; - return true; - -} - -/** - * Do translation between KFileMetaInfo items and TagLib::String in a tidy way. - */ - -class Translator -{ -public: - Translator(const KFileMetaInfo &info) : m_info(info) {} - TagLib::String operator[](const char *key) const - { - return QStringToTString(m_info["Comment"][key].value().toString()); - } - int toInt(const char *key) const - { - return m_info["Comment"][key].value().toInt(); - } -private: - const KFileMetaInfo &m_info; -}; - -bool KFlacPlugin::writeInfo(const KFileMetaInfo& info) const -{ - TagLib::File *file; - - if (!TagLib::File::isWritable(TQFile::encodeName(info.path()).data())) { - kdDebug(7034) << "can't write to " << info.path() << endl; - return false; - } - - if (info.mimeType() == "audio/x-flac") - file = new TagLib::FLAC::File(TQFile::encodeName(info.path()).data(), false); -#ifdef TAGLIB_1_2 - else - file = new TagLib::Ogg::FLAC::File(TQFile::encodeName(info.path()).data(), false); -#endif - - if(!file->isOpen()) - { - kdDebug(7034) << "couldn't open " << info.path() << endl; - delete file; - return false; - } - - Translator t(info); - - file->tag()->setTitle(t["Title"]); - file->tag()->setArtist(t["Artist"]); - file->tag()->setAlbum(t["Album"]); - file->tag()->setYear(t.toInt("Date")); - file->tag()->setComment(t["Comment"]); - file->tag()->setTrack(t.toInt("Tracknumber")); - file->tag()->setGenre(t["Genre"]); - - file->save(); - - delete file; - return true; -} - -TQValidator* KFlacPlugin::createValidator( const TQString&, - const TQString &group, const TQString &key, - TQObject* parent, const char* name) const -{ - if(key == "Tracknumber" || key == "Date") - { - return new TQIntValidator(0, 9999, parent, name); - } - else - return new TQRegExpValidator(TQRegExp(".*"), parent, name); -} - -#include "kfile_flac.moc" diff --git a/kfile-plugins/flac/kfile_flac.desktop b/kfile-plugins/flac/kfile_flac.desktop deleted file mode 100644 index f4c65815..00000000 --- a/kfile-plugins/flac/kfile_flac.desktop +++ /dev/null @@ -1,62 +0,0 @@ -[Desktop Entry] -Type=Service -Name=FLAC Info -Name[bg]=Информация за FLAC -Name[bn]=ফ্ল্যাক (FLAC) তথ্য -Name[br]=Titouroù FLAC -Name[bs]=FLAC informacije -Name[ca]=Informació FLAC -Name[cs]=FLAC info -Name[cy]=Gwybodaeth FLAC -Name[da]=FLAC-Info -Name[de]=FLAC-Info -Name[el]=Πληροφορίες FLAC -Name[es]=Info FLAC -Name[et]=FLAC info -Name[eu]=FLAC Informazioa -Name[fa]=اطلاعات FLAC -Name[fi]=FLAC-tiedot -Name[fr]=Informations FLAC -Name[gl]=Información FLAC -Name[he]=מידע FLAC -Name[hi]=FLAC जानकारी -Name[hu]=FLAC-jellemzők -Name[is]=AU upplýsingar -Name[it]=Informazioni FLAC -Name[ja]=FLAC 情報 -Name[kk]=FLAC мәліметі -Name[km]=ព័ត៌មាន FLAC -Name[ko]=FLAC 정보 -Name[lt]=FLAC informacija -Name[mk]=FLAC информации -Name[nb]=FLAC informasjon -Name[nds]=FLAC-Info -Name[ne]=FLAC सूचना -Name[nl]=FLAC-informatie -Name[nn]=FLAC-info -Name[pa]=FLAC ਜਾਣਕਾਰੀ -Name[pl]=Informacja o pliku FLAC -Name[pt]=Informação do FLAC -Name[pt_BR]=Informação sobre FLAC -Name[ro]=Informaţii FLAC -Name[ru]=Сведения о FLAC -Name[sk]=FLAC info -Name[sl]=Podatki o FLAC -Name[sr]=Информације о FLAC-у -Name[sr@Latn]=Informacije o FLAC-u -Name[sv]=FLAC-information -Name[ta]=FLAC தகவல் -Name[tg]=FLAC Ахборот -Name[th]=ขอมูล FLAC -Name[tr]=FLAC Bilgisi -Name[uk]=Інформація по FLAC -Name[uz]=FLAC haqida maʼlumot -Name[uz@cyrillic]=FLAC ҳақида маълумот -Name[zh_CN]=FLAC 信息 -Name[zh_HK]=FLAC 資訊 -Name[zh_TW]=FLAC 資訊 -ServiceTypes=KFilePlugin -X-TDE-Library=kfile_flac -MimeType=audio/x-flac;audio/x-oggflac -PreferredGroups=Comment,Technical -PreferredItems=Title,Artist,Album,Tracknumber,Genre,Bitrate,Length,Channels, Date,Description,Organization,Location,Copyright diff --git a/kfile-plugins/flac/kfile_flac.h b/kfile-plugins/flac/kfile_flac.h deleted file mode 100644 index 08f283ae..00000000 --- a/kfile-plugins/flac/kfile_flac.h +++ /dev/null @@ -1,51 +0,0 @@ -/* This file is part of the KDE project - * Copyright (C) 2003 Allan Sandfeld Jensen <kde@carewolf.com> - * - * Originally based upon the kfile_ogg plugin: - * Copyright (C) 2001, 2002 Rolf Magnus <ramagnus@kde.org> - * Interfacing to TagLib is copied from kfile_mp3 plugin: - * Copyright (C) 2003 Scott Wheeler <wheeler@kde.org> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation version 2. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __KFILE_FLAC_H__ -#define __KFILE_FLAC_H__ - -#include <kfilemetainfo.h> - -class TQString; -class TQStringList; - -class KFlacPlugin: public KFilePlugin -{ - Q_OBJECT - - -public: - KFlacPlugin( TQObject *parent, const char *name, const TQStringList& args ); - - virtual bool readInfo( KFileMetaInfo& info, uint what); - virtual bool writeInfo( const KFileMetaInfo& info ) const; - virtual TQValidator* createValidator( const TQString& mimetype, - const TQString &group, - const TQString &key, - TQObject* parent, const char* name) const; -protected: - virtual void makeMimeTypeInfo(const TQString& mimeType); -}; - - -#endif |