[git] GpgOL - branch, mime-addin, updated. gpgol-1.2.0-36-g9036bb3

by Andre Heinecke cvs at cvs.gnupg.org
Thu Oct 1 18:24:03 CEST 2015


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, mime-addin has been updated
       via  9036bb3fe96742b6e4f46581d86ca8bf59c6a9a5 (commit)
      from  fdbeb6fbb026b750bc36bfb97c52697e645bd0e1 (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 9036bb3fe96742b6e4f46581d86ca8bf59c6a9a5
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Oct 1 17:56:56 2015 +0200

    Change ribbon UI for mime functionality.
    
    * gpgoladdin.cpp (GetIDsOfNames): Add ID's for mime actions.
      (Invoke): Handle new actions.
      (GetCustomUI): Remove most of the Ribbon UI only leave
      encrypt / sign / start certificate manager buttons.
    * src/mailitem-events.cpp (sign_encrypt_item): Renamed to
      do_crypto_on_item.
      (do_crypto_on_item): Do crypto according to draft flags.
      (needs_crypto): New. Check if the mailitem needs crypto at all.
      (Invoke): Pass send when no crypto action is selected.
    * src/mapihelp.cpp (get_gpgol_draft_info_flags),
      (set_gpgol_draft_info_flags): New helpers to work with draft info.
    * src/mapihelp.h: Declare above functions.
    * src/ribbon-callbacks.cpp (message_flag_status): Show a messagebox
      to inform about crypto actions.
      (mark_mime_action): New. Set the draft_info_flags.
      (mime_sign, mime_encrypt): New. Callback functions for outlook.

diff --git a/src/gpgoladdin.cpp b/src/gpgoladdin.cpp
index 6f189c7..c7da01d 100644
--- a/src/gpgoladdin.cpp
+++ b/src/gpgoladdin.cpp
@@ -464,6 +464,10 @@ GpgolRibbonExtender::GetIDsOfNames (REFIID riid, LPOLESTR *rgszNames,
       ID_MAPPER (L"addEncAttachment", ID_CMD_ATT_ENC_FILE)
       ID_MAPPER (L"signBody", ID_CMD_SIGN_BODY)
       ID_MAPPER (L"verifyBody", ID_CMD_VERIFY_BODY)
+
+      /* MIME support: */
+      ID_MAPPER (L"encryptMime", ID_CMD_MIME_ENCRYPT)
+      ID_MAPPER (L"signMime", ID_CMD_MIME_SIGN)
     }
 
   if (cNames > 1)
@@ -513,6 +517,10 @@ GpgolRibbonExtender::Invoke (DISPID dispid, REFIID riid, LCID lcid,
         return signBody (parms->rgvarg[0].pdispVal);
       case ID_CMD_VERIFY_BODY:
         return verifyBody (parms->rgvarg[0].pdispVal);
+      case ID_CMD_MIME_SIGN:
+        return mime_sign (parms->rgvarg[0].pdispVal);
+      case ID_CMD_MIME_ENCRYPT:
+        return mime_encrypt (parms->rgvarg[0].pdispVal);
       case ID_BTN_CERTMANAGER:
       case ID_BTN_ENCRYPT:
       case ID_BTN_DECRYPT:
@@ -529,7 +537,6 @@ GpgolRibbonExtender::Invoke (DISPID dispid, REFIID riid, LCID lcid,
   return DISP_E_MEMBERNOTFOUND;
 }
 
-
 /* Returns the XML markup for the various RibbonID's
 
    The custom ui syntax is documented at:
@@ -541,289 +548,81 @@ GpgolRibbonExtender::Invoke (DISPID dispid, REFIID riid, LCID lcid,
 STDMETHODIMP
 GpgolRibbonExtender::GetCustomUI (BSTR RibbonID, BSTR * RibbonXml)
 {
-  wchar_t buffer[8192];
+  char * buffer = NULL;
+
   const char *certManagerTTip =
     _("Start the Certificate Management Software");
   const char *certManagerSTip =
     _("Open GPA or Kleopatra to manage your certificates. "
       "You can use this you to generate your "
       "own certificates. ");
-  const char *encryptTextTTip =
-    _("Encrypt the text of the message");
-  const char *encryptTextSTip =
-    _("Choose the certificates for which the message "
-      "should be encrypted and replace the text "
-      "with the encrypted message.");
-  const char *encryptFileTTip =
-    _("Add a file as an encrypted attachment");
-  const char *encryptFileSTip =
-    _("Encrypts a file and adds it as an attachment to the "
-      "message. ");
-  const char *encryptSignFileTTip =
-    _("Add a file as an encrypted attachment with a signature");
-  const char *encryptSignFileSTip =
-    _("Encrypts a file, signs it and adds both the encrypted file "
-      "and the signature as attachments to the message. ");
-  const char *decryptTextTTip=
-    _("Decrypt the message");
-  const char *decryptTextSTip =
-    _("Look for PGP or S/MIME encrypted data in the message text "
-      "and decrypt it.");
-  const char *signTextTTip =
-    _("Add a signature of the message");
-  const char *signTextSTip =
-    _("Appends a signed copy of the message text in an opaque signature. "
-      "An opaque signature ensures that the signed text is not modified by "
-      "embedding it in the signature itself. "
-      "The combination of the signed message text and your signature is "
-      "added below the plain text. "
-      "The message will not be encrypted!");
-
-  memset(buffer, 0, sizeof buffer);
+  const char *encryptTTip =
+    _("Encrypt the message.");
+  const char *encryptSTip =
+    _("Encrypts the message and all attachments before sending.");
+  const char *signTTip =
+    _("Sign the message.");
+  const char *signSTip =
+    _("Sign the message and all attchments before sending.");
 
   log_debug ("%s:%s: GetCustomUI for id: %ls", SRCNAME, __func__, RibbonID);
 
-  if (!RibbonXml)
+  if (!RibbonXml || !RibbonID)
     return E_POINTER;
 
   if (!wcscmp (RibbonID, L"Microsoft.Outlook.Mail.Compose"))
     {
-      swprintf (buffer,
-        L"<customUI xmlns=\"http://schemas.microsoft.com/office/2009/07/customui\">"
-        L" <ribbon>"
-        L"   <tabs>"
-        L"    <tab id=\"gpgolTab\""
-        L"         label=\"%hs\">"
-        L"     <group id=\"general\""
-        L"            label=\"%hs\">"
-        L"       <button id=\"CustomButton\""
-        L"               getImage=\"btnCertManager\""
-        L"               size=\"large\""
-        L"               label=\"%hs\""
-        L"               screentip=\"%hs\""
-        L"               supertip=\"%hs\""
-        L"               onAction=\"startCertManager\"/>"
-        L"     </group>"
-        L"     <group id=\"textGroup\""
-        L"            label=\"%hs\">"
-        L"       <button id=\"fullTextEncrypt\""
-        L"               getImage=\"btnEncryptLarge\""
-        L"               size=\"large\""
-        L"               label=\"%hs\""
-        L"               screentip=\"%hs\""
-        L"               supertip=\"%hs\""
-        L"               onAction=\"encryptBody\"/>"
-        L"       <button id=\"fullTextDecrypt\""
-        L"               getImage=\"btnDecryptLarge\""
-        L"               size=\"large\""
-        L"               label=\"%hs\""
-        L"               screentip=\"%hs\""
-        L"               supertip=\"%hs\""
-        L"               onAction=\"decryptBody\"/>"
-        L"       <button id=\"fullTextSign\""
-        L"               getImage=\"btnSignLarge\""
-        L"               size=\"large\""
-        L"               label=\"%hs\""
-        L"               screentip=\"%hs\""
-        L"               supertip=\"%hs\""
-        L"               onAction=\"signBody\"/>"
-        L"       <button id=\"fullTextVerify\""
-        L"               getImage=\"btnVerifyLarge\""
-        L"               size=\"large\""
-        L"               label=\"%hs\""
-        L"               onAction=\"verifyBody\"/>"
-        L"     </group>"
-        L"     <group id=\"attachmentGroup\""
-        L"            label=\"%hs\">"
-        L"       <button id=\"encryptedFile\""
-        L"               getImage=\"btnEncryptLarge\""
-        L"               size=\"large\""
-        L"               label=\"%hs\""
-        L"               screentip=\"%hs\""
-        L"               supertip=\"%hs\""
-        L"               onAction=\"addEncAttachment\"/>"
-        L"       <button id=\"encryptSignFile\""
-        L"               getImage=\"btnEncryptFileLarge\""
-        L"               size=\"large\""
-        L"               label=\"%hs\""
-        L"               screentip=\"%hs\""
-        L"               supertip=\"%hs\""
-        L"               onAction=\"addEncSignedAttachment\"/>"
-        L"     </group>"
-        L"    </tab>"
-        L"   </tabs>"
-        L" </ribbon>"
-        L" <contextMenus>"
-        L"  <contextMenu idMso=\"ContextMenuText\">"
-        L"    <button id=\"encryptButton\""
-        L"            label=\"%hs\""
-        L"            getImage=\"btnEncrypt\""
-        L"            onAction=\"encryptSelection\"/>"
-        L"    <button id=\"decryptButton\""
-        L"            label=\"%hs\""
-        L"            getImage=\"btnDecrypt\""
-        L"            onAction=\"decryptSelection\"/>"
-        L" </contextMenu>"
-        L"</contextMenus>"
-        L"</customUI>", _("GpgOL"), _("General"),
+      asprintf (&buffer,
+        "<customUI xmlns=\"http://schemas.microsoft.com/office/2009/07/customui\">"
+        " <ribbon>"
+        "   <tabs>"
+        "    <tab id=\"gpgolTab\""
+        "         label=\"%s\">"
+        "     <group id=\"general\""
+        "            label=\"%s\">"
+        "       <button id=\"CustomButton\""
+        "               getImage=\"btnCertManager\""
+        "               size=\"large\""
+        "               label=\"%s\""
+        "               screentip=\"%s\""
+        "               supertip=\"%s\""
+        "               onAction=\"startCertManager\"/>"
+        "     </group>"
+        "     <group id=\"textGroup\""
+        "            label=\"%s\">"
+        "       <button id=\"mimeEncrypt\""
+        "               getImage=\"btnEncryptLarge\""
+        "               size=\"large\""
+        "               label=\"%s\""
+        "               screentip=\"%s\""
+        "               supertip=\"%s\""
+        "               onAction=\"encryptMime\"/>"
+        "       <button id=\"mimeSign\""
+        "               getImage=\"btnSignLarge\""
+        "               size=\"large\""
+        "               label=\"%s\""
+        "               screentip=\"%s\""
+        "               supertip=\"%s\""
+        "               onAction=\"signMime\"/>"
+        "     </group>"
+        "    </tab>"
+        "   </tabs>"
+        " </ribbon>"
+        "</customUI>", _("GpgOL"), _("General"),
         _("Start Certificate Manager"), certManagerTTip, certManagerSTip,
-        _("Textbody"),
-        _("Encrypt"), encryptTextTTip, encryptTextSTip,
-        _("Decrypt"), decryptTextTTip, decryptTextSTip,
-        _("Sign"), signTextTTip, signTextSTip,
-        _("Verify"),
-        _("Attachments"),
-        _("Encrypted file"), encryptFileTTip, encryptFileSTip,
-        _("Encrypted file and Signature"), encryptSignFileTTip, encryptSignFileSTip,
-        _("Encrypt"), _("Decrypt")
+        _("GnuPG"),
+        _("Encrypt"), encryptTTip, encryptSTip,
+        _("Sign"), signTTip, signSTip
         );
     }
-  else if (!wcscmp (RibbonID, L"Microsoft.Outlook.Mail.Read"))
-    {
-      swprintf (buffer,
-        L"<customUI xmlns=\"http://schemas.microsoft.com/office/2009/07/customui\">"
-        L" <ribbon>"
-        L"   <tabs>"
-        L"    <tab id=\"gpgolTab\""
-        L"         label=\"%hs\">"
-        L"     <group id=\"general\""
-        L"            label=\"%hs\">"
-        L"       <button id=\"CustomButton\""
-        L"               getImage=\"btnCertManager\""
-        L"               size=\"large\""
-        L"               label=\"%hs\""
-        L"               screentip=\"%hs\""
-        L"               supertip=\"%hs\""
-        L"               onAction=\"startCertManager\"/>"
-        L"     </group>"
-        L"     <group id=\"textGroup\""
-        L"            label=\"%hs\">"
-        L"       <button id=\"fullTextDecrypt\""
-        L"               getImage=\"btnDecryptLarge\""
-        L"               size=\"large\""
-        L"               label=\"%hs\""
-        L"               screentip=\"%hs\""
-        L"               supertip=\"%hs\""
-        L"               onAction=\"decryptBody\"/>"
-        L"       <button id=\"fullTextVerify\""
-        L"               getImage=\"btnVerifyLarge\""
-        L"               size=\"large\""
-        L"               label=\"%hs\""
-        L"               onAction=\"verifyBody\"/>"
-        L"     </group>"
-        L"    </tab>"
-        L"   </tabs>"
-        L"  <contextualTabs>"
-        L"    <tabSet idMso=\"TabSetAttachments\">"
-        L"        <tab idMso=\"TabAttachments\">"
-        L"            <group label=\"%hs\" id=\"gnupgLabel\">"
-        L"                <button id=\"gpgol_contextual_decrypt\""
-        L"                    size=\"large\""
-        L"                    label=\"%hs\""
-        L"                    getImage=\"btnDecryptLarge\""
-        L"                    onAction=\"attachmentDecryptCallback\" />"
-        L"            </group>"
-        L"        </tab>"
-        L"    </tabSet>"
-        L"  </contextualTabs>"
-        L" </ribbon>"
-        L"<contextMenus>"
-        L"<contextMenu idMso=\"ContextMenuReadOnlyMailText\">"
-        L"   <button id=\"decryptReadButton\""
-        L"           label=\"%hs\""
-        L"           getImage=\"btnDecrypt\""
-        L"           onAction=\"decryptSelection\"/>"
-        L" </contextMenu>"
-        L" <contextMenu idMso=\"ContextMenuAttachments\">"
-        L"   <button id=\"gpgol_decrypt\""
-        L"           label=\"%hs\""
-        L"           getImage=\"btnDecrypt\""
-        L"           onAction=\"attachmentDecryptCallback\"/>"
-        L" </contextMenu>"
-        L"</contextMenus>"
-        L"</customUI>",
-        _("GpgOL"), _("General"),
-        _("Start Certificate Manager"), certManagerTTip, certManagerSTip,
-        _("Textbody"),
-        _("Decrypt"), decryptTextTTip, decryptTextSTip,
-        _("Verify"),
-        _("GpgOL"), _("Save and decrypt"),
-        _("Decrypt"),
-        _("Decrypt"));
-    }
-  else if (!wcscmp (RibbonID, L"Microsoft.Outlook.Explorer"))
+
+  if (buffer)
     {
-      swprintf (buffer,
-        L"<customUI xmlns=\"http://schemas.microsoft.com/office/2009/07/customui\">"
-        L" <ribbon>"
-        L"   <tabs>"
-        L"    <tab id=\"gpgolTab\""
-        L"         label=\"%hs\">"
-        L"     <group id=\"general\""
-        L"            label=\"%hs\">"
-        L"       <button id=\"CustomButton\""
-        L"               getImage=\"btnCertManager\""
-        L"               size=\"large\""
-        L"               label=\"%hs\""
-        L"               screentip=\"%hs\""
-        L"               supertip=\"%hs\""
-        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=\"%hs\">"
-        L"       <button id=\"fullTextDecrypt\""
-        L"               getImage=\"btnDecryptLarge\""
-        L"               size=\"large\""
-        L"               label=\"%hs\""
-        L"               onAction=\"decryptBody\"/>"
-        L"     </group>"
-        */
-        L"    </tab>"
-        L"   </tabs>"
-        L"  <contextualTabs>"
-        L"    <tabSet idMso=\"TabSetAttachments\">"
-        L"        <tab idMso=\"TabAttachments\">"
-        L"            <group label=\"%hs\" id=\"gnupgLabel\">"
-        L"                <button id=\"gpgol_contextual_decrypt\""
-        L"                    size=\"large\""
-        L"                    label=\"%hs\""
-        L"                    getImage=\"btnDecryptLarge\""
-        L"                    onAction=\"attachmentDecryptCallback\" />"
-        L"            </group>"
-        L"        </tab>"
-        L"    </tabSet>"
-        L"  </contextualTabs>"
-        L" </ribbon>"
-        L" <contextMenus>"
-        /*
-           There appears to be no way to access the word editor
-           / get the selected text from that Context.
-        L" <contextMenu idMso=\"ContextMenuReadOnlyMailText\">"
-        L" <button id=\"decryptReadButton1\""
-        L"         label=\"%hs\""
-        L"         onAction=\"decryptSelection\"/>"
-        L" </contextMenu>"
-        */
-        L" <contextMenu idMso=\"ContextMenuAttachments\">"
-        L"   <button id=\"gpgol_decrypt\""
-        L"           label=\"%hs\""
-        L"           getImage=\"btnDecrypt\""
-        L"           onAction=\"attachmentDecryptCallback\"/>"
-        L" </contextMenu>"
-        L" </contextMenus>"
-        L"</customUI>",
-        _("GpgOL"), _("General"),
-        _("Start Certificate Manager"), certManagerTTip, certManagerSTip,
-        /*_("Mail Body"), _("Decrypt"),*/
-        _("GpgOL"), _("Save and decrypt"),/*_("Decrypt"), */
-        _("Save and decrypt"));
+      wchar_t *wbuf = utf8_to_wchar2 (buffer, strlen(buffer));
+      xfree (buffer);
+      *RibbonXml = SysAllocString (wbuf);
+      xfree (wbuf);
     }
