comparison plugin/PluginScan.cpp @ 1179:6b1af0f05f06 pluginscan

Make use of, and warn for, the plugin checker for all types of plugin. Haven't yet resolved the question of how to install and find it.
author Chris Cannam
date Thu, 14 Apr 2016 14:03:18 +0100
parents bf05d9259dbc
children 98664afd518b
comparison
equal deleted inserted replaced
1178:bf05d9259dbc 1179:6b1af0f05f06
27 if (!m_instance) m_instance = new PluginScan(); 27 if (!m_instance) m_instance = new PluginScan();
28 mutex.unlock(); 28 mutex.unlock();
29 return m_instance; 29 return m_instance;
30 } 30 }
31 31
32 PluginScan::PluginScan() : m_kp(0) { 32 PluginScan::PluginScan() : m_kp(0), m_succeeded(false) {
33 } 33 }
34 34
35 PluginScan::~PluginScan() { 35 PluginScan::~PluginScan() {
36 delete m_kp; 36 delete m_kp;
37 } 37 }
44 44
45 void 45 void
46 PluginScan::scan() 46 PluginScan::scan()
47 { 47 {
48 delete m_kp; 48 delete m_kp;
49 m_kp = new KnownPlugins("./helper", this); //!!! 49 m_succeeded = false;
50 try {
51 m_kp = new KnownPlugins("./helper", this); //!!!
52 m_succeeded = true;
53 } catch (const std::exception &e) {
54 cerr << "ERROR: PluginScan::scan: " << e.what() << endl;
55 m_kp = 0;
56 }
57 }
58
59 QStringList
60 PluginScan::getCandidateLibrariesFor(KnownPlugins::PluginType type) const
61 {
62 QStringList candidates;
63 if (!m_kp) return candidates;
64 auto c = m_kp->getCandidateLibrariesFor(type);
65 for (auto s: c) candidates.push_back(s.c_str());
66 return candidates;
50 } 67 }
51 68
52 QStringList 69 QStringList
53 PluginScan::getCandidateVampLibraries() const 70 PluginScan::getCandidateVampLibraries() const
54 { 71 {
55 QStringList candidates; 72 return getCandidateLibrariesFor(KnownPlugins::VampPlugin);
56 if (!m_kp) return candidates;
57 auto c = m_kp->getCandidateLibrariesFor(KnownPlugins::VampPlugin);
58 for (auto s: c) candidates.push_back(s.c_str());
59 return candidates;
60 } 73 }
61 74
62 QStringList 75 QStringList
63 PluginScan::getCandidateLADSPALibraries() const 76 PluginScan::getCandidateLADSPALibraries() const
64 { 77 {
65 QStringList candidates; 78 return getCandidateLibrariesFor(KnownPlugins::LADSPAPlugin);
66 if (!m_kp) return candidates;
67 auto c = m_kp->getCandidateLibrariesFor(KnownPlugins::LADSPAPlugin);
68 for (auto s: c) candidates.push_back(s.c_str());
69 return candidates;
70 } 79 }
71 80
72 QStringList 81 QStringList
73 PluginScan::getCandidateDSSILibraries() const 82 PluginScan::getCandidateDSSILibraries() const
74 { 83 {
75 QStringList candidates; 84 return getCandidateLibrariesFor(KnownPlugins::DSSIPlugin);
76 if (!m_kp) return candidates;
77 auto c = m_kp->getCandidateLibrariesFor(KnownPlugins::DSSIPlugin);
78 for (auto s: c) candidates.push_back(s.c_str());
79 return candidates;
80 } 85 }
81 86
82 QString 87 QString
83 PluginScan::getStartupFailureReport() const 88 PluginScan::getStartupFailureReport() const
84 { 89 {
85 if (!m_kp) return ""; //!!!??? 90 if (!m_succeeded) {
91 return QObject::tr("<b>Failed to scan for plugins</b>"
92 "<p>Failed to scan for plugins at startup "
93 "(application installation problem?)</p>");
94 }
95 if (!m_kp) {
96 return QObject::tr("<b>Did not scan for plugins</b>"
97 "<p>Apparently no scan for plugins was attempted "
98 "(internal error?)</p>");
99 }
100
86 string report = m_kp->getFailureReport(); 101 string report = m_kp->getFailureReport();
87 return report.c_str(); //!!! wrap? 102 if (report == "") {
103 return QString(report.c_str());
104 }
105
106 return QObject::tr("<b>Failed to load plugins</b>"
107 "<p>Failed to load one or more plugin libraries:</p>")
108 + QString(report.c_str());
88 } 109 }
89 110