summaryrefslogtreecommitdiffstats
path: root/src/server/events/Connect.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-03-12 02:28:21 +0000
committerDavid Robillard <d@drobilla.net>2012-03-12 02:28:21 +0000
commite9d9569271ee962c09ab66c6babed1ca5655a6c6 (patch)
treef77142b08c2bf2488eb382e993da1477c0b94307 /src/server/events/Connect.cpp
parent7835b3d8c9b5b4a6f4959f56083d62826e6f7b8e (diff)
downloadingen-e9d9569271ee962c09ab66c6babed1ca5655a6c6.tar.gz
ingen-e9d9569271ee962c09ab66c6babed1ca5655a6c6.tar.bz2
ingen-e9d9569271ee962c09ab66c6babed1ca5655a6c6.zip
Unify event response mechanism and make it more appropriate for wire transmission.
The downside being more cryptic error messages until the client side error reporting stuff gets more fancy, but the important part is that belongs client side. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4053 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/events/Connect.cpp')
-rw-r--r--src/server/events/Connect.cpp42
1 files changed, 9 insertions, 33 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