summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-05-24 23:29:42 +0000
committerDavid Robillard <d@drobilla.net>2011-05-24 23:29:42 +0000
commitacaab5ca7ce6869b8192de4f98c9f075fd17690e (patch)
tree731f14aa5cfb03e7f8837fe0c573b2b12ce7a8b4 /src
parent881eac58c2f9bf1fcb18ef7dcda7ab025e327871 (diff)
downloadingen-acaab5ca7ce6869b8192de4f98c9f075fd17690e.tar.gz
ingen-acaab5ca7ce6869b8192de4f98c9f075fd17690e.tar.bz2
ingen-acaab5ca7ce6869b8192de4f98c9f075fd17690e.zip
Remove dependence on protocol-specific client headers in GUI code.
In other words, remove need for protocol-specific (and library dependent) headers to be in public headers... git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3318 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/client/HTTPEngineSender.cpp7
-rw-r--r--src/client/HTTPEngineSender.hpp8
-rw-r--r--src/client/OSCClientReceiver.cpp3
-rw-r--r--src/client/OSCEngineSender.cpp6
-rw-r--r--src/client/OSCEngineSender.hpp14
-rw-r--r--src/client/ingen_client.cpp21
-rw-r--r--src/gui/App.cpp5
-rw-r--r--src/gui/App.hpp4
-rw-r--r--src/gui/ConnectWindow.cpp41
-rw-r--r--src/ingen/main.cpp7
-rw-r--r--src/shared/World.cpp13
-rw-r--r--src/shared/World.hpp11
12 files changed, 72 insertions, 68 deletions
diff --git a/src/client/HTTPEngineSender.cpp b/src/client/HTTPEngineSender.cpp
index ec5cc6a0..2c3dbe98 100644
--- a/src/client/HTTPEngineSender.cpp
+++ b/src/client/HTTPEngineSender.cpp
@@ -36,8 +36,11 @@ using namespace Shared;
namespace Client {
-HTTPEngineSender::HTTPEngineSender(World* world, const URI& engine_url)
- : _world(*world->rdf_world())
+HTTPEngineSender::HTTPEngineSender(World* world,
+ const URI& engine_url,
+ SharedPtr<Raul::Deletable> receiver)
+ : _receiver(receiver)
+ , _world(*world->rdf_world())
, _engine_url(engine_url)
, _id(0)
, _enabled(true)
diff --git a/src/client/HTTPEngineSender.hpp b/src/client/HTTPEngineSender.hpp
index 27c34a51..3f932fb0 100644
--- a/src/client/HTTPEngineSender.hpp
+++ b/src/client/HTTPEngineSender.hpp
@@ -22,6 +22,7 @@
#include <string>
+#include "raul/Deletable.hpp"
#include "raul/Path.hpp"
#include "sord/sordmm.hpp"
@@ -47,7 +48,10 @@ class HTTPClientReceiver;
class HTTPEngineSender : public ServerInterface
{
public:
- HTTPEngineSender(Shared::World* world, const Raul::URI& engine_url);
+ HTTPEngineSender(Shared::World* world,
+ const Raul::URI& engine_url,
+ SharedPtr<Raul::Deletable> receiver);
+
~HTTPEngineSender();
Raul::URI uri() const { return _engine_url; }
@@ -106,6 +110,8 @@ public:
void request_property(const Raul::URI& path, const Raul::URI& key);
protected:
+ SharedPtr<Raul::Deletable> _receiver;
+
SoupSession* _session;
Sord::World& _world;
const Raul::URI _engine_url;
diff --git a/src/client/OSCClientReceiver.cpp b/src/client/OSCClientReceiver.cpp
index 33e2d050..c163da60 100644
--- a/src/client/OSCClientReceiver.cpp
+++ b/src/client/OSCClientReceiver.cpp
@@ -137,6 +137,9 @@ OSCClientReceiver::unknown_cb(const char* path, const char* types, lo_arg** argv
void
OSCClientReceiver::setup_callbacks()
{
+ if (!_target)
+ return;
+
lo_server_thread_add_method(_st, "/ok", "i", response_ok_cb, this);
lo_server_thread_add_method(_st, "/error", "is", response_error_cb, this);
lo_server_thread_add_method(_st, "/plugin", "sss", plugin_cb, this);
diff --git a/src/client/OSCEngineSender.cpp b/src/client/OSCEngineSender.cpp
index 4147c831..21c1ad6e 100644
--- a/src/client/OSCEngineSender.cpp
+++ b/src/client/OSCEngineSender.cpp
@@ -37,9 +37,11 @@ namespace Client {
* from the most recently created server, so create the OSC listener before
* this to have it all happen on the same port. Yeah, this is a big magic :/
*/
-OSCEngineSender::OSCEngineSender(const URI& engine_url,
- size_t max_packet_size)
+OSCEngineSender::OSCEngineSender(const URI& engine_url,
+ size_t max_packet_size,
+ SharedPtr<Raul::Deletable> receiver)
: Shared::OSCSender(max_packet_size)
+ , _receiver(receiver)
, _engine_url(engine_url)
, _id(0)
{
diff --git a/src/client/OSCEngineSender.hpp b/src/client/OSCEngineSender.hpp
index a50de0f3..876d2ec2 100644
--- a/src/client/OSCEngineSender.hpp
+++ b/src/client/OSCEngineSender.hpp
@@ -24,6 +24,8 @@
#include <lo/lo.h>
+#include "raul/Deletable.hpp"
+
#include "ingen/ServerInterface.hpp"
#include "shared/OSCSender.hpp"
@@ -40,16 +42,12 @@ namespace Client {
*/
class OSCEngineSender : public ServerInterface, public Shared::OSCSender {
public:
- OSCEngineSender(const Raul::URI& engine_url,
- size_t max_packet_size);
+ OSCEngineSender(const Raul::URI& engine_url,
+ size_t max_packet_size,
+ SharedPtr<Raul::Deletable> receiver);
~OSCEngineSender();
- static OSCEngineSender* create(const Raul::URI& engine_url,
- size_t max_packet_size) {
- return new OSCEngineSender(engine_url, max_packet_size);
- }
-
Raul::URI uri() const { return _engine_url; }
inline int32_t next_id()
@@ -106,6 +104,8 @@ public:
void request_property(const Raul::URI& path, const Raul::URI& key);
protected:
+ SharedPtr<Raul::Deletable> _receiver;
+
const Raul::URI _engine_url;
int _client_port;
int32_t _id;
diff --git a/src/client/ingen_client.cpp b/src/client/ingen_client.cpp
index dc4d7f20..db32b117 100644
--- a/src/client/ingen_client.cpp
+++ b/src/client/ingen_client.cpp
@@ -20,9 +20,11 @@
#include "shared/Module.hpp"
#include "shared/World.hpp"
#ifdef HAVE_LIBLO
+#include "OSCClientReceiver.hpp"
#include "OSCEngineSender.hpp"
#endif
#ifdef HAVE_SOUP
+#include "HTTPClientReceiver.hpp"
#include "HTTPEngineSender.hpp"
#endif
@@ -30,10 +32,14 @@ using namespace Ingen;
#ifdef HAVE_LIBLO
SharedPtr<Ingen::ServerInterface>
-new_osc_interface(Ingen::Shared::World* world, const std::string& url)
+new_osc_interface(Ingen::Shared::World* world,
+ const std::string& url,
+ SharedPtr<ClientInterface> respond_to)
{
- Client::OSCEngineSender* oes = Client::OSCEngineSender::create(
- url, world->conf()->option("packet-size").get_int32());
+ SharedPtr<Client::OSCClientReceiver> receiver(
+ new Client::OSCClientReceiver(16181, respond_to));
+ Client::OSCEngineSender* oes = new Client::OSCEngineSender(
+ url, world->conf()->option("packet-size").get_int32(), receiver);
oes->attach(rand(), true);
return SharedPtr<ServerInterface>(oes);
}
@@ -41,9 +47,14 @@ new_osc_interface(Ingen::Shared::World* world, const std::string& url)
#ifdef HAVE_SOUP
SharedPtr<Ingen::ServerInterface>
-new_http_interface(Ingen::Shared::World* world, const std::string& url)
+new_http_interface(Ingen::Shared::World* world,
+ const std::string& url,
+ SharedPtr<ClientInterface> respond_to)
{
- Client::HTTPEngineSender* hes = new Client::HTTPEngineSender(world, url);
+ SharedPtr<Client::HTTPClientReceiver> receiver(
+ new Client::HTTPClientReceiver(world, url, respond_to));
+ Client::HTTPEngineSender* hes = new Client::HTTPEngineSender(
+ world, url, receiver);
hes->attach(rand(), true);
return SharedPtr<ServerInterface>(hes);
}
diff --git a/src/gui/App.cpp b/src/gui/App.cpp
index 9d7fffc1..f1e590cb 100644
--- a/src/gui/App.cpp
+++ b/src/gui/App.cpp
@@ -150,8 +150,7 @@ App::run()
}
void
-App::attach(SharedPtr<SigClientInterface> client,
- SharedPtr<Raul::Deletable> handle)
+App::attach(SharedPtr<SigClientInterface> client)
{
assert(!_client);
assert(!_store);
@@ -160,7 +159,6 @@ App::attach(SharedPtr<SigClientInterface> client,
_world->engine()->register_client(client.get());
_client = client;
- _handle = handle;
_store = SharedPtr<ClientStore>(new ClientStore(_world->uris(), _world->engine(), client));
_loader = SharedPtr<ThreadedLoader>(new ThreadedLoader(_world->uris(), _world->engine()));
@@ -182,7 +180,6 @@ App::detach()
_loader.reset();
_store.reset();
_client.reset();
- _handle.reset();
_world->set_engine(SharedPtr<ServerInterface>());
}
}
diff --git a/src/gui/App.hpp b/src/gui/App.hpp
index ca5c590f..96cd0152 100644
--- a/src/gui/App.hpp
+++ b/src/gui/App.hpp
@@ -74,8 +74,7 @@ public:
void error_message(const std::string& msg);
- void attach(SharedPtr<Client::SigClientInterface> client,
- SharedPtr<Raul::Deletable> handle=SharedPtr<Raul::Deletable>());
+ void attach(SharedPtr<Client::SigClientInterface> client);
void detach();
@@ -143,7 +142,6 @@ protected:
static App* _instance;
SharedPtr<Client::SigClientInterface> _client;
- SharedPtr<Raul::Deletable> _handle;
SharedPtr<Client::ClientStore> _store;
SharedPtr<ThreadedLoader> _loader;
diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp
index b266307a..56acc52b 100644
--- a/src/gui/ConnectWindow.cpp
+++ b/src/gui/ConnectWindow.cpp
@@ -29,12 +29,6 @@
#include "shared/Module.hpp"
#include "shared/World.hpp"
#include "server/Engine.hpp"
-#ifdef HAVE_SOUP
-#include "client/HTTPClientReceiver.hpp"
-#endif
-#ifdef HAVE_LIBLO
-#include "client/OSCClientReceiver.hpp"
-#endif
#include "client/ClientStore.hpp"
#include "client/PatchModel.hpp"
#include "client/ThreadedSigClientInterface.hpp"
@@ -78,7 +72,7 @@ ConnectWindow::start(Ingen::Shared::World* world)
set_connected_to(world->engine());
- connect(true);
+ connect(world->engine());
}
void
@@ -175,27 +169,10 @@ ConnectWindow::connect(bool existing)
// Create client-side listener
SharedPtr<ThreadedSigClientInterface> tsci(new ThreadedSigClientInterface(1024));
- SharedPtr<Raul::Deletable> client;
- string scheme = uri.substr(0, uri.find(":"));
-
-#ifdef HAVE_LIBLO
- if (scheme == "osc.udp" || scheme == "osc.tcp")
- client = SharedPtr<OSCClientReceiver>(new OSCClientReceiver(16181, tsci));
-#endif
-#ifdef HAVE_SOUP
- if (scheme == "http")
- client = SharedPtr<HTTPClientReceiver>(new HTTPClientReceiver(world, uri, tsci));
-#endif
-
- if (!existing) {
- world->set_engine(world->interface(uri));
- } else {
- uri = world->engine()->uri().str();
- scheme = uri.substr(0, uri.find(":"));
- }
+ world->set_engine(world->interface(uri, tsci));
- App::instance().attach(tsci, client);
+ App::instance().attach(tsci);
App::instance().register_callbacks();
Glib::signal_timeout().connect(
@@ -204,19 +181,17 @@ ConnectWindow::connect(bool existing)
} else if (_mode == LAUNCH_REMOTE) {
#ifdef HAVE_LIBLO
int port = _port_spinbutton->get_value_as_int();
- char port_str[6];
- snprintf(port_str, 6, "%u", port);
- const string cmd = string("ingen -e --engine-port=").append(port_str);
+ char port_str[8];
+ snprintf(port_str, sizeof(port_str), "%u", port);
+ const string cmd = string("ingen -e -E ").append(port_str);
if (Raul::Process::launch(cmd)) {
const std::string engine_uri = string("osc.udp://localhost:").append(port_str);
- world->set_engine(world->interface(engine_uri));
- // FIXME: static args
SharedPtr<ThreadedSigClientInterface> tsci(new ThreadedSigClientInterface(1024));
- SharedPtr<OSCClientReceiver> client(new OSCClientReceiver(16181, tsci));
+ world->set_engine(world->interface(engine_uri, tsci));
- App::instance().attach(tsci, client);
+ App::instance().attach(tsci);
App::instance().register_callbacks();
Glib::signal_timeout().connect(
diff --git a/src/ingen/main.cpp b/src/ingen/main.cpp
index 997fb66e..8df67e92 100644
--- a/src/ingen/main.cpp
+++ b/src/ingen/main.cpp
@@ -45,6 +45,7 @@
#include "shared/Configuration.hpp"
#include "shared/World.hpp"
#include "shared/runtime_paths.hpp"
+#include "client/ThreadedSigClientInterface.hpp"
#ifdef WITH_BINDINGS
#include "bindings/ingen_bindings.hpp"
#endif
@@ -105,17 +106,15 @@ main(int argc, char** argv)
SharedPtr<ServerInterface> engine_interface;
Glib::thread_init();
-#if HAVE_SOUP
+#ifdef HAVE_SOUP
g_type_init();
#endif
Ingen::Shared::World* world = new Ingen::Shared::World(&conf, argc, argv);
-#if INGEN_JACK_SESSION
if (conf.option("uuid").get_string()) {
world->set_jack_uuid(conf.option("uuid").get_string());
}
-#endif
// Run engine
if (conf.option("engine").get_bool()) {
@@ -145,7 +144,7 @@ main(int argc, char** argv)
ingen_try(world->load_module("client"),
"Unable to load client module");
const char* const uri = conf.option("connect").get_string();
- ingen_try((engine_interface = world->interface(uri)),
+ ingen_try((engine_interface = world->interface(uri, SharedPtr<ClientInterface>())),
(string("Unable to create interface to `") + uri + "'").c_str());
}
diff --git a/src/shared/World.cpp b/src/shared/World.cpp
index f2af34a7..c583f2fa 100644
--- a/src/shared/World.cpp
+++ b/src/shared/World.cpp
@@ -169,6 +169,7 @@ public:
SharedPtr<Serialisation::Serialiser> serialiser;
SharedPtr<Serialisation::Parser> parser;
SharedPtr<Store> store;
+ SharedPtr<ClientInterface> client;
LilvWorld* lilv_world;
std::string jack_uuid;
};
@@ -189,6 +190,7 @@ void World::set_engine(SharedPtr<ServerInterface> e) { _impl->engi
void World::set_serialiser(SharedPtr<Serialisation::Serialiser> s) { _impl->serialiser = s; }
void World::set_parser(SharedPtr<Serialisation::Parser> p) { _impl->parser = p; }
void World::set_store(SharedPtr<Store> s) { _impl->store = s; }
+void World::set_client(SharedPtr<ClientInterface> c) { _impl->client = c; }
void World::set_conf(Raul::Configuration* c) { _impl->conf = c; }
int& World::argc() { return _impl->argc; }
@@ -198,6 +200,7 @@ SharedPtr<ServerInterface> World::engine() { return _impl->engin
SharedPtr<Serialisation::Serialiser> World::serialiser() { return _impl->serialiser; }
SharedPtr<Serialisation::Parser> World::parser() { return _impl->parser; }
SharedPtr<Store> World::store() { return _impl->store; }
+SharedPtr<ClientInterface> World::client() { return _impl->client; }
Raul::Configuration* World::conf() { return _impl->conf; }
LV2Features* World::lv2_features() { return _impl->lv2_features; }
@@ -207,7 +210,7 @@ SharedPtr<LV2URIMap> World::uris() { return _impl->uris; }
/** Load an Ingen module.
* @return true on success, false on failure
- */
+m */
bool
World::load_module(const char* name)
{
@@ -236,16 +239,18 @@ World::unload_modules()
/** Get an interface for a remote engine at @a url
*/
SharedPtr<ServerInterface>
-World::interface(const std::string& url)
+World::interface(
+ const std::string& engine_url,
+ SharedPtr<ClientInterface> respond_to)
{
- const string scheme = url.substr(0, url.find(":"));
+ const string scheme = engine_url.substr(0, engine_url.find(":"));
const Pimpl::InterfaceFactories::const_iterator i = _impl->interface_factories.find(scheme);
if (i == _impl->interface_factories.end()) {
warn << "Unknown URI scheme `" << scheme << "'" << endl;
return SharedPtr<ServerInterface>();
}
- return i->second(this, url);
+ return i->second(this, engine_url, respond_to);
}
/** Run a script of type @a mime_type at filename @a filename */
diff --git a/src/shared/World.hpp b/src/shared/World.hpp
index 3ce4d03e..6aacea36 100644
--- a/src/shared/World.hpp
+++ b/src/shared/World.hpp
@@ -34,6 +34,7 @@ namespace Sord { class World; }
namespace Ingen {
class EngineBase;
+class ClientInterface;
class ServerInterface;
namespace Serialisation { class Serialiser; class Parser; }
@@ -62,14 +63,16 @@ public:
virtual void unload_modules();
typedef SharedPtr<ServerInterface> (*InterfaceFactory)(
- World* world,
- const std::string& engine_url);
+ World* world,
+ const std::string& engine_url,
+ SharedPtr<ClientInterface> respond_to);
virtual void add_interface_factory(const std::string& scheme,
InterfaceFactory factory);
virtual SharedPtr<ServerInterface> interface(
- const std::string& engine_url);
+ const std::string& engine_url,
+ SharedPtr<ClientInterface> respond_to);
virtual bool run(const std::string& mime_type,
const std::string& filename);
@@ -79,12 +82,14 @@ public:
virtual void set_serialiser(SharedPtr<Serialisation::Serialiser> s);
virtual void set_parser(SharedPtr<Serialisation::Parser> p);
virtual void set_store(SharedPtr<Store> s);
+ virtual void set_client(SharedPtr<ClientInterface> c);
virtual SharedPtr<EngineBase> local_engine();
virtual SharedPtr<ServerInterface> engine();
virtual SharedPtr<Serialisation::Serialiser> serialiser();
virtual SharedPtr<Serialisation::Parser> parser();
virtual SharedPtr<Store> store();
+ virtual SharedPtr<ClientInterface> client();
virtual Sord::World* rdf_world();
virtual SharedPtr<LV2URIMap> uris();