summaryrefslogtreecommitdiff
path: root/plugins/Db3x_mmap/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-12-05 22:07:14 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-12-05 22:07:14 +0000
commit39679a3cc145c5253bbbd99b9a013f3fe991532b (patch)
tree50faf2e1a7a1fd464bd2a75f3865229e28057246 /plugins/Db3x_mmap/src
parent3f4bfef9370e7ec778e501f4608d3c4fe0b3b255 (diff)
resetting menu item name upon password change
git-svn-id: http://svn.miranda-ng.org/main/trunk@7061 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap/src')
-rw-r--r--plugins/Db3x_mmap/src/dbcrypt.cpp1
-rw-r--r--plugins/Db3x_mmap/src/dbintf.h3
-rw-r--r--plugins/Db3x_mmap/src/ui.cpp36
3 files changed, 27 insertions, 13 deletions
diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp
index 4193316d17..7b384cedfe 100644
--- a/plugins/Db3x_mmap/src/dbcrypt.cpp
+++ b/plugins/Db3x_mmap/src/dbcrypt.cpp
@@ -207,4 +207,5 @@ void CDb3Mmap::SetPassword(LPCTSTR ptszPassword)
m_bUsesPassword = true;
m_crypto->setPassword(ptrA(mir_utf8encodeT(ptszPassword)));
}
+ UpdateMenuItem();
}
diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h
index 1d5fae78a6..c512b27ecb 100644
--- a/plugins/Db3x_mmap/src/dbintf.h
+++ b/plugins/Db3x_mmap/src/dbintf.h
@@ -301,6 +301,9 @@ struct CDb3Mmap : public CDb3Base
void StoreKey(void);
void SetPassword(const TCHAR *ptszPassword);
+ void UpdateMenuItem(void);
+
+ __forceinline LPSTR GetMenuTitle() const { return m_bUsesPassword ? LPGEN("Change/remove password") : LPGEN("Set password"); }
protected:
virtual DWORD GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc,DWORD ofsContact,DWORD ofsModuleName);
diff --git a/plugins/Db3x_mmap/src/ui.cpp b/plugins/Db3x_mmap/src/ui.cpp
index fa22d1008b..0c74569dcd 100644
--- a/plugins/Db3x_mmap/src/ui.cpp
+++ b/plugins/Db3x_mmap/src/ui.cpp
@@ -192,20 +192,22 @@ LBL_Error:
SetDlgItemTextA(hwndDlg, IDC_USERPASS2, "");
}
else {
- param->newPass[0] = 0;
- EndDialog(hwndDlg, IDOK);
+ param->db->SetPassword(NULL);
+ param->db->StoreKey();
+ EndDialog(hwndDlg, IDREMOVE);
}
break;
case IDOK:
- GetDlgItemText(hwndDlg, IDC_USERPASS1, param->newPass, SIZEOF(param->newPass));
- if (_tcslen(param->newPass) < 3) {
+ TCHAR buf2[100];
+ GetDlgItemText(hwndDlg, IDC_USERPASS1, buf2, SIZEOF(buf2));
+ if (_tcslen(buf2) < 3) {
SetDlgItemText(hwndDlg, IDC_HEADERBAR, TranslateT("Password is too short!"));
goto LBL_Error;
}
GetDlgItemText(hwndDlg, IDC_USERPASS2, buf, SIZEOF(buf));
- if (_tcscmp(param->newPass, buf)) {
+ if (_tcscmp(buf2, buf)) {
SetWindowText(GetDlgItem(hwndDlg, IDC_HEADERBAR), TranslateT("Passwords do not match!"));
goto LBL_Error;
}
@@ -213,6 +215,9 @@ LBL_Error:
if (!CheckOldPassword(hwndDlg, param->db))
goto LBL_Error;
+ param->db->SetPassword(buf2);
+ param->db->StoreKey();
+ SecureZeroMemory(buf2, sizeof(buf2));
EndDialog(hwndDlg, IDOK);
}
break;
@@ -233,16 +238,21 @@ static INT_PTR ChangePassword(void* obj, LPARAM, LPARAM)
{
CDb3Mmap *db = (CDb3Mmap*)obj;
DlgChangePassParam param = { db };
- if (IDOK == DialogBoxParam(g_hInst, MAKEINTRESOURCE(db->usesPassword() ? IDD_CHANGEPASS : IDD_NEWPASS), 0, sttChangePassword, (LPARAM)&param)) {
- db->SetPassword(param.newPass);
- db->StoreKey();
- }
-
+ DialogBoxParam(g_hInst, MAKEINTRESOURCE(db->usesPassword() ? IDD_CHANGEPASS : IDD_NEWPASS), 0, sttChangePassword, (LPARAM)&param);
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
+void CDb3Mmap::UpdateMenuItem()
+{
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.flags = CMIM_NAME;
+ mi.icolibItem = iconList[1].hIcolib;
+ mi.pszName = GetMenuTitle();
+ Menu_ModifyItem(hSetPwdMenu, &mi);
+}
+
static int OnModulesLoaded(PVOID obj, WPARAM, LPARAM)
{
CDb3Mmap *db = (CDb3Mmap*)obj;
@@ -251,10 +261,10 @@ static int OnModulesLoaded(PVOID obj, WPARAM, LPARAM)
// main menu item
CLISTMENUITEM mi = { sizeof(mi) };
- mi.flags = CMIM_ALL | CMIF_TCHAR;
+ mi.flags = CMIM_ALL;
mi.icolibItem = iconList[1].hIcolib;
- mi.ptszName = (db->isEncrypted()) ? LPGENT("Change password") : LPGENT("Set password");
- mi.ptszPopupName = LPGENT("Database");
+ mi.pszName = db->GetMenuTitle();
+ mi.pszPopupName = LPGEN("Database");
mi.pszService = MS_DB_CHANGEPASSWORD;
mi.position = 500000000;
hSetPwdMenu = Menu_AddMainMenuItem(&mi);