[git] GpgOL - branch, nomapi, updated. gpgol-1.4.0-121-g2b376a4

by Andre Heinecke cvs at cvs.gnupg.org
Thu Oct 27 17:52:17 CEST 2016


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, nomapi has been updated
       via  2b376a48241aaef927ab1ffd6e7d213480d6751e (commit)
       via  2ff3d5e90c146c4056ab9b2c38c0157caa92b7ff (commit)
       via  09284b0ab35a701c078147c2f6c2fb017c96cbfb (commit)
      from  a20666844db52b53ea082934a304e7e90f687acc (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 2b376a48241aaef927ab1ffd6e7d213480d6751e
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Oct 27 17:48:06 2016 +0200

    Implement encryption without MAPI data
    
    * src/attachment.cpp (Attachment::get_data_string): New helper.
    * src/attachment.h: Declare get_data_string.
    * src/mail.cpp, src/mail.h (Mail::remove_attachments)
    (Mail::add_attachments, get_string, Mail::get_body)
    (Mail::get_html_body, Mail::get_recipients): New.
    * src/mailitem-events.cpp (request_send): Comment out for now.
    (EVENT_SINK_INVOKE): Encrypt in send event.
    * src/mimemaker.cpp (sink_data_write): New to work with GpgME::Data.
    (encrypt_sign_mail): New works based on Objects.
    
    --
    This still uses the engine style encryption. In this first impl
    only encryption is supported. Can do both inline and MIME.

diff --git a/src/attachment.cpp b/src/attachment.cpp
index fc528c7..dc9d633 100644
--- a/src/attachment.cpp
+++ b/src/attachment.cpp
@@ -56,3 +56,21 @@ Attachment::get_data()
 {
   return m_data;
 }
+
+const std::string &
+Attachment::get_data_string()
+{
+  if (!m_data_string.empty())
+    {
+      return m_data_string;
+    }
+  char buf[4096];
+  m_data.seek (0, SEEK_SET);
+  size_t nread;
+  m_data_string = std::string();
+  while ((nread = m_data.read (buf, 4096)) > 0)
+    {
+      m_data_string += std::string(buf, nread);
+    }
+  return m_data_string;
+}
diff --git a/src/attachment.h b/src/attachment.h
index 47c536e..af45e75 100644
--- a/src/attachment.h
+++ b/src/attachment.h
@@ -41,10 +41,16 @@ public:
   /* get the underlying data structure */
   GpgME::Data& get_data();
 
+  /* get the data as string. resets the seek pointer
+     of data. The string data is cached after this
+     function is called once. */
+  const std::string & get_data_string();
+
 private:
   GpgME::Data m_data;
   std::string m_utf8DisplayName;
   attachtype_t m_type;
+  std::string m_data_string;
 };
 
 #endif // ATTACHMENT_H
diff --git a/src/mail.cpp b/src/mail.cpp
index a3c54e9..b6a3cf8 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -34,6 +34,7 @@
 #include "gpgolstr.h"
 #include "windowmessages.h"
 #include "mlang-charset.h"
+#include "mimemaker.h"
 
 #include <gpgme++/tofuinfo.h>
 #include <gpgme++/verificationresult.h>
@@ -417,11 +418,52 @@ copy_attachment_to_file (std::shared_ptr<Attachment> att, HANDLE hFile)
   return 0;
 }
 
