Index: src/ch/UpdaterDlg.cpp =================================================================== diff -u -N -r501360c5c84079dd290b59ca7904c84bad7e38f9 -r1f27a2022090cf7aaf827a3f1ad90d6fe0038518 --- src/ch/UpdaterDlg.cpp (.../UpdaterDlg.cpp) (revision 501360c5c84079dd290b59ca7904c84bad7e38f9) +++ src/ch/UpdaterDlg.cpp (.../UpdaterDlg.cpp) (revision 1f27a2022090cf7aaf827a3f1ad90d6fe0038518) @@ -57,15 +57,13 @@ InitUpdateChannelCombo(); // disable button initially - CWnd* pWnd = GetDlgItem(IDC_OPEN_WEBPAGE_BUTTON); - if(pWnd) - pWnd->EnableWindow(FALSE); + EnableOpenWebPageButton(false); if(!m_bBackgroundMode) ShowWindow(SW_SHOW); // start the updater - m_ucChecker.AsyncCheckForUpdates(_T(PRODUCT_SITE), GetPropValue(GetConfig()), (UpdateVersionInfo::EVersionType)GetPropValue(GetConfig()), m_bBackgroundMode); + CheckForUpdates(); // start a timer to display progress SetTimer(UPDATER_TIMER, 50, NULL); @@ -108,7 +106,9 @@ if(eResult != m_eLastState) { - switch(m_ucChecker.GetResult()) + m_eLastState = eResult; + + switch(eResult) { case CUpdateChecker::eResult_Undefined: TRACE(_T("CUpdateChecker::eResult_Undefined\n")); @@ -168,7 +168,8 @@ fmt.SetFormat(strFmt); fmt.SetParam(_t("%site"), _t(PRODUCT_SITE)); fmt.SetParam(_t("%thisver"), _T(PRODUCT_VERSION)); - fmt.SetParam(L"%numericver", PRODUCT_NUMERIC_VERSION); + fmt.SetParam(L"%thisnumericver", PRODUCT_NUMERIC_VERSION); + fmt.SetParam(L"%numericver", m_ucChecker.GetNumericVersion()); fmt.SetParam(_t("%officialver"), m_ucChecker.GetReadableVersion()); fmt.SetParam(L"%reldate", m_ucChecker.GetReleaseDate()); @@ -186,12 +187,9 @@ UpdateSecondaryText(strEntireText); // Update button state - CWnd* pWnd = GetDlgItem(IDC_OPEN_WEBPAGE_BUTTON); - if(pWnd) - pWnd->EnableWindow(bEnableButton); + EnableOpenWebPageButton(bEnableButton); + EnableUpdateRelatedControls(eResult > CUpdateChecker::eResult_Pending); - m_eLastState = eResult; - // handle background mode if(m_bBackgroundMode) { @@ -205,6 +203,8 @@ return; case eRes_Show: ShowWindow(SW_SHOW); + m_bBackgroundMode = false; // when we show this window for the first time the user is responsible for closing the dialog; + // otherwise window might close by itself when checking for updates from within the open window break; default: BOOST_ASSERT(FALSE); @@ -308,6 +308,7 @@ eFrequency = (EUpdatesFrequency)iCurSel; SetPropValue(GetConfig(), eFrequency); + GetConfig().Write(); } void CUpdaterDlg::OnSelchangeChannelCombo() @@ -321,4 +322,27 @@ eFrequency = (UpdateVersionInfo::EVersionType)iCurSel; SetPropValue(GetConfig(), eFrequency); + GetConfig().Write(); + + CheckForUpdates(); } + +void CUpdaterDlg::EnableOpenWebPageButton(bool bEnable) +{ + CWnd* pWnd = GetDlgItem(IDC_OPEN_WEBPAGE_BUTTON); + if(pWnd) + pWnd->EnableWindow(bEnable ? TRUE : FALSE); +} + +void CUpdaterDlg::CheckForUpdates() +{ + EnableUpdateRelatedControls(false); + m_eLastState = CUpdateChecker::eResult_Undefined; + + m_ucChecker.AsyncCheckForUpdates(_T(UPDATE_CHECK_LINK), GetPropValue(GetConfig()), (UpdateVersionInfo::EVersionType)GetPropValue(GetConfig()), m_bBackgroundMode); +} + +void CUpdaterDlg::EnableUpdateRelatedControls(bool bEnable) +{ + m_ctlUpdateChannel.EnableWindow(bEnable ? TRUE : FALSE); +}