summaryrefslogtreecommitdiffstats
path: root/src/pluginloader
diff options
context:
space:
mode:
Diffstat (limited to 'src/pluginloader')
-rwxr-xr-xsrc/pluginloader/Makefile.am9
-rwxr-xr-xsrc/pluginloader/convertpluginloader.cpp265
-rwxr-xr-xsrc/pluginloader/convertpluginloader.h190
-rwxr-xr-xsrc/pluginloader/formatinfoloader.cpp88
-rwxr-xr-xsrc/pluginloader/formatinfoloader.h67
-rwxr-xr-xsrc/pluginloader/pluginloaderbase.cpp17
-rwxr-xr-xsrc/pluginloader/pluginloaderbase.h86
-rwxr-xr-xsrc/pluginloader/replaygainpluginloader.cpp116
-rwxr-xr-xsrc/pluginloader/replaygainpluginloader.h89
-rwxr-xr-xsrc/pluginloader/ripperpluginloader.cpp111
-rwxr-xr-xsrc/pluginloader/ripperpluginloader.h84
11 files changed, 1122 insertions, 0 deletions
diff --git a/src/pluginloader/Makefile.am b/src/pluginloader/Makefile.am
new file mode 100755
index 0000000..64ca193
--- /dev/null
+++ b/src/pluginloader/Makefile.am
@@ -0,0 +1,9 @@
+INCLUDES = -I$(top_srcdir)/src/metadata $(all_includes) -I$(top_srcdir)/src/
+METASOURCES = AUTO
+noinst_HEADERS = pluginloaderbase.h convertpluginloader.h \
+ replaygainpluginloader.h formatinfoloader.h ripperpluginloader.h
+
+noinst_LTLIBRARIES = libpluginloader.la
+libpluginloader_la_SOURCES = pluginloaderbase.cpp \
+ convertpluginloader.cpp replaygainpluginloader.cpp formatinfoloader.cpp \
+ ripperpluginloader.cpp
diff --git a/src/pluginloader/convertpluginloader.cpp b/src/pluginloader/convertpluginloader.cpp
new file mode 100755
index 0000000..89996ba
--- /dev/null
+++ b/src/pluginloader/convertpluginloader.cpp
@@ -0,0 +1,265 @@
+
+#include "convertpluginloader.h"
+
+#include <qfile.h>
+
+#include <klocale.h>
+#include <kglobal.h>
+
+// TODO check whether it is possible to implement presets in the lame plugin
+
+ConvertPlugin::ConvertPlugin()
+{}
+
+ConvertPlugin::~ConvertPlugin()
+{}
+
+
+ConvertPluginLoader::ConvertPluginLoader()
+{}
+
+ConvertPluginLoader::~ConvertPluginLoader()
+{}
+
+int ConvertPluginLoader::verifyFile( QString fileName )
+{
+ QFile opmlFile( fileName );
+ if( !opmlFile.open( IO_ReadOnly ) ) {
+ return -1;
+ }
+ if( !domTree.setContent( &opmlFile ) ) {
+ return -1;
+ }
+ opmlFile.close();
+
+ QDomElement root = domTree.documentElement();
+ if( root.attribute("type") != "converter" ) return -1;
+ int version;
+ QDomNode node;
+ node = root.firstChild();
+ while( !node.isNull() ) {
+ if( node.isElement() && node.nodeName() == "info" ) {
+ version = node.toElement().attribute("version","0").toInt();
+ break;
+ }
+ }
+
+ return version;
+}
+
+ConvertPlugin* ConvertPluginLoader::loadFile( QString fileName )
+{
+ int t_int;
+ float t_float;
+ QString t_str;
+
+ ConvertPlugin* plugin = new ConvertPlugin();
+ plugin->info.version = -1; // if something goes wrong, we can see that by looking at plugin->info.version
+ plugin->filePathName = fileName;
+
+ QFile opmlFile( fileName );
+ if( !opmlFile.open( IO_ReadOnly ) ) {
+ return plugin;
+ }
+ if( !domTree.setContent( &opmlFile ) ) {
+ return plugin;
+ }
+ opmlFile.close();
+
+ QString language = KGlobal::locale()->languagesTwoAlpha().first();
+
+ QDomElement root = domTree.documentElement();
+ if( root.attribute("type") != "converter" ) return plugin;
+ QDomNode node, sub1Node, sub2Node, sub3Node, sub4Node;
+ node = root.firstChild();
+
+ plugin->enc.enabled = false;
+ plugin->enc.strength.enabled = false;
+ plugin->enc.lossy.enabled = false;
+ plugin->enc.lossy.quality.enabled = false;
+ plugin->enc.lossy.bitrate.abr.enabled = false;
+ plugin->enc.lossy.bitrate.abr.bitrate_range.enabled = false;
+ plugin->enc.lossy.bitrate.cbr.enabled = false;
+ plugin->enc.lossy.samplingrate.enabled = false;
+ plugin->enc.lossy.channels.stereo_enabled = false;
+ plugin->enc.lossy.channels.joint_stereo_enabled = false;
+ plugin->enc.lossy.channels.forced_joint_stereo_enabled = false;
+ plugin->enc.lossy.channels.dual_channels_enabled = false;
+ plugin->enc.lossy.channels.mono_enabled = false;
+ plugin->enc.lossless.enabled = false;
+ plugin->enc.hybrid.enabled = false;
+ plugin->enc.replaygain.enabled = false;
+ plugin->enc.tag.enabled = false;
+ plugin->dec.enabled = false;
+
+ while( !node.isNull() ) {
+ if( node.isElement() && node.nodeName() == "info" ) {
+
+ plugin->info.name = node.toElement().attribute("name",i18n("Unknown Name"));
+ plugin->info.about = node.toElement().attribute("about_"+language);
+ if( plugin->info.about.isEmpty() ) plugin->info.about = node.toElement().attribute("about");
+ if( plugin->info.about.isEmpty() ) plugin->info.about = i18n("Sorry, no information available!");
+ plugin->info.author = node.toElement().attribute("author",i18n("Unknown Author"));
+ plugin->info.version = node.toElement().attribute("version","0").toInt();
+
+ }
+ else if( node.isElement() && node.nodeName() == "enc" ) {
+
+ if(node.toElement().attribute("enabled") == "true") plugin->enc.enabled = true;
+ plugin->enc.rank = node.toElement().attribute("rank","10").toInt();
+ plugin->enc.bin = node.toElement().attribute( "bin" );
+ plugin->enc.param = node.toElement().attribute("param");
+ plugin->enc.silent_param = node.toElement().attribute("silent_param");
+ plugin->enc.mime_types = QStringList::split( ',', node.toElement().attribute("mime_types","application/octet-stream") );
+ plugin->enc.in_out_files = node.toElement().attribute("in_out_files");
+ plugin->enc.overwrite = node.toElement().attribute("overwrite");
+
+ sub1Node = node.toElement().firstChild();
+ while( !sub1Node.isNull() ) {
+ if( sub1Node.isElement() && sub1Node.nodeName() == "strength" ) {
+
+ if( sub1Node.toElement().attribute("enabled") == "true" ) plugin->enc.strength.enabled = true;
+ plugin->enc.strength.range_min = sub1Node.toElement().attribute("range_min").toFloat();
+ plugin->enc.strength.range_max = sub1Node.toElement().attribute("range_max").toFloat();
+ plugin->enc.strength.separator = sub1Node.toElement().attribute("separator").at(0);
+ plugin->enc.strength.param = sub1Node.toElement().attribute("param");
+ plugin->enc.strength.step = sub1Node.toElement().attribute("step").toFloat();
+ plugin->enc.strength.profiles = QStringList::split( ',', sub1Node.toElement().attribute("profiles") );
+ plugin->enc.strength.default_value = sub1Node.toElement().attribute("default_value").toFloat();
+
+ }
+ else if( sub1Node.isElement() && sub1Node.nodeName() == "lossy" ) {
+
+ if( sub1Node.toElement().attribute("enabled") == "true" ) plugin->enc.lossy.enabled = true;
+
+ sub2Node = sub1Node.toElement().firstChild();
+ while( !sub2Node.isNull() ) {
+ if( sub2Node.isElement() && sub2Node.nodeName() == "quality" ) {
+
+ if( sub2Node.toElement().attribute("enabled") == "true" ) plugin->enc.lossy.quality.enabled = true;
+ plugin->enc.lossy.quality.range_min = sub2Node.toElement().attribute("range_min").toFloat();
+ plugin->enc.lossy.quality.range_max = sub2Node.toElement().attribute("range_max").toFloat();
+ plugin->enc.lossy.quality.separator = sub2Node.toElement().attribute("separator").at(0);
+ plugin->enc.lossy.quality.help = sub2Node.toElement().attribute("help");
+ plugin->enc.lossy.quality.output = sub2Node.toElement().attribute("output");
+ plugin->enc.lossy.quality.param = sub2Node.toElement().attribute("param");
+ plugin->enc.lossy.quality.step = sub2Node.toElement().attribute("step").toFloat();
+ plugin->enc.lossy.quality.profiles = QStringList::split( ',', sub2Node.toElement().attribute("profiles") );
+
+ }
+ else if( sub2Node.isElement() && sub2Node.nodeName() == "bitrate" ) {
+ sub3Node = sub2Node.toElement().firstChild();
+ while( !sub3Node.isNull() ) {
+ if( sub3Node.isElement() && sub3Node.nodeName() == "abr" ) {
+
+ if( sub3Node.toElement().attribute("enabled") == "true" ) plugin->enc.lossy.bitrate.abr.enabled = true;
+ plugin->enc.lossy.bitrate.abr.output = sub3Node.toElement().attribute("output");
+ plugin->enc.lossy.bitrate.abr.param = sub3Node.toElement().attribute("param");
+
+ sub4Node = sub3Node.toElement().firstChild();
+ while( !sub4Node.isNull() ) {
+ if( sub4Node.isElement() && sub4Node.nodeName() == "bitrate_range" ) {
+
+ if( sub4Node.toElement().attribute("enabled") == "true" ) plugin->enc.lossy.bitrate.abr.bitrate_range.enabled = true;
+ plugin->enc.lossy.bitrate.abr.bitrate_range.param_min = sub4Node.toElement().attribute("min_param");
+ plugin->enc.lossy.bitrate.abr.bitrate_range.param_max = sub4Node.toElement().attribute("max_param");
+
+ }
+ sub4Node = sub4Node.nextSibling();
+ }
+ }
+ else if( sub3Node.isElement() && sub3Node.nodeName() == "cbr" ) {
+
+ if( sub3Node.toElement().attribute("enabled") == "true" ) plugin->enc.lossy.bitrate.cbr.enabled = true;
+ plugin->enc.lossy.bitrate.cbr.output = sub3Node.toElement().attribute("output");
+ plugin->enc.lossy.bitrate.cbr.param = sub3Node.toElement().attribute("param");
+
+ }
+ sub3Node = sub3Node.nextSibling();
+ }
+ }
+ else if( sub2Node.isElement() && sub2Node.nodeName() == "samplingrate" ) {
+
+ if( sub2Node.toElement().attribute("enabled") == "true" ) plugin->enc.lossy.samplingrate.enabled = true;
+ if( sub2Node.toElement().attribute("unit") == "Hz" ) plugin->enc.lossy.samplingrate.unit = PluginLoaderBase::Hz;
+ else plugin->enc.lossy.samplingrate.unit = PluginLoaderBase::KHz;
+ plugin->enc.lossy.samplingrate.param = sub2Node.toElement().attribute("param");
+
+ }
+ else if( sub2Node.isElement() && sub2Node.nodeName() == "channels" ) {
+
+ if( sub2Node.toElement().attribute("stereo_enabled") == "true" ) plugin->enc.lossy.channels.stereo_enabled = true;
+ plugin->enc.lossy.channels.stereo_param = sub2Node.toElement().attribute("stereo_param");
+ if( sub2Node.toElement().attribute("joint_stereo_enabled") == "true" ) plugin->enc.lossy.channels.joint_stereo_enabled = true;
+ plugin->enc.lossy.channels.joint_stereo_param = sub2Node.toElement().attribute("joint_stereo_param");
+ if( sub2Node.toElement().attribute("forced_joint_stereo_enabled") == "true" ) plugin->enc.lossy.channels.forced_joint_stereo_enabled = true;
+ plugin->enc.lossy.channels.forced_joint_stereo_param = sub2Node.toElement().attribute("forced_joint_stereo_param");
+ if( sub2Node.toElement().attribute("dual_channels_enabled") == "true" ) plugin->enc.lossy.channels.dual_channels_enabled = true;
+ plugin->enc.lossy.channels.dual_channels_param=sub2Node.toElement().attribute("dual_channels_param");
+ if( sub2Node.toElement().attribute("mono_enabled") == "true" ) plugin->enc.lossy.channels.mono_enabled = true;
+ plugin->enc.lossy.channels.mono_param=sub2Node.toElement().attribute("mono_param");
+
+ }
+ sub2Node = sub2Node.nextSibling();
+ }
+ }
+ else if( sub1Node.isElement() && sub1Node.nodeName() == "lossless" ) {
+
+ if( sub1Node.toElement().attribute("enabled") == "true" ) plugin->enc.lossless.enabled = true;
+ plugin->enc.lossless.output = sub1Node.toElement().attribute("output");
+ plugin->enc.lossless.param = sub1Node.toElement().attribute("param");
+
+ }
+ else if( sub1Node.isElement() && sub1Node.nodeName() == "hybrid" ) {
+
+ if( sub1Node.toElement().attribute("enabled") == "true" ) plugin->enc.hybrid.enabled = true;
+ plugin->enc.hybrid.output = sub1Node.toElement().attribute("output");
+ plugin->enc.hybrid.param = sub1Node.toElement().attribute("param");
+ plugin->enc.hybrid.correction_file_mime_type = sub1Node.toElement().attribute("correction_file_mime_type","application/octet-stream");
+
+ }
+ else if( sub1Node.isElement() && sub1Node.nodeName() == "replay_gain" ) {
+
+ if( sub1Node.toElement().attribute("enabled") == "true" ) plugin->enc.replaygain.enabled = true;
+ plugin->enc.replaygain.use = sub1Node.toElement().attribute("use");
+ plugin->enc.replaygain.avoid = sub1Node.toElement().attribute("avoid");
+ plugin->enc.replaygain.rank = sub1Node.toElement().attribute("rank","10").toInt();
+
+ }
+ else if( sub1Node.isElement() && sub1Node.nodeName() == "tag" ) {
+
+ if( sub1Node.toElement().attribute("enabled") == "true" ) plugin->enc.tag.enabled = true;
+ plugin->enc.tag.param = sub1Node.toElement().attribute("param");
+ plugin->enc.tag.artist = sub1Node.toElement().attribute("artist");
+ plugin->enc.tag.composer = sub1Node.toElement().attribute("composer");
+ plugin->enc.tag.album = sub1Node.toElement().attribute("album");
+ plugin->enc.tag.disc = sub1Node.toElement().attribute("disc");
+ plugin->enc.tag.title = sub1Node.toElement().attribute("title");
+ plugin->enc.tag.genre = sub1Node.toElement().attribute("genre");
+ plugin->enc.tag.comment = sub1Node.toElement().attribute("comment");
+ plugin->enc.tag.track = sub1Node.toElement().attribute("track");
+ plugin->enc.tag.year = sub1Node.toElement().attribute("year");
+
+ }
+ sub1Node = sub1Node.nextSibling();
+ }
+ }
+ else if ( node.isElement() && node.nodeName() == "dec" ) {
+
+ if(node.toElement().attribute("enabled") == "true") plugin->dec.enabled = true;
+ plugin->dec.rank = node.toElement().attribute("rank","10").toInt();
+ plugin->dec.bin = node.toElement().attribute("bin");
+ plugin->dec.output = node.toElement().attribute("output");
+ plugin->dec.param = node.toElement().attribute("param");
+ plugin->dec.overwrite = node.toElement().attribute("overwrite");
+ plugin->dec.mime_types = QStringList::split( ',', node.toElement().attribute("mime_types","application/octet-stream") );
+ plugin->dec.in_out_files = node.toElement().attribute("in_out_files");
+ plugin->dec.silent_param = node.toElement().attribute("silent_param");
+
+ }
+ node = node.nextSibling();
+ }
+
+ return plugin;
+}
+
diff --git a/src/pluginloader/convertpluginloader.h b/src/pluginloader/convertpluginloader.h
new file mode 100755
index 0000000..ad09e12
--- /dev/null
+++ b/src/pluginloader/convertpluginloader.h
@@ -0,0 +1,190 @@
+
+
+#ifndef CONVERTPLUGINLOADER_H
+#define CONVERTPLUGINLOADER_H
+
+#include "pluginloaderbase.h"
+
+
+/**
+ * @short The complete data, how to use the backend
+ * @author Daniel Faust <hessijames@gmail.com>
+ * @version 0.3
+ */
+class ConvertPlugin
+{
+public:
+ /**
+ * Constructor
+ */
+ ConvertPlugin();
+
+ /**
+ * Destructor
+ */
+ virtual ~ConvertPlugin();
+
+ QString filePathName; // the file name of th plugin (needed to detect write permissions)
+
+ struct Info
+ {
+ int version; // the version of our plugin (v0.2.1 = 201, v11.3 = 110300)
+ QString name; // the name of our plugin
+ QString author; // the author of the plugin
+ QString about; // a short information aboue the plugin
+ } info;
+
+ struct Enc
+ {
+ bool enabled;
+ int rank;
+ QString bin;
+ QString param;
+ QString silent_param;
+ QStringList mime_types;
+ QString in_out_files;
+ QString overwrite;
+
+ struct Strength {
+ bool enabled;
+ QString param;
+ float range_min;
+ float range_max;
+ float step;
+ QChar separator;
+ QStringList profiles;
+ float default_value;
+ } strength;
+
+ struct Lossy {
+ bool enabled;
+
+ struct Quality {
+ bool enabled;
+ QString param;
+ float range_min;
+ float range_max;
+ float step;
+ QChar separator;
+ QString help;
+ QString output;
+ QStringList profiles; // NOTE when using profiles, step must be 1 and range_min 0
+ } quality;
+
+ struct Bitrate {
+ struct Abr
+ {
+ bool enabled;
+ QString param;
+ QString output;
+
+ struct BitrateRange {
+ bool enabled;
+ QString param_min;
+ QString param_max;
+ } bitrate_range;
+
+ } abr;
+
+ struct Cbr {
+ bool enabled;
+ QString param;
+ QString output;
+ } cbr;
+
+ } bitrate;
+
+ struct Samplingrate {
+ bool enabled;
+ QString param;
+ PluginLoaderBase::Unit unit;
+ } samplingrate;
+
+ struct Channels {
+ bool stereo_enabled;
+ QString stereo_param;
+ bool joint_stereo_enabled;
+ QString joint_stereo_param;
+ bool forced_joint_stereo_enabled;
+ QString forced_joint_stereo_param;
+ bool dual_channels_enabled;
+ QString dual_channels_param;
+ bool mono_enabled;
+ QString mono_param;
+ } channels;
+ } lossy;
+
+ struct Lossless {
+ bool enabled;
+ QString param;
+ QString output;
+ } lossless;
+
+ struct Hybrid {
+ bool enabled;
+ QString param;
+ QString output;
+ QString correction_file_mime_type;
+ } hybrid;
+
+ struct ReplayGain {
+ bool enabled;
+ QString use;
+ QString avoid;
+ int rank;
+ } replaygain;
+
+ struct Tag {
+ bool enabled;
+ QString param;
+ QString artist;
+ QString composer;
+ QString album;
+ QString disc;
+ QString title;
+ QString genre;
+ QString comment;
+ QString track;
+ QString year;
+ } tag;
+ } enc;
+
+ struct Dec {
+ bool enabled;
+ int rank;
+ QString bin;
+ QString param;
+ QString silent_param;
+ QStringList mime_types;
+ QString output;
+ QString in_out_files;
+ QString overwrite;
+ } dec;
+};
+
+/**
+ * @short The plugin loader for the converter plugins
+ * @author Daniel Faust <hessijames@gmail.com>
+ * @version 0.3
+ */
+class ConvertPluginLoader : public PluginLoaderBase
+{
+ Q_OBJECT
+public:
+ /**
+ * Constructor
+ */
+ ConvertPluginLoader();
+
+ /**
+ * Destructor
+ */
+ virtual ~ConvertPluginLoader();
+
+ /** is this file a converter plugin and loadable? */
+ int verifyFile( QString );
+ /** load a given file */
+ ConvertPlugin* loadFile( QString );
+};
+
+#endif // CONVERTPLUGINLOADER_H
diff --git a/src/pluginloader/formatinfoloader.cpp b/src/pluginloader/formatinfoloader.cpp
new file mode 100755
index 0000000..c585ed6
--- /dev/null
+++ b/src/pluginloader/formatinfoloader.cpp
@@ -0,0 +1,88 @@
+
+#include "formatinfoloader.h"
+
+#include <qfile.h>
+
+#include <klocale.h>
+#include <kglobal.h>
+
+FormatInfo::FormatInfo()
+{}
+
+FormatInfo::~FormatInfo()
+{}
+
+
+FormatInfoLoader::FormatInfoLoader()
+{}
+
+FormatInfoLoader::~FormatInfoLoader()
+{}
+
+bool FormatInfoLoader::verifyFile( QString fileName )
+{
+ QFile opmlFile( fileName );
+ if( !opmlFile.open( IO_ReadOnly ) ) {
+ return false;
+ }
+ if( !domTree.setContent( &opmlFile ) ) {
+ return false;
+ }
+ opmlFile.close();
+
+ QDomElement root = domTree.documentElement();
+ if( root.attribute("type") == "format_info" ) return true;
+
+ return false;
+}
+
+FormatInfo* FormatInfoLoader::loadFile( QString fileName )
+{
+ int t_int;
+ float t_float;
+ QString t_str;
+
+ FormatInfo* plugin = new FormatInfo();
+ plugin->mime_types = "application/octet-stream"; // if something goes wrong, we can see that by looking at plugin->mimetype
+
+ QFile opmlFile( fileName );
+ if( !opmlFile.open( IO_ReadOnly ) ) {
+ return plugin;
+ }
+ if( !domTree.setContent( &opmlFile ) ) {
+ return plugin;
+ }
+ opmlFile.close();
+
+ QString language = KGlobal::locale()->languagesTwoAlpha().first();
+
+ QDomElement root = domTree.documentElement();
+ if( root.attribute("type") != "format_info" ) return plugin;
+ QDomNode node;
+ node = root.firstChild();
+
+ while( !node.isNull() ) {
+ if( node.isElement() && node.nodeName() == "data" ) {
+
+ plugin->mime_types = QStringList::split( ',',node.toElement().attribute("mime_types","application/octet-stream") );
+ plugin->extensions = QStringList::split( ',',node.toElement().attribute("extensions") );
+ plugin->description = node.toElement().attribute("description_"+language);
+ if( plugin->description.isEmpty() ) plugin->description = node.toElement().attribute("description");
+ plugin->urls = QStringList::split( ',',node.toElement().attribute("urls_"+language) );
+ if( plugin->urls.isEmpty() ) plugin->urls = QStringList::split( ',',node.toElement().attribute("urls") );
+ QStringList compressionTypeList = QStringList::split( ',',node.toElement().attribute("compression_type") );
+ plugin->compressionType = (FormatInfo::CompressionType)0x0000;
+ for( QStringList::Iterator it = compressionTypeList.begin(); it != compressionTypeList.end(); ++it ) {
+ if( *it == "lossy" ) plugin->compressionType = FormatInfo::CompressionType( plugin->compressionType | FormatInfo::lossy );
+ else if( *it == "lossless" ) plugin->compressionType = FormatInfo::CompressionType( plugin->compressionType | FormatInfo::lossless );
+ else if( *it == "hybrid" ) plugin->compressionType = FormatInfo::CompressionType( plugin->compressionType | FormatInfo::hybrid );
+ }
+ plugin->size = node.toElement().attribute("size","15000").toInt();
+
+ }
+ node = node.nextSibling();
+ }
+
+ return plugin;
+}
+
diff --git a/src/pluginloader/formatinfoloader.h b/src/pluginloader/formatinfoloader.h
new file mode 100755
index 0000000..f36f7fe
--- /dev/null
+++ b/src/pluginloader/formatinfoloader.h
@@ -0,0 +1,67 @@
+
+
+#ifndef FORMATINFOLOADER_H
+#define FORMATINFOLOADER_H
+
+#include <qobject.h>
+#include <qstringlist.h>
+#include <qdom.h>
+
+/**
+ * @short The complete information about that format
+ * @author Daniel Faust <hessijames@gmail.com>
+ * @version 0.3
+ */
+class FormatInfo
+{
+public:
+ /**
+ * Constructor
+ */
+ FormatInfo();
+
+ /**
+ * Destructor
+ */
+ virtual ~FormatInfo();
+
+ QStringList mime_types;
+ QStringList extensions;
+ QString description;
+ QStringList urls;
+ enum CompressionType {
+ lossy = 0x0001, // encode with loss
+ lossless = 0x0002, // encode without loss
+ hybrid = 0x0004 // encode a file with loss and a correction file
+ } compressionType;
+ int size;
+};
+
+/**
+ * @short The format info loader that provides information about the compression type and a format description
+ * @author Daniel Faust <hessijames@gmail.com>
+ * @version 0.3
+ */
+class FormatInfoLoader : public QObject
+{
+ Q_OBJECT
+public:
+ /**
+ * Constructor
+ */
+ FormatInfoLoader();
+
+ /**
+ * Destructor
+ */
+ virtual ~FormatInfoLoader();
+
+ /** is this file a converter plugin and loadable? */
+ bool verifyFile( QString );
+ /** load a given file */
+ FormatInfo* loadFile( QString );
+ /** the dom tree for loading the xml file */
+ QDomDocument domTree;
+};
+
+#endif // FORMATINFOLOADER_H
diff --git a/src/pluginloader/pluginloaderbase.cpp b/src/pluginloader/pluginloaderbase.cpp
new file mode 100755
index 0000000..d9a8413
--- /dev/null
+++ b/src/pluginloader/pluginloaderbase.cpp
@@ -0,0 +1,17 @@
+
+#include "pluginloaderbase.h"
+
+PluginLoaderBase::PluginLoaderBase()
+{}
+
+PluginLoaderBase::~PluginLoaderBase()
+{}
+
+void PluginLoaderBase::unloadAll()
+{}
+
+void PluginLoaderBase::unload( QString pluginName )
+{}
+
+void PluginLoaderBase::remove( QString pluginName )
+{}
diff --git a/src/pluginloader/pluginloaderbase.h b/src/pluginloader/pluginloaderbase.h
new file mode 100755
index 0000000..c35bebe
--- /dev/null
+++ b/src/pluginloader/pluginloaderbase.h
@@ -0,0 +1,86 @@
+
+
+#ifndef PLUGINLOADERBASE_H
+#define PLUGINLOADERBASE_H
+
+#include <qobject.h>
+#include <qstringlist.h>
+#include <qdom.h>
+
+#include "config.h"
+
+// TODO implement rank everywhere
+
+/**
+ * @short The base for all pluginloaders
+ * @author Daniel Faust <hessijames@gmail.com>
+ * @version 0.3
+ */
+class PluginLoaderBase : public QObject
+{
+ Q_OBJECT
+public:
+ /**
+ * Do we recommend this backend to the user
+ */
+ enum FeatureLevel
+ {
+ Full, // the backend provides full support
+ Most, // most features are supported
+ Basic // we'll have just basic support
+ };
+
+ /**
+ * Just a small enum for our sampling rate units
+ */
+ enum Unit
+ {
+ Hz,
+ KHz
+ };
+
+ /**
+ * Constructor
+ */
+ PluginLoaderBase();
+
+ /**
+ * Destructor
+ */
+ virtual ~PluginLoaderBase();
+
+ /** a list of all plugin files that are loaded at the moment */
+// QStringList openPluginFiles;
+
+ /** the dom tree for loading the xml file */
+ QDomDocument domTree;
+
+public slots:
+ /**
+ * Unload all plugins
+ */
+ void unloadAll();
+
+ /**
+ * Unoad a specific plugin with name @p pluginName
+ */
+ void unload( QString pluginName );
+
+ /**
+ * Unoad a specific plugin with name @p pluginName and delete the plugin file
+ */
+ void remove( QString pluginName );
+};
+
+#endif // PLUGINLOADERBASE_H
+
+
+/**
+
+Each plugin package contains 3 files:
+ - The plugin file ( $KDE_DIR/share/apps/soundkonverter/plugins/'filename' )
+ - The format info file ( $KDE_DIR/share/apps/soundkonverter/format_infos/'lang'/'plugin'_'filename' )
+ - The service menu ( $KDE_DIR/share/apps/konqueror/servicemenus/'filename' )
+
+*/
+
diff --git a/src/pluginloader/replaygainpluginloader.cpp b/src/pluginloader/replaygainpluginloader.cpp
new file mode 100755
index 0000000..7ac11f6
--- /dev/null
+++ b/src/pluginloader/replaygainpluginloader.cpp
@@ -0,0 +1,116 @@
+
+#include "replaygainpluginloader.h"
+
+#include <qfile.h>
+
+#include <klocale.h>
+
+
+ReplayGainPlugin::ReplayGainPlugin()
+{}
+
+ReplayGainPlugin::~ReplayGainPlugin()
+{}
+
+
+ReplayGainPluginLoader::ReplayGainPluginLoader()
+{}
+
+ReplayGainPluginLoader::~ReplayGainPluginLoader()
+{}
+
+int ReplayGainPluginLoader::verifyFile( QString fileName )
+{
+ QFile opmlFile( fileName );
+ if( !opmlFile.open( IO_ReadOnly ) ) {
+ return -1;
+ }
+ if( !domTree.setContent( &opmlFile ) ) {
+ return -1;
+ }
+ opmlFile.close();
+
+ QDomElement root = domTree.documentElement();
+ if( root.attribute("type") != "replaygain" ) return -1;
+ int version;
+ QDomNode node;
+ node = root.firstChild();
+ while( !node.isNull() ) {
+ if( node.isElement() && node.nodeName() == "info" ) {
+ version = node.toElement().attribute("version","0").toInt();
+ break;
+ }
+ }
+
+ return version;
+}
+
+ReplayGainPlugin* ReplayGainPluginLoader::loadFile( QString fileName )
+{
+ //int t_int;
+ //float t_float;
+ //QString t_str;
+
+ ReplayGainPlugin* plugin = new ReplayGainPlugin();
+ plugin->info.version = -1; // if something goes wrong, we can see that by looking at plugin->info.version
+ plugin->filePathName = fileName;
+
+ QFile opmlFile( fileName );
+ if( !opmlFile.open( IO_ReadOnly ) ) {
+ return plugin;
+ }
+ if( !domTree.setContent( &opmlFile ) ) {
+ return plugin;
+ }
+ opmlFile.close();
+
+ QDomElement root = domTree.documentElement();
+ if( root.attribute("type") != "replaygain" ) return plugin;
+ QDomNode node;//, sub1Node;
+ node = root.firstChild();
+
+ while( !node.isNull() ) {
+ if( node.isElement() && node.nodeName() == "info" ) {
+
+ plugin->info.name = node.toElement().attribute("name",i18n("Unknown Name"));
+ plugin->info.about = node.toElement().attribute("about",i18n("Sorry, no information available!"));
+ plugin->info.author = node.toElement().attribute("author",i18n("Unknown Author"));
+ plugin->info.version = node.toElement().attribute("version","0").toInt();
+
+ }
+ else if( node.isElement() && node.nodeName() == "replaygain" ) {
+
+ plugin->replaygain.rank = node.toElement().attribute("rank","10").toInt();
+ plugin->replaygain.bin = node.toElement().attribute( "bin" );
+ plugin->replaygain.param = node.toElement().attribute("param");
+ plugin->replaygain.silent_param = node.toElement().attribute("silent_param");
+ plugin->replaygain.in_files = node.toElement().attribute("in_files");
+ plugin->replaygain.output_single = node.toElement().attribute("output_single");
+ plugin->replaygain.output_multiple = node.toElement().attribute("output_multiple");
+ plugin->replaygain.mime_types = QStringList::split( ',', node.toElement().attribute("mime_types","application/octet-stream") );
+ plugin->replaygain.force = node.toElement().attribute("force");
+ plugin->replaygain.skip = node.toElement().attribute("skip");
+ plugin->replaygain.track = node.toElement().attribute("track");
+ plugin->replaygain.album = node.toElement().attribute("album");
+ plugin->replaygain.remove = node.toElement().attribute("remove");
+
+ /*sub1Node = node.toElement().firstChild(); // obsolete
+ while( !sub1Node.isNull() ) {
+ if( sub1Node.isElement() && sub1Node.nodeName() == "test" ) {
+
+ if( sub1Node.toElement().attribute("enabled") == "true" ) plugin->replaygain.test.enabled = true;
+ else plugin->replaygain.test.enabled = false;
+ plugin->replaygain.test.param = sub1Node.toElement().attribute("param");
+ plugin->replaygain.test.output_track = sub1Node.toElement().attribute("output_track");
+ plugin->replaygain.test.output_album = sub1Node.toElement().attribute("output_album");
+
+ }
+ sub1Node = sub1Node.nextSibling();
+ }*/
+ }
+ node = node.nextSibling();
+ }
+
+ return plugin;
+}
+
diff --git a/src/pluginloader/replaygainpluginloader.h b/src/pluginloader/replaygainpluginloader.h
new file mode 100755
index 0000000..d1c1237
--- /dev/null
+++ b/src/pluginloader/replaygainpluginloader.h
@@ -0,0 +1,89 @@
+
+
+#ifndef REPLAYGAINPLUGINLOADER_H
+#define REPLAYGAINPLUGINLOADER_H
+
+#include "pluginloaderbase.h"
+
+
+/**
+ * @short The complete data, how to use the backend
+ * @author Daniel Faust <hessijames@gmail.com>
+ * @version 0.3
+ */
+class ReplayGainPlugin
+{
+public:
+ /**
+ * Constructor
+ */
+ ReplayGainPlugin();
+
+ /**
+ * Destructor
+ */
+ virtual ~ReplayGainPlugin();
+
+ QString filePathName; // the file name of th plugin (needed to detect write permissions)
+
+ struct Info
+ {
+ int version; // the version of our plugin (v0.2.1 = 201, v11.3 = 110300)
+ QString name; // the name of our plugin
+ QString author; // the author of the plugin
+ QString about; // a short information aboue the plugin
+ } info;
+
+ struct ReplayGain
+ {
+ //PluginLoaderBase::FeatureLevel level;
+ int rank;
+ QString bin;
+ QString param;
+ QString silent_param;
+ QStringList mime_types;
+ QString in_files;
+ QString output_single;
+ QString output_multiple;
+ QString force;
+ QString skip;
+ QString track; // TODO remove track and album (put them into param)
+ QString album;
+ QString remove;
+
+ /*struct Test // obsolete
+ {
+ bool enabled;
+ QString param;
+ QString output_track;
+ QString output_album;
+ } test;*/
+ } replaygain;
+};
+
+/**
+ * @short The plugin loader for the replaygain plugins
+ * @author Daniel Faust <hessijames@gmail.com>
+ * @version 0.3
+ */
+class ReplayGainPluginLoader : public PluginLoaderBase
+{
+ Q_OBJECT
+public:
+ /**
+ * Constructor
+ */
+ ReplayGainPluginLoader();
+
+ /**
+ * Destructor
+ */
+ virtual ~ReplayGainPluginLoader();
+
+ /** is this file a replaygain plugin and loadable? */
+ int verifyFile( QString );
+ /** load a given file */
+ ReplayGainPlugin* loadFile( QString );
+};
+
+#endif // REPLAYGAINPLUGINLOADER_H
diff --git a/src/pluginloader/ripperpluginloader.cpp b/src/pluginloader/ripperpluginloader.cpp
new file mode 100755
index 0000000..9c1f9d4
--- /dev/null
+++ b/src/pluginloader/ripperpluginloader.cpp
@@ -0,0 +1,111 @@
+
+#include "ripperpluginloader.h"
+
+#include <qfile.h>
+
+#include <klocale.h>
+
+
+RipperPlugin::RipperPlugin()
+{}
+
+RipperPlugin::~RipperPlugin()
+{}
+
+
+RipperPluginLoader::RipperPluginLoader()
+{}
+
+RipperPluginLoader::~RipperPluginLoader()
+{}
+
+int RipperPluginLoader::verifyFile( QString fileName )
+{
+ QFile opmlFile( fileName );
+ if( !opmlFile.open( IO_ReadOnly ) ) {
+ return -1;
+ }
+ if( !domTree.setContent( &opmlFile ) ) {
+ return -1;
+ }
+ opmlFile.close();
+
+ QDomElement root = domTree.documentElement();
+ if( root.attribute("type") != "ripper" ) return -1;
+ int version;
+ QDomNode node;
+ node = root.firstChild();
+ while( !node.isNull() ) {
+ if( node.isElement() && node.nodeName() == "info" ) {
+ version = node.toElement().attribute("version","0").toInt();
+ break;
+ }
+ }
+
+ return version;
+}
+
+RipperPlugin* RipperPluginLoader::loadFile( QString fileName )
+{
+ int t_int;
+ float t_float;
+ QString t_str;
+
+ RipperPlugin* plugin = new RipperPlugin();
+ plugin->info.version = -1; // if something goes wrong, we can see that by looking at plugin->info.version
+ plugin->filePathName = fileName;
+
+ QFile opmlFile( fileName );
+ if( !opmlFile.open( IO_ReadOnly ) ) {
+ return plugin;
+ }
+ if( !domTree.setContent( &opmlFile ) ) {
+ return plugin;
+ }
+ opmlFile.close();
+
+ QDomElement root = domTree.documentElement();
+ if( root.attribute("type") != "ripper" ) return plugin;
+ QDomNode node, sub1Node;
+ node = root.firstChild();
+
+ while( !node.isNull() ) {
+ if( node.isElement() && node.nodeName() == "info" ) {
+
+ plugin->info.name = node.toElement().attribute("name",i18n("Unknown Name"));
+ plugin->info.about = node.toElement().attribute("about",i18n("Sorry, no information available!"));
+ plugin->info.author = node.toElement().attribute("author",i18n("Unknown Author"));
+ plugin->info.version = node.toElement().attribute("version","0").toInt();
+
+ }
+ else if( node.isElement() && node.nodeName() == "rip" ) {
+
+ plugin->rip.rank = node.toElement().attribute("rank","10").toInt();
+ plugin->rip.bin = node.toElement().attribute( "bin" );
+ plugin->rip.param = node.toElement().attribute("param");
+ plugin->rip.silent_param = node.toElement().attribute("silent_param");
+ plugin->rip.out_file = node.toElement().attribute("out_file");
+ plugin->rip.track = node.toElement().attribute("track");
+ plugin->rip.device = node.toElement().attribute("device");
+ plugin->rip.overwrite = node.toElement().attribute("overwrite");
+ plugin->rip.output = node.toElement().attribute("output");
+
+ sub1Node = node.toElement().firstChild();
+ while( !sub1Node.isNull() ) {
+ if( sub1Node.isElement() && sub1Node.nodeName() == "full_disc" ) {
+
+ if( sub1Node.toElement().attribute("enabled") == "true" ) plugin->rip.full_disc.enabled = true;
+ else plugin->rip.full_disc.enabled = false;
+ plugin->rip.full_disc.param = sub1Node.toElement().attribute("param");
+ plugin->rip.full_disc.output = sub1Node.toElement().attribute("output");
+
+ }
+ sub1Node = sub1Node.nextSibling();
+ }
+ }
+ node = node.nextSibling();
+ }
+
+ return plugin;
+}
+
diff --git a/src/pluginloader/ripperpluginloader.h b/src/pluginloader/ripperpluginloader.h
new file mode 100755
index 0000000..6cf965e
--- /dev/null
+++ b/src/pluginloader/ripperpluginloader.h
@@ -0,0 +1,84 @@
+
+
+#ifndef RIPPERPLUGINLOADER_H
+#define RIPPERPLUGINLOADER_H
+
+#include "pluginloaderbase.h"
+
+
+/**
+ * @short The complete data, how to use the backend
+ * @author Daniel Faust <hessijames@gmail.com>
+ * @version 0.3
+ */
+class RipperPlugin
+{
+public:
+ /**
+ * Constructor
+ */
+ RipperPlugin();
+
+ /**
+ * Destructor
+ */
+ virtual ~RipperPlugin();
+
+ QString filePathName; // the file name of th plugin (needed to detect write permissions)
+
+ struct Info
+ {
+ int version; // the version of our plugin (v0.2.1 = 201, v11.3 = 110300)
+ QString name; // the name of our plugin
+ QString author; // the author of the plugin
+ QString about; // a short information aboue the plugin
+ } info;
+
+ struct Rip
+ {
+ //PluginLoaderBase::FeatureLevel level;
+ int rank;
+ QString bin;
+ QString param;
+ QString silent_param;
+ QString out_file;
+ QString track;
+ QString device;
+ QString overwrite;
+ QString output;
+
+ struct FullDisc
+ {
+ bool enabled;
+ QString param;
+ QString output;
+ } full_disc;
+ } rip;
+};
+
+/**
+ * @short The plugin loader for the ripper plugins
+ * @author Daniel Faust <hessijames@gmail.com>
+ * @version 0.3
+ */
+class RipperPluginLoader : public PluginLoaderBase
+{
+ Q_OBJECT
+public:
+ /**
+ * Constructor
+ */
+ RipperPluginLoader();
+
+ /**
+ * Destructor
+ */
+ virtual ~RipperPluginLoader();
+
+ /** is this file a ripper plugin and loadable? */
+ int verifyFile( QString );
+ /** load a given file */
+ RipperPlugin* loadFile( QString );
+};
+
+#endif // RIPPERPLUGINLOADER_H