-/** Helper to update the attachments of a mail object in oom.
+int
+Mail::remove_attachments()
+{
+  LPDISPATCH attachments = get_oom_object (m_mailitem, "Attachments");
+  if (!attachments)
+    {
+      log_debug ("%s:%s: Failed to get attachments.",
+                 SRCNAME, __func__);
+      return 0;
+    }
+
+  int count = get_oom_int (attachments, "Count");
+  if (count < 1)
+    {
+      gpgol_release (attachments);
+      return 0;
+    }
+  for (int i = 1; i <= count; i++)
+    {
+      VARIANT aVariant[1];
+      DISPPARAMS dispparams;
+
+      dispparams.rgvarg = aVariant;
+      dispparams.rgvarg[0].vt = VT_INT;
+      dispparams.rgvarg[0].intVal = i;
+      dispparams.cArgs = 1;
+      dispparams.cNamedArgs = 0;
+
+      if (invoke_oom_method_with_parms (attachments, "Remove",
+                                        NULL, &dispparams))
+        {
+          log_error ("%s:%s: Failed to remove attachments.",
+                     SRCNAME, __func__);
+          gpgol_release (attachments);
+          return 1;
+        }
+    }
+  gpgol_release (attachments);
+
+  return 0;
+}
+
+/** Update the attachments of a mail object in oom.
   does not modify the underlying mapi structure. */
-static int
-add_attachments(LPDISPATCH mail,
-                std::vector<std::shared_ptr<Attachment> > attachments)
+int
+Mail::add_attachments(std::vector<std::shared_ptr<Attachment> > attachments)
 {
   int err = 0;
   for (auto att: attachments)
@@ -436,7 +478,7 @@ add_attachments(LPDISPATCH mail,
                      SRCNAME, __func__, att->get_display_name().c_str());
           err = 1;
         }
-      if (add_oom_attachment (mail, wchar_file, wchar_name))
+      if (add_oom_attachment (m_mailitem, wchar_file, wchar_name))
         {
           log_error ("%s:%s: Failed to add attachment: %s",
                      SRCNAME, __func__, att->get_display_name().c_str());
@@ -601,7 +643,7 @@ Mail::parsing_done()
   TRACEPOINT;
 
   /* Update attachments */
-  if (add_attachments (m_mailitem, m_parser->get_attachments()))
+  if (add_attachments (m_parser->get_attachments()))
     {
       log_error ("%s:%s: Failed to update attachments.",
                  SRCNAME, __func__);
@@ -634,28 +676,8 @@ Mail::encrypt_sign ()
       return err;
     }
   flags = get_gpgol_draft_info_flags (message);
-  if (flags == 3)
-    {
-      log_debug ("%s:%s: Sign / Encrypting message",
-                 SRCNAME, __func__);
-      err = message_sign_encrypt (message, proto,
-                                  NULL, get_sender ());
-    }
-  else if (flags == 2)
-    {
-      err = message_sign (message, proto,
-                          NULL, get_sender ());
-    }
-  else if (flags == 1)
-    {
-      err = message_encrypt (message, proto,
-                             NULL, get_sender ());
-    }
-  else
-    {
-      log_debug ("%s:%s: Unknown flags for crypto: %i",
-                 SRCNAME, __func__, flags);
-    }
+  err = encrypt_sign_mail (this, (flags & 1), (flags & 2), proto,
+                           NULL);
   log_debug ("%s:%s: Status: %i",
              SRCNAME, __func__, err);
   gpgol_release (message);
@@ -768,6 +790,7 @@ int
 Mail::revert_all_mails ()
 {
   int err = 0;
+#if 0
   std::map<LPDISPATCH, Mail *>::iterator it;
   for (it = g_mail_map.begin(); it != g_mail_map.end(); ++it)
     {
@@ -785,6 +808,7 @@ Mail::revert_all_mails ()
           continue;
         }
     }
+#endif
   return err;
 }
 
@@ -873,10 +897,45 @@ Mail::is_smime ()
   return m_is_smime;
 }
 
+static std::string
+get_string (LPDISPATCH item, const char *str)
+{
+  char *buf = get_oom_string (item, str);
+  if (!buf)
+    return std::string();
+  std::string ret = buf;
+  xfree (buf);
+  return ret;
+}
+
 std::string
