blob: 743ca406335c73f2856b39a69f072492c48a85e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
#include "ripperpluginloader.h"
#include <tqfile.h>
#include <tdelocale.h>
RipperPlugin::RipperPlugin()
{}
RipperPlugin::~RipperPlugin()
{}
RipperPluginLoader::RipperPluginLoader()
{}
RipperPluginLoader::~RipperPluginLoader()
{}
int RipperPluginLoader::verifyFile( TQString fileName )
{
TQFile opmlFile( fileName );
if( !opmlFile.open( IO_ReadOnly ) ) {
return -1;
}
if( !domTree.setContent( &opmlFile ) ) {
return -1;
}
opmlFile.close();
TQDomElement root = domTree.documentElement();
if( root.attribute("type") != "ripper" ) return -1;
int version;
TQDomNode 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( TQString fileName )
{
int t_int;
float t_float;
TQString 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;
TQFile opmlFile( fileName );
if( !opmlFile.open( IO_ReadOnly ) ) {
return plugin;
}
if( !domTree.setContent( &opmlFile ) ) {
return plugin;
}
opmlFile.close();
TQDomElement root = domTree.documentElement();
if( root.attribute("type") != "ripper" ) return plugin;
TQDomNode 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;
}
|