From f2cfda2a54780868dfe0af7bd652fcd4906547da Mon Sep 17 00:00:00 2001 From: tpearson Date: Mon, 1 Mar 2010 19:09:31 +0000 Subject: Added KDE3 version of SoundKonverter git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/soundkonverter@1097614 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/pluginloader/replaygainpluginloader.cpp | 116 ++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100755 src/pluginloader/replaygainpluginloader.cpp (limited to 'src/pluginloader/replaygainpluginloader.cpp') 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 + +#include + + +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; +} + -- cgit v1.2.1