Linux/MacOSX: Add wait dialog to the benchmark computation. Correct handling of wait dialog call when changing password and creating volumes.

This commit is contained in:
Mounir IDRASSI 2015-01-04 23:51:43 +01:00
parent 41607d126a
commit 6a254778e2
4 changed files with 42 additions and 22 deletions

View File

@ -59,14 +59,36 @@ namespace VeraCrypt
} }
void BenchmarkDialog::OnBenchmarkButtonClick (wxCommandEvent& event) void BenchmarkDialog::OnBenchmarkButtonClick (wxCommandEvent& event)
{
try
{ {
list <BenchmarkResult> results; list <BenchmarkResult> results;
wxBusyCursor busy; wxBusyCursor busy;
Buffer buffer ((size_t) Gui->GetSelectedData <size_t> (BufferSizeChoice)); Buffer buffer ((size_t) Gui->GetSelectedData <size_t> (BufferSizeChoice));
BenchmarkThreadRoutine routine(this, results, buffer);
Gui->ExecuteWaitThreadRoutine (this, &routine);
BenchmarkListCtrl->DeleteAllItems();
foreach (const BenchmarkResult &result, results)
{
vector <wstring> fields (BenchmarkListCtrl->GetColumnCount());
fields[ColumnAlgorithm] = result.AlgorithmName;
fields[ColumnEncryption] = Gui->SpeedToString (result.EncryptionSpeed);
fields[ColumnDecryption] = Gui->SpeedToString (result.DecryptionSpeed);
fields[ColumnMean] = Gui->SpeedToString (result.MeanSpeed);
Gui->AppendToListCtrl (BenchmarkListCtrl, fields);
}
BenchmarkListCtrl->SetColumnWidth(0, wxLIST_AUTOSIZE);
}
void BenchmarkDialog::DoBenchmark (list<BenchmarkResult>& results, Buffer& buffer)
{
try
{
EncryptionAlgorithmList encryptionAlgorithms = EncryptionAlgorithm::GetAvailableAlgorithms(); EncryptionAlgorithmList encryptionAlgorithms = EncryptionAlgorithm::GetAvailableAlgorithms();
foreach (shared_ptr <EncryptionAlgorithm> ea, encryptionAlgorithms) foreach (shared_ptr <EncryptionAlgorithm> ea, encryptionAlgorithms)
{ {
@ -135,19 +157,6 @@ namespace VeraCrypt
} }
} }
BenchmarkListCtrl->DeleteAllItems();
foreach (const BenchmarkResult &result, results)
{
vector <wstring> fields (BenchmarkListCtrl->GetColumnCount());
fields[ColumnAlgorithm] = result.AlgorithmName;
fields[ColumnEncryption] = Gui->SpeedToString (result.EncryptionSpeed);
fields[ColumnDecryption] = Gui->SpeedToString (result.DecryptionSpeed);
fields[ColumnMean] = Gui->SpeedToString (result.MeanSpeed);
Gui->AppendToListCtrl (BenchmarkListCtrl, fields);
}
} }
catch (exception &e) catch (exception &e)
{ {

View File

@ -36,7 +36,20 @@ namespace VeraCrypt
uint64 MeanSpeed; uint64 MeanSpeed;
}; };
void DoBenchmark (list<BenchmarkResult>& results, Buffer& buffer);
void OnBenchmarkButtonClick (wxCommandEvent& event); void OnBenchmarkButtonClick (wxCommandEvent& event);
class BenchmarkThreadRoutine : public WaitThreadRoutine
{
public:
BenchmarkDialog* m_pDlg;
list<BenchmarkResult>& m_results;
Buffer& m_buffer;
BenchmarkThreadRoutine(BenchmarkDialog* pDlg, list<BenchmarkResult>& results, Buffer& buffer)
: m_pDlg(pDlg), m_results(results), m_buffer(buffer) { }
virtual ~BenchmarkThreadRoutine() { }
virtual void ExecutionCode(void) { m_pDlg->DoBenchmark (m_results, m_buffer); }
};
}; };
} }

View File

@ -136,8 +136,7 @@ namespace VeraCrypt
ChangePasswordThreadRoutine routine(Path, Gui->GetPreferences().DefaultMountOptions.PreserveTimestamps, ChangePasswordThreadRoutine routine(Path, Gui->GetPreferences().DefaultMountOptions.PreserveTimestamps,
CurrentPasswordPanel->GetPassword(), CurrentPasswordPanel->GetPkcs5Kdf(), CurrentPasswordPanel->GetTrueCryptMode(),CurrentPasswordPanel->GetKeyfiles(), CurrentPasswordPanel->GetPassword(), CurrentPasswordPanel->GetPkcs5Kdf(), CurrentPasswordPanel->GetTrueCryptMode(),CurrentPasswordPanel->GetKeyfiles(),
newPassword, newKeyfiles, NewPasswordPanel->GetPkcs5Kdf(), NewPasswordPanel->GetHeaderWipeCount()); newPassword, newKeyfiles, NewPasswordPanel->GetPkcs5Kdf(), NewPasswordPanel->GetHeaderWipeCount());
WaitDialog dlg(this, LangString["IDT_STATIC_MODAL_WAIT_DLG_INFO"], &routine); Gui->ExecuteWaitThreadRoutine (this, &routine);
dlg.Run();
} }
switch (DialogMode) switch (DialogMode)

View File

@ -867,8 +867,7 @@ namespace VeraCrypt
Creator.reset (new VolumeCreator); Creator.reset (new VolumeCreator);
VolumeCreatorThreadRoutine routine(options, Creator); VolumeCreatorThreadRoutine routine(options, Creator);
WaitDialog dlg(this, LangString["IDT_STATIC_MODAL_WAIT_DLG_INFO"], &routine); Gui->ExecuteWaitThreadRoutine (this, &routine);
dlg.Run();
page->SetKeyInfo (Creator->GetKeyInfo()); page->SetKeyInfo (Creator->GetKeyInfo());