summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/AtomReader.cpp93
-rw-r--r--src/shared/AtomWriter.cpp15
-rw-r--r--src/shared/ResourceImpl.cpp2
-rw-r--r--src/shared/URIs.cpp2
4 files changed, 83 insertions, 29 deletions
diff --git a/src/shared/AtomReader.cpp b/src/shared/AtomReader.cpp
index dc2aa15c..c6ff7e18 100644
--- a/src/shared/AtomReader.cpp
+++ b/src/shared/AtomReader.cpp
@@ -62,53 +62,68 @@ AtomReader::get_props(const LV2_Atom_Object* obj,
}
}
-void
+const char*
+AtomReader::atom_to_uri(const LV2_Atom* atom)
+{
+ if (atom && atom->type == _uris.atom_URI) {
+ return (const char*)LV2_ATOM_BODY(atom);
+ } else if (atom && atom->type == _uris.atom_URID) {
+ return _map.unmap_uri(((LV2_Atom_URID*)atom)->body);
+ } else {
+ return NULL;
+ }
+}
+
+bool
AtomReader::write(const LV2_Atom* msg)
{
- if (msg->type != _uris.atom_Blank) {
- Raul::warn << "Unknown message type " << msg->type << std::endl;
- return;
+ if (msg->type != _uris.atom_Blank && msg->type != _uris.atom_Resource) {
+ Raul::warn << (Raul::fmt("Unknown message type <%1%>\n")
+ % _map.unmap_uri(msg->type)).str();
+ return false;
}
const LV2_Atom_Object* obj = (const LV2_Atom_Object*)msg;
const LV2_Atom* subject = NULL;
lv2_atom_object_get(obj, (LV2_URID)_uris.patch_subject, &subject, NULL);
- const char* subject_uri = NULL;
- if (subject && subject->type == _uris.atom_URI) {
- subject_uri = (const char*)LV2_ATOM_BODY(subject);
- } else if (subject && subject->type == _uris.atom_URID) {
- subject_uri = _map.unmap_uri(((LV2_Atom_URID*)subject)->body);
- }
+ const char* subject_uri = atom_to_uri(subject);
if (obj->body.otype == _uris.patch_Get) {
_iface.set_response_id(obj->body.id);
_iface.get(subject_uri);
} else if (obj->body.otype == _uris.patch_Delete) {
- if (subject_uri) {
- _iface.del(subject_uri);
- return;
- }
-
const LV2_Atom_Object* body = NULL;
lv2_atom_object_get(obj, (LV2_URID)_uris.patch_body, &body, 0);
- if (body && body->body.otype == _uris.ingen_Edge) {
- const LV2_Atom* tail = NULL;
- const LV2_Atom* head = NULL;
+
+ if (subject_uri && !body) {
+ _iface.del(subject_uri);
+ return true;
+ } else if (body && body->body.otype == _uris.ingen_Edge) {
+ const LV2_Atom* tail = NULL;
+ const LV2_Atom* head = NULL;
+ const LV2_Atom* incidentTo = NULL;
lv2_atom_object_get(body,
(LV2_URID)_uris.ingen_tail, &tail,
(LV2_URID)_uris.ingen_head, &head,
+ (LV2_URID)_uris.ingen_incidentTo, &incidentTo,
NULL);
Raul::Atom tail_atom;
Raul::Atom head_atom;
+ Raul::Atom incidentTo_atom;
get_atom(tail, tail_atom);
get_atom(head, head_atom);
+ get_atom(incidentTo, incidentTo_atom);
if (tail_atom.is_valid() && head_atom.is_valid()) {
_iface.disconnect(Raul::Path(tail_atom.get_uri()),
Raul::Path(head_atom.get_uri()));
+ } else if (incidentTo_atom.is_valid()) {
+ _iface.disconnect_all(subject_uri,
+ Raul::Path(incidentTo_atom.get_uri()));
} else {
Raul::warn << "Delete of unknown object." << std::endl;
+ return false;
}
}
} else if (obj->body.otype == _uris.patch_Put) {
@@ -116,10 +131,10 @@ AtomReader::write(const LV2_Atom* msg)
lv2_atom_object_get(obj, (LV2_URID)_uris.patch_body, &body, 0);
if (!body) {
Raul::warn << "Put message has no body" << std::endl;
- return;
+ return false;
} else if (!subject_uri) {
Raul::warn << "Put message has no subject" << std::endl;
- return;
+ return false;
}
if (body->body.otype == _uris.ingen_Edge) {
@@ -131,7 +146,7 @@ AtomReader::write(const LV2_Atom* msg)
NULL);
if (!tail || !head) {
Raul::warn << "Edge has no tail or head" << std::endl;
- return;
+ return false;
}
Raul::Atom tail_atom;
@@ -151,10 +166,10 @@ AtomReader::write(const LV2_Atom* msg)
lv2_atom_object_get(obj, (LV2_URID)_uris.patch_body, &body, 0);
if (!body) {
Raul::warn << "Set message has no body" << std::endl;
- return;
+ return false;
} else if (!subject_uri) {
Raul::warn << "Set message has no subject" << std::endl;
- return;
+ return false;
}
LV2_ATOM_OBJECT_FOREACH(body, p) {
@@ -165,21 +180,21 @@ AtomReader::write(const LV2_Atom* msg)
} else if (obj->body.otype == _uris.patch_Patch) {
if (!subject_uri) {
Raul::warn << "Put message has no subject" << std::endl;
- return;
+ return false;
}
const LV2_Atom_Object* remove = NULL;
lv2_atom_object_get(obj, (LV2_URID)_uris.patch_remove, &remove, 0);
if (!remove) {
Raul::warn << "Patch message has no remove" << std::endl;
- return;
+ return false;
}
const LV2_Atom_Object* add = NULL;
lv2_atom_object_get(obj, (LV2_URID)_uris.patch_add, &add, 0);
if (!add) {
Raul::warn << "Patch message has no add" << std::endl;
- return;
+ return false;
}
Ingen::Resource::Properties add_props;
@@ -189,6 +204,26 @@ AtomReader::write(const LV2_Atom* msg)
get_props(remove, remove_props);
_iface.delta(subject_uri, remove_props, add_props);
+ } else if (obj->body.otype == _uris.patch_Move) {
+ if (!subject_uri) {
+ Raul::warn << "Move message has no subject" << std::endl;
+ return false;
+ }
+
+ const LV2_Atom* dest = NULL;
+ lv2_atom_object_get(obj, (LV2_URID)_uris.patch_destination, &dest, 0);
+ if (!dest) {
+ Raul::warn << "Move message has no destination" << std::endl;
+ return false;
+ }
+
+ const char* dest_uri = atom_to_uri(dest);
+ if (!dest_uri) {
+ Raul::warn << "Move message destination is not a URI" << std::endl;
+ return false;
+ }
+
+ _iface.move(subject_uri, dest_uri);
} else if (obj->body.otype == _uris.patch_Response) {
const LV2_Atom* request = NULL;
const LV2_Atom* body = NULL;
@@ -198,10 +233,10 @@ AtomReader::write(const LV2_Atom* msg)
0);
if (!request || request->type != _uris.atom_Int) {
Raul::warn << "Response message has no request" << std::endl;
- return;
+ return false;
} else if (!body || body->type != _uris.atom_Int) {
Raul::warn << "Response message body is not integer" << std::endl;
- return;
+ return false;
}
_iface.response(((LV2_Atom_Int*)request)->body,
(Ingen::Status)((LV2_Atom_Int*)body)->body);
@@ -210,6 +245,8 @@ AtomReader::write(const LV2_Atom* msg)
<< _map.unmap_uri(obj->body.otype)
<< ">" << std::endl;
}
+
+ return true;
}
} // namespace Shared
diff --git a/src/shared/AtomWriter.cpp b/src/shared/AtomWriter.cpp
index a1ce8fb1..7d600466 100644
--- a/src/shared/AtomWriter.cpp
+++ b/src/shared/AtomWriter.cpp
@@ -216,6 +216,21 @@ void
AtomWriter::disconnect_all(const Raul::Path& parent_patch_path,
const Raul::Path& path)
{
+ LV2_Atom_Forge_Frame msg;
+ lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Delete);
+
+ lv2_atom_forge_property_head(&_forge, _uris.patch_subject, 0);
+ forge_uri(parent_patch_path);
+
+ lv2_atom_forge_property_head(&_forge, _uris.patch_body, 0);
+ LV2_Atom_Forge_Frame edge;
+ lv2_atom_forge_blank(&_forge, &edge, 0, _uris.ingen_Edge);
+ lv2_atom_forge_property_head(&_forge, _uris.ingen_incidentTo, 0);
+ forge_uri(path);
+ lv2_atom_forge_pop(&_forge, &edge);
+
+ lv2_atom_forge_pop(&_forge, &msg);
+ finish_msg();
}
void
diff --git a/src/shared/ResourceImpl.cpp b/src/shared/ResourceImpl.cpp
index bb60da5c..13284cf4 100644
--- a/src/shared/ResourceImpl.cpp
+++ b/src/shared/ResourceImpl.cpp
@@ -122,7 +122,7 @@ ResourceImpl::type(const URIs& uris,
patch = node = port = is_output = false;
for (iterator i = types_range.first; i != types_range.second; ++i) {
const Raul::Atom& atom = i->second;
- if (atom.type() != uris.forge.URI) {
+ if (atom.type() != uris.forge.URI && atom.type() != uris.forge.URID) {
Raul::warn << "[ResourceImpl] Non-URI type " << uris.forge.str(atom) << endl;
continue;
}
diff --git a/src/shared/URIs.cpp b/src/shared/URIs.cpp
index 1bc64c27..2c44c826 100644
--- a/src/shared/URIs.cpp
+++ b/src/shared/URIs.cpp
@@ -54,6 +54,7 @@ URIs::URIs(Shared::Forge& f, URIMap* map)
, atom_Bool (forge, map, LV2_ATOM__Bool)
, atom_Float (forge, map, LV2_ATOM__Float)
, atom_Int (forge, map, LV2_ATOM__Int)
+ , atom_Resource (forge, map, LV2_ATOM__Resource)
, atom_Sequence (forge, map, LV2_ATOM__Sequence)
, atom_Sound (forge, map, LV2_ATOM__Sound)
, atom_String (forge, map, LV2_ATOM__String)
@@ -77,6 +78,7 @@ URIs::URIs(Shared::Forge& f, URIMap* map)
, ingen_enabled (forge, map, NS_INGEN "enabled")
, ingen_engine (forge, map, NS_INGEN "engine")
, ingen_head (forge, map, NS_INGEN "head")
+ , ingen_incidentTo (forge, map, NS_INGEN "incidentTo")
, ingen_nil (forge, map, NS_INGEN "nil")
, ingen_node (forge, map, NS_INGEN "node")
, ingen_polyphonic (forge, map, NS_INGEN "polyphonic")