diff options
Diffstat (limited to 'mods.cc')
-rw-r--r-- | mods.cc | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -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()); + } } |