Make the update checker configurable

Move the server and base url to the build-time configuration options and make
it disablable entirely.

Originally committed to SVN as r6911.
This commit is contained in:
Thomas Goyne 2012-06-21 02:09:40 +00:00
parent 87370eb9c0
commit 7d2fb49828
5 changed files with 45 additions and 9 deletions

View File

@ -630,6 +630,34 @@ AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
[The basename for our gettext translation domains.])
################
# Update checker
################
AC_MSG_CHECKING([whether to enable the update checker])
AC_ARG_ENABLE(update-checker,
AS_HELP_STRING([--disable-update-checker], [disable the update checker [no]]))
AC_MSG_RESULT(${enable_update_checker:=yes})
AS_IF([test "x$enable_update_checker" != "xno"],
[AC_DEFINE([WITH_UPDATE_CHECKER], [],
[Whether to enable the update checker])])
AC_MSG_CHECKING([for update checker server])
AC_ARG_WITH(update-server,
AS_HELP_STRING([--with-update-server=HOSTNAME],
[Server to use for the update checker
[updates.aegisub.org]]))
AC_MSG_RESULT(${with_update_server:=updates.aegisub.org})
AC_DEFINE_UNQUOTED([UPDATE_CHECKER_SERVER], ["$with_update_server"],
[Server for the update checker])
AC_MSG_CHECKING([for update checker base URL])
AC_ARG_WITH(update-url,
AS_HELP_STRING([--with-update-url=HOSTNAME],
[Base path to use for the update checker [/trunk]]))
AC_MSG_RESULT(${with_update_url:=/trunk})
AC_DEFINE_UNQUOTED([UPDATE_CHECKER_BASE_URL], ["$with_update_url"],
[Base path for the update checker])
####################################################################
# Default settings for Providers/Players
# * This is done at the end to preserve sanity rather than littering

View File

@ -314,6 +314,8 @@ namespace cmd {
reg(new app_options);
reg(new app_toggle_global_hotkeys);
reg(new app_toggle_toolbar);
#ifdef WITH_UPDATE_CHECKER
reg(new app_updates);
#endif
}
}

View File

@ -128,7 +128,9 @@
# define UPDATE_CHECKER_ACCEPT_TAGS "win64 source"
#endif
// Where the update checker should look for updates
#define UPDATE_CHECKER_SERVER "updates.aegisub.org"
#define UPDATE_CHECKER_BASE_URL "/trunk"
///////////// NOT RECOMMENDED /////////////

View File

@ -37,6 +37,8 @@
#include "config.h"
#ifdef WITH_UPDATE_CHECKER
#include "dialog_version_check.h"
#ifndef AGI_PRE
@ -325,24 +327,20 @@ void AegisubVersionCheckerThread::DoCheck()
inserter(accept_tags, accept_tags.end()));
#endif
const wxString servername = "updates.aegisub.org";
const wxString base_updates_path = "/trunk";
wxString querystring = wxString::Format(
"?rev=%d&rel=%d&os=%s&lang=%s",
wxString path = wxString::Format(
"%s?rev=%d&rel=%d&os=%s&lang=%s",
UPDATE_CHECKER_BASE_URL,
GetSVNRevision(),
GetIsOfficialRelease()?1:0,
GetOSShortName(),
GetSystemLanguage());
wxString path = base_updates_path + querystring;
wxHTTP http;
http.SetHeader("User-Agent", wxString("Aegisub ") + GetAegisubLongVersionString());
http.SetHeader("Connection", "Close");
http.SetFlags(wxSOCKET_WAITALL | wxSOCKET_BLOCK);
if (!http.Connect(servername))
if (!http.Connect(UPDATE_CHECKER_SERVER))
throw VersionCheckError(STD_STR(_("Could not connect to updates server.")));
agi::scoped_ptr<wxInputStream> stream(http.GetInputStream(path));
@ -533,3 +531,5 @@ static void register_event_handler()
wxTheApp->Bind(AEGISUB_EVENT_VERSIONCHECK_RESULT, on_update_result);
is_registered = true;
}
#endif

View File

@ -211,12 +211,16 @@ FrameMain::FrameMain (wxArrayString args)
StartupLog("Possibly perform automatic updates check");
if (OPT_GET("App/First Start")->GetBool()) {
OPT_SET("App/First Start")->SetBool(false);
#ifdef WITH_UPDATE_CHECKER
int result = wxMessageBox(_("Do you want Aegisub to check for updates whenever it starts? You can still do it manually via the Help menu."),_("Check for updates?"), wxYES_NO | wxCENTER);
OPT_SET("App/Auto/Check For Updates")->SetBool(result == wxYES);
config::opt->Flush();
#endif
}
#ifdef WITH_UPDATE_CHECKER
PerformVersionCheck(false);
#endif
StartupLog("Leaving FrameMain constructor");
}