summaryrefslogtreecommitdiffstats
path: root/src/pluginloader/ripperpluginloader.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-03-01 19:09:31 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-03-01 19:09:31 +0000
commitf2cfda2a54780868dfe0af7bd652fcd4906547da (patch)
treec6ac23545528f5701818424f2af5f79ce3665e6c /src/pluginloader/ripperpluginloader.cpp
downloadsoundkonverter-f2cfda2a54780868dfe0af7bd652fcd4906547da.tar.gz
soundkonverter-f2cfda2a54780868dfe0af7bd652fcd4906547da.zip
Added KDE3 version of SoundKonverter
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/soundkonverter@1097614 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/pluginloader/ripperpluginloader.cpp')
-rwxr-xr-xsrc/pluginloader/ripperpluginloader.cpp111
1 files changed, 111 insertions, 0 deletions
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;
+}
+