[git] GpgOL - branch, master, updated. gpgol-1.4.0-177-gc7c293a

by Andre Heinecke cvs at cvs.gnupg.org
Thu Nov 17 15:40:13 CET 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, master has been updated
       via  c7c293a1c69de961abf388664b2897b509d9a934 (commit)
       via  20995f156333c9cf3d8fe0703a685890f58c54d8 (commit)
       via  ecf4e2cca83970e9ddfe7dbd77cdf1b9d0bdd589 (commit)
       via  425e52bb2262c8edf96c37e60c706cfec2bbd3f5 (commit)
      from  7424fd0fcad08ce4de7492c28d5d1bec1060661d (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 c7c293a1c69de961abf388664b2897b509d9a934
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Nov 17 15:36:45 2016 +0100

    Start locate-keys when a recipient is added
    
    * src/mail.cpp (Mail::locate_keys): Check for recipient keys.
    (do_locate): New.
    (Mail::needs_crypto): Return flags.
    * src/mail.h: Update accordingly.
    * src/mailitem-events.cpp (EVENT_SINK_INVOKE): Handle recipient
    changes and do locate_keys if necessary.
    
    --
    Checked addresses are stored in a set so that they are not
    searched twice per session to avoid spammy requests.
    
    This feature is mostly useful for users of auto-key-locate
    where this can be used to retrieve keys from dane etc.

diff --git a/src/mail.cpp b/src/mail.cpp
index 8c5c478..03e3347 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -39,9 +39,12 @@
 #include <gpgme++/verificationresult.h>
 #include <gpgme++/decryptionresult.h>
 #include <gpgme++/key.h>
+#include <gpgme++/context.h>
+#include <gpgme++/keylistresult.h>
 #include <gpg-error.h>
 
 #include <map>
+#include <set>
 #include <vector>
 #include <memory>
 
@@ -53,6 +56,7 @@ using namespace GpgME;
 
 static std::map<LPDISPATCH, Mail*> g_mail_map;
 static std::map<std::string, Mail*> g_uid_map;
+static std::set<std::string> uids_searched;
 
 #define COPYBUFSIZE (8 * 1024)
 
@@ -716,7 +720,7 @@ Mail::encrypt_sign ()
   return err;
 }
 
-bool
+int
 Mail::needs_crypto ()
 {
   LPMESSAGE message = get_oom_message (m_mailitem);
@@ -1499,3 +1503,66 @@ Mail::get_sig_fpr() const
     }
   return m_sig.fingerprint();
 }
+
+
+static DWORD WINAPI
+do_locate (LPVOID arg)
+{
+  char *recipient = (char*) arg;
+  log_debug ("%s:%s searching key for recipient: \"%s\"",
+             SRCNAME, __func__, recipient);
+  Context *ctx = Context::createForProtocol (OpenPGP);
+
+  if (!ctx)
+    {
+      TRACEPOINT;
+      return 0;
+    }
+
+  ctx->setKeyListMode (GpgME::Extern | GpgME::Local);
+  ctx->startKeyListing (recipient, false);
+
+  std::vector<Key> keys;
+  Error err;
+  do {
+      keys.push_back (ctx->nextKey(err));
+    } while (!err);
+  keys.pop_back ();
+  ctx->endKeyListing ();
+  delete ctx;
+
+  if (keys.size ())
+    {
+      log_debug ("%s:%s found key for recipient: \"%s\"",
+                 SRCNAME, __func__, recipient);
+    }
+  xfree (recipient);
+  do_in_ui_thread (UNKNOWN, NULL);
+  return 0;
+}
+
+/** Try to locate the keys for all recipients */
+void Mail::locate_keys()
+{
+  char ** recipients = get_recipients ();
+
+  if (!recipients)
+    {
+      TRACEPOINT;
+      return;
+    }
+  for (int i = 0; recipients[i]; i++)
+    {
+      std::string recp = recipients[i];
+      if (uids_searched.find (recp) == uids_searched.end ())
+        {
+          uids_searched.insert (recp);
+          HANDLE thread = CreateThread (NULL, 0, do_locate,
+                                        (LPVOID) strdup(recipients[i]), 0,
+                                        NULL);
+          CloseHandle (thread);
+        }
+      xfree (recipients[i]);
+    }
+  xfree (recipients);
+}
diff --git a/src/mail.h b/src/mail.h
index 21ca885..b0d5c59 100644
--- a/src/mail.h
+++ b/src/mail.h
@@ -144,8 +144,13 @@ public:
   /** @brief Necessary crypto operations were completed successfully. */
   bool crypto_successful () { return !needs_crypto() || m_crypt_successful; }
 
-  /** @brief Message should be encrypted and or signed. */
-  bool needs_crypto ();
+  /** @brief Message should be encrypted and or signed.
+    0: No
+    1: Encrypt
+    2: Sign
+    3: Encrypt & Sign
+  */
+  int needs_crypto ();
 
   /** @brief wipe the plaintext from the message and encrypt attachments.
    *
@@ -274,6 +279,8 @@ public:
       call. */
   int close ();
 
+  /** Try to locate the keys for all recipients */
+  void locate_keys();
 private:
   void update_categories ();
   void update_body ();
