31#include <wx/dynarray.h>
38#include "ocpn_plugin.h"
40#include "OCPN_Sound.h"
42#include "catalog_parser.h"
43#include "plugin_blacklist.h"
44#include "observable.h"
45#include "ais_target_data.h"
46#include "comm_navmsg.h"
48#include "semantic_vers.h"
51#include <wx/hyperlink.h>
54#include <wx/bmpcbox.h>
56#ifndef __OCPN__ANDROID__
58#include <wx/curl/http.h>
59#include <wx/curl/dialog.h>
75#include <wx/json_defs.h>
76#include <wx/jsonwriter.h>
77#include "plugin_loader.h"
94 OCPN_MsgEvent(wxEventType commandType = wxEVT_NULL,
int id = 0);
98 m_MessageID(event.m_MessageID),
99 m_MessageText(event.m_MessageText) {}
104 wxString GetID() {
return m_MessageID; }
105 wxString GetJSONText() {
return m_MessageText; }
107 void SetID(
const wxString &
string) { m_MessageID = string; }
108 void SetJSONText(
const wxString &
string) { m_MessageText = string; }
111 wxEvent *Clone()
const;
114 wxString m_MessageID;
115 wxString m_MessageText;
118extern const wxEventType wxEVT_OCPN_MSG;
122 UPGRADE_TO_MANAGED_VERSION,
123 UPGRADE_INSTALLED_MANAGED_VERSION,
124 REINSTALL_MANAGED_VERSION,
125 DOWNGRADE_INSTALLED_MANAGED_VERSION,
126 UNINSTALL_MANAGED_VERSION,
127 INSTALL_MANAGED_VERSION
133 wxMenuItem *pmenu_item;
152 wxBitmap *bitmap_day;
153 wxBitmap *bitmap_dusk;
154 wxBitmap *bitmap_night;
155 wxBitmap *bitmap_Rollover_day;
156 wxBitmap *bitmap_Rollover_dusk;
157 wxBitmap *bitmap_Rollover_night;
162 wxObject *clientData;
167 wxString pluginNormalIconSVG;
168 wxString pluginRolloverIconSVG;
169 wxString pluginToggledIconSVG;
188 bool RenderAllCanvasOverlayPlugIns(
ocpnDC &dc,
const ViewPort &vp,
189 int canvasIndex,
int priority);
190 bool RenderAllGLCanvasOverlayPlugIns(wxGLContext *pcontext,
191 const ViewPort &vp,
int canvasIndex,
193 void SendCursorLatLonToAllPlugIns(
double lat,
double lon);
194 void SendViewPortToRequestingPlugIns(
ViewPort &vp);
195 void PrepareAllPluginContextMenus();
197 void NotifySetupOptions();
199 void CloseAllPlugInPanels(
int);
201 ArrayOfPlugInToolbarTools &GetPluginToolbarToolArray() {
202 return m_PlugInToolbarTools;
204 int AddToolbarTool(wxString label, wxBitmap *bitmap, wxBitmap *bmpRollover,
205 wxItemKind kind, wxString shortHelp, wxString longHelp,
206 wxObject *clientData,
int position,
int tool_sel,
209 void RemoveToolbarTool(
int tool_id);
210 void SetToolbarToolViz(
int tool_id,
bool viz);
211 void SetToolbarItemState(
int tool_id,
bool toggle);
212 void SetToolbarItemBitmaps(
int item, wxBitmap *bitmap, wxBitmap *bmpDisabled);
214 int AddToolbarTool(wxString label, wxString SVGfile, wxString SVGRolloverfile,
215 wxString SVGToggledfile, wxItemKind kind,
216 wxString shortHelp, wxString longHelp,
217 wxObject *clientData,
int position,
int tool_sel,
220 void SetToolbarItemBitmaps(
int item, wxString SVGfile,
221 wxString SVGfileRollover, wxString SVGfileToggled);
224 wxString GetToolOwnerCommonName(
const int id);
225 void ShowDeferredBlacklistMessages();
227 ArrayOfPlugInMenuItems &GetPluginContextMenuItemArray() {
228 return m_PlugInMenuItems;
230 int AddCanvasContextMenuItem(wxMenuItem *pitem,
opencpn_plugin *pplugin,
231 const char *name =
"");
232 void RemoveCanvasContextMenuItem(
int item,
const char *name =
"");
233 void SetCanvasContextMenuItemViz(
int item,
bool viz,
const char *name =
"");
234 void SetCanvasContextMenuItemGrey(
int item,
bool grey,
const char *name =
"");
236 void SendNMEASentenceToAllPlugIns(
const wxString &sentence);
238 void SendActiveLegInfoToAllPlugIns(
const ActiveLegDat *infos);
239 void SendAISSentenceToAllPlugIns(
const wxString &sentence);
240 void SendJSONMessageToAllPlugins(
const wxString &message_id, wxJSONValue v);
241 void SendMessageToAllPlugins(
const wxString &message_id,
242 const wxString &message_body);
243 bool UpDateChartDataTypes();
244 void FinalizePluginLoadall();
246 int GetJSONMessageTargetCount();
248 void SendResizeEventToAllPlugIns(
int x,
int y);
249 void SetColorSchemeForAllPlugIns(ColorScheme cs);
250 void NotifyAuiPlugIns(
void);
251 bool CallLateInit(
void);
253 bool IsAnyPlugInChartEnabled();
255 void SendVectorChartObjectInfo(
const wxString &chart,
const wxString &feature,
256 const wxString &objname,
double &lat,
257 double &lon,
double &
scale,
int &nativescale);
259 bool SendMouseEventToPlugins(wxMouseEvent &event);
260 bool SendKeyEventToPlugins(wxKeyEvent &event);
262 void SendBaseConfigToAllPlugIns();
263 void SendS52ConfigToAllPlugIns(
bool bReconfig =
false);
264 void SendSKConfigToAllPlugIns();
266 void UpdateManagedPlugins();
269 void InitCommListeners(
void);
270 void HandleN0183( std::shared_ptr <const Nmea0183Msg> n0183_msg );
271 void HandleSignalK(std::shared_ptr<const SignalkMsg> sK_msg);
273 wxArrayString GetPlugInChartClassNameArray(
void);
276 float zlat,
float zlon,
280 ListOfPI_S57Obj *rule_list);
282 wxString GetLastError();
283 MyFrame *GetParentFrame() {
return pParent; }
285 void DimeWindow(wxWindow *win);
289 ListOfPI_S57Obj *GetLightsObjRuleListVisibleAtLatLon(
293 bool CheckBlacklistedPlugin(wxString name,
int major,
int minor);
317 wxBitmap *BuildDimmedToolBitmap(wxBitmap *pbmp_normal,
318 unsigned char dim_ratio);
322 void HandlePluginLoaderEvents();
323 void HandlePluginHandlerEvents();
326 std::unique_ptr<BlacklistUI> m_blacklist_ui;
328 wxString m_last_error_string;
330 ArrayOfPlugInMenuItems m_PlugInMenuItems;
331 ArrayOfPlugInToolbarTools m_PlugInToolbarTools;
333 wxString m_plugin_location;
335 int m_plugin_tool_id_next;
336 int m_plugin_menu_item_id_next;
337 wxBitmap m_cached_overlay_bm;
339 wxArrayString m_plugin_order;
340 void SetPluginOrder(wxString serialized_names);
341 wxString GetPluginOrder();
345 std::unique_ptr<AbstractBlacklist> m_blacklist;
347#ifndef __OCPN__ANDROID__
351 wxCurlDownloadThread *m_pCurlThread;
353 std::shared_ptr<wxCurlBase> m_pCurl;
356 bool HandleCurlThreadError(wxCurlThreadError err, wxCurlBaseThread *p,
357 const wxString &url = wxEmptyString);
358 void OnEndPerformCurlDownload(wxCurlEndPerformEvent &ev);
359 void OnCurlDownload(wxCurlDownloadEvent &ev);
361 wxEvtHandler *m_download_evHandler;
362 long *m_downloadHandle;
364 long m_last_online_chk;
368 DECLARE_EVENT_TABLE()
371WX_DEFINE_ARRAY_PTR(
PluginPanel *, ArrayOfPluginPanel);
381 void OnClick(wxMouseEvent &event);
386 wxStaticBitmap *m_staticBitmap;
397 void OnUpdateButton(wxCommandEvent &event);
399 m_PluginListPanel = listPanel;
401 void OnTarballButton(wxCommandEvent &event);
402 void OnPluginSettingsButton(wxCommandEvent &event);
405 wxString GetCatalogText(
bool);
406 void SetUpdateButtonLabel();
407 wxString GetImportInitDir();
409 wxButton *m_updateButton, *m_advancedButton, *m_tarballButton;
410 wxButton *m_adv_button;
411 wxStaticText *m_catalogText;
417#define ID_CMD_BUTTON_PERFORM_ACTION 27663
420 DECLARE_EVENT_TABLE()
424 const wxSize &size, ArrayOfPlugIns *pPluginArray);
430 void UpdateSelections();
431 void UpdatePluginsOrder();
435 void SelectByName(wxString &name);
439 int ComputePluginSpace(ArrayOfPluginPanel plugins, wxBoxSizer *sizer);
442 ArrayOfPlugIns *m_pPluginArray;
443 ArrayOfPluginPanel m_PluginItems;
445 wxString m_selectedName;
454 void SetURL(std::string url) { m_url = url; }
461 DECLARE_EVENT_TABLE()
464 PluginPanel(wxPanel *parent, wxWindowID
id,
const wxPoint &pos,
468 void OnPluginSelected(wxMouseEvent &event);
469 void OnPluginSelectedUp(wxMouseEvent &event);
470 void DoPluginSelect();
472 void SetSelected(
bool selected);
473 void OnPluginPreferences(wxCommandEvent &event);
474 void OnPluginEnableToggle(wxCommandEvent &event);
475 void OnPluginAction(wxCommandEvent &event);
476 void OnPluginUninstall(wxCommandEvent &event);
477 void OnPluginUp(wxCommandEvent &event);
478 void OnPluginDown(wxCommandEvent &event);
479 void SetEnabled(
bool enabled);
480 bool GetSelected() {
return m_bSelected; }
482 void SetActionLabel(wxString &label);
483 ActionVerb GetAction() {
return m_action; }
485 void OnPaint(wxPaintEvent &event);
491 wxStaticText *m_pName;
492 wxStaticText *m_pVersion;
493 wxStaticText *m_pDescription;
494 wxBoxSizer *m_pButtons;
495 wxStaticBitmap *m_itemStaticBitmap;
496 wxStaticBitmap *m_itemStatusIconBitmap;
497 wxButton *m_pButtonPreferences;
498 wxButton *m_pButtonAction, *m_pButtonUninstall;
500 wxCheckBox *m_cbEnable;
503 int m_penWidthUnselected, m_penWidthSelected;
512 bBBObj_valid =
false;
514 bFText_Added =
false;
517 ChildRazRules = NULL;
535 ObjRazRules *ChildRazRules;
536 mps_container *MPSRulesList;
539void CreateCompatibleS57Object(
PI_S57Obj *pObj, S57Obj *cobj,
540 chart_context *pctx);
541void UpdatePIObjectPlibContext(
PI_S57Obj *pObj, S57Obj *cobj);
Handle messages for blacklisted plugins.
Keeps listening over it's lifespan, removes itself on destruction.
void ReloadPluginPanels()
Complete reload from plugins array.