bool LLUpdaterServiceImpl::checkForResume() { bool result = false; std::string download_marker_path = mUpdateDownloader.downloadMarkerPath(); if(LLFile::isfile(download_marker_path)) { llifstream download_marker_stream(download_marker_path, std::ios::in | std::ios::binary); if(download_marker_stream.is_open()) { LLSD download_info; LLSDSerialize::fromXMLDocument(download_info, download_marker_stream); download_marker_stream.close(); if(download_info["current_version"].asString() == ll_get_version()) { mIsDownloading = true; mNewVersion = download_info["update_version"].asString(); mUpdateDownloader.resume(); result = true; } else { // The viewer that started this download is not the same as this viewer; ignore. llinfos << "ignoring partial download from different viewer version" << llendl; std::string path = download_info["path"].asString(); if(!path.empty()) LLFile::remove(path); LLFile::remove(download_marker_path); } } } return result; }
void LLUpdaterServiceImpl::requiredUpdate(std::string const & newVersion, LLURI const & uri, std::string const & hash) { stopTimer(); mNewVersion = newVersion; mIsDownloading = true; setState(LLUpdaterService::DOWNLOADING); mUpdateDownloader.download(uri, hash, newVersion, true); }
void LLUpdaterServiceImpl::stopChecking() { if(mIsChecking) { mIsChecking = false; stopTimer(); } if(mIsDownloading) { mUpdateDownloader.cancel(); mIsDownloading = false; } setState(LLUpdaterService::TERMINAL); }
// A successful response was received from the viewer version manager void LLUpdaterServiceImpl::response(LLSD const & content) { if(!content.asBoolean()) // an empty response means "no update" { LL_INFOS("UpdaterService") << "up to date" << LL_ENDL; if(mIsChecking) { restartTimer(mCheckPeriod); } setState(LLUpdaterService::UP_TO_DATE); } else if ( content.isMap() && content.has("url") ) { // there is an update available... stopTimer(); mNewChannel = content["channel"].asString(); if (mNewChannel.empty()) { LL_INFOS("UpdaterService") << "no channel supplied, assuming current channel" << LL_ENDL; mNewChannel = mChannel; } mNewVersion = content["version"].asString(); mIsDownloading = true; setState(LLUpdaterService::DOWNLOADING); BOOL required = content["required"].asBoolean(); LLURI url(content["url"].asString()); std::string more_info = content["more_info"].asString(); LL_DEBUGS("UpdaterService") << "Starting download of " << ( required ? "required" : "optional" ) << " update" << " to channel '" << mNewChannel << "' version " << mNewVersion << " more info '" << more_info << "'" << LL_ENDL; mUpdateDownloader.download(url, content["hash"].asString(), mNewChannel, mNewVersion, more_info, required); } else { LL_WARNS("UpdaterService") << "Invalid update query response ignored; retry in " << mCheckPeriod << " seconds" << LL_ENDL; restartTimer(mCheckPeriod); } }
void LLUpdaterServiceImpl::setBandwidthLimit(U64 bytesPerSecond) { mUpdateDownloader.setBandwidthLimit(bytesPerSecond); }