aboutsummaryrefslogtreecommitdiff
path: root/mods.cc
diff options
context:
space:
mode:
authorYour Name <you@example.com>2020-11-06 15:28:10 -0500
committerYour Name <you@example.com>2020-11-06 15:28:10 -0500
commit44f16b6cd5b9cd9641c0c5df1c671c9e610ad7ac (patch)
tree47e540ac3e98d8f68a0e0ab36f1c1bc03beb2d35 /mods.cc
parent7fc8ebf27892eb02488fd2e75ca35ae48f596782 (diff)
downloadlibbible-44f16b6cd5b9cd9641c0c5df1c671c9e610ad7ac.tar.gz
libbible-44f16b6cd5b9cd9641c0c5df1c671c9e610ad7ac.tar.bz2
libbible-44f16b6cd5b9cd9641c0c5df1c671c9e610ad7ac.zip
Added mod installation to cli interface
Diffstat (limited to 'mods.cc')
-rw-r--r--mods.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/mods.cc b/mods.cc
index c30fce4..1a31602 100644
--- a/mods.cc
+++ b/mods.cc
@@ -62,9 +62,9 @@ map<string, vector<string>> libbible::downloadModsAvailable(libbible::Status *st
config["General"]["PassiveFTP"] = "true";
config["Sources"]["FTPSource"] = is.getConfEnt();
config.save();
+ installMgr->refreshRemoteSourceConfiguration();
}
installMgr->readInstallConf();
- installMgr->refreshRemoteSourceConfiguration();
map<string, vector<string>> 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<string, vector<pair<string, sword::InstallSource *>>> installSources;
+ if(installSources.empty()) {
+ downloadModsAvailable();
+ }
for (pair<string, sword::InstallSource *> 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());
+ }
}