summaryrefslogtreecommitdiffstats
path: root/src/server/events
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/events')
-rw-r--r--src/server/events/Connect.cpp42
-rw-r--r--src/server/events/Connect.hpp10
-rw-r--r--src/server/events/CreateNode.cpp27
-rw-r--r--src/server/events/CreatePatch.cpp31
-rw-r--r--src/server/events/CreatePatch.hpp2
-rw-r--r--src/server/events/CreatePort.cpp27
-rw-r--r--src/server/events/CreatePort.hpp7
-rw-r--r--src/server/events/Deactivate.hpp2
-rw-r--r--src/server/events/Delete.cpp12
-rw-r--r--src/server/events/Disconnect.cpp44
-rw-r--r--src/server/events/Disconnect.hpp10
-rw-r--r--src/server/events/DisconnectAll.cpp31
-rw-r--r--src/server/events/DisconnectAll.hpp7
-rw-r--r--src/server/events/Get.cpp8
-rw-r--r--src/server/events/Move.cpp23
-rw-r--r--src/server/events/Move.hpp8
-rw-r--r--src/server/events/Ping.hpp2
-rw-r--r--src/server/events/RegisterClient.cpp2
-rw-r--r--src/server/events/SetMetadata.cpp53
-rw-r--r--src/server/events/SetMetadata.hpp8
-rw-r--r--src/server/events/SetPortValue.cpp43
-rw-r--r--src/server/events/SetPortValue.hpp9
-rw-r--r--src/server/events/UnregisterClient.cpp9
23 files changed, 100 insertions, 317 deletions
diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp
index 7a4dae0a..0cdd78dd 100644
--- a/src/server/events/Connect.cpp
+++ b/src/server/events/Connect.cpp
@@ -67,7 +67,7 @@ Connect::pre_process()
PortImpl* src_port = _engine.engine_store()->find_port(_src_port_path);
PortImpl* dst_port = _engine.engine_store()->find_port(_dst_port_path);
if (!src_port || !dst_port) {
- _error = PORT_NOT_FOUND;
+ _status = PORT_NOT_FOUND;
Event::pre_process();
return;
}
@@ -75,7 +75,7 @@ Connect::pre_process()
_dst_input_port = dynamic_cast<InputPort*>(dst_port);
_src_output_port = dynamic_cast<OutputPort*>(src_port);
if (!_dst_input_port || !_src_output_port) {
- _error = DIRECTION_MISMATCH;
+ _status = DIRECTION_MISMATCH;
Event::pre_process();
return;
}
@@ -83,7 +83,7 @@ Connect::pre_process()
NodeImpl* const src_node = src_port->parent_node();
NodeImpl* const dst_node = dst_port->parent_node();
if (!src_node || !dst_node) {
- _error = PARENTS_NOT_FOUND;
+ _status = PARENT_NOT_FOUND;
Event::pre_process();
return;
}
@@ -91,13 +91,13 @@ Connect::pre_process()
if (src_node->parent() != dst_node->parent()
&& src_node != dst_node->parent()
&& src_node->parent() != dst_node) {
- _error = PARENT_PATCH_DIFFERENT;
+ _status = PARENT_DIFFERS;
Event::pre_process();
return;
}
if (!ConnectionImpl::can_connect(_src_output_port, _dst_input_port)) {
- _error = TYPE_MISMATCH;
+ _status = TYPE_MISMATCH;
Event::pre_process();
return;
}
@@ -120,7 +120,7 @@ Connect::pre_process()
}
if (_patch->has_connection(_src_output_port, _dst_input_port)) {
- _error = ALREADY_CONNECTED;
+ _status = EXISTS;
Event::pre_process();
return;
}
@@ -161,7 +161,7 @@ Connect::execute(ProcessContext& context)
{
Event::execute(context);
- if (_error == NO_ERROR) {
+ if (_status == SUCCESS) {
// This must be inserted here, since they're actually used by the audio thread
_dst_input_port->add_connection(_connection.get());
assert(_buffers);
@@ -175,34 +175,10 @@ Connect::execute(ProcessContext& context)
void
Connect::post_process()
{
- std::ostringstream ss;
- if (_error == NO_ERROR) {
- respond_ok();
+ respond(_status);
+ if (!_status) {
_engine.broadcaster()->connect(_src_port_path, _dst_port_path);
- return;
- }
-
- ss << boost::format("Unable to make connection %1% -> %2% (")
- % _src_port_path.chop_scheme() % _dst_port_path.chop_scheme();
-
- switch (_error) {
- case PARENT_PATCH_DIFFERENT:
- ss << "Ports have mismatched parents"; break;
- case PORT_NOT_FOUND:
- ss << "Port not found"; break;
- case TYPE_MISMATCH:
- ss << "Type mismatch"; break;
- case DIRECTION_MISMATCH:
- ss << "Direction mismatch"; break;
- case ALREADY_CONNECTED:
- ss << "Already connected"; break;
- case PARENTS_NOT_FOUND:
- ss << "Parents not found"; break;
- default:
- ss << "Unknown error";
}
- ss << ")";
- respond_error(ss.str());
}
} // namespace Events
diff --git a/src/server/events/Connect.hpp b/src/server/events/Connect.hpp
index 92f8bcf4..c1218865 100644
--- a/src/server/events/Connect.hpp
+++ b/src/server/events/Connect.hpp
@@ -61,16 +61,6 @@ public:
void post_process();
private:
- enum ErrorType {
- NO_ERROR,
- PARENT_PATCH_DIFFERENT,
- PORT_NOT_FOUND,
- TYPE_MISMATCH,
- DIRECTION_MISMATCH,
- ALREADY_CONNECTED,
- PARENTS_NOT_FOUND
- };
-
Raul::Path _src_port_path;
Raul::Path _dst_port_path;
diff --git a/src/server/events/CreateNode.cpp b/src/server/events/CreateNode.cpp
index 04fef8b1..5fe7a86f 100644
--- a/src/server/events/CreateNode.cpp
+++ b/src/server/events/CreateNode.cpp
@@ -96,8 +96,9 @@ CreateNode::pre_process()
}
}
- if (!_node)
- _error = 1;
+ if (!_node) {
+ _status = FAILURE;
+ }
Event::pre_process();
}
@@ -116,22 +117,16 @@ CreateNode::execute(ProcessContext& context)
void
CreateNode::post_process()
{
- string msg;
if (_node_already_exists) {
- msg = string("Could not create node - ").append(_path.str());// + " already exists.";
- respond_error(msg);
- } else if (_patch == NULL) {
- msg = "Could not find patch '" + _path.parent().str() +"' to add node.";
- respond_error(msg);
- } else if (_plugin == NULL) {
- msg = "Unable to load node ";
- msg += _path.str() + " (you're missing the plugin " + _plugin_uri.str() + ")";
- respond_error(msg);
- } else if (_node == NULL) {
- msg = "Failed to instantiate plugin " + _plugin_uri.str();
- respond_error(msg);
+ respond(EXISTS);
+ } else if (!_patch) {
+ respond(PARENT_NOT_FOUND);
+ } else if (!_plugin) {
+ respond(PLUGIN_NOT_FOUND);
+ } else if (!_node) {
+ respond(FAILURE);
} else {
- respond_ok();
+ respond(SUCCESS);
_engine.broadcaster()->send_object(_node, true); // yes, send ports
}
}
diff --git a/src/server/events/CreatePatch.cpp b/src/server/events/CreatePatch.cpp
index eda05ccd..6e261755 100644
--- a/src/server/events/CreatePatch.cpp
+++ b/src/server/events/CreatePatch.cpp
@@ -55,13 +55,13 @@ void
CreatePatch::pre_process()
{
if (_path.is_root() || _engine.engine_store()->find_object(_path) != NULL) {
- _error = OBJECT_EXISTS;
+ _status = EXISTS;
Event::pre_process();
return;
}
if (_poly < 1) {
- _error = INVALID_POLY;
+ _status = INVALID_POLY;
Event::pre_process();
return;
}
@@ -70,7 +70,7 @@ CreatePatch::pre_process()
_parent = _engine.engine_store()->find_patch(path.parent());
if (_parent == NULL) {
- _error = PARENT_NOT_FOUND;
+ _status = PARENT_NOT_FOUND;
Event::pre_process();
return;
}
@@ -126,32 +126,11 @@ CreatePatch::execute(ProcessContext& context)
void
CreatePatch::post_process()
{
- string msg;
- switch (_error) {
- case NO_ERROR:
- respond_ok();
+ respond(_status);
+ if (!_status) {
// Don't send ports/nodes that have been added since prepare()
// (otherwise they would be sent twice)
_engine.broadcaster()->send_object(_patch, false);
- break;
- case OBJECT_EXISTS:
- respond_ok();
- /*string msg = "Unable to create patch: ";
- msg.append(_path).append(" already exists.");
- respond_error(msg);*/
- break;
- case PARENT_NOT_FOUND:
- msg = "Unable to create patch: Parent ";
- msg.append(Path(_path).parent().str()).append(" not found.");
- respond_error(msg);
- break;
- case INVALID_POLY:
- msg = "Unable to create patch ";
- msg.append(_path.str()).append(": ").append("Invalid polyphony requested.");
- respond_error(msg);
- break;
- default:
- respond_error("Unable to load patch.");
}
}
diff --git a/src/server/events/CreatePatch.hpp b/src/server/events/CreatePatch.hpp
index 4addd524..66a81c20 100644
--- a/src/server/events/CreatePatch.hpp
+++ b/src/server/events/CreatePatch.hpp
@@ -49,8 +49,6 @@ public:
void post_process();
private:
- enum ErrorType { NO_ERROR, OBJECT_EXISTS, PARENT_NOT_FOUND, INVALID_POLY };
-
const Raul::Path _path;
PatchImpl* _patch;
PatchImpl* _parent;
diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp
index 9c519981..5080fb79 100644
--- a/src/server/events/CreatePort.cpp
+++ b/src/server/events/CreatePort.cpp
@@ -84,14 +84,14 @@ CreatePort::CreatePort(Engine& engine,
}
if (_data_type == PortType::UNKNOWN) {
- _error = UNKNOWN_TYPE;
+ _status = UNKNOWN_TYPE;
}
}
void
CreatePort::pre_process()
{
- if (_error == UNKNOWN_TYPE || _engine.engine_store()->find_object(_path)) {
+ if (_status == UNKNOWN_TYPE || _engine.engine_store()->find_object(_path)) {
Event::pre_process();
return;
}
@@ -115,7 +115,7 @@ CreatePort::pre_process()
} else if (index_i->second.type() != Atom::INT
|| index_i->second.get_int32() != static_cast<int32_t>(old_num_ports)) {
Event::pre_process();
- _error = BAD_INDEX;
+ _status = BAD_INDEX;
return;
}
@@ -151,7 +151,7 @@ CreatePort::pre_process()
assert(_ports_array->size() == _patch->num_ports());
} else {
- _error = CREATION_FAILED;
+ _status = CREATION_FAILED;
}
}
Event::pre_process();
@@ -175,24 +175,9 @@ CreatePort::execute(ProcessContext& context)
void
CreatePort::post_process()
{
- string msg;
- switch (_error) {
- case NO_ERROR:
- respond_ok();
+ respond(_status);
+ if (!_status) {
_engine.broadcaster()->send_object(_patch_port, true);
- break;
- case BAD_INDEX:
- msg = string("Could not create port ") + _path.str() + " (Illegal index given)";
- respond_error(msg);
- break;
- case UNKNOWN_TYPE:
- msg = string("Could not create port ") + _path.str() + " (Unknown type)";
- respond_error(msg);
- break;
- case CREATION_FAILED:
- msg = string("Could not create port ") + _path.str() + " (Creation failed)";
- respond_error(msg);
- break;
}
}
diff --git a/src/server/events/CreatePort.hpp b/src/server/events/CreatePort.hpp
index 4113611f..fec23f0d 100644
--- a/src/server/events/CreatePort.hpp
+++ b/src/server/events/CreatePort.hpp
@@ -55,13 +55,6 @@ public:
void post_process();
private:
- enum ErrorType {
- NO_ERROR,
- UNKNOWN_TYPE,
- BAD_INDEX,
- CREATION_FAILED
- };
-
Raul::Path _path;
Raul::URI _type;
PortType _data_type;
diff --git a/src/server/events/Deactivate.hpp b/src/server/events/Deactivate.hpp
index b99a2568..33264795 100644
--- a/src/server/events/Deactivate.hpp
+++ b/src/server/events/Deactivate.hpp
@@ -40,7 +40,7 @@ public:
{}
void post_process() {
- respond_ok();
+ respond(SUCCESS);
_engine.deactivate();
}
};
diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp
index 53d77379..7138a40d 100644
--- a/src/server/events/Delete.cpp
+++ b/src/server/events/Delete.cpp
@@ -173,15 +173,13 @@ Delete::post_process()
if (!Raul::Path::is_path(_uri)
|| _path.is_root() || _path == "path:/control_in" || _path == "path:/control_out") {
- // XXX: Just ignore?
- //respond_error(_path.chop_scheme() + " can not be deleted");
+ // XXX: Report error? Silently ignore?
} else if (!_node && !_port) {
- string msg = string("Could not find object ") + _path.chop_scheme() + " to delete";
- respond_error(msg);
+ respond(NOT_FOUND);
} else if (_patch_node_listnode) {
assert(_node);
_node->deactivate();
- respond_ok();
+ respond(SUCCESS);
_engine.broadcaster()->bundle_begin();
if (_disconnect_event)
_disconnect_event->post_process();
@@ -190,7 +188,7 @@ Delete::post_process()
_engine.maid()->push(_patch_node_listnode);
} else if (_patch_port_listnode) {
assert(_port);
- respond_ok();
+ respond(SUCCESS);
_engine.broadcaster()->bundle_begin();
if (_disconnect_event)
_disconnect_event->post_process();
@@ -198,7 +196,7 @@ Delete::post_process()
_engine.broadcaster()->bundle_end();
_engine.maid()->push(_patch_port_listnode);
} else {
- respond_error("Unable to delete object " + _path.chop_scheme());
+ respond(FAILURE);
}
if (_driver_port)
diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp
index 01313208..81528d7c 100644
--- a/src/server/events/Disconnect.cpp
+++ b/src/server/events/Disconnect.cpp
@@ -119,7 +119,7 @@ Disconnect::pre_process()
if (_src_port_path.parent().parent() != _dst_port_path.parent().parent()
&& _src_port_path.parent() != _dst_port_path.parent().parent()
&& _src_port_path.parent().parent() != _dst_port_path.parent()) {
- _error = PARENT_PATCH_DIFFERENT;
+ _status = PARENT_DIFFERS;
Event::pre_process();
return;
}
@@ -128,7 +128,7 @@ Disconnect::pre_process()
_dst_port = _engine.engine_store()->find_port(_dst_port_path);
if (_src_port == NULL || _dst_port == NULL) {
- _error = PORT_NOT_FOUND;
+ _status = PORT_NOT_FOUND;
Event::pre_process();
return;
}
@@ -157,13 +157,13 @@ Disconnect::pre_process()
assert(_patch);
if (!_patch->has_connection(_src_port, _dst_port)) {
- _error = NOT_CONNECTED;
+ _status = NOT_FOUND;
Event::pre_process();
return;
}
if (src_node == NULL || dst_node == NULL) {
- _error = PARENTS_NOT_FOUND;
+ _status = PARENT_NOT_FOUND;
Event::pre_process();
return;
}
@@ -213,9 +213,9 @@ Disconnect::execute(ProcessContext& context)
{
Event::execute(context);
- if (_error == NO_ERROR) {
+ if (_status == SUCCESS) {
if (!_impl->execute(context, true)) {
- _error = CONNECTION_NOT_FOUND;
+ _status = NOT_FOUND;
return;
}
@@ -227,37 +227,9 @@ Disconnect::execute(ProcessContext& context)
void
Disconnect::post_process()
{
- if (_error == NO_ERROR) {
- respond_ok();
+ respond(_status);
+ if (!_status) {
_engine.broadcaster()->disconnect(_src_port->path(), _dst_port->path());
- } else {
- string msg("Unable to disconnect ");
- msg.append(_src_port_path.str() + " => " + _dst_port_path.str());
- msg.append(" (");
- switch (_error) {
- case PARENT_PATCH_DIFFERENT:
- msg.append("Ports exist in different patches");
- break;
- case PORT_NOT_FOUND:
- msg.append("Port not found");
- break;
- case TYPE_MISMATCH:
- msg.append("Ports have incompatible types");
- break;
- case NOT_CONNECTED:
- msg.append("Ports are not connected");
- break;
- case PARENTS_NOT_FOUND:
- msg.append("Parent node not found");
- break;
- case CONNECTION_NOT_FOUND:
- msg.append("Connection not found");
- break;
- default:
- break;
- }
- msg.append(")");
- respond_error(msg);
}
delete _impl;
diff --git a/src/server/events/Disconnect.hpp b/src/server/events/Disconnect.hpp
index 7b26e90c..726f5a98 100644
--- a/src/server/events/Disconnect.hpp
+++ b/src/server/events/Disconnect.hpp
@@ -78,16 +78,6 @@ public:
};
private:
- enum ErrorType {
- NO_ERROR,
- PARENT_PATCH_DIFFERENT,
- PORT_NOT_FOUND,
- TYPE_MISMATCH,
- NOT_CONNECTED,
- PARENTS_NOT_FOUND,
- CONNECTION_NOT_FOUND
- };
-
const Raul::Path _src_port_path;
const Raul::Path _dst_port_path;
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp
index 7bd9ee96..1538c93b 100644
--- a/src/server/events/DisconnectAll.cpp
+++ b/src/server/events/DisconnectAll.cpp
@@ -94,22 +94,21 @@ DisconnectAll::pre_process()
_parent = _engine.engine_store()->find_patch(_parent_path);
if (_parent == NULL) {
- _error = PARENT_NOT_FOUND;
+ _status = PARENT_NOT_FOUND;
Event::pre_process();
return;
}
GraphObjectImpl* object = _engine.engine_store()->find_object(_path);
-
- if (object == NULL) {
- _error = OBJECT_NOT_FOUND;
+ if (!object) {
+ _status = NOT_FOUND;
Event::pre_process();
return;
}
if (object->parent_patch() != _parent
&& object->parent()->parent_patch() != _parent) {
- _error = INVALID_PARENT_PATH;
+ _status = INVALID_PARENT_PATH;
Event::pre_process();
return;
}
@@ -159,7 +158,7 @@ DisconnectAll::execute(ProcessContext& context)
{
Event::execute(context);
- if (_error == NO_ERROR) {
+ if (_status == SUCCESS) {
for (Impls::iterator i = _impls.begin(); i != _impls.end(); ++i) {
(*i)->execute(context,
!_deleting || ((*i)->dst_port()->parent_node() != _node));
@@ -173,25 +172,9 @@ DisconnectAll::execute(ProcessContext& context)
void
DisconnectAll::post_process()
{
- if (_error == NO_ERROR) {
- respond_ok();
+ respond(_status);
+ if (!_status) {
_engine.broadcaster()->disconnect_all(_parent_path, _path);
- } else {
- boost::format fmt("Unable to disconnect %1% (%2%)");
- fmt % _path;
- switch (_error) {
- case INVALID_PARENT_PATH:
- fmt % string("Invalid parent path: ").append(_parent_path.str());
- break;
- case PARENT_NOT_FOUND:
- fmt % string("Unable to find parent: ").append(_parent_path.str());
- break;
- case OBJECT_NOT_FOUND:
- fmt % string("Unable to find object");
- default:
- break;
- }
- respond_error(fmt.str());
}
}
diff --git a/src/server/events/DisconnectAll.hpp b/src/server/events/DisconnectAll.hpp
index d3f84e96..e3cd2490 100644
--- a/src/server/events/DisconnectAll.hpp
+++ b/src/server/events/DisconnectAll.hpp
@@ -62,13 +62,6 @@ public:
void post_process();
private:
- enum ErrorType {
- NO_ERROR,
- INVALID_PARENT_PATH,
- PARENT_NOT_FOUND,
- OBJECT_NOT_FOUND,
- };
-
Raul::Path _parent_path;
Raul::Path _path;
PatchImpl* _parent;
diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp
index c13054dc..08ac3e10 100644
--- a/src/server/events/Get.cpp
+++ b/src/server/events/Get.cpp
@@ -63,14 +63,14 @@ void
Get::post_process()
{
if (_uri == "ingen:plugins") {
- respond_ok();
+ respond(SUCCESS);
if (_request_client) {
_engine.broadcaster()->send_plugins_to(_request_client, _plugins);
}
} else if (!_object && !_plugin) {
- respond_error("Unable to find object requested.");
+ respond(NOT_FOUND);
} else if (_request_client) {
- respond_ok();
+ respond(SUCCESS);
if (_request_client) {
if (_object) {
ObjectSender::send_object(_request_client, _object, true);
@@ -79,7 +79,7 @@ Get::post_process()
}
}
} else {
- respond_error("Unable to find client to send object.");
+ respond(CLIENT_NOT_FOUND);
}
_lock.release();
diff --git a/src/server/events/Move.cpp b/src/server/events/Move.cpp
index 3991e636..878f21f0 100644
--- a/src/server/events/Move.cpp
+++ b/src/server/events/Move.cpp
@@ -58,19 +58,19 @@ Move::pre_process()
Glib::RWLock::WriterLock lock(_engine.engine_store()->lock());
if (!_old_path.parent().is_parent_of(_new_path)) {
- _error = PARENT_DIFFERS;
+ _status = PARENT_DIFFERS;
Event::pre_process();
return;
}
_store_iterator = _engine.engine_store()->find(_old_path);
if (_store_iterator == _engine.engine_store()->end()) {
- _error = OBJECT_NOT_FOUND;
+ _status = NOT_FOUND;
Event::pre_process();
return;
}
if (_engine.engine_store()->find_object(_new_path)) {
- _error = OBJECT_EXISTS;
+ _status = EXISTS;
Event::pre_process();
return;
}
@@ -115,22 +115,9 @@ Move::execute(ProcessContext& context)
void
Move::post_process()
{
- string msg = "Unable to rename object - ";
-
- if (_error == NO_ERROR) {
- respond_ok();
+ respond(_status);
+ if (!_status) {
_engine.broadcaster()->move(_old_path, _new_path);
- } else {
- if (_error == OBJECT_EXISTS)
- msg.append("Object already exists at ").append(_new_path.str());
- else if (_error == OBJECT_NOT_FOUND)
- msg.append("Could not find object ").append(_old_path.str());
- else if (_error == OBJECT_NOT_RENAMABLE)
- msg.append(_old_path.str()).append(" is not renamable");
- else if (_error == PARENT_DIFFERS)
- msg.append(_new_path.str()).append(" is a child of a different patch");
-
- respond_error(msg);
}
}
diff --git a/src/server/events/Move.hpp b/src/server/events/Move.hpp
index e8e99b25..4a167656 100644
--- a/src/server/events/Move.hpp
+++ b/src/server/events/Move.hpp
@@ -59,14 +59,6 @@ public:
void post_process();
private:
- enum ErrorType {
- NO_ERROR,
- OBJECT_NOT_FOUND,
- OBJECT_EXISTS,
- OBJECT_NOT_RENAMABLE,
- PARENT_DIFFERS
- };
-
Raul::Path _old_path;
Raul::Path _new_path;
PatchImpl* _parent_patch;
diff --git a/src/server/events/Ping.hpp b/src/server/events/Ping.hpp
index 5017fd12..4a2a13dc 100644
--- a/src/server/events/Ping.hpp
+++ b/src/server/events/Ping.hpp
@@ -43,7 +43,7 @@ public:
: Event(engine, client, id, timestamp)
{}
- void post_process() { respond_ok(); }
+ void post_process() { respond(SUCCESS); }
};
} // namespace Server
diff --git a/src/server/events/RegisterClient.cpp b/src/server/events/RegisterClient.cpp
index a2c0b8be..c18afb72 100644
--- a/src/server/events/RegisterClient.cpp
+++ b/src/server/events/RegisterClient.cpp
@@ -48,7 +48,7 @@ RegisterClient::pre_process()
void
RegisterClient::post_process()
{
- respond_ok();
+ respond(SUCCESS);
/* Tell the client the engine's sample rate (which it needs to know to
interpret control bounds for lv2:sampleRate ports). This is a bit of a
diff --git a/src/server/events/SetMetadata.cpp b/src/server/events/SetMetadata.cpp
index 720cf3ba..68bd24d5 100644
--- a/src/server/events/SetMetadata.cpp
+++ b/src/server/events/SetMetadata.cpp
@@ -112,7 +112,7 @@ SetMetadata::pre_process()
: static_cast<Shared::ResourceImpl*>(_engine.node_factory()->plugin(_subject));
if (!_object && (!is_graph_object || !_create)) {
- _error = NOT_FOUND;
+ _status = NOT_FOUND;
Event::pre_process();
return;
}
@@ -144,7 +144,7 @@ SetMetadata::pre_process()
// Grab the object for applying properties, if the create-event succeeded
_object = _engine.engine_store()->find_object(Path(_subject.str()));
} else {
- _error = BAD_OBJECT_TYPE;
+ _status = BAD_OBJECT_TYPE;
}
}
@@ -187,7 +187,7 @@ SetMetadata::pre_process()
if (value.type() == Atom::BOOL) {
op = ENABLE_BROADCAST;
} else {
- _error = BAD_VALUE_TYPE;
+ _status = BAD_VALUE_TYPE;
}
} else if (key == uris.ingen_value) {
SetPortValue* ev = new SetPortValue(
@@ -201,10 +201,10 @@ SetMetadata::pre_process()
} else if (value.type() == Atom::DICT) {
op = CONTROL_BINDING;
} else {
- _error = BAD_VALUE_TYPE;
+ _status = BAD_VALUE_TYPE;
}
} else {
- _error = BAD_OBJECT_TYPE;
+ _status = BAD_OBJECT_TYPE;
}
}
} else if ((_patch = dynamic_cast<PatchImpl*>(_object))) {
@@ -215,14 +215,14 @@ SetMetadata::pre_process()
if (value.get_bool() && !_patch->enabled())
_compiled_patch = _patch->compile();
} else {
- _error = BAD_VALUE_TYPE;
+ _status = BAD_VALUE_TYPE;
}
} else if (key == uris.ingen_polyphony) {
if (value.type() == Atom::INT) {
op = POLYPHONY;
_patch->prepare_internal_poly(*_engine.buffer_factory(), value.get_int32());
} else {
- _error = BAD_VALUE_TYPE;
+ _status = BAD_VALUE_TYPE;
}
}
} else if (key == uris.ingen_polyphonic) {
@@ -240,15 +240,15 @@ SetMetadata::pre_process()
obj->prepare_poly(*_engine.buffer_factory(), 1);
}
} else {
- _error = BAD_VALUE_TYPE;
+ _status = BAD_VALUE_TYPE;
}
} else {
- _error = BAD_OBJECT_TYPE;
+ _status = BAD_OBJECT_TYPE;
}
}
}
- if (_error != NO_ERROR) {
+ if (_status != SUCCESS) {
_error_predicate += key.str();
break;
}
@@ -266,7 +266,7 @@ SetMetadata::pre_process()
void
SetMetadata::execute(ProcessContext& context)
{
- if (_error != NO_ERROR) {
+ if (_status != SUCCESS) {
Event::execute(context);
return;
}
@@ -318,7 +318,7 @@ SetMetadata::execute(ProcessContext& context)
!_patch->apply_internal_poly(_engine.driver()->context(),
*_engine.buffer_factory(),
*_engine.maid(), value.get_int32())) {
- _error = INTERNAL;
+ _status = INTERNAL_ERROR;
}
break;
case CONTROL_BINDING:
@@ -351,34 +351,19 @@ SetMetadata::post_process()
for (SetEvents::iterator i = _set_events.begin(); i != _set_events.end(); ++i)
(*i)->post_process();
- switch (_error) {
- case NO_ERROR:
+ if (!_status) {
if (_create_event) {
_create_event->post_process();
} else {
- respond_ok();
- if (_create)
+ respond(SUCCESS);
+ if (_create) {
_engine.broadcaster()->put(_subject, _properties, _context);
- else
+ } else {
_engine.broadcaster()->delta(_subject, _remove, _properties);
+ }
}
- break;
- case NOT_FOUND:
- respond_error((boost::format(
- "Unable to find object `%1%'") % _subject).str());
- break;
- case INTERNAL:
- respond_error("Internal error");
- break;
- case BAD_OBJECT_TYPE:
- respond_error((boost::format(
- "Bad type for object `%1%'") % _subject).str());
- break;
- case BAD_VALUE_TYPE:
- respond_error((boost::format(
- "Bad metadata value type for subject `%1%' predicate `%2%'")
- % _subject % _error_predicate).str());
- break;
+ } else {
+ respond(_status);
}
if (_create_event) {
diff --git a/src/server/events/SetMetadata.hpp b/src/server/events/SetMetadata.hpp
index 512e35c0..bcc3ab4f 100644
--- a/src/server/events/SetMetadata.hpp
+++ b/src/server/events/SetMetadata.hpp
@@ -86,14 +86,6 @@ public:
void post_process();
private:
- enum ErrorType {
- NO_ERROR,
- NOT_FOUND,
- INTERNAL,
- BAD_OBJECT_TYPE,
- BAD_VALUE_TYPE
- };
-
enum SpecialType {
NONE,
ENABLE,
diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp
index f96649b9..bc4cd9bf 100644
--- a/src/server/events/SetPortValue.cpp
+++ b/src/server/events/SetPortValue.cpp
@@ -84,7 +84,7 @@ SetPortValue::pre_process()
if (_port == NULL)
_port = _engine.engine_store()->find_port(_port_path);
if (_port == NULL)
- _error = PORT_NOT_FOUND;
+ _status = PORT_NOT_FOUND;
}
// Port is a message context port, set its value and
@@ -123,20 +123,20 @@ void
SetPortValue::apply(Context& context)
{
uint32_t start = context.start();
- if (_error == NO_ERROR && !_port)
+ if (_status == SUCCESS && !_port)
_port = _engine.engine_store()->find_port(_port_path);
if (!_port) {
- if (_error == NO_ERROR)
- _error = PORT_NOT_FOUND;
+ if (_status == SUCCESS)
+ _status = PORT_NOT_FOUND;
/*} else if (_port->buffer(0)->capacity() < _data_size) {
- _error = NO_SPACE;*/
+ _status = NO_SPACE;*/
} else {
Buffer* const buf = _port->buffer(0).get();
AudioBuffer* const abuf = dynamic_cast<AudioBuffer*>(buf);
if (abuf) {
if (_value.type() != Atom::FLOAT) {
- _error = TYPE_MISMATCH;
+ _status = TYPE_MISMATCH;
return;
}
@@ -192,31 +192,12 @@ SetPortValue::apply(Context& context)
void
SetPortValue::post_process()
{
- string msg;
- std::ostringstream ss;
- switch (_error) {
- case NO_ERROR:
- assert(_port != NULL);
- respond_ok();
- _engine.broadcaster()->set_property(_port_path,
- _engine.world()->uris()->ingen_value, _value);
- break;
- case TYPE_MISMATCH:
- ss << "Illegal value type " << _value.type()
- << " for port " << _port_path << endl;
- respond_error(ss.str());
- break;
- case PORT_NOT_FOUND:
- msg = "Unable to find port ";
- msg.append(_port_path.str()).append(" to set value");
- respond_error(msg);
- break;
- case NO_SPACE:
- ss << "Attempt to write " << _value.data_size() << " bytes to "
- << _port_path.str() << ", with capacity "
- << _port->buffer_size() << endl;
- respond_error(ss.str());
- break;
+ respond(_status);
+ if (!_status) {
+ _engine.broadcaster()->set_property(
+ _port_path,
+ _engine.world()->uris()->ingen_value,
+ _value);
}
}
diff --git a/src/server/events/SetPortValue.hpp b/src/server/events/SetPortValue.hpp
index 2ceb37f6..71764568 100644
--- a/src/server/events/SetPortValue.hpp
+++ b/src/server/events/SetPortValue.hpp
@@ -65,13 +65,6 @@ public:
void post_process();
private:
- enum ErrorType {
- NO_ERROR,
- PORT_NOT_FOUND,
- NO_SPACE,
- TYPE_MISMATCH
- };
-
void apply(Context& context);
bool _queued;
@@ -81,8 +74,8 @@ private:
ControlBindings::Key _binding;
};
+} // namespace Events
} // namespace Server
} // namespace Ingen
-} // namespace Events
#endif // INGEN_EVENTS_SETPORTVALUE_HPP
diff --git a/src/server/events/UnregisterClient.cpp b/src/server/events/UnregisterClient.cpp
index 64c37fb8..a673c25a 100644
--- a/src/server/events/UnregisterClient.cpp
+++ b/src/server/events/UnregisterClient.cpp
@@ -39,10 +39,11 @@ UnregisterClient::UnregisterClient(Engine& engine,
void
UnregisterClient::post_process()
{
- if (_engine.broadcaster()->unregister_client(_uri))
- respond_ok();
- else
- respond_error("Unable to unregister client");
+ if (_engine.broadcaster()->unregister_client(_uri)) {
+ respond(SUCCESS);
+ } else {
+ respond(FAILURE);
+ }
}
} // namespace Server