39#include "load_errors_dlg.h"
40#include "observable_evt.h"
41#include "model/plugin_handler.h"
42#include "model/plugin_loader.h"
44#include "androidUTIL.h"
49static const char*
const kBadPluginsIntro = _(R
"(
50The following plugins have encountered errors during startup:
54static const char*
const kBadPluginIntro = _(R
"(
55The following plugin has encountered errors during startup:
59static const char*
const kBadLibsIntro = _(R
"(
60The following libraries have encountered errors during startup:
64static const char*
const kBadLibIntro = _(R
"(
65The following library has encountered errors during startup:
68static const char*
const kBadPluginsFooter = _(R
"(
70These plugins will be uninstalled. You might want to reinstall
71them after updating the catalog.
74static const char*
const kBadPluginFooter = _(R
"(
76This plugin will be uninstalled. You might want to reinstall
77it after updating the catalog.
80static const char*
const kBadLibsFooter = _(R
"(
82These libraries will be removed. You might want to reinstall their
83associated plugin after updating the catalog.)");
85static const char*
const kBadLibFooter = _(R
"(
87The library will be removed. You might want to reinstall it's
88associated 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);
102 if (plugin !=
"") plugins.push_back(plugin);
103 if (e.lib_path !=
"") libs.push_back(e.lib_path);
111 std::string FormatMsg(
const FormatCtx& ctx) {
112 auto handler = PluginHandler::getInstance();
113 std::stringstream ss;
114 if (ctx.plugins.size() > 0) {
115 ss << (ctx.plugins.size() == 1 ? kBadPluginIntro : kBadPluginsIntro);
116 for (
const auto& p : ctx.plugins) {
117 ss <<
" " << p <<
"\n";
119 ss << (ctx.plugins.size() == 1 ? kBadPluginFooter : kBadPluginsFooter);
121 if (ctx.libs.size() > 0) {
122 ss << (ctx.libs.size() == 1 ? kBadLibIntro : kBadLibsIntro);
123 for (
const auto& lib : ctx.libs) {
124 ss <<
" " << lib <<
"\n";
126 ss << (ctx.libs.size() == 1 ? kBadLibFooter : kBadLibsFooter);
133static void Run(wxWindow* parent,
const std::vector<LoadError>& errors) {
138 std::string ss = dlg.FormatMsg(format_ctx);
139 androidShowSimpleOKDialog(
"Error", ss);
142 int sts = dlg.ShowModal();
144 if (sts == wxID_YES || sts == wxID_OK) {
145 for (
const auto& plugin : format_ctx.plugins) {
146 PluginHandler::getInstance()->
uninstall(plugin);
148 for (
const auto& lib : format_ctx.libs) {
149 if (isRegularFile(lib.c_str())) remove(lib.c_str());
154LoadErrorsDlgCtrl::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.