diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2010-09-04 00:50:35 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2010-09-04 00:50:35 +0300 |
commit | 0a3c70d8388264a9d4c21c9063c4a493b88b882c (patch) | |
tree | 644e76bd64764f07bae54945a8abcb40f2a51c88 /messages.cpp | |
parent | b53bf2d6db46cd9b7b1b681b0d2bee448f79a400 (diff) |
bugfixes, ability to set default password
Diffstat (limited to 'messages.cpp')
-rw-r--r-- | messages.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
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<<tmp; mir_free(tmp); @@ -151,26 +152,38 @@ int RecvMsgSvc(WPARAM w, LPARAM l) dbsetting += inkeyid; dbsetting += "_Password"; pass = UniGetContactSettingUtf(NULL, szGPGModuleName, dbsetting.c_str(), _T("")); + if(_tcslen(pass) > 0) + debuglog<<"info: found password in database for key id: "<<inkeyid<<", trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" with password\n"; } else + { pass = UniGetContactSettingUtf(NULL, szGPGModuleName, "szKeyPassword", _T("")); + if(_tcslen(pass) > 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; } } |