summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-05-28 18:15:11 +0000
committerDavid Robillard <d@drobilla.net>2009-05-28 18:15:11 +0000
commit8935cca8706d74f39d3cca43b4df3ab48799b06a (patch)
tree90944dd3367ca3252c391546f88e3e9605dcba80 /src/client
parentf2135439b806e9c375f2e8588be23ea53c69832c (diff)
downloadingen-8935cca8706d74f39d3cca43b4df3ab48799b06a.tar.gz
ingen-8935cca8706d74f39d3cca43b4df3ab48799b06a.tar.bz2
ingen-8935cca8706d74f39d3cca43b4df3ab48799b06a.zip
Replace new_plugin with put.
Fix default symbol generation (URI chopping). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2029 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/client')
-rw-r--r--src/client/ClientStore.cpp29
-rw-r--r--src/client/ClientStore.hpp5
-rw-r--r--src/client/OSCClientReceiver.cpp12
-rw-r--r--src/client/PluginModel.cpp62
-rw-r--r--src/client/PluginModel.hpp6
-rw-r--r--src/client/SigClientInterface.hpp4
-rw-r--r--src/client/ThreadedSigClientInterface.hpp4
7 files changed, 80 insertions, 42 deletions
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp
index a8fe7c51..e4cd604e 100644
--- a/src/client/ClientStore.cpp
+++ b/src/client/ClientStore.cpp
@@ -45,7 +45,6 @@ ClientStore::ClientStore(SharedPtr<EngineInterface> engine, SharedPtr<SigClientI
emitter->signal_object_deleted.connect(sigc::mem_fun(this, &ClientStore::del));
emitter->signal_object_moved.connect(sigc::mem_fun(this, &ClientStore::move));
- emitter->signal_new_plugin.connect(sigc::mem_fun(this, &ClientStore::new_plugin));
emitter->signal_put.connect(sigc::mem_fun(this, &ClientStore::put));
emitter->signal_clear_patch.connect(sigc::mem_fun(this, &ClientStore::clear_patch));
emitter->signal_connection.connect(sigc::mem_fun(this, &ClientStore::connect));
@@ -264,29 +263,29 @@ ClientStore::move(const Path& old_path_str, const Path& new_path_str)
}*/
}
-void
-ClientStore::new_plugin(const URI& uri, const URI& type_uri, const Symbol& symbol)
-{
- SharedPtr<PluginModel> p(new PluginModel(uri, type_uri));
- p->set_property("lv2:symbol", Atom(Atom::STRING, symbol));
- add_plugin(p);
- //resolve_plugin_orphans(p);
-}
-
void
ClientStore::put(const URI& uri, const Resource::Properties& properties)
{
- size_t hash = uri.find("#");
- bool meta = (hash != string::npos);
- Path path(meta ? (string("/") + uri.chop_start("#")) : uri.str());
-
typedef Resource::Properties::const_iterator iterator;
- cerr << "CLIENT PUT " << uri << " (" << path << ") {" << endl;
+ cerr << "CLIENT PUT " << uri << " {" << endl;
for (iterator i = properties.begin(); i != properties.end(); ++i)
cerr << "\t" << i->first << " = " << i->second << " :: " << i->second.type() << endl;
cerr << "}" << endl;
+ bool is_path = Path::is_valid(uri.str());
+ bool is_meta = uri.substr(0, 8) == "meta:#";
+
+ if (!(is_path || is_meta)) {
+ const URI& type_uri = properties.find("rdf:type")->second.get_uri();
+ SharedPtr<PluginModel> p(new PluginModel(uri, type_uri));
+ p->set_properties(properties);
+ add_plugin(p);
+ return;
+ }
+
+ Path path(is_meta ? (string("/") + uri.chop_start("#")) : uri.str());
+
SharedPtr<ObjectModel> obj = PtrCast<ObjectModel>(object(path));
if (obj) {
obj->set_properties(properties);
diff --git a/src/client/ClientStore.hpp b/src/client/ClientStore.hpp
index 00069701..53cb4a59 100644
--- a/src/client/ClientStore.hpp
+++ b/src/client/ClientStore.hpp
@@ -67,7 +67,6 @@ public:
void set_plugins(SharedPtr<Plugins> p) { _plugins = p; }
// CommonInterface
- void new_plugin(const Raul::URI& uri, const Raul::URI& type_uri, const Raul::Symbol& symbol);
bool new_object(const Shared::GraphObject* object);
void put(const Raul::URI& path, const Shared::Resource::Properties& properties);
void move(const Raul::Path& old_path, const Raul::Path& new_path);
@@ -78,8 +77,8 @@ public:
void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path);
void del(const Raul::Path& path);
- sigc::signal<void, SharedPtr<ObjectModel> > signal_new_object;
- sigc::signal<void, SharedPtr<PluginModel> > signal_new_plugin;
+ sigc::signal< void, SharedPtr<ObjectModel> > signal_new_object;
+ sigc::signal< void, SharedPtr<PluginModel> > signal_new_plugin;
private:
diff --git a/src/client/OSCClientReceiver.cpp b/src/client/OSCClientReceiver.cpp
index c552e82e..eb5eb84b 100644
--- a/src/client/OSCClientReceiver.cpp
+++ b/src/client/OSCClientReceiver.cpp
@@ -303,17 +303,5 @@ OSCClientReceiver::_response_error_cb(const char* path, const char* types, lo_ar
}
-/** A plugin info response from the server, in response to an /ingen/send_plugins
- */
-int
-OSCClientReceiver::_plugin_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- assert(argc == 3 && !strcmp(types, "sss"));
- _target->new_plugin(&argv[0]->s, &argv[1]->s, &argv[2]->s); // uri, type, symbol
-
- return 0;
-}
-
-
} // namespace Client
} // namespace Ingen
diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp
index 4db79091..fd484df4 100644
--- a/src/client/PluginModel.cpp
+++ b/src/client/PluginModel.cpp
@@ -16,6 +16,7 @@
*/
#include <sstream>
+#include <ctype.h>
#include "ingen-config.h"
#include "raul/Path.hpp"
#include "raul/Atom.hpp"
@@ -51,11 +52,70 @@ PluginModel::PluginModel(const URI& uri, const URI& type_uri)
#endif
if (_type == Internal)
set_property("doap:name", Raul::Atom(uri.substr(uri.find_last_of("#") + 1).c_str()));
+
+ if (!get_property("lv2:symbol").is_valid()) {
+ size_t last_slash = uri.find_last_of("/");
+ size_t last_hash = uri.find_last_of("#");
+ string symbol;
+ if (last_slash == string::npos && last_hash == string::npos) {
+ size_t last_colon = uri.find_last_of(":");
+ if (last_colon != string::npos)
+ symbol = uri.substr(last_colon + 1);
+ else
+ symbol = uri.str();
+ } else if (last_slash == string::npos) {
+ symbol = uri.substr(last_hash + 1);
+ } else if (last_hash == string::npos) {
+ symbol = uri.substr(last_slash + 1);
+ } else {
+ size_t first_delim = std::min(last_slash, last_hash);
+ size_t last_delim = std::max(last_slash, last_hash);
+ if (isalpha(uri.str()[last_delim + 1]))
+ symbol = uri.str().substr(last_delim + 1);
+ else
+ symbol = uri.str().substr(first_delim + 1, last_delim - first_delim - 1);
+ }
+ set_property("lv2:symbol", Atom(Atom::STRING, symbol));
+ }
+}
+
+
+const std::string
+PluginModel::symbol()
+{
+ const Atom& val = get_property("lv2:symbol");
+ if (val.is_valid() && val.type() == Atom::STRING)
+ return val.get_string();
+
+#ifdef HAVE_SLV2
+ SLV2Value lv2_symbol_pred = slv2_value_new_uri(_slv2_world,
+ "http://lv2plug.in/ns/lv2core#symbol");
+ SLV2Values symbols = slv2_plugin_get_value(_slv2_plugin, lv2_symbol_pred);
+ for (unsigned i = 0; i < slv2_values_size(symbols); ++i) {
+ SLV2Value val = slv2_values_get_at(symbols, 0);
+ if (slv2_value_is_string(val)) {
+ cerr << uri() << " FOUND SYMBOL: " << slv2_value_as_string(val) << endl;
+ set_property("lv2:symbol", Atom(Atom::STRING, slv2_value_as_string(val)));
+ break;
+ }
+ }
+ slv2_values_free(symbols);
+ slv2_value_free(lv2_symbol_pred);
+#endif
+
+ return string_property("lv2:symbol");
+}
+
+
+const std::string
+PluginModel::name()
+{
+ return string_property("doap:name");
}
string
-PluginModel::default_node_symbol() const
+PluginModel::default_node_symbol()
{
return Raul::Path::nameify(symbol());
}
diff --git a/src/client/PluginModel.hpp b/src/client/PluginModel.hpp
index 7013d819..19499be0 100644
--- a/src/client/PluginModel.hpp
+++ b/src/client/PluginModel.hpp
@@ -50,10 +50,10 @@ public:
Type type() const { return _type; }
- const std::string symbol() const { return string_property("lv2:symbol"); }
- const std::string name() const { return string_property("doap:name"); }
+ const std::string symbol();
+ const std::string name();
- std::string default_node_symbol() const;
+ std::string default_node_symbol();
std::string human_name();
std::string port_human_name(uint32_t index) const;
diff --git a/src/client/SigClientInterface.hpp b/src/client/SigClientInterface.hpp
index 857c575d..6efbdd8e 100644
--- a/src/client/SigClientInterface.hpp
+++ b/src/client/SigClientInterface.hpp
@@ -50,7 +50,6 @@ public:
sigc::signal<void> signal_bundle_begin;
sigc::signal<void> signal_bundle_end;
sigc::signal<void, std::string> signal_error;
- sigc::signal<void, Raul::URI, Raul::URI, Raul::Symbol> signal_new_plugin;
sigc::signal<void, Raul::Path, uint32_t> signal_new_patch;
sigc::signal<void, Raul::Path, Raul::URI, uint32_t, bool> signal_new_port;
sigc::signal<void, Raul::URI, Shared::Resource::Properties> signal_put;
@@ -95,9 +94,6 @@ protected:
void error(const std::string& msg)
{ if (_enabled) signal_error.emit(msg); }
- void new_plugin(const Raul::URI& uri, const Raul::URI& type_uri, const Raul::Symbol& symbol)
- { if (_enabled) signal_new_plugin.emit(uri, type_uri, symbol); }
-
void put(const Raul::URI& path, const Shared::Resource::Properties& properties)
{ if (_enabled) signal_put.emit(path, properties); }
diff --git a/src/client/ThreadedSigClientInterface.hpp b/src/client/ThreadedSigClientInterface.hpp
index d83e3334..eda3bfb2 100644
--- a/src/client/ThreadedSigClientInterface.hpp
+++ b/src/client/ThreadedSigClientInterface.hpp
@@ -50,7 +50,6 @@ public:
, response_ok_slot(signal_response_ok.make_slot())
, response_error_slot(signal_response_error.make_slot())
, error_slot(signal_error.make_slot())
- , new_plugin_slot(signal_new_plugin.make_slot())
, new_port_slot(signal_new_port.make_slot())
, put_slot(signal_put.make_slot())
, connection_slot(signal_connection.make_slot())
@@ -89,9 +88,6 @@ public:
void error(const std::string& msg)
{ push_sig(sigc::bind(error_slot, msg)); }
- void new_plugin(const Raul::URI& uri, const Raul::URI& type_uri, const Raul::Symbol& symbol)
- { push_sig(sigc::bind(new_plugin_slot, uri, type_uri, symbol)); }
-
void put(const Raul::URI& path, const Shared::Resource::Properties& properties)
{ push_sig(sigc::bind(put_slot, path, properties)); }