[git] GpgOL - branch, nomapi, updated. gpgol-1.4.0-154-g49b9fd0

by Andre Heinecke cvs at cvs.gnupg.org
Fri Nov 11 15:14:54 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, nomapi has been updated
       via  49b9fd0697088a25c260e4acd14be96252fe3988 (commit)
       via  d16f3075cfa8db3a162c996035a21680386d69a1 (commit)
       via  574ff72396de2ab6e71d6f078e3caa56c623c13a (commit)
       via  d77e4135ecc23f3dd9390b5650ed5d926fdcecec (commit)
       via  d7192df3f3fa1543326acef17cd344d3412cce25 (commit)
       via  6e085dd895b2ae922a320a8c0501e59de68642a4 (commit)
       via  ea6f44cc0508db178a986874525d170105d95678 (commit)
       via  22ea51b3672f68ffde6923c0720e4bf36f66f712 (commit)
      from  fd27fa2fc04ba2172e4007b472d000153286b311 (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 49b9fd0697088a25c260e4acd14be96252fe3988
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Nov 11 15:14:07 2016 +0100

    Clean up some debug output
    
    * src/ribbon-callbacks.cpp (get_mail_from_control): Don't
    print the Subject

diff --git a/src/ribbon-callbacks.cpp b/src/ribbon-callbacks.cpp
index 977145a..596d74f 100644
--- a/src/ribbon-callbacks.cpp
+++ b/src/ribbon-callbacks.cpp
@@ -1471,9 +1471,8 @@ get_mail_from_control (LPDISPATCH ctrl)
       uid = mapi_get_uid (mailitem);
       if (!uid)
         {
-          log_oom ("%s:%s: Failed to get uid for %p .",
+          log_debug ("%s:%s: Failed to get uid for %p",
                    SRCNAME, __func__, mailitem);
-          log_debug ("subject: %s", get_oom_string(mailitem, "Subject"));
           gpgol_release (mailitem);
           return NULL;
         }

commit d16f3075cfa8db3a162c996035a21680386d69a1
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Nov 11 15:11:56 2016 +0100

    Remove accidentally commited AddRef experiment
    
    * src/mailitem-events.cpp (EVENT_SINK_INVOKE): Do not add
    another ref on read.
    
    --
    This was part of an experiment if the additional ref prevented
    an unload.

diff --git a/src/mailitem-events.cpp b/src/mailitem-events.cpp
index e1e5881..bd37d5d 100644
--- a/src/mailitem-events.cpp
+++ b/src/mailitem-events.cpp
@@ -196,7 +196,6 @@ EVENT_SINK_INVOKE(MailItemEvents)
         {
           log_oom_extra ("%s:%s: Read : %p",
                          SRCNAME, __func__, m_mail);
-          m_object->AddRef();
           if (!m_mail->is_crypto_mail())
             {
               /* Not for us. */

commit 574ff72396de2ab6e71d6f078e3caa56c623c13a
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Nov 11 15:07:30 2016 +0100

    Fix WM_CLOSE handling
    
    * src/windowmessages.h (add_explorer, remove_explorer): Use LPDISPATCH
    * src/windowmessages.cpp (add_explorer, remove_explorer): Update
    accordingly.
    (gpgol_hook): Use FindWindowEx to find all explorer windows.
    * src/gpgoladdin.cpp (install_explorer_sinks): Register explorer
    dispatch.
    * src/explorer-events.cpp (EVENT_SINK_INVOKE): Remove explorer
    on close.
    
    --
    At least with Outlook 2016 casting to IOlewindow and using
    GetWindow did not work anymore. The returned handle was always 1.
    FindWindowEx should work reliably.

diff --git a/src/explorer-events.cpp b/src/explorer-events.cpp
index c794a91..4b8a7ab 100644
--- a/src/explorer-events.cpp
+++ b/src/explorer-events.cpp
@@ -100,9 +100,7 @@ EVENT_SINK_INVOKE(ExplorerEvents)
           log_oom_extra ("%s:%s: Deleting event handler: %p",
                          SRCNAME, __func__, this);
 
-          HWND hwnd;
-          ((LPOLEWINDOW)m_object)->GetWindow(&hwnd);
-          remove_explorer_window (hwnd);
+          remove_explorer (m_object);
           delete this;
           return S_OK;
         }
diff --git a/src/gpgoladdin.cpp b/src/gpgoladdin.cpp
index 0f43663..fda79a5 100644
--- a/src/gpgoladdin.cpp
+++ b/src/gpgoladdin.cpp
@@ -407,9 +407,7 @@ install_explorer_sinks (LPDISPATCH application)
           log_oom_extra ("%s:%s: created sink %p for explorer %i",
                          SRCNAME, __func__, sink, i);
         }
-      HWND hwnd;
-      ((LPOLEWINDOW)explorer)->GetWindow(&hwnd);
-      add_explorer_window (hwnd);
+      add_explorer (explorer);
       gpgol_release (explorer);
     }
   /* Now install the event sink to handle new explorers */
diff --git a/src/windowmessages.cpp b/src/windowmessages.cpp
index 7268299..0760cdf 100644
--- a/src/windowmessages.cpp
+++ b/src/windowmessages.cpp
@@ -191,19 +191,19 @@ do_in_ui_thread (gpgol_wmsg_type type, void *data)
   return ctx.err;
 }
 
