diff options
author | Your Name <you@example.com> | 2020-11-18 11:38:59 -0500 |
---|---|---|
committer | Your Name <you@example.com> | 2020-11-18 11:38:59 -0500 |
commit | dcfac3432f981191da68f14f21f5010fc4da51c0 (patch) | |
tree | 7e2a405d15f0ce4ce1c83e070d68fcb5088ed3c2 /mods.cc | |
parent | 49c05187f739779a6433f75a348529c26e123e94 (diff) | |
download | libbible-dcfac3432f981191da68f14f21f5010fc4da51c0.tar.gz libbible-dcfac3432f981191da68f14f21f5010fc4da51c0.tar.bz2 libbible-dcfac3432f981191da68f14f21f5010fc4da51c0.zip |
Fixed issue with status reporting
Diffstat (limited to 'mods.cc')
-rw-r--r-- | mods.cc | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -10,9 +10,9 @@ using namespace std; class myStatusReporter : public sword::StatusReporter { public: myStatusReporter(libbible::Status *status); - virtual ~myStatusReporter(); - virtual void preStatus(long totalBytes, long completedBytes, const char *message); - virtual void update(unsigned long totalBytes, unsigned long completedBytes); + ~myStatusReporter(); + void preStatus(long totalBytes, long completedBytes, const char *message); + void update(unsigned long totalBytes, unsigned long completedBytes); protected: libbible::Status *status; string message; @@ -24,31 +24,33 @@ myStatusReporter::myStatusReporter(libbible::Status *s) { myStatusReporter::~myStatusReporter() {}; -void libbible::Status::update(unsigned long totalBytes, unsigned long completedBytes, string message) {} +//virtual void libbible::Status::update(unsigned long totalBytes, unsigned long completedBytes, string message) {} void myStatusReporter::preStatus(long totalBytes, long completedBytes, const char *msg) { message = string(msg); status->update((unsigned long) totalBytes, (unsigned long) completedBytes, message); + //printf("Got a status update: %ld / %ld, \"%s\"\n", completedBytes, totalBytes, message.c_str()); } void myStatusReporter::update(unsigned long totalBytes, unsigned long completedBytes) { status->update(totalBytes, completedBytes, message); + //printf("Got a status update: %ld / %ld, \"%s\"\n", completedBytes, totalBytes, message.c_str()); } string basedir = (getenv("HOME")) + string("/.sword/"); sword::InstallMgr *installMgr = new sword::InstallMgr((basedir + std::string("InstallMgr")).c_str(), nullptr); map<string, vector<pair<string, sword::InstallSource *>>> installSources; -map<string, vector<string>> libbible::downloadModsAvailable(libbible::Status *status) { +void libbible::setStatusReporter(libbible::Status& status) { + myStatusReporter *msr = new myStatusReporter(&status); + free(installMgr); + installMgr = new sword::InstallMgr((basedir + std::string("InstallMgr")).c_str(), msr); +} + +map<string, vector<string>> libbible::downloadModsAvailable() { installSources.clear(); mkdir((basedir + std::string("mods.d/")).c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); mkdir((basedir + std::string("modules/")).c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); - myStatusReporter *msr = nullptr; - if(status) { - msr = new myStatusReporter(status); - } - free(installMgr); - installMgr = new sword::InstallMgr((basedir + std::string("InstallMgr")).c_str(), msr); installMgr->setUserDisclaimerConfirmed(true); string confpath = basedir + string("InstallMgr/InstallMgr.conf"); if(! sword::FileMgr::existsFile(confpath.c_str())) { |