From: Andre Heinecke Date: Fri, 9 Nov 2018 17:17:36 +0000 (+0100) Subject: Add explicit decrypt as WindowMessage handler X-Git-Tag: gpgol-2.3.2~6 X-Git-Url: http://git.gnupg.org/cgi-bin/gitweb.cgi?p=gpgol.git;a=commitdiff_plain;h=d27f609e7f606b6f85c483f15091fa2a5cb204ba Add explicit decrypt as WindowMessage handler * src/mail.cpp (decryptVerify_o): Remove obsolete safeguard against double decryption. * src/windowmessages.cpp (EXT_API_DECRYPT): Add new command. -- This is nice to have a close -> do something with the encrypted mail -> decrypt again workflow. GnuPG-Bug-Id: T4241 --- diff --git a/src/mail.cpp b/src/mail.cpp index a75225f..e44dcde 100644 --- a/src/mail.cpp +++ b/src/mail.cpp @@ -1066,12 +1066,6 @@ Mail::decryptVerify_o () SRCNAME, __func__, m_mailitem); TRETURN 0; } - if (m_needs_wipe) - { - log_error ("%s:%s: Decrypt verify called for msg that needs wipe: %p", - SRCNAME, __func__, m_mailitem); - TRETURN 1; - } auto cipherstream = get_attachment_stream_o (m_mailitem, m_moss_position); if (!cipherstream) diff --git a/src/windowmessages.cpp b/src/windowmessages.cpp index d39cd2b..b311030 100644 --- a/src/windowmessages.cpp +++ b/src/windowmessages.cpp @@ -340,6 +340,25 @@ gpgol_window_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) mail->releaseCurrentItem(); TRETURN 0; } + else if (cds->dwData == EXT_API_DECRYPT) + { + log_debug ("%s:%s CopyData with external decrypt. Payload: %.*s", + SRCNAME, __func__, (int)cds->cbData, (char *) cds->lpData); + + std::string uid ((char*) cds->lpData, cds->cbData); + auto mail = Mail::getMailForUUID (uid.c_str ()); + if (!mail) + { + log_error ("%s:%s Failed to find mail for: %s", + SRCNAME, __func__, uid.c_str() ); + TRETURN DefWindowProc(hWnd, message, wParam, lParam); + } + + log_debug ("%s:%s: Decrypting %p again.", + SRCNAME, __func__, mail); + mail->decryptVerify_o (); + TRETURN 0; + } } return DefWindowProc(hWnd, message, wParam, lParam); diff --git a/src/windowmessages.h b/src/windowmessages.h index a8d24de..4e2ea56 100644 --- a/src/windowmessages.h +++ b/src/windowmessages.h @@ -59,6 +59,7 @@ typedef enum _gpgol_wmsg_type /* External API, keep it stable! */ EXT_API_CLOSE = 1301, EXT_API_CLOSE_ALL = 1302, + EXT_API_DECRYPT = 1303, } gpgol_wmsg_type; typedef struct