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 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(); }