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()) {}
169 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);
279 void SetEnabled(
const wxString& common_name,
bool enabled);
289 bool LoadPlugInDirectory(
const wxString& plugin_dir,
bool load_enabled);
290 bool LoadPluginCandidate(
const wxString& file_name,
bool load_enabled);
291 std::unique_ptr<AbstractBlacklist> m_blacklist;
292 ArrayOfPlugIns plugin_array;
293 wxString m_last_error_string;
294 wxString m_plugin_location;
297 wxString m_module_name;
298 bool m_found_wxwidgets;
301 const wxBitmap* m_default_plugin_icon;
304 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.
bool IsPlugInAvailable(const wxString &commonName)
Return true if a plugin with given name exists in GetPlugInArray()
static void MarkAsLoadable(const std::string &library_path)
Mark a library file (complete path) as loadable i.
EventVar evt_load_plugin
Notified with a PlugInContainer* pointer when a plugin is loaded.
void UpdateManagedPlugins(bool keep_orphans)
Update all managed plugins i.
EventVar evt_pluglist_change
Notified without data when the GetPlugInArray() list is changed.
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.
EventVar evt_load_directory
Notified without data when loader starts loading from a new directory.
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.
bool DeactivatePlugIn(PlugInContainer *pic)
Deactivate given plugin.
bool UnLoadAllPlugIns()
Unload allplugins i.
void RemovePlugin(const PlugInData &pd)
Remove a plugin from *GetPluginArray().
bool UpdatePlugIns()
Update the GetPlugInArray() list by reloading all plugins from disk.
void ShowPreferencesDialog(const PlugInData &pd, wxWindow *parent)
Display the preferences dialog for a plugin.
bool CheckPluginCompatibility(const wxString &plugin_file)
Check plugin compatibiliet w r t library type.
const ArrayOfPlugIns * GetPlugInArray()
Return list of currently loaded plugins.
EventVar evt_deactivate_plugin
Carries a malloc'ed read-only copy of a PlugInContainer owned: by listener.
bool DeactivateAllPlugIns()
Deactivate all plugins.
PlugInContainer * LoadPlugIn(const wxString &plugin_file)
Load given plugin file from disk into GetPlugInArray() list.
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.