Make wxUpdCheckThread::wxResult scoped enum
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
de9535b961
commit
e2cf7d09f8
@ -38,6 +38,7 @@ int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In
|
||||
|
||||
// Initialize locale.
|
||||
wxLocale locale;
|
||||
#pragma warning(suppress: 26812) // wxLanguage is unscoped
|
||||
wxLanguage lang_ui;
|
||||
if (wxInitializeLocale(locale, &lang_ui)) {
|
||||
// Do not add translation catalog, to keep log messages in English.
|
||||
@ -60,8 +61,8 @@ int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In
|
||||
wxUpdCheckThread worker(lang_ui == wxLANGUAGE_DEFAULT ? wxT("en_US") : wxLocale::GetLanguageCanonicalName(lang_ui));
|
||||
wxUpdCheckThread::wxResult res = worker.CheckForUpdate();
|
||||
switch (res) {
|
||||
case wxUpdCheckThread::wxUpdUpdateAvailable: return worker.LaunchUpdate(NULL, true) ? 0 : 1;
|
||||
case wxUpdCheckThread::wxUpdUpToDate : return 0;
|
||||
default : return res;
|
||||
case wxUpdCheckThread::wxResult::UpdateAvailable: return worker.LaunchUpdate(NULL, true) ? 0 : 1;
|
||||
case wxUpdCheckThread::wxResult::UpToDate : return 0;
|
||||
default : return static_cast<int>(res);
|
||||
}
|
||||
}
|
||||
|
@ -49,14 +49,14 @@ public:
|
||||
///
|
||||
/// Thread exit codes
|
||||
///
|
||||
enum wxResult {
|
||||
wxUpdUninitialized = -1, ///< Initialization failed
|
||||
wxUpdAborted = -2, ///< Thread aborted
|
||||
wxUpdRepoUnavailable = -3, ///< No update package information available
|
||||
wxUpdPkgUnavailable = -4, ///< Update package not available
|
||||
enum class wxResult {
|
||||
Uninitialized = -1, ///< Initialization failed
|
||||
Aborted = -2, ///< Thread aborted
|
||||
RepoUnavailable = -3, ///< No update package information available
|
||||
PkgUnavailable = -4, ///< Update package not available
|
||||
|
||||
wxUpdUpdateAvailable = 0, ///< Update downloaded, verified and prepared to install
|
||||
wxUpdUpToDate, ///< Product is up-to-date
|
||||
UpdateAvailable = 0, ///< Update downloaded, verified and prepared to install
|
||||
UpToDate, ///< Product is up-to-date
|
||||
};
|
||||
|
||||
wxUpdCheckThread(const wxString &langId, wxEvtHandler *parent = NULL);
|
||||
|
@ -78,7 +78,7 @@ wxThread::ExitCode wxUpdCheckThread::Entry()
|
||||
// NOTE: here we assume that using the m_parent pointer is safe,
|
||||
// (in this case this is assured by the wxZRColaCharSelect destructor)
|
||||
wxThreadEvent *e = new wxThreadEvent(wxEVT_UPDATER_CHECK_COMPLETE);
|
||||
e->SetInt(result);
|
||||
e->SetInt(static_cast<int>(result));
|
||||
wxQueueEvent(m_parent, e);
|
||||
}
|
||||
|
||||
@ -95,35 +95,35 @@ bool wxUpdCheckThread::TestDestroy()
|
||||
wxUpdCheckThread::wxResult wxUpdCheckThread::DoCheckForUpdate()
|
||||
{
|
||||
if (!m_ok)
|
||||
return wxUpdUninitialized;
|
||||
return wxResult::Uninitialized;
|
||||
|
||||
// Download update catalogue.
|
||||
if (TestDestroy()) return wxUpdAborted;
|
||||
if (TestDestroy()) return wxResult::Aborted;
|
||||
wxScopedPtr<wxXmlDocument> doc(GetCatalogue());
|
||||
if (doc) {
|
||||
// Parse the update catalogue to check for an update package availability.
|
||||
if (TestDestroy()) return wxUpdAborted;
|
||||
if (TestDestroy()) return wxResult::Aborted;
|
||||
if (ParseCatalogue(*doc)) {
|
||||
// Save update package meta-information for the next time.
|
||||
if (TestDestroy()) return wxUpdAborted;
|
||||
if (TestDestroy()) return wxResult::Aborted;
|
||||
WriteUpdatePackageMeta();
|
||||
} else {
|
||||
wxLogStatus(_("Update check complete. Your product is up to date."));
|
||||
WriteUpdatePackageMeta();
|
||||
return wxUpdUpToDate;
|
||||
return wxResult::UpToDate;
|
||||
}
|
||||
} else {
|
||||
// Update download catalogue failed, or repository database didn't change. Read a cached version of update package meta-information?
|
||||
if (TestDestroy()) return wxUpdAborted;
|
||||
if (TestDestroy()) return wxResult::Aborted;
|
||||
if (!ReadUpdatePackageMeta()) {
|
||||
// Reset CatalogueLastModified to force update catalogue download next time.
|
||||
m_config.DeleteEntry(wxT("CatalogueLastModified"), false);
|
||||
return wxUpdRepoUnavailable;
|
||||
return wxResult::RepoUnavailable;
|
||||
}
|
||||
|
||||
if (m_version <= PRODUCT_VERSION) {
|
||||
wxLogStatus(_("Update check complete. Your product is up to date."));
|
||||
return wxUpdUpToDate;
|
||||
return wxResult::UpToDate;
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,11 +132,11 @@ wxUpdCheckThread::wxResult wxUpdCheckThread::DoCheckForUpdate()
|
||||
m_fileName += m_versionStr;
|
||||
m_fileName += wxT(".msi");
|
||||
|
||||
if (TestDestroy()) return wxUpdAborted;
|
||||
if (TestDestroy()) return wxResult::Aborted;
|
||||
if (!DownloadUpdatePackage())
|
||||
return wxUpdPkgUnavailable;
|
||||
return wxResult::PkgUnavailable;
|
||||
|
||||
return wxUpdUpdateAvailable;
|
||||
return wxResult::UpdateAvailable;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user