[git] GpgOL - branch, outlook14, updated. gpgol-1.1.3-33-g98acc5a
by Andre Heinecke
cvs at cvs.gnupg.org
Fri Jul 12 20:06:52 CEST 2013
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG extension for MS Outlook".
The branch, outlook14 has been updated
via 98acc5a6122cb1c664a4c7c0d91472911fcb96f2 (commit)
via 29dccaed22246f9546aa522a1c4a314fe9c813a4 (commit)
via 7ffe414c43e5b8c75da60d23e00fb6943ffdfed2 (commit)
via 22a5a7f43cc683102ff05df98c4d9e4b9d177253 (commit)
via a0a963a941ee89e70afd01115c6b2d46ce22604a (commit)
via 8ee687d2167b2af81784dc3adb00033dfa645db5 (commit)
from 532d7417713e4f3ac9ad4db011fbe117e0fa15de (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 98acc5a6122cb1c664a4c7c0d91472911fcb96f2
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Fri Jul 12 17:33:50 2013 +0000
Update UI to reflect implementation
Comment out add encrypted attachment selection and
the decrypt action in the explorer context.
* src/gpgoladdin.cpp (GetContext): Comment out code.
--
AddEncryptedAttachment is something for later.
diff --git a/src/gpgoladdin.cpp b/src/gpgoladdin.cpp
index d8f1b65..047858d 100644
--- a/src/gpgoladdin.cpp
+++ b/src/gpgoladdin.cpp
@@ -559,14 +559,17 @@ GpgolRibbonExtender::GetCustomUI (BSTR RibbonID, BSTR * RibbonXml)
L" label=\"%S\""
L" onAction=\"decryptBody\"/>"
L" </group>"
+ /*
+ TODO: Implement
L" <group id=\"attachmentGroup\""
L" label=\"%S\">"
L" <button id=\"encryptSignFile\""
L" getImage=\"btnEncryptFileLarge\""
L" size=\"large\""
L" label=\"%S\""
- L" onAction=\"attachEncryptFile\"/>"
+ L" onAction=\"addEncSignedAttachment\"/>"
L" </group>"
+ */
L" </tab>"
L" </tabs>"
L" </ribbon>"
@@ -587,8 +590,11 @@ GpgolRibbonExtender::GetCustomUI (BSTR RibbonID, BSTR * RibbonXml)
_("Textbody"),
_("Encrypt"),
_("Decrypt"),
+ /*
+ TODO: Implement
_("Attachments"),
_("Encrypted file"),
+ */
_("Encrypt"), _("Decrypt")
);
}
@@ -596,6 +602,29 @@ GpgolRibbonExtender::GetCustomUI (BSTR RibbonID, BSTR * RibbonXml)
{
swprintf (buffer,
L"<customUI xmlns=\"http://schemas.microsoft.com/office/2009/07/customui\">"
+ L" <ribbon>"
+ L" <tabs>"
+ L" <tab id=\"gpgolTab\""
+ L" label=\"%S\">"
+ L" <group id=\"general\""
+ L" label=\"%S\">"
+ L" <button id=\"CustomButton\""
+ L" getImage=\"btnCertManager\""
+ L" size=\"large\""
+ L" label=\"%S\""
+ L" onAction=\"startCertManager\"/>"
+ L" </group>"
+ L" <group id=\"textGroup\""
+ L" label=\"%S\">"
+ L" <button id=\"fullTextDecrypt\""
+ L" getImage=\"btnDecryptLarge\""
+ L" size=\"large\""
+ L" label=\"%S\""
+ L" onAction=\"decryptBody\"/>"
+ L" </group>"
+ L" </tab>"
+ L" </tabs>"
+ L" </ribbon>"
L"<contextMenus>"
L"<contextMenu idMso=\"ContextMenuReadOnlyMailText\">"
L" <button id=\"decryptReadButton\""
@@ -603,7 +632,11 @@ GpgolRibbonExtender::GetCustomUI (BSTR RibbonID, BSTR * RibbonXml)
L" onAction=\"decryptSelection\"/>"
L" </contextMenu>"
L"</contextMenus>"
- L"</customUI>", _("Decrypt"));
+ L"</customUI>", _("GpgOL"), _("General"),
+ _("Start Certificate Manager"),
+ _("Textbody"),
+ _("Decrypt"),
+ _("Decrypt"));
}
else if (!wcscmp (RibbonID, L"Microsoft.Outlook.Explorer"))
{
@@ -621,6 +654,18 @@ GpgolRibbonExtender::GetCustomUI (BSTR RibbonID, BSTR * RibbonXml)
L" label=\"%S\""
L" onAction=\"startCertManager\"/>"
L" </group>"
+ /* This would be totally nice but Outlook
+ saves the decrypted text aftewards automatically.
+ Yay,..
+ L" <group id=\"textGroup\""
+ L" label=\"%S\">"
+ L" <button id=\"fullTextDecrypt\""
+ L" getImage=\"btnDecryptLarge\""
+ L" size=\"large\""
+ L" label=\"%S\""
+ L" onAction=\"decryptBody\"/>"
+ L" </group>"
+ */
L" </tab>"
L" </tabs>"
L" <contextualTabs>"
@@ -656,6 +701,7 @@ GpgolRibbonExtender::GetCustomUI (BSTR RibbonID, BSTR * RibbonXml)
L" </contextMenus>"
L"</customUI>",
_("GpgOL"), _("General"), _("Start Certificate Manager"),
+ /*_("Mail Body"), _("Decrypt"),*/
_("GpgOL"), _("Save and decrypt"),/*_("Decrypt"), */
_("Save and decrypt"));
}
commit 29dccaed22246f9546aa522a1c4a314fe9c813a4
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Fri Jul 12 17:28:25 2013 +0000
Make decryptInspector work for Explorer Context
Beware: If you decrypt a Mail in the explorer context outlook
automatically saves it!
* src/ribbon-callbacks.cpp (decryptInspector): Handle explorer
context. Clean up variable names.
--
This code is not called in that context there might be a way
to avoid the save or maybe we can offer something like
"Permanently Decrypt"
diff --git a/src/ribbon-callbacks.cpp b/src/ribbon-callbacks.cpp
index 417cf13..e66adf2 100644
--- a/src/ribbon-callbacks.cpp
+++ b/src/ribbon-callbacks.cpp
@@ -503,8 +503,8 @@ decryptInspector (LPDISPATCH ctrl, int flags)
engine_filter_t filter = NULL;
LPOLEWINDOW actExplorer;
HWND curWindow;
- char* plaintext = NULL;
- int plaintextLen = 0;
+ char* encData = NULL;
+ int encDataLen = 0;
int rc = 0;
unsigned int session_number;
HRESULT hr;
@@ -531,12 +531,16 @@ decryptInspector (LPDISPATCH ctrl, int flags)
}
RELDISP (actExplorer);
- wordEditor = get_oom_object (context, "WordEditor");
- wordApplication = get_oom_object (wordEditor, "get_Application");
- selection = get_oom_object (wordApplication, "get_Selection");
+ if ( !flags & DECRYPT_INSPECTOR_BODY)
+ {
+ wordEditor = get_oom_object (context, "WordEditor");
+ wordApplication = get_oom_object (wordEditor, "get_Application");
+ selection = get_oom_object (wordApplication, "get_Selection");
+ }
mailItem = get_oom_object (context, "CurrentItem");
- if (!wordEditor || !wordApplication || !selection || !mailItem)
+ if ((!wordEditor || !wordApplication || !selection || !mailItem) &&
+ (!flags & DECRYPT_INSPECTOR_BODY))
{
MessageBox (NULL,
"Internal error in GpgOL.\n"
@@ -548,11 +552,27 @@ decryptInspector (LPDISPATCH ctrl, int flags)
goto failure;
}
+ if (!mailItem)
+ {
+ /* This happens when we try to decrypt the body of a mail in the
+ explorer context. */
+ mailItem = get_oom_object (context, "Selection.Item(1)");
+
+ if (!mailItem)
+ {
+ MessageBox (NULL,
+ _("Please select a Mail."),
+ _("GpgOL"),
+ MB_ICONINFORMATION|MB_OK);
+ goto failure;
+ }
+ }
+
if (flags & DECRYPT_INSPECTOR_SELECTION)
{
- plaintext = get_oom_string (selection, "Text");
+ encData = get_oom_string (selection, "Text");
- if (!plaintext || (plaintextLen = strlen (plaintext)) <= 1)
+ if (!encData || (encDataLen = strlen (encData)) <= 1)
{
MessageBox (NULL,
_("Please select the data you wish to decrypt."),
@@ -563,9 +583,9 @@ decryptInspector (LPDISPATCH ctrl, int flags)
}
else if (flags & DECRYPT_INSPECTOR_BODY)
{
- plaintext = get_oom_string (mailItem, "Body");
+ encData = get_oom_string (mailItem, "Body");
- if (!plaintext || (plaintextLen = strlen (plaintext)) <= 1)
+ if (!encData || (encDataLen = strlen (encData)) <= 1)
{
MessageBox (NULL,
_("Nothing to decrypt."),
@@ -575,10 +595,10 @@ decryptInspector (LPDISPATCH ctrl, int flags)
}
}
- fix_linebreaks (plaintext, &plaintextLen);
+ fix_linebreaks (encData, &encDataLen);
/* Determine the protocol based on the content */
- protocol = is_cms_data (plaintext, plaintextLen) ? PROTOCOL_SMIME :
+ protocol = is_cms_data (encData, encDataLen) ? PROTOCOL_SMIME :
PROTOCOL_OPENPGP;
hr = OpenStreamOnFile (MAPIAllocateBuffer, MAPIFreeBuffer,
@@ -617,7 +637,7 @@ decryptInspector (LPDISPATCH ctrl, int flags)
}
/* Write the text in the decryption sink. */
- rc = write_buffer (decsink, plaintext, plaintextLen);
+ rc = write_buffer (decsink, encData, encDataLen);
/* Flush the decryption sink and wait for the encryption to get
ready. */
@@ -669,7 +689,7 @@ decryptInspector (LPDISPATCH ctrl, int flags)
}
if (strlen (buffer) > 1)
{
- /* Now replace the crypto data with the plaintext or show it
+ /* Now replace the crypto data with the encData or show it
somehow.*/
int err;
if (flags & DECRYPT_INSPECTOR_SELECTION)
@@ -706,7 +726,7 @@ decryptInspector (LPDISPATCH ctrl, int flags)
RELDISP (selection);
RELDISP (wordEditor);
RELDISP (wordApplication);
- xfree (plaintext);
+ xfree (encData);
if (tmpstream)
tmpstream->Release();
@@ -866,5 +886,6 @@ encryptSelection (LPDISPATCH ctrl)
HRESULT
addEncSignedAttachment (LPDISPATCH ctrl)
{
+ /* TODO */
return S_OK;
}
commit 7ffe414c43e5b8c75da60d23e00fb6943ffdfed2
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Fri Jul 12 15:41:56 2013 +0000
Implement decryptBody command
Similar to the split in encryptSelection / encryptInspector.
* src/ribbon-callbacks.cpp (decryptInspector): New.
(decryptSelection, decryptBody): Wrapper around decryptInspector.
diff --git a/src/ribbon-callbacks.cpp b/src/ribbon-callbacks.cpp
index 83324ee..417cf13 100644
--- a/src/ribbon-callbacks.cpp
+++ b/src/ribbon-callbacks.cpp
@@ -477,12 +477,21 @@ decryptAttachments (LPDISPATCH ctrl)
callback function failed in an ugly window. */
}
+#define DECRYPT_INSPECTOR_SELECTION 1
+#define DECRYPT_INSPECTOR_BODY 2
+
+/* decryptInspector
+ decrypts the content of an inspector. Controled by flags
+ similary to the encryptInspector.
+*/
+
HRESULT
-decryptSelection (LPDISPATCH ctrl)
+decryptInspector (LPDISPATCH ctrl, int flags)
{
LPDISPATCH context;
LPDISPATCH selection;
LPDISPATCH wordEditor;
+ LPDISPATCH mailItem;
LPDISPATCH wordApplication;
struct sink_s decsinkmem;
@@ -494,8 +503,8 @@ decryptSelection (LPDISPATCH ctrl)
engine_filter_t filter = NULL;
LPOLEWINDOW actExplorer;
HWND curWindow;
- char* selectedText = NULL;
- int selectedLen = 0;
+ char* plaintext = NULL;
+ int plaintextLen = 0;
int rc = 0;
unsigned int session_number;
HRESULT hr;
@@ -525,8 +534,9 @@ decryptSelection (LPDISPATCH ctrl)
wordEditor = get_oom_object (context, "WordEditor");
wordApplication = get_oom_object (wordEditor, "get_Application");
selection = get_oom_object (wordApplication, "get_Selection");
+ mailItem = get_oom_object (context, "CurrentItem");
- if (!wordEditor || !wordApplication || !selection)
+ if (!wordEditor || !wordApplication || !selection || !mailItem)
{
MessageBox (NULL,
"Internal error in GpgOL.\n"
@@ -538,22 +548,37 @@ decryptSelection (LPDISPATCH ctrl)
goto failure;
}
- selectedText = get_oom_string (selection, "Text");
+ if (flags & DECRYPT_INSPECTOR_SELECTION)
+ {
+ plaintext = get_oom_string (selection, "Text");
- if (!selectedText || (selectedLen = strlen (selectedText)) <= 1)
+ if (!plaintext || (plaintextLen = strlen (plaintext)) <= 1)
+ {
+ MessageBox (NULL,
+ _("Please select the data you wish to decrypt."),
+ _("GpgOL"),
+ MB_ICONINFORMATION|MB_OK);
+ goto failure;
+ }
+ }
+ else if (flags & DECRYPT_INSPECTOR_BODY)
{
- /* TODO more usable if we just use all text in this case? */
- MessageBox (NULL,
- _("Please select the data you wish to decrypt."),
- _("GpgOL"),
- MB_ICONINFORMATION|MB_OK);
- goto failure;
+ plaintext = get_oom_string (mailItem, "Body");
+
+ if (!plaintext || (plaintextLen = strlen (plaintext)) <= 1)
+ {
+ MessageBox (NULL,
+ _("Nothing to decrypt."),
+ _("GpgOL"),
+ MB_ICONINFORMATION|MB_OK);
+ goto failure;
+ }
}
- fix_linebreaks (selectedText, &selectedLen);
+ fix_linebreaks (plaintext, &plaintextLen);
/* Determine the protocol based on the content */
- protocol = is_cms_data (selectedText, selectedLen) ? PROTOCOL_SMIME :
+ protocol = is_cms_data (plaintext, plaintextLen) ? PROTOCOL_SMIME :
PROTOCOL_OPENPGP;
hr = OpenStreamOnFile (MAPIAllocateBuffer, MAPIFreeBuffer,
@@ -592,7 +617,7 @@ decryptSelection (LPDISPATCH ctrl)
}
/* Write the text in the decryption sink. */
- rc = write_buffer (decsink, selectedText, selectedLen);
+ rc = write_buffer (decsink, plaintext, plaintextLen);
/* Flush the decryption sink and wait for the encryption to get
ready. */
@@ -644,9 +669,19 @@ decryptSelection (LPDISPATCH ctrl)
}
if (strlen (buffer) > 1)
{
- /* Now replace the selection with the encrypted or show it
+ /* Now replace the crypto data with the plaintext or show it
somehow.*/
- if (put_oom_string (selection, "Text", buffer))
+ int err;
+ if (flags & DECRYPT_INSPECTOR_SELECTION)
+ {
+ err = put_oom_string (selection, "Text", buffer);
+ }
+ else if (flags & DECRYPT_INSPECTOR_BODY)
+ {
+ err = put_oom_string (mailItem, "Body", buffer);
+ }
+
+ if (err)
{
MessageBox (NULL, buffer,
_("Plain text"),
@@ -667,10 +702,11 @@ decryptSelection (LPDISPATCH ctrl)
log_debug ("%s:%s: failed rc=%d (%s) <%s>", SRCNAME, __func__, rc,
gpg_strerror (rc), gpg_strsource (rc));
engine_cancel (filter);
+ RELDISP (mailItem);
RELDISP (selection);
RELDISP (wordEditor);
RELDISP (wordApplication);
- xfree (selectedText);
+ xfree (plaintext);
if (tmpstream)
tmpstream->Release();
@@ -773,7 +809,6 @@ getIcon (int id, VARIANT* result)
result->pdispVal = pPict;
result->vt = VT_DISPATCH;
-
return S_OK;
}
@@ -799,6 +834,7 @@ startCertManager (LPDISPATCH ctrl)
SRCNAME, __func__);
curWindow = NULL;
}
+ RELDISP (actExplorer);
engine_start_keymanager (curWindow);
}
@@ -806,7 +842,13 @@ startCertManager (LPDISPATCH ctrl)
HRESULT
decryptBody (LPDISPATCH ctrl)
{
- return S_OK;
+ return decryptInspector (ctrl, DECRYPT_INSPECTOR_BODY);
+}
+
+HRESULT
+decryptSelection (LPDISPATCH ctrl)
+{
+ return decryptInspector (ctrl, DECRYPT_INSPECTOR_SELECTION);
}
HRESULT
commit 22a5a7f43cc683102ff05df98c4d9e4b9d177253
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Fri Jul 12 15:19:19 2013 +0000
Release dispatcher objects
QueryInterface adds a reference that has to be released.
* src/ribbon-callbacks.cpp (encryptInspector, decryptAttachments),
(startCertManager, decryptSelection): Release dispatcher.
diff --git a/src/ribbon-callbacks.cpp b/src/ribbon-callbacks.cpp
index 0227893..83324ee 100644
--- a/src/ribbon-callbacks.cpp
+++ b/src/ribbon-callbacks.cpp
@@ -114,6 +114,7 @@ encryptInspector (LPDISPATCH ctrl, int flags)
SRCNAME, __func__);
curWindow = NULL;
}
+ RELDISP (actExplorer);
wordEditor = get_oom_object (context, "WordEditor");
application = get_oom_object (wordEditor, "get_Application");
@@ -132,7 +133,7 @@ encryptInspector (LPDISPATCH ctrl, int flags)
MB_ICONINFORMATION|MB_OK);
log_error ("%s:%s: Could not find all objects.",
SRCNAME, __func__);
- return S_OK;
+ goto failure;
}
if (flags & ENCRYPT_INSPECTOR_SELECTION)
@@ -230,11 +231,7 @@ encryptInspector (LPDISPATCH ctrl, int flags)
encsink->writefnc = sink_encryption_write;
engine_set_session_number (filter, session_number);
- {
- char *tmp = get_oom_string (mailItem, "Subject");
- engine_set_session_title (filter, tmp);
- xfree (tmp);
- }
+ engine_set_session_title (filter, _("GpgOL"));
if ((rc=engine_encrypt_prepare (filter, curWindow,
PROTOCOL_UNKNOWN,
@@ -406,6 +403,9 @@ decryptAttachments (LPDISPATCH ctrl)
SRCNAME, __func__);
curWindow = NULL;
}
+
+ RELDISP (actExplorer);
+
{
char *filenames[attachmentCount + 1];
filenames[attachmentCount] = NULL;
@@ -452,6 +452,7 @@ decryptAttachments (LPDISPATCH ctrl)
DISPATCH_METHOD, &saveParams,
NULL, NULL, NULL);
SysFreeString (saveParams.rgvarg[0].bstrVal);
+ RELDISP (attachmentObj);
if (FAILED(hr))
{
int j;
@@ -459,9 +460,11 @@ decryptAttachments (LPDISPATCH ctrl)
SRCNAME, __func__, (unsigned int) hr);
for (j = 0; j < i; j++)
xfree (filenames[j]);
+ RELDISP (attachmentSelection);
return hr;
}
}
+ RELDISP (attachmentSelection);
err = op_assuan_start_decrypt_files (curWindow, filenames);
for (i = 0; i < attachmentCount; i++)
xfree (filenames[i]);
@@ -517,6 +520,7 @@ decryptSelection (LPDISPATCH ctrl)
SRCNAME, __func__);
curWindow = NULL;
}
+ RELDISP (actExplorer);
wordEditor = get_oom_object (context, "WordEditor");
wordApplication = get_oom_object (wordEditor, "get_Application");
@@ -531,7 +535,7 @@ decryptSelection (LPDISPATCH ctrl)
MB_ICONINFORMATION|MB_OK);
log_error ("%s:%s: Could not find all objects.",
SRCNAME, __func__);
- return S_OK;
+ goto failure;
}
selectedText = get_oom_string (selection, "Text");
@@ -543,7 +547,7 @@ decryptSelection (LPDISPATCH ctrl)
_("Please select the data you wish to decrypt."),
_("GpgOL"),
MB_ICONINFORMATION|MB_OK);
- return S_OK;
+ goto failure;
}
fix_linebreaks (selectedText, &selectedLen);
@@ -576,7 +580,7 @@ decryptSelection (LPDISPATCH ctrl)
decsink->writefnc = sink_encryption_write;
engine_set_session_number (filter, session_number);
- engine_set_session_title (filter, _("Decrypt"));
+ engine_set_session_title (filter, _("GpgOL"));
if ((rc=engine_decrypt_start (filter, curWindow,
protocol,
@@ -663,6 +667,9 @@ decryptSelection (LPDISPATCH ctrl)
log_debug ("%s:%s: failed rc=%d (%s) <%s>", SRCNAME, __func__, rc,
gpg_strerror (rc), gpg_strsource (rc));
engine_cancel (filter);
+ RELDISP (selection);
+ RELDISP (wordEditor);
+ RELDISP (wordApplication);
xfree (selectedText);
if (tmpstream)
tmpstream->Release();
@@ -795,6 +802,7 @@ startCertManager (LPDISPATCH ctrl)
engine_start_keymanager (curWindow);
}
+
HRESULT
decryptBody (LPDISPATCH ctrl)
{
@@ -813,7 +821,6 @@ encryptSelection (LPDISPATCH ctrl)
return encryptInspector (ctrl, ENCRYPT_INSPECTOR_SELECTION);
}
-
HRESULT
addEncSignedAttachment (LPDISPATCH ctrl)
{
commit a0a963a941ee89e70afd01115c6b2d46ce22604a
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Fri Jul 12 15:01:48 2013 +0000
Implent encryptBody and add some dummy callbacks
The old encryptSelection is now split up into encryptInspector
and encryptSelection. encryptInspector accepts flags to control
it's behavior.
* src/gpgoladdin.cpp (GetIDsOfNames, Invoke): Handle command
callbacks
* src/ribbon-callbacks.cpp (encryptInspector): New. More
general version of encryptSelection.
(encryptBody): New. Calls encryptSelection with body flags.
(addEncSignedAttachment): New. Dummy.
(decryptBody): New. Dummy.
* src/ribbon-callbacks.h: Add new command ids
diff --git a/src/gpgoladdin.cpp b/src/gpgoladdin.cpp
index 9a7df61..d8f1b65 100644
--- a/src/gpgoladdin.cpp
+++ b/src/gpgoladdin.cpp
@@ -449,6 +449,9 @@ GpgolRibbonExtender::GetIDsOfNames (REFIID riid, LPOLESTR *rgszNames,
ID_MAPPER (L"btnEncrypt", ID_BTN_ENCRYPT)
ID_MAPPER (L"btnEncryptLarge", ID_BTN_ENCRYPT_LARGE)
ID_MAPPER (L"btnEncryptFileLarge", ID_BTN_ENCSIGN_LARGE)
+ ID_MAPPER (L"encryptBody", ID_CMD_ENCRYPT_BODY)
+ ID_MAPPER (L"decryptBody", ID_CMD_DECRYPT_BODY)
+ ID_MAPPER (L"addEncSignedAttachment", ID_CMD_ATT_ENCSIGN_FILE)
}
if (cNames > 1)
@@ -486,6 +489,12 @@ GpgolRibbonExtender::Invoke (DISPID dispid, REFIID riid, LCID lcid,
return decryptSelection (parms->rgvarg[0].pdispVal);
case ID_CMD_CERT_MANAGER:
return startCertManager (parms->rgvarg[0].pdispVal);
+ case ID_CMD_ENCRYPT_BODY:
+ return encryptBody (parms->rgvarg[0].pdispVal);
+ case ID_CMD_DECRYPT_BODY:
+ return decryptBody (parms->rgvarg[0].pdispVal);
+ case ID_CMD_ATT_ENCSIGN_FILE:
+ return addEncSignedAttachment (parms->rgvarg[0].pdispVal);
case ID_BTN_CERTMANAGER:
case ID_BTN_ENCRYPT:
case ID_BTN_DECRYPT:
diff --git a/src/ribbon-callbacks.cpp b/src/ribbon-callbacks.cpp
index f686fa6..0227893 100644
--- a/src/ribbon-callbacks.cpp
+++ b/src/ribbon-callbacks.cpp
@@ -46,6 +46,9 @@
#include "mimemaker.h"
#include "filetype.h"
+/* Helper to release dispatcher */
+#define RELDISP(dispatcher) if (dispatcher) dispatcher->Release()
+
/* Gets the context of a ribbon control. And prints some
useful debug output */
HRESULT getContext (LPDISPATCH ctrl, LPDISPATCH *context)
@@ -56,9 +59,17 @@ HRESULT getContext (LPDISPATCH ctrl, LPDISPATCH *context)
return context ? S_OK : E_FAIL;
}
+#define ENCRYPT_INSPECTOR_SELECTION 1
+#define ENCRYPT_INSPECTOR_BODY 2
+
+/* encryptInspector
+ Encrypts text in an IInspector context. Depending on
+ the flags either the active selection or the full body
+ is encrypted.
+*/
HRESULT
-encryptSelection (LPDISPATCH ctrl)
+encryptInspector (LPDISPATCH ctrl, int flags)
{
LPDISPATCH context = NULL;
LPDISPATCH selection;
@@ -75,7 +86,7 @@ encryptSelection (LPDISPATCH ctrl)
char* senderAddr = NULL;
LPSTREAM tmpstream = NULL;
engine_filter_t filter = NULL;
- char* text = NULL;
+ char* plaintext = NULL;
int rc = 0;
HRESULT hr;
int recipientsCnt;
@@ -124,16 +135,32 @@ encryptSelection (LPDISPATCH ctrl)
return S_OK;
}
- text = get_oom_string (selection, "Text");
+ if (flags & ENCRYPT_INSPECTOR_SELECTION)
+ {
+ plaintext = get_oom_string (selection, "Text");
- if (!text || strlen (text) <= 1)
+ if (!plaintext || strlen (plaintext) <= 1)
+ {
+ /* TODO more usable if we just use all text in this case? */
+ MessageBox (NULL,
+ _("Please select text to encrypt."),
+ _("GpgOL"),
+ MB_ICONINFORMATION|MB_OK);
+ goto failure;
+ }
+ }
+ else if (flags & ENCRYPT_INSPECTOR_BODY)
{
- /* TODO more usable if we just use all text in this case? */
- MessageBox (NULL,
- _("Please select text to encrypt."),
- _("GpgOL"),
- MB_ICONINFORMATION|MB_OK);
- return S_OK;
+ plaintext = get_oom_string (mailItem, "Body");
+ if (!plaintext || strlen (plaintext) <= 1)
+ {
+ /* TODO more usable if we just use all text in this case? */
+ MessageBox (NULL,
+ _("Textbody empty."),
+ _("GpgOL"),
+ MB_ICONINFORMATION|MB_OK);
+ goto failure;
+ }
}
/* Create a temporary sink to construct the encrypted data. */
@@ -163,7 +190,7 @@ encryptSelection (LPDISPATCH ctrl)
_("Please add at least one recipent."),
_("GpgOL"),
MB_ICONINFORMATION|MB_OK);
- return S_OK;
+ goto failure;
}
{
@@ -233,7 +260,7 @@ encryptSelection (LPDISPATCH ctrl)
}
/* Write the text in the encryption sink. */
- rc = write_buffer (encsink, text, strlen (text));
+ rc = write_buffer (encsink, plaintext, strlen (plaintext));
if (rc)
{
@@ -298,13 +325,24 @@ encryptSelection (LPDISPATCH ctrl)
unsigned int enclosedSize = strlen (buffer) + 34 + 31 + 1;
char enclosedData[enclosedSize];
snprintf (enclosedData, sizeof enclosedData,
- "-----BEGIN ENCRYPTED MESSAGE-----\n"
+ "-----BEGIN ENCRYPTED MESSAGE-----\r\n"
"%s"
- "-----END ENCRYPTED MESSAGE-----\n", buffer);
- put_oom_string (selection, "Text", enclosedData);
+ "-----END ENCRYPTED MESSAGE-----\r\n", buffer);
+ if (flags & ENCRYPT_INSPECTOR_SELECTION)
+ put_oom_string (selection, "Text", enclosedData);
+ else if (flags & ENCRYPT_INSPECTOR_BODY)
+ put_oom_string (mailItem, "Body", enclosedData);
+
}
else
- put_oom_string (selection, "Text", buffer);
+ {
+ if (flags & ENCRYPT_INSPECTOR_SELECTION)
+ put_oom_string (selection, "Text", buffer);
+ else if (flags & ENCRYPT_INSPECTOR_BODY)
+ {
+ put_oom_string (mailItem, "Body", buffer);
+ }
+ }
}
else
{
@@ -320,9 +358,14 @@ encryptSelection (LPDISPATCH ctrl)
log_debug ("%s:%s: failed rc=%d (%s) <%s>", SRCNAME, __func__, rc,
gpg_strerror (rc), gpg_strsource (rc));
engine_cancel (filter);
- if (tmpstream)
- tmpstream->Release();
- xfree (text);
+ RELDISP(wordEditor);
+ RELDISP(application);
+ RELDISP(selection);
+ RELDISP(sender);
+ RELDISP(recipients);
+ RELDISP(mailItem);
+ RELDISP(tmpstream);
+ xfree (plaintext);
xfree (senderAddr);
return S_OK;
@@ -642,7 +685,6 @@ getIcon (int id, VARIANT* result)
PICTDESC pdesc;
LPDISPATCH pPict;
HRESULT hr;
- UINT fuload;
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::Bitmap* pbitmap;
ULONG_PTR gdiplusToken;
@@ -753,3 +795,27 @@ startCertManager (LPDISPATCH ctrl)
engine_start_keymanager (curWindow);
}
+HRESULT
+decryptBody (LPDISPATCH ctrl)
+{
+ return S_OK;
+}
+
+HRESULT
+encryptBody (LPDISPATCH ctrl)
+{
+ return encryptInspector (ctrl, ENCRYPT_INSPECTOR_BODY);
+}
+
+HRESULT
+encryptSelection (LPDISPATCH ctrl)
+{
+ return encryptInspector (ctrl, ENCRYPT_INSPECTOR_SELECTION);
+}
+
+
+HRESULT
+addEncSignedAttachment (LPDISPATCH ctrl)
+{
+ return S_OK;
+}
diff --git a/src/ribbon-callbacks.h b/src/ribbon-callbacks.h
index 6737a22..f3b2eb2 100644
--- a/src/ribbon-callbacks.h
+++ b/src/ribbon-callbacks.h
@@ -30,6 +30,10 @@
#define ID_CMD_ENCRYPT_SELECTION 3
#define ID_CMD_DECRYPT_SELECTION 4
#define ID_CMD_CERT_MANAGER 5
+#define ID_CMD_ENCRYPT_BODY 6
+#define ID_CMD_DECRYPT_BODY 8
+#define ID_CMD_ATT_ENCSIGN_FILE 9
+
#define ID_BTN_CERTMANAGER IDI_KEY_MANAGER_64_PNG
#define ID_BTN_DECRYPT IDI_DECRYPT_16_PNG
#define ID_BTN_DECRYPT_LARGE IDI_DECRYPT_48_PNG
@@ -40,6 +44,9 @@
HRESULT decryptAttachments (LPDISPATCH ctrl);
HRESULT encryptSelection (LPDISPATCH ctrl);
HRESULT decryptSelection (LPDISPATCH ctrl);
+HRESULT decryptBody (LPDISPATCH ctrl);
+HRESULT encryptBody (LPDISPATCH ctrl);
+HRESULT addEncSignedAttachment (LPDISPATCH ctrl);
HRESULT getIcon (int id, VARIANT* result);
HRESULT startCertManager (LPDISPATCH ctrl);
#endif
commit 8ee687d2167b2af81784dc3adb00033dfa645db5
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Fri Jul 12 14:15:19 2013 +0000
Add ui for additional composer actions
Add dummy buttons for encrypt/decrypt body and adding of
an encrypted attachment.
* src/Makefile.am: Add new icon.
* src/encrypt-sign-file-48.png: New.
* src/gpgoladdin.cpp (GetCustomUI): Add UiXML for new actions
(Invoke, GetIDsOfNames): Handle new callbacks.
* src/ribbon-callbacks.h: Map new Icon.
diff --git a/src/Makefile.am b/src/Makefile.am
index a385d5b..1c01565 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,6 +33,7 @@ EXTRA_DIST = \
encrypt-16.png encrypt-48.png \
key-manager-64.png \
decrypt-16.png decrypt-48.png \
+ encrypt-sign-file-48.png \
logo.bmp README.icons
EXEEXT = .dll
diff --git a/src/dialogs.h b/src/dialogs.h
index 314047d..e140507 100644
--- a/src/dialogs.h
+++ b/src/dialogs.h
@@ -140,5 +140,6 @@
#define IDI_DECRYPT_16_PNG 6010
#define IDI_DECRYPT_48_PNG 6011
#define IDI_KEY_MANAGER_64_PNG 6020
+#define IDI_ENCSIGN_FILE_48_PNG 6030
#endif /*DIALOGS_H*/
diff --git a/src/dialogs.rc b/src/dialogs.rc
index 586ebdb..a5ba635 100644
--- a/src/dialogs.rc
+++ b/src/dialogs.rc
@@ -60,7 +60,7 @@ IDB_DECRYPT_VERIFY_16M BITMAP DISCARDABLE "decrypt-verify-16m.bmp"
IDB_DECRYPT_VERIFY_32 BITMAP DISCARDABLE "decrypt-verify-32.bmp"
IDB_DECRYPT_VERIFY_32M BITMAP DISCARDABLE "decrypt-verify-32m.bmp"
-
+IDI_ENCSIGN_FILE_48_PNG RCDATA "encrypt-sign-file-48.png"
IDB_BANNER BITMAP DISCARDABLE "logo.bmp"
diff --git a/src/encrypt-sign-file-48.png b/src/encrypt-sign-file-48.png
new file mode 100644
index 0000000..aa83384
Binary files /dev/null and b/src/encrypt-sign-file-48.png differ
diff --git a/src/gpgoladdin.cpp b/src/gpgoladdin.cpp
index e6cde64..9a7df61 100644
--- a/src/gpgoladdin.cpp
+++ b/src/gpgoladdin.cpp
@@ -447,6 +447,8 @@ GpgolRibbonExtender::GetIDsOfNames (REFIID riid, LPOLESTR *rgszNames,
ID_MAPPER (L"btnDecrypt", ID_BTN_DECRYPT)
ID_MAPPER (L"btnDecryptLarge", ID_BTN_DECRYPT_LARGE)
ID_MAPPER (L"btnEncrypt", ID_BTN_ENCRYPT)
+ ID_MAPPER (L"btnEncryptLarge", ID_BTN_ENCRYPT_LARGE)
+ ID_MAPPER (L"btnEncryptFileLarge", ID_BTN_ENCSIGN_LARGE)
}
if (cNames > 1)
@@ -488,6 +490,8 @@ GpgolRibbonExtender::Invoke (DISPID dispid, REFIID riid, LCID lcid,
case ID_BTN_ENCRYPT:
case ID_BTN_DECRYPT:
case ID_BTN_DECRYPT_LARGE:
+ case ID_BTN_ENCRYPT_LARGE:
+ case ID_BTN_ENCSIGN_LARGE:
return getIcon (dispid, result);
}
@@ -521,19 +525,63 @@ GpgolRibbonExtender::GetCustomUI (BSTR RibbonID, BSTR * RibbonXml)
{
swprintf (buffer,
L"<customUI xmlns=\"http://schemas.microsoft.com/office/2009/07/customui\">"
- L"<contextMenus>"
- L"<contextMenu idMso=\"ContextMenuText\">"
- L" <button id=\"encryptButton\""
- L" label=\"%S\""
- L" getImage=\"btnEncrypt\""
- L" onAction=\"encryptSelection\"/>"
- L" <button id=\"decryptButton\""
- L" label=\"%S\""
- L" getImage=\"btnDecrypt\""
- L" onAction=\"decryptSelection\"/>"
+ L" <ribbon>"
+ L" <tabs>"
+ L" <tab id=\"gpgolTab\""
+ L" label=\"%S\">"
+ L" <group id=\"general\""
+ L" label=\"%S\">"
+ L" <button id=\"CustomButton\""
+ L" getImage=\"btnCertManager\""
+ L" size=\"large\""
+ L" label=\"%S\""
+ L" onAction=\"startCertManager\"/>"
+ L" </group>"
+ L" <group id=\"textGroup\""
+ L" label=\"%S\">"
+ L" <button id=\"fullTextEncrypt\""
+ L" getImage=\"btnEncryptLarge\""
+ L" size=\"large\""
+ L" label=\"%S\""
+ L" onAction=\"encryptBody\"/>"
+ L" <button id=\"fullTextDecrypt\""
+ L" getImage=\"btnDecryptLarge\""
+ L" size=\"large\""
+ L" label=\"%S\""
+ L" onAction=\"decryptBody\"/>"
+ L" </group>"
+ L" <group id=\"attachmentGroup\""
+ L" label=\"%S\">"
+ L" <button id=\"encryptSignFile\""
+ L" getImage=\"btnEncryptFileLarge\""
+ L" size=\"large\""
+ L" label=\"%S\""
+ L" onAction=\"attachEncryptFile\"/>"
+ L" </group>"
+ L" </tab>"
+ L" </tabs>"
+ L" </ribbon>"
+ L" <contextMenus>"
+ L" <contextMenu idMso=\"ContextMenuText\">"
+ L" <button id=\"encryptButton\""
+ L" label=\"%S\""
+ L" getImage=\"btnEncrypt\""
+ L" onAction=\"encryptSelection\"/>"
+ L" <button id=\"decryptButton\""
+ L" label=\"%S\""
+ L" getImage=\"btnDecrypt\""
+ L" onAction=\"decryptSelection\"/>"
L" </contextMenu>"
L"</contextMenus>"
- L"</customUI>", _("Encrypt"), _("Decrypt"));
+ L"</customUI>", _("GpgOL"), _("General"),
+ _("Start Certificate Manager"),
+ _("Textbody"),
+ _("Encrypt"),
+ _("Decrypt"),
+ _("Attachments"),
+ _("Encrypted file"),
+ _("Encrypt"), _("Decrypt")
+ );
}
else if (!wcscmp (RibbonID, L"Microsoft.Outlook.Mail.Read"))
{
diff --git a/src/ribbon-callbacks.h b/src/ribbon-callbacks.h
index 9396c0f..6737a22 100644
--- a/src/ribbon-callbacks.h
+++ b/src/ribbon-callbacks.h
@@ -35,6 +35,7 @@
#define ID_BTN_DECRYPT_LARGE IDI_DECRYPT_48_PNG
#define ID_BTN_ENCRYPT IDI_ENCRYPT_16_PNG
#define ID_BTN_ENCRYPT_LARGE IDI_ENCRYPT_48_PNG
+#define ID_BTN_ENCSIGN_LARGE IDI_ENCSIGN_FILE_48_PNG
HRESULT decryptAttachments (LPDISPATCH ctrl);
HRESULT encryptSelection (LPDISPATCH ctrl);
-----------------------------------------------------------------------
Summary of changes:
src/Makefile.am | 1 +
src/dialogs.h | 1 +
src/dialogs.rc | 2 +-
src/encrypt-sign-file-48.png | Bin 0 -> 9415 bytes
src/gpgoladdin.cpp | 127 ++++++++++++++++++++--
src/ribbon-callbacks.cpp | 236 +++++++++++++++++++++++++++++++++---------
src/ribbon-callbacks.h | 8 ++
7 files changed, 312 insertions(+), 63 deletions(-)
create mode 100644 src/encrypt-sign-file-48.png
hooks/post-receive
--
GnuPG extension for MS Outlook
http://git.gnupg.org
More information about the Gnupg-commits
mailing list