Index: src/ch/UpdaterDlg.cpp =================================================================== diff -u -N -r53cb62334fc09a404726d92af726eca6141ad177 -rd9982d1ee462dceb76298ef4216f0b6122d004a6 --- src/ch/UpdaterDlg.cpp (.../UpdaterDlg.cpp) (revision 53cb62334fc09a404726d92af726eca6141ad177) +++ src/ch/UpdaterDlg.cpp (.../UpdaterDlg.cpp) (revision d9982d1ee462dceb76298ef4216f0b6122d004a6) @@ -6,19 +6,23 @@ #include "UpdaterDlg.h" #include "UpdateChecker.h" #include "../common/version.h" -#include "StaticEx.h" +#include +#define UPDATER_TIMER 639 + +BEGIN_MESSAGE_MAP(CUpdaterDlg, ictranslate::CLanguageDialog) + ON_BN_CLICKED(IDC_OPEN_WEBPAGE_BUTTON, &CUpdaterDlg::OnBnClickedOpenWebpageButton) + ON_WM_TIMER() +END_MESSAGE_MAP() + + // CUpdaterDlg dialog IMPLEMENT_DYNAMIC(CUpdaterDlg, ictranslate::CLanguageDialog) -CUpdaterDlg::CUpdaterDlg(CUpdateChecker::ECheckResult eResult, PCTSTR pszVersion, PCTSTR pszError, CWnd* pParent /*=NULL*/) - : ictranslate::CLanguageDialog(CUpdaterDlg::IDD, pParent), - m_eResult(eResult), - m_strVersion(pszVersion), - m_strError(pszError) +CUpdaterDlg::CUpdaterDlg(CWnd* pParent /*=NULL*/) +: ictranslate::CLanguageDialog(CUpdaterDlg::IDD, pParent) { - RegisterStaticExControl(AfxGetInstanceHandle()); } CUpdaterDlg::~CUpdaterDlg() @@ -31,56 +35,68 @@ DDX_Control(pDX, IDC_INFO_STATIC, m_ctlText); } -BEGIN_MESSAGE_MAP(CUpdaterDlg, ictranslate::CLanguageDialog) -END_MESSAGE_MAP() - - -// CUpdaterDlg message handlers BOOL CUpdaterDlg::OnInitDialog() { ictranslate::CLanguageDialog::OnInitDialog(); - ictranslate::CFormat fmt; + + ictranslate::CFormat fmt(GetResManager()->LoadString(IDS_UPDATER_WAITING_STRING)); + fmt.SetParam(_t("%site"), _T(PRODUCT_SITE)); + m_ctlText.SetWindowText(fmt); + + SetTimer(UPDATER_TIMER, 10, NULL); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CUpdaterDlg::StartChecking() +{ + m_ucChecker.CheckForUpdates(_T(PRODUCT_SITE), false); + ictranslate::CResourceManager* pResManager = GetResManager(); - _ASSERTE(pResManager); + BOOST_ASSERT(pResManager); if(!pResManager) - return FALSE; + return; + ictranslate::CFormat fmt; + CString strFmt; - switch(m_eResult) + switch(m_ucChecker.GetResult()) { case CUpdateChecker::eResult_Error: strFmt = pResManager->LoadString(IDS_UPDATER_ERROR_STRING); - fmt.SetFormat(strFmt); - fmt.SetParam(_t("%errdesc"), m_strError); - - m_ctlText.SetWindowText(fmt); break; case CUpdateChecker::eResult_VersionNewer: strFmt = pResManager->LoadString(IDS_UPDATER_NEW_VERSION_STRING); - fmt.SetFormat(strFmt); - fmt.SetParam(_t("%thisver"), _T(PRODUCT_VERSION)); - fmt.SetParam(_t("%officialver"), m_strVersion); - - m_ctlText.SetWindowText(fmt); break; case CUpdateChecker::eResult_VersionCurrent: strFmt = pResManager->LoadString(IDS_UPDATER_EQUAL_VERSION_STRING); - fmt.SetFormat(strFmt); - fmt.SetParam(_t("%thisver"), _T(PRODUCT_VERSION)); - fmt.SetParam(_t("%officialver"), m_strVersion); - - m_ctlText.SetWindowText(fmt); break; case CUpdateChecker::eResult_VersionOlder: strFmt = pResManager->LoadString(IDS_UPDATER_OLD_VERSION_STRING); - fmt.SetFormat(strFmt); - fmt.SetParam(_t("%thisver"), _T(PRODUCT_VERSION)); - fmt.SetParam(_t("%officialver"), m_strVersion); - - m_ctlText.SetWindowText(fmt); break; } - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE + fmt.SetFormat(strFmt); + fmt.SetParam(_t("%errdesc"), m_ucChecker.GetLastError()); + fmt.SetParam(_t("%thisver"), _T(PRODUCT_VERSION)); + fmt.SetParam(_t("%officialver"), m_ucChecker.GetReadableVersion()); + + m_ctlText.SetWindowText(fmt); } + +void CUpdaterDlg::OnBnClickedOpenWebpageButton() +{ + ShellExecute(NULL, _T("open"), m_ucChecker.GetDownloadAddress(), NULL, NULL, SW_SHOW); +} + +void CUpdaterDlg::OnTimer(UINT_PTR nIDEvent) +{ + if(nIDEvent == UPDATER_TIMER) + { + KillTimer(UPDATER_TIMER); + StartChecking(); + } + + CLanguageDialog::OnTimer(nIDEvent); +}