/*
- Copyright (C) 2000-2002 Paul Davis
+ Copyright (C) 2000-2002 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
+#ifdef WAF_BUILD
+#include "libardour-config.h"
+#endif
+
#include <vector>
#include <string>
uint32_t id;
std::string unique (unique_id());
- /* XXX problem: AU plugins don't have numeric ID's.
+ /* XXX problem: AU plugins don't have numeric ID's.
Solution: they have a different method of providing presets.
XXX sub-problem: implement it.
*/
}
bool
-Plugin::load_preset(const string preset_uri)
+Plugin::load_preset(const string& preset_uri)
{
lrdf_defaults* defs = lrdf_get_setting_values(preset_uri.c_str());
if (defs) {
for (uint32_t i = 0; i < (uint32_t) defs->count; ++i) {
- // The defs->items[i].pid < defs->count check is to work around
+ // The defs->items[i].pid < defs->count check is to work around
// a bug in liblrdf that saves invalid values into the presets file.
if (((uint32_t) defs->items[i].pid < (uint32_t) defs->count) && parameter_is_input (defs->items[i].pid)) {
set_parameter(defs->items[i].pid, defs->items[i].value);
}
bool
-Plugin::save_preset (string uri, string domain)
+Plugin::save_preset (string name, string domain)
{
lrdf_portvalue portvalues[parameter_count()];
lrdf_defaults defaults;
uint32_t id;
std::string unique (unique_id());
- /* XXX problem: AU plugins don't have numeric ID's.
+ /* XXX problem: AU plugins don't have numeric ID's.
Solution: they have a different method of providing/saving presets.
XXX sub-problem: implement it.
*/
warning << _("Could not locate HOME. Preset not saved.") << endmsg;
return false;
}
-
+
string source(string_compose("file:%1/.%2/rdf/ardour-presets.n3", envvar, domain));
- map<string,PresetRecord>::const_iterator pr = presets.find(uri);
- if (pr == presets.end()) {
- warning << _("Could not find preset ") << uri << endmsg;
- return false;
- }
- free(lrdf_add_preset(source.c_str(), pr->second.label.c_str(), id, &defaults));
+ char* uri = lrdf_add_preset (source.c_str(), name.c_str(), id, &defaults);
+
+ /* XXX: why is the uri apparently kept as the key in the `presets' map and also in the PresetRecord? */
+
+ presets.insert (make_pair (uri, PresetRecord (uri, name)));
+ free (uri);
string path = string_compose("%1/.%2", envvar, domain);
if (g_mkdir_with_parents (path.c_str(), 0775)) {
warning << string_compose(_("Could not create %1. Preset not saved. (%2)"), path, strerror(errno)) << endmsg;
return false;
}
-
+
path += "/rdf";
if (g_mkdir_with_parents (path.c_str(), 0775)) {
warning << string_compose(_("Could not create %1. Preset not saved. (%2)"), path, strerror(errno)) << endmsg;
return false;
}
-
+
if (lrdf_export_by_source(source.c_str(), source.substr(5).c_str())) {
warning << string_compose(_("Error saving presets file %1."), source) << endmsg;
return false;
case ARDOUR::LADSPA:
plugs = mgr->ladspa_plugin_info();
break;
-
+
#ifdef HAVE_SLV2
case ARDOUR::LV2:
plugs = mgr->lv2_plugin_info();
}
}
#endif
-
+
return PluginPtr ((Plugin*) 0);
}