36#include "observable/event.h"
42#include "load_errors_dlg.h"
45#include "androidUTIL.h"
50static const char*
const kBadPluginsIntro = _(R
"(
51The following plugins have encountered errors during startup:
55static const char*
const kBadPluginIntro = _(R
"(
56The following plugin has encountered errors during startup:
60static const char*
const kBadLibsIntro = _(R
"(
61The following libraries have encountered errors during startup:
65static const char*
const kBadLibIntro = _(R
"(
66The following library has encountered errors during startup:
69static const char*
const kBadPluginsFooter = _(R
"(
71These plugins will be uninstalled. You might want to reinstall
72them after updating the catalog.
75static const char*
const kBadPluginFooter = _(R
"(
77This plugin will be uninstalled. You might want to reinstall
78it after updating the catalog.
81static const char*
const kBadLibsFooter = _(R
"(
83These libraries will be removed. You might want to reinstall their
84associated plugin after updating the catalog.)");
86static const char*
const kBadLibFooter = _(R
"(
88The library will be removed. You might want to reinstall it's
89associated plugin after updating the catalog.)");
96 std::vector<std::string> plugins;
97 std::vector<std::string> libs;
99 FormatCtx(
const std::vector<LoadError> errors) {
101 for (
const auto& e : errors) {
102 auto plugin = handler->GetPluginByLibrary(e.lib_path);
103 if (plugin !=
"") plugins.push_back(plugin);
104 if (e.lib_path !=
"") libs.push_back(e.lib_path);
112 std::string FormatMsg(
const FormatCtx& ctx) {
114 std::stringstream ss;
115 if (ctx.plugins.size() > 0) {
116 ss << (ctx.plugins.size() == 1 ? kBadPluginIntro : kBadPluginsIntro);
117 for (
const auto& p : ctx.plugins) {
118 ss <<
" " << p <<
"\n";
120 ss << (ctx.plugins.size() == 1 ? kBadPluginFooter : kBadPluginsFooter);
122 if (ctx.libs.size() > 0) {
123 ss << (ctx.libs.size() == 1 ? kBadLibIntro : kBadLibsIntro);
124 for (
const auto& lib : ctx.libs) {
125 ss <<
" " << lib <<
"\n";
127 ss << (ctx.libs.size() == 1 ? kBadLibFooter : kBadLibsFooter);
134static void Run(wxWindow* parent,
const std::vector<LoadError>& errors) {
139 std::string ss = dlg.FormatMsg(format_ctx);
140 androidShowSimpleOKDialog(
"Error", ss);
143 int sts = dlg.ShowModal();
145 if (sts == wxID_YES || sts == wxID_OK) {
146 for (
const auto& plugin : format_ctx.plugins) {
149 for (
const auto& lib : format_ctx.libs) {
150 if (isRegularFile(lib.c_str())) remove(lib.c_str());
155LoadErrorsDlgCtrl::LoadErrorsDlgCtrl(wxWindow* parent) : m_parent(parent) {
156 auto loader = PluginLoader::GetInstance();
158 load_complete_listener.Listen(loader->evt_plugin_loadall_finalize,
this,
161 auto errors = obs::UnpackEvtPointer<std::vector<LoadError>>(ev);
162 if (errors->size() != 0) Run(m_parent, *errors);
Unloadable plugins report message box.
Custom event class for OpenCPN's notification system.
bool Uninstall(const std::string plugin)
Uninstall an installed and loaded plugin.
static PluginHandler * GetInstance()
Singleton factory.
General purpose GUI support.
Plugin remote repositories installation and Uninstall/list operations.
Low level code to load plugins from disk, notably the PluginLoader class.