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.
This commit is contained in:
Rafael Kitover 2017-02-12 03:47:29 -08:00
parent 65dae0d0a1
commit a493e0f85a
5 changed files with 5 additions and 206 deletions

View File

@ -2389,26 +2389,6 @@ EVT_HANDLER(Translate, "Translations")
wxLaunchDefaultBrowser(wxT("http://www.transifex.com/projects/p/vba-m")); 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 // was About
EVT_HANDLER(wxID_ABOUT, "About...") EVT_HANDLER(wxID_ABOUT, "About...")
{ {
@ -2431,7 +2411,7 @@ EVT_HANDLER(wxID_ABOUT, "About...")
ai.SetWebSite(wxT("http://www.vba-m.com/")); ai.SetWebSite(wxT("http://www.vba-m.com/"));
ai.SetIcon(GetIcon()); ai.SetIcon(GetIcon());
ai.SetDescription(_("Nintendo GameBoy (+Color+Advance) emulator.")); 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" 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" "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" "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("xKiv"));
ai.AddDeveloper(wxT("skidau")); ai.AddDeveloper(wxT("skidau"));
ai.AddDeveloper(wxT("TheCanadianBacon")); ai.AddDeveloper(wxT("TheCanadianBacon"));
ai.AddDeveloper(wxT("Caelum")); ai.AddDeveloper(wxT("rkitover"));
ai.AddDeveloper(wxT("Orig. VBA team")); ai.AddDeveloper(wxT("Orig. VBA team"));
ai.AddDeveloper(wxT("... many contributors who send us patches/PRs"));
wxAboutBox(ai); wxAboutBox(ai);
} }

View File

@ -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) if (!emusys)
return; return;

View File

@ -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 MainFrame::GetGamePath(wxString path)
{ {
wxString game_path = path; wxString game_path = path;

View File

@ -297,9 +297,6 @@ public:
// call this to update the viewers once a frame: // call this to update the viewers once a frame:
void UpdateViewers(); void UpdateViewers();
// Check for online updates to the emulator
bool CheckForUpdates();
virtual bool MenusOpened() { return menus_opened != 0; } virtual bool MenusOpened() { return menus_opened != 0; }
virtual void SetMenusOpened(bool state); virtual void SetMenusOpened(bool state);
@ -354,10 +351,6 @@ private:
// Load a named wxDialog from the XRC file // Load a named wxDialog from the XRC file
wxDialog* LoadXRCropertySheetDialog(const char* name); 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" #include "cmdhandlers.h"
}; };

View File

@ -626,12 +626,14 @@
<object class="wxMenuItem" name="Translate"> <object class="wxMenuItem" name="Translate">
<label>Translations</label> <label>Translations</label>
</object> </object>
<!-- FIXME: turn this back on when Sparkle is implemented
<object class="wxMenuItem" name="UpdateRDB"> <object class="wxMenuItem" name="UpdateRDB">
<label>Update ROM database</label> <label>Update ROM database</label>
</object> </object>
<object class="wxMenuItem" name="UpdateEmu"> <object class="wxMenuItem" name="UpdateEmu">
<label>Check for updates</label> <label>Check for updates</label>
</object> </object>
-->
<object class="separator"/> <object class="separator"/>
<object class="wxMenuItem" name="wxID_ABOUT"/> <object class="wxMenuItem" name="wxID_ABOUT"/>
</object> </object>