summaryrefslogtreecommitdiffstats
path: root/src/world.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-07-01 19:44:19 +0000
committerDavid Robillard <d@drobilla.net>2007-07-01 19:44:19 +0000
commite67a923c73c26dfd335cfb325511c831996952ab (patch)
tree9f33af93a0ec3d8e20ad475495f4e5811bfcc660 /src/world.c
parent34eff8deba278aebe01b50fec879ab5d3d2335dc (diff)
downloadlilv-e67a923c73c26dfd335cfb325511c831996952ab.tar.gz
lilv-e67a923c73c26dfd335cfb325511c831996952ab.tar.bz2
lilv-e67a923c73c26dfd335cfb325511c831996952ab.zip
Fix a couple memory leaks/errors.
Add proper bundle path finding (support plugins with binaries not immediately under their bundle paths, though none exist). Add slv2_plugin_get_bundle_uri. Add stub for loading plugin GUIs. git-svn-id: http://svn.drobilla.net/lad/slv2@553 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/world.c')
-rw-r--r--src/world.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/world.c b/src/world.c
index 57bea81..dc2be1a 100644
--- a/src/world.c
+++ b/src/world.c
@@ -143,6 +143,7 @@ slv2_world_load_bundle(SLV2World world, const char* bundle_uri_str)
librdf_parser_parse_into_model(world->parser, manifest_uri, NULL,
manifest_model);
+ /* Query statement: ?plugin a lv2:Plugin */
librdf_statement* q = librdf_new_statement_from_nodes(world->world,
NULL, world->rdf_a_node, world->lv2_plugin_node);
@@ -151,8 +152,9 @@ slv2_world_load_bundle(SLV2World world, const char* bundle_uri_str)
while (!librdf_stream_end(results)) {
librdf_statement* s = librdf_stream_get_object(results);
- librdf_node* plugin_node = librdf_statement_get_subject(s);
+ librdf_node* plugin_node = librdf_new_node_from_node(librdf_statement_get_subject(s));
+ /* Add ?plugin rdfs:seeAlso "datafile.ttl" */
librdf_node* subject = plugin_node;
librdf_node* predicate = librdf_new_node_from_uri_string(world->world,
(unsigned char*)"http://www.w3.org/2000/01/rdf-schema#seeAlso");
@@ -160,6 +162,14 @@ slv2_world_load_bundle(SLV2World world, const char* bundle_uri_str)
manifest_uri);
librdf_model_add(world->model, subject, predicate, object);
+
+ /* Add ?plugin slv2:bundleURI "file://some/path" */
+ subject = librdf_new_node_from_node(plugin_node);
+ predicate = librdf_new_node_from_uri_string(world->world,
+ (unsigned char*)"http://drobilla.net/ns/slv2#bundleURI");
+ object = librdf_new_node_from_uri(world->world, bundle_uri);
+
+ librdf_model_add(world->model, subject, predicate, object);
librdf_stream_next(results);
}
@@ -172,6 +182,7 @@ slv2_world_load_bundle(SLV2World world, const char* bundle_uri_str)
librdf_free_stream(manifest_stream);
librdf_free_model(manifest_model);
+ free(q);
librdf_free_storage(manifest_storage);
librdf_free_uri(manifest_uri);
librdf_free_uri(bundle_uri);
@@ -345,8 +356,9 @@ slv2_world_load_all(SLV2World world)
unsigned char* query_string = (unsigned char*)
"PREFIX : <http://lv2plug.in/ontology#>\n"
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
- "SELECT DISTINCT ?plugin ?data ?binary\n"
- "WHERE { ?plugin a :Plugin; rdfs:seeAlso ?data\n"
+ "PREFIX slv2: <http://drobilla.net/ns/slv2#>\n"
+ "SELECT DISTINCT ?plugin ?data ?bundle ?binary\n"
+ "WHERE { ?plugin a :Plugin; slv2:bundleURI ?bundle; rdfs:seeAlso ?data\n"
"OPTIONAL { ?plugin :binary ?binary } }\n"
"ORDER BY ?plugin\n";
@@ -361,7 +373,9 @@ slv2_world_load_all(SLV2World world)
librdf_uri* plugin_uri = librdf_node_get_uri(plugin_node);
librdf_node* data_node = librdf_query_results_get_binding_value(results, 1);
librdf_uri* data_uri = librdf_node_get_uri(data_node);
- librdf_node* binary_node = librdf_query_results_get_binding_value(results, 2);
+ librdf_node* bundle_node = librdf_query_results_get_binding_value(results, 2);
+ librdf_uri* bundle_uri = librdf_node_get_uri(bundle_node);
+ librdf_node* binary_node = librdf_query_results_get_binding_value(results, 3);
librdf_uri* binary_uri = librdf_node_get_uri(binary_node);
SLV2Plugin plugin = slv2_plugins_get_by_uri(world->plugins,
@@ -369,8 +383,7 @@ slv2_world_load_all(SLV2World world)
// Create a new SLV2Plugin
if (!plugin) {
- plugin = slv2_plugin_new(world, plugin_uri,
- (const char*)librdf_uri_as_string(binary_uri));
+ plugin = slv2_plugin_new(world, plugin_uri, bundle_uri, binary_uri);
raptor_sequence_push(world->plugins, plugin);
}
@@ -382,6 +395,7 @@ slv2_world_load_all(SLV2World world)
librdf_free_node(plugin_node);
librdf_free_node(data_node);
+ librdf_free_node(bundle_node);
librdf_free_node(binary_node);
librdf_query_results_next(results);