00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "FdmApp.h"
00008 #include "Dlg_CheckFileIntegrity_Progress.h"
00009
00010 #ifdef _DEBUG
00011 #define new DEBUG_NEW
00012 #undef THIS_FILE
00013 static char THIS_FILE[] = __FILE__;
00014 #endif
00015
00016 CDlg_CheckFileIntegrity_Progress::CDlg_CheckFileIntegrity_Progress(CWnd* pParent )
00017 : CDialog(CDlg_CheckFileIntegrity_Progress::IDD, pParent)
00018 {
00019
00020
00021
00022 m_enSHA2Strength = HSHA2S_256;
00023 }
00024
00025 void CDlg_CheckFileIntegrity_Progress::DoDataExchange(CDataExchange* pDX)
00026 {
00027 CDialog::DoDataExchange(pDX);
00028
00029 DDX_Control(pDX, IDC_PROGRESS, m_wndProgress);
00030
00031 }
00032
00033 BEGIN_MESSAGE_MAP(CDlg_CheckFileIntegrity_Progress, CDialog)
00034
00035
00036 END_MESSAGE_MAP()
00037
00038 BOOL CDlg_CheckFileIntegrity_Progress::OnInitDialog()
00039 {
00040 CDialog::OnInitDialog();
00041
00042 ApplyLanguage ();
00043
00044 DWORD dw;
00045 CloseHandle (
00046 CreateThread (NULL, 0, _threadDoJob, this, 0, &dw));
00047
00048 return TRUE;
00049 }
00050
00051 void CDlg_CheckFileIntegrity_Progress::OnCancel()
00052 {
00053 if (m_bNeedStop == false)
00054 {
00055 m_bNeedStop = true;
00056 GetDlgItem (IDCANCEL)->EnableWindow (false);
00057 }
00058 else
00059 CDialog::OnCancel ();
00060 }
00061
00062 void CDlg_CheckFileIntegrity_Progress::ApplyLanguage()
00063 {
00064 SetWindowText (LS (L_PLEASEWAIT));
00065 GetDlgItem (IDCANCEL)->SetWindowText (LS (L_CANCEL));
00066 GetDlgItem (IDC_MESSAGE)->SetWindowText (LS (L_CALCULATINGCHECKSUM));
00067 }
00068
00069 bool CDlg_CheckFileIntegrity_Progress::OnProgressChanged(double fPercentage)
00070 {
00071 m_wndProgress.SetPos ((int)fPercentage);
00072 return m_bNeedStop == false;
00073 }
00074
00075 DWORD WINAPI CDlg_CheckFileIntegrity_Progress::_threadDoJob(LPVOID lp)
00076 {
00077 CDlg_CheckFileIntegrity_Progress* pthis = (CDlg_CheckFileIntegrity_Progress*)lp;
00078
00079 pthis->m_bNeedStop = false;
00080 pthis->m_bSucceeded = false;
00081
00082 vmsHash hash;
00083 hash.set_EventsHandler (pthis);
00084
00085 hash.set_SHA2Strength (pthis->m_enSHA2Strength);
00086
00087 pthis->m_strHashResult = hash.Hash (pthis->m_strFile, pthis->m_enHashAlgorithm).c_str ();
00088
00089 if (pthis->m_bNeedStop == false)
00090
00091 pthis->m_bSucceeded = pthis->m_strHashResult == pthis->get_ValidHashResult ();
00092
00093
00094 pthis->PostMessage (WM_COMMAND, pthis->m_bNeedStop ? IDCANCEL : IDOK);
00095
00096 return 0;
00097 }
00098
00099 CString CDlg_CheckFileIntegrity_Progress::get_ValidHashResult()
00100 {
00101 CString str = m_strValidHashResult;
00102 str.MakeLower ();
00103
00104 CString str2;
00105 LPCSTR psz = str;
00106 while (*psz)
00107 {
00108 if ((*psz >= '0' && *psz <= '9') ||
00109 (*psz >= 'a' && *psz <= 'f') )
00110 str2 += *psz;
00111
00112 psz++;
00113 }
00114
00115 return str2;
00116 }
00117
00118 bool CDlg_CheckFileIntegrity_Progress::is_CheckingSucceeded()
00119 {
00120 return m_bSucceeded;
00121 }