From 08759b27bc19de59bfd17fc929ee7e0021181ffb Mon Sep 17 00:00:00 2001
From: David Robillard <d@drobilla.net>
Date: Tue, 19 Apr 2011 21:07:07 +0000
Subject: Remove EngineInterface::activate() and EngineInterface::deactivate().

Use set_property("ingen:driver", "ingen:enabled", true | false) instead.


git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3171 a436a847-0d15-0410-975c-d299462d15a1
---
 src/client/HTTPEngineSender.cpp      | 10 ----------
 src/client/HTTPEngineSender.hpp      |  2 --
 src/client/OSCEngineSender.cpp       | 12 ------------
 src/client/OSCEngineSender.hpp       |  2 --
 src/engine/OSCEngineReceiver.cpp     | 30 ------------------------------
 src/engine/OSCEngineReceiver.hpp     |  2 --
 src/engine/QueuedEngineInterface.cpp | 35 +++++++++++++++++------------------
 src/engine/QueuedEngineInterface.hpp |  2 --
 src/gui/ConnectWindow.cpp            |  8 ++++++--
 src/ingen/main.cpp                   |  2 --
 10 files changed, 23 insertions(+), 82 deletions(-)

(limited to 'src')

diff --git a/src/client/HTTPEngineSender.cpp b/src/client/HTTPEngineSender.cpp
index 31e1238c..e188b010 100644
--- a/src/client/HTTPEngineSender.cpp
+++ b/src/client/HTTPEngineSender.cpp
@@ -80,16 +80,6 @@ HTTPEngineSender::unregister_client(const URI& uri)
 
 // Engine commands
 
