diff options
author | George Hazan <ghazan@miranda.im> | 2019-05-29 14:12:44 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-05-29 14:12:44 +0300 |
commit | 56bdae442699a6defb1b783ed4d8e81824acf8de (patch) | |
tree | e07a7467d75b3d7c2bb247bbff791ab2e47fbb45 /plugins/Dbx_mdbx/src | |
parent | 2610fee647614e9e13daef898b99315c26fa987c (diff) |
all icons with keys replaced with skin password icon SKINICON_OTHER_KEYS
Diffstat (limited to 'plugins/Dbx_mdbx/src')
-rw-r--r-- | plugins/Dbx_mdbx/src/dbcrypt.cpp | 142 | ||||
-rw-r--r-- | plugins/Dbx_mdbx/src/resource.h | 2 | ||||
-rw-r--r-- | plugins/Dbx_mdbx/src/stdafx.h | 1 | ||||
-rw-r--r-- | plugins/Dbx_mdbx/src/ui.cpp | 66 | ||||
-rw-r--r-- | plugins/Dbx_mdbx/src/ui.h | 183 |
5 files changed, 197 insertions, 197 deletions
diff --git a/plugins/Dbx_mdbx/src/dbcrypt.cpp b/plugins/Dbx_mdbx/src/dbcrypt.cpp index 47bf3c3e34..eafbf7e6e8 100644 --- a/plugins/Dbx_mdbx/src/dbcrypt.cpp +++ b/plugins/Dbx_mdbx/src/dbcrypt.cpp @@ -23,7 +23,59 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-/////////////////////////////////////////////////////////////////////////////////////////
+class CSelectCryptoDialog : public CDlgBase
+{
+ CCtrlCombo m_combo;
+ CCtrlData m_descr;
+ CCtrlCheck m_chkTotalCrypt;
+ CRYPTO_PROVIDER **m_provs;
+ size_t m_provscount;
+ CRYPTO_PROVIDER *m_selected;
+ bool m_bTotalEncryption;
+
+ bool OnInitDialog() override
+ {
+ for (size_t i = 0; i < m_provscount; i++) {
+ CRYPTO_PROVIDER *prov = m_provs[i];
+ m_combo.AddStringA(prov->pszName, i);
+ }
+ m_combo.SetCurSel(0);
+ m_descr.SetText(m_provs[0]->szDescr.w);
+ return true;
+ }
+
+ bool OnClose() override
+ {
+ m_selected = m_provs[m_combo.GetItemData(m_combo.GetCurSel())];
+ m_bTotalEncryption = m_chkTotalCrypt.GetState() != 0;
+ return true;
+ }
+
+ void OnComboChanged(CCtrlCombo*)
+ {
+ m_descr.SetText(m_provs[m_combo.GetItemData(m_combo.GetCurSel())]->szDescr.w);
+ }
+
+public:
+ CSelectCryptoDialog(CRYPTO_PROVIDER **provs, size_t count) :
+ CDlgBase(g_plugin, IDD_SELECT_CRYPTOPROVIDER),
+ m_combo(this, IDC_SELECTCRYPT_COMBO),
+ m_descr(this, IDC_CRYPTOPROVIDER_DESCR),
+ m_chkTotalCrypt(this, IDC_CHECK_TOTALCRYPT),
+ m_provs(provs),
+ m_provscount(count),
+ m_selected(nullptr)
+ {
+ m_combo.OnChange = Callback(this, &CSelectCryptoDialog::OnComboChanged);
+ }
+
+ inline CRYPTO_PROVIDER* GetSelected()
+ { return m_selected;
+ }
+ inline bool TotalSelected()
+ { return m_bTotalEncryption;
+ }
+};
char DBKey_Crypto_Provider[] = "Provider";
char DBKey_Crypto_Key[] = "Key";
@@ -66,6 +118,85 @@ CRYPTO_PROVIDER* CDbxMDBX::SelectProvider() return pProv;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+class CEnterPasswordDialog : public CDlgBase
+{
+ 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;
+
+ 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 ((HWND)lParam == m_language.GetHwnd()) {
+ SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
+ SetBkMode((HDC)wParam, TRANSPARENT);
+ return (INT_PTR)GetSysColorBrush(COLOR_HIGHLIGHT);
+ }
+ }
+ return CDlgBase::DlgProc(msg, wParam, lParam);
+ }
+
+ bool OnInitDialog() override
+ {
+ m_header.SendMsg(WM_SETICON, ICON_SMALL, (LPARAM)g_plugin.getIcon(IDI_LOGO, true));
+
+ if (m_wrongPass) {
+ if (m_wrongPass > 2) {
+ m_passwordEdit.Disable();
+ m_buttonOK.Disable();
+ 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);
+ return true;
+ }
+
+ void OnDestroy() override
+ {
+ KillTimer(m_hwnd, 1);
+ Window_FreeIcon_IcoLib(m_header.GetHwnd());
+ }
+
+ void OnOK(CCtrlButton*)
+ {
+ m_passwordEdit.GetText(m_newPass, _countof(m_newPass));
+ EndDialog(m_hwnd, -128);
+ }
+
+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)
+ {
+ m_newPass[0] = 0;
+ m_buttonOK.OnClick = Callback(this, &CEnterPasswordDialog::OnOK);
+ }
+};
+
int CDbxMDBX::InitCrypt()
{
if (m_crypto != nullptr)
@@ -91,18 +222,17 @@ int CDbxMDBX::InitCrypt() key.iov_len = sizeof(DBKey_Crypto_Key); key.iov_base = DBKey_Crypto_Key;
if (mdbx_get(txn, m_dbCrypto, &key, &value) == MDBX_SUCCESS && (value.iov_len == m_crypto->getKeyLength())) {
if (!m_crypto->setKey((const BYTE*)value.iov_base, value.iov_len)) {
- DlgChangePassParam param = { this };
- CEnterPasswordDialog dlg(¶m);
+ CEnterPasswordDialog dlg(this);
while (true) {
if (-128 != dlg.DoModal())
return 4;
- m_crypto->setPassword(pass_ptrA(mir_utf8encodeW(param.newPass)));
+ m_crypto->setPassword(pass_ptrA(mir_utf8encodeW(dlg.m_newPass)));
if (m_crypto->setKey((const BYTE*)value.iov_base, value.iov_len)) {
m_bUsesPassword = true;
- SecureZeroMemory(¶m, sizeof(param));
+ SecureZeroMemory(&dlg.m_newPass, sizeof(dlg.m_newPass));
break;
}
- param.wrongPass++;
+ dlg.m_wrongPass++;
}
}
}
diff --git a/plugins/Dbx_mdbx/src/resource.h b/plugins/Dbx_mdbx/src/resource.h index ac0d874da2..dfc3ffc748 100644 --- a/plugins/Dbx_mdbx/src/resource.h +++ b/plugins/Dbx_mdbx/src/resource.h @@ -3,7 +3,6 @@ // Используется d:\Others\SVN\MirandaNG\trunk\plugins\Dbx_mdb\res\dbx_mdbx.rc
//
#define IDREMOVE 3
-#define IDI_ICONPASS 100
#define IDI_LOGO 101
#define IDD_LOGIN 102
#define IDD_NEWPASS 103
@@ -21,7 +20,6 @@ #define IDC_TOTAL 1008
#define IDC_SELECTCRYPT_COMBO 1010
#define IDC_CRYPTOPROVIDER_DESCR 1011
-#define IDC_CHECK1 1012
#define IDC_CHECK_TOTALCRYPT 1012
// Next default values for new objects
diff --git a/plugins/Dbx_mdbx/src/stdafx.h b/plugins/Dbx_mdbx/src/stdafx.h index 1d01db9c12..f2e2c2f6e1 100644 --- a/plugins/Dbx_mdbx/src/stdafx.h +++ b/plugins/Dbx_mdbx/src/stdafx.h @@ -50,6 +50,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_protocols.h>
#include <m_netlib.h>
#include <m_gui.h>
+#include <m_skin.h>
#include "../../Libs/libmdbx/src/mdbx.h"
diff --git a/plugins/Dbx_mdbx/src/ui.cpp b/plugins/Dbx_mdbx/src/ui.cpp index 7740130a9c..aa32b95ccf 100644 --- a/plugins/Dbx_mdbx/src/ui.cpp +++ b/plugins/Dbx_mdbx/src/ui.cpp @@ -39,7 +39,6 @@ void LanguageChanged(HWND hwndDlg) }
}
-
/////////////////////////////////////////////////////////////////////////////////////////
static bool CheckOldPassword(HWND hwndDlg, CDbxMDBX *db)
@@ -58,6 +57,13 @@ static bool CheckOldPassword(HWND hwndDlg, CDbxMDBX *db) return true;
}
+struct DlgChangePassParam
+{
+ CDbxMDBX *db;
+ TCHAR newPass[100];
+ unsigned short wrongPass;
+};
+
static INT_PTR CALLBACK sttChangePassword(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
DlgChangePassParam *param = (DlgChangePassParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
@@ -66,7 +72,7 @@ static INT_PTR CALLBACK sttChangePassword(HWND hwndDlg, UINT uMsg, WPARAM wParam switch (uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- SendDlgItemMessage(hwndDlg, IDC_HEADERBAR, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIconByHandle(iconList[0].hIcolib, true));
+ SendDlgItemMessage(hwndDlg, IDC_HEADERBAR, WM_SETICON, ICON_SMALL, (LPARAM)g_plugin.getIcon(IDI_LOGO, true));
param = (DlgChangePassParam*)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
@@ -136,7 +142,7 @@ static INT_PTR CALLBACK sttChangePassword(HWND hwndDlg, UINT uMsg, WPARAM wParam case WM_DESTROY:
KillTimer(hwndDlg, 1);
- IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0));
+ Window_FreeIcon_IcoLib(GetDlgItem(hwndDlg, IDC_HEADERBAR));
}
return FALSE;
@@ -160,6 +166,48 @@ static INT_PTR CompactMe(void* obj, WPARAM, LPARAM) /////////////////////////////////////////////////////////////////////////////////////////
+class COptionsDialog : public CDlgBase
+{
+ CCtrlCheck m_chkStandart;
+ CCtrlCheck m_chkTotal;
+ CCtrlButton m_btnChangePass;
+ CDbxMDBX *m_db;
+
+ bool OnInitDialog() override
+ {
+ m_chkStandart.SetState(!m_db->isEncrypted());
+ m_chkTotal.SetState(m_db->isEncrypted());
+ m_btnChangePass.SetTextA(Translate(m_db->GetMenuTitle()));
+ return true;
+ }
+
+ bool OnApply() override
+ {
+ SetCursor(LoadCursor(nullptr, IDC_WAIT));
+ m_db->EnableEncryption(m_chkTotal.GetState() != 0);
+ SetCursor(LoadCursor(nullptr, IDC_ARROW));
+ m_chkStandart.SetState(!m_db->isEncrypted());
+ m_chkTotal.SetState(m_db->isEncrypted());
+ return true;
+ }
+
+ void ChangePass(CCtrlButton*)
+ {
+ CallService(MS_DB_CHANGEPASSWORD, 0, 0);
+ }
+
+public:
+ COptionsDialog(CDbxMDBX *db) :
+ CDlgBase(g_plugin, IDD_OPTIONS),
+ m_chkStandart(this, IDC_STANDARD),
+ m_chkTotal(this, IDC_TOTAL),
+ m_btnChangePass(this, IDC_USERPASS),
+ m_db(db)
+ {
+ m_btnChangePass.OnClick = Callback(this, &COptionsDialog::ChangePass);
+ }
+};
+
static int OnOptionsInit(PVOID obj, WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
@@ -173,9 +221,15 @@ static int OnOptionsInit(PVOID obj, WPARAM wParam, LPARAM) /////////////////////////////////////////////////////////////////////////////////////////
+static IconItem iconList[] =
+{
+ { LPGEN("Logo"), "logo", IDI_LOGO },
+ { LPGEN("Compact"), "compact", IDI_COMPACT }
+};
+
void CDbxMDBX::UpdateMenuItem()
{
- Menu_ModifyItem(hSetPwdMenu, _A2T(GetMenuTitle()), iconList[1].hIcolib);
+ Menu_ModifyItem(hSetPwdMenu, _A2T(GetMenuTitle()), Skin_GetIconHandle(SKINICON_OTHER_KEYS));
}
static int OnModulesLoaded(PVOID obj, WPARAM, LPARAM)
@@ -194,14 +248,14 @@ static int OnModulesLoaded(PVOID obj, WPARAM, LPARAM) SET_UID(mi, 0x50321866, 0xba1, 0x46dd, 0xb3, 0xa6, 0xc3, 0xcc, 0x55, 0xf2, 0x42, 0x9e);
mi.position = 1000000001;
- mi.hIcolibItem = iconList[1].hIcolib;
+ mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_KEYS);
mi.name.a = db->GetMenuTitle();
mi.pszService = MS_DB_CHANGEPASSWORD;
hSetPwdMenu = Menu_AddMainMenuItem(&mi);
SET_UID(mi, 0x98c0caf3, 0xBfe5, 0x4e31, 0xac, 0xf0, 0xab, 0x95, 0xb2, 0x9b, 0x9f, 0x73);
mi.position++;
- mi.hIcolibItem = iconList[2].hIcolib;
+ mi.hIcolibItem = iconList[1].hIcolib;
mi.name.a = LPGEN("Compact");
mi.pszService = MS_DB_COMPACT;
hSetPwdMenu = Menu_AddMainMenuItem(&mi);
diff --git a/plugins/Dbx_mdbx/src/ui.h b/plugins/Dbx_mdbx/src/ui.h index 8ed9c0b1c3..832146ea33 100644 --- a/plugins/Dbx_mdbx/src/ui.h +++ b/plugins/Dbx_mdbx/src/ui.h @@ -1,187 +1,4 @@ #pragma once
-static IconItem iconList[] =
-{
- { LPGEN("Logo"), "logo", IDI_LOGO },
- { LPGEN("Password"), "password", IDI_ICONPASS },
- { LPGEN("Compact"), "compact", IDI_COMPACT }
-};
-
#define MS_DB_CHANGEPASSWORD "DB/UI/ChangePassword"
#define MS_DB_COMPACT "DB/UI/Compact"
-
-class COptionsDialog : public CDlgBase
-{
- CCtrlCheck m_chkStandart;
- CCtrlCheck m_chkTotal;
- CCtrlButton m_btnChangePass;
- CDbxMDBX *m_db;
-
- bool OnInitDialog() override
- {
- m_chkStandart.SetState(!m_db->isEncrypted());
- m_chkTotal.SetState(m_db->isEncrypted());
- m_btnChangePass.SetTextA(Translate(m_db->GetMenuTitle()));
- return true;
- }
-
- bool OnApply() override
- {
- SetCursor(LoadCursor(nullptr, IDC_WAIT));
- m_db->EnableEncryption(m_chkTotal.GetState() != 0);
- SetCursor(LoadCursor(nullptr, IDC_ARROW));
- m_chkStandart.SetState(!m_db->isEncrypted());
- m_chkTotal.SetState(m_db->isEncrypted());
- return true;
- }
-
- void ChangePass(CCtrlButton*)
- {
- CallService(MS_DB_CHANGEPASSWORD, 0, 0);
- }
-
-public:
- COptionsDialog(CDbxMDBX *db) :
- CDlgBase(g_plugin, IDD_OPTIONS),
- m_chkStandart(this, IDC_STANDARD),
- m_chkTotal(this, IDC_TOTAL),
- m_btnChangePass(this, IDC_USERPASS),
- m_db(db)
- {
- m_btnChangePass.OnClick = Callback(this, &COptionsDialog::ChangePass);
- }
-};
-
-class CSelectCryptoDialog : public CDlgBase
-{
- CCtrlCombo m_combo;
- CCtrlData m_descr;
- CCtrlCheck m_chkTotalCrypt;
- CRYPTO_PROVIDER **m_provs;
- size_t m_provscount;
- CRYPTO_PROVIDER *m_selected;
- bool m_bTotalEncryption;
-
- bool OnInitDialog() override
- {
- for (size_t i = 0; i < m_provscount; i++) {
- CRYPTO_PROVIDER *prov = m_provs[i];
- m_combo.AddStringA(prov->pszName, i);
- }
- m_combo.SetCurSel(0);
- m_descr.SetText(m_provs[0]->szDescr.w);
- return true;
- }
-
- bool OnClose() override
- {
- m_selected = m_provs[m_combo.GetItemData(m_combo.GetCurSel())];
- m_bTotalEncryption = m_chkTotalCrypt.GetState() != 0;
- return true;
- }
-
- void OnComboChanged(CCtrlCombo*)
- {
- m_descr.SetText(m_provs[m_combo.GetItemData(m_combo.GetCurSel())]->szDescr.w);
- }
-
-public:
- CSelectCryptoDialog(CRYPTO_PROVIDER **provs, size_t count) :
- CDlgBase(g_plugin, IDD_SELECT_CRYPTOPROVIDER),
- m_combo(this, IDC_SELECTCRYPT_COMBO),
- m_descr(this, IDC_CRYPTOPROVIDER_DESCR),
- m_chkTotalCrypt(this, IDC_CHECK_TOTALCRYPT),
- m_provs(provs),
- m_provscount(count),
- m_selected(nullptr)
- {
- m_combo.OnChange = Callback(this, &CSelectCryptoDialog::OnComboChanged);
- }
-
- inline CRYPTO_PROVIDER* GetSelected()
- {
- return m_selected;
- }
- inline bool TotalSelected()
- {
- return m_bTotalEncryption;
- }
-};
-
-struct DlgChangePassParam
-{
- CDbxMDBX *db;
- TCHAR newPass[100];
- unsigned short wrongPass;
-};
-
-class CEnterPasswordDialog : public CDlgBase
-{
- CCtrlData m_header;
- CCtrlData m_language;
- CCtrlEdit m_passwordEdit;
- CCtrlButton m_buttonOK;
-
- DlgChangePassParam *m_param;
-
- 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 ((HWND)lParam == m_language.GetHwnd()) {
- SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
- SetBkMode((HDC)wParam, TRANSPARENT);
- return (INT_PTR)GetSysColorBrush(COLOR_HIGHLIGHT);
- }
- }
- return CDlgBase::DlgProc(msg, wParam, lParam);
- }
-
- bool OnInitDialog() override
- {
- m_header.SendMsg(WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(iconList[0].defIconID)));
- if (m_param->wrongPass) {
- if (m_param->wrongPass > 2) {
- m_passwordEdit.Disable();
- m_buttonOK.Disable();
- 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);
- return true;
- }
-
- void OnDestroy() override
- {
- KillTimer(m_hwnd, 1);
- }
-
- void OnOK(CCtrlButton*)
- {
- m_passwordEdit.GetText(m_param->newPass, _countof(m_param->newPass));
- EndDialog(m_hwnd, -128);
- }
-
-public:
- CEnterPasswordDialog(DlgChangePassParam *param) :
- 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_param(param)
- {
- m_buttonOK.OnClick = Callback(this, &CEnterPasswordDialog::OnOK);
- }
-};
|