summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdbx/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Dbx_mdbx/src')
-rw-r--r--plugins/Dbx_mdbx/src/dbcrypt.cpp64
1 files changed, 32 insertions, 32 deletions
diff --git a/plugins/Dbx_mdbx/src/dbcrypt.cpp b/plugins/Dbx_mdbx/src/dbcrypt.cpp
index 75a630aa72..117c5e0af6 100644
--- a/plugins/Dbx_mdbx/src/dbcrypt.cpp
+++ b/plugins/Dbx_mdbx/src/dbcrypt.cpp
@@ -122,28 +122,29 @@ CRYPTO_PROVIDER* CDbxMDBX::SelectProvider()
class CEnterPasswordDialog : public CDlgBase
{
+ CTimer m_timer;
CCtrlData m_header;
CCtrlData m_language;
CCtrlEdit m_passwordEdit;
- CCtrlButton m_buttonOK;
friend class CDbxMDBX;
CDbxMDBX *m_db;
TCHAR m_newPass[100];
unsigned short m_wrongPass = 0;
+ void OnTimer(CTimer*)
+ {
+ UINT_PTR LangID = (UINT_PTR)GetKeyboardLayout(0);
+ char Lang[3] = { 0 };
+ GetLocaleInfoA(MAKELCID((LangID & 0xffffffff), SORT_DEFAULT), LOCALE_SABBREVLANGNAME, Lang, 2);
+ Lang[0] = toupper(Lang[0]);
+ Lang[1] = tolower(Lang[1]);
+ m_language.SetTextA(Lang);
+ }
+
INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override
{
- if (msg == WM_TIMER) {
- UINT_PTR LangID = (UINT_PTR)GetKeyboardLayout(0);
- char Lang[3] = { 0 };
- GetLocaleInfoA(MAKELCID((LangID & 0xffffffff), SORT_DEFAULT), LOCALE_SABBREVLANGNAME, Lang, 2);
- Lang[0] = toupper(Lang[0]);
- Lang[1] = tolower(Lang[1]);
- m_language.SetTextA(Lang);
- return FALSE;
- }
- else if (msg == WM_CTLCOLORSTATIC) {
+ if (msg == WM_CTLCOLORSTATIC) {
if ((HWND)lParam == m_language.GetHwnd()) {
SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
SetBkMode((HDC)wParam, TRANSPARENT);
@@ -153,6 +154,19 @@ class CEnterPasswordDialog : public CDlgBase
return CDlgBase::DlgProc(msg, wParam, lParam);
}
+public:
+ CEnterPasswordDialog(CDbxMDBX *db) :
+ CDlgBase(g_plugin, IDD_LOGIN),
+ m_timer(this, 1),
+ m_header(this, IDC_HEADERBAR),
+ m_language(this, IDC_LANG),
+ m_passwordEdit(this, IDC_USERPASS),
+ m_db(db)
+ {
+ m_newPass[0] = 0;
+ m_timer.OnEvent = Callback(this, &CEnterPasswordDialog::OnTimer);
+ }
+
bool OnInitDialog() override
{
m_header.SendMsg(WM_SETICON, ICON_SMALL, (LPARAM)g_plugin.getIcon(IDI_LOGO, true));
@@ -160,40 +174,26 @@ class CEnterPasswordDialog : public CDlgBase
if (m_wrongPass) {
if (m_wrongPass > 2) {
m_passwordEdit.Disable();
- m_buttonOK.Disable();
+ EnableWindow(GetDlgItem(m_hwnd, IDOK), false);
m_header.SetText(TranslateT("Too many errors!"));
}
else m_header.SetText(TranslateT("Password is not correct!"));
}
else m_header.SetText(TranslateT("Please type in your password"));
- SetTimer(m_hwnd, 1, 200, nullptr);
+ m_timer.Start(200);
return true;
}
- void OnDestroy() override
- {
- KillTimer(m_hwnd, 1);
- Window_FreeIcon_IcoLib(m_header.GetHwnd());
- }
-
- void OnOK(CCtrlButton*)
+ bool OnApply() override
{
m_passwordEdit.GetText(m_newPass, _countof(m_newPass));
- EndDialog(m_hwnd, -128);
+ return true;
}
-public:
- CEnterPasswordDialog(CDbxMDBX *db) :
- CDlgBase(g_plugin, IDD_LOGIN),
- m_header(this, IDC_HEADERBAR),
- m_language(this, IDC_LANG),
- m_passwordEdit(this, IDC_USERPASS),
- m_buttonOK(this, IDOK),
- m_db(db)
+ void OnDestroy() override
{
- m_newPass[0] = 0;
- m_buttonOK.OnClick = Callback(this, &CEnterPasswordDialog::OnOK);
+ Window_FreeIcon_IcoLib(m_header.GetHwnd());
}
};
@@ -233,7 +233,7 @@ int CDbxMDBX::InitCrypt()
if (!m_crypto->setKey((const BYTE*)value.iov_base, value.iov_len)) {
CEnterPasswordDialog dlg(this);
while (true) {
- if (-128 != dlg.DoModal())
+ if (!dlg.DoModal())
return 4;
m_crypto->setPassword(pass_ptrA(mir_utf8encodeW(dlg.m_newPass)));
if (m_crypto->setKey((const BYTE*)value.iov_base, value.iov_len)) {