void StatusNotifier::cleanup() { // Disable the loop data = NULL; // True if there was anything to abort bool abort = false; // Abort the update job, if any if(updateJob && !updateJob->isFinished()) { updateJob->abort(); abort = true; } // Abort any other job WatchList::iterator it; for(it = watchList.begin(); it != watchList.end(); it++) { JobInfoPtr job = it->second; if(job && !job->isFinished()) { job->abort(); abort = true; } } // Give jobs some time to finish. This is run after the main window // closes, so a delay before exiting won't disturb the user. if(abort) wxSleep(1); }
void check(JobInfoPtr info) { if(info->isSuccess()) cout << "SUCCESS: " << info->getMessage() << " prog=" << info->getCurrent() << "/" << info->getTotal() << endl; else cout << "FAILURE: " << info->getMessage() << endl; }
bool progress(int64_t total, int64_t now) { info->setProgress(now, total); // Abort the download if the user requested it. if(info->checkStatus()) return false; return true; }
void inst(const std::string &where, bool doUpgrade) { cout << "\nINSTALLING to " << where << endl; JobInfoPtr inf = spr->installPack("test", "test", where, NULL, false, doUpgrade); if(inf) if(inf->isSuccess()) cout << "SUCCESS!\n"; else inf->failError(); else cout << "NO JOB EXECUTED\n"; printDir(where); }
void uninst(const std::string &where) { cout << "\nUNINSTALLING " << where << endl; JobInfoPtr inf = spr->uninstallPack("test", "test", where, false); if(inf) if(inf->isSuccess()) cout << "SUCCESS!\n"; else inf->failError(); else cout << "NO JOB EXECUTED\n"; shortStatus(*spr); if(bf::exists(where)) throw runtime_error("ERROR: dir still exists!\n"); }
void testStatus(Job &j) { JobInfoPtr info = j.getInfo(); if(info->isBusy()) cout << "Busy!"; else if(!info->hasStarted()) cout << "Not started yet!"; else if(info->isSuccess()) cout << "Success!"; else if(info->isError()) cout << "Failure: " << info->getMessage(); else if(info->isAbort()) cout << "Abort!"; cout << " - progress " << info->getCurrent() << "/" << info->getTotal() << endl; }
void StatusNotifier::tick() { // If the data pointer hasn't been set yet, we aren't ready to do // anything. So just exit. if(!data) return; // Check if we're updating the entire dataset first if(updateJob && updateJob->isFinished()) { if(updateJob->isSuccess()) { PRINT("Update job successful"); data->updateReady(); } else { /* TODO: If the job failed, but the base Spread update succeeded, then the update will not be attempted again until the next release. This means we might be sitting on a partially updated repo and it won't be fixed. */ PRINT("Update job FAILED: " << updateJob->getMessage()); } updateJob.reset(); } // How much do we need to update bool soft = false; bool hard = false; WatchList::iterator it, itold; for(it = watchList.begin(); it != watchList.end();) { // If there are any elements being installed at all, always // update the displays. soft = true; // Increase the iterator, since we might erase it from the // list below, invalidating the current position. itold = it++; // Get the GameInf pointer GameInf* inf = getFromId(data->repo, itold->first); if(!inf) continue; // Get the stored job JobInfoPtr job = itold->second; // Check that we have the right job attached assert(job == inf->info.getStatus()); // If we are no longer working, update main status and remove // ourselves from the list if(job->isFinished()) { watchList.erase(itold); hard = true; // Report errors to the user if(job->isError()) Boxes::error(job->getMessage()); } // Update the object status inf->updateStatus(); } /* A 'hard' update means totally refresh the 'installed' list, and tell all tabs to update game data - screenshot, button information etc - in case the currently selected game has changed status. */ if(hard) statusChanged(); /* A 'soft' update just refreshes the list views. It's only meant to update the percentages when downloading/installing. */ else if(soft) data->updateDisplayStatus(); }