-static std::vector <HWND> explorers;
+static std::vector <LPDISPATCH> explorers;
 
 void
-add_explorer_window (HWND hwnd)
+add_explorer (LPDISPATCH explorer)
 {
-  explorers.push_back (hwnd);
+  explorers.push_back (explorer);
 }
 
-void remove_explorer_window (HWND hwnd)
+void remove_explorer (LPDISPATCH explorer)
 {
   explorers.erase(std::remove(explorers.begin(),
                               explorers.end(),
-                              hwnd),
+                              explorer),
                   explorers.end());
 }
 
@@ -220,15 +220,34 @@ gpgol_hook(int code, WPARAM wParam, LPARAM lParam)
     {
       case WM_CLOSE:
       {
-        if (std::find(explorers.begin(), explorers.end(), cwp->hwnd) == explorers.end())
+        HWND lastChild = NULL;
+        for (const auto explorer: explorers)
           {
-            /* Not an explorer window */
-            break;
+            /* Casting to LPOLEWINDOW and calling GetWindow
+               succeeded in Outlook 2016 but always returned
+               the number 1. So we need this hack. */
+            char *caption = get_oom_string (explorer, "Caption");
+            if (!caption)
+              {
+                log_debug ("%s:%s: No caption.",
+                           SRCNAME, __func__);
+                continue;
+              }
+            /* rctrl_renwnd32 is the window class of outlook. */
+            HWND hwnd = FindWindowExA(NULL, lastChild, "rctrl_renwnd32",
+                                      caption);
+            xfree (caption);
+            lastChild = hwnd;
+            if (hwnd == cwp->hwnd)
+              {
+                log_debug ("%s:%s: WM_CLOSE windowmessage for explorer. "
+                           "Closing all mails.",
+                           SRCNAME, __func__);
+                Mail::close_all_mails();
+                break;
+              }
           }
-        log_debug ("%s:%s: WM_CLOSE windowmessage for explorer. "
-                   "Closing all mails.",
-                   SRCNAME, __func__);
-        Mail::close_all_mails();
+        break;
       }
      case WM_SYSCOMMAND:
        if (cwp->wParam == SC_CLOSE)
diff --git a/src/windowmessages.h b/src/windowmessages.h
index 366e67e..7c07ae3 100644
--- a/src/windowmessages.h
+++ b/src/windowmessages.h
@@ -70,7 +70,7 @@ do_in_ui_thread (gpgol_wmsg_type type, void *data);
 HHOOK
 create_message_hook();
 
-void add_explorer_window (HWND hwnd);
-void remove_explorer_window (HWND hwnd);
+void add_explorer (LPDISPATCH explorer);
+void remove_explorer (LPDISPATCH explorer);
 
 #endif // WINDOWMESSAGES_H

commit d77e4135ecc23f3dd9390b5650ed5d926fdcecec
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Nov 11 15:05:16 2016 +0100

    Fix UI Invalidation after selection change
    
    * src/explorer-events.cpp (EVENT_SINK_INVOKE): Invalidate again
    on selection change.
    (invalidate_ui): Delay invalidation.
    
    --
    We sleep before the invalidation to give outlook a chance to
    actually read the mail properly after the selection is changed
    before we invalidate the ui. This fixes some races after selection
    change.

diff --git a/src/explorer-events.cpp b/src/explorer-events.cpp
index c8130a7..c794a91 100644
--- a/src/explorer-events.cpp
+++ b/src/explorer-events.cpp
@@ -61,6 +61,17 @@ typedef enum
     ViewSwitch = 0xF004
   } ExplorerEvent;
 
