[git] GpgOL - branch, master, updated. gpgol-2.0.6-6-g1536161

by Andre Heinecke cvs at cvs.gnupg.org
Mon Feb 12 14:57:41 CET 2018


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  153616194d2562c1aabda8b61d787d8f6cf5b3b6 (commit)
       via  cd8633c93a4f7f6f6b9668fcc9669beb9e47188b (commit)
       via  833c56e4f24674588b72fb9f3a958eba87ccdb62 (commit)
       via  c2572084cdb13a154e0e2bbc156155865b08c83e (commit)
      from  fb43d7dc2a4e7c6f822050eec0489248fe162af7 (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 153616194d2562c1aabda8b61d787d8f6cf5b3b6
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Feb 12 14:54:34 2018 +0100

    Use different offsets for windowmessages
    
    * src/windowmessages.cpp (gpgol_window_proc)
    (send_msg_to_ui_thread): Use WM_USER + 42
    * src/windowmessages.h: Start enum at 1100.
    
    --
    While a better fix might be to use a nonce to ensure
    that a message really originated from us I hope that this
    is enough for other software that globally sends out
    WM_USER messages.
    
    GnuPG-Bug-ID: T3769

diff --git a/src/windowmessages.cpp b/src/windowmessages.cpp
index da6ee34..5508d91 100644
--- a/src/windowmessages.cpp
+++ b/src/windowmessages.cpp
@@ -36,7 +36,7 @@ static HWND g_responder_window = NULL;
 LONG_PTR WINAPI
 gpgol_window_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
-  if (message == WM_USER + 1)
+  if (message == WM_USER + 42)
     {
       wm_ctx_t *ctx = (wm_ctx_t *) lParam;
       log_debug ("%s:%s: Recieved user msg: %i",
@@ -140,7 +140,7 @@ send_msg_to_ui_thread (wm_ctx_t *ctx)
                SRCNAME, __func__);
     return -1;
   }
-  SendMessage (responder, WM_USER + 1, 0, (LPARAM) ctx);
+  SendMessage (responder, WM_USER + 42, 0, (LPARAM) ctx);
   return 0;
 }
 
diff --git a/src/windowmessages.h b/src/windowmessages.h
index 584ff68..014c7d9 100644
--- a/src/windowmessages.h
+++ b/src/windowmessages.h
@@ -40,13 +40,13 @@
   */
 typedef enum _gpgol_wmsg_type
 {
-  UNKNOWN = 0,
-  INVALIDATE_UI = 1, /* The UI should be invalidated. */
-  PARSING_DONE = 2, /* A mail was parsed. Data should be a pointer
+  UNKNOWN = 1100, /* A large offset to avoid conflicts */
+  INVALIDATE_UI, /* The UI should be invalidated. */
+  PARSING_DONE, /* A mail was parsed. Data should be a pointer
                       to the mail object. */
-  RECIPIENT_ADDED = 3, /* A recipient was added. Data should be ptr
+  RECIPIENT_ADDED, /* A recipient was added. Data should be ptr
                           to mail */
-  CLOSE = 4, /* Send the message in the next event loop. */
+  CLOSE, /* Send the message in the next event loop. */
 } gpgol_wmsg_type;
 
 typedef struct

commit cd8633c93a4f7f6f6b9668fcc9669beb9e47188b
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Feb 12 14:52:40 2018 +0100

    Hold invalidation lock while parsing
    
    * src/mail.cpp (do_parsing): Hold invalidation lock.
    * src/windowmessages.h: Expose invalidation lock.
    * src/windowmessages.cpp: Define / initialize lock.
    
    --
    This should make it more robust to do the parsing without
    having the mail deleted under our hands because of invalidation
    wonkyness.
    
    GnuPG-Bug-Id: T3789

diff --git a/src/mail.cpp b/src/mail.cpp
index 27a0665..d86d995 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -696,6 +696,7 @@ do_parsing (LPVOID arg)
   gpgrt_lock_unlock (&dtor_lock);
 
   gpgrt_lock_lock (&parser_lock);
