17 #include <vamp-hostsdk/PluginHostAdapter.h> 24 #include <QMutexLocker> 39 std::map<QString, QString>
50 QMutexLocker locker(&m_mutex);
52 if (!m_supportedKeys.empty()) {
53 return m_supportedKeys;
57 keys.push_back({ KnownPlugins::VampPlugin, KnownPlugins::FormatNative });
64 if (execs.size() > 1) {
66 KnownPlugins::VampPlugin, KnownPlugins::FormatNonNative32Bit });
69 keys.push_back({ KnownPlugins::LADSPAPlugin, KnownPlugins::FormatNative });
70 keys.push_back({ KnownPlugins::DSSIPlugin, KnownPlugins::FormatNative });
72 m_supportedKeys = keys;
84 KnownPlugins kp(k.second);
86 auto path = kp.getPathFor(k.first);
89 qPath.push_back(QString::fromStdString(s));
92 auto var = kp.getPathEnvironmentVariableFor(k.first);
93 QString qVar = QString::fromStdString(var);
95 paths[k] = { qPath, qVar,
true };
106 QMutexLocker locker(&m_mutex);
112 KnownPlugins kp(k.second);
114 auto path = kp.getDefaultPathFor(k.first);
117 qPath.push_back(QString::fromStdString(s));
120 auto var = kp.getPathEnvironmentVariableFor(k.first);
121 QString qVar = QString::fromStdString(var);
123 paths[k] = { qPath, qVar,
true };
134 QMutexLocker locker(&m_mutex);
136 if (!m_environmentPaths.empty()) {
137 return m_environmentPaths;
140 m_environmentPaths = getEnvironmentPathsUncached(keys);
141 return m_environmentPaths;
147 string tag = KnownPlugins(tk.second).getTagFor(tk.first);
148 if (tk.second == KnownPlugins::FormatNonNative32Bit) {
151 return QString::fromStdString(tag);
157 Paths paths = getEnvironmentPaths();
160 settings.beginGroup(
"Plugins");
162 for (
auto p: paths) {
166 QString settingTag = getSettingTagFor(tk);
168 QStringList directories =
169 settings.value(QString(
"directories-%1").arg(settingTag),
170 p.second.directories)
172 QString envVariable =
173 settings.value(QString(
"env-variable-%1").arg(settingTag),
174 p.second.envVariable)
176 bool useEnvVariable =
177 settings.value(QString(
"use-env-variable-%1").arg(settingTag),
178 p.second.useEnvVariable)
181 string envVarStr = envVariable.toStdString();
185 if (currentValue !=
"" && useEnvVariable) {
186 directories = QString::fromStdString(currentValue).split(
195 paths[tk] = { directories, envVariable, useEnvVariable };
207 settings.beginGroup(
"Plugins");
209 for (
auto p: paths) {
210 QString settingTag = getSettingTagFor(p.first);
211 settings.setValue(QString(
"directories-%1").arg(settingTag),
212 p.second.directories);
213 settings.setValue(QString(
"env-variable-%1").arg(settingTag),
214 p.second.envVariable);
215 settings.setValue(QString(
"use-env-variable-%1").arg(settingTag),
216 p.second.useEnvVariable);
225 if (m_originalEnvValues.find(envVariable) != m_originalEnvValues.end()) {
226 return m_originalEnvValues.at(envVariable);
242 (void)getDefaultPaths();
243 (void)getEnvironmentPaths();
245 Paths paths = getPaths();
247 for (
auto p: paths) {
248 QString envVariable = p.second.envVariable;
249 string envVarStr = envVariable.toStdString();
252 m_originalEnvValues[envVariable] = QString::fromStdString(currentValue);
253 if (currentValue !=
"" && p.second.useEnvVariable) {
255 SVDEBUG <<
"PluginPathSetter: for environment variable " 256 << envVariable <<
", useEnvVariable setting is false; " 257 <<
"leaving current value alone: it is \"" 258 << currentValue <<
"\"" << endl;
268 QString proposedValue = p.second.directories.join(separator);
269 SVDEBUG <<
"PluginPathSetter: for environment variable " 270 << envVariable <<
", useEnvVariable setting is true or " 271 <<
"variable is currently unset; " 272 <<
"changing value from \"" << currentValue
273 <<
"\" to setting preference of \"" << proposedValue
275 putEnvUtf8(envVarStr, proposedValue.toStdString());
bool putEnvUtf8(std::string variable, std::string value)
Set the value of the given environment variable.
static std::vector< TypeKey > getSupportedKeys()
static QString getSettingTagFor(TypeKey)
static void initialiseEnvironmentVariables()
Update *_PATH environment variables from the settings, on application startup.
bool getEnvUtf8(std::string variable, std::string &value)
Return the value of the given environment variable by reference.
bool getRunPluginsInProcess() const
static Preferences * getInstance()
std::vector< TypeKey > TypeKeys
Class to find helper executables that have been installed alongside the application.
static QString getOriginalEnvironmentValue(QString envVariable)
Return the original value observed on startup for the given environment variable, if it is one of the...
static std::map< QString, QString > m_originalEnvValues
static Paths getDefaultPaths()
Return default values of paths only, without any environment variables or user-defined preferences...
static Paths getPaths()
Return paths arising from user settings + environment variables + defaults as appropriate.
static Paths m_environmentPaths
std::pair< KnownPlugins::PluginType, KnownPlugins::BinaryFormat > TypeKey
static TypeKeys m_supportedKeys
static void savePathSettings(Paths paths)
Save the given paths to the settings.
QList< HelperExec > getHelperExecutables(QString basename)
Find all helper executables with the given base name in the bundle directory or installation location...
static Paths getEnvironmentPathsUncached(const TypeKeys &keys)
static Paths getEnvironmentPaths()
Return paths arising from environment variables only, falling back to the defaults, without any user-defined preferences.
static Paths m_defaultPaths
std::map< TypeKey, PathConfig > Paths