void CUpdater::Init() { raw_version_information_ = COptions::Get()->GetOption( OPTION_UPDATECHECK_NEWVERSION ); UpdaterState s = ProcessFinishedData(FZ_AUTOUPDATECHECK); SetState(s); RunIfNeeded(); update_timer_.SetOwner(this); update_timer_.Start(1000 * 3600); if( !instance ) { instance = this; } }
void CUpdater::Init() { if( state_ == UpdaterState::checking || state_ == UpdaterState::newversion_downloading ) { return; } raw_version_information_ = COptions::Get()->GetOption( OPTION_UPDATECHECK_NEWVERSION ); UpdaterState s = ProcessFinishedData(FZ_AUTOUPDATECHECK); SetState(s); AutoRunIfNeeded(); update_timer_.SetOwner(this); update_timer_.Start(1000 * 3600); if( !instance ) { instance = this; } }
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); }