Chris@1178
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@1178
|
2
|
Chris@1178
|
3 /*
|
Chris@1178
|
4 Sonic Visualiser
|
Chris@1178
|
5 An audio file viewer and annotation editor.
|
Chris@1178
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@1178
|
7
|
Chris@1178
|
8 This program is free software; you can redistribute it and/or
|
Chris@1178
|
9 modify it under the terms of the GNU General Public License as
|
Chris@1178
|
10 published by the Free Software Foundation; either version 2 of the
|
Chris@1178
|
11 License, or (at your option) any later version. See the file
|
Chris@1178
|
12 COPYING included with this distribution for more information.
|
Chris@1178
|
13 */
|
Chris@1178
|
14
|
Chris@1178
|
15 #include "PluginScan.h"
|
Chris@1178
|
16
|
Chris@1178
|
17 #include "base/Debug.h"
|
Chris@1178
|
18
|
Chris@1178
|
19 #include <QMutex>
|
Chris@1178
|
20
|
Chris@1178
|
21 using std::string;
|
Chris@1178
|
22
|
Chris@1178
|
23 PluginScan *PluginScan::getInstance() {
|
Chris@1178
|
24 static QMutex mutex;
|
Chris@1178
|
25 static PluginScan *m_instance = 0;
|
Chris@1178
|
26 mutex.lock();
|
Chris@1178
|
27 if (!m_instance) m_instance = new PluginScan();
|
Chris@1178
|
28 mutex.unlock();
|
Chris@1178
|
29 return m_instance;
|
Chris@1178
|
30 }
|
Chris@1178
|
31
|
Chris@1179
|
32 PluginScan::PluginScan() : m_kp(0), m_succeeded(false) {
|
Chris@1178
|
33 }
|
Chris@1178
|
34
|
Chris@1178
|
35 PluginScan::~PluginScan() {
|
Chris@1178
|
36 delete m_kp;
|
Chris@1178
|
37 }
|
Chris@1178
|
38
|
Chris@1178
|
39 void
|
Chris@1178
|
40 PluginScan::log(string message)
|
Chris@1178
|
41 {
|
Chris@1178
|
42 SVDEBUG << "PluginScan: " << message;
|
Chris@1178
|
43 }
|
Chris@1178
|
44
|
Chris@1178
|
45 void
|
Chris@1178
|
46 PluginScan::scan()
|
Chris@1178
|
47 {
|
Chris@1178
|
48 delete m_kp;
|
Chris@1179
|
49 m_succeeded = false;
|
Chris@1179
|
50 try {
|
Chris@1179
|
51 m_kp = new KnownPlugins("./helper", this); //!!!
|
Chris@1179
|
52 m_succeeded = true;
|
Chris@1179
|
53 } catch (const std::exception &e) {
|
Chris@1179
|
54 cerr << "ERROR: PluginScan::scan: " << e.what() << endl;
|
Chris@1179
|
55 m_kp = 0;
|
Chris@1179
|
56 }
|
Chris@1179
|
57 }
|
Chris@1179
|
58
|
Chris@1179
|
59 QStringList
|
Chris@1179
|
60 PluginScan::getCandidateLibrariesFor(KnownPlugins::PluginType type) const
|
Chris@1179
|
61 {
|
Chris@1179
|
62 QStringList candidates;
|
Chris@1179
|
63 if (!m_kp) return candidates;
|
Chris@1179
|
64 auto c = m_kp->getCandidateLibrariesFor(type);
|
Chris@1179
|
65 for (auto s: c) candidates.push_back(s.c_str());
|
Chris@1179
|
66 return candidates;
|
Chris@1178
|
67 }
|
Chris@1178
|
68
|
Chris@1178
|
69 QStringList
|
Chris@1178
|
70 PluginScan::getCandidateVampLibraries() const
|
Chris@1178
|
71 {
|
Chris@1179
|
72 return getCandidateLibrariesFor(KnownPlugins::VampPlugin);
|
Chris@1178
|
73 }
|
Chris@1178
|
74
|
Chris@1178
|
75 QStringList
|
Chris@1178
|
76 PluginScan::getCandidateLADSPALibraries() const
|
Chris@1178
|
77 {
|
Chris@1179
|
78 return getCandidateLibrariesFor(KnownPlugins::LADSPAPlugin);
|
Chris@1178
|
79 }
|
Chris@1178
|
80
|
Chris@1178
|
81 QStringList
|
Chris@1178
|
82 PluginScan::getCandidateDSSILibraries() const
|
Chris@1178
|
83 {
|
Chris@1179
|
84 return getCandidateLibrariesFor(KnownPlugins::DSSIPlugin);
|
Chris@1178
|
85 }
|
Chris@1178
|
86
|
Chris@1178
|
87 QString
|
Chris@1178
|
88 PluginScan::getStartupFailureReport() const
|
Chris@1178
|
89 {
|
Chris@1179
|
90 if (!m_succeeded) {
|
Chris@1179
|
91 return QObject::tr("<b>Failed to scan for plugins</b>"
|
Chris@1179
|
92 "<p>Failed to scan for plugins at startup "
|
Chris@1179
|
93 "(application installation problem?)</p>");
|
Chris@1179
|
94 }
|
Chris@1179
|
95 if (!m_kp) {
|
Chris@1179
|
96 return QObject::tr("<b>Did not scan for plugins</b>"
|
Chris@1179
|
97 "<p>Apparently no scan for plugins was attempted "
|
Chris@1179
|
98 "(internal error?)</p>");
|
Chris@1179
|
99 }
|
Chris@1179
|
100
|
Chris@1178
|
101 string report = m_kp->getFailureReport();
|
Chris@1179
|
102 if (report == "") {
|
Chris@1179
|
103 return QString(report.c_str());
|
Chris@1179
|
104 }
|
Chris@1179
|
105
|
Chris@1179
|
106 return QObject::tr("<b>Failed to load plugins</b>"
|
Chris@1179
|
107 "<p>Failed to load one or more plugin libraries:</p>")
|
Chris@1179
|
108 + QString(report.c_str());
|
Chris@1178
|
109 }
|
Chris@1178
|
110
|