From dcfac3432f981191da68f14f21f5010fc4da51c0 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 18 Nov 2020 11:38:59 -0500 Subject: Fixed issue with status reporting --- mods.cc | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'mods.cc') diff --git a/mods.cc b/mods.cc index 6b2063a..903c91f 100644 --- a/mods.cc +++ b/mods.cc @@ -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>> installSources; -map> 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> 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())) { -- cgit v1.2.3