From 44f16b6cd5b9cd9641c0c5df1c671c9e610ad7ac Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 6 Nov 2020 15:28:10 -0500 Subject: Added mod installation to cli interface --- mods.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'mods.cc') diff --git a/mods.cc b/mods.cc index c30fce4..1a31602 100644 --- a/mods.cc +++ b/mods.cc @@ -62,9 +62,9 @@ map> libbible::downloadModsAvailable(libbible::Status *st config["General"]["PassiveFTP"] = "true"; config["Sources"]["FTPSource"] = is.getConfEnt(); config.save(); + installMgr->refreshRemoteSourceConfiguration(); } installMgr->readInstallConf(); - installMgr->refreshRemoteSourceConfiguration(); map> modsAvailable; //printf("Getting langs...\n"); for(auto src : installMgr->sources) { @@ -96,15 +96,21 @@ void libbible::terminateDownload() { installMgr->terminate(); } -void libbible::installModFromInternet(string language, string name) { +bool libbible::installModFromInternet(string language, string name) { // Searching through map>> installSources; + if(installSources.empty()) { + downloadModsAvailable(); + } for (pair p : installSources[language]) { if(p.first == name) { sword::SWMgr mgr(basedir.c_str()); - installMgr->installModule(&mgr, 0, name.c_str(), p.second); - break; + if(installMgr->installModule(&mgr, 0, name.c_str(), p.second) == 0) { + return true; + } + return false; } } + return false; } void libbible::installModFromZip(string filename) { @@ -122,5 +128,7 @@ void libbible::installModFromZip(string filename) { void libbible::uninstallMod(string modname) { sword::SWMgr mgr(basedir.c_str()); sword::ModMap::iterator it = mgr.Modules.find(modname.c_str()); - installMgr->removeModule(&mgr, it->second->getName()); + if(it != mgr.Modules.end()) { + installMgr->removeModule(&mgr, it->second->getName()); + } } -- cgit v1.2.3