[git] GpgOL - branch, nomapi, updated. gpgol-1.4.0-156-ga8891e3

by Andre Heinecke cvs at cvs.gnupg.org
Fri Nov 11 16:02:42 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  a8891e3a6ef1cb32842f203656ada790d7581957 (commit)
       via  957f2441efb15e4a51342ff3f73a86bec4dabee7 (commit)
      from  49b9fd0697088a25c260e4acd14be96252fe3988 (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 a8891e3a6ef1cb32842f203656ada790d7581957
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Nov 11 16:01:18 2016 +0100

    Add property change warning
    
    * src/mailitem-events.cpp (EVENT_SINK_INVOKE): Warn on property
    change done by the user.
    
    --
    See the comment in the PropertyChange event why we can't handle
    this.

diff --git a/src/mailitem-events.cpp b/src/mailitem-events.cpp
index bd37d5d..d8bc897 100644
--- a/src/mailitem-events.cpp
+++ b/src/mailitem-events.cpp
@@ -28,14 +28,15 @@
 #include "mail.h"
 #include "mapihelp.h"
 
-const wchar_t * save_props[] = {
+const wchar_t *prop_blacklist[] = {
+  L"Body",
+  L"HTMLBody",
+  L"To", /* Somehow this is done when a mail is opened */
+  L"CC", /* Ditto */
+  L"BCC", /* Ditto */
   L"Categories",
-  L"FlagRequest",
-  L"TaskCompletedDate",
-  L"FlagStatus",
   NULL };
 
-
 typedef enum
   {
     AfterWrite = 0xFC8D,
@@ -125,6 +126,8 @@ request_close (LPVOID arg)
   return 0;
 }
 
+static bool propchangeWarnShown = false;
+
 /* 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
@@ -221,11 +224,9 @@ EVENT_SINK_INVOKE(MailItemEvents)
             }
           break;
         }
-#if 0
       case PropertyChange:
         {
-          wchar_t *prop_name;
-          const wchar_t **cur;
+          const wchar_t *prop_name;
           if (!m_mail->is_crypto_mail ())
             {
               break;
@@ -238,22 +239,70 @@ EVENT_SINK_INVOKE(MailItemEvents)
                          SRCNAME, __func__);
               break;
             }
-
           prop_name = parms->rgvarg[0].bstrVal;
-
-          for (cur = save_props; *cur; cur++)
+          for (const wchar_t **cur = prop_blacklist; *cur; cur++)
             {
               if (!wcscmp (prop_name, *cur))
                 {
-                  m_mail->set_needs_save (true);
-                  break;
+                  log_oom ("%s:%s: Message %p propchange: %ls discarded.",
+                           SRCNAME, __func__, m_object, prop_name);
+                  return S_OK;
                 }
             }
           log_oom ("%s:%s: Message %p propchange: %ls.",
                    SRCNAME, __func__, m_object, prop_name);
+
+          /* We have tried several scenarios to handle propery changes.
+             Only save the property in MAPI and call MAPI SaveChanges
+             worked and did not leak plaintext but this caused outlook
+             still to break the attachments of PGP/MIME Mails into two
+             attachments and add them as winmail.dat so other clients
+             are broken.
+
+             Alternatively reverting the mail, saving the property and
+             then decrypt again also worked a bit but there were some
+             weird side effects and breakages. But this has the usual
+             problem of a revert that the mail is created by outlook and
+             e.g. multipart/signed signatures from most MUA's are broken.
+
+             Close -> discard changes -> then setting the property and
+             then saving also works but then the mail is closed / unloaded
+             and we can't decrypt again.
+
+             Some things to try out might be the close approach and then
+             another open or a selection change. But for now we just warn.
+
+             As a workardound a user should make property changes when
+             the mail was not read by us. */
+          if (propchangeWarnShown)
+            {
+              return S_OK;
+            }
+
+          wchar_t *title = utf8_to_wchar (_("Sorry, that's not possible, yet"));
+          char *fmt;
+          gpgrt_asprintf (&fmt, _("GpgOL has prevented the change to the \"%s\" property.\n"
+                                  "Property changes are not yet handled for crypto messages.\n\n"
+                                  "To workaround this limitation please change the property when the"
+                                  "message is not open in any window and not selected in the"
+                                  "messagelist.\n\nFor example by right clicking but not selecting the message.\n"),
+                          wchar_to_utf8(prop_name));
+          wchar_t *msg = utf8_to_wchar (fmt);
+          xfree (fmt);
+          MessageBoxW (get_active_hwnd(), msg, title,
+                       MB_ICONINFORMATION | MB_OK);
+          xfree (msg);
+          xfree (title);
+          propchangeWarnShown = true;
           return S_OK;
         }
-#endif
+      case CustomPropertyChange:
+        {
+          log_oom_extra ("%s:%s: CustomPropertyChange : %p",
+                         SRCNAME, __func__, m_mail);
+          /* TODO */
+          break;
+        }
       case Send:
         {
           /* This is the only event where we can cancel the send of an
@@ -386,8 +435,8 @@ EVENT_SINK_INVOKE(MailItemEvents)
                   break;
                 }
               *(parms->rgvarg[0].pboolVal) = VARIANT_TRUE;
-              log_oom ("%s:%s: Canceling close event.",
-                       SRCNAME, __func__);
+              log_oom_extra ("%s:%s: Canceling close event.",
+                             SRCNAME, __func__);
               m_decrypt_after_write = true;
               m_ignore_unloads = false;
               m_ignore_next_unload = true;

commit 957f2441efb15e4a51342ff3f73a86bec4dabee7
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Nov 11 16:00:34 2016 +0100

    Add helper method to get active window handle
    
    * src/oomhelp.cpp, src/oomhelp.h (get_active_hwnd): New get the
    handle of the active window.

diff --git a/src/oomhelp.cpp b/src/oomhelp.cpp
index bb8df36..1b23d75 100644
--- a/src/oomhelp.cpp
+++ b/src/oomhelp.cpp
@@ -1652,3 +1652,40 @@ get_unique_id (LPDISPATCH mail, int create, const char *uuid)
              SRCNAME, __func__, mail, newuid);
   return newuid;
 }
+
+HWND
+get_active_hwnd ()
+{
+  LPDISPATCH app = GpgolAddin::get_instance ()->get_application ();
+
+  if (!app)
+    {
+      TRACEPOINT;
+      return nullptr;
+    }
+
+  LPDISPATCH activeWindow = get_oom_object (app, "ActiveWindow");
+  gpgol_release (app);
+
+  if (!activeWindow)
+    {
+      TRACEPOINT;
+      return nullptr;
+    }
+
+  /* Both explorer and inspector have this. */
+  char *caption = get_oom_string (activeWindow, "Caption");
+  gpgol_release (activeWindow);
+  if (!caption)
+    {
+      TRACEPOINT;
+      return nullptr;
+    }
+  /* Might not be completly true for multiple explorers
+     on the same folder but good enugh. */
+  HWND hwnd = FindWindowExA(NULL, NULL, "rctrl_renwnd32",
+                            caption);
+  xfree (caption);
+
+  return hwnd;
+}
diff --git a/src/oomhelp.h b/src/oomhelp.h
index 35991ce..1c6aa94 100644
--- a/src/oomhelp.h
+++ b/src/oomhelp.h
@@ -302,6 +302,11 @@ remove_category (LPDISPATCH mail, const char *category);
 char *
 get_unique_id (LPDISPATCH mail, int create, const char* uuid);
 
+
+/* Uses the Application->ActiveWindow to determine the hwnd
+   through FindWindow and the caption. Does not use IOleWindow
+   because that was unreliable somhow. */
+HWND get_active_hwnd (void);
 #ifdef __cplusplus
 }
 #endif

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

Summary of changes:
 src/mailitem-events.cpp | 81 +++++++++++++++++++++++++++++++++++++++----------
 src/oomhelp.cpp         | 37 ++++++++++++++++++++++
 src/oomhelp.h           |  5 +++
 3 files changed, 107 insertions(+), 16 deletions(-)


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




More information about the Gnupg-commits mailing list