+  gpgrt_lock_lock (&invalidate_lock);
   /* We lock the parser here to avoid too many
      decryption attempts if there are
      multiple mailobjects which might have already
@@ -709,6 +710,7 @@ do_parsing (LPVOID arg)
     {
       log_debug ("%s:%s: cancel for: %p already deleted",
                  SRCNAME, __func__, arg);
+      gpgrt_lock_unlock (&invalidate_lock);
       gpgrt_lock_unlock (&parser_lock);
       return 0;
     }
@@ -717,11 +719,13 @@ do_parsing (LPVOID arg)
     {
       log_error ("%s:%s: no parser found for mail: %p",
                  SRCNAME, __func__, arg);
+      gpgrt_lock_unlock (&invalidate_lock);
       gpgrt_lock_unlock (&parser_lock);
       return -1;
     }
   parser->parse();
   do_in_ui_thread (PARSING_DONE, arg);
+  gpgrt_lock_unlock (&invalidate_lock);
   gpgrt_lock_unlock (&parser_lock);
   return 0;
 }
diff --git a/src/windowmessages.cpp b/src/windowmessages.cpp
index f44b9df..da6ee34 100644
--- a/src/windowmessages.cpp
+++ b/src/windowmessages.cpp
@@ -244,7 +244,8 @@ create_message_hook()
                            GetCurrentThreadId());
 }
 
-GPGRT_LOCK_DEFINE(invalidate_lock);
+gpgrt_lock_t invalidate_lock = GPGRT_LOCK_INITIALIZER;
+
 static bool invalidation_in_progress;
 
 DWORD WINAPI
@@ -261,7 +262,7 @@ delayed_invalidate_ui (LPVOID)
   /* We sleep here a bit to prevent invalidation immediately
      after the selection change before we have started processing
      the mail. */
-  Sleep (500);
+  Sleep (250);
   do_in_ui_thread (INVALIDATE_UI, nullptr);
   invalidation_in_progress = false;
   gpgrt_lock_unlock(&invalidate_lock);
diff --git a/src/windowmessages.h b/src/windowmessages.h
index f53ecd4..584ff68 100644
--- a/src/windowmessages.h
+++ b/src/windowmessages.h
@@ -22,6 +22,10 @@
 
 #include <windows.h>
 
+#include "config.h"
+
+#include <gpg-error.h>
+
 /** Window Message handling for GpgOL.
   In Outlook only one thread has access to the Outlook Object model
   and this is the UI Thread. We can work in other threads but
@@ -80,4 +84,7 @@ close_mail (LPVOID);
 void add_explorer (LPDISPATCH explorer);
 void remove_explorer (LPDISPATCH explorer);
 
+/* The lock to invalide the ui */
+extern gpgrt_lock_t invalidate_lock;
+
 #endif // WINDOWMESSAGES_H

commit 833c56e4f24674588b72fb9f3a958eba87ccdb62
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Feb 12 14:50:33 2018 +0100

    Use delayed invalidation when parsing is done
    
    * src/mail.cpp (Mail::parsing_done): Use delayed invalidation.
    
    --
    If we are unlucky the direct invalidate ui would come right before
    or after a Window Message invalidation. This would then lead
    to behavior as we had in T3523 where Outlook goes bonkers.
    
    GnuPG-Bug-ID: T3769
    GnuPG-Bug-ID: T3789

diff --git a/src/mail.cpp b/src/mail.cpp
index a2f3e2b..27a0665 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -986,7 +986,11 @@ Mail::parsing_done()
 
   /* Invalidate UI to set the correct sig status. */
   m_parser = nullptr;
-  gpgoladdin_invalidate_ui ();
+
+  log_debug ("%s:%s: Delayed invalidate to update sigstate.",
+             SRCNAME, __func__);
+  CloseHandle(CreateThread (NULL, 0, delayed_invalidate_ui, (LPVOID) this, 0,
+                            NULL));
   TRACEPOINT;
   return;
 }

commit c2572084cdb13a154e0e2bbc156155865b08c83e
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Feb 12 14:49:38 2018 +0100

    Log errors strings
    
    * src/mail.cpp (Mail::update_body): Log errors.
    
    --
    Makes it easier to analyze what happend when only looking
    at the log.

diff --git a/src/mail.cpp b/src/mail.cpp
index 39342b1..a2f3e2b 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -841,6 +841,12 @@ Mail::update_body()
               log_error ("%s:%s: Failed to modify html body of item.",
                          SRCNAME, __func__);
             }
+          else
+            {
+              log_debug ("%s:%s: Set error html to: '%s'",
+                         SRCNAME, __func__, error.c_str ());
+            }
+
         }
       else
         {
@@ -850,6 +856,11 @@ Mail::update_body()
               log_error ("%s:%s: Failed to modify html body of item.",
                          SRCNAME, __func__);
             }
+          else
+            {
+              log_debug ("%s:%s: Set error plain to: '%s'",
+                         SRCNAME, __func__, error.c_str ());
+            }
         }
       return;
     }

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

Summary of changes:
 src/mail.cpp           | 21 ++++++++++++++++++++-
 src/windowmessages.cpp |  9 +++++----
 src/windowmessages.h   | 17 ++++++++++++-----
 3 files changed, 37 insertions(+), 10 deletions(-)


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




More information about the Gnupg-commits mailing list