Chris@1472
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@1472
|
2
|
Chris@1472
|
3 /*
|
Chris@1472
|
4 Sonic Visualiser
|
Chris@1472
|
5 An audio file viewer and annotation editor.
|
Chris@1472
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@1472
|
7
|
Chris@1472
|
8 This program is free software; you can redistribute it and/or
|
Chris@1472
|
9 modify it under the terms of the GNU General Public License as
|
Chris@1472
|
10 published by the Free Software Foundation; either version 2 of the
|
Chris@1472
|
11 License, or (at your option) any later version. See the file
|
Chris@1472
|
12 COPYING included with this distribution for more information.
|
Chris@1472
|
13 */
|
Chris@1472
|
14
|
Chris@1472
|
15 #ifndef SV_PLUGIN_PATH_SETTER_H
|
Chris@1472
|
16 #define SV_PLUGIN_PATH_SETTER_H
|
Chris@1472
|
17
|
Chris@1472
|
18 #include <QString>
|
Chris@1472
|
19 #include <QStringList>
|
Chris@1472
|
20 #include <QMutex>
|
Chris@1472
|
21
|
Chris@1472
|
22 #include <map>
|
Chris@1472
|
23
|
Chris@1472
|
24 class PluginPathSetter
|
Chris@1472
|
25 {
|
Chris@1472
|
26 public:
|
Chris@1472
|
27 /// Text used to identify a plugin type, e.g. "LADSPA", "Vamp"
|
Chris@1472
|
28 typedef QString PluginTypeLabel;
|
Chris@1472
|
29
|
Chris@1472
|
30 struct PathConfig {
|
Chris@1473
|
31 QStringList directories; // Actual list of directories arising
|
Chris@1473
|
32 // from user settings, environment
|
Chris@1473
|
33 // variables, and defaults as
|
Chris@1473
|
34 // appropriate
|
Chris@1473
|
35
|
Chris@1473
|
36 QString envVariable; // Name of env var, e.g. LADSPA_PATH
|
Chris@1473
|
37
|
Chris@1473
|
38 bool useEnvVariable; // True if env variable should override
|
Chris@1473
|
39 // any user settings for this
|
Chris@1472
|
40 };
|
Chris@1472
|
41
|
Chris@1472
|
42 typedef std::map<PluginTypeLabel, PathConfig> Paths;
|
Chris@1472
|
43
|
Chris@1473
|
44 /// Update *_PATH environment variables from the settings, on
|
Chris@1473
|
45 /// application startup. Must be called exactly once, before any
|
Chris@1473
|
46 /// of the other functions in this class has been called
|
Chris@1473
|
47 static void initialiseEnvironmentVariables();
|
Chris@1473
|
48
|
Chris@1473
|
49 /// Return default values of paths only, without any environment
|
Chris@1473
|
50 /// variables or user-defined preferences
|
Chris@1472
|
51 static Paths getDefaultPaths();
|
Chris@1472
|
52
|
Chris@1473
|
53 /// Return paths arising from environment variables only, falling
|
Chris@1473
|
54 /// back to the defaults, without any user-defined preferences
|
Chris@1473
|
55 static Paths getEnvironmentPaths();
|
Chris@1473
|
56
|
Chris@1472
|
57 /// Return paths arising from user settings + environment
|
Chris@1473
|
58 /// variables + defaults as appropriate
|
Chris@1472
|
59 static Paths getPaths();
|
Chris@1472
|
60
|
Chris@1472
|
61 /// Save the given paths to the settings
|
Chris@1472
|
62 static void savePathSettings(Paths paths);
|
Chris@1472
|
63
|
Chris@1473
|
64 /// Return the original value observed on startup for the given
|
Chris@1473
|
65 /// environment variable, if it is one of the variables used by a
|
Chris@1473
|
66 /// known path config.
|
Chris@1473
|
67 static QString getOriginalEnvironmentValue(QString envVariable);
|
Chris@1473
|
68
|
Chris@1472
|
69 private:
|
Chris@1472
|
70 static Paths m_defaultPaths;
|
Chris@1473
|
71 static Paths m_environmentPaths;
|
Chris@1473
|
72 static std::map<QString, QString> m_originalEnvValues;
|
Chris@1472
|
73 static QMutex m_mutex;
|
Chris@1473
|
74
|
Chris@1473
|
75 static Paths getEnvironmentPathsUncached();
|
Chris@1472
|
76 };
|
Chris@1472
|
77
|
Chris@1472
|
78 #endif
|