-void
-HTTPEngineSender::activate()
-{
-}
-
-void
-HTTPEngineSender::deactivate()
-{
-}
-
 void
 HTTPEngineSender::quit()
 {
diff --git a/src/client/HTTPEngineSender.hpp b/src/client/HTTPEngineSender.hpp
index 3a0b1a40..549ad07a 100644
--- a/src/client/HTTPEngineSender.hpp
+++ b/src/client/HTTPEngineSender.hpp
@@ -73,8 +73,6 @@ public:
 	void unregister_client(const Raul::URI& uri);
 
 	// Engine commands
-	void activate();
-	void deactivate();
 	void quit();
 
 	// Object commands
diff --git a/src/client/OSCEngineSender.cpp b/src/client/OSCEngineSender.cpp
index f78583f9..3c9b60b4 100644
--- a/src/client/OSCEngineSender.cpp
+++ b/src/client/OSCEngineSender.cpp
@@ -100,18 +100,6 @@ OSCEngineSender::unregister_client(const URI& uri)
 
 // Engine commands
 
-void
-OSCEngineSender::activate()
-{
-	send("/activate", "i", next_id(), LO_ARGS_END);
-}
-
-void
-OSCEngineSender::deactivate()
-{
-	send("/deactivate", "i", next_id(), LO_ARGS_END);
-}
-
 void
 OSCEngineSender::quit()
 {
diff --git a/src/client/OSCEngineSender.hpp b/src/client/OSCEngineSender.hpp
index 30e82c5f..75cf3db1 100644
--- a/src/client/OSCEngineSender.hpp
+++ b/src/client/OSCEngineSender.hpp
@@ -74,8 +74,6 @@ public:
 	void unregister_client(const Raul::URI& uri);
 
 	// Engine commands
-	void activate();
-	void deactivate();
 	void quit();
 
 	// Object commands
diff --git a/src/engine/OSCEngineReceiver.cpp b/src/engine/OSCEngineReceiver.cpp
index 59aac9e4..1b8d1179 100644
--- a/src/engine/OSCEngineReceiver.cpp
+++ b/src/engine/OSCEngineReceiver.cpp
@@ -97,8 +97,6 @@ OSCEngineReceiver::OSCEngineReceiver(Engine& engine, size_t queue_size, uint16_t
 	lo_server_add_method(_server, "/quit", "i", quit_cb, this);
 	lo_server_add_method(_server, "/register_client", "i", register_client_cb, this);
 	lo_server_add_method(_server, "/unregister_client", "i", unregister_client_cb, this);
-	lo_server_add_method(_server, "/activate", "i", engine_activate_cb, this);
-	lo_server_add_method(_server, "/deactivate", "i", engine_deactivate_cb, this);
 	lo_server_add_method(_server, "/put", NULL, put_cb, this);
 	lo_server_add_method(_server, "/move", "iss", move_cb, this);
 	lo_server_add_method(_server, "/delete", "is", del_cb, this);
@@ -327,34 +325,6 @@ OSCEngineReceiver::_unregister_client_cb(const char* path, const char* types, lo
 	return 0;
 }
 
-/** \page engine_osc_namespace
- * <h2>/activate</h2>
- * \arg \b response-id (integer)
- *
- * Activate the engine (event processing and all drivers, e.g. audio and MIDI).
- * Note that you <b>must</b> send this message first if you want the engine to do
- * anything at all - <em>including respond to your messages!</em>
- */
-int
-OSCEngineReceiver::_engine_activate_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
-	QueuedEngineInterface::activate();
-	return 0;
-}
-
-/** \page engine_osc_namespace
- * <h2>/deactivate</h2>
- * \arg \b response-id (integer)
- *
- * Deactivate the engine.
- */
-int
-OSCEngineReceiver::_engine_deactivate_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
-	QueuedEngineInterface::deactivate();
-	return 0;
-}
-
 /** \page engine_osc_namespace
  * <h2>/get</h2>
  * \arg \b response-id (integer)
diff --git a/src/engine/OSCEngineReceiver.hpp b/src/engine/OSCEngineReceiver.hpp
index e32cd4ae..4293f890 100644
--- a/src/engine/OSCEngineReceiver.hpp
+++ b/src/engine/OSCEngineReceiver.hpp
@@ -94,8 +94,6 @@ private:
 	LO_HANDLER(ping_slow);
 	LO_HANDLER(register_client);
 	LO_HANDLER(unregister_client);
-	LO_HANDLER(engine_activate);
-	LO_HANDLER(engine_deactivate);
 	LO_HANDLER(get);
 	LO_HANDLER(put);
 	LO_HANDLER(move);
diff --git a/src/engine/QueuedEngineInterface.cpp b/src/engine/QueuedEngineInterface.cpp
index 8e9363ec..1fc68799 100644
--- a/src/engine/QueuedEngineInterface.cpp
+++ b/src/engine/QueuedEngineInterface.cpp
@@ -99,19 +99,6 @@ QueuedEngineInterface::unregister_client(const URI& uri)
 
 // Engine commands
 
-void
-QueuedEngineInterface::activate()
-{
-	_engine.activate();
-	push_queued(new Events::Ping(_engine, _request, now()));
-}
-
-void
-QueuedEngineInterface::deactivate()
-{
-	push_queued(new Events::Deactivate(_engine, _request, now()));
-}
-
 void
 QueuedEngineInterface::quit()
 {
@@ -191,11 +178,23 @@ QueuedEngineInterface::set_property(const URI&  uri,
                                     const URI&  predicate,
                                     const Atom& value)
 {
-	Resource::Properties remove;
-	remove.insert(make_pair(predicate, _engine.world()->uris()->wildcard));
-	Resource::Properties add;
-	add.insert(make_pair(predicate, value));
-	push_queued(new Events::SetMetadata(_engine, _request, now(), false, Resource::DEFAULT, uri, add, remove));
+	if (uri == "ingen:engine" && predicate == "ingen:enabled"
+	    && value.type() == Atom::BOOL) {
+		if (value.get_bool()) {
+			_engine.activate();
+			push_queued(new Events::Ping(_engine, _request, now()));
+		} else {
+			push_queued(new Events::Deactivate(_engine, _request, now()));
+		}
+	} else {
+		Resource::Properties remove;
+		remove.insert(make_pair(predicate, _engine.world()->uris()->wildcard));
+		Resource::Properties add;
+		add.insert(make_pair(predicate, value));
+		push_queued(new Events::SetMetadata(
+			            _engine, _request, now(), false, Resource::DEFAULT,
+			            uri, add, remove));
+	}
 }
 
 // Requests //
diff --git a/src/engine/QueuedEngineInterface.hpp b/src/engine/QueuedEngineInterface.hpp
index a2c13040..dede135e 100644
--- a/src/engine/QueuedEngineInterface.hpp
+++ b/src/engine/QueuedEngineInterface.hpp
@@ -60,8 +60,6 @@ public:
 	virtual void unregister_client(const Raul::URI& uri);
 
 	// Engine commands
-	virtual void activate();
-	virtual void deactivate();
 	virtual void quit();
 
 	// Bundles
diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp
index e5ade51c..f93ebf4c 100644
--- a/src/gui/ConnectWindow.cpp
+++ b/src/gui/ConnectWindow.cpp
@@ -288,13 +288,17 @@ ConnectWindow::disconnect()
 void
 ConnectWindow::activate()
 {
-	App::instance().engine()->activate();
+	App::instance().engine()->set_property("ingen:driver",
+	                                       "ingen:enabled",
+	                                       true);
 }
 
 void
 ConnectWindow::deactivate()
 {
-	App::instance().engine()->deactivate();
+	App::instance().engine()->set_property("ingen:driver",
+	                                       "ingen:enabled",
+	                                       false);
 }
 
 void
diff --git a/src/ingen/main.cpp b/src/ingen/main.cpp
index 0767e328..4691c302 100644
--- a/src/ingen/main.cpp
+++ b/src/ingen/main.cpp
@@ -225,8 +225,6 @@ main(int argc, char** argv)
 			nanosleep(&main_rate, NULL);
 		}
 		info << "Finished main loop" << endl;
-
-		world->local_engine()->deactivate();
 	}
 
 	// Shut down
-- 
cgit v1.2.1