-Mail::get_subject()
+Mail::get_subject() const
 {
-  return std::string(get_oom_string (m_mailitem, "Subject"));
+  return get_string (m_mailitem, "Subject");
+}
+
+std::string
+Mail::get_body() const
+{
+  return get_string (m_mailitem, "Body");
+}
+
+std::string
+Mail::get_html_body() const
+{
+  return get_string (m_mailitem, "HTMLBody");
+}
+
+char **
+Mail::get_recipients() const
+{
+  LPDISPATCH recipients = get_oom_object (m_mailitem, "Recipients");
+  if (!recipients)
+    {
+      TRACEPOINT;
+      return nullptr;
+    }
+  return get_oom_recipients (recipients);
 }
 
 int
diff --git a/src/mail.h b/src/mail.h
index 83c10ab..9b28f05 100644
--- a/src/mail.h
+++ b/src/mail.h
@@ -31,6 +31,7 @@
 #include <future>
 
 class ParseController;
+class Attachment;
 
 /** @brief Data wrapper around a mailitem.
  *
@@ -163,7 +164,7 @@ public:
   /** @brief get the subject string (UTF-8 encoded).
     *
     * @returns the subject or an empty string. */
-  std::string get_subject ();
+  std::string get_subject () const;
 
   /** @brief Is this a crypto mail handled by gpgol.
   *
@@ -243,6 +244,23 @@ public:
   /** Remove all categories of this mail */
   void remove_categories ();
 
+  /** Get the body of the mail */
+  std::string get_body () const;
+
+  /** Get the html of the mail */
+  std::string get_html_body () const;
+
+  /** Get the recipients recipients is a null
+      terminated array of strings. Needs to be freed
+      by the caller. */
+  char ** get_recipients () const;
+
+  /** Add attachments to this mail returns 0 on success */
+  int add_attachments (std::vector <std::shared_ptr <Attachment> >attachments);
+
+  /** Remove all attachments of this mail. returns 0 on success. */
+  int remove_attachments ();
+
 private:
   void update_categories ();
   void update_body ();
diff --git a/src/mailitem-events.cpp b/src/mailitem-events.cpp
index e4442cc..446e616 100644
--- a/src/mailitem-events.cpp
+++ b/src/mailitem-events.cpp
@@ -95,6 +95,7 @@ MailItemEvents::~MailItemEvents()
     gpgol_release (m_object);
 }
 
+/*
 static DWORD WINAPI
 request_send (LPVOID arg)
 {
@@ -110,6 +111,7 @@ request_send (LPVOID arg)
     }
   return 0;
 }
+*/
 
 static DWORD WINAPI
 request_decrypt (LPVOID arg)
@@ -253,19 +255,18 @@ EVENT_SINK_INVOKE(MailItemEvents)
                         SRCNAME, __func__);
              break;
            }
+          m_mail->update_sender ();
+          m_mail->encrypt_sign ();
           if (m_mail->crypto_successful ())
             {
                log_debug ("%s:%s: Passing send event for message %p.",
                           SRCNAME, __func__, m_object);
-               m_send_seen = false;
                break;
             }
-          m_mail->update_sender ();
-          m_send_seen = true;
-          log_debug ("%s:%s: Message %p cancelling send to let us do crypto.",
+          log_debug ("%s:%s: Message %p cancelling send because crypto failed.",
                      SRCNAME, __func__, m_object);
           *(parms->rgvarg[0].pboolVal) = VARIANT_TRUE;
-          invoke_oom_method (m_object, "Save", NULL);
+          //invoke_oom_method (m_object, "Save", NULL);
 
           return S_OK;
         }
