forked from mia/Aegisub
Make update checker use a compile-time list of tags to determine the appropriate updates to list, instead of a hard-coded OS check. The list of accepted tags is defined by the UPDATE_CHECKER_ACCEPT_TAGS macro. If this macro is undefined, the update checker will still compile, but will reject all updates with tags.
Updates #1132. Originally committed to SVN as r4440.
This commit is contained in:
parent
2d9eee4ea9
commit
ff34a08afd
2 changed files with 42 additions and 17 deletions
|
@ -112,6 +112,18 @@
|
||||||
//#define FINAL_RELEASE
|
//#define FINAL_RELEASE
|
||||||
|
|
||||||
|
|
||||||
|
// Specify tags the update checker accepts
|
||||||
|
// See <http://devel.aegisub.org/wiki/Technical/UpdateChecker> for details on tags.
|
||||||
|
// Depending on who will be using your build, you may or may not want to have the
|
||||||
|
// "source" tag in here. If the string is empty, the update checker will reject any
|
||||||
|
// update offered.
|
||||||
|
#if defined(_M_IX86)
|
||||||
|
# define UPDATE_CHECKER_ACCEPT_TAGS "windows source"
|
||||||
|
#elif defined(_M_X64)
|
||||||
|
# define UPDATE_CHECKER_ACCEPT_TAGS "win64 source"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////// NOT RECOMMENDED /////////////
|
///////////// NOT RECOMMENDED /////////////
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
#include <wx/statline.h>
|
#include <wx/statline.h>
|
||||||
#include <wx/textctrl.h>
|
#include <wx/textctrl.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -323,6 +324,17 @@ static wxString GetSystemLanguage()
|
||||||
|
|
||||||
void AegisubVersionCheckerThread::DoCheck()
|
void AegisubVersionCheckerThread::DoCheck()
|
||||||
{
|
{
|
||||||
|
std::set<wxString> accept_tags;
|
||||||
|
#ifdef UPDATE_CHECKER_ACCEPT_TAGS
|
||||||
|
{
|
||||||
|
wxStringTokenizer tk(wxString(UPDATE_CHECKER_ACCEPT_TAGS, wxConvUTF8), _T(" "));
|
||||||
|
while (tk.HasMoreTokens())
|
||||||
|
{
|
||||||
|
accept_tags.insert(tk.GetNextToken());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const wxString servername = _T("updates.aegisub.org");
|
const wxString servername = _T("updates.aegisub.org");
|
||||||
const wxString base_updates_path = _T("/trunk");
|
const wxString base_updates_path = _T("/trunk");
|
||||||
|
|
||||||
|
@ -344,7 +356,7 @@ void AegisubVersionCheckerThread::DoCheck()
|
||||||
|
|
||||||
std::auto_ptr<wxInputStream> stream(http.GetInputStream(path));
|
std::auto_ptr<wxInputStream> stream(http.GetInputStream(path));
|
||||||
if (stream.get() == 0) // check for null-pointer
|
if (stream.get() == 0) // check for null-pointer
|
||||||
throw VersionCheckError("Could not connect to updates server.");
|
throw VersionCheckError(STD_STR(_("Could not download from updates server.")));
|
||||||
|
|
||||||
if (http.GetResponse() < 200 || http.GetResponse() >= 300) {
|
if (http.GetResponse() < 200 || http.GetResponse() >= 300) {
|
||||||
const std::string str_err = STD_STR(wxString::Format(_("HTTP request failed, got HTTP response %d."), http.GetResponse()));
|
const std::string str_err = STD_STR(wxString::Format(_("HTTP request failed, got HTTP response %d."), http.GetResponse()));
|
||||||
|
@ -367,7 +379,7 @@ void AegisubVersionCheckerThread::DoCheck()
|
||||||
|
|
||||||
wxString line_type = parsed[0];
|
wxString line_type = parsed[0];
|
||||||
wxString line_revision = parsed[1];
|
wxString line_revision = parsed[1];
|
||||||
wxString line_platform = parsed[2];
|
wxString line_tags_str = parsed[2];
|
||||||
wxString line_url = inline_string_decode(parsed[3]);
|
wxString line_url = inline_string_decode(parsed[3]);
|
||||||
wxString line_friendlyname = inline_string_decode(parsed[4]);
|
wxString line_friendlyname = inline_string_decode(parsed[4]);
|
||||||
wxString line_description = inline_string_decode(parsed[5]);
|
wxString line_description = inline_string_decode(parsed[5]);
|
||||||
|
@ -378,24 +390,25 @@ void AegisubVersionCheckerThread::DoCheck()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the OS is right
|
// check if the tags match
|
||||||
wxOperatingSystemId osid = wxGetOsVersion();
|
if (line_tags_str.IsEmpty() || line_tags_str == _T("all"))
|
||||||
if (line_platform == _T("windows") && !(osid & wxOS_WINDOWS_NT))
|
|
||||||
{
|
{
|
||||||
continue;
|
// looking good
|
||||||
}
|
}
|
||||||
if (line_platform == _T("mac") && !(osid & wxOS_MAC_OSX_DARWIN))
|
else
|
||||||
{
|
{
|
||||||
continue;
|
bool accepts_all_tags = true;
|
||||||
}
|
wxStringTokenizer tk(line_tags_str, _T(" "));
|
||||||
if (line_platform == _T("source") && (osid & wxOS_WINDOWS_NT || osid & wxOS_MAC_OSX_DARWIN))
|
while (tk.HasMoreTokens())
|
||||||
{
|
{
|
||||||
// TODO: support interested-in-source-releases flag
|
if (accept_tags.find(tk.GetNextToken()) == accept_tags.end())
|
||||||
continue;
|
{
|
||||||
}
|
accepts_all_tags = false;
|
||||||
if (!(line_platform == _T("windows") || line_platform == _T("mac") || line_platform == _T("source") || line_platform == _T("all")))
|
break;
|
||||||
{
|
}
|
||||||
continue;
|
}
|
||||||
|
if (!accepts_all_tags)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line_type == _T("upgrade") || line_type == _T("bugfix"))
|
if (line_type == _T("upgrade") || line_type == _T("bugfix"))
|
||||||
|
|
Loading…
Reference in a new issue