/* ============ sdGUIDFile::WriteBans ============ */ bool sdGUIDFile::WriteBans( int& startIndex, idBitMsg& msg ) { CheckForUpdates(); const int MAX_WRITE_BANS = 5; int count = 0; int i = startIndex + 1; for ( ; i < info.Num(); i++ ) { sdGUIDInfo& gInfo = info[ i ]; if ( !gInfo.IsBanned() ) { continue; } count++; msg.WriteLong( i ); idStr name; gInfo.GetPrintableName( name ); msg.WriteString( name.c_str() ); if ( count == MAX_WRITE_BANS ) { startIndex = i; return false; } } startIndex = -1; return true; }
/* ============ sdGUIDFile::AuthUser ============ */ void sdGUIDFile::AuthUser( int clientNum, const clientGUIDLookup_t& lookup ) { CheckForUpdates(); for ( int i = 0; i < info.Num(); i++ ) { sdGUIDInfo& gInfo = info[ i ]; if ( !gInfo.Match( lookup ) ) { continue; } const char* authGroup = gInfo.GetAuthGroup(); if ( !*authGroup ) { continue; } int group = sdUserGroupManager::GetInstance().FindGroup( authGroup ); if ( group == -1 ) { continue; } gameLocal.rules->SetPlayerUserGroup( clientNum, group ); return; } gameLocal.rules->SetPlayerUserGroup( clientNum, -1 ); }
/* ============ sdGUIDFile::BanUser ============ */ void sdGUIDFile::BanUser( const clientGUIDLookup_t& lookup, int length ) { CheckForUpdates(); int index = -1; for ( int i = 0; i < info.Num(); i++ ) { sdGUIDInfo& gInfo = info[ i ]; if ( !gInfo.Match( lookup ) ) { continue; } index = i; break; } if ( index == -1 ) { index = info.Num(); info.Alloc().SetMatch( lookup ); } sdGUIDInfo& gInfo = info[ index ]; gInfo.Ban( length ); WriteGUIDFile(); }
void LoaderGUI::showEvent(QShowEvent *event) { QWidget::showEvent(event); #ifdef NDEBUG // Check for MHUD2 updates automatically... CheckForUpdates(); #endif }
void CRepositoryUpdater::CheckForUpdates(bool showProgress) { VECADDONS addons; if (CAddonMgr::GetInstance().GetAddons(ADDON_REPOSITORY, addons) && !addons.empty()) { CSingleLock lock(m_criticalSection); for (const auto& addon : addons) CheckForUpdates(std::static_pointer_cast<ADDON::CRepository>(addon), showProgress); } }
void c_version_check_manager_dedi::TestForUpdate() { c_version_check_manager_base::TestForUpdate(); // check for updates using blocking if(!m_states.checked_today) { blam::console_printf(false, "Checking for updates..."); CheckForUpdates(); } }
bool CRepositoryUpdater::CheckForUpdates(bool showProgress) { VECADDONS addons; if (m_addonMgr.GetAddons(addons, ADDON_REPOSITORY) && !addons.empty()) { CSingleLock lock(m_criticalSection); for (const auto& addon : addons) CheckForUpdates(std::static_pointer_cast<ADDON::CRepository>(addon), showProgress); return true; } return false; }
/* ============ sdGUIDFile::ListBans ============ */ void sdGUIDFile::ListBans( void ) { CheckForUpdates(); for ( int i = 0; i < info.Num(); i++ ) { sdGUIDInfo& gInfo = info[ i ]; if ( !gInfo.IsBanned() ) { continue; } idStr name; gInfo.GetPrintableName( name ); gameLocal.Printf( "%d: %s\n", i, name.c_str() ); } }
void CRepositoryUpdater::OnTimeout() { //workaround if (g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO || g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW) { CLog::Log(LOGDEBUG,"CRepositoryUpdater: busy playing. postponing scheduled update"); m_timer.RestartAsync(2 * 60 * 1000); return; } CLog::Log(LOGDEBUG,"CRepositoryUpdater: running scheduled update"); CheckForUpdates(); }
wxString MainFrame::CheckForUpdates(wxString host, wxString url) { wxString update_url = wxT(""); wxHTTP get; get.SetHeader(_T("Content-type"), _T("text/html; charset=utf-8")); #ifdef __WXMSW__ get.SetHeader(wxT("User-Agent"), wxT("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0")); #endif get.SetTimeout(10); while (!get.Connect(host)) wxSleep(5); wxInputStream* httpStream = get.GetInputStream(url); if (get.GetError() == wxPROTO_NOERR) { if (httpStream != NULL) { size_t size = httpStream->GetSize(); if (httpStream) { wxTextInputStream text(*httpStream, wxT("\x09"), wxConvUTF8); while (httpStream->IsOk() && !httpStream->Eof() && update_url.IsEmpty()) { wxString line = text.ReadLine(); if (line.Contains(wxT("direct-download"))) { wxURL redirect_url(line.SubString(line.Find(wxT("http://")), line.Find(wxT("\" "))).BeforeLast('\"')); update_url = CheckForUpdates(redirect_url.GetServer(), redirect_url.GetPath() + wxT("?") + redirect_url.GetQuery()); } if (line.Contains(wxT(" redirected "))) { update_url = line.SubString(line.Find(wxT("http://")), line.Find(wxT(";"))).BeforeLast(';'); } } } delete httpStream; } } get.Close(); return update_url; }
/*! * \brief * Runs the update check if needed. * * Updates the date condition to see if a check has been performed today. * If it hasn't, an update check will be run. This check is not blocking, * so that normal running is not paused. If there is a new version available * The versions will be printed to the console when each map is loaded. * * \remarks * Since servers can be running for longer than 24 hours it's necessary * for the server to automatically check for updates at some point. Currently * this happens when a new map is loaded, however, if the server is running a * gametype that can run for a VERY long time, updates will be missed. */ void c_version_check_manager_dedi::InitializeForNewMap() { // update the date state UpdateDateState(); // if the version hasn't been checked today, check it without blocking // although, considering this is map load time a little delay for // getting the update might be ok if(m_states.is_request_in_progress) return; if(!m_states.checked_today) CheckForUpdates(); else DisplayVersions(m_states.is_new_version_available); }
/* ============ sdGUIDFile::RemoveOldEntries ============ */ void sdGUIDFile::RemoveOldEntries( void ) { CheckForUpdates( false ); bool changed = false; for ( int i = 0; i < info.Num(); ) { if ( info[ i ].IsFinished() ) { changed = true; info.RemoveIndexFast( i ); } else { i++; } } if ( changed ) { WriteGUIDFile(); } }
LRESULT CAppWindow::OnCommand(WORD wID) { switch (wID) { case ID_TRAYICON_EXIT: SendMessage(WM_SYSCOMMAND, SC_CLOSE); break; case ID_TRAYICON_CHECKFORUPDATESNOW: m_fManualUpdateCheck = TRUE; CheckForUpdates(); break; case ID_TRAYICON_INBOX: OpenInbox(); break; case ID_TRAYICON_LOGIN: PromptForCredentials(); break; case ID_TRAYICON_SIGNOUT: SignOut(TRUE); break; case ID_TRAYICON_HELP: DisplayHelp(); break; case ID_TRAYICON_ABOUT: (new CAboutDialog())->Create(DT_ABOUT, this); break; case ID_TRAYICON_OPTIONS: (new COptionsSheet())->Create(DT_OPTIONS, this); break; case ID_TRAYICON_CHECKWAVESNOW: CheckWavesNow(); break; } return 0; }
void CUpdaterApp::StartApplication(CString sCommandLine) { m_szUpdateUrl = _T(""); if(sCommandLine.Find(PARAMETER_CHECKNEWVERSION) >= 0) { sCommandLine.MakeLower(); if (sCommandLine.Find(_T("-beta")) >= 0) { m_szUpdateUrl = HTTP_REMOTE_ADDRES_BEAT_DOWNLOAD; } else if (sCommandLine.Find(_T("-debug")) >= 0 ) { m_szUpdateUrl = HTTP_LOCAL_ADDRES_DEBUG_DOWNLOAD; } else if (sCommandLine.Find(_T("-release")) >= 0 ) { m_szUpdateUrl = HTTP_REMOTE_ADDRES_REALEASE_DOWNLOAD; } else if (sCommandLine.Find(_T("-alpha")) >= 0 ) { m_szUpdateUrl = HTTP_REMOTE_ADDRES_ALPHA_DOWNLOAD; } else if (sCommandLine.Find(_T("-crack")) >= 0 ) { m_szUpdateUrl = _T("http://dl.dianlv.com/update/dianlvupdate"); } else if (sCommandLine.Find(_T("-english")) >= 0 ) { m_szUpdateUrl = HTTP_REMOTE_ADDRES_ENGLISH_DOWNLOAD; } else { } if (m_szUpdateUrl.IsEmpty()) { return; } CheckForUpdates(); //开始检查新版本操作 return; } //CheckForUpdates(); //开始检查新版本操作 }
/* ============ sdGUIDFile::CheckForBan ============ */ sdGUIDFile::banState_t sdGUIDFile::CheckForBan( const clientGUIDLookup_t& lookup ) { CheckForUpdates(); for ( int i = 0; i < info.Num(); i++ ) { sdGUIDInfo& gInfo = info[ i ]; if ( !gInfo.Match( lookup ) ) { continue; } if ( !gInfo.IsBanned() ) { continue; } if ( gInfo.GetBanEndTime() < 0 ) { return BS_PERM_BAN; } return BS_TEMP_BAN; } return BS_NOT_BANNED; }
bool MainFrame::CheckForUpdates() { #ifndef __WXMSW__ int ret = wxMessageBox(_("Online updates are available on Windows only. Please browse this site for updates.\n\nhttps://sourceforge.net/projects/vbam/files/latest/download"), _("Online Update"), wxOK | wxICON_INFORMATION); return true; #endif bool new_update_available = false; wxString update_url = CheckForUpdates(_T("sourceforge.net"), _T("/projects/vbam/files/latest/download")); if (!update_url.IsEmpty()) { wxFileConfig* cfg = wxGetApp().cfg; wxString update_filename = update_url.AfterLast('/'); if (gopts.last_updated_filename != update_filename) { new_update_available = true; int ret = wxMessageBox(_("A new update is available. To update, VisualBoyAdvance-M must be Run as administrator. Would you like to download and update VisualBoyAdvance-M?\n\nhttps://sourceforge.net/projects/vbam/files/latest/download"), _("New Update Available"), wxYES_NO | wxICON_QUESTION); if (ret == wxYES) { wxURL url(update_url); UpdateFile(url.GetServer(), url.GetPath()); ret = wxMessageBox(_("The update has been downloaded and installed. Please restart VisualBoyAdvance-M."), _("Update Downloaded"), wxOK | wxICON_INFORMATION); gopts.last_updated_filename = update_filename; cfg->Write(wxT("General/LastUpdatedFileName"), gopts.last_updated_filename); } } gopts.last_update = wxDateTime::Now().GetTicks(); cfg->Write(wxT("General/LastUpdated"), gopts.last_update); cfg->Flush(); } return new_update_available; }
/* ============ sdGUIDFile::AuthUser ============ */ void sdGUIDFile::SetAutoAuth( const clientGUIDLookup_t& lookup, const char* group ) { CheckForUpdates(); int index = -1; for ( int i = 0; i < info.Num(); i++ ) { sdGUIDInfo& gInfo = info[ i ]; if ( !gInfo.Match( lookup ) ) { continue; } index = i; break; } if ( index == -1 ) { index = info.Num(); info.Alloc().SetMatch( lookup ); } sdGUIDInfo& gInfo = info[ index ]; gInfo.SetAuthGroup( group ); WriteGUIDFile(); }
bool FvUpdater::CheckForUpdatesNotSilent() { return CheckForUpdates(false); }
bool FvUpdater::CheckForUpdatesSilent() { return CheckForUpdates(true); }
/* * Update policy and settings dialog callback */ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hPolicy; static HWND hFrequency, hBeta; int32_t freq; char update_policy_text[4096]; switch (message) { case WM_INITDIALOG: set_title_bar_icon(hDlg); center_dialog(hDlg); hFrequency = GetDlgItem(hDlg, IDC_UPDATE_FREQUENCY); hBeta = GetDlgItem(hDlg, IDC_INCLUDE_BETAS); IGNORE_RETVAL(ComboBox_SetItemData(hFrequency, ComboBox_AddStringU(hFrequency, "Disabled"), -1)); IGNORE_RETVAL(ComboBox_SetItemData(hFrequency, ComboBox_AddStringU(hFrequency, "Daily (Default)"), 86400)); IGNORE_RETVAL(ComboBox_SetItemData(hFrequency, ComboBox_AddStringU(hFrequency, "Weekly"), 604800)); IGNORE_RETVAL(ComboBox_SetItemData(hFrequency, ComboBox_AddStringU(hFrequency, "Monthly"), 2629800)); freq = ReadRegistryKey32(REGKEY_HKCU, REGKEY_UPDATE_INTERVAL); EnableWindow(GetDlgItem(hDlg, IDC_CHECK_NOW), (freq != 0)); EnableWindow(hBeta, (freq >= 0)); switch(freq) { case -1: IGNORE_RETVAL(ComboBox_SetCurSel(hFrequency, 0)); break; case 0: case 86400: IGNORE_RETVAL(ComboBox_SetCurSel(hFrequency, 1)); break; case 604800: IGNORE_RETVAL(ComboBox_SetCurSel(hFrequency, 2)); break; case 2629800: IGNORE_RETVAL(ComboBox_SetCurSel(hFrequency, 3)); break; default: IGNORE_RETVAL(ComboBox_SetItemData(hFrequency, ComboBox_AddStringU(hFrequency, "Custom"), freq)); IGNORE_RETVAL(ComboBox_SetCurSel(hFrequency, 4)); break; } IGNORE_RETVAL(ComboBox_AddStringU(hBeta, "Yes")); IGNORE_RETVAL(ComboBox_AddStringU(hBeta, "No")); IGNORE_RETVAL(ComboBox_SetCurSel(hBeta, GetRegistryKeyBool(REGKEY_HKCU, REGKEY_INCLUDE_BETAS)?0:1)); hPolicy = GetDlgItem(hDlg, IDC_POLICY); SendMessage(hPolicy, EM_AUTOURLDETECT, 1, 0); safe_sprintf(update_policy_text, sizeof(update_policy_text), update_policy); SendMessageA(hPolicy, EM_SETTEXTEX, (WPARAM)&friggin_microsoft_unicode_amateurs, (LPARAM)update_policy_text); SendMessage(hPolicy, EM_SETSEL, -1, -1); SendMessage(hPolicy, EM_SETEVENTMASK, 0, ENM_LINK); SendMessageA(hPolicy, EM_SETBKGNDCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNFACE)); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDCLOSE: case IDCANCEL: EndDialog(hDlg, LOWORD(wParam)); return (INT_PTR)TRUE; case IDC_CHECK_NOW: CheckForUpdates(TRUE); return (INT_PTR)TRUE; case IDC_UPDATE_FREQUENCY: if (HIWORD(wParam) != CBN_SELCHANGE) break; freq = (int32_t)ComboBox_GetItemData(hFrequency, ComboBox_GetCurSel(hFrequency)); WriteRegistryKey32(REGKEY_HKCU, REGKEY_UPDATE_INTERVAL, (DWORD)freq); EnableWindow(hBeta, (freq >= 0)); return (INT_PTR)TRUE; case IDC_INCLUDE_BETAS: if (HIWORD(wParam) != CBN_SELCHANGE) break; SetRegistryKeyBool(REGKEY_HKCU, REGKEY_INCLUDE_BETAS, ComboBox_GetCurSel(hBeta) == 0); return (INT_PTR)TRUE; } break; } return (INT_PTR)FALSE; }
void CMainFrame::OnHelpUpdates() { CheckForUpdates(false); }
void CMainFrame::OnAppCheckForUpdates() { CWaitCursor wc; CheckForUpdates(TRUE); // explicit check }
void CRepositoryUpdater::OnTimeout() { CLog::Log(LOGDEBUG,"CRepositoryUpdater: running scheduled update"); CheckForUpdates(); }
void SettingsDlg::OnButtonCheckForUpdates(wxCommandEvent& WXUNUSED(event)) { CheckForUpdates(m_settings, GetAppVersion(), true); }