DWORD WINAPI LoadUpdate (LPVOID param) { CUpdateDlg* dlg = (CUpdateDlg*) param; if (dlg->autoCheck) UpdateVersion (NULL); char buf[2048]; sprintf (buf, "Current version: %s\r\n" "Last version: %s\r\n", formatVersion (curVersion), formatVersion (lastVersion)); dlg->SetDlgItemText (IDC_BUFFER, buf); if (curVersion < lastVersion) { CString log = buf; log += "\r\nLoading changelog..."; dlg->SetDlgItemText (IDC_BUFFER, log); try { CInternetSession inet; CInternetFile* file = dynamic_cast<CInternetFile*> (inet.OpenURL (logURL)); log = buf; log += "\r\nChangelog:\r\n"; if (file != NULL) { while (file->ReadString (buf, sizeof buf - 5)) { if (buf[0] == '*' && buf[1] == '*') { unsigned int ver = parseVersion (buf + 2); if (ver != 0 && ver <= curVersion) break; } log += buf; } log.Replace ("\n", "\r\n"); dlg->SetDlgItemText (IDC_BUFFER, log); delete file; } else lastVersion = 0; } catch (CInternetException*) { } } return 0; }
void CUpdateDlg::_UpdateMgrEvents(fsUpdateMgrEvent ev, LPVOID lp) { CUpdateDlg *pThis = (CUpdateDlg*) lp; switch (ev) { case UME_CONNECTING: pThis->m_wndMsg.SetWindowText (LS (L_CONNECTINGTOSERV)); break; case UME_RETREIVINGUPDLST: _UpdateMgr.m_dldr->GetDP ()->uMaxAttempts = UINT_MAX; _UpdateMgr.m_dldr->ApplyProperties (); pThis->SetTimer (1, 1000, NULL); pThis->m_wndMsg.SetWindowText (LS (L_CHECKINGUPD)); pThis->OnTimer (1); break; case UME_UPDLSTDONE: pThis->KillTimer (1); pThis->m_wndProgress.SetPos (100); break; case UME_NEWVERSIONAVAIL: pThis->ShowUpdateInfo (); if (pThis->m_bCheckingByUser == false && _UpdateMgr.m_enAUT == AUT_DLANDINST) pThis->PostMessage (WM_COMMAND, ID_UPDATE); break; case UME_NEWVERSIONNOTAVAIL: pThis->m_wndMsg.SetWindowText (LS (L_ALRNEWESTVER)); pThis->SetDlgItemText (IDCANCEL, "OK"); break; case UME_FATALERROR: char szErr [1000]; fsIRToStr (_UpdateMgr.m_dldr->GetLastError (), szErr, sizeof (szErr)); pThis->m_wndMsg.SetWindowText (szErr); pThis->KillTimer (1); break; case UME_RETREIVINGUPDATE: { _UpdateMgr.m_dldr->GetDP ()->uMaxAttempts = UINT_MAX; _UpdateMgr.m_dldr->ApplyProperties (); CString str; str.Format (LS (L_VERAVAIL), _UpdateMgr.GetVersion (), _UpdateMgr.GetBuildNumber ()); str += ". "; str += LS (L_DOWNLOADING); str += "..."; pThis->m_wndMsg.SetWindowText (str); pThis->SetTimer (1, 1000, NULL); pThis->OnTimer (1); } break; case UME_UPDATEDONE: CString str; str.Format (LS (L_VERAVAIL), _UpdateMgr.GetVersion (), _UpdateMgr.GetBuildNumber ()); str += ". "; str += LS (L_DONE); str += '.'; pThis->m_wndMsg.SetWindowText (str); pThis->KillTimer (1); pThis->m_wndProgress.SetPos (100); pThis->OnUpdateDone (); break; } }