@@ -312,27 +313,12 @@ EVENT_SINK_INVOKE(MailItemEvents)
         }
       case AfterWrite:
         {
-          if (m_send_seen)
-            {
-              m_send_seen = false;
-              m_mail->encrypt_sign ();
-              if (m_mail->crypto_successful ())
-                {
-                  /* We can't trigger a Send event in the current state.
-                     Appearently Outlook locks some methods in some events.
-                     So we Create a new thread that will sleep a bit before
-                     it requests to send the item again. */
-                  HANDLE thread = CreateThread (NULL, 0, request_send,
-                                                (LPVOID) m_object, 0, NULL);
-                  CloseHandle (thread);
-                }
-              return S_OK;
-            }
-          else if (m_decrypt_after_write)
+          if (m_decrypt_after_write)
             {
               char *uuid = strdup (m_mail->get_uuid ().c_str());
               HANDLE thread = CreateThread (NULL, 0, request_decrypt,
                                             (LPVOID) uuid, 0, NULL);
+              log_debug ("Requesting decrypt again for uuid: %s", uuid);
               CloseHandle (thread);
             }
           break;
diff --git a/src/mimemaker.cpp b/src/mimemaker.cpp
index 56c9d9a..58934e6 100644
--- a/src/mimemaker.cpp
+++ b/src/mimemaker.cpp
@@ -42,6 +42,8 @@
 #include "mimemaker.h"
 #include "oomhelp.h"
 #include "gpgolstr.h"
+#include "mail.h"
+#include "attachment.h"
 
 static const unsigned char oid_mimetag[] =
     {0x2A, 0x86, 0x48, 0x86, 0xf7, 0x14, 0x03, 0x0a, 0x04};
@@ -116,6 +118,27 @@ sink_file_write (sink_t sink, const void *data, size_t datalen)
   return 0;
 }
 
+/* Write method used with a sink_t object that contains a GpgME::Data object.  */
+int
+sink_data_write (sink_t sink, const void *data, size_t datalen)
+{
+  auto d = static_cast<GpgME::Data*>(sink->cb_data);
+
+  if (!d)
+    {
+      log_error ("%s:%s: sink not setup for writing", SRCNAME, __func__);
+      return -1;
+    }
+  if (!data)
+    return 0;  /* Flush - nothing to do here.  */
+
+  if (d->write(data, datalen) != datalen)
+    {
+      log_error ("%s:%s: Failed to write data", SRCNAME, __func__);
+      return -1;
+    }
+  return 0;
+}
 
 /* Make sure that PROTOCOL is usable or return a suitable protocol.
    On error PROTOCOL_UNKNOWN is returned.  */
@@ -2099,3 +2122,209 @@ done:
   xfree (orig);
   return err;
 }
