36 #include <wx/window.h>
40 #include "observable_evt.h"
41 #include "model/plugin_handler.h"
42 #include "model/plugin_loader.h"
44 #include "androidUTIL.h"
49 static const char*
const kBadPluginsIntro = _(R
"(
50 The following plugins have encountered errors during startup:
54 static const char*
const kBadPluginIntro = _(R
"(
55 The following plugin has encountered errors during startup:
59 static const char*
const kBadLibsIntro = _(R
"(
60 The following libraries have encountered errors during startup:
64 static const char*
const kBadLibIntro = _(R
"(
65 The following library has encountered errors during startup:
68 static const char*
const kBadPluginsFooter = _(R
"(
70 These plugins will be uninstalled. You might want to reinstall
71 them after updating the catalog.
74 static const char*
const kBadPluginFooter = _(R
"(
76 This plugin will be uninstalled. You might want to reinstall
77 it after updating the catalog.
80 static const char*
const kBadLibsFooter = _(R
"(
82 These libraries will be removed. You might want to reinstall their
83 associated plugin after updating the catalog.)");
85 static const char*
const kBadLibFooter = _(R
"(
87 The library will be removed. You might want to reinstall it's
88 associated plugin after updating the catalog.)");
95 std::vector<std::string> plugins;
96 std::vector<std::string> libs;
98 FormatCtx(
const std::vector<LoadError> errors) {
99 auto handler = PluginHandler::getInstance();
100 for (
const auto& e : errors) {
101 auto plugin = handler->getPluginByLibrary(e.lib_path);
103 plugins.push_back(plugin);
105 libs.push_back(e.lib_path);
113 std::string FormatMsg(
const FormatCtx& ctx) {
114 auto handler = PluginHandler::getInstance();
115 std::stringstream ss;
116 if (ctx.plugins.size() > 0) {
117 ss << (ctx.plugins.size() == 1 ? kBadPluginIntro : kBadPluginsIntro);
118 for (
const auto& p : ctx.plugins) {
119 ss <<
" " << p <<
"\n";
121 ss << (ctx.plugins.size() == 1 ? kBadPluginFooter : kBadPluginsFooter);
123 if (ctx.libs.size() > 0) {
124 ss << (ctx.libs.size() == 1 ? kBadLibIntro : kBadLibsIntro);
125 for (
const auto& lib : ctx.libs) {
126 ss <<
" " << lib <<
"\n";
128 ss << (ctx.libs.size() == 1 ? kBadLibFooter : kBadLibsFooter);
135 static void Run(wxWindow* parent,
const std::vector<LoadError>& errors) {
140 std::string ss = dlg.FormatMsg(format_ctx);
141 androidShowSimpleOKDialog(
"Error", ss);
144 int sts = dlg.ShowModal();
146 if (sts == wxID_YES || sts == wxID_OK) {
147 for (
const auto& plugin : format_ctx.plugins) {
148 PluginHandler::getInstance()->
uninstall(plugin);
150 for (
const auto& lib : format_ctx.libs) remove(lib.c_str());
154 LoadErrorsDlgCtrl::LoadErrorsDlgCtrl(wxWindow* parent) : m_parent(parent) {
155 auto loader = PluginLoader::getInstance();
157 load_complete_listener.Listen(loader->evt_plugin_loadall_finalize,
this,
160 auto errors = UnpackEvtPointer<std::vector<LoadError>>(ev);
161 if (errors->size() != 0) Run(m_parent, *errors);
Unloadable plugins report message box.
Adds a std::shared<void> element to wxCommandEvent.
bool uninstall(const std::string plugin)
Uninstall an installed and loaded plugin.
General purpose GUI support.
Handle dialog reporting plugin load errors.
wxDEFINE_EVENT(REST_IO_EVT, ObservedEvt)
Event from IO thread to main.