+static DWORD WINAPI
+invalidate_ui (LPVOID)
+{
+  /* We sleep here a bit to prevent invalidtion immediately
+     after the selection change before we have started processing
+     the mail. */
+  Sleep (1000);
+  do_in_ui_thread (INVALIDATE_UI, nullptr);
+  return 0;
+}
+
 EVENT_SINK_INVOKE(ExplorerEvents)
 {
   USE_INVOKE_ARGS
@@ -70,7 +81,18 @@ EVENT_SINK_INVOKE(ExplorerEvents)
         {
           log_oom_extra ("%s:%s: Selection change in explorer: %p",
                          SRCNAME, __func__, this);
-        //  gpgoladdin_invalidate_ui ();
+          HANDLE thread = CreateThread (NULL, 0, invalidate_ui, (LPVOID) this, 0,
+                                        NULL);
+
+          if (!thread)
+            {
+              log_error ("%s:%s: Failed to create invalidate_ui thread.",
+                         SRCNAME, __func__);
+            }
+          else
+            {
+              CloseHandle (thread);
+            }
           break;
         }
       case Close:
diff --git a/src/windowmessages.cpp b/src/windowmessages.cpp
index a650810..7268299 100644
--- a/src/windowmessages.cpp
+++ b/src/windowmessages.cpp
@@ -113,6 +113,15 @@ gpgol_window_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
               gpgol_window_proc (hWnd, message, wParam, (LPARAM) ctx);
               break;
             }
+          case (INVALIDATE_UI):
+            {
+              log_debug ("%s:%s: Invalidating UI",
+                         SRCNAME, __func__);
+              gpgoladdin_invalidate_ui();
+              log_debug ("%s:%s: Invalidation done",
+                         SRCNAME, __func__);
+              break;
+            }
           default:
             log_debug ("Unknown msg");
         }
diff --git a/src/windowmessages.h b/src/windowmessages.h
index 0af0a3c..366e67e 100644
--- a/src/windowmessages.h
+++ b/src/windowmessages.h
@@ -33,11 +33,10 @@
 
   The Responder Window should be initalized on startup.
   */
-
-
 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
                       to the mail object. */
   REQUEST_DECRYPT = 3,

commit d7192df3f3fa1543326acef17cd344d3412cce25
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Nov 11 15:01:51 2016 +0100

    Ensure uuid's are always logged
    
    * src/mail.cpp (Mail::set_uuid): Log uuid changes.

diff --git a/src/mail.cpp b/src/mail.cpp
index e262d7b..e34cb53 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -1257,6 +1257,8 @@ Mail::set_uuid()
   else
     {
       uuid = get_unique_id (m_mailitem, 1, nullptr);
+      log_debug ("%s:%s: uuid for %p set to %s",
+                 SRCNAME, __func__, this, uuid);
     }
 
   if (!uuid)

commit 6e085dd895b2ae922a320a8c0501e59de68642a4
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Nov 11 14:58:56 2016 +0100

    Fix sigstate code for multiple signatures
    
    * src/mail.cpp (Mail::update_sigstate): Fix signature selection code.
    
    --
    Previously the first signature was selected always even if this
    signature did not have the uid belonging to the sender. This
    might be considered a security problem but was thankfully not
    released yet.
    Thanks to Daniel Vrátil <dvratil at kdab.com> for seeing this issue.

diff --git a/src/mail.cpp b/src/mail.cpp
index 4694ed3..e262d7b 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -1169,6 +1169,7 @@ Mail::update_sigstate ()
       m_sig = sig;
       m_uid = uid;
       m_is_valid = true;