+
+
+int
+encrypt_sign_mail (Mail *mail, bool encrypt, bool sign, protocol_t protocol,
+                   HWND hwnd)
+{
+  if (!mail || (!encrypt && !sign))
+    {
+      TRACEPOINT;
+      return 1;
+    }
+
+  const auto body = mail->get_body();
+  /* TODO get attachments here, too */
+  if (body.empty())
+    {
+      log_debug ("%s:%s: No body",
+                 SRCNAME, __func__);
+      return 1;
+    }
+
+  /* Crate an attachment as container for the data. */
+  auto attach = std::shared_ptr<Attachment> (new Attachment());
+
+  //struct sink_s tmpsinkmem;
+  //sink_t tmpsink = &tmpsinkmem;
+
+  struct sink_s sinkmem;
+  sink_t sink = &sinkmem;
+  memset (sink, 0, sizeof *sink);
+  sink->cb_data = &(attach->get_data ());
+  sink->writefnc = sink_data_write;
+
+
+  /* Prepare the engine.  We do this early as it is quite common
+     that some recipients are not available and thus the encryption
+     will fail early.  This is also required to allow the UIserver to
+     figure out the protocol to use if we have not forced one.  */
+  engine_filter_t filter = NULL;
+  if (engine_create_filter (&filter, write_buffer_for_cb, sink))
+    {
+      log_debug ("%s:%s: Failed to create filter",
+                 SRCNAME, __func__);
+      return 1;
+    }
+
+  /* Session number */
+  int session_number = engine_new_session_number ();
+  engine_set_session_number (filter, session_number);
+
+  /* Set the subject for the dialog */
+  std::string subject = mail->get_subject();
+  engine_set_session_title (filter, mail->get_subject().c_str());
+
+  const char *sender = mail->get_sender();
+
+  struct sink_s encsinkmem;
+  sink_t encsink = &encsinkmem;
+  memset (encsink, 0, sizeof *encsink);
+  encsink->cb_data = filter;
+  encsink->writefnc = sink_encryption_write;
+
+  if (encrypt)
+    {
+      const auto recipients = mail->get_recipients();
+      int rc = engine_encrypt_prepare (filter, hwnd, protocol,
+                                  sign ? ENGINE_FLAG_SIGN_FOLLOWS : 0,
+                                  sender, recipients, &protocol);
+      for (int i = 0; recipients && recipients[i]; i++)
+        xfree (recipients[i]);
+      xfree (recipients);
+      if (rc)
+        {
+          log_error ("%s:%s: Failed to prepare encrypt",
+                     SRCNAME, __func__);
+          if (recipients)
+            {
+            }
+          return 1;
+        }
+      if (engine_encrypt_start (filter, 0))
+        {
+          log_error ("%s:%s: Failed to start encrypt",
+                     SRCNAME, __func__);
+          return 1;
+        }
+    }
+
+  /* Check the selected protocol */
+  protocol = check_protocol (protocol);
+  if (protocol == PROTOCOL_UNKNOWN)
+    {
+      log_error ("%s:%s: Protocol unkown",
+                 SRCNAME, __func__);
+      return 1;
+    }
+
+  int n_att_usable = 0;
+  bool inline_pgp = opt.inline_pgp && !n_att_usable;
+
+  /* Write the top header.  */
+  char boundary[BOUNDARYSIZE+1];
+  if (!inline_pgp && create_top_encryption_header (sink, protocol, boundary))
+    {
+      log_error ("%s:%s: Failed to write top header",
+                 SRCNAME, __func__);
+      return 1;
+    }
+
+  char inner_boundary[BOUNDARYSIZE+1];
+  if (!inline_pgp && ((body.size() && n_att_usable) || n_att_usable > 1))
+    {
+      /* A body and at least one attachment or more than one attachment  */
+      generate_boundary (inner_boundary);
+      if (write_multistring (encsink,
+                             "Content-Type: multipart/mixed;\r\n",
+                             "\tboundary=\"", inner_boundary, "\"\r\n",
+                             NULL))
+        {
+          log_error ("%s:%s: Failed to write boundary",
+                     SRCNAME, __func__);
+          return 1;
+        }
+    }
+  else
+    {
+      /* Only one part */
+      *inner_boundary = 0;
+    }
+
+  TRACEPOINT;
+  if (!body.empty())
+    {
+      if (write_part (encsink, body.c_str(), body.size(),
+                      *inner_boundary ? inner_boundary : NULL, NULL, 1))
+        {
+          log_error ("%s:%s: Failed to write body",
+                     SRCNAME, __func__);
+          return 1;
+        }
+    }
+
+  // TODO attachments
+  /* Finish the possible multipart/mixed. */
+  if (!inline_pgp && *inner_boundary &&
+      write_boundary (encsink, inner_boundary, 1))
+    {
+      log_error ("%s:%s: Failed to write boundary",
+                 SRCNAME, __func__);
+      return 1;
+    }
+
+  /* Flush the sink and wait for the encryption to get
+     ready.  */
+  if (write_buffer (encsink, NULL, 0))
+    {
+      log_error ("%s:%s: Failed to flush tmpsink",
+                 SRCNAME, __func__);
+      return 1;
+    }
+
+  log_debug ("%s:%s: Waiting for crypto",
+             SRCNAME, __func__);
+  if (engine_wait (filter))
+    {
+      log_error ("%s:%s: Failed to wait for engine",
+                 SRCNAME, __func__);
+      return 1;
+    }
+  log_debug ("%s:%s: Wait done",
+             SRCNAME, __func__);
+
+  if (inline_pgp)
+    {
+      return put_oom_string (mail->item (), "Body",
+                             attach->get_data_string ().c_str ());
+    }
+  if (put_oom_string (mail->item (), "Body", ""))
+    {
+      log_error ("%s:%s: Failed to update body",
+                 SRCNAME, __func__);
+      return 1;
+    }
+  if (mail->remove_attachments ())
+    {
+      log_error ("%s:%s: Failed to remove attachments",
+                 SRCNAME, __func__);
+      return 1;
+    }
+  attach->set_display_name("gpgol.dat");
+  std::vector<std::shared_ptr <Attachment> > attachments;
+  attachments.push_back (attach);
+  if (mail->add_attachments (attachments))
+    {
+      log_error ("%s:%s: Failed to add attachments",
+                 SRCNAME, __func__);
+      return 1;
+    }
+  if (put_oom_string (mail->item(), "MessageClass", "IPM.Note.SMIME.MultipartSigned"))
+    {
+      log_error ("%s:%s: Failed to change message class",
+                 SRCNAME, __func__);
+      return 1;
+    }
+  return 0;
+}
diff --git a/src/mimemaker.h b/src/mimemaker.h
index f483120..c2ce42b 100644
--- a/src/mimemaker.h
+++ b/src/mimemaker.h
@@ -69,5 +69,9 @@ int restore_msg_from_moss (LPMESSAGE message, LPDISPATCH moss_att,
 
 #ifdef __cplusplus
 }
