From 0a3c70d8388264a9d4c21c9063c4a493b88b882c Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Sat, 4 Sep 2010 00:50:35 +0300 Subject: bugfixes, ability to set default password --- messages.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'messages.cpp') diff --git a/messages.cpp b/messages.cpp index 46e54ad..f4e9ad6 100644 --- a/messages.cpp +++ b/messages.cpp @@ -132,6 +132,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) TCHAR *tmp2 = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T("")); wstring path = tmp2; path.append(_T("\\encrypted_data.asc")); + DeleteFile(path.c_str()); wfstream f(path.c_str(), std::ios::out); f< 0) + debuglog<<"info: found password in database for key id: "< 0) + debuglog<<"info: found password for all keys in database, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" with password\n"; + } if(_tcslen(pass) > 0) { - debuglog<<"info: found password in database, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<"\n"; cmd += _T("--passphrase \""); cmd += pass; cmd += _T("\" "); } else if(password) { - debuglog<<"info: found password in memory, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<"\n"; + debuglog<<"info: found password in memory, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" with password\n"; cmd += _T("--passphrase \""); cmd += password; cmd += _T("\" "); } + else + debuglog<<"info: passwords not found in database or memory, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" with out password\n"; mir_free(pass); mir_free(inkeyid); } + { + wstring path = tmp2; + path += _T("\\decrypted_data"); + DeleteFile(path.c_str()); + } cmd += _T("--output \""); cmd += tmp2; cmd += _T("\\decrypted_data\""); @@ -529,10 +542,11 @@ static BOOL CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam, L { case WM_INITDIALOG: { + TranslateDialogDefault(hwndDlg); string questionstr = "Please enter password for key with ID: "; questionstr += inkeyid; SetDlgItemTextA(hwndDlg, IDC_KEYID, questionstr.c_str()); - TranslateDialogDefault(hwndDlg); + EnableWindow(GetDlgItem(hwndDlg, IDC_DEFAULT_PASSWORD), 0); return TRUE; } @@ -550,7 +564,7 @@ static BOOL CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam, L extern TCHAR *password; if(IsDlgButtonChecked(hwndDlg, IDC_SAVE_PASSWORD)) { - if(strlen(inkeyid) > 0) + if((strlen(inkeyid) > 0) && !IsDlgButtonChecked(hwndDlg, IDC_DEFAULT_PASSWORD)) { string dbsetting = "szKey_"; dbsetting += inkeyid; @@ -587,6 +601,7 @@ static BOOL CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam, L switch (((LPNMHDR)lParam)->code) { default: + EnableWindow(GetDlgItem(hwndDlg, IDC_DEFAULT_PASSWORD), IsDlgButtonChecked(hwndDlg, IDC_SAVE_PASSWORD)?1:0); break; } } -- cgit v1.2.3