26#ifndef PLUGIN_LOADER_H_GUARD
27#define PLUGIN_LOADER_H_GUARD
33#include <wx/dynarray.h>
39#include "model/plugin_blacklist.h"
40#include "model/semantic_vers.h"
41#include "observable_evtvar.h"
50 LegacyUpdateAvailable,
51 ManagedInstallAvailable,
52 ManagedInstalledUpdateAvailable,
53 ManagedInstalledCurrentVersion,
54 ManagedInstalledDowngradeAvailable,
78 wxString m_short_description;
79 wxString m_long_description;
90 std::string
Key()
const;
104 wxDynamicLibrary m_library;
105 destroy_t* m_destroy_fn;
119 const std::string lib_path;
124 : type(t), lib_path(l), plugin_version(pv) {}
127 : type(t), lib_path(std::move(l)), plugin_version(
SemanticVersion()) {}
171 std::function<
const PluginMetadata(
const std::string&)> get_metadata);
210 bool LoadAllPlugIns(
bool enabled_plugins,
bool keep_orphans =
false);
212 const wxBitmap* GetPluginDefaultIcon();
213 void SetPluginDefaultIcon(
const wxBitmap* bitmap);
217 m_on_deactivate_cb = cb;
222 void NotifySetupOptionsPlugin(
const PlugInData* pic);
233 bool UnLoadAllPlugIns();
234 bool DeactivateAllPlugIns();
237 bool UpdatePlugIns();
238 void UpdateManagedPlugins(
bool keep_orphans);
243 const ArrayOfPlugIns* GetPlugInArray() {
return &plugin_array; }
244 bool IsPlugInAvailable(
const wxString& commonName);
245 bool CheckPluginCompatibility(
const wxString& plugin_file);
248 void SetEnabled(
const wxString& common_name,
bool enabled);
258 bool LoadPlugInDirectory(
const wxString& plugin_dir,
bool load_enabled);
259 bool LoadPluginCandidate(
const wxString& file_name,
bool load_enabled);
260 std::unique_ptr<AbstractBlacklist> m_blacklist;
261 ArrayOfPlugIns plugin_array;
262 wxString m_last_error_string;
263 wxString m_plugin_location;
266 wxString m_module_name;
267 bool m_found_wxwidgets;
270 const wxBitmap* m_default_plugin_icon;
273 std::vector<LoadError> load_errors;
Datatypes and methods to parse ocpn-plugins.xml XML data, either complete catalog or a single plugin.
Generic event handling between MVC Model and Controller based on a shared EventVar variable.
Error condition when loading a plugin.
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.
static void MarkAsLoadable(const std::string &library_path)
Mark a library file (complete path) as loadable i.
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 SetSetupOptions(const wxString &common_name, bool value)
Update m_has_setup_options state for plugin with given name.
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_version_incompatible_plugin
FIXME (leamas) not notified.
EventVar evt_deactivate_plugin
Carries a malloc'ed read-only copy of a PlugInContainer owned: by listener.
EventVar evt_update_chart_types
Notified without data after all plugins loaded ot updated.
Base class for OpenCPN plugins.
PlugIn Object Definition/API.
@ Ghost
Managed, shadowing another (packaged?) plugin.
@ Unmanaged
Unmanaged, probably a package.
@ Managed
Managed by installer.
@ System
One of the four system plugins, unmanaged.
Versions uses a modified semantic versioning scheme: major.minor.revision.post-tag+build.