summaryrefslogtreecommitdiff
path: root/plugins/New_GPG
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
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')
-rwxr-xr-xplugins/New_GPG/res/new_gpg.rc24
-rwxr-xr-xplugins/New_GPG/src/main.cpp79
-rwxr-xr-xplugins/New_GPG/src/options.cpp3
-rwxr-xr-xplugins/New_GPG/src/resource.h4
4 files changed, 93 insertions, 17 deletions
diff --git a/plugins/New_GPG/res/new_gpg.rc b/plugins/New_GPG/res/new_gpg.rc
index 3714a30c52..928a1cf099 100755
--- a/plugins/New_GPG/res/new_gpg.rc
+++ b/plugins/New_GPG/res/new_gpg.rc
@@ -27,7 +27,7 @@ LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
1 TEXTINCLUDE
BEGIN
- "resource.h\0"
+ "..\src\resource.h\0"
END
2 TEXTINCLUDE
@@ -63,24 +63,26 @@ BEGIN
PUSHBUTTON "Import key from keyserver",IDC_IMPORT,140,152,188,14,WS_DISABLED
END
-IDD_FIRST_RUN DIALOGEX 0, 0, 291, 230
+IDD_FIRST_RUN DIALOGEX 0, 0, 291, 241
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Set own key"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- DEFPUSHBUTTON "خت",ID_OK,12,209,50,14,WS_DISABLED
+ DEFPUSHBUTTON "خت",ID_OK,12,220,50,14,WS_DISABLED
CONTROL "",IDC_KEY_LIST,"SysListView32",LVS_REPORT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,44,277,105
- PUSHBUTTON "Generate key",IDC_GENERATE_KEY,8,152,74,14
+ PUSHBUTTON "Generate key",IDC_GENERATE_KEY,7,152,74,14
LTEXT "Select key for use",IDC_STATIC,16,33,186,8
- EDITTEXT IDC_KEY_PASSWORD,94,168,77,14,ES_PASSWORD | ES_AUTOHSCROLL
- RTEXT "Key password:",IDC_STATIC,12,170,76,8
- PUSHBUTTON "Load other",IDC_OTHER,83,152,64,14
- PUSHBUTTON "Delete key",IDC_DELETE_KEY,149,152,70,14
- PUSHBUTTON "Generate and use random key",IDC_GENERATE_RANDOM,40,184,141,14
+ EDITTEXT IDC_KEY_PASSWORD,94,187,77,14,ES_PASSWORD | ES_AUTOHSCROLL
+ RTEXT "Key password:",IDC_STATIC,12,191,76,8
+ PUSHBUTTON "Load other",IDC_OTHER,117,152,64,14
+ PUSHBUTTON "Delete key",IDC_DELETE_KEY,214,152,70,14
+ PUSHBUTTON "Generate and use random key",IDC_GENERATE_RANDOM,143,220,141,14
LTEXT "",IDC_GENERATING_KEY,82,207,174,8
LTEXT "Account:",IDC_STATIC,15,12,42,8
LTEXT "key id: ",IDC_KEY_ID,178,12,99,8
COMBOBOX IDC_ACCOUNT,66,9,104,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "Copy public key",IDC_COPY_PUBKEY,7,169,101,14
+ PUSHBUTTON "Export private key",IDC_EXPORT_PRIVATE,182,169,102,14
END
IDD_BIN_PATH DIALOGEX 0, 0, 354, 108
@@ -220,8 +222,10 @@ BEGIN
RIGHTMARGIN, 284
VERTGUIDE, 15
TOPMARGIN, 7
- BOTTOMMARGIN, 223
+ BOTTOMMARGIN, 234
HORZGUIDE, 20
+ HORZGUIDE, 166
+ HORZGUIDE, 183
END
IDD_BIN_PATH, DIALOG
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