summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--slv2/slv2.h10
-rw-r--r--src/plugin.c8
-rw-r--r--src/slv2_internal.h2
-rw-r--r--src/world.c36
5 files changed, 56 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d831d48..385cd46 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,7 @@ slv2 (UNRELEASED) unstable; urgency=low
* Document entire API in single header file / page.
* Add new collections and iterator API (and deprecate index based API)
* Remove the questionable slv2_world_get_plugins_by_filter.
+ * Add slv2_plugin_is_replaced to allow hosts to hide old plugins.
* Switch to 2-clause BSD license.
* *** API BREAK ***
diff --git a/slv2/slv2.h b/slv2/slv2.h
index 49e31f5..b55cc16 100644
--- a/slv2/slv2.h
+++ b/slv2/slv2.h
@@ -922,6 +922,16 @@ SLV2Value
slv2_plugin_get_author_homepage(SLV2Plugin plugin);
/**
+ Return true iff @a plugin has been replaced by another plugin.
+
+ The plugin will still be usable, but hosts should hide them from their
+ user interfaces to prevent users from using deprecated plugins.
+*/
+SLV2_API
+bool
+slv2_plugin_is_replaced(SLV2Plugin plugin);
+
+/**
@}
@name Port
@{
diff --git a/src/plugin.c b/src/plugin.c
index e86b16a..ce5299e 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -63,6 +63,7 @@ slv2_plugin_new(SLV2World world, SLV2Value uri, SLV2Value bundle_uri)
plugin->ports = NULL;
plugin->num_ports = 0;
plugin->loaded = false;
+ plugin->replaced = false;
return plugin;
}
@@ -775,6 +776,13 @@ slv2_plugin_get_author_homepage(SLV2Plugin plugin)
}
SLV2_API
+bool
+slv2_plugin_is_replaced(SLV2Plugin plugin)
+{
+ return plugin->replaced;
+}
+
+SLV2_API
SLV2UIs
slv2_plugin_get_uis(SLV2Plugin p)
{
diff --git a/src/slv2_internal.h b/src/slv2_internal.h
index b1f223f..c6b8a41 100644
--- a/src/slv2_internal.h
+++ b/src/slv2_internal.h
@@ -123,6 +123,7 @@ struct _SLV2Plugin {
SLV2Port* ports;
uint32_t num_ports;
bool loaded;
+ bool replaced;
};
SLV2Plugin slv2_plugin_new(SLV2World world, SLV2Value uri, SLV2Value bundle_uri);
@@ -231,6 +232,7 @@ struct _SLV2World {
SLV2PluginClass lv2_plugin_class;
SLV2PluginClasses plugin_classes;
SLV2Plugins plugins;
+ SLV2Node dc_replaces_node;
SLV2Node dyn_manifest_node;
SLV2Node lv2_specification_node;
SLV2Node lv2_plugin_node;
diff --git a/src/world.c b/src/world.c
index 97539c0..f014d1a 100644
--- a/src/world.c
+++ b/src/world.c
@@ -65,11 +65,13 @@ slv2_world_new()
world->plugins = slv2_plugins_new();
#define NS_DYNMAN (const uint8_t*)"http://lv2plug.in/ns/ext/dynmanifest#"
+#define NS_DC (const uint8_t*)"http://dublincore.org/documents/dcmi-namespace/"
#define NEW_URI(uri) sord_new_uri(world->world, uri)
#define NEW_URI_VAL(uri) slv2_value_new_from_node( \
world, sord_new_uri(world->world, uri));
+ world->dc_replaces_node = NEW_URI(NS_DC "replaces");
world->dyn_manifest_node = NEW_URI(NS_DYNMAN "DynManifest");
world->lv2_specification_node = NEW_URI(SLV2_NS_LV2 "Specification");
world->lv2_plugin_node = NEW_URI(SLV2_NS_LV2 "Plugin");
@@ -127,6 +129,7 @@ slv2_world_free(SLV2World world)
slv2_plugin_class_free(world->lv2_plugin_class);
world->lv2_plugin_class = NULL;
+ slv2_node_free(world, world->dc_replaces_node);
slv2_node_free(world, world->dyn_manifest_node);
slv2_node_free(world, world->lv2_specification_node);
slv2_node_free(world, world->lv2_plugin_node);
@@ -430,7 +433,7 @@ slv2_world_load_bundle(SLV2World world, SLV2Value bundle_uri)
}
slv2_match_end(dmanifests);
#endif // SLV2_DYN_MANIFEST
-
+
// ?specification a lv2:Specification
SLV2Matches spec_results = slv2_world_find_statements(
world, world->model,
@@ -660,6 +663,37 @@ slv2_world_load_all(SLV2World world)
// Discover bundles and read all manifest files into model
slv2_world_load_path(world, lv2_path);
+ SLV2_FOREACH(p, world->plugins) {
+ SLV2Plugin plugin = slv2_collection_get(world->plugins, p);
+ SLV2Value plugin_uri = slv2_plugin_get_uri(plugin);
+
+ // ?new dc:replaces plugin
+ SLV2Matches replacements = slv2_world_find_statements(
+ world, world->model,
+ NULL,
+ world->dc_replaces_node,
+ slv2_value_as_node(plugin_uri),
+ NULL);
+ FOREACH_MATCH(replacements) {
+ SLV2Node subject = slv2_match_subject(replacements);
+ SLV2Node object = slv2_match_object(replacements);
+ if (sord_node_get_type(subject) != SORD_URI
+ || sord_node_get_type(object) != SORD_URI) {
+ continue;
+ }
+
+ SLV2Value subject_val = slv2_value_new_from_node(world, subject);
+ SLV2Value object_val = slv2_value_new_from_node(world, object);
+
+ fprintf(stderr, "%s REPLACES %s\n",
+ slv2_value_as_uri(subject_val),
+ slv2_value_as_uri(object_val));
+
+ plugin->replaced = true;
+ }
+ slv2_match_end(replacements);
+ }
+
// Query out things to cache
slv2_world_load_specifications(world);
slv2_world_load_plugin_classes(world);