summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-08-12 04:46:29 +0000
committerDavid Robillard <d@drobilla.net>2015-08-12 04:46:29 +0000
commitdd79e76e41446833088482588456afed37231bff (patch)
treec0f3c5c2fc74b286d529df69ad2206e2fddd96f9 /src/client
parent44af7b7b66e2083819103c760ab3bf4980469f86 (diff)
downloadingen-dd79e76e41446833088482588456afed37231bff.tar.gz
ingen-dd79e76e41446833088482588456afed37231bff.tar.bz2
ingen-dd79e76e41446833088482588456afed37231bff.zip
Server-side presets.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5703 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/client')
-rw-r--r--src/client/BlockModel.cpp4
-rw-r--r--src/client/ClientStore.cpp53
-rw-r--r--src/client/PluginModel.cpp27
-rw-r--r--src/client/PluginUI.cpp2
4 files changed, 57 insertions, 29 deletions
diff --git a/src/client/BlockModel.cpp b/src/client/BlockModel.cpp
index 13b15012..67261dba 100644
--- a/src/client/BlockModel.cpp
+++ b/src/client/BlockModel.cpp
@@ -174,7 +174,7 @@ BlockModel::default_port_value_range(SPtr<const PortModel> port,
max = 1.0;
// Get range from client-side LV2 data
- if (_plugin && _plugin->type() == PluginModel::LV2 && _plugin->lilv_plugin()) {
+ if (_plugin && _plugin->lilv_plugin()) {
if (!_min_values) {
_num_values = lilv_plugin_get_num_ports(_plugin->lilv_plugin());
_min_values = new float[_num_values];
@@ -243,7 +243,7 @@ BlockModel::port_label(SPtr<const PortModel> port) const
return name.ptr<char>();
}
- if (_plugin && _plugin->type() == PluginModel::LV2) {
+ if (_plugin && _plugin->lilv_plugin()) {
LilvWorld* w = _plugin->lilv_world();
const LilvPlugin* plug = _plugin->lilv_plugin();
LilvNode* sym = lilv_new_string(w, port->symbol().c_str());
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp
index 31ef4d47..5adf7f52 100644
--- a/src/client/ClientStore.cpp
+++ b/src/client/ClientStore.cpp
@@ -136,11 +136,18 @@ ClientStore::remove_object(const Raul::Path& path)
SPtr<PluginModel>
ClientStore::_plugin(const Raul::URI& uri)
{
- Plugins::iterator i = _plugins->find(uri);
- if (i == _plugins->end())
- return SPtr<PluginModel>();
- else
- return (*i).second;
+ const Plugins::iterator i = _plugins->find(uri);
+ return (i == _plugins->end()) ? SPtr<PluginModel>() : (*i).second;
+}
+
+SPtr<PluginModel>
+ClientStore::_plugin(const Atom& uri)
+{
+ /* FIXME: SHould probably be stored with URIs rather than strings, to make this
+ a fast case. */
+
+ const Plugins::iterator i = _plugins->find(Raul::URI(_uris.forge.str(uri, false)));
+ return (i == _plugins->end()) ? SPtr<PluginModel>() : (*i).second;
}
SPtr<const PluginModel>
@@ -241,17 +248,31 @@ ClientStore::put(const Raul::URI& uri,
Resource::type(uris(), properties,
is_graph, is_block, is_port, is_output);
- // Check if uri is a plugin
- Iterator t = properties.find(_uris.rdf_type);
- if (t != properties.end() && t->second.type() == _uris.forge.URI) {
- const Atom& type(t->second);
- const Raul::URI type_uri(type.ptr<char>());
- const Plugin::Type plugin_type(Plugin::type_from_uri(type_uri));
- if (plugin_type == Plugin::Graph) {
+ // Check for specially handled types
+ const Iterator t = properties.find(_uris.rdf_type);
+ if (t != properties.end()) {
+ const Atom& type(t->second);
+ if (_uris.pset_Preset == type) {
+ const Iterator p = properties.find(_uris.lv2_appliesTo);
+ const Iterator l = properties.find(_uris.rdfs_label);
+ SPtr<PluginModel> plug;
+ if (p == properties.end()) {
+ _log.error(fmt("Preset <%1%> with no plugin\n") % uri.c_str());
+ } else if (l == properties.end()) {
+ _log.error(fmt("Preset <%1%> with no label\n") % uri.c_str());
+ } else if (l->second.type() != _uris.forge.String) {
+ _log.error(fmt("Preset <%1%> label is not a string\n") % uri.c_str());
+ } else if (!(plug = _plugin(p->second))) {
+ _log.error(fmt("Preset <%1%> for unknown plugin %2%\n")
+ % uri.c_str() % _uris.forge.str(p->second));
+ } else {
+ plug->add_preset(uri, l->second.ptr<char>());
+ }
+ return;
+ } else if (_uris.ingen_Graph == type) {
is_graph = true;
- } else if (plugin_type != Plugin::NIL) {
- SPtr<PluginModel> p(
- new PluginModel(uris(), uri, type_uri, properties));
+ } else if (_uris.ingen_Internal == type || _uris.lv2_Plugin == type) {
+ SPtr<PluginModel> p(new PluginModel(uris(), uri, type, properties));
add_plugin(p);
return;
}
@@ -292,7 +313,7 @@ ClientStore::put(const Raul::URI& uri,
new PluginModel(
uris(),
Raul::URI(p->second.ptr<char>()),
- Raul::URI("http://www.w3.org/2002/07/owl#Nothing"),
+ Atom(),
Resource::Properties()));
add_plugin(plug);
}
diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp
index f228863c..3a1f3a9a 100644
--- a/src/client/PluginModel.cpp
+++ b/src/client/PluginModel.cpp
@@ -42,28 +42,28 @@ Sord::World* PluginModel::_rdf_world = NULL;
PluginModel::PluginModel(URIs& uris,
const Raul::URI& uri,
- const Raul::URI& type_uri,
+ const Atom& type,
const Resource::Properties& properties)
- : Plugin(uris, uri)
- , _type(type_from_uri(type_uri))
+ : Resource(uris, uri)
+ , _type(type)
+ , _fetched(false)
{
- if (_type == NIL) {
+ if (!_type.is_valid()) {
if (uri.find("ingen-internals") != string::npos) {
- _type = Internal;
+ _type = uris.ingen_Internal;
} else {
- _type = LV2; // Assume LV2 and hope Lilv can tell us something
+ _type = uris.lv2_Plugin; // Assume LV2 and hope for the best...
}
}
+
+ add_property(uris.rdf_type, type);
add_properties(properties);
- assert(_rdf_world);
- add_property(uris.rdf_type,
- uris.forge.alloc_uri(this->type_uri()));
LilvNode* plugin_uri = lilv_new_uri(_lilv_world, uri.c_str());
_lilv_plugin = lilv_plugins_get_by_uri(_lilv_plugins, plugin_uri);
lilv_node_free(plugin_uri);
- if (_type == Internal) {
+ if (uris.ingen_Internal == _type) {
set_property(uris.doap_name,
uris.forge.alloc(uri.substr(uri.find_last_of('#') + 1)));
}
@@ -166,6 +166,13 @@ PluginModel::set(SPtr<PluginModel> p)
_signal_changed.emit();
}
+void
+PluginModel::add_preset(const Raul::URI& uri, const std::string& label)
+{
+ _presets.insert(std::make_pair(uri, label));
+ _signal_preset.emit(uri, label);
+}
+
Raul::Symbol
PluginModel::default_block_symbol() const
{
diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp
index f959fd3b..69e9eb95 100644
--- a/src/client/PluginUI.cpp
+++ b/src/client/PluginUI.cpp
@@ -75,7 +75,7 @@ lv2_ui_write(SuilController controller,
uris.ingen_value,
ui->world()->forge().make(value));
- } else if (format == uris.atom_eventTransfer.id) {
+ } else if (format == uris.atom_eventTransfer.urid.get<LV2_URID>()) {
const LV2_Atom* atom = (const LV2_Atom*)buffer;
Atom val = ui->world()->forge().alloc(
atom->size, atom->type, LV2_ATOM_BODY_CONST(atom));