From a493e0f85ade7ad6125a54434dae1af87581f2ad Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Sun, 12 Feb 2017 03:47:29 -0800 Subject: [PATCH] remove updater code #71 Remove the "check for updates" and "Update ROM database" menu entries, as well as the automatic update checking and all supporting code. This fixes the issue with the emulator hanging without access to the internet. Updating code will be reimplemented in the future using something like Sparkle. wxHTTP does not support redirects or https so is pretty much useless now. Also update the About box to bump copyright year to 2017 and change my name to "rkitover", which is what I use on github, and mention other contributors. --- src/wx/cmdevents.cpp | 25 +----- src/wx/panel.cpp | 9 --- src/wx/wxvbam.cpp | 168 ---------------------------------------- src/wx/wxvbam.h | 7 -- src/wx/xrc/MainMenu.xrc | 2 + 5 files changed, 5 insertions(+), 206 deletions(-) diff --git a/src/wx/cmdevents.cpp b/src/wx/cmdevents.cpp index a8c27ac8..303450c2 100644 --- a/src/wx/cmdevents.cpp +++ b/src/wx/cmdevents.cpp @@ -2389,26 +2389,6 @@ EVT_HANDLER(Translate, "Translations") wxLaunchDefaultBrowser(wxT("http://www.transifex.com/projects/p/vba-m")); } -EVT_HANDLER(UpdateRDB, "Update ROM database") -{ - int ret = wxMessageBox(_("This will download and update three GBA No-Intro DAT files. Do you want to continue?"), - _("Confirm Update"), wxYES_NO | wxICON_EXCLAMATION); - - if (ret == wxYES) { - DownloadFile(_T("sourceforge.net"), _T("/p/vbam/code/HEAD/tree/trunk/data/Nintendo%20-%20Game%20Boy%20Advance.zip?format=raw")); - DownloadFile(_T("sourceforge.net"), _T("/p/vbam/code/HEAD/tree/trunk/data/Nintendo%20-%20Game%20Boy%20Advance%20%28Scene%29.zip?format=raw")); - DownloadFile(_T("sourceforge.net"), _T("/p/vbam/code/HEAD/tree/trunk/data/Official%20No-Intro%20Nintendo%20Gameboy%20Advance%20Number%20%28Date%29.zip?format=raw")); - } -} - -EVT_HANDLER(UpdateEmu, "Check for updates") -{ - if (!CheckForUpdates()) { - wxMessageBox(_("There are no new updates at this time."), - _("Check for updates"), wxOK | wxICON_INFORMATION); - } -} - // was About EVT_HANDLER(wxID_ABOUT, "About...") { @@ -2431,7 +2411,7 @@ EVT_HANDLER(wxID_ABOUT, "About...") ai.SetWebSite(wxT("http://www.vba-m.com/")); ai.SetIcon(GetIcon()); ai.SetDescription(_("Nintendo GameBoy (+Color+Advance) emulator.")); - ai.SetCopyright(_("Copyright (C) 1999-2003 Forgotten\nCopyright (C) 2004-2006 VBA development team\nCopyright (C) 2007-2015 VBA-M development team")); + ai.SetCopyright(_("Copyright (C) 1999-2003 Forgotten\nCopyright (C) 2004-2006 VBA development team\nCopyright (C) 2007-2017 VBA-M development team")); ai.SetLicense(_("This program is free software: you can redistribute it and/or modify\n" "it under the terms of the GNU General Public License as published by\n" "the Free Software Foundation, either version 2 of the License, or\n" @@ -2468,8 +2448,9 @@ EVT_HANDLER(wxID_ABOUT, "About...") ai.AddDeveloper(wxT("xKiv")); ai.AddDeveloper(wxT("skidau")); ai.AddDeveloper(wxT("TheCanadianBacon")); - ai.AddDeveloper(wxT("Caelum")); + ai.AddDeveloper(wxT("rkitover")); ai.AddDeveloper(wxT("Orig. VBA team")); + ai.AddDeveloper(wxT("... many contributors who send us patches/PRs")); wxAboutBox(ai); } diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp index 757524fc..cb796d9a 100644 --- a/src/wx/panel.cpp +++ b/src/wx/panel.cpp @@ -975,15 +975,6 @@ void GameArea::OnIdle(wxIdleEvent& event) } } -#ifdef __WXMSW__ - - // Check for online updates - if (gopts.onlineupdates > 0 && !emusys) { - wxGetApp().frame->CheckForUpdates(); - } - -#endif - if (!emusys) return; diff --git a/src/wx/wxvbam.cpp b/src/wx/wxvbam.cpp index 25d696ae..2f854437 100644 --- a/src/wx/wxvbam.cpp +++ b/src/wx/wxvbam.cpp @@ -642,174 +642,6 @@ void MainFrame::OnMenu(wxContextMenuEvent& event) } } -void MainFrame::DownloadFile(wxString host, wxString url) -{ - wxHTTP get; - get.SetHeader(_T("Content-type"), _T("text/html; charset=utf-8")); - get.SetTimeout(10); - - while (!get.Connect(host)) - wxSleep(5); - - wxApp::IsMainLoopRunning(); - wxInputStream* httpStream = get.GetInputStream(url); - - if (get.GetError() == wxPROTO_NOERR) { - if (httpStream != NULL) { - wxZipInputStream zip(httpStream); - wxZipEntry* entry; - - while (entry = zip.GetNextEntry()) { - wxFileName name(wxGetApp().data_path, entry->GetName(), wxEmptyString); - - if (!entry->IsDir()) { - zip.OpenEntry(*entry); - - if (zip.CanRead()) { - wxFileOutputStream file(name.GetFullPath()); - - if (file.IsOk()) { - zip.Read(file); - } - } - } - } - } - } - - get.Close(); -} - -void MainFrame::UpdateFile(wxString host, wxString url) -{ - wxProgressDialog progress(_T("Downloading..."), _T("Please wait while the VisualBoyAdvance-M update is downloading.")); - wxHTTP get; - get.SetHeader(_T("Content-type"), _T("text/html; charset=utf-8")); - 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(); - char* data = new char[size]; - wxFileName name(wxStandardPaths::Get().GetPluginsDir(), url.AfterLast('/'), wxEmptyString); - - if (httpStream) { - size_t chunks = 100; - size_t chunkSize = httpStream->GetSize() / chunks; - char* fileContent = new char[chunkSize]; -#if (wxMAJOR_VERSION >= 3) - progress.SetRange(chunks); -#endif - wxFFile file(name.GetFullPath(), _T("wb")); - - for (size_t i = 0; i <= chunks; i++) { - progress.Update(i); - httpStream->Read(fileContent, chunkSize); - file.Write(fileContent, httpStream->LastRead()); - } - - file.Flush(); - wxDELETE(fileContent); - } - - if (name.FileExists() && name.GetFullName().Lower().Contains(wxT(".7z"))) { - utilExtract(name.GetPathWithSep().mb_str(wxConvUTF8), name.GetFullName().mb_str(wxConvUTF8)); - } - - delete[] data; - delete httpStream; - } - } - - get.Close(); -} - -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; -} - -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; -} - wxString MainFrame::GetGamePath(wxString path) { wxString game_path = path; diff --git a/src/wx/wxvbam.h b/src/wx/wxvbam.h index 330969a1..d2cf5712 100644 --- a/src/wx/wxvbam.h +++ b/src/wx/wxvbam.h @@ -297,9 +297,6 @@ public: // call this to update the viewers once a frame: void UpdateViewers(); - // Check for online updates to the emulator - bool CheckForUpdates(); - virtual bool MenusOpened() { return menus_opened != 0; } virtual void SetMenusOpened(bool state); @@ -354,10 +351,6 @@ private: // Load a named wxDialog from the XRC file wxDialog* LoadXRCropertySheetDialog(const char* name); - void DownloadFile(wxString host, wxString url); - void UpdateFile(wxString host, wxString url); - wxString CheckForUpdates(wxString host, wxString url); - #include "cmdhandlers.h" }; diff --git a/src/wx/xrc/MainMenu.xrc b/src/wx/xrc/MainMenu.xrc index 53130575..e02a4925 100644 --- a/src/wx/xrc/MainMenu.xrc +++ b/src/wx/xrc/MainMenu.xrc @@ -626,12 +626,14 @@ +