summaryrefslogtreecommitdiff
path: root/plugins/New_GPG/src
diff options
context:
space:
mode:
authorAlexander Gluzsky <sss123next@list.ru>2013-01-28 06:15:37 +0000
committerAlexander Gluzsky <sss123next@list.ru>2013-01-28 06:15:37 +0000
commit53dc5988239964b2c134d05686d3e345abf6f654 (patch)
tree1935bba70d4f22e4f1befb21fa637c9fcee5cef1 /plugins/New_GPG/src
parentc8edd352ec9351d662c5e1ea4ae50881d02f53fc (diff)
added ability to copy public key in key choosing dialog
fixed wrong "resource.h" path in new_gpg.rc git-svn-id: http://svn.miranda-ng.org/main/trunk@3312 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/New_GPG/src')
-rwxr-xr-xplugins/New_GPG/src/main.cpp79
-rwxr-xr-xplugins/New_GPG/src/options.cpp3
-rwxr-xr-xplugins/New_GPG/src/resource.h4
3 files changed, 79 insertions, 7 deletions
diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp
index 2c6640a43d..5e45d04832 100755
--- a/plugins/New_GPG/src/main.cpp
+++ b/plugins/New_GPG/src/main.cpp
@@ -42,6 +42,8 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR
SetWindowPos(hwndDlg, 0, firstrun_rect.left, firstrun_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);
TranslateDialogDefault(hwndDlg);
SetWindowText(hwndDlg, TranslateT("Set own key"));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_COPY_PUBKEY), 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_EXPORT_PRIVATE), 0);
col.pszText = _T("Key ID");
col.mask = LVCF_TEXT | LVCF_WIDTH;
col.fmt = LVCFMT_LEFT;
@@ -321,10 +323,7 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR
if(result == pxNotFound)
break;
string::size_type s = 0;
- while((s = out.find("\r", s)) != string::npos)
- {
- out.erase(s, 1);
- }
+ boost::algorithm::erase_all(out, "\r");
{
char buf[64];
GetDlgItemTextA(hwndDlg, IDC_ACCOUNT, buf, 63);
@@ -708,6 +707,76 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR
}
}
break;
+ case IDC_COPY_PUBKEY:
+ {
+ 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 ");
+ 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, &params));
+ 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");
+ HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, out.size() +1);
+ if(!hMem)
+ {
+ MessageBox(0, TranslateT("Failed to alocate memory"), TranslateT("Error"), MB_OK);
+ break;
+ }
+ char *szKey = (char*)GlobalLock(hMem);
+ if(!szKey)
+ {
+ char msg[64];
+ mir_snprintf(msg, 127, "Failed to lock memory with error %d", GetLastError());
+ MessageBoxA(0, msg, "Error", MB_OK);
+ GlobalFree(hMem);
+ }
+ memcpy(szKey, out.c_str(), out.size());
+ szKey[out.size()] = '\0';
+ EmptyClipboard();
+ GlobalUnlock(hMem);
+ if(!SetClipboardData(CF_OEMTEXT, hMem))
+ {
+ GlobalFree(hMem);
+ char msg[64];
+ mir_snprintf(msg, 127, "Failed write to clipboard with error %d", GetLastError());
+ MessageBoxA(0, msg, "Error", MB_OK);
+ }
+ CloseClipboard();
+ }
+ }
+ break;
+ case IDC_EXPORT_PRIVATE:
+ break;
}
break;
@@ -720,6 +789,8 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR
if(hdr->hdr.code == NM_CLICK)
{
EnableWindow(GetDlgItem(hwndDlg, ID_OK), 1);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_COPY_PUBKEY), 1);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_EXPORT_PRIVATE), 1);
itemnum = hdr->iItem;
}
}
diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp
index feea41b67a..230749623c 100755
--- a/plugins/New_GPG/src/options.cpp
+++ b/plugins/New_GPG/src/options.cpp
@@ -381,8 +381,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
char *szKey = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", "");
std::string str = szKey;;
mir_free(szKey);
- for(std::string::size_type i = str.find("\n"); i != std::string::npos; i = str.find("\n", i+2))
- str.replace(i, 1, "\r\n");
+ boost::algorithm::replace_all(str, "\n", "\r\n");
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, str.size() +1);
if(!hMem)
{
diff --git a/plugins/New_GPG/src/resource.h b/plugins/New_GPG/src/resource.h
index 7ffd83c47b..38f790f6a1 100755
--- a/plugins/New_GPG/src/resource.h
+++ b/plugins/New_GPG/src/resource.h
@@ -82,6 +82,7 @@
#define IDC_AUT_EXCHANGE 1065
#define IDC_BUTTON3 1066
#define IDC_COPY_KEY 1066
+#define IDC_COPY_PUBKEY 1066
#define IDC_STRIP_TAGS 1067
#define IDC_CHECK1 1068
#define IDC_PRESCENSE_SUBSCRIPTION 1068
@@ -95,6 +96,7 @@
#define IDC_PUBLIC 1073
#define IDC_PRIVATE 1074
#define IDC_ALL 1075
+#define IDC_EXPORT_PRIVATE 1076
// Next default values for new objects
//
@@ -102,7 +104,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 115
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1076
+#define _APS_NEXT_CONTROL_VALUE 1077
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif