24 #include <QCoreApplication> 29 #ifdef HAVE_PLUGIN_CHECKER_HELPER
30 :
public PluginCandidates::LogCallback
34 void log(std::string message)
35 #ifdef HAVE_PLUGIN_CHECKER_HELPER 39 SVDEBUG <<
"PluginScan: " << message << endl;
48 if (!m_instance) m_instance =
new PluginScan();
60 SVDEBUG <<
"PluginScan::~PluginScan completed" << endl;
66 #ifdef HAVE_PLUGIN_CHECKER_HELPER 76 QString helperName(
"vamp-plugin-load-checker");
81 for (
auto p: helpers) {
82 SVDEBUG <<
"NOTE: PluginScan: Found helper: " << p.executable << endl;
85 if (helpers.empty()) {
86 SVDEBUG <<
"NOTE: No plugin checker helpers found in installation;" 87 <<
" found none of the following:" << endl;
89 SVDEBUG <<
"NOTE: " << d << endl;
93 for (
auto p: helpers) {
96 (p.executable.toStdString(),
m_logger);
97 if (
m_kp.find(p.tag) !=
m_kp.end()) {
98 SVDEBUG <<
"WARNING: PluginScan::scan: Duplicate tag " << p.tag
99 <<
" for helpers" << endl;
104 }
catch (
const std::exception &e) {
105 SVDEBUG <<
"ERROR: PluginScan::scan: " << e.what()
106 <<
" (with helper path = " << p.executable <<
")" << endl;
110 SVDEBUG <<
"PluginScan::scan complete" << endl;
124 for (
auto &p:
m_kp) {
131 QList<PluginScan::Candidate>
133 #ifdef HAVE_PLUGIN_CHECKER_HELPER
138 #ifdef HAVE_PLUGIN_CHECKER_HELPER 142 KnownPlugins::PluginType kpt;
144 case VampPlugin: kpt = KnownPlugins::VampPlugin;
break;
145 case LADSPAPlugin: kpt = KnownPlugins::LADSPAPlugin;
break;
146 case DSSIPlugin: kpt = KnownPlugins::DSSIPlugin;
break;
147 default:
throw std::logic_error(
"Inconsistency in plugin type enums");
150 QList<Candidate> candidates;
152 for (
auto rec:
m_kp) {
156 auto c = kp->getCandidateLibrariesFor(kpt);
158 SVDEBUG <<
"PluginScan: helper \"" << kp->getHelperExecutableName()
159 <<
"\" likes " << c.size() <<
" libraries of type " 160 << kp->getTagFor(kpt) << endl;
163 candidates.push_back({ s.c_str(), rec.first });
185 #ifdef HAVE_PLUGIN_CHECKER_HELPER 187 PluginScan::formatFailureReport(QString tag,
188 std::vector<PluginCandidates::FailureRec> failures)
const 190 int n = int(failures.size());
193 std::ostringstream os;
196 for (
auto f: failures) {
197 os <<
"<li><code>" + f.library +
"</code>";
199 SVDEBUG <<
"PluginScan::formatFailureReport: tag is \"" << tag
200 <<
"\", failure code is " << int(f.code) <<
", message is \"" 201 << f.message <<
"\"" << endl;
203 QString userMessage = QString::fromStdString(f.message);
207 case PluginCheckCode::FAIL_LIBRARY_NOT_FOUND:
208 userMessage = QObject::tr(
"Library file could not be opened");
211 case PluginCheckCode::FAIL_WRONG_ARCHITECTURE:
212 if (tag ==
"64" || (
sizeof(
void *) == 8 && tag ==
"")) {
213 userMessage = QObject::tr
214 (
"Library has wrong architecture - possibly a 32-bit plugin installed in a 64-bit plugin folder");
215 }
else if (tag ==
"32" || (
sizeof(
void *) == 4 && tag ==
"")) {
216 userMessage = QObject::tr
217 (
"Library has wrong architecture - possibly a 64-bit plugin installed in a 32-bit plugin folder");
221 case PluginCheckCode::FAIL_DEPENDENCY_MISSING:
222 userMessage = QObject::tr
223 (
"Library depends on another library that cannot be found: %1")
227 case PluginCheckCode::FAIL_NOT_LOADABLE:
228 userMessage = QObject::tr
229 (
"Library cannot be loaded: %1").arg(userMessage);
232 case PluginCheckCode::FAIL_FORBIDDEN:
233 userMessage = QObject::tr
234 (
"Permission to load library was refused");
237 case PluginCheckCode::FAIL_DESCRIPTOR_MISSING:
238 userMessage = QObject::tr
239 (
"Not a valid plugin library (no descriptor found)");
242 case PluginCheckCode::FAIL_NO_PLUGINS:
243 userMessage = QObject::tr
244 (
"Library contains no plugins");
247 case PluginCheckCode::FAIL_OTHER:
248 if (userMessage ==
"") {
249 userMessage = QObject::tr
254 case PluginCheckCode::SUCCESS:
259 os <<
"<br><i>" + userMessage.toStdString() +
"</i>";
265 os << QObject::tr(
"... and %n further failure(s)",
275 return QString::fromStdString(os.str());
282 #ifdef HAVE_PLUGIN_CHECKER_HELPER 287 return QObject::tr(
"<b>Failed to scan for plugins</b>" 288 "<p>Failed to scan for plugins at startup. Possibly " 289 "the plugin checker program was not correctly " 290 "installed alongside %1?</p>")
291 .arg(QCoreApplication::applicationName());
294 return QObject::tr(
"<b>Did not scan for plugins</b>" 295 "<p>Apparently no scan for plugins was attempted " 296 "(internal error?)</p>");
300 for (
auto kp:
m_kp) {
301 auto failures = kp.second->getFailures();
302 if (!failures.empty()) {
303 report += formatFailureReport(kp.first, failures);
310 return QObject::tr(
"<p>Failed to load one or more plugin libraries:</p>")
312 + QObject::tr(
"<p>These plugins may be incompatible with the system, " 313 "and will be ignored during this run of %1.</p>")
314 .arg(QCoreApplication::applicationName());
void log(std::string message)
QList< Candidate > getCandidateLibrariesFor(PluginType) const
Return the candidate plugin libraries of the given type that were found by helpers during the startup...
std::map< QString, KnownPluginCandidates * > m_kp
bool getRunPluginsInProcess() const
static Preferences * getInstance()
static PluginScan * getInstance()
Class to find helper executables that have been installed alongside the application.
void scan()
Carry out startup scan of available plugins.
QStringList getHelperCandidatePaths(QString basename)
Return the list of executable paths examined in the search for the helper executable with the given b...
QList< HelperExec > getHelperExecutables(QString basename)
Find all helper executables with the given base name in the bundle directory or installation location...
bool scanSucceeded() const
Return true if scan() completed successfully.
QString getStartupFailureReport() const