diff options
Diffstat (limited to 'options.cpp')
-rw-r--r-- | options.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/options.cpp b/options.cpp index 5dafb05..4f73d32 100644 --- a/options.cpp +++ b/options.cpp @@ -624,6 +624,59 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP } } } + char *tmp = UniGetContactSettingUtf(hcnt, szGPGModuleName, "KeyID_Prescense", ""); + if(strlen(tmp) > 0) + { + char *tmp2 = UniGetContactSettingUtf(hcnt, szGPGModuleName, "KeyID", ""); + if(strlen(tmp2) == 0) + { + string out; + DWORD code; + wstring cmd = _T(" --export -a "); + TCHAR *tmp3 = mir_a2t(tmp); + cmd += tmp3; + mir_free(tmp3); + gpg_execution_params params; + pxResult result; + params.cmd = &cmd; + params.useless = ""; + params.out = &out; + params.code = &code; + params.result = &result; + HANDLE gpg_thread = mir_forkthread(pxEexcute_thread, (void*)¶ms); + if(WaitForSingleObject(gpg_thread, 10000) == WAIT_TIMEOUT) + { + TerminateThread(gpg_thread, 0); + MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK); + } + if(result == pxNotFound) + { + MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK); + } + if((out.find("-----BEGIN PGP PUBLIC KEY BLOCK-----") != string::npos) && (out.find("-----END PGP PUBLIC KEY BLOCK-----") != string::npos)) + { + string::size_type p = 0, stop = 0; + for(;;) + { + if((p = out.find("\n", p+2)) != string::npos) + { + if(p > stop) + { + stop = p; + out.insert(p, "\r"); + } + else + break; + } + } + TCHAR *tmp = mir_a2t(out.c_str()); + str.clear(); + str.append(tmp); + } + } + mir_free(tmp2); + } + mir_free(tmp); SetDlgItemText(hwndDlg, IDC_PUBLIC_KEY_EDIT, !str.empty()?str.c_str():_T("")); } hPubKeyEdit = GetDlgItem(hwndDlg, IDC_PUBLIC_KEY_EDIT); |