+
+class Mail;
+int encrypt_sign_mail (Mail *, bool encrypt, bool sign, protocol_t protocol,
+                       HWND hwnd);
 #endif
 #endif /*MIMEMAKER_H*/

commit 2ff3d5e90c146c4056ab9b2c38c0157caa92b7ff
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Oct 27 17:42:03 2016 +0200

    Add options for inline pgp and recpt. autoresolve
    
    * src/addin-options.cpp (set_labels)
    (enable_disable_opts, options_window_proc): Handle
    new checkboxes.
    * src/common_indep.h: Extend opts.
    * src/main.c: Load / Save opts.
    * src/dialogs.rc: Update Layout.
    * src/dialogs.h: Add new ID's
    
    --
    Recipient autoresolution is something for the future. Mostly
    inline-pgp needed now.

diff --git a/src/addin-options.cpp b/src/addin-options.cpp
index 365a7f8..2e9ac64 100644
--- a/src/addin-options.cpp
+++ b/src/addin-options.cpp
@@ -42,6 +42,10 @@ set_labels (HWND dlg)
     { IDC_G_SEND,           N_("Message sending")},
     { IDC_ENCRYPT_DEFAULT,  N_("&Encrypt new messages by default")},
     { IDC_SIGN_DEFAULT,     N_("&Sign new messages by default")},
+    { IDC_INLINE_PGP,       N_("&Send OpenPGP mails without "
+                               "attachments as inline-pgp")},
+    { IDC_AUTORRESOLVE,     N_("&Select certificates automatically (OpenPGP only)")},
+
 
     { IDC_GPG_OPTIONS,      N_("Debug...")},
     { IDC_GPG_CONF,         N_("Configure GnuPG")},
@@ -62,6 +66,12 @@ enable_disable_opts (HWND hDlg)
   BOOL enable = opt.mime_ui ? TRUE : FALSE;
   EnableWindow (GetDlgItem (hDlg, IDC_ENCRYPT_DEFAULT), enable);
   EnableWindow (GetDlgItem (hDlg, IDC_SIGN_DEFAULT), enable);
+  char *uiserver = get_uiserver_name ();
+  if (!uiserver && !opt.enable_smime)
+    {
+      EnableWindow (GetDlgItem (hDlg, IDC_AUTORRESOLVE), FALSE);
+    }
+  xfree (uiserver);
 }
 
 static INT_PTR CALLBACK
