Index: src/ch/UpdateChecker.cpp =================================================================== diff -u -r8068e0c351055554340ac9755d1bc846893bf2b8 -r9ddf8fdd5f641491dd30c49eb90f8f740314b6af --- src/ch/UpdateChecker.cpp (.../UpdateChecker.cpp) (revision 8068e0c351055554340ac9755d1bc846893bf2b8) +++ src/ch/UpdateChecker.cpp (.../UpdateChecker.cpp) (revision 9ddf8fdd5f641491dd30c49eb90f8f740314b6af) @@ -25,7 +25,6 @@ #include "UpdateResponse.h" #include #include "../libchcore/TWin32ErrorFormatter.h" -#include "../common/version.h" #include // ============================================================================ @@ -35,14 +34,14 @@ /// @brief Constructs the update checker object. // ============================================================================ CUpdateChecker::CUpdateChecker() : - m_hThread(nullptr), - m_hKillEvent(nullptr), + m_eUpdateChannel(UpdateVersionInfo::eStable), m_eResult(eResult_Undefined), - m_eUpdateChannel(UpdateVersionInfo::eStable) + m_hThread(nullptr), + m_hKillEvent(nullptr) { m_hKillEvent = ::CreateEvent(nullptr, FALSE, FALSE, nullptr); BOOST_ASSERT(m_hKillEvent); - ::InitializeCriticalSection(&m_cs); + InitializeCriticalSection(&m_cs); } // ============================================================================ @@ -62,20 +61,11 @@ } if(m_hKillEvent) - ::CloseHandle(m_hKillEvent); + CloseHandle(m_hKillEvent); - ::DeleteCriticalSection(&m_cs); + DeleteCriticalSection(&m_cs); } -// ============================================================================ -/// CUpdateChecker::AsyncCheckForUpdates -/// @date 2009/04/18 -/// -/// @brief Starts the asynchronous checking for updates. -/// @param[in] pszSite Site where to search for updates (without file name). -/// @param[in] bCheckBeta States if we are interested in beta products. -/// @return True if operation started, false otherwise. -// ============================================================================ bool CUpdateChecker::AsyncCheckForUpdates(const wchar_t* pszSite, const wchar_t* pszLanguage, UpdateVersionInfo::EVersionType eUpdateChannel, bool bOnlyIfConnected, bool bSendHeaders) { if(!pszSite) @@ -88,17 +78,17 @@ if(bOnlyIfConnected && !InternetGetConnectedState(&dwConnectionFlags, 0)) return false; - ::EnterCriticalSection(&m_cs); + EnterCriticalSection(&m_cs); m_strSite = pszSite; m_eResult = eResult_Undefined; m_eUpdateChannel = eUpdateChannel; m_strLanguage = pszLanguage; m_bSendHeaders = bSendHeaders; - ::LeaveCriticalSection(&m_cs); + LeaveCriticalSection(&m_cs); - ::ResetEvent(m_hKillEvent); + ResetEvent(m_hKillEvent); m_hThread = CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)&CUpdateChecker::UpdateCheckThread, (void*)this, 0, nullptr); if(!m_hThread) @@ -121,19 +111,19 @@ if(m_hThread) { if(m_hKillEvent) - ::SetEvent(m_hKillEvent); + SetEvent(m_hKillEvent); DWORD dwResult = WaitForSingleObject(m_hThread, 5000); if (dwResult == WAIT_TIMEOUT || dwResult == WAIT_FAILED) throw std::exception("Failed to stop update checker thread."); m_hThread = nullptr; } - ::ResetEvent(m_hKillEvent); + ResetEvent(m_hKillEvent); m_httpFile.Close(); - ::EnterCriticalSection(&m_cs); + EnterCriticalSection(&m_cs); m_strSite.Empty(); m_eUpdateChannel = UpdateVersionInfo::eStable; @@ -144,10 +134,10 @@ m_strReleaseDate.Empty(); m_strDownloadAddress.Empty(); m_strReleaseNotes.Empty(); - m_eResult = CUpdateChecker::eResult_Undefined; + m_eResult = eResult_Undefined; m_bSendHeaders = true; - ::LeaveCriticalSection(&m_cs); + LeaveCriticalSection(&m_cs); } // ============================================================================ @@ -160,16 +150,16 @@ // ============================================================================ void CUpdateChecker::SetResult(ECheckResult eCheckResult, DWORD dwError) { - chcore::TString strError; + string::TString strError; if(eCheckResult == eResult_Error && dwError != 0) strError = chcore::TWin32ErrorFormatter::FormatWin32ErrorCodeWithFallback(dwError, _T("wininet.dll"), true); - ::EnterCriticalSection(&m_cs); + EnterCriticalSection(&m_cs); m_eResult = eCheckResult; m_strLastError = strError.c_str(); - ::LeaveCriticalSection(&m_cs); + LeaveCriticalSection(&m_cs); } // ============================================================================ @@ -181,9 +171,9 @@ // ============================================================================ void CUpdateChecker::SetLastError(PCTSTR pszError) { - ::EnterCriticalSection(&m_cs); + EnterCriticalSection(&m_cs); m_strLastError = pszError; - ::LeaveCriticalSection(&m_cs); + LeaveCriticalSection(&m_cs); } // ============================================================================ @@ -197,34 +187,27 @@ // ============================================================================ void CUpdateChecker::SetVersionsAndAddress(PCTSTR pszAddress, PCTSTR pszNumericVersion, PCTSTR pszReadableVersion, PCTSTR pszReleaseDate, PCTSTR pszReleaseNotes) { - ::EnterCriticalSection(&m_cs); + EnterCriticalSection(&m_cs); m_strDownloadAddress = pszAddress; m_strNumericVersion = pszNumericVersion; m_strReadableVersion = pszReadableVersion; m_strReleaseDate = pszReleaseDate; m_strReleaseNotes = pszReleaseNotes; - ::LeaveCriticalSection(&m_cs); + LeaveCriticalSection(&m_cs); } void CUpdateChecker::SetSendHeaders(bool bSendHeaders) { - ::EnterCriticalSection(&m_cs); + EnterCriticalSection(&m_cs); m_bSendHeaders = bSendHeaders; - ::LeaveCriticalSection(&m_cs); + LeaveCriticalSection(&m_cs); } -// ============================================================================ -/// CUpdateChecker::GetSiteAddress -/// @date 2009/04/18 -/// -/// @brief Retrieves the address of a site to check the updates at. -/// @param[out] rstrAddress Receives the address. -// ============================================================================ CString CUpdateChecker::GetSiteAddress() const { - ::EnterCriticalSection(&m_cs); + EnterCriticalSection(&m_cs); CString strAddress = m_strSite; - ::LeaveCriticalSection(&m_cs); + LeaveCriticalSection(&m_cs); return strAddress; } @@ -238,9 +221,9 @@ // ============================================================================ UpdateVersionInfo::EVersionType CUpdateChecker::GetUpdateChannel() { - ::EnterCriticalSection(&m_cs); + EnterCriticalSection(&m_cs); UpdateVersionInfo::EVersionType eUpdateChannel = m_eUpdateChannel; - ::LeaveCriticalSection(&m_cs); + LeaveCriticalSection(&m_cs); return eUpdateChannel; } @@ -254,9 +237,9 @@ // ============================================================================ CUpdateChecker::ECheckResult CUpdateChecker::GetResult() const { - ::EnterCriticalSection(&m_cs); + EnterCriticalSection(&m_cs); ECheckResult eResult = m_eResult; - ::LeaveCriticalSection(&m_cs); + LeaveCriticalSection(&m_cs); return eResult; }