diff --git a/build/DefaultConfiguration.props b/build/DefaultConfiguration.props
index ba920928b..7c41be0ea 100644
--- a/build/DefaultConfiguration.props
+++ b/build/DefaultConfiguration.props
@@ -46,8 +46,8 @@
true
vsfilter.lib
false
- updates.aegisub.org
- /trunk
+ mugen.karaokes.moe
+ /downloads/aegisub-japan7
$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\vendor))
$(VendorRoot)\boost
diff --git a/build/version.sh b/build/version.sh
index 2020bde77..b277a6e91 100755
--- a/build/version.sh
+++ b/build/version.sh
@@ -44,10 +44,13 @@ else
tagged_release=0
fi
+last_release=$(git describe --tags)
+
new_version_h="\
#define BUILD_GIT_VERSION_NUMBER ${git_revision}
#define BUILD_GIT_VERSION_STRING \"${git_version_str}\"
+#define RELEASE_VERSION \"${last_release#v}\"
#define TAGGED_RELEASE ${tagged_release}
#define INSTALLER_VERSION \"${installer_version}\"
#define RESOURCE_BASE_VERSION ${resource_version}"
diff --git a/configure.ac b/configure.ac
index 31a2e4711..157129a83 100644
--- a/configure.ac
+++ b/configure.ac
@@ -523,16 +523,16 @@ 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})
+ [mugen.karaokes.moe]]))
+AC_MSG_RESULT(${with_update_server:=mugen.karaokes.moe})
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})
+ [Base path to use for the update checker [/downloads/aegisub-japan7]]))
+AC_MSG_RESULT(${with_update_url:=/downloads/aegisub-japan7})
AC_DEFINE_UNQUOTED([UPDATE_CHECKER_BASE_URL], ["$with_update_url"],
[Base path for the update checker])
diff --git a/src/dialog_version_check.cpp b/src/dialog_version_check.cpp
index 6dea7e3b6..349fc0520 100644
--- a/src/dialog_version_check.cpp
+++ b/src/dialog_version_check.cpp
@@ -71,11 +71,59 @@ namespace {
std::mutex VersionCheckLock;
struct AegisubUpdateDescription {
- std::string url;
- std::string friendly_name;
+ int major;
+ int minor;
+ int patch;
+ std::string extra;
std::string description;
};
+AegisubUpdateDescription ParseVersionString(std::string version_string) {
+ std::vector maj_min;
+ std::vector patch;
+ agi::Split(maj_min, version_string, '.');
+ agi::Split(patch, maj_min[2], '-');
+
+ std::string extra = "";
+ if (patch.size() > 1) {
+ extra = patch[1];
+ }
+
+ return AegisubUpdateDescription{
+ atoi(maj_min[0].c_str()),
+ atoi(maj_min[1].c_str()),
+ atoi(patch[0].c_str()),
+ extra,
+ ""
+ };
+}
+
+bool IsNewer(AegisubUpdateDescription update) {
+ AegisubUpdateDescription current = ParseVersionString(GetReleaseVersion());
+
+ if (update.major > current.major)
+ return true;
+ else if (update.major == current.major)
+ if (update.minor > current.minor)
+ return true;
+ else if (update.minor == current.minor)
+ if (update.patch > current.patch)
+ return true;
+ else
+ return update.extra.compare(current.extra) > 0;
+
+ return false;
+}
+
+std::string AegisubVersion(AegisubUpdateDescription update) {
+ std::ostringstream s;
+ s << update.major << "." << update.minor << "." << update.patch;
+ if (!update.extra.empty())
+ s << "-" << update.extra;
+
+ return s.str();
+}
+
class VersionCheckerResultDialog final : public wxDialog {
void OnCloseButton(wxCommandEvent &evt);
void OnRemindMeLater(wxCommandEvent &evt);
@@ -84,12 +132,12 @@ class VersionCheckerResultDialog final : public wxDialog {
wxCheckBox *automatic_check_checkbox;
public:
- VersionCheckerResultDialog(wxString const& main_text, const std::vector &updates);
+ VersionCheckerResultDialog(wxString const& main_text, const AegisubUpdateDescription update);
bool ShouldPreventAppExit() const override { return false; }
};
-VersionCheckerResultDialog::VersionCheckerResultDialog(wxString const& main_text, const std::vector &updates)
+VersionCheckerResultDialog::VersionCheckerResultDialog(wxString const& main_text, const AegisubUpdateDescription update)
: wxDialog(nullptr, -1, _("Version Checker"))
{
const int controls_width = 500;
@@ -100,10 +148,10 @@ VersionCheckerResultDialog::VersionCheckerResultDialog(wxString const& main_text
text->Wrap(controls_width);
main_sizer->Add(text, 0, wxBOTTOM|wxEXPAND, 6);
- for (auto const& update : updates) {
- main_sizer->Add(new wxStaticLine(this), 0, wxEXPAND|wxALL, 6);
+ main_sizer->Add(new wxStaticLine(this), 0, wxEXPAND|wxALL, 6);
- text = new wxStaticText(this, -1, to_wx(update.friendly_name));
+ if (IsNewer(update)) {
+ text = new wxStaticText(this, -1, to_wx("Aegisub-Japan7"));
wxFont boldfont = text->GetFont();
boldfont.SetWeight(wxFONTWEIGHT_BOLD);
text->SetFont(boldfont);
@@ -112,21 +160,25 @@ VersionCheckerResultDialog::VersionCheckerResultDialog(wxString const& main_text
wxTextCtrl *descbox = new wxTextCtrl(this, -1, to_wx(update.description), wxDefaultPosition, wxSize(controls_width,60), wxTE_MULTILINE|wxTE_READONLY);
main_sizer->Add(descbox, 0, wxEXPAND|wxBOTTOM, 6);
- main_sizer->Add(new wxHyperlinkCtrl(this, -1, to_wx(update.url), to_wx(update.url)), 0, wxALIGN_LEFT|wxBOTTOM, 6);
+ std::ostringstream surl;
+ surl << "https://" << UPDATE_CHECKER_SERVER << UPDATE_CHECKER_BASE_URL << "/Aegisub-Japan7-x64-" << AegisubVersion(update) << ".exe";
+ std::string url = surl.str();
+
+ main_sizer->Add(new wxHyperlinkCtrl(this, -1, to_wx(url), to_wx(url)), 0, wxALIGN_LEFT|wxBOTTOM, 6);
}
automatic_check_checkbox = new wxCheckBox(this, -1, _("&Auto Check for Updates"));
automatic_check_checkbox->SetValue(OPT_GET("App/Auto/Check For Updates")->GetBool());
wxButton *remind_later_button = nullptr;
- if (updates.size() > 0)
+ if (IsNewer(update))
remind_later_button = new wxButton(this, wxID_NO, _("Remind me again in a &week"));
wxButton *close_button = new wxButton(this, wxID_OK, _("&Close"));
SetAffirmativeId(wxID_OK);
SetEscapeId(wxID_OK);
- if (updates.size())
+ if (IsNewer(update))
main_sizer->Add(new wxStaticLine(this), 0, wxEXPAND|wxALL, 6);
main_sizer->Add(automatic_check_checkbox, 0, wxEXPAND|wxBOTTOM, 6);
@@ -280,25 +332,19 @@ static wxString GetAegisubLanguage() {
return to_wx(OPT_GET("App/Language")->GetString());
}
-void DoCheck(bool interactive) {
+AegisubUpdateDescription GetLatestVersion() {
boost::asio::ip::tcp::iostream stream;
stream.connect(UPDATE_CHECKER_SERVER, "http");
if (!stream)
throw VersionCheckError(from_wx(_("Could not connect to updates server.")));
agi::format(stream,
- "GET %s?rev=%d&rel=%d&os=%s&lang=%s&aegilang=%s HTTP/1.0\r\n"
- "User-Agent: Aegisub %s\r\n"
+ "GET %s/latest HTTP/1.1\r\n"
+ "User-Agent: Aegisub-Japan7\r\n"
"Host: %s\r\n"
"Accept: */*\r\n"
"Connection: close\r\n\r\n"
, UPDATE_CHECKER_BASE_URL
- , GetSVNRevision()
- , (GetIsOfficialRelease() ? 1 : 0)
- , GetOSShortName()
- , GetSystemLanguage()
- , GetAegisubLanguage()
- , GetAegisubLongVersionString()
, UPDATE_CHECKER_SERVER);
std::string http_version;
@@ -316,36 +362,39 @@ void DoCheck(bool interactive) {
for (auto const& header : agi::line_iterator(stream))
if (header.empty()) break;
- std::vector results;
+ AegisubUpdateDescription version = AegisubUpdateDescription{0, 0, 0, "", ""};
+ std::ostringstream desc;
for (auto const& line : agi::line_iterator(stream)) {
- if (line.empty()) continue;
- std::vector parsed;
- agi::Split(parsed, line, '|');
- if (parsed.size() != 6) continue;
+ if (version.major == 0 && version.minor == 0 && version.minor == 0) {
+ version = ParseVersionString(line);
+ } else {
+ desc << line << "\n";
+ }
- if (atoi(parsed[1].c_str()) <= GetSVNRevision())
- continue;
-
- // 0 and 2 being things that never got used
- results.push_back(AegisubUpdateDescription{
- inline_string_decode(parsed[3]),
- inline_string_decode(parsed[4]),
- inline_string_decode(parsed[5])
- });
}
- if (!results.empty() || interactive) {
+ if (version.major != 0 && version.minor != 0 && version.patch != 0) {
+ version.description = desc.str();
+ return version;
+ }
+
+ throw VersionCheckError(from_wx(_("Could not get update from updates server.")));
+}
+
+
+void DoCheck(bool interactive) {
+ AegisubUpdateDescription update = GetLatestVersion();
+
+ if (IsNewer(update) || interactive) {
agi::dispatch::Main().Async([=]{
wxString text;
- if (results.size() == 1)
+ if (IsNewer(update))
text = _("An update to Aegisub was found.");
- else if (results.size() > 1)
- text = _("Several possible updates to Aegisub were found.");
else
text = _("There are no updates to Aegisub.");
- new VersionCheckerResultDialog(text, results);
+ new VersionCheckerResultDialog(text, update);
});
}
}
diff --git a/src/version.cpp b/src/version.cpp
index a612b439c..9851dd719 100644
--- a/src/version.cpp
+++ b/src/version.cpp
@@ -74,6 +74,10 @@ const char *GetVersionNumber() {
return BUILD_GIT_VERSION_STRING;
}
+const char *GetReleaseVersion() {
+ return RELEASE_VERSION;
+}
+
int GetSVNRevision() {
#ifdef BUILD_GIT_VERSION_NUMBER
return BUILD_GIT_VERSION_NUMBER;
diff --git a/src/version.h b/src/version.h
index d413d634f..63662b3ce 100644
--- a/src/version.h
+++ b/src/version.h
@@ -46,3 +46,5 @@ bool GetIsOfficialRelease();
const char *GetVersionNumber();
/// Get SVN revision
int GetSVNRevision();
+/// Get Release Version
+const char *GetReleaseVersion();