@@ -82,6 +92,10 @@ options_window_proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
           SendDlgItemMessage (hDlg, IDC_MIME_UI, BM_SETCHECK,
                               !!opt.mime_ui, 0L);
 #endif
+          SendDlgItemMessage (hDlg, IDC_INLINE_PGP, BM_SETCHECK,
+                              !!opt.inline_pgp, 0L);
+          SendDlgItemMessage (hDlg, IDC_AUTORRESOLVE, BM_SETCHECK,
+                              !!opt.autoresolve, 0L);
           enable_disable_opts (hDlg);
           set_labels (hDlg);
           ShowWindow (GetDlgItem (hDlg, IDC_GPG_OPTIONS),
@@ -116,6 +130,12 @@ options_window_proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
                                 MB_ICONINFORMATION|MB_OK);
                   }
 #endif
+                opt.inline_pgp = !!SendDlgItemMessage
+                  (hDlg, IDC_INLINE_PGP, BM_GETCHECK, 0, 0L);
+
+                opt.autoresolve = !!SendDlgItemMessage
+                  (hDlg, IDC_AUTORRESOLVE, BM_GETCHECK, 0, 0L);
+
                 write_options ();
                 EndDialog (hDlg, TRUE);
                 break;
diff --git a/src/common_indep.h b/src/common_indep.h
index 57b7888..b1dcb4c 100644
--- a/src/common_indep.h
+++ b/src/common_indep.h
@@ -192,6 +192,8 @@ struct
   int prefer_html;           /* Prefer html in html/text alternatives. */
   int body_as_attachment;    /* Present encrypted message as attachment.  */
   int mime_ui;               /* Only for Addin. Use the PGP/MIME ui */
+  int inline_pgp;            /* Only for Addin. Use Inline PGP by default. */
+  int autoresolve;           /* Autresolve keys with --locate-keys. */
 
   /* The compatibility flags. */
   struct
diff --git a/src/dialogs.h b/src/dialogs.h
index 34da890..daf8873 100644
--- a/src/dialogs.h
+++ b/src/dialogs.h
@@ -102,6 +102,8 @@
 #define IDC_GPG4WIN_STRING              0x5131
 #define IDC_START_CERTMAN               0x5132
 #define IDC_MIME_UI                     0x5133
+#define IDC_INLINE_PGP                  0x5134
+#define IDC_AUTORRESOLVE                0x5135
 
 /* Ids for PNG Images */
 #define IDI_ENCRYPT_16_PNG              0x6000
diff --git a/src/dialogs.rc b/src/dialogs.rc
index d1d4abc..50b3ec3 100644
--- a/src/dialogs.rc
+++ b/src/dialogs.rc
@@ -297,7 +297,7 @@ BEGIN
                     198, 96, 50, 14
 END
 
-IDD_ADDIN_OPTIONS DIALOGEX DISCARDABLE  300, 300, 266, 150
+IDD_ADDIN_OPTIONS DIALOGEX DISCARDABLE  300, 300, 266, 170
 STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_SHELLFONT | DS_SETFONT
 CAPTION "GpgOL"
 FONT 8, "MS Shell Dlg"
@@ -321,7 +321,7 @@ BEGIN
 
     /* Send options box.  */
     GROUPBOX        "send-options", IDC_G_SEND,
-                    9, 50, 250, 38
+                    9, 50, 250, 60
 
     CONTROL         "encrypt-by-default", IDC_ENCRYPT_DEFAULT,
                     "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
@@ -331,19 +331,27 @@ BEGIN
                     "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
                     24, 71, 215, 10
 
+    CONTROL         "inline-pgp", IDC_INLINE_PGP,
+                    "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+                    24, 82, 215, 10
+
+    CONTROL         "autoresolve", IDC_AUTORRESOLVE,
+                    "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+                    24, 82, 215, 10
+
     /* Stuff at the lower left corner.  */
     LTEXT           "GpgOL by Gpg4win", IDC_GPG4WIN_STRING,
