Add patch for GpgOL to better open conf
authorAndre Heinecke <aheinecke@intevation.de>
Mon, 30 Apr 2018 09:47:55 +0000 (11:47 +0200)
committerAndre Heinecke <aheinecke@intevation.de>
Mon, 30 Apr 2018 09:47:55 +0000 (11:47 +0200)
* Makefile.am (EXTRA_DIST): Add it.
* patches/gpgol-2.1.1/
0001-Launch-Kleopatra-config-dialog-with-parent.patch: New.

Makefile.am
patches/gpgol-2.1.1/0001-Launch-Kleopatra-config-dialog-with-parent.patch [new file with mode: 0755]

index a3cd2b8..c08e2d4 100644 (file)
@@ -47,7 +47,8 @@ EXTRA_DIST = autogen.sh README.GIT ONEWS \
         patches/extra-cmake-modules/0001-Use-BIN_INSTALL_DIR-data-for-DATAROOTDIR-on-Windows.patch \
         patches/gpa-0.9.10/0001-w32-Make-location-of-locale-dir-more-flexible.patch \
         patches/libgpg-error-1.29/0001-doc-Fix-yat2m-build-for-cross-compilation.patch \
-        patches/gpgol-2.1.1/0001-Disable-OL-2013-2016-resiliency-for-us.patch
+        patches/gpgol-2.1.1/0001-Disable-OL-2013-2016-resiliency-for-us.patch \
+        patches/gpgol-2.1.1/0001-Launch-Kleopatra-config-dialog-with-parent.patch
 
 
 copy-news:
diff --git a/patches/gpgol-2.1.1/0001-Launch-Kleopatra-config-dialog-with-parent.patch b/patches/gpgol-2.1.1/0001-Launch-Kleopatra-config-dialog-with-parent.patch
new file mode 100755 (executable)
index 0000000..d61a0fb
--- /dev/null
@@ -0,0 +1,113 @@
+#! /bin/sh
+patch -p1 -l -f $* < $0
+exit $?
+
+From 07811afb552bfc1e51aea25a39cb52327831198b Mon Sep 17 00:00:00 2001
+From: Andre Heinecke <aheinecke@intevation.de>
+Date: Mon, 30 Apr 2018 11:44:54 +0200
+Subject: [PATCH] Launch Kleopatra config dialog with parent
+
+* src/addin-options.cpp (launch_kleo_config): New.
+(options_window_proc): Use it.
+
+--
+This fixes that the config dialog might be opened in the
+background, or that the assuan communication fails.
+
+Fixes
+GnuPG-Bug-Id: T3946
+---
+ src/addin-options.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++-
+ 1 file changed, 63 insertions(+), 1 deletion(-)
+
+diff --git a/src/addin-options.cpp b/src/addin-options.cpp
+index 32b47eb..6677a30 100644
+--- a/src/addin-options.cpp
++++ b/src/addin-options.cpp
+@@ -27,6 +27,11 @@
+ #include "common.h"
+ #include "engine.h"
+
++#include <string>
++
++#include <gpgme++/context.h>
++#include <gpgme++/data.h>
++
+ /* To avoid writing a dialog template for each language we use gettext
+    for the labels and hope that there is enough space in the dialog to
+    fit the longest translation.. */
+@@ -77,6 +82,63 @@ enable_disable_opts (HWND hDlg)
+   xfree (uiserver);
+ }
+
++static void
++launch_kleo_config (HWND hDlg)
++{
++  char *uiserver = get_uiserver_name ();
++  bool showError = false;
++  if (uiserver)
++    {
++      std::string path (uiserver);
++      xfree (uiserver);
++      if (path.find("kleopatra.exe") != std::string::npos)
++        {
++        size_t dpos;
++        if ((dpos = path.find(" --daemon")) != std::string::npos)
++            {
++              path.erase(dpos, strlen(" --daemon"));
++            }
++          auto ctx = GpgME::Context::createForEngine(GpgME::SpawnEngine);
++          if (!ctx)
++            {
++              log_error ("%s:%s: No spawn engine.",
++                         SRCNAME, __func__);
++            }
++            std::string parentWid = std::to_string ((int) (intptr_t) hDlg);
++            const char *argv[] = {path.c_str(),
++                                  "--config",
++                                  "--parent-windowid",
++                                  parentWid.c_str(),
++                                  NULL };
++            log_debug ("%s:%s: Starting %s %s %s",
++                       SRCNAME, __func__, path.c_str(), argv[1], argv[2]);
++            GpgME::Data d(GpgME::Data::null);
++            ctx->spawnAsync(path.c_str(), argv, d, d,
++                            d, (GpgME::Context::SpawnFlags) (
++                                GpgME::Context::SpawnAllowSetFg |
++                                GpgME::Context::SpawnShowWindow));
++        }
++      else
++        {
++          showError = true;
++        }
++    }
++  else
++    {
++      showError = true;
++    }
++
++  if (showError)
++    {
++      MessageBox (NULL,
++                  _("Could not find Kleopatra.\n"
++                  "Please reinstall Gpg4win with the Kleopatra component enabled."),
++                  _("GpgOL"),
++                  MB_ICONINFORMATION|MB_OK);
++    }
++
++}
++
+ static INT_PTR CALLBACK
+ options_window_proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+ {
+@@ -149,7 +211,7 @@ options_window_proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+                 break;
+               }
+             case IDC_GPG_CONF:
+-              engine_start_confdialog (hDlg);
++              launch_kleo_config (hDlg);
+               break;
+             case IDC_GPG_OPTIONS:
+               config_dialog_box (hDlg);
+--
+2.11.0