Index: src/ch/AsyncHttpFile.cpp =================================================================== diff -u -r045540c818c374806d09742ef3d7a984d8d757d3 -rd0cfddc68b5ec4dc4e9b73b6f87aa97995c7cc54 --- src/ch/AsyncHttpFile.cpp (.../AsyncHttpFile.cpp) (revision 045540c818c374806d09742ef3d7a984d8d757d3) +++ src/ch/AsyncHttpFile.cpp (.../AsyncHttpFile.cpp) (revision d0cfddc68b5ec4dc4e9b73b6f87aa97995c7cc54) @@ -36,7 +36,7 @@ m_hFinishedEvent(NULL), m_dwError(ERROR_SUCCESS) { - memset(&m_internetBuffers, 0, sizeof(INTERNET_BUFFERS)); + memset(&m_internetBuffers, 0, sizeof(INTERNET_BUFFERSA)); m_tOpenRequest.pHttpFile = this; m_tOpenRequest.eOperationType = CONTEXT_REQUEST::eInternetOpenUrl; @@ -263,10 +263,6 @@ { if(!::InternetCloseHandle(m_hOpenUrl)) { - DWORD dwError = GetLastError(); - ATLTRACE(L"InternetCloseHandle failed with error: %lu\n", dwError); - - SetErrorCode(dwError); if(GetErrorCode() == ERROR_IO_PENDING) return S_FALSE; else @@ -288,6 +284,14 @@ m_hFinishedEvent = nullptr; } + memset(&m_internetBuffers, 0, sizeof(INTERNET_BUFFERSA)); + + m_tOpenRequest.pHttpFile = this; + m_tOpenRequest.eOperationType = CONTEXT_REQUEST::eInternetOpenUrl; + + m_tReadRequest.pHttpFile = this; + m_tReadRequest.eOperationType = CONTEXT_REQUEST::eInternetReadFileEx; + return S_OK; } Index: src/ch/UpdateChecker.cpp =================================================================== diff -u -r045540c818c374806d09742ef3d7a984d8d757d3 -rd0cfddc68b5ec4dc4e9b73b6f87aa97995c7cc54 --- src/ch/UpdateChecker.cpp (.../UpdateChecker.cpp) (revision 045540c818c374806d09742ef3d7a984d8d757d3) +++ src/ch/UpdateChecker.cpp (.../UpdateChecker.cpp) (revision d0cfddc68b5ec4dc4e9b73b6f87aa97995c7cc54) @@ -93,11 +93,7 @@ m_hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&CUpdateChecker::UpdateCheckThread, (void*)this, 0, NULL); if(!m_hThread) { - m_strLanguage.Empty(); - m_strSite.Empty(); - m_eResult = eResult_Undefined; - m_eUpdateChannel = UpdateVersionInfo::eStable; - m_bSendHeaders = true; + Cleanup(); return false; } @@ -120,9 +116,12 @@ m_hThread = NULL; } + ::ResetEvent(m_hKillEvent); + m_httpFile.Close(); ::EnterCriticalSection(&m_cs); + m_strSite.Empty(); m_eUpdateChannel = UpdateVersionInfo::eStable; m_strLanguage.Empty(); @@ -133,6 +132,8 @@ m_strDownloadAddress.Empty(); m_strReleaseNotes.Empty(); m_eResult = CUpdateChecker::eResult_Undefined; + m_bSendHeaders = true; + ::LeaveCriticalSection(&m_cs); } @@ -268,7 +269,7 @@ std::stringstream dataBuffer; // open the connection and try to get to the file - std::wstring wstrUserAgent = pUpdateChecker->m_tUpdateHeaders.GetUserAgent(); + std::wstring wstrUserAgent = pUpdateChecker->m_tUpdateHeaders.GetUserAgent((PCTSTR)pUpdateChecker->m_strLanguage, pUpdateChecker->m_eUpdateChannel); std::wstring wstrHeaders; if(pUpdateChecker->GetSendHeaders()) wstrHeaders = pUpdateChecker->m_tUpdateHeaders.GetHeaders((PCTSTR)pUpdateChecker->m_strLanguage, pUpdateChecker->m_eUpdateChannel); Index: src/ch/UpdateHeaders.cpp =================================================================== diff -u -r50007f112b77cba170e6c427fee5428bda2d9dc5 -rd0cfddc68b5ec4dc4e9b73b6f87aa97995c7cc54 --- src/ch/UpdateHeaders.cpp (.../UpdateHeaders.cpp) (revision 50007f112b77cba170e6c427fee5428bda2d9dc5) +++ src/ch/UpdateHeaders.cpp (.../UpdateHeaders.cpp) (revision d0cfddc68b5ec4dc4e9b73b6f87aa97995c7cc54) @@ -22,12 +22,13 @@ #include #include #include "..\common\version.h" +#include UpdateHeaders::UpdateHeaders() { } -std::wstring UpdateHeaders::GetUserAgent() +std::wstring UpdateHeaders::GetUserAgent(const std::wstring& wstrLanguagePath, UpdateVersionInfo::EVersionType eUpdateChannel) { std::wstring wstrUserAgent(PRODUCT_FULL_VERSION_T); wstrUserAgent += L" (" + @@ -36,20 +37,17 @@ boost::lexical_cast(PRODUCT_VERSION3) + L"." + boost::lexical_cast(PRODUCT_VERSION4) + L")"; + wstrUserAgent += L"; " + ParseLanguagePath(wstrLanguagePath); wstrUserAgent += L"; " + m_tWindowsVersion.GetWindowsVersion(); wstrUserAgent += L"; " + m_tWindowsVersion.GetCpuArch(); + wstrUserAgent += L"; " + GetUpdateChannel(eUpdateChannel); return wstrUserAgent; } std::wstring UpdateHeaders::GetHeaders(const std::wstring& wstrLanguagePath, UpdateVersionInfo::EVersionType eUpdateChannel) { - std::wstring wstrLanguage; - size_t stPos = wstrLanguagePath.rfind(L'\\'); - if(stPos != std::wstring::npos) - wstrLanguage = wstrLanguagePath.substr(stPos + 1); - else - wstrLanguage = L"unknown"; + std::wstring wstrLanguage = ParseLanguagePath(wstrLanguagePath); std::wstring wstrHeaders; @@ -80,6 +78,20 @@ return wstrHeaders; } +std::wstring UpdateHeaders::ParseLanguagePath(const std::wstring &wstrLanguagePath) +{ + std::wstring wstrLanguage; + size_t stPos = wstrLanguagePath.rfind(L'\\'); + if(stPos != std::wstring::npos) + wstrLanguage = wstrLanguagePath.substr(stPos + 1); + else + wstrLanguage = L"unknown"; + + boost::ireplace_all(wstrLanguage, L".lng", L""); + + return wstrLanguage; +} + std::wstring UpdateHeaders::GetUpdateChannel(UpdateVersionInfo::EVersionType eUpdateChannel) { switch(eUpdateChannel) Index: src/ch/UpdateHeaders.h =================================================================== diff -u -r1f27a2022090cf7aaf827a3f1ad90d6fe0038518 -rd0cfddc68b5ec4dc4e9b73b6f87aa97995c7cc54 --- src/ch/UpdateHeaders.h (.../UpdateHeaders.h) (revision 1f27a2022090cf7aaf827a3f1ad90d6fe0038518) +++ src/ch/UpdateHeaders.h (.../UpdateHeaders.h) (revision d0cfddc68b5ec4dc4e9b73b6f87aa97995c7cc54) @@ -27,9 +27,11 @@ public: UpdateHeaders(); - std::wstring GetUserAgent(); + std::wstring GetUserAgent(const std::wstring& wstrLanguagePath, UpdateVersionInfo::EVersionType eUpdateChannel); std::wstring GetHeaders(const std::wstring& wstrLanguagePath, UpdateVersionInfo::EVersionType eUpdateChannel); + std::wstring ParseLanguagePath(const std::wstring &wstrLanguagePath); + private: static std::wstring GetUpdateChannel(UpdateVersionInfo::EVersionType eUpdateChannel); Index: src/ch/UpdaterDlg.cpp =================================================================== diff -u -r045540c818c374806d09742ef3d7a984d8d757d3 -rd0cfddc68b5ec4dc4e9b73b6f87aa97995c7cc54 --- src/ch/UpdaterDlg.cpp (.../UpdaterDlg.cpp) (revision 045540c818c374806d09742ef3d7a984d8d757d3) +++ src/ch/UpdaterDlg.cpp (.../UpdaterDlg.cpp) (revision d0cfddc68b5ec4dc4e9b73b6f87aa97995c7cc54) @@ -318,11 +318,11 @@ if(iCurSel == CB_ERR) return; - UpdateVersionInfo::EVersionType eFrequency = UpdateVersionInfo::eReleaseCandidate; + UpdateVersionInfo::EVersionType eVersionType = UpdateVersionInfo::eReleaseCandidate; if(iCurSel < UpdateVersionInfo::EVersionType::eMax) - eFrequency = (UpdateVersionInfo::EVersionType)iCurSel; + eVersionType = (UpdateVersionInfo::EVersionType)iCurSel; - SetPropValue(GetConfig(), eFrequency); + SetPropValue(GetConfig(), eVersionType); GetConfig().Write(); CheckForUpdates(); @@ -370,7 +370,8 @@ GetPropValue(GetConfig()), (UpdateVersionInfo::EVersionType)GetPropValue(GetConfig()), m_bBackgroundMode, - !WindowsVersion::IsWindowsXP()); + false // disabled sending headers as it is causing issues with WinInet on WinXP and Win Vista + ); } void CUpdaterDlg::EnableUpdateRelatedControls(bool bEnable)