1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
2 /*
3     Copyright (c) 2016-2018 Queen Mary, University of London
4 
5     Permission is hereby granted, free of charge, to any person
6     obtaining a copy of this software and associated documentation
7     files (the "Software"), to deal in the Software without
8     restriction, including without limitation the rights to use, copy,
9     modify, merge, publish, distribute, sublicense, and/or sell copies
10     of the Software, and to permit persons to whom the Software is
11     furnished to do so, subject to the following conditions:
12 
13     The above copyright notice and this permission notice shall be
14     included in all copies or substantial portions of the Software.
15 
16     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21     CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22     WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 
24     Except as contained in this notice, the names of the Centre for
25     Digital Music and Queen Mary, University of London shall not be
26     used in advertising or otherwise to promote the sale, use or other
27     dealings in this Software without prior written authorization.
28 */
29 
30 #ifndef KNOWN_PLUGIN_CANDIDATES_H
31 #define KNOWN_PLUGIN_CANDIDATES_H
32 
33 #include "plugincandidates.h"
34 #include "knownplugins.h"
35 
36 #include <string>
37 #include <map>
38 #include <vector>
39 
40 /**
41  * Class to identify and list candidate shared-library files possibly
42  * containing plugins in a hardcoded set of known formats. Uses a
43  * separate process (the "helper", whose executable name must be
44  * provided at construction) to test-load each library in order to
45  * winnow out any that fail to load or crash on load.
46  *
47  * In v1 of the checker library this was the role of the KnownPlugins
48  * class, but that has been changed so that it only provides static
49  * known information about plugin formats and paths, and this class
50  * has been introduced instead (tying that static information together
51  * with a PluginCandidates object that handles the run-time query).
52  *
53  * Requires C++11 and the Qt5 QtCore library.
54  */
55 class KnownPluginCandidates
56 {
57     typedef std::vector<std::string> stringlist;
58 
59 public:
60     KnownPluginCandidates(std::string helperExecutableName,
61                           PluginCandidates::LogCallback *cb = 0);
62 
getKnownPluginTypes()63     std::vector<KnownPlugins::PluginType> getKnownPluginTypes() const {
64         return m_known.getKnownPluginTypes();
65     }
66 
getTagFor(KnownPlugins::PluginType type)67     std::string getTagFor(KnownPlugins::PluginType type) const {
68         return m_known.getTagFor(type);
69     }
70 
getCandidateLibrariesFor(KnownPlugins::PluginType type)71     stringlist getCandidateLibrariesFor(KnownPlugins::PluginType type) const {
72         return m_candidates.getCandidateLibrariesFor(m_known.getTagFor(type));
73     }
74 
getHelperExecutableName()75     std::string getHelperExecutableName() const {
76         return m_helperExecutableName;
77     }
78 
79     std::vector<PluginCandidates::FailureRec> getFailures() const;
80 
81     /** Return a non-localised HTML failure report */
82     std::string getFailureReport() const;
83 
84 private:
85     KnownPlugins m_known;
86     PluginCandidates m_candidates;
87     std::string m_helperExecutableName;
88 };
89 
90 #endif
91 
92