-                      8, 124, 100, 8
+                      8, 144, 100, 8
     LTEXT           "Version x ", IDC_VERSION_INFO,
-                      8, 135, 100, 9
+                      8, 155, 100, 9
 
     PUSHBUTTON      "advanced", IDC_GPG_OPTIONS,
-                    180, 100, 70, 14
+                    180, 120, 70, 14
 
     PUSHBUTTON      "gpgconf", IDC_GPG_CONF,
-                    180, 115, 70, 14
+                    180, 135, 70, 14
 
     DEFPUSHBUTTON   "&OK", IDOK,
-                    180, 130, 70, 14
+                    180, 150, 70, 14
 
 END
diff --git a/src/main.c b/src/main.c
index 5d73a62..a580b11 100644
--- a/src/main.c
+++ b/src/main.c
@@ -393,6 +393,10 @@ read_options (void)
   opt.mime_ui = val == NULL || *val != '1'? 0 : 1;
   xfree (val); val = NULL;
 #endif
+
+  load_extension_value ("inlinePGP", &val);
+  opt.inline_pgp = val == NULL || *val != '1'? 0 : 1;
+  xfree (val); val = NULL;
   /* Note, that on purpose these flags are only Registry changeable.
      The format of the entry is a string of of "0" and "1" digits; see
      the switch below for a description. */
@@ -470,6 +474,7 @@ write_options (void)
     {"announceNumber",           1, opt.announce_number, NULL},
     {"bodyAsAttachment",         0, opt.body_as_attachment, NULL},
     {"mimeUI", MIME_UI_DEFAULT, opt.mime_ui, NULL},
+    {"inlinePGP",                0, opt.inline_pgp, NULL},
     {NULL, 0, 0, NULL}
   };
   char buf[32];

commit 09284b0ab35a701c078147c2f6c2fb017c96cbfb
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Wed Oct 26 13:43:17 2016 +0200

    Ensure that the moss attachment stays hidden
    
    * src/mapihelp.cpp (mapi_mark_or_create_moss_attach): Hide attachment.

diff --git a/src/mapihelp.cpp b/src/mapihelp.cpp
index 61768f2..d4407e4 100644
--- a/src/mapihelp.cpp
+++ b/src/mapihelp.cpp
@@ -3531,6 +3531,22 @@ mapi_mark_or_create_moss_attach (LPMESSAGE message, msgtype_t msgtype)
     {
       /* Found existing moss attachment */
       mapi_release_attach_table (table);
+      /* Remark to ensure that it is hidden. As our revert
+         code must unhide it so that it is not stored in winmail.dat
+         but used as the mosstmpl. */
+      mapi_attach_item_t *item = table - 1 + (part2 ? part2 : part1);
+      LPATTACH att;
+      if (message->OpenAttach (item->mapipos, NULL, MAPI_BEST_ACCESS, &att) != S_OK)
+        {
+          log_error ("%s:%s: can't open attachment at %d",
+                     SRCNAME, __func__, item->mapipos);
+          return -1;
+        }
+      if (!mapi_test_attach_hidden (att))
+        {
+          mapi_set_attach_hidden (att);
+        }
+      gpgol_release (att);
       if (part2)
         return part2;
       return part1;

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

Summary of changes:
 src/addin-options.cpp   |  20 +++++
 src/attachment.cpp      |  18 ++++
 src/attachment.h        |   6 ++
 src/common_indep.h      |   2 +
 src/dialogs.h           |   2 +
 src/dialogs.rc          |  22 +++--
 src/mail.cpp            | 119 ++++++++++++++++++-------
 src/mail.h              |  20 ++++-
 src/mailitem-events.cpp |  30 ++-----
 src/main.c              |   5 ++
 src/mapihelp.cpp        |  16 ++++
 src/mimemaker.cpp       | 229 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/mimemaker.h         |   4 +
 13 files changed, 433 insertions(+), 60 deletions(-)


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




More information about the Gnupg-commits mailing list