31 #include <wx/dynarray.h>
32 #include <wx/dynlib.h>
39 #include "OCPN_Sound.h"
41 #include "model/catalog_parser.h"
42 #include "model/plugin_blacklist.h"
43 #include "observable.h"
44 #include "model/ais_target_data.h"
45 #include "model/comm_navmsg.h"
47 #include "model/semantic_vers.h"
50 #include <wx/hyperlink.h>
51 #include <wx/choice.h>
52 #include <wx/tglbtn.h>
53 #include <wx/bmpcbox.h>
55 #ifndef __OCPN__ANDROID__
57 #include <wx/curl/http.h>
58 #include <wx/curl/dialog.h>
74 #include <wx/json_defs.h>
75 #include <wx/jsonwriter.h>
76 #include "model/plugin_loader.h"
93 OCPN_MsgEvent(wxEventType commandType = wxEVT_NULL,
int id = 0);
97 m_MessageID(event.m_MessageID),
98 m_MessageText(event.m_MessageText) {}
103 wxString GetID() {
return m_MessageID; }
104 wxString GetJSONText() {
return m_MessageText; }
106 void SetID(
const wxString&
string) { m_MessageID = string; }
107 void SetJSONText(
const wxString&
string) { m_MessageText = string; }
110 wxEvent* Clone()
const;
113 wxString m_MessageID;
114 wxString m_MessageText;
117 extern const wxEventType wxEVT_OCPN_MSG;
121 UPGRADE_TO_MANAGED_VERSION,
122 UPGRADE_INSTALLED_MANAGED_VERSION,
123 REINSTALL_MANAGED_VERSION,
124 DOWNGRADE_INSTALLED_MANAGED_VERSION,
125 UNINSTALL_MANAGED_VERSION,
126 INSTALL_MANAGED_VERSION
131 wxMenuItem* pmenu_item;
150 wxBitmap* bitmap_day;
151 wxBitmap* bitmap_dusk;
152 wxBitmap* bitmap_night;
153 wxBitmap* bitmap_Rollover_day;
154 wxBitmap* bitmap_Rollover_dusk;
155 wxBitmap* bitmap_Rollover_night;
160 wxObject* clientData;
165 wxString pluginNormalIconSVG;
166 wxString pluginRolloverIconSVG;
167 wxString pluginToggledIconSVG;
186 bool RenderAllCanvasOverlayPlugIns(
ocpnDC& dc,
const ViewPort& vp,
187 int canvasIndex,
int priority);
188 bool RenderAllGLCanvasOverlayPlugIns(wxGLContext* pcontext,
189 const ViewPort& vp,
int canvasIndex,
191 void SendCursorLatLonToAllPlugIns(
double lat,
double lon);
192 void SendViewPortToRequestingPlugIns(
ViewPort& vp);
193 void PrepareAllPluginContextMenus();
195 void NotifySetupOptions();
197 void CloseAllPlugInPanels(
int);
199 ArrayOfPlugInToolbarTools& GetPluginToolbarToolArray() {
200 return m_PlugInToolbarTools;
202 int AddToolbarTool(wxString label, wxBitmap* bitmap, wxBitmap* bmpRollover,
203 wxItemKind kind, wxString shortHelp, wxString longHelp,
204 wxObject* clientData,
int position,
int tool_sel,
207 void RemoveToolbarTool(
int tool_id);
208 void SetToolbarToolViz(
int tool_id,
bool viz);
209 void SetToolbarItemState(
int tool_id,
bool toggle);
210 void SetToolbarItemBitmaps(
int item, wxBitmap* bitmap, wxBitmap* bmpDisabled);
212 int AddToolbarTool(wxString label, wxString SVGfile, wxString SVGRolloverfile,
213 wxString SVGToggledfile, wxItemKind kind,
214 wxString shortHelp, wxString longHelp,
215 wxObject* clientData,
int position,
int tool_sel,
218 void SetToolbarItemBitmaps(
int item, wxString SVGfile,
219 wxString SVGfileRollover, wxString SVGfileToggled);
222 wxString GetToolOwnerCommonName(
const int id);
223 void ShowDeferredBlacklistMessages();
225 ArrayOfPlugInMenuItems& GetPluginContextMenuItemArray() {
226 return m_PlugInMenuItems;
228 int AddCanvasContextMenuItem(wxMenuItem* pitem,
opencpn_plugin* pplugin,
229 const char* name =
"");
230 void RemoveCanvasContextMenuItem(
int item,
const char* name =
"");
231 void SetCanvasContextMenuItemViz(
int item,
bool viz,
const char* name =
"");
232 void SetCanvasContextMenuItemGrey(
int item,
bool grey,
const char* name =
"");
234 static void SendNMEASentenceToAllPlugIns(
const wxString& sentence);
236 void SendActiveLegInfoToAllPlugIns(
const ActiveLegDat* infos);
237 void SendAISSentenceToAllPlugIns(
const wxString& sentence);
238 void SendJSONMessageToAllPlugins(
const wxString& message_id, wxJSONValue v);
239 void SendMessageToAllPlugins(
const wxString& message_id,
240 const wxString& message_body);
241 bool UpDateChartDataTypes();
242 void FinalizePluginLoadall();
244 int GetJSONMessageTargetCount();
246 void SendResizeEventToAllPlugIns(
int x,
int y);
247 void SetColorSchemeForAllPlugIns(ColorScheme cs);
248 void NotifyAuiPlugIns(
void);
249 bool CallLateInit(
void);
251 bool IsAnyPlugInChartEnabled();
253 void SendVectorChartObjectInfo(
const wxString& chart,
const wxString& feature,
254 const wxString& objname,
double& lat,
255 double& lon,
double&
scale,
int& nativescale);
257 bool SendMouseEventToPlugins(wxMouseEvent& event);
258 bool SendKeyEventToPlugins(wxKeyEvent& event);
260 void SendBaseConfigToAllPlugIns();
261 void SendS52ConfigToAllPlugIns(
bool bReconfig =
false);
262 void SendSKConfigToAllPlugIns();
264 void UpdateManagedPlugins();
267 void InitCommListeners(
void);
268 void HandleN0183(std::shared_ptr<const Nmea0183Msg> n0183_msg);
269 void HandleSignalK(std::shared_ptr<const SignalkMsg> sK_msg);
271 wxArrayString GetPlugInChartClassNameArray(
void);
274 float zlat,
float zlon,
278 ListOfPI_S57Obj* rule_list);
280 wxString GetLastError();
281 MyFrame* GetParentFrame() {
return pParent; }
283 void DimeWindow(wxWindow* win);
287 ListOfPI_S57Obj* GetLightsObjRuleListVisibleAtLatLon(
291 bool CheckBlacklistedPlugin(wxString name,
int major,
int minor);
312 wxBitmap* BuildDimmedToolBitmap(wxBitmap* pbmp_normal,
313 unsigned char dim_ratio);
317 void HandlePluginLoaderEvents();
318 void HandlePluginHandlerEvents();
321 std::unique_ptr<BlacklistUI> m_blacklist_ui;
323 wxString m_last_error_string;
325 ArrayOfPlugInMenuItems m_PlugInMenuItems;
326 ArrayOfPlugInToolbarTools m_PlugInToolbarTools;
328 wxString m_plugin_location;
330 int m_plugin_tool_id_next;
331 int m_plugin_menu_item_id_next;
332 wxBitmap m_cached_overlay_bm;
334 wxArrayString m_plugin_order;
335 void SetPluginOrder(wxString serialized_names);
336 wxString GetPluginOrder();
340 std::unique_ptr<AbstractBlacklist> m_blacklist;
342 #ifndef __OCPN__ANDROID__
346 wxCurlDownloadThread* m_pCurlThread;
348 std::shared_ptr<wxCurlBase> m_pCurl;
351 bool HandleCurlThreadError(wxCurlThreadError err, wxCurlBaseThread* p,
352 const wxString& url = wxEmptyString);
353 void OnEndPerformCurlDownload(wxCurlEndPerformEvent& ev);
354 void OnCurlDownload(wxCurlDownloadEvent& ev);
356 wxEvtHandler* m_download_evHandler;
357 long* m_downloadHandle;
359 long m_last_online_chk;
363 DECLARE_EVENT_TABLE()
366 WX_DEFINE_ARRAY_PTR(
PluginPanel*, ArrayOfPluginPanel);
376 void OnClick(wxMouseEvent& event);
381 wxStaticBitmap* m_staticBitmap;
392 void OnUpdateButton(wxCommandEvent& event);
394 m_PluginListPanel = listPanel;
396 void OnTarballButton(wxCommandEvent& event);
397 void OnPluginSettingsButton(wxCommandEvent& event);
400 wxString GetCatalogText(
bool);
401 void SetUpdateButtonLabel();
402 wxString GetImportInitDir();
404 wxButton *m_updateButton, *m_advancedButton, *m_tarballButton;
405 wxButton* m_adv_button;
406 wxStaticText* m_catalogText;
412 #define ID_CMD_BUTTON_PERFORM_ACTION 27663
415 DECLARE_EVENT_TABLE()
425 void UpdateSelections();
426 void UpdatePluginsOrder();
430 void SelectByName(wxString& name);
434 void AddPlugin(
const std::string& name);
435 int ComputePluginSpace(ArrayOfPluginPanel plugins, wxBoxSizer* sizer);
438 ArrayOfPluginPanel m_PluginItems;
440 wxString m_selectedName;
442 std::atomic_flag m_is_loading;
450 void SetURL(std::string url) { m_url = url; }
457 DECLARE_EVENT_TABLE()
462 PluginPanel(wxPanel* parent, wxWindowID
id,
const wxPoint& pos,
466 PluginPanel(wxPanel* parent, wxWindowID
id,
const wxPoint& pos,
470 PluginPanel(wxPanel* parent,
const std::string& name);
474 void OnPluginSelected(wxMouseEvent& event);
475 void OnPluginSelectedUp(wxMouseEvent& event);
476 void DoPluginSelect();
478 void SetSelected(
bool selected);
479 void OnPluginPreferences(wxCommandEvent& event);
480 void OnPluginEnableToggle(wxCommandEvent& event);
481 void OnPluginAction(wxCommandEvent& event);
482 void OnPluginUninstall(wxCommandEvent& event);
483 void OnPluginUp(wxCommandEvent& event);
484 void OnPluginDown(wxCommandEvent& event);
485 void SetEnabled(
bool enabled);
486 bool GetSelected() {
return m_bSelected; }
487 const PlugInData* GetPluginPtr() {
return &m_plugin; };
488 void SetActionLabel(wxString& label);
489 ActionVerb GetAction() {
return m_action; }
490 const PlugInData* GetPlugin() {
return &m_plugin; }
491 void OnPaint(wxPaintEvent& event);
497 wxStaticText* m_pName;
498 wxStaticText* m_pVersion;
499 wxStaticText* m_pDescription;
500 wxBoxSizer* m_pButtons;
501 wxStaticBitmap* m_itemStaticBitmap;
502 wxStaticBitmap* m_itemStatusIconBitmap;
503 wxButton* m_pButtonPreferences;
504 wxButton *m_pButtonAction, *m_pButtonUninstall;
506 wxCheckBox* m_cbEnable;
509 int m_penWidthUnselected, m_penWidthSelected;
510 bool m_is_safe_panel;
519 bBBObj_valid =
false;
521 bFText_Added =
false;
524 ChildRazRules = NULL;
542 ObjRazRules* ChildRazRules;
543 mps_container* MPSRulesList;
546 void CreateCompatibleS57Object(
PI_S57Obj* pObj, S57Obj* cobj,
547 chart_context* pctx);
548 void UpdatePIObjectPlibContext(
PI_S57Obj* pObj, S57Obj* cobj);
Handle messages for blacklisted plugins.
Define an action to be performed when a KeyProvider is notified.
Keeps listening over it's lifespan, removes itself on destruction.
Data for a loaded plugin, including dl-loaded library.
Basic data for a loaded plugin, trivially copyable.
void ReloadPluginPanels()
Complete reload from plugins array.
PluginPanel(wxPanel *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const PlugInData plugin)
An entry in the list of plugins presented by Options | Plugins.