[git] GpgOL - branch, nomapi, updated. gpgol-1.4.0-145-g7ba4f6e

by Andre Heinecke cvs at cvs.gnupg.org
Mon Nov 7 18:17:28 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  7ba4f6e43ffc999945f7c9298b44572d237723e4 (commit)
      from  b6b1b43ca1f29bf3afebd53d8afb0b3d7b3e7f4d (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 7ba4f6e43ffc999945f7c9298b44572d237723e4
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Nov 7 18:14:05 2016 +0100

    Only close on WM_CLOSE of explorers
    
    * src/explorer-events.cpp (EVENT_SINK_INVOKE): Track explorers.
    * src/gpgoladdin.cpp (install_explorer_sinks): Install sinks.
    * src/windowmessages.cpp (add_explorer_window)
    (remove_explorer_window): New.
    (gpgol_hook): Only react to explorers.
    
    --
    This prevents mails from beeing closed when they are opened
    in a reader. Still todo is to close only the mails from the
    selection of the explorer that is currently closing and
    only to close all mails if it is the last explorer.

diff --git a/src/explorer-events.cpp b/src/explorer-events.cpp
index 6336561..c8130a7 100644
--- a/src/explorer-events.cpp
+++ b/src/explorer-events.cpp
@@ -32,6 +32,7 @@
 #include "oomhelp.h"
 #include "mail.h"
 #include "gpgoladdin.h"
+#include "windowmessages.h"
 
 /* Explorer Events */
 BEGIN_EVENT_SINK(ExplorerEvents, IDispatch)
@@ -76,6 +77,10 @@ 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);
           delete this;
           return S_OK;
         }
diff --git a/src/gpgoladdin.cpp b/src/gpgoladdin.cpp
index 9e80808..0f43663 100644
--- a/src/gpgoladdin.cpp
+++ b/src/gpgoladdin.cpp
@@ -407,6 +407,9 @@ 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);
       gpgol_release (explorer);
     }
   /* Now install the event sink to handle new explorers */
diff --git a/src/windowmessages.cpp b/src/windowmessages.cpp
index 585d0d0..a650810 100644
--- a/src/windowmessages.cpp
+++ b/src/windowmessages.cpp
@@ -182,6 +182,21 @@ do_in_ui_thread (gpgol_wmsg_type type, void *data)
   return ctx.err;
 }
 
+static std::vector <HWND> explorers;
+
+void
+add_explorer_window (HWND hwnd)
+{
+  explorers.push_back (hwnd);
+}
+
+void remove_explorer_window (HWND hwnd)
+{
+  explorers.erase(std::remove(explorers.begin(),
+                              explorers.end(),
+                              hwnd),
+                  explorers.end());
+}
 
 LRESULT CALLBACK
 gpgol_hook(int code, WPARAM wParam, LPARAM lParam)
@@ -192,11 +207,30 @@ gpgol_hook(int code, WPARAM wParam, LPARAM lParam)
    before it reaches outlook. */
   LPCWPSTRUCT cwp = (LPCWPSTRUCT) lParam;
 
-  if (cwp->message == WM_CLOSE)
+  switch (cwp->message)
     {
-      log_debug ("%s:%s: WM_CLOSE windowmessage. Closing all mails.",
-                 SRCNAME, __func__);
-      Mail::revert_all_mails();
+      case WM_CLOSE:
+      {
+        if (std::find(explorers.begin(), explorers.end(), cwp->hwnd) == explorers.end())
+          {
+            /* Not an explorer window */
+            break;
+          }
+        log_debug ("%s:%s: WM_CLOSE windowmessage for explorer. "
+                   "Closing all mails.",
+                   SRCNAME, __func__);
+        Mail::close_all_mails();
+      }
+     case WM_SYSCOMMAND:
+       if (cwp->wParam == SC_CLOSE)
+        {
+          log_debug ("%s:%s: SC_CLOSE syscommand. Closing all mails.",
+                     SRCNAME, __func__);
+          Mail::close_all_mails();
+        }
+       break;
+     default:
+       break;
     }
   return CallNextHookEx (NULL, code, wParam, lParam);
 }
diff --git a/src/windowmessages.h b/src/windowmessages.h
index c7f275e..0af0a3c 100644
--- a/src/windowmessages.h
+++ b/src/windowmessages.h
@@ -71,4 +71,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);
+
 #endif // WINDOWMESSAGES_H

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

Summary of changes:
 src/explorer-events.cpp |  5 +++++
 src/gpgoladdin.cpp      |  3 +++
 src/windowmessages.cpp  | 42 ++++++++++++++++++++++++++++++++++++++----
 src/windowmessages.h    |  3 +++
 4 files changed, 49 insertions(+), 4 deletions(-)


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




More information about the Gnupg-commits mailing list