summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugin.c56
-rw-r--r--src/plugininstance.c5
-rw-r--r--src/slv2_internal.h6
-rw-r--r--src/world.c26
4 files changed, 68 insertions, 25 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 6e09161..80f59a5 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -33,12 +33,13 @@
/* private */
SLV2Plugin
-slv2_plugin_new(SLV2World world, librdf_uri* uri, const char* binary_uri)
+slv2_plugin_new(SLV2World world, librdf_uri* uri, librdf_uri* bundle_uri, librdf_uri* binary_uri)
{
struct _SLV2Plugin* plugin = malloc(sizeof(struct _SLV2Plugin));
plugin->world = world;
plugin->plugin_uri = librdf_new_uri_from_uri(uri);
- plugin->binary_uri = strdup(binary_uri);
+ plugin->bundle_uri = librdf_new_uri_from_uri(bundle_uri);
+ plugin->binary_uri = librdf_new_uri_from_uri(binary_uri);
plugin->plugin_class = NULL;
plugin->data_uris = slv2_values_new();
plugin->ports = raptor_new_sequence((void (*)(void*))&slv2_port_free, NULL);
@@ -56,8 +57,11 @@ slv2_plugin_free(SLV2Plugin p)
librdf_free_uri(p->plugin_uri);
p->plugin_uri = NULL;
- //free(p->bundle_url);
- free(p->binary_uri);
+ librdf_free_uri(p->bundle_uri);
+ p->bundle_uri = NULL;
+
+ librdf_free_uri(p->binary_uri);
+ p->binary_uri = NULL;
raptor_free_sequence(p->ports);
p->ports = NULL;
@@ -73,6 +77,7 @@ slv2_plugin_free(SLV2Plugin p)
}
slv2_values_free(p->data_uris);
+ p->data_uris = NULL;
free(p);
}
@@ -238,17 +243,24 @@ slv2_plugin_get_uri(SLV2Plugin p)
}
-SLV2Values
-slv2_plugin_get_data_uris(SLV2Plugin p)
+const char*
+slv2_plugin_get_bundle_uri(SLV2Plugin p)
{
- return p->data_uris;
+ return (const char*)librdf_uri_as_string(p->bundle_uri);
}
const char*
slv2_plugin_get_library_uri(SLV2Plugin p)
{
- return p->binary_uri;
+ return (const char*)librdf_uri_as_string(p->binary_uri);
+}
+
+
+SLV2Values
+slv2_plugin_get_data_uris(SLV2Plugin p)
+{
+ return p->data_uris;
}
@@ -387,22 +399,25 @@ slv2_plugin_get_value_for_subject(SLV2Plugin p,
/* Hack around broken RASQAL, full URI predicates don't work :/ */
+ char* subject_token = slv2_value_get_turtle_token(subject);
+
if (predicate_type == SLV2_URI) {
query = slv2_strjoin(
"PREFIX slv2predicate: <", predicate, ">",
"SELECT DISTINCT ?value WHERE { \n",
- slv2_value_get_turtle_token(subject), " slv2predicate: ?value \n"
+ subject_token, " slv2predicate: ?value \n"
"}\n", NULL);
} else {
query = slv2_strjoin(
"SELECT DISTINCT ?value WHERE { \n",
- slv2_value_get_turtle_token(subject), " ", predicate, " ?value \n"
+ subject_token, " ", predicate, " ?value \n"
"}\n", NULL);
}
SLV2Values result = slv2_plugin_simple_query(p, query, 0);
free(query);
+ free(subject_token);
return result;
}
@@ -442,9 +457,11 @@ slv2_plugin_has_latency(SLV2Plugin p)
" lv2:index ?index .\n"
"}\n";
- SLV2Values result = slv2_plugin_simple_query(p, query, 0);
+ SLV2Values results = slv2_plugin_simple_query(p, query, 0);
+ const bool latent = (slv2_values_size(results) > 0);
+ slv2_values_free(results);
- return (slv2_values_size(result) > 0);
+ return latent;
}
@@ -599,3 +616,18 @@ slv2_gui_type_get_uri(SLV2GUIType type)
return "http://ll-plugins.nongnu.org/lv2/ext/gtk2gui";
}
+
+void*
+slv2_plugin_load_gui(SLV2Plugin plugin,
+ SLV2Value gui)
+{
+ SLV2Value lib_uri = slv2_plugin_get_gui_library_uri(plugin, gui);
+
+ if (!lib_uri)
+ return NULL;
+
+ //LV2UI_Handle handle =
+ //
+ return NULL;
+}
+
diff --git a/src/plugininstance.c b/src/plugininstance.c
index d989ef6..90af196 100644
--- a/src/plugininstance.c
+++ b/src/plugininstance.c
@@ -67,10 +67,7 @@ slv2_plugin_instantiate(SLV2Plugin plugin,
// Search for plugin by URI
// FIXME: Kluge to get bundle path (containing directory of binary)
- char* bundle_path = strdup(plugin->binary_uri);
- char* const bundle_path_end = strrchr(bundle_path, '/');
- if (bundle_path_end)
- *(bundle_path_end+1) = '\0';
+ char* bundle_path = slv2_uri_to_path(strdup(slv2_plugin_get_bundle_uri(plugin)));
printf("Bundle path: %s\n", bundle_path);
for (uint32_t i=0; 1; ++i) {
diff --git a/src/slv2_internal.h b/src/slv2_internal.h
index 89325ca..ca1e002 100644
--- a/src/slv2_internal.h
+++ b/src/slv2_internal.h
@@ -59,8 +59,8 @@ void slv2_port_free(SLV2Port port);
struct _SLV2Plugin {
struct _SLV2World* world;
librdf_uri* plugin_uri;
-// char* bundle_url; ///< Bundle directory plugin was loaded from
- char* binary_uri; ///< lv2:binary
+ librdf_uri* bundle_uri; ///< Bundle directory plugin was loaded from
+ librdf_uri* binary_uri; ///< lv2:binary
SLV2PluginClass plugin_class;
raptor_sequence* data_uris; ///< rdfs::seeAlso
raptor_sequence* ports;
@@ -68,7 +68,7 @@ struct _SLV2Plugin {
librdf_model* rdf;
};
-SLV2Plugin slv2_plugin_new(SLV2World world, librdf_uri* uri, const char* binary_uri);
+SLV2Plugin slv2_plugin_new(SLV2World world, librdf_uri* uri, librdf_uri* bundle_uri, librdf_uri* binary_uri);
void slv2_plugin_load(SLV2Plugin p);
void slv2_plugin_free(SLV2Plugin plugin);
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);