+      return;
     }
 
   log_debug ("%s:%s: No signature with enough trust. Using first",

commit ea6f44cc0508db178a986874525d170105d95678
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Nov 11 14:58:23 2016 +0100

    Set uuid again in close
    
    * src/mail.cpp (Mail::close): Set uuid again.
    
    --
    This fixes the decrypt again code.

diff --git a/src/mail.cpp b/src/mail.cpp
index 06dc278..4694ed3 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -1043,18 +1043,20 @@ Mail::close ()
   dispparams.cArgs = 1;
   dispparams.cNamedArgs = 0;
 
+  log_oom_extra ("%s:%s: Invoking close for: %p",
+                 SRCNAME, __func__, this);
   int rc = invoke_oom_method_with_parms (m_mailitem, "Close",
                                          NULL, &dispparams);
 
   /* Reset the uuid after discarding all changes in the oom
      so that we can still find ourself. */
-//  set_uuid ();
+  set_uuid ();
 
-  /* Now that we have closed it with discard changes we no
-     longer need to wipe the mail because the plaintext was
-     discarded. */
   if (!rc)
     {
+    /* Now that we have closed it with discard changes we no
+       longer need to wipe the mail because the plaintext was
+       discarded. */
       m_needs_wipe = false;
     }
   return rc;

commit 22ea51b3672f68ffde6923c0720e4bf36f66f712
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Nov 11 14:56:53 2016 +0100

    Remove old error message template
    
    * src/mail.cpp (HTML_TEMPLATE): Remove.
    (Mail::wipe): Just empty out body.
    
    --
    This should no longer be needed. Only if close errors out
    is wipe actually called.

diff --git a/src/mail.cpp b/src/mail.cpp
index a727b23..06dc278 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -57,34 +57,6 @@ static std::map<std::string, Mail*> g_uid_map;
    in get_valid_sig why.*/
 #define GPGOL_BASIC_TOFU_TRUST 10
 
-/* TODO: Localize this once it is less bound to change.
-   TODO: Use a dedicated message for failed decryption. */
-#define HTML_TEMPLATE  \
-"<html><head></head><body>" \
-"<table border=\"0\" width=\"100%\" cellspacing=\"1\" cellpadding=\"1\" bgcolor=\"#0069cc\">" \
-"<tr>" \
-"<td bgcolor=\"#0080ff\">" \
-"<p><span style=\"font-weight:600; background-color:#0080ff;\"><center>This message is encrypted</center><span></p></td></tr>" \
-"<tr>" \
-"<td bgcolor=\"#e0f0ff\">" \
-"<center>" \
-"<br/>You can decrypt this message with GnuPG" \
-"<br/>Open this message to decrypt it." \
-"<br/>Opening any attachments while this message is shown will only give you access to encrypted data. </center>" \
-"<br/><br/>If you have GpgOL (The GnuPG Outlook plugin installed) this message should have been automatically decrypted." \
-"<br/>Reasons that you still see this message can be: " \
-"<ul>" \
-"<li>Decryption failed: <ul><li> Refer to the Decrypt / Verify popup window for details.</li></ul></li>" \
-"<li>Outlook tried to save the decrypted content:" \
-" <ul> "\
-" <li>To protect your data GpgOL encrypts a message when it is saved by Outlook.</li>" \
-" <li>You will need to restart Outlook to allow GpgOL to decrypt this message again.</li>" \
-" </ul>" \
-"<li>GpgOL is not activated: <ul><li>Check under Options -> Add-Ins -> COM-Add-Ins to see if this is the case.</li></ul></li>" \
-"</ul>"\
-"</td></tr>" \
-"</table></body></html>"
-
 Mail::Mail (LPDISPATCH mailitem) :
     m_mailitem(mailitem),
     m_processed(false),
@@ -766,10 +738,15 @@ Mail::wipe ()
   log_debug ("%s:%s: Removing plaintext from mailitem: %p.",
              SRCNAME, __func__, m_mailitem);
   if (put_oom_string (m_mailitem, "HTMLBody",
-                      HTML_TEMPLATE))
+                      ""))
     {
-      log_debug ("%s:%s: Failed to wipe mailitem: %p.",
-                 SRCNAME, __func__, m_mailitem);
+      if (put_oom_string (m_mailitem, "Body",
+                          ""))
+        {
+          log_debug ("%s:%s: Failed to wipe mailitem: %p.",
+                     SRCNAME, __func__, m_mailitem);
+          return -1;
+        }
       return -1;
     }
   m_needs_wipe = false;

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

Summary of changes:
 src/explorer-events.cpp  | 28 ++++++++++++++++++++++----
 src/gpgoladdin.cpp       |  4 +---
 src/mail.cpp             | 52 ++++++++++++++++--------------------------------
 src/mailitem-events.cpp  |  1 -
 src/ribbon-callbacks.cpp |  3 +--
 src/windowmessages.cpp   | 52 +++++++++++++++++++++++++++++++++++++-----------
 src/windowmessages.h     |  7 +++----
 7 files changed, 86 insertions(+), 61 deletions(-)


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




More information about the Gnupg-commits mailing list