From dd4c07b6f71dc074dabef6b27e5dd4c49d882bb2 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Fri, 8 Feb 2013 22:52:02 +0200 Subject: merged with miranda_ng main repo "boosted" process management evnt_to_db/history>actual_sending logic to avoid srmm problem --- options.cpp | 107 +++++++++++++++++++----------------------------------------- 1 file changed, 33 insertions(+), 74 deletions(-) (limited to 'options.cpp') diff --git a/options.cpp b/options.cpp index 8360a26..c7b89f5 100755 --- a/options.cpp +++ b/options.cpp @@ -258,28 +258,22 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP if(!keep) if(MessageBox(0, TranslateT("This key not used by any contact, do you want to remove it from public keyring ?"), TranslateT("Key info"), MB_YESNO) == IDYES) { - wstring cmd; + std::vector cmd; string output; DWORD exitcode; - cmd += _T(" --batch --yes --delete-key "); + cmd.push_back(L"--batch"); + cmd.push_back(L"--yes"); + cmd.push_back(L"--delete-key"); ptmp = mir_a2t(tmp); - cmd += ptmp; + cmd.push_back(ptmp); mir_free(ptmp); - gpg_execution_params params; + gpg_execution_params params(cmd); pxResult result; - params.cmd = &cmd; - params.useless = ""; params.out = &output; params.code = &exitcode; params.result = &result; - boost::thread gpg_thread(boost::bind(&pxEexcute_thread, ¶ms)); - if(!gpg_thread.timed_join(boost::posix_time::seconds(10))) + if(!gpg_launcher(params)) { - gpg_thread.~thread(); - TerminateProcess(params.hProcess, 1); - params.hProcess = NULL; - if(bDebugLog) - debuglog< cmd; + cmd.push_back(L"--version"); + gpg_execution_params params(cmd); pxResult result; - params.cmd = &cmd; - params.useless = ""; params.out = &out; params.code = &code; params.result = &result; - boost::thread gpg_thread(boost::bind(&pxEexcute_thread, ¶ms)); - if(!gpg_thread.timed_join(boost::posix_time::seconds(10))) - { - gpg_thread.~thread(); - TerminateProcess(params.hProcess, 1); - params.hProcess = NULL; - } + gpg_launcher(params); DBWriteContactSettingTString(NULL, szGPGModuleName, "szGpgBinPath", tmp_path); mir_free(tmp_path); string::size_type p1 = out.find("(GnuPG) "); @@ -844,26 +831,16 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam { string out; DWORD code; - wstring cmd = _T(" --export -a "); -// TCHAR *tmp3 = mir_a2t(tmp); - cmd += toUTF16(hcontact_data[hcnt].key_in_prescense); -// mir_free(tmp3); - gpg_execution_params params; + std::vector cmd; + cmd.push_back(L"--export"); + cmd.push_back(L"-a"); + cmd.push_back(toUTF16(hcontact_data[hcnt].key_in_prescense)); + gpg_execution_params params(cmd); pxResult result; - params.cmd = &cmd; - params.useless = ""; params.out = &out; params.code = &code; params.result = &result; - boost::thread gpg_thread(boost::bind(&pxEexcute_thread, ¶ms)); - if(!gpg_thread.timed_join(boost::posix_time::seconds(10))) - { - gpg_thread.~thread(); - TerminateProcess(params.hProcess, 1); - params.hProcess = NULL; - if(bDebugLog) - debuglog< cmd; TCHAR tmp2[MAX_PATH] = {0}; TCHAR *ptmp; string output; @@ -985,7 +962,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam mir_free(ptmp); _tcscat(tmp2, _T("\\")); _tcscat(tmp2, _T("temporary_exported.asc")); - DeleteFile(tmp2); + boost::filesystem::remove(tmp2); wfstream f(tmp2, std::ios::out); ptmp = UniGetContactSettingUtf(hcnt, szGPGModuleName, "GPGPubKey", _T("")); wstring str = ptmp; @@ -997,28 +974,17 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam } f< cmd; + cmd.push_back(L"--batch"); + cmd.push_back(L"-a"); + cmd.push_back(L"--export"); + cmd.push_back(fp); mir_free(fp); - gpg_execution_params params; + gpg_execution_params params(cmd); pxResult result; - params.cmd = &cmd; - params.useless = ""; params.out = &out; params.code = &code; params.result = &result; - boost::thread gpg_thread(boost::bind(&pxEexcute_thread, ¶ms)); - if(!gpg_thread.timed_join(boost::posix_time::seconds(10))) - { - gpg_thread.~thread(); - TerminateProcess(params.hProcess, 1); - params.hProcess = NULL; - if(bDebugLog) - debuglog<