summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-04-27 23:50:08 +0000
committerDavid Robillard <d@drobilla.net>2012-04-27 23:50:08 +0000
commitb08a8a15fd136ab8323e282484a5a96d698dc808 (patch)
treef5e33ab732ddb6566d0a2f74279cda9142cfbd32
parentface634af32eeeddf43839f2ffc2ab81a17cd6ff (diff)
downloadingen-b08a8a15fd136ab8323e282484a5a96d698dc808.tar.gz
ingen-b08a8a15fd136ab8323e282484a5a96d698dc808.tar.bz2
ingen-b08a8a15fd136ab8323e282484a5a96d698dc808.zip
Disconnect via atom interface.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4287 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--ingen/shared/AtomWriter.hpp1
-rw-r--r--src/shared/AtomReader.cpp39
-rw-r--r--src/shared/AtomWriter.cpp29
3 files changed, 54 insertions, 15 deletions
diff --git a/ingen/shared/AtomWriter.hpp b/ingen/shared/AtomWriter.hpp
index 7b9c43fb..a59f11c8 100644
--- a/ingen/shared/AtomWriter.hpp
+++ b/ingen/shared/AtomWriter.hpp
@@ -78,6 +78,7 @@ public:
private:
void forge_uri(const Raul::URI& uri);
void forge_properties(const Resource::Properties& properties);
+ void forge_edge(const Raul::URI& tail, const Raul::URI& head);
void finish_msg();
int32_t next_id();
diff --git a/src/shared/AtomReader.cpp b/src/shared/AtomReader.cpp
index fa14243a..99a09b44 100644
--- a/src/shared/AtomReader.cpp
+++ b/src/shared/AtomReader.cpp
@@ -35,11 +35,13 @@ AtomReader::AtomReader(LV2URIMap& map, URIs& uris, Forge& forge, Interface& ifac
void
AtomReader::get_uri(const LV2_Atom* in, Raul::Atom& out)
{
- if (in->type == _uris.atom_URID) {
- const LV2_Atom_URID* urid = (const LV2_Atom_URID*)in;
- out = _forge.alloc_uri(_map.unmap_uri(urid->body));
- } else {
- out = _forge.alloc(in->size, in->type, LV2_ATOM_BODY(in));
+ if (in) {
+ if (in->type == _uris.atom_URID) {
+ const LV2_Atom_URID* urid = (const LV2_Atom_URID*)in;
+ out = _forge.alloc_uri(_map.unmap_uri(urid->body));
+ } else {
+ out = _forge.alloc(in->size, in->type, LV2_ATOM_BODY(in));
+ }
}
}
@@ -76,6 +78,33 @@ AtomReader::write(const LV2_Atom* msg)
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;
+ lv2_atom_object_get(body,
+ (LV2_URID)_uris.ingen_tail, &tail,
+ (LV2_URID)_uris.ingen_head, &head,
+ NULL);
+
+ Raul::Atom tail_atom;
+ Raul::Atom head_atom;
+ get_uri(tail, tail_atom);
+ get_uri(head, head_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 {
+ Raul::warn << "Delete of unknown object." << std::endl;
+ }
+ }
} else if (obj->body.otype == _uris.patch_Put) {
const LV2_Atom_Object* body = NULL;
lv2_atom_object_get(obj, (LV2_URID)_uris.patch_body, &body, 0);
diff --git a/src/shared/AtomWriter.cpp b/src/shared/AtomWriter.cpp
index 4e3853e8..d77364a5 100644
--- a/src/shared/AtomWriter.cpp
+++ b/src/shared/AtomWriter.cpp
@@ -105,6 +105,18 @@ AtomWriter::forge_properties(const Resource::Properties& properties)
}
void
+AtomWriter::forge_edge(const Raul::URI& tail, const Raul::URI& head)
+{
+ LV2_Atom_Forge_Frame edge;
+ lv2_atom_forge_blank(&_forge, &edge, 0, _uris.ingen_Edge);
+ lv2_atom_forge_property_head(&_forge, _uris.ingen_tail, 0);
+ forge_uri(tail);
+ lv2_atom_forge_property_head(&_forge, _uris.ingen_head, 0);
+ forge_uri(head);
+ lv2_atom_forge_pop(&_forge, &edge);
+}
+
+void
AtomWriter::put(const Raul::URI& uri,
const Resource::Properties& properties,
Resource::Graph ctx)
@@ -180,17 +192,8 @@ AtomWriter::connect(const Raul::Path& src,
lv2_atom_forge_property_head(&_forge, _uris.patch_subject, 0);
forge_uri(Raul::Path::lca(src, dst));
lv2_atom_forge_property_head(&_forge, _uris.patch_body, 0);
-
- LV2_Atom_Forge_Frame body;
- lv2_atom_forge_blank(&_forge, &body, 0, _uris.ingen_Edge);
- lv2_atom_forge_property_head(&_forge, _uris.ingen_tail, 0);
- forge_uri(src);
- lv2_atom_forge_property_head(&_forge, _uris.ingen_head, 0);
- forge_uri(dst);
- lv2_atom_forge_pop(&_forge, &body);
-
+ forge_edge(src, dst);
lv2_atom_forge_pop(&_forge, &msg);
-
finish_msg();
}
@@ -198,6 +201,12 @@ void
AtomWriter::disconnect(const Raul::URI& src,
const Raul::URI& dst)
{
+ LV2_Atom_Forge_Frame msg;
+ lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Delete);
+ lv2_atom_forge_property_head(&_forge, _uris.patch_body, 0);
+ forge_edge(src, dst);
+ lv2_atom_forge_pop(&_forge, &msg);
+ finish_msg();
}
void