From e9d9569271ee962c09ab66c6babed1ca5655a6c6 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 12 Mar 2012 02:28:21 +0000 Subject: 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 --- src/server/events/Disconnect.cpp | 44 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 36 deletions(-) (limited to 'src/server/events/Disconnect.cpp') 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; -- cgit v1.2.1