Index: src/ch/UpdateChecker.h =================================================================== diff -u -N -rd5fd15320ef765fd5225b10e764bca458c2e317c -r50ad2dc9f0b42ba432bb54e4a042582277410773 --- src/ch/UpdateChecker.h (.../UpdateChecker.h) (revision d5fd15320ef765fd5225b10e764bca458c2e317c) +++ src/ch/UpdateChecker.h (.../UpdateChecker.h) (revision 50ad2dc9f0b42ba432bb54e4a042582277410773) @@ -23,74 +23,11 @@ #ifndef __UPDATECHECKER_H__ #define __UPDATECHECKER_H__ -class CAsyncHttpFile; +#include "WindowsVersion.h" +#include "AsyncHttpFile.h" +#include "UpdateHeaders.h" +#include "UpdateVersionInfo.h" -struct CONTEXT_REQUEST -{ - CAsyncHttpFile* pHttpFile; - enum EOperation - { - eNone, - eInternetOpenUrl = 1, - eInternetReadFileEx = 2, - } eOperationType; -}; - -class CAsyncHttpFile -{ -public: - enum EWaitResult - { - eKilled, - eFinished, - eTimeout, - ePending, - eError - }; - -public: - CAsyncHttpFile(); - ~CAsyncHttpFile(); - - HRESULT Open(const wchar_t* pszPath, const wchar_t* pszUserAgent); - HRESULT GetFileSize(size_t& stSize); - - HRESULT RequestData(void* pBuffer, size_t stSize); - HRESULT GetRetrievedDataSize(size_t& stSize); - - HRESULT Close(); - - EWaitResult GetResult(); - DWORD GetErrorCode() { return m_dwError; } - - EWaitResult WaitForResult(HANDLE hKillEvent); - - bool IsClosed() const { return m_hOpenUrl == NULL; } - -protected: - static void CALLBACK InternetStatusCallback(HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength); - - void SetUrlHandle(HANDLE hOpenUrl); - void SetErrorCode(DWORD dwError); - - /// Sets the completion event - HRESULT SetCompletionStatus(DWORD dwCurrentState); - -protected: - HINTERNET m_hInternet; - HINTERNET m_hOpenUrl; - - DWORD m_dwExpectedState; ///< State we are expecting - HANDLE m_hFinishedEvent; - - INTERNET_BUFFERS m_internetBuffers; - CONTEXT_REQUEST m_tOpenRequest; - CONTEXT_REQUEST m_tReadRequest; - - - DWORD m_dwError; -}; - class CUpdateChecker : protected CInternetSession { public: @@ -100,7 +37,6 @@ eResult_Pending, eResult_Killed, eResult_Error, - eResult_RemoteVersionOlder, eResult_VersionCurrent, eResult_RemoteVersionNewer }; @@ -112,7 +48,7 @@ ~CUpdateChecker(); /// Starts the 'check for updates' thread - bool AsyncCheckForUpdates(const tchar_t* pszSite, bool bCheckBeta, bool bOnlyIfConnected); + bool AsyncCheckForUpdates(const wchar_t* pszSite, const wchar_t* pszLanguage, UpdateVersionInfo::EVersionType bCheckBeta, bool bOnlyIfConnected); /// Stops checking and cleanups the object void Cleanup(); @@ -121,10 +57,12 @@ ECheckResult GetResult() const; // methods for retrieving state - const tchar_t* GetNumericVersion() const { return (const tchar_t*)m_strNumericVersion; } - const tchar_t* GetReadableVersion() const { return (const tchar_t*)m_strReadableVersion; } - const tchar_t* GetLastError() const { return (const tchar_t*)m_strLastError; } - const tchar_t* GetDownloadAddress() const { return m_strDownloadAddress; } + const wchar_t* GetNumericVersion() const { return (const wchar_t*)m_strNumericVersion; } + const wchar_t* GetReadableVersion() const { return (const wchar_t*)m_strReadableVersion; } + const wchar_t* GetLastError() const { return (const wchar_t*)m_strLastError; } + const wchar_t* GetDownloadAddress() const { return m_strDownloadAddress; } + const wchar_t* GetReleaseDate() const { return m_strReleaseDate; } + const wchar_t* GetReleaseNotes() const { return m_strReleaseNotes; } protected: /// Thread function (handles most of the internet connection operation) @@ -135,27 +73,31 @@ /// Sets the last error void SetLastError(PCTSTR pszError); /// Sets the versions and download address - void SetVersionsAndAddress(PCTSTR pszAddress, PCTSTR pszNumericVersion, PCTSTR pszReadableVersion); + void SetVersionsAndAddress(PCTSTR pszAddress, PCTSTR pszNumericVersion, PCTSTR pszReadableVersion, PCTSTR pszReleaseDate, PCTSTR pszReleaseNotes); /// Retrieves the site address void GetSiteAddress(CString& rstrAddress) const; /// Returns information if we're interested in beta versions - bool CheckForBeta(); + UpdateVersionInfo::EVersionType GetUpdateChannel(); + static std::wstring FormatDate(const boost::gregorian::date& date); - // user agent - static std::wstring GetUserAgent(); - protected: CString m_strSite; - bool m_bCheckForBeta; + UpdateVersionInfo::EVersionType m_eUpdateChannel; + CString m_strLanguage; CString m_strLastError; CString m_strNumericVersion; CString m_strReadableVersion; CString m_strDownloadAddress; + CString m_strReleaseDate; + CString m_strReleaseNotes; ECheckResult m_eResult; CAsyncHttpFile m_httpFile; + UpdateHeaders m_tUpdateHeaders; + + HANDLE m_hThread; HANDLE m_hKillEvent; mutable CRITICAL_SECTION m_cs;