diff options
author | Alexander Gluzsky <sss123next@list.ru> | 2013-01-28 11:31:01 +0000 |
---|---|---|
committer | Alexander Gluzsky <sss123next@list.ru> | 2013-01-28 11:31:01 +0000 |
commit | cd6972996f5645c1c3fcc55a1673499b266285e6 (patch) | |
tree | 0c37dd94447ab70f8d01cf48bc5f3429939bca6a | |
parent | 63d0eda1753a37d093350a53436e3b86e8266f5e (diff) |
added ability to export private key in key choosing dialog
git-svn-id: http://svn.miranda-ng.org/main/trunk@3315 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rwxr-xr-x | plugins/New_GPG/src/main.cpp | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp index 5e45d04832..7282865ba1 100755 --- a/plugins/New_GPG/src/main.cpp +++ b/plugins/New_GPG/src/main.cpp @@ -712,16 +712,6 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR if(OpenClipboard(hwndDlg))
{
ListView_GetItemText(hwndList, itemnum, 0, fp, 16);
- /*TCHAR *name = new TCHAR [64];
- ListView_GetItemText(hwndList, itemnum, 2, name, 64);
- {
- if(_tcschr(name, _T('(')))
- {
- wstring str = name;
- wstring::size_type p = str.find(_T("("))-1;
- _tcscpy(name, str.substr(0, p).c_str());
- }
- }*/
string out;
DWORD code;
wstring cmd = _T("--batch -a --export ");
@@ -776,6 +766,50 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR }
break;
case IDC_EXPORT_PRIVATE:
+ {
+ TCHAR *p = GetFilePath(_T("Choose file to export key"), _T("*"), _T("Any file"), true);
+ if(!p || !p[0])
+ {
+ delete [] p;
+ //TODO: handle error
+ break;
+ }
+ char *path = mir_t2a(p);
+ delete [] p;
+ std::ofstream file;
+ file.open(path, std::ios::trunc | std::ios::out);
+ mir_free(path);
+ if(!file.is_open())
+ break; //TODO: handle error
+ ListView_GetItemText(hwndList, itemnum, 0, fp, 16);
+ string out;
+ DWORD code;
+ wstring cmd = _T("--batch -a --export-secret-keys ");
+ cmd += fp;
+ gpg_execution_params params;
+ 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<<std::string(time_str()+": GPG execution timed out, aborted");
+ break;
+ }
+ if(result == pxNotFound)
+ break;
+ boost::algorithm::erase_all(out, "\r");
+ file<<out;
+ if(file.is_open())
+ file.close();
+ }
break;
}
|