36#include <wx/fileconf.h>
37#include <wx/tokenzr.h>
40#include "chartdldrgui.h"
43#define MY_API_VERSION_MAJOR 1
44#define MY_API_VERSION_MINOR 13
45#define USERDATA "{USERDATA}"
46#define UPDATE_DATA_FILENAME "chartdldr_pi.dat"
82 bool ProcessFile(
const wxString& aFile,
const wxString& aTargetDir,
83 bool aStripPath =
true,
84 wxDateTime aMTime = wxDateTime::Now());
85 bool ExtractZipFiles(
const wxString& aZipFile,
const wxString& aTargetDir,
86 bool aStripPath =
true,
87 wxDateTime aMTime = wxDateTime::Now(),
88 bool aRemoveZip =
false);
89#ifdef DLDR_USE_LIBARCHIVE
90 bool ExtractLibArchiveFiles(
const wxString& aArchiveFile,
91 const wxString& aTargetDir,
92 bool aStripPath =
true,
93 wxDateTime aMTime = wxDateTime::Now(),
94 bool aRemoveArchive =
false);
96#if defined(CHARTDLDR_RAR_UNARR) || !defined(DLDR_USE_LIBARCHIVE)
97 bool ExtractUnarrFiles(
const wxString& aRarFile,
const wxString& aTargetDir,
98 bool aStripPath =
true,
99 wxDateTime aMTime = wxDateTime::Now(),
100 bool aRemoveRar =
false);
106 std::vector<std::unique_ptr<ChartSource>> m_ChartSources;
107 wxWindow* m_parent_window;
110 void SetSourceId(
int id) { m_selected_source = id; }
111 [[nodiscard]]
int GetSourceId()
const {
return m_selected_source; }
112 wxString GetBaseChartDir() {
return m_base_chart_dir; }
114 bool m_reselect_updated;
115 bool m_allow_bulk_update;
118 wxFileConfig* m_config;
119 wxScrolledWindow* m_options_page;
120 wxString m_schartdldr_sources;
121 int m_selected_source;
123 wxString m_base_chart_dir;
130 ChartSource(
const wxString& name,
const wxString& url,
131 const wxString& localdir);
134 wxString GetName() {
return m_name; }
135 wxString GetUrl() {
return m_url; }
136 wxString GetDir() {
return m_dir; }
137 void SetDir(
const wxString& dir) { m_dir = dir; }
138 void SetName(
const wxString& name) { m_name = name; }
139 void SetUrl(
const wxString& url) { m_url = url; }
140 bool ExistsLocally(
const wxString& chart_number,
const wxString& filename);
141 bool IsNewerThanLocal(
const wxString& chart_number,
const wxString& filename,
142 const wxDateTime& validDate);
143 void UpdateLocalFiles() { GetLocalFiles(); }
145 bool UpdateDataExists();
146 void LoadUpdateData();
147 void SaveUpdateData();
148 void ChartUpdated(
const wxString& chart_number, time_t timestamp);
151 wxArrayString m_localfiles;
152 std::vector<wxDateTime> m_localdt;
156 std::map<std::string, time_t> m_update_data;
158 void GetLocalFiles();
169 bool m_download_is_cancel;
172 bool m_is_transfer_complete;
173 bool m_is_transfer_ok;
175 long m_transferred_size;
176 int m_failed_downloads;
180 size_t m_updated_charts;
183 bool DownloadChart(
const wxString& url,
const wxString& file,
184 const wxString& title);
185 void OnPopupClick(wxCommandEvent& evt);
186 int GetSelectedCatalog();
187 void AppendCatalog(std::unique_ptr<ChartSource>& cs);
190 void DisableForDownload(
bool enabled);
194 void SetSource(
int id);
195 void SelectSource(wxListEvent& event)
override;
196 void AddSource(wxCommandEvent& event)
override;
197 void DeleteSource(wxCommandEvent& event)
override;
198 void EditSource(wxCommandEvent& event)
override;
199 void UpdateChartList(wxCommandEvent& event)
override;
200 void OnDownloadCharts(wxCommandEvent& event)
override;
202#if defined(CHART_LIST)
203 void OnSelectChartItem(wxCommandEvent& event);
204 void OnSelectNewCharts(wxCommandEvent& event);
205 void OnSelectUpdatedCharts(wxCommandEvent& event);
206 void OnSelectAllCharts(wxCommandEvent& event);
210 void DoHelp(wxCommandEvent& event)
override {
213 "plugins/chartdldr_pi/data/doc/index.html");
216 "plugins/chartdldr_pi/data/doc/index.html");
219 void UpdateAllCharts(wxCommandEvent& event)
override;
220 void OnShowLocalDir(wxCommandEvent& event)
override;
221 void OnPaint(wxPaintEvent& event)
override;
222 void OnLeftDClick(wxMouseEvent& event)
override;
225 void FillFromFile(
const wxString& url,
const wxString& dir,
226 bool selnew =
false,
bool selupd =
false);
228 void SetBulkUpdate(
bool bulk_update);
231 int GetCheckedChartCount();
232 bool isChartChecked(
int i);
233 void CheckAllCharts(
bool value);
234 void InvertCheckAllCharts();
236 void CheckNewCharts(
bool value);
237 void CheckUpdatedCharts(
bool value);
242 wxWindow* parent =
nullptr,
243 wxWindowID
id = wxID_ANY,
244 const wxPoint& pos = wxDefaultPosition,
245 const wxSize& size = wxDefaultSize,
246 long style = wxDEFAULT_DIALOG_STYLE |
248 void SelectCatalog(
int item);
250 void CancelDownload() {
252 wxEVT_DOWNLOAD_EVENT,
253 (wxObjectEventFunction)(wxEventFunction)&ChartDldrPanelImpl::onDLEvent);
255 m_is_connected =
false;
257 void OnContextMenu(wxMouseEvent& event)
override;
260 DECLARE_EVENT_TABLE()
265 void OnChangeType(wxCommandEvent& event);
266 void OnSourceSelected(wxTreeEvent& event)
override;
267 void OnOkClick(wxCommandEvent& event)
override;
268 void OnCancelClick(wxCommandEvent& event)
override;
271 bool LoadSections(
const wxTreeItemId& root,
pugi::xml_node& node);
273 bool LoadCatalogs(
const wxTreeItemId& root,
pugi::xml_node& node);
279 void SetBasePath(
const wxString& path) { m_base_path = path; }
280 void SetSourceEdit(std::unique_ptr<ChartSource>& cs);
283 wxString m_base_path;
284 wxString m_last_path;
285 wxImageList* p_iconList;
287 wxImageList* p_buttonIconList;
290 bool ValidateUrl(
const wxString& Url,
bool catalog_xml =
true);
291 wxString FixPath(
const wxString& path);
296 void OnOkClick(wxCommandEvent& event)
override;
301 [[nodiscard]] wxString GetPath()
const {
return m_tcDefaultDir->GetValue(); }
302 void SetPath(
const wxString& path);
303 void GetPreferences(
bool& preselect_new,
bool& preselect_updated,
305 void SetPreferences(
bool preselect_new,
bool preselect_updated,
Chart Downloader Plugin chart classes.
Implementing ChartDldrPanel.
The PlugIn Class Definition.
wxBitmap * GetPlugInBitmap() override
Get the plugin's icon bitmap.
wxString GetShortDescription() override
Get a brief description of the plugin.
int GetAPIVersionMinor() override
Returns the minor version number of the plugin API that this plugin supports.
void ShowPreferencesDialog(wxWindow *parent) override
Shows the plugin preferences dialog.
int GetPlugInVersionMinor() override
Returns the minor version number of the plugin itself.
wxString GetCommonName() override
Get the plugin's common (short) name.
void OnSetupOptions() override
Allows plugin to add pages to global Options dialog.
bool DeInit() override
Clean up plugin resources.
wxString GetLongDescription() override
Get detailed plugin information.
int GetPlugInVersionMajor() override
Returns the major version number of the plugin itself.
void OnCloseToolboxPanel(int page_sel, int ok_apply_cancel) override
Handles preference page closure.
int Init() override
Initialize the plugin and declare its capabilities.
int GetAPIVersionMajor() override
Returns the major version number of the plugin API that this plugin supports.
PlugIn Object Definition/API.
wxString * GetpSharedDataLocation()
Gets shared application data location.