diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/AtomReader.cpp | 30 | ||||
-rw-r--r-- | src/AtomWriter.cpp | 9 | ||||
-rw-r--r-- | src/URIs.cpp | 2 |
3 files changed, 24 insertions, 17 deletions
diff --git a/src/AtomReader.cpp b/src/AtomReader.cpp index 63f493a7..55e88427 100644 --- a/src/AtomReader.cpp +++ b/src/AtomReader.cpp @@ -199,22 +199,30 @@ AtomReader::write(const LV2_Atom* msg) _iface.put(Raul::URI(subject_uri), props); } } else if (obj->body.otype == _uris.patch_Set) { - const LV2_Atom_Object* body = NULL; - lv2_atom_object_get(obj, (LV2_URID)_uris.patch_body, &body, 0); - if (!body) { - _log.warn("Set message has no body\n"); - return false; - } else if (!subject_uri) { + if (!subject_uri) { _log.warn("Set message has no subject\n"); return false; } - LV2_ATOM_OBJECT_FOREACH(body, p) { - Raul::Atom val; - get_atom(&p->value, val); - _iface.set_property(Raul::URI(subject_uri), - Raul::URI(_map.unmap_uri(p->key)), val); + const LV2_Atom_URID* prop = NULL; + lv2_atom_object_get(obj, (LV2_URID)_uris.patch_property, &prop, 0); + if (!prop || ((LV2_Atom*)prop)->type != _uris.atom_URID) { + _log.warn("Set message missing property\n"); + return false; } + + const LV2_Atom* value = NULL; + lv2_atom_object_get(obj, (LV2_URID)_uris.patch_value, &value, 0); + if (!value) { + _log.warn("Set message missing value\n"); + return false; + } + + Raul::Atom atom; + get_atom(value, atom); + _iface.set_property(Raul::URI(subject_uri), + Raul::URI(_map.unmap_uri(prop->body)), + atom); } else if (obj->body.otype == _uris.patch_Patch) { if (!subject) { _log.warn("Patch message has no subject\n"); diff --git a/src/AtomWriter.cpp b/src/AtomWriter.cpp index 05e5d64d..2e24e8cc 100644 --- a/src/AtomWriter.cpp +++ b/src/AtomWriter.cpp @@ -242,14 +242,11 @@ AtomWriter::set_property(const Raul::URI& subject, lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Set); lv2_atom_forge_property_head(&_forge, _uris.patch_subject, 0); forge_uri(subject); - lv2_atom_forge_property_head(&_forge, _uris.patch_body, 0); - - LV2_Atom_Forge_Frame body; - lv2_atom_forge_blank(&_forge, &body, 0, 0); - lv2_atom_forge_property_head(&_forge, _map.map_uri(predicate.c_str()), 0); + lv2_atom_forge_property_head(&_forge, _uris.patch_property, 0); + lv2_atom_forge_urid(&_forge, _map.map_uri(predicate.c_str())); + lv2_atom_forge_property_head(&_forge, _uris.patch_value, 0); lv2_atom_forge_atom(&_forge, value.size(), value.type()); lv2_atom_forge_write(&_forge, value.get_body(), value.size()); - lv2_atom_forge_pop(&_forge, &body); lv2_atom_forge_pop(&_forge, &msg); finish_msg(); diff --git a/src/URIs.cpp b/src/URIs.cpp index a3ee8874..d2d3d9fa 100644 --- a/src/URIs.cpp +++ b/src/URIs.cpp @@ -129,9 +129,11 @@ URIs::URIs(Forge& f, URIMap* map) , patch_add (forge, map, LV2_PATCH__add) , patch_body (forge, map, LV2_PATCH__body) , patch_destination (forge, map, LV2_PATCH__destination) + , patch_property (forge, map, LV2_PATCH__property) , patch_remove (forge, map, LV2_PATCH__remove) , patch_request (forge, map, LV2_PATCH__request) , patch_subject (forge, map, LV2_PATCH__subject) + , patch_value (forge, map, LV2_PATCH__value) , pprops_logarithmic (forge, map, LV2_PORT_PROPS__logarithmic) , rdf_type (forge, map, NS_RDF "type") , rdfs_seeAlso (forge, map, NS_RDFS "seeAlso") |