diff --git a/src/mailitem-events.cpp b/src/mailitem-events.cpp
index 2eba0b8..d5e7ef4 100644
--- a/src/mailitem-events.cpp
+++ b/src/mailitem-events.cpp
@@ -230,11 +230,6 @@ EVENT_SINK_INVOKE(MailItemEvents)
         }
       case PropertyChange:
         {
-          const wchar_t *prop_name;
-          if (!m_mail->is_crypto_mail ())
-            {
-              break;
-            }
           if (!parms || parms->cArgs != 1 ||
               parms->rgvarg[0].vt != VT_BSTR ||
               !parms->rgvarg[0].bstrVal)
@@ -243,7 +238,24 @@ EVENT_SINK_INVOKE(MailItemEvents)
                          SRCNAME, __func__);
               break;
             }
-          prop_name = parms->rgvarg[0].bstrVal;
+          const wchar_t *prop_name = parms->rgvarg[0].bstrVal;
+          if (!m_mail->is_crypto_mail ())
+            {
+              if (!opt.autoresolve)
+                {
+                  break;
+                }
+              if (!wcscmp (prop_name, L"To") ||
+                  !wcscmp (prop_name, L"BCC") ||
+                  !wcscmp (prop_name, L"CC"))
+                {
+                  if ((m_mail->needs_crypto() & 1))
+                    {
+                      m_mail->locate_keys();
+                    }
+                }
+              break;
+            }
           for (const wchar_t **cur = prop_blacklist; *cur; cur++)
             {
               if (!wcscmp (prop_name, *cur))

commit 20995f156333c9cf3d8fe0703a685890f58c54d8
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Nov 17 15:34:07 2016 +0100

    Add autoresolve keys option for encryption
    
    * src/addin-options.cpp (set_labels): Improve wording.
    * src/dialogs.rc: Fix layout of autoresolve option.
    * src/main.c (read_options, write_options): Handle option.

diff --git a/src/addin-options.cpp b/src/addin-options.cpp
index 2e9ac64..d08b71a 100644
--- a/src/addin-options.cpp
+++ b/src/addin-options.cpp
@@ -44,7 +44,7 @@ set_labels (HWND dlg)
     { 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_AUTORRESOLVE,     N_("&Search for OpenPGP keys automatically when encrypting")},
 
 
     { IDC_GPG_OPTIONS,      N_("Debug...")},
diff --git a/src/dialogs.rc b/src/dialogs.rc
index 50b3ec3..359169d 100644
--- a/src/dialogs.rc
+++ b/src/dialogs.rc
@@ -337,7 +337,7 @@ BEGIN
 
     CONTROL         "autoresolve", IDC_AUTORRESOLVE,
                     "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
-                    24, 82, 215, 10
+                    24, 93, 215, 10
 
     /* Stuff at the lower left corner.  */
     LTEXT           "GpgOL by Gpg4win", IDC_GPG4WIN_STRING,
diff --git a/src/main.c b/src/main.c
index d862b57..d2e7122 100644
--- a/src/main.c
+++ b/src/main.c
@@ -418,6 +418,9 @@ read_options (void)
   load_extension_value ("inlinePGP", &val);
   opt.inline_pgp = val == NULL || *val != '1'? 0 : 1;
   xfree (val); val = NULL;
+  load_extension_value ("autoresolve", &val);
+  opt.autoresolve = 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. */
@@ -489,6 +492,7 @@ write_options (void)
     {"bodyAsAttachment",         0, opt.body_as_attachment, NULL},
     {"mimeUI", MIME_UI_DEFAULT, opt.mime_ui, NULL},
     {"inlinePGP",                0, opt.inline_pgp, NULL},
+    {"autoresolve",              0, opt.autoresolve, NULL},
     {NULL, 0, 0, NULL}
   };
   char buf[32];

commit ecf4e2cca83970e9ddfe7dbd77cdf1b9d0bdd589
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Nov 17 13:35:14 2016 +0100

    Sleep a bit in engine_wait
    
    * src/engine.c (engine_wait): Sleep in the busy wait loop.

diff --git a/src/engine.c b/src/engine.c
index a30408d..c96cb62 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -692,6 +692,8 @@ engine_wait (engine_filter_t filter)
       release_in_lock (filter, __func__);
       if (more)
         SwitchToThread ();
+      /* Let's not burn at 100% CPU please */
+      Sleep (100);
     }
   while (more);
 

commit 425e52bb2262c8edf96c37e60c706cfec2bbd3f5
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Nov 17 13:32:06 2016 +0100

    Fix minor memory leak in error condition
    
    * src/ommon_indep.c (qp_encode): Free outbuf on error.

diff --git a/src/common_indep.c b/src/common_indep.c
index 578169a..ba7b0ed 100644
--- a/src/common_indep.c
+++ b/src/common_indep.c
@@ -313,6 +313,7 @@ qp_encode (const char *input, size_t inlen, size_t *r_outlen)
         {
           log_error ("Quoted printable too long. Bug.");
           r_outlen = NULL;
+          xfree (outbuf);
           return NULL;
         }
     }

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

Summary of changes:
 src/addin-options.cpp   |  2 +-
 src/common_indep.c      |  1 +
 src/dialogs.rc          |  2 +-
 src/engine.c            |  2 ++
 src/mail.cpp            | 69 ++++++++++++++++++++++++++++++++++++++++++++++++-
 src/mail.h              | 11 ++++++--
 src/mailitem-events.cpp | 24 ++++++++++++-----
 src/main.c              |  4 +++
 8 files changed, 104 insertions(+), 11 deletions(-)


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




More information about the Gnupg-commits mailing list