summaryrefslogtreecommitdiff
path: root/plugins/New_GPG
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-09-26 19:16:12 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-09-26 19:16:12 +0300
commitc5dc28ec2272a865ef2f28fd7ab151b55517fedf (patch)
treed751f3e869c66371b8f1d65480b39c2997ba6e62 /plugins/New_GPG
parentdc2a4dc50d6cc3e7bd513122756dd39141d7887e (diff)
more clipboard shit removed
Diffstat (limited to 'plugins/New_GPG')
-rw-r--r--plugins/New_GPG/src/options.cpp42
-rw-r--r--plugins/New_GPG/src/ui.cpp30
2 files changed, 5 insertions, 67 deletions
diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp
index 5dd4c3d03c..2462694f43 100644
--- a/plugins/New_GPG/src/options.cpp
+++ b/plugins/New_GPG/src/options.cpp
@@ -445,45 +445,11 @@ public:
}
}
- void onClick_COPY_KEY(CCtrlButton*)
+ void onClick_COPY_KEY(CCtrlButton *)
{
- if (OpenClipboard(m_hwnd)) {
- CMStringA str(g_plugin.getMStringA("GPGPubKey"));
- str.Replace("\n", "\r\n");
-
- HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, str.GetLength() + 1);
- if (!hMem) {
- MessageBox(nullptr, TranslateT("Failed to allocate memory"), TranslateT("Error"), MB_OK);
- return;
- }
-
- char *szKey = (char*)GlobalLock(hMem);
- if (!szKey) {
- wchar_t msg[64];
- mir_snwprintf(msg, TranslateT("Failed to lock memory with error %d"), GetLastError());
- MessageBox(nullptr, msg, TranslateT("Error"), MB_OK);
- GlobalFree(hMem);
- }
- else {
- memcpy(szKey, str.c_str(), str.GetLength());
- szKey[str.GetLength()] = '\0';
-
- EmptyClipboard();
- GlobalUnlock(hMem);
- if (!SetClipboardData(CF_OEMTEXT, hMem)) {
- GlobalFree(hMem);
- wchar_t msg[64];
- mir_snwprintf(msg, TranslateT("Failed write to clipboard with error %d"), GetLastError());
- MessageBox(nullptr, msg, TranslateT("Error"), MB_OK);
- }
- CloseClipboard();
- }
- }
- else {
- wchar_t msg[64];
- mir_snwprintf(msg, TranslateT("Failed to open clipboard with error %d"), GetLastError());
- MessageBox(nullptr, msg, TranslateT("Error"), MB_OK);
- }
+ CMStringW str(g_plugin.getMStringW("GPGPubKey"));
+ str.Replace(L"\n", L"\r\n");
+ Utils_ClipboardCopy(str);
}
void onClick_LOG_FILE_SET(CCtrlButton*)
diff --git a/plugins/New_GPG/src/ui.cpp b/plugins/New_GPG/src/ui.cpp
index f56c876d71..7ae95a8443 100644
--- a/plugins/New_GPG/src/ui.cpp
+++ b/plugins/New_GPG/src/ui.cpp
@@ -538,9 +538,6 @@ public:
if (i == -1)
return;
- if (!OpenClipboard(m_hwnd))
- return;
-
list_KEY_LIST.GetItemText(i, 0, fp, _countof(fp));
gpg_execution_params params;
@@ -554,32 +551,7 @@ public:
return;
params.out.Remove('\r');
- HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, params.out.GetLength() + 1);
- if (!hMem) {
- MessageBox(nullptr, TranslateT("Failed to allocate memory"), TranslateT("Error"), MB_OK);
- return;
- }
-
- char *szKey = (char *)GlobalLock(hMem);
- if (!szKey) {
- wchar_t msg[64];
- mir_snwprintf(msg, TranslateT("Failed to lock memory with error %d"), GetLastError());
- MessageBox(nullptr, msg, TranslateT("Error"), MB_OK);
- GlobalFree(hMem);
- }
-
- memcpy(szKey, params.out.c_str(), params.out.GetLength());
- szKey[params.out.GetLength()] = '\0';
-
- EmptyClipboard();
- GlobalUnlock(hMem);
- if (!SetClipboardData(CF_OEMTEXT, hMem)) {
- GlobalFree(hMem);
- wchar_t msg[64];
- mir_snwprintf(msg, TranslateT("Failed write to clipboard with error %d"), GetLastError());
- MessageBox(nullptr, msg, TranslateT("Error"), MB_OK);
- }
- CloseClipboard();
+ Utils_ClipboardCopy(_A2T(params.out));
}
void onClick_EXPORT_PRIVATE(CCtrlButton *)