summaryrefslogtreecommitdiffstats
path: root/src/server/events
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/events')
-rw-r--r--src/server/events/CreateBlock.hpp4
-rw-r--r--src/server/events/CreateGraph.hpp2
-rw-r--r--src/server/events/Delta.cpp25
-rw-r--r--src/server/events/Delta.hpp1
-rw-r--r--src/server/events/Get.cpp112
-rw-r--r--src/server/events/Get.hpp45
6 files changed, 28 insertions, 161 deletions
diff --git a/src/server/events/CreateBlock.hpp b/src/server/events/CreateBlock.hpp
index 189a0896..40d72f52 100644
--- a/src/server/events/CreateBlock.hpp
+++ b/src/server/events/CreateBlock.hpp
@@ -19,8 +19,8 @@
#include "ingen/Resource.hpp"
+#include "ClientUpdate.hpp"
#include "Event.hpp"
-#include "events/Get.hpp"
namespace Ingen {
namespace Server {
@@ -54,7 +54,7 @@ public:
private:
Raul::Path _path;
Resource::Properties& _properties;
- Events::Get::Response _update;
+ ClientUpdate _update;
GraphImpl* _graph;
BlockImpl* _block;
CompiledGraph* _compiled_graph;
diff --git a/src/server/events/CreateGraph.hpp b/src/server/events/CreateGraph.hpp
index bcb857ae..cf40fb41 100644
--- a/src/server/events/CreateGraph.hpp
+++ b/src/server/events/CreateGraph.hpp
@@ -55,7 +55,7 @@ private:
const Raul::Path _path;
Resource::Properties _properties;
- Events::Get::Response _update;
+ ClientUpdate _update;
GraphImpl* _graph;
GraphImpl* _parent;
CompiledGraph* _compiled_graph;
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp
index 9b990c2d..66ebf803 100644
--- a/src/server/events/Delta.cpp
+++ b/src/server/events/Delta.cpp
@@ -160,7 +160,7 @@ get_file_node(LilvWorld* lworld, const URIs& uris, const Atom& value)
* a patch:Put ;
* patch:subject </> ;
* patch:body [
- * ingen:loadedBundle <file:///old.lv2>
+ * ingen:loadedBundle <file:///old.lv2/>
* ] .
*
* # Replace /old.lv2 with /new.lv2
@@ -168,10 +168,10 @@ get_file_node(LilvWorld* lworld, const URIs& uris, const Atom& value)
* a patch:Patch ;
* patch:subject </> ;
* patch:remove [
- * ingen:loadedBundle <file:///old.lv2>
+ * ingen:loadedBundle <file:///old.lv2/>
* ];
* patch:add [
- * ingen:loadedBundle <file:///new.lv2>
+ * ingen:loadedBundle <file:///new.lv2/>
* ] .
* @endcode
*/
@@ -277,7 +277,14 @@ Delta::pre_process()
LilvWorld* lworld = _engine.world()->lilv_world();
LilvNode* bundle = get_file_node(lworld, uris, value);
if (bundle) {
+ for (const auto& p : _engine.block_factory()->plugins()) {
+ if (p.second->bundle_uri() == lilv_node_as_string(bundle)) {
+ p.second->set_is_zombie(true);
+ _update.del(p.second->uri());
+ }
+ }
lilv_world_unload_bundle(lworld, bundle);
+ _engine.block_factory()->refresh();
lilv_node_free(bundle);
} else {
_status = Status::BAD_VALUE;
@@ -423,6 +430,14 @@ Delta::pre_process()
LilvNode* bundle = get_file_node(lworld, uris, value);
if (bundle) {
lilv_world_load_bundle(lworld, bundle);
+ const std::set<PluginImpl*> new_plugins =
+ _engine.block_factory()->refresh();
+
+ for (PluginImpl* p : new_plugins) {
+ if (p->bundle_uri() == lilv_node_as_string(bundle)) {
+ _update.put_plugin(p);
+ }
+ }
lilv_node_free(bundle);
} else {
_status = Status::BAD_VALUE;
@@ -568,6 +583,8 @@ Delta::post_process()
}
if (respond() == Status::SUCCESS) {
+ _update.send(_engine.broadcaster());
+
switch (_type) {
case Type::SET:
/* Kludge to avoid feedback for set events only. The GUI
@@ -583,7 +600,7 @@ Delta::post_process()
case Type::PUT:
if (_type == Type::PUT && _subject.substr(0, 5) == "file:") {
// Preset save
- Get::Response response;
+ ClientUpdate response;
response.put(_preset->uri(), _preset->properties());
response.send(_engine.broadcaster());
} else {
diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp
index 0782238c..569b3e92 100644
--- a/src/server/events/Delta.hpp
+++ b/src/server/events/Delta.hpp
@@ -98,6 +98,7 @@ private:
Raul::URI _subject;
Resource::Properties _properties;
Resource::Properties _remove;
+ ClientUpdate _update;
Ingen::Resource* _object;
GraphImpl* _graph;
CompiledGraph* _compiled_graph;
diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp
index 6d49657d..fa56f23a 100644
--- a/src/server/events/Get.cpp
+++ b/src/server/events/Get.cpp
@@ -34,118 +34,6 @@ namespace Ingen {
namespace Server {
namespace Events {
-void
-Get::Response::put(const Raul::URI& uri,
- const Resource::Properties& props,
- Resource::Graph ctx)
-{
- const Get::Response::Put put = { uri, props, ctx };
- puts.push_back(put);
-}
-
-void
-Get::Response::put_port(const PortImpl* port)
-{
- if (port->is_a(PortType::CONTROL) || port->is_a(PortType::CV)) {
- Resource::Properties props = port->properties();
- props.erase(port->bufs().uris().ingen_value);
- props.insert(std::make_pair(port->bufs().uris().ingen_value,
- port->value()));
- put(port->uri(), props);
- } else {
- put(port->uri(), port->properties());
- }
-}
-
-void
-Get::Response::put_block(const BlockImpl* block)
-{
- const PluginImpl* const plugin = block->plugin_impl();
- const URIs& uris = plugin->uris();
-
- if (uris.ingen_Graph == plugin->type()) {
- put_graph((const GraphImpl*)block);
- } else {
- put(block->uri(), block->properties());
- for (size_t j = 0; j < block->num_ports(); ++j) {
- put_port(block->port_impl(j));
- }
- }
-}
-
-void
-Get::Response::put_graph(const GraphImpl* graph)
-{
- put(graph->uri(),
- graph->properties(Resource::Graph::INTERNAL),
- Resource::Graph::INTERNAL);
-
- put(graph->uri(),
- graph->properties(Resource::Graph::EXTERNAL),
- Resource::Graph::EXTERNAL);
-
- // Enqueue blocks
- for (const auto& b : graph->blocks()) {
- put_block(&b);
- }
-
- // Enqueue ports
- for (uint32_t i = 0; i < graph->num_ports_non_rt(); ++i) {
- put_port(graph->port_impl(i));
- }
-
- // Enqueue arcs
- for (const auto& a : graph->arcs()) {
- const SPtr<const Arc> arc = a.second;
- const Connect connect = { arc->tail_path(), arc->head_path() };
- connects.push_back(connect);
- }
-}
-
-void
-Get::Response::put_plugin(PluginImpl* plugin)
-{
- put(plugin->uri(), plugin->properties());
-
- for (const auto& p : plugin->presets()) {
- put_preset(plugin->uris(), plugin->uri(), p.first, p.second);
- }
-}
-
-void
-Get::Response::put_preset(const URIs& uris,
- const Raul::URI& plugin,
- const Raul::URI& preset,
- const std::string& label)
-{
- Resource::Properties props{
- { uris.rdf_type, uris.pset_Preset.urid },
- { uris.rdfs_label, uris.forge.alloc(label) },
- { uris.lv2_appliesTo, uris.forge.make_urid(plugin) }};
- put(preset, props);
-}
-
-/** Returns true if a is closer to the root than b. */
-static inline bool
-put_higher_than(const Get::Response::Put& a, const Get::Response::Put& b)
-{
- return (std::count(a.uri.begin(), a.uri.end(), '/') <
- std::count(b.uri.begin(), b.uri.end(), '/'));
-}
-
-void
-Get::Response::send(Interface* dest)
-{
- // Sort puts by increasing depth so parents are sent first
- std::stable_sort(puts.begin(), puts.end(), put_higher_than);
- for (const Response::Put& put : puts) {
- dest->put(put.uri, put.properties, put.ctx);
- }
- for (const Response::Connect& connect : connects) {
- dest->connect(connect.tail, connect.head);
- }
-}
-
Get::Get(Engine& engine,
SPtr<Interface> client,
int32_t id,
diff --git a/src/server/events/Get.hpp b/src/server/events/Get.hpp
index f24e42e0..fc5fcb13 100644
--- a/src/server/events/Get.hpp
+++ b/src/server/events/Get.hpp
@@ -19,8 +19,9 @@
#include <vector>
-#include "Event.hpp"
#include "BlockFactory.hpp"
+#include "ClientUpdate.hpp"
+#include "Event.hpp"
#include "types.hpp"
namespace Ingen {
@@ -50,52 +51,12 @@ public:
void execute(ProcessContext& context) {}
void post_process();
- /** A sequence of puts and connects to respond to client with.
- * This is constructed in the pre_process() and later sent in
- * post_process() to avoid the need to lock.
- *
- * Ideally events (both server and client) would always be in a standard
- * message format so the Ingen protocol went the whole way through the
- * system, but for now things are controlled procedurally through
- * Interface, so this interim structure is necessary.
- */
- struct Response {
- void put(const Raul::URI& uri,
- const Resource::Properties& props,
- Resource::Graph ctx=Resource::Graph::DEFAULT);
-
- void put_port(const PortImpl* port);
- void put_block(const BlockImpl* block);
- void put_graph(const GraphImpl* graph);
- void put_plugin(PluginImpl* plugin);
- void put_preset(const URIs& uris,
- const Raul::URI& plugin,
- const Raul::URI& preset,
- const std::string& label);
-
- void send(Interface* dest);
-
- struct Put {
- Raul::URI uri;
- Resource::Properties properties;
- Resource::Graph ctx;
- };
-
- struct Connect {
- Raul::Path tail;
- Raul::Path head;
- };
-
- std::vector<Put> puts;
- std::vector<Connect> connects;
- };
-
private:
const Raul::URI _uri;
const Node* _object;
PluginImpl* _plugin;
BlockFactory::Plugins _plugins;
- Response _response;
+ ClientUpdate _response;
};
} // namespace Events