OpenCPN Partial API docs
Loading...
Searching...
No Matches
plugin_loader.h
1/***************************************************************************
2 *
3 *
4 * Project: OpenCPN
5 * Purpose: PlugIn Manager Object
6 * Author: David Register
7 *
8 ***************************************************************************
9 * Copyright (C) 2010 by David S. Register *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License for more details. *
20 * *
21 * You should have received a copy of the GNU General Public License *
22 * along with this program; if not, write to the *
23 * Free Software Foundation, Inc., *
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
25 **************************************************************************/
26
27#ifndef _PLUGIN_LOADER_H_
28#define _PLUGIN_LOADER_H_
29
30#include <wx/wx.h>
31#include <wx/bitmap.h>
32#include <wx/dynarray.h>
33#include <wx/dynlib.h>
34
35#include "config.h"
36
37#include "catalog_parser.h"
38#include "observable_evtvar.h"
39#include "ocpn_plugin.h"
40#include "plugin_blacklist.h"
41#include "semantic_vers.h"
42
43
44
45typedef struct {
46 wxString name; // name of the plugin
47 int version_major; // major version
48 int version_minor; // minor version
49 bool hard; // hard blacklist - if true, don't load it at all, if false, load
50 // it and just warn the user
51 bool all_lower; // if true, blacklist also all the lower versions of the
52 // plugin
53 bool mute_dialog; // if true, don't warn the user by dialog.
55
56
57enum class PluginStatus {
58 System, // One of the four system plugins, unmanaged.
59 Managed, // Managed by installer.
60 Unmanaged, // Unmanaged, probably a package.
61 Ghost, // Managed, shadowing another (packaged?) plugin.
62 Unknown,
63 LegacyUpdateAvailable,
64 ManagedInstallAvailable,
65 ManagedInstalledUpdateAvailable,
66 ManagedInstalledCurrentVersion,
67 ManagedInstalledDowngradeAvailable,
68 PendingListRemoval
69};
70
71
72
73//-----------------------------------------------------------------------------------------------------
74//
75// The PlugIn Container Specification
76//
77//-----------------------------------------------------------------------------------------------------
79public:
81
82 opencpn_plugin* m_pplugin;
83 bool m_bEnabled;
84 bool m_bInitState;
85 bool m_bToolboxPanel;
86 int m_cap_flag; // PlugIn Capabilities descriptor
87 wxString m_plugin_file; // The full file path
88 wxString m_plugin_filename; // The short file path
89 wxDateTime m_plugin_modification; // used to detect upgraded plugins
90 destroy_t* m_destroy_fn;
91 wxDynamicLibrary m_library;
92 wxString m_common_name; // A common name string for the plugin
93 wxString m_short_description;
94 wxString m_long_description;
95 int m_api_version;
96 int m_version_major;
97 int m_version_minor;
98 PluginStatus m_pluginStatus;
99 PluginMetadata m_ManagedMetadata;
100 wxBitmap* m_bitmap;
107 wxString m_version_str; // Complete version as of
108 // semantic_vers
109 std::string m_InstalledManagedVersion; // As detected from manifest
110};
111
112// Declare an array of PlugIn Containers
113WX_DEFINE_ARRAY_PTR(PlugInContainer* , ArrayOfPlugIns);
114
115//-----------------------------------------------------------------------------------------------------
116//
117// The PlugIn Manager Specification
118//
119//-----------------------------------------------------------------------------------------------------
120
142public:
143 EventVar evt_blacklisted_plugin;
144
147
148 EventVar evt_incompatible_plugin;
149 EventVar evt_load_directory;
150 EventVar evt_load_plugin;
151 EventVar evt_plugin_unload;
152 EventVar evt_pluglist_change;
153 EventVar evt_unreadable_plugin;
154 EventVar evt_update_chart_types;
155 EventVar evt_plugin_loadall_finalize;
156 EventVar evt_version_incompatible_plugin;
157
158
159 static PluginLoader* getInstance();
160 virtual ~PluginLoader() {}
161
162 bool LoadAllPlugIns(bool enabled_plugins);
163
164 void SetPluginDefaultIcon(const wxBitmap* bitmap);
165 const wxBitmap* GetPluginDefaultIcon();
167 bool UnLoadPlugIn(size_t ix);
168
169 bool UnLoadAllPlugIns();
170 bool DeactivateAllPlugIns();
171 bool DeactivatePlugIn(PlugInContainer* pic);
172 bool UpdatePlugIns();
173 void UpdateManagedPlugins();
174 PlugInContainer* LoadPlugIn(wxString plugin_file);
175 PlugInContainer* LoadPlugIn(wxString plugin_file, PlugInContainer* pic);
176
177 ArrayOfPlugIns* GetPlugInArray() { return &plugin_array; }
178 bool IsPlugInAvailable(wxString commonName);
179 bool CheckPluginCompatibility(wxString plugin_file);
180
181private:
182 PluginLoader();
183 bool LoadPlugInDirectory(const wxString &plugin_dir, bool load_enabled);
184 bool LoadPluginCandidate(wxString file_name, bool load_enabled);
185 std::unique_ptr<AbstractBlacklist> m_blacklist;
186 ArrayOfPlugIns plugin_array;
187 wxString m_last_error_string;
188 wxString m_plugin_location;
189 const wxBitmap* m_default_plugin_icon;
190};
191
192#endif // _PLUGIN_LOADER_H_
Generic event handling between between two parties like MVC Model and Controller using a shared Event...
SemanticVersion GetVersion()
Return version from plugin API.
PluginLoader is a backend module without any direct GUI functionality.
bool UnLoadPlugIn(size_t ix)
Unload, delete and remove item ix in GetPlugInArray().
EventVar evt_deactivate_plugin
Receives a malloc'ed copy of a PlugInContainer owned by listener.
Plugin metadata, reflects the xml format directly.
Versions uses a modified semantic versioning scheme: major.minor.revision.post-tag+build.
Definition: semantic_vers.h:51