Chris@1472: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@1472: Chris@1472: /* Chris@1472: Sonic Visualiser Chris@1472: An audio file viewer and annotation editor. Chris@1472: Centre for Digital Music, Queen Mary, University of London. Chris@1472: Chris@1472: This program is free software; you can redistribute it and/or Chris@1472: modify it under the terms of the GNU General Public License as Chris@1472: published by the Free Software Foundation; either version 2 of the Chris@1472: License, or (at your option) any later version. See the file Chris@1472: COPYING included with this distribution for more information. Chris@1472: */ Chris@1472: Chris@1472: #ifndef SV_PLUGIN_PATH_SETTER_H Chris@1472: #define SV_PLUGIN_PATH_SETTER_H Chris@1472: Chris@1472: #include Chris@1472: #include Chris@1472: #include Chris@1472: Chris@1472: #include Chris@1472: Chris@1481: #include "checker/knownplugins.h" Chris@1481: Chris@1472: class PluginPathSetter Chris@1472: { Chris@1472: public: Chris@1481: typedef std::pair TypeKey; Chris@1481: Chris@1481: typedef std::vector TypeKeys; Chris@1472: Chris@1472: struct PathConfig { Chris@1473: QStringList directories; // Actual list of directories arising Chris@1473: // from user settings, environment Chris@1473: // variables, and defaults as Chris@1473: // appropriate Chris@1473: Chris@1473: QString envVariable; // Name of env var, e.g. LADSPA_PATH Chris@1473: Chris@1473: bool useEnvVariable; // True if env variable should override Chris@1473: // any user settings for this Chris@1472: }; Chris@1472: Chris@1481: typedef std::map Paths; Chris@1472: Chris@1473: /// Update *_PATH environment variables from the settings, on Chris@1473: /// application startup. Must be called exactly once, before any Chris@1473: /// of the other functions in this class has been called Chris@1473: static void initialiseEnvironmentVariables(); Chris@1473: Chris@1473: /// Return default values of paths only, without any environment Chris@1473: /// variables or user-defined preferences Chris@1472: static Paths getDefaultPaths(); Chris@1472: Chris@1473: /// Return paths arising from environment variables only, falling Chris@1473: /// back to the defaults, without any user-defined preferences Chris@1473: static Paths getEnvironmentPaths(); Chris@1473: Chris@1472: /// Return paths arising from user settings + environment Chris@1473: /// variables + defaults as appropriate Chris@1472: static Paths getPaths(); Chris@1472: Chris@1472: /// Save the given paths to the settings Chris@1472: static void savePathSettings(Paths paths); Chris@1472: Chris@1473: /// Return the original value observed on startup for the given Chris@1473: /// environment variable, if it is one of the variables used by a Chris@1473: /// known path config. Chris@1473: static QString getOriginalEnvironmentValue(QString envVariable); Chris@1473: Chris@1472: private: Chris@1472: static Paths m_defaultPaths; Chris@1473: static Paths m_environmentPaths; Chris@1473: static std::map m_originalEnvValues; Chris@1481: static TypeKeys m_supportedKeys; Chris@1472: static QMutex m_mutex; Chris@1473: Chris@1481: static std::vector getSupportedKeys(); Chris@1481: static Paths getEnvironmentPathsUncached(const TypeKeys &keys); Chris@1481: static QString getSettingTagFor(TypeKey); Chris@1472: }; Chris@1472: Chris@1472: #endif