load plugins from config
This commit is contained in:
parent
132f8cfcd6
commit
e632676b33
25
src/main.cpp
25
src/main.cpp
@ -144,17 +144,15 @@ int main(int argc, char** argv) {
|
|||||||
conf.set("tox", "save_file_path", (config_path_base / "totato.tox").u8string());
|
conf.set("tox", "save_file_path", (config_path_base / "totato.tox").u8string());
|
||||||
} else { // transform relative to config to absolute
|
} else { // transform relative to config to absolute
|
||||||
const auto tox_conf_path = std::filesystem::path{conf.get_string("tox", "save_file_path").value()};
|
const auto tox_conf_path = std::filesystem::path{conf.get_string("tox", "save_file_path").value()};
|
||||||
if (tox_conf_path.has_relative_path()) {
|
if (tox_conf_path.is_relative()) {
|
||||||
// is relative to config
|
// is relative to config
|
||||||
conf.set("tox", "save_file_path", std::filesystem::canonical(tox_conf_path).u8string());
|
conf.set("tox", "save_file_path", std::filesystem::canonical(config_path_base / tox_conf_path).u8string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: name
|
// TODO: name
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.dump();
|
|
||||||
|
|
||||||
Contact3Registry cr;
|
Contact3Registry cr;
|
||||||
RegistryMessageModel rmm{cr};
|
RegistryMessageModel rmm{cr};
|
||||||
MessageTimeSort mts{rmm};
|
MessageTimeSort mts{rmm};
|
||||||
@ -195,13 +193,26 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load from config!!!
|
// load from config!!!
|
||||||
for (const auto& ppath : {"../../solanaceae_ecosystem/build/bin/libplugin_transfer_auto_accept.so"}) {
|
// HACK: we cheat and directly access the members
|
||||||
if (!pm.add(ppath)) {
|
// TODO: add api to iterate
|
||||||
std::cerr << "TOTATO error: loading plugin '" << ppath << "' failed!\n";
|
if (conf._map_bool.count("PluginManager") && conf._map_bool.at("PluginManager").count("autoload")) {
|
||||||
|
const auto config_path_base = std::filesystem::path{config_path}.parent_path();
|
||||||
|
|
||||||
|
for (const auto& [plugin_path, plugin_autoload] : conf._map_bool.at("PluginManager").at("autoload").second) {
|
||||||
|
if (plugin_autoload) {
|
||||||
|
std::filesystem::path real_plugin_path = plugin_path;
|
||||||
|
if (real_plugin_path.is_relative()) {
|
||||||
|
real_plugin_path = config_path_base / real_plugin_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pm.add(real_plugin_path.u8string())) {
|
||||||
|
std::cerr << "TOTATO error: loading plugin '" << real_plugin_path << "' failed!\n";
|
||||||
// thow?
|
// thow?
|
||||||
assert(false && "failed to load plugin");
|
assert(false && "failed to load plugin");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
conf.dump();
|
conf.dump();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user