-
-  if (wcslen (buffer))
-    *RibbonXml = SysAllocString (buffer);
   else
     *RibbonXml = NULL;
 
diff --git a/src/mailitem-events.cpp b/src/mailitem-events.cpp
index bf364f1..492e2db 100644
--- a/src/mailitem-events.cpp
+++ b/src/mailitem-events.cpp
@@ -167,9 +167,10 @@ MailItemEvents::handle_before_read()
 
 
 static int
-sign_encrypt_item (LPDISPATCH mailitem)
+do_crypto_on_item (LPDISPATCH mailitem)
 {
-  int err = -1;
+  int err = -1,
+      flags = 0;
   LPMESSAGE message = get_oom_base_message (mailitem);
   if (!message)
     {
@@ -177,12 +178,30 @@ sign_encrypt_item (LPDISPATCH mailitem)
                  SRCNAME, __func__);
       return err;
     }
-  log_debug ("%s:%s: Sign / Encrypting message",
-             SRCNAME, __func__);
-  /* TODO check for message flags to determine */
-  err = message_sign_encrypt (message, PROTOCOL_UNKNOWN,
-                              NULL);
-  log_debug ("%s:%s: Sign / Encryption status: %i",
+  flags = get_gpgol_draft_info_flags (message);
+  if (flags == 3)
+    {
+      log_debug ("%s:%s: Sign / Encrypting message",
+                 SRCNAME, __func__);
+      err = message_sign_encrypt (message, PROTOCOL_UNKNOWN,
+                                  NULL);
+    }
+  else if (flags == 2)
+    {
+      err = message_sign (message, PROTOCOL_UNKNOWN,
+                          NULL);
+    }
+  else if (flags == 1)
+    {
+      err = message_encrypt (message, PROTOCOL_UNKNOWN,
+                             NULL);
+    }
+  else
+    {
+      log_debug ("%s:%s: Unknown flags for crypto: %i",
+                 SRCNAME, __func__, flags);
+    }
+  log_debug ("%s:%s: Status: %i",
              SRCNAME, __func__, err);
   message->Release ();
   return err;
@@ -213,6 +232,22 @@ request_send (LPVOID arg)
   return 0;
 }
 
+static bool
+needs_crypto (LPDISPATCH mailitem)
+{
+  LPMESSAGE message = get_oom_message (mailitem);
+  bool ret;
+  if (!message)
+    {
+      log_error ("%s:%s: Failed to get message.",
+                 SRCNAME, __func__);
+      return false;
+    }
+  ret = get_gpgol_draft_info_flags (message);
+  message->Release ();
+  return ret;
+}
+
 /* The main Invoke function. The return value of this
    function does not appear to have any effect on outlook
    although I have read in an example somewhere that you
@@ -262,9 +297,9 @@ EVENT_SINK_INVOKE(MailItemEvents)
                         SRCNAME, __func__);
              break;
            }
-          if (m_crypt_successful)
+          if (!needs_crypto (m_object) || m_crypt_successful)
             {
-               log_debug ("%s:%s: Message %p sucessfully encrypted. May go.",
+               log_debug ("%s:%s: Passing send event for message %p.",
                           SRCNAME, __func__, m_object);
                m_send_seen = false;
                break;
@@ -317,7 +352,7 @@ EVENT_SINK_INVOKE(MailItemEvents)
           if (m_send_seen)
             {
               m_send_seen = false;
-              m_crypt_successful = !sign_encrypt_item (m_object);
+              m_crypt_successful = !do_crypto_on_item (m_object);
               if (m_crypt_successful)
                 {
                   /* We can't trigger a Send event in the current state.
diff --git a/src/mapihelp.cpp b/src/mapihelp.cpp
index 81b3fd2..049f784 100644
--- a/src/mapihelp.cpp
+++ b/src/mapihelp.cpp
@@ -2638,6 +2638,49 @@ mapi_get_mime_info (LPMESSAGE msg)
 }
 
 
+/* Helper around mapi_get_gpgol_draft_info to avoid
+   the string handling.
+   Return values are:
+   0 -> Do nothing
+   1 -> Encrypt
+   2 -> Sign
+   3 -> Encrypt & Sign*/
+int
+get_gpgol_draft_info_flags (LPMESSAGE message)
+{
+  char *buf = mapi_get_gpgol_draft_info (message);
+  int ret = 0;
+  if (!buf)
+    {
+      return 0;
+    }
+  if (buf[0] == 'E')
+    {
+      ret |= 1;
+    }
+  if (buf[1] == 'S')
+    {
+      ret |= 2;
+    }
+  xfree (buf);
+  return ret;
+}
+
+/* Sets the draft info flags. Protocol is always Auto.
+   flags should be the same as defined by
+   get_gpgol_draft_info_flags
+*/
+int
+set_gpgol_draft_info_flags (LPMESSAGE message, int flags)
+{
+  char buf[4];
+  buf[3] = '\0';
+  buf[2] = 'A'; /* Protocol */
+  buf[1] = flags & 2 ? 'S' : 's';
+  buf[0] = flags & 1 ? 'E' : 'e';
+
+  return mapi_set_gpgol_draft_info (message, buf);
+}
 
 
 /* Helper for mapi_get_msg_content_type() */
diff --git a/src/mapihelp.h b/src/mapihelp.h
index 8173b94..a154d95 100644
--- a/src/mapihelp.h
+++ b/src/mapihelp.h
@@ -172,6 +172,10 @@ int   mapi_delete_gpgol_body_attachment (LPMESSAGE message);
 int   mapi_attachment_to_body (LPMESSAGE message, mapi_attach_item_t *item);
 
 attachtype_t get_gpgolattachtype (LPATTACH obj, ULONG tag);
+
+int get_gpgol_draft_info_flags (LPMESSAGE message);
+
+int set_gpgol_draft_info_flags (LPMESSAGE message, int flags);
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/ribbon-callbacks.cpp b/src/ribbon-callbacks.cpp
index eef0b2a..cd5c4c8 100644
--- a/src/ribbon-callbacks.cpp
+++ b/src/ribbon-callbacks.cpp
@@ -1231,3 +1231,95 @@ HRESULT verifyBody (LPDISPATCH ctrl)
 {
   return do_reader_action (ctrl, DATA_BODY | OP_VERIFY);
 }
+
+static void
+message_flag_status (HWND window, int flags)
+{
+  const char * message;
+  if (flags & OP_ENCRYPT && flags & OP_SIGN)
+    {
+      message = _("The message will be signed & encrypted.");
+    }
+  else if (flags & OP_ENCRYPT)
+    {
+      message = _("The message will be encrypted.");
+    }
+  else if (flags & OP_SIGN)
+    {
+      message = _("The message will be signed.");
+    }
+  else
+    {
+      message = _("The message will be sent plain and without a signature.");
+    }
+  MessageBox (NULL,
+              message,
+              _("GpgOL"),
+              MB_ICONINFORMATION|MB_OK);
+}
+
+static HRESULT
+mark_mime_action (LPDISPATCH ctrl, int flags)
+{
+  HRESULT hr;
+  HRESULT rc = E_FAIL;
+  HWND cur_window;
+  LPDISPATCH context = NULL,
+             mailitem = NULL;
+  LPMESSAGE message = NULL;
+  int oldflags,
+      newflags;
+
+  log_debug ("%s:%s: enter", SRCNAME, __func__);
+  hr = getContext (ctrl, &context);
+  if (FAILED(hr))
+      return hr;
+  cur_window = get_oom_context_window (context);
+
+  mailitem = get_oom_object (context, "CurrentItem");
+
+  if (!mailitem)
+    {
+      log_error ("%s:%s: Failed to get mailitem.",
+                 SRCNAME, __func__);
+      goto done;
+    }
+
+  message = get_oom_message (mailitem);
+
+  if (!message)
+    {
+      log_error ("%s:%s: Failed to get message.",
+                 SRCNAME, __func__);
+      goto done;
+    }
+
+  oldflags = get_gpgol_draft_info_flags (message);
+
+  newflags = oldflags xor flags;
+
+  if (set_gpgol_draft_info_flags (message, newflags))
+    {
+      log_error ("%s:%s: Failed to set draft flags.",
+                 SRCNAME, __func__);
+    }
+
+  message_flag_status (cur_window, newflags);
+
+done:
+  RELDISP (context);
+  RELDISP (mailitem);
+  RELDISP (message);
+
+  return rc;
+}
+
+HRESULT mime_sign (LPDISPATCH ctrl)
+{
+  return mark_mime_action (ctrl, OP_SIGN);
+}
+
+HRESULT mime_encrypt (LPDISPATCH ctrl)
+{
+  return mark_mime_action (ctrl, OP_ENCRYPT);
+}
diff --git a/src/ribbon-callbacks.h b/src/ribbon-callbacks.h
index 0f46af4..8c4762d 100644
--- a/src/ribbon-callbacks.h
+++ b/src/ribbon-callbacks.h
@@ -36,6 +36,8 @@
 #define ID_CMD_SIGN_BODY        10
 #define ID_CMD_ATT_ENC_FILE     11
 #define ID_CMD_VERIFY_BODY      12
+#define ID_CMD_MIME_SIGN        13
+#define ID_CMD_MIME_ENCRYPT     14
 
 #define ID_BTN_CERTMANAGER       IDI_KEY_MANAGER_64_PNG
 #define ID_BTN_DECRYPT           IDI_DECRYPT_16_PNG
@@ -57,4 +59,9 @@ HRESULT getIcon (int id, VARIANT* result);
 HRESULT startCertManager (LPDISPATCH ctrl);
 HRESULT signBody (LPDISPATCH ctrl);
 HRESULT verifyBody (LPDISPATCH ctrl);
+
+/* Mark the mail to be mime encrypted on send. */
+HRESULT mime_encrypt (LPDISPATCH ctrl);
+/* Mark the mail to be mime signed on send. */
+HRESULT mime_sign (LPDISPATCH ctrl);
 #endif

-----------------------------------------------------------------------

Summary of changes:
 src/gpgoladdin.cpp       | 331 ++++++++++-------------------------------------
 src/mailitem-events.cpp  |  57 ++++++--
 src/mapihelp.cpp         |  43 ++++++
 src/mapihelp.h           |   4 +
 src/ribbon-callbacks.cpp |  92 +++++++++++++
 src/ribbon-callbacks.h   |   7 +
 6 files changed, 257 insertions(+), 277 deletions(-)


hooks/post-receive
-- 
GnuPG extension for MS Outlook
http://git.gnupg.org




More information about the Gnupg-commits mailing list