28 #ifndef PLUGIN_LOADER_H_GUARD
29 #define PLUGIN_LOADER_H_GUARD
34 #include <wx/bitmap.h>
35 #include <wx/dynarray.h>
36 #include <wx/dynlib.h>
40 #include "model/catalog_parser.h"
41 #include "model/plugin_blacklist.h"
42 #include "model/semantic_vers.h"
43 #include "observable_evtvar.h"
46 enum class PluginStatus {
52 LegacyUpdateAvailable,
53 ManagedInstallAvailable,
54 ManagedInstalledUpdateAvailable,
55 ManagedInstalledCurrentVersion,
56 ManagedInstalledDowngradeAvailable,
80 wxString m_short_description;
81 wxString m_long_description;
85 PluginStatus m_status;
92 std::string
Key()
const;
106 wxDynamicLibrary m_library;
107 destroy_t* m_destroy_fn;
120 const std::string lib_path;
125 : type(t), lib_path(l), plugin_version(pv) {}
128 : type(t), lib_path(std::move(l)), plugin_version(
SemanticVersion()) {}
166 std::function<
const PluginMetadata(
const std::string&)> get_metadata);
192 EventVar evt_version_incompatible_plugin;
202 bool LoadAllPlugIns(
bool enabled_plugins,
bool keep_orphans =
false);
204 const wxBitmap* GetPluginDefaultIcon();
205 void SetPluginDefaultIcon(
const wxBitmap* bitmap);
209 m_on_deactivate_cb = cb;
214 void NotifySetupOptionsPlugin(
const PlugInData* pic);
225 bool UnLoadAllPlugIns();
226 bool DeactivateAllPlugIns();
229 bool UpdatePlugIns();
230 void UpdateManagedPlugins(
bool keep_orphans);
235 const ArrayOfPlugIns* GetPlugInArray() {
return &plugin_array; }
236 bool IsPlugInAvailable(
const wxString& commonName);
237 bool CheckPluginCompatibility(
const wxString& plugin_file);
240 void SetEnabled(
const wxString& common_name,
bool enabled);
247 bool LoadPlugInDirectory(
const wxString& plugin_dir,
bool load_enabled);
248 bool LoadPluginCandidate(
const wxString& file_name,
bool load_enabled);
249 std::unique_ptr<AbstractBlacklist> m_blacklist;
250 ArrayOfPlugIns plugin_array;
251 wxString m_last_error_string;
252 wxString m_plugin_location;
255 wxString m_module_name;
256 bool m_found_wxwidgets;
259 const wxBitmap* m_default_plugin_icon;
262 std::vector<LoadError> load_errors;
Generic event handling between MVC Model and Controller based on a shared EventVar variable.
Data for a loaded plugin, including dl-loaded library.
Basic data for a loaded plugin, trivially copyable.
wxString m_plugin_filename
The short file path.
wxString m_plugin_file
The full file path.
int m_cap_flag
PlugIn Capabilities descriptor.
wxString m_common_name
A common name string for the plugin.
bool m_has_setup_options
Has run NotifySetupOptionsPlugin()
std::string Key() const
sort key.
std::string m_manifest_version
As detected from manifest.
wxDateTime m_plugin_modification
used to detect upgraded plugins
wxString m_version_str
Complete version as of semantic_vers.
PluginLoader is a backend module without any direct GUI functionality.
void SetOnDeactivateCb(std::function< void(const PlugInContainer *)> cb)
Callback invoked in late stage on deactivating a plugin.
bool LoadAllPlugIns(bool enabled_plugins, bool keep_orphans=false)
Update catalog with imported metadata and load all plugin library files.
EventVar evt_plugin_loadall_finalize
Emitted after all plugins are loaded.
static std::string GetPluginVersion(const PlugInData pd, std::function< const PluginMetadata(const std::string &)> get_metadata)
Return version string for a plugin, possibly with an "Imported" suffix.
bool UnLoadPlugIn(size_t ix)
Unload, delete and remove item ix in GetPlugInArray().
void SortPlugins(int(*cmp_func)(PlugInContainer **, PlugInContainer **))
Sort GetPluginArray().
static void UpdatePlugin(PlugInContainer *plugin, const PluginMetadata &md)
Update PlugInContainer status using data from PluginMetadata and manifest.
void SetEnabled(const wxString &common_name, bool enabled)
Update enabled/disabled state for plugin with given name.
void SetToolboxPanel(const wxString &common_name, bool value)
Update m_toolbox_panel state for plugin with given name.
static PluginMetadata MetadataByName(const std::string &name)
Find metadata for given plugin.
void RemovePlugin(const PlugInData &pd)
Remove a plugin from *GetPluginArray().
void ShowPreferencesDialog(const PlugInData &pd, wxWindow *parent)
Display the preferences dialog for a plugin.
EventVar evt_deactivate_plugin
Carries a malloc'ed read-only copy of a PlugInContainer owned by listener.
Versions uses a modified semantic versioning scheme: major.minor.revision.post-tag+build.