Chris@35: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@35: /* Chris@35: Copyright (c) 2016-2018 Queen Mary, University of London Chris@35: Chris@35: Permission is hereby granted, free of charge, to any person Chris@35: obtaining a copy of this software and associated documentation Chris@35: files (the "Software"), to deal in the Software without Chris@35: restriction, including without limitation the rights to use, copy, Chris@35: modify, merge, publish, distribute, sublicense, and/or sell copies Chris@35: of the Software, and to permit persons to whom the Software is Chris@35: furnished to do so, subject to the following conditions: Chris@35: Chris@35: The above copyright notice and this permission notice shall be Chris@35: included in all copies or substantial portions of the Software. Chris@35: Chris@35: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, Chris@35: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF Chris@35: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND Chris@35: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY Chris@35: CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF Chris@35: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION Chris@35: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Chris@35: Chris@35: Except as contained in this notice, the names of the Centre for Chris@35: Digital Music and Queen Mary, University of London shall not be Chris@35: used in advertising or otherwise to promote the sale, use or other Chris@35: dealings in this Software without prior written authorization. Chris@35: */ Chris@35: Chris@35: #include "knownplugincandidates.h" Chris@35: Chris@35: #include Chris@35: Chris@35: using namespace std; Chris@35: Chris@35: /** This returns true if the helper has a name ending in "-32". By our Chris@35: * convention, this means that it is a 32-bit helper found on a Chris@35: * 64-bit system, so (depending on the OS) we may need to look in Chris@35: * 32-bit-specific paths. Note that is32bit() is *not* usually true Chris@35: * on 32-bit systems; it's used specifically to indicate a Chris@35: * "non-native" 32-bit helper. Chris@35: */ Chris@35: static Chris@35: bool Chris@35: is32bit(string helperExecutableName) Chris@35: { Chris@35: return helperExecutableName.find("-32") != string::npos; Chris@35: } Chris@35: Chris@35: KnownPluginCandidates::KnownPluginCandidates(string helperExecutableName, Chris@35: PluginCandidates::LogCallback *cb) : Chris@35: m_known(is32bit(helperExecutableName) ? Chris@35: KnownPlugins::FormatNonNative32Bit : Chris@35: KnownPlugins::FormatNative), Chris@35: m_candidates(helperExecutableName), Chris@35: m_helperExecutableName(helperExecutableName) Chris@35: { Chris@35: m_candidates.setLogCallback(cb); Chris@35: Chris@35: auto knownTypes = m_known.getKnownPluginTypes(); Chris@35: Chris@35: for (auto type: knownTypes) { Chris@35: m_candidates.scan(m_known.getTagFor(type), Chris@35: m_known.getPathFor(type), Chris@35: m_known.getDescriptorFor(type)); Chris@35: } Chris@35: } Chris@35: Chris@40: vector Chris@40: KnownPluginCandidates::getFailures() const Chris@35: { Chris@35: vector failures; Chris@35: Chris@35: for (auto t: getKnownPluginTypes()) { Chris@35: auto ff = m_candidates.getFailedLibrariesFor(m_known.getTagFor(t)); Chris@35: failures.insert(failures.end(), ff.begin(), ff.end()); Chris@35: } Chris@35: Chris@40: return failures; Chris@40: } Chris@40: Chris@40: string Chris@40: KnownPluginCandidates::getFailureReport() const Chris@40: { Chris@40: auto failures = getFailures(); Chris@35: if (failures.empty()) return ""; Chris@35: Chris@35: int n = int(failures.size()); Chris@35: int i = 0; Chris@35: Chris@35: ostringstream os; Chris@35: Chris@35: os << "
    "; Chris@35: for (auto f: failures) { Chris@35: os << "
  • " + f.library; Chris@35: if (f.message != "") { Chris@35: os << "
    " + f.message + ""; Chris@35: } else { Chris@35: os << "
    unknown error"; Chris@35: } Chris@35: os << "
  • "; Chris@35: Chris@35: if (n > 10) { Chris@35: if (++i == 5) { Chris@35: os << "
  • (... and " << (n - i) << " further failures)
  • "; Chris@35: break; Chris@35: } Chris@35: } Chris@35: } Chris@35: os << "
"; Chris@35: Chris@35: return os.str(); Chris@35: }