summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-04-03 17:10:58 +0000
committerDavid Robillard <d@drobilla.net>2015-04-03 17:10:58 +0000
commite1ea99192e10149e0cac7a93f98fbec20e7cedb2 (patch)
tree97d8d9e63b6d2085c2b49e71fc2183c8058b4533 /src
parentac888fe3cb4a7bdf0f43e9474160e3b525edf774 (diff)
downloadingen-e1ea99192e10149e0cac7a93f98fbec20e7cedb2.tar.gz
ingen-e1ea99192e10149e0cac7a93f98fbec20e7cedb2.tar.bz2
ingen-e1ea99192e10149e0cac7a93f98fbec20e7cedb2.zip
Use lv2:prototype and deprecate ingen:prototype.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5652 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/Parser.cpp32
-rw-r--r--src/Serialiser.cpp2
-rw-r--r--src/client/ClientStore.cpp12
-rw-r--r--src/gui/GraphCanvas.cpp4
-rw-r--r--src/gui/LoadPluginWindow.cpp2
-rw-r--r--src/server/events/CreateBlock.cpp18
-rw-r--r--src/server/events/CreateGraph.cpp8
7 files changed, 51 insertions, 27 deletions
diff --git a/src/Parser.cpp b/src/Parser.cpp
index 30de26ba..7df71aa3 100644
--- a/src/Parser.cpp
+++ b/src/Parser.cpp
@@ -276,31 +276,37 @@ parse_block(Ingen::World* world,
{
const URIs& uris = world->uris();
- const Sord::URI ingen_prototype(*world->rdf_world(), uris.ingen_prototype);
- const Sord::Node nil;
-
- Sord::Iter i = model.find(subject, ingen_prototype, nil);
- if (i.end() || i.get_object().type() != Sord::Node::URI) {
- if (!i.end()) {
- std::cerr << "type: " << i.get_object().type() << std::endl;
+ // Try lv2:prototype and old ingen:prototype for backwards compatibility
+ const Sord::URI prototype_predicates[] = {
+ Sord::URI(*world->rdf_world(), uris.lv2_prototype),
+ Sord::URI(*world->rdf_world(), uris.ingen_prototype)
+ };
+
+ std::string type_uri;
+ for (const Sord::URI& prototype : prototype_predicates) {
+ Sord::Iter i = model.find(subject, prototype, Sord::Node());
+ if (!i.end() && i.get_object().type() == Sord::Node::URI) {
+ type_uri = relative_uri(base_uri,
+ i.get_object().to_string(),
+ false);
+ break;
}
+ }
+
+ if (type_uri.empty()) {
world->log().error(
- fmt("Block %1% (%2%) missing mandatory ingen:prototype\n") %
+ fmt("Block %1% (%2%) missing mandatory lv2:prototype\n") %
subject.to_string() % path);
return boost::optional<Raul::Path>();
}
- const std::string type_uri = relative_uri(base_uri,
- i.get_object().to_string(),
- false);
-
if (!serd_uri_string_has_scheme((const uint8_t*)type_uri.c_str())) {
SerdURI base_uri_parts;
serd_uri_parse((const uint8_t*)base_uri.c_str(), &base_uri_parts);
SerdURI ignored;
SerdNode sub_uri = serd_node_new_uri_from_string(
- i.get_object().to_u_string(),
+ (const uint8_t*)type_uri.c_str(),
&base_uri_parts,
&ignored);
diff --git a/src/Serialiser.cpp b/src/Serialiser.cpp
index 2114cc00..91fd5e75 100644
--- a/src/Serialiser.cpp
+++ b/src/Serialiser.cpp
@@ -409,7 +409,7 @@ Serialiser::Impl::serialise_block(SPtr<const Node> block,
Sord::URI(_model->world(), uris.rdf_type),
Sord::URI(_model->world(), uris.ingen_Block));
_model->add_statement(block_id,
- Sord::URI(_model->world(), uris.ingen_prototype),
+ Sord::URI(_model->world(), uris.lv2_prototype),
class_id);
const Node::Properties props = block->properties(Resource::Graph::EXTERNAL);
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp
index a61d511a..a260cb07 100644
--- a/src/client/ClientStore.cpp
+++ b/src/client/ClientStore.cpp
@@ -280,7 +280,11 @@ ClientStore::put(const Raul::URI& uri,
model->set_properties(properties);
add_object(model);
} else if (is_block) {
- const Iterator p = properties.find(_uris.ingen_prototype);
+ Iterator p = properties.find(_uris.lv2_prototype);
+ if (p == properties.end()) {
+ p = properties.find(_uris.ingen_prototype);
+ }
+
SPtr<PluginModel> plug;
if (p->second.is_valid() && p->second.type() == _uris.forge.URI) {
if (!(plug = _plugin(Raul::URI(p->second.ptr<char>())))) {
@@ -297,8 +301,7 @@ ClientStore::put(const Raul::URI& uri,
bm->set_properties(properties);
add_object(bm);
} else {
- _log.warn(fmt("Block %1% has no prototype\n")
- % path.c_str());
+ _log.warn(fmt("Block %1% has no prototype\n") % path.c_str());
}
} else if (is_port) {
PortModel::Direction pdir = (is_output)
@@ -314,8 +317,7 @@ ClientStore::put(const Raul::URI& uri,
p->set_properties(properties);
add_object(p);
} else {
- _log.warn(fmt("Ignoring object %1% with unknown type\n")
- % path.c_str());
+ _log.warn(fmt("Ignoring %1% of unknown type\n") % path.c_str());
}
}
diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp
index c3b8b937..f07f1d5b 100644
--- a/src/gui/GraphCanvas.cpp
+++ b/src/gui/GraphCanvas.cpp
@@ -683,7 +683,7 @@ GraphCanvas::paste()
const Raul::URI& old_uri = Node::path_to_uri(old_path);
const Raul::Path& new_path = avoider.map_path(parent.child(node->path()));
- Node::Properties props{{uris.ingen_prototype,
+ Node::Properties props{{uris.lv2_prototype,
_app.forge().alloc_uri(old_uri)}};
// Set the same types
@@ -789,7 +789,7 @@ GraphCanvas::load_plugin(WPtr<PluginModel> weak_plugin)
Node::Properties props = get_initial_data();
props.insert(make_pair(uris.rdf_type,
Resource::Property(uris.ingen_Block)));
- props.insert(make_pair(uris.ingen_prototype,
+ props.insert(make_pair(uris.lv2_prototype,
uris.forge.alloc_uri(plugin->uri())));
_app.interface()->put(Node::path_to_uri(path), props);
}
diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp
index fd8a8868..9d644641 100644
--- a/src/gui/LoadPluginWindow.cpp
+++ b/src/gui/LoadPluginWindow.cpp
@@ -400,7 +400,7 @@ LoadPluginWindow::load_plugin(const Gtk::TreeModel::iterator& iter)
Resource::Properties props = _initial_data;
props.insert(make_pair(uris.rdf_type,
Resource::Property(uris.ingen_Block)));
- props.insert(make_pair(uris.ingen_prototype,
+ props.insert(make_pair(uris.lv2_prototype,
_app->forge().alloc_uri(plugin->uri())));
props.insert(make_pair(uris.ingen_polyphonic,
_app->forge().make(polyphonic)));
diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp
index e14a3356..3ea009a4 100644
--- a/src/server/events/CreateBlock.cpp
+++ b/src/server/events/CreateBlock.cpp
@@ -69,9 +69,20 @@ CreateBlock::pre_process()
return Event::pre_process_done(Status::PARENT_NOT_FOUND, _path.parent());
}
- // Get prototype URI
- const iterator t = _properties.find(uris.ingen_prototype);
+ // Map old ingen:prototype to new lv2:prototype
+ auto range = _properties.equal_range(uris.ingen_prototype);
+ for (auto i = range.first; i != range.second;) {
+ const auto& value = i->second;
+ auto next = i;
+ next = _properties.erase(i);
+ _properties.insert(std::make_pair(uris.lv2_prototype, i->second));
+ i = next;
+ }
+
+ // Get prototype
+ iterator t = _properties.find(uris.lv2_prototype);
if (t == _properties.end() || t->second.type() != uris.forge.URI) {
+ // Missing/invalid prototype
return Event::pre_process_done(Status::BAD_REQUEST);
}
@@ -98,7 +109,8 @@ CreateBlock::pre_process()
/* Replace prototype with the ancestor's. This is less informative,
but the client expects an actual LV2 plugin as prototype. */
_properties.erase(uris.ingen_prototype);
- _properties.insert(std::make_pair(uris.ingen_prototype,
+ _properties.erase(uris.lv2_prototype);
+ _properties.insert(std::make_pair(uris.lv2_prototype,
uris.forge.alloc_uri(ancestor->plugin()->uri())));
} else {
// Prototype is a plugin
diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp
index 06445a6b..b9661a13 100644
--- a/src/server/events/CreateGraph.cpp
+++ b/src/server/events/CreateGraph.cpp
@@ -76,8 +76,12 @@ CreateGraph::pre_process()
const Raul::Symbol symbol((_path.is_root()) ? "root" : _path.symbol());
- // Create graph based on prototype
- const iterator t = _properties.find(uris.ingen_prototype);
+ // Get graph prototype
+ iterator t = _properties.find(uris.lv2_prototype);
+ if (t == _properties.end()) {
+ t = _properties.find(uris.lv2_prototype);
+ }
+
if (t != _properties.end() &&
Raul::URI::is_valid(t->second.ptr<char>()) &&
Node::uri_is_path(Raul::URI(t->second.ptr<char>()))) {