UpdaterState CUpdater::ProcessFinishedData(bool can_download) { UpdaterState s = failed; ParseData(); if( version_information_.available_.version_.empty() ) { s = idle; } else if( !version_information_.available_.url_.empty() ) { wxString const temp = GetTempFile(); wxString const local_file = GetLocalFile(version_information_.available_, true); if( !local_file.empty() && CLocalFileSystem::GetFileType(local_file) != CLocalFileSystem::unknown) { local_file_ = local_file; log_ += wxString::Format(_("Local file is %s\n"), local_file.c_str()); s = newversion_ready; } else { // We got a checksum over a secure channel already. update_options_->m_use_internal_rootcert = false; if( temp.empty() || local_file.empty() ) { s = newversion; } else { s = newversion_downloading; wxLongLong size = CLocalFileSystem::GetSize(temp); if( size >= 0 && static_cast<unsigned long long>(size.GetValue()) >= version_information_.available_.size_ ) { s = ProcessFinishedDownload(); } else if( !can_download || Download( version_information_.available_.url_, GetTempFile() ) != FZ_REPLY_WOULDBLOCK ) { s = newversion; } } } } else { s = newversion; } return s; }
void CUpdater::ProcessOperation(CNotification* notification) { if( state_ != checking && state_ != newversion_downloading ) { return; } UpdaterState s = failed; COperationNotification* operation = reinterpret_cast<COperationNotification*>(notification); if (operation->nReplyCode != FZ_REPLY_OK) { if( state_ != checking ) { s = newversion; } } else if( state_ == checking ) { s = ProcessFinishedData(true); } else { s = ProcessFinishedDownload(); } SetState(s); }
void CUpdater::ProcessOperation(COperationNotification const& operation) { if( state_ != UpdaterState::checking && state_ != UpdaterState::newversion_downloading ) { return; } if (pending_commands_.empty()) { SetState(UpdaterState::failed); return; } UpdaterState s = UpdaterState::failed; int res = operation.nReplyCode; if (res == FZ_REPLY_OK || (operation.commandId == Command::disconnect && res & FZ_REPLY_DISCONNECTED)) { pending_commands_.pop_front(); res = ContinueDownload(); if (res == FZ_REPLY_WOULDBLOCK) { return; } } if (res != FZ_REPLY_OK) { if (state_ != UpdaterState::checking) { s = UpdaterState::newversion; } } else if( state_ == UpdaterState::checking ) { s = ProcessFinishedData(true); } else { s = ProcessFinishedDownload(); } SetState(s); }