[git] GpgOL - branch, master, updated. gpgol-2.2.0-33-g61956b7

by Andre Heinecke cvs at cvs.gnupg.org
Tue Jul 3 16:22:04 CEST 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  61956b72ebf422d637c3aca934b4a027f791b862 (commit)
       via  541333d406df77b67cf520f80619ae92e3b92cbc (commit)
      from  87e96e7ee79ee837065883bb5434c9839024035f (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 61956b72ebf422d637c3aca934b4a027f791b862
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Jul 3 16:21:38 2018 +0200

    Remove now unused WinAPI dialog resource
    
    * src/dialogs.rc: Remove last winapi dialog.

diff --git a/src/dialogs.rc b/src/dialogs.rc
index 5687041..d5fc93e 100644
--- a/src/dialogs.rc
+++ b/src/dialogs.rc
@@ -57,138 +57,3 @@ IDI_SIGN_20_PNG            RCDATA              "icons/sign-20.png"
 IDI_GPGOL_LOCK_ICON        ICON    DISCARDABLE "icons/lock.ico"
 
 IDB_LOGO                   BITMAP  DISCARDABLE "icons/logo.bmp"
-
-IDD_GPG_OPTIONS  DIALOG DISCARDABLE  0, 0, 266, 274
-STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
-CAPTION "GpgOL"
-FONT 8, "MS Sans Serif"
-BEGIN
-    /* General options box.  */
-    GROUPBOX        "general-options", IDC_G_GENERAL,
-                    9, 9, 250, 25
-
-    CONTROL         "enable-smime", IDC_ENABLE_SMIME,
-                    "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
-                    24, 19, 215, 10
-
-    /* Send options box.  */
-    GROUPBOX        "send-options", IDC_G_SEND,
-                    9, 40, 250, 38
-
-    CONTROL         "encrypt-by-default", IDC_ENCRYPT_DEFAULT,
-                    "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
-                    24, 50, 215, 10
-
-    CONTROL         "sign-by-default", IDC_SIGN_DEFAULT, 
-                    "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
-                    24, 61, 215, 10
-
-    /* Receive options box.  */
-    GROUPBOX        "recv-options", IDC_G_RECV,
-                    9, 82, 250, 36
-
-  /* We have no reliable way to detect the preview window, thus we
-     don't show this option.  */
-/*     CONTROL         "preview-decrypt", IDC_PREVIEW_DECRYPT, */
-/*                     "Button", BS_AUTOCHECKBOX | WS_TABSTOP, */
-/*                     24, 114, 215, 10 */
-
-    CONTROL         "prefer-html", IDC_PREFER_HTML,
-                    "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
-                    24,  94, 215, 10
- 
-    CONTROL         "body-as-attachment", IDC_BODY_AS_ATTACHMENT,
-                    "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
-                    24, 103, 215, 10
- 
-    /* Stuff at the lower left corner.  */
-    LTEXT           "GpgOL by g10 Code GmbH", IDC_G10CODE_STRING, 
-                      8, 229, 100, 8
-    LTEXT           "Version x ", IDC_VERSION_INFO,
-                      8, 240, 100, 9
-
-  /* No more logo due to problems with the background colour.  */
-/*     CONTROL         IDB_BANNER, IDC_BITMAP, */
-/*                     "Static", SS_BITMAP | SS_REALSIZEIMAGE, */
-/*                       8, 212, 150, 64 */
-
-    PUSHBUTTON      "advanced", IDC_GPG_OPTIONS,
-                    130, 240, 50, 14
-
-    PUSHBUTTON      "gpgconf", IDC_GPG_CONF,
-                    190, 240, 70, 14
-
-END
-
-
-
-IDD_EXT_OPTIONS DIALOG DISCARDABLE  0, 0, 155, 70
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
-CAPTION "GpgOL - Debug Options"
-FONT 8, "MS Sans Serif"
-BEGIN
-    LTEXT           "debug-logfile", IDC_T_DEBUG_LOGFILE,
-                    8, 10, 122, 8
-
-    EDITTEXT        IDC_DEBUG_LOGFILE,
-                    8, 20, 138, 12, ES_AUTOHSCROLL
-
-    DEFPUSHBUTTON   "&OK", IDOK,
-                    90, 50, 50, 14
-END
-
-
-IDD_ADDIN_OPTIONS DIALOGEX DISCARDABLE  300, 300, 286, 190
-STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_SHELLFONT | DS_SETFONT
-CAPTION "GpgOL"
-FONT 8, "MS Shell Dlg"
-BEGIN
-    /* General options box.  */
-    GROUPBOX        "general-options", IDC_G_GENERAL,
-                    9, 9, 270, 25
-    CONTROL         "enable-smime", IDC_ENABLE_SMIME,
-                    "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
-                    24, 19, 235, 10
-
-    /* Send options box.  */
-    GROUPBOX        "send-options", IDC_G_SEND,
-                    9, 50, 270, 67
-
-    CONTROL         "encrypt-by-default", IDC_ENCRYPT_DEFAULT,
-                    "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
-                    24, 60, 235, 10
-
-    CONTROL         "sign-by-default", IDC_SIGN_DEFAULT,
-                    "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
-                    24, 71, 235, 10
-
-    CONTROL         "inline-pgp", IDC_INLINE_PGP,
-                    "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
-                    24, 82, 235, 10
-
-    CONTROL         "replycrypt", IDC_REPLYCRYPT,
-                    "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
-                    24, 93, 235, 10
-
-    CONTROL         "autoresolve", IDC_AUTORRESOLVE,
-                    "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
-                    24, 104, 235, 10
-
-    /* Stuff at the lower left corner.  */
-    CONTROL         IDB_LOGO, IDC_BITMAP,
-                    "Static", SS_BITMAP | SS_REALSIZEIMAGE,
-                      10, 125, 128, 80
-
-    LTEXT           "Version x ", IDC_VERSION_INFO,
-                      10, 175, 100, 9
-
-    PUSHBUTTON      "advanced", IDC_GPG_OPTIONS,
-                    180, 140, 90, 14
-
-    PUSHBUTTON      "gpgconf", IDC_GPG_CONF,
-                    180, 155, 90, 14
-
-    DEFPUSHBUTTON   "&OK", IDOK,
-                    180, 170, 90, 14
-
-END

commit 541333d406df77b67cf520f80619ae92e3b92cbc
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Jul 3 16:14:43 2018 +0200

    Change addion-options to use external dialog
    
    * src/addin-options.cpp (open_gpgolgui): New.
    (options_dialog_box): Open gpgolgui or bring it to foreground.
    (i18n_noops): Add strings.
    (launch_kleo_config): Removed.
    (options_window_proc): Removed.
    
    --
    This adds a new config dialog which is a dynamic qt application.
    It uses the translations from GpgOL.
    
    GnuPG-Bug-Id: T3944

diff --git a/src/addin-options.cpp b/src/addin-options.cpp
index bc36911..0286746 100644
--- a/src/addin-options.cpp
+++ b/src/addin-options.cpp
@@ -25,6 +25,8 @@
 #include <windows.h>
 #include "dialogs.h"
 #include "common.h"
+#include "cpphelp.h"
+#include "oomhelp.h"
 
 #include <string>
 
@@ -36,178 +38,125 @@ __attribute__((__unused__)) static char const *
 i18n_noops[] = {
     N_("GnuPG System"),
     N_("Enable the S/MIME support"),
+    N_("Configure GpgOL"),
+    N_("Automation"),
+    N_("General"),
+
+    N_("Automatically secure &messages"),
+    N_("Configure GnuPG"),
+    N_("Debug..."),
+    N_("Version "),
+    N_("&Resolve recipient keys automatically"),
+    N_("&Encrypt new messages by default"),
+    N_("&Sign new messages by default"),
+    N_("&Send OpenPGP mails without "
+       "attachments as PGP/Inline"),
+    N_("S&elect crypto settings automatically "
+       "for reply and forward"),
+
+    /* Tooltips */
+    N_("Enable or disable any automated key handling."),
+    N_("Automate trust based on communication history."),
+    N_("This changes the trust model to \"tofu+pgp\" which tracks the history of key usage. Automated trust can <b>never</b> exceed level 2."),
+    N_("experimental"),
+    N_("Automatically toggles secure if keys with at least level 1 trust were found for all recipients."),
+    N_("Toggles the encrypt option for all new mails."),
+    N_("Toggles the sign option for all new mails."),
+    N_("Toggles sign, encrypt options if the original mail was signed or encrypted."),
+    N_("Instead of using the PGP/MIME format, "
+       "which properly handles attachments and encoding, "
+       "the deprecated PGP/Inline is used.\n"
+       "This can be required for compatibility but should generally not "
+       "be used."),
 };
 
-/* 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.. */
-static void
-set_labels (HWND dlg)
-{
-  static struct { int itemid; const char *label; } labels[] = {
-    { IDC_G_GENERAL,        N_("General")},
-    { IDC_ENABLE_SMIME,     N_("Enable the S/MIME support")},
-
-    { IDC_G_SEND,           N_("Message sending")},
-    { IDC_ENCRYPT_DEFAULT,  N_("&Encrypt new messages by default")},
-    { IDC_SIGN_DEFAULT,     N_("&Sign new messages by default")},
-    { IDC_INLINE_PGP,       N_("&Send OpenPGP mails without "
-                               "attachments as PGP/Inline")},
-    { IDC_REPLYCRYPT,       N_("S&elect crypto settings automatically "
-                               "for reply and forward")},
-    { IDC_AUTORRESOLVE,     N_("&Resolve recipient keys automatically")},
-
-
-    { IDC_GPG_OPTIONS,      N_("Debug...")},
-    { IDC_GPG_CONF,         N_("Configure GnuPG")},
-    { IDC_VERSION_INFO,     N_("Version ")VERSION},
-    { 0, NULL}
-  };
-  int i;
-
-  for (i=0; labels[i].itemid; i++)
-    SetDlgItemText (dlg, labels[i].itemid, _(labels[i].label));
-}
+static bool dlg_open;
 
-static void
-launch_kleo_config (HWND hDlg)
+static DWORD WINAPI
+open_gpgolgui (LPVOID arg)
 {
-  char *uiserver = get_uiserver_name ();
-  bool showError = false;
-  if (uiserver)
+  HWND wnd = (HWND) arg;
+
+  std::vector<std::string> args;
+
+  // Collect the arguments
+  char *gpg4win_dir = get_gpg4win_dir ();
+  if (!gpg4win_dir)
     {
-      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;
-        }
+      TRACEPOINT;
+      return -1;
     }
-  else
+  const auto gpgolgui = std::string (gpg4win_dir) + "\\bin\\gpgolgui.exe";
+  args.push_back (gpgolgui);
+
+  args.push_back (std::string ("--hwnd"));
+  args.push_back (std::to_string ((int) (intptr_t) wnd));
+
+  args.push_back (std::string("--gpgol-version"));
+  args.push_back (std::string(VERSION));
+
+  auto ctx = GpgME::Context::createForEngine (GpgME::SpawnEngine);
+  if (!ctx)
     {
-      showError = true;
+      // can't happen
+      TRACEPOINT;
+      return -1;
     }
 
-  if (showError)
+  GpgME::Data mystdin (GpgME::Data::null), mystdout, mystderr;
+  dlg_open = true;
+
+  char **cargs = vector_to_cArray (args);
+  log_debug ("%s:%s: args:", SRCNAME, __func__);
+  for (size_t i = 0; cargs && cargs[i]; i++)
     {
-      MessageBox (NULL,
-                  _("Could not find Kleopatra.\n"
-                  "Please reinstall Gpg4win with the Kleopatra component enabled."),
-                  _("GpgOL"),
-                  MB_ICONINFORMATION|MB_OK);
+      log_debug (SIZE_T_FORMAT ": '%s'", i, cargs[i]);
     }
 
-}
-
-static INT_PTR CALLBACK
-options_window_proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
-  (void)lParam;
-  switch (uMsg)
+  GpgME::Error err = ctx->spawn (cargs[0], const_cast <const char**> (cargs),
+                                 mystdin, mystdout, mystderr,
+                                 (GpgME::Context::SpawnFlags) (
+                                  GpgME::Context::SpawnAllowSetFg |
+                                  GpgME::Context::SpawnShowWindow));
+  if (err)
     {
-      case WM_INITDIALOG:
-        {
-          SendDlgItemMessage (hDlg, IDC_ENABLE_SMIME, BM_SETCHECK,
-                              !!opt.enable_smime, 0L);
-          SendDlgItemMessage (hDlg, IDC_ENCRYPT_DEFAULT, BM_SETCHECK,
-                              !!opt.encrypt_default, 0L);
-          SendDlgItemMessage (hDlg, IDC_SIGN_DEFAULT, BM_SETCHECK,
-                              !!opt.sign_default, 0L);
-          SendDlgItemMessage (hDlg, IDC_INLINE_PGP, BM_SETCHECK,
-                              !!opt.inline_pgp, 0L);
-          SendDlgItemMessage (hDlg, IDC_REPLYCRYPT, BM_SETCHECK,
-                              !!opt.reply_crypt, 0L);
-          SendDlgItemMessage (hDlg, IDC_AUTORRESOLVE, BM_SETCHECK,
-                              !!opt.autoresolve, 0L);
-          set_labels (hDlg);
-          ShowWindow (GetDlgItem (hDlg, IDC_GPG_OPTIONS),
-                      opt.enable_debug ? SW_SHOW : SW_HIDE);
-        }
-      return 1;
-      case WM_LBUTTONDOWN:
-        {
-          return 1;
-        }
-      case WM_COMMAND:
-        switch (LOWORD (wParam))
-          {
-            case IDOK:
-              {
-                opt.enable_smime = !!SendDlgItemMessage
-                  (hDlg, IDC_ENABLE_SMIME, BM_GETCHECK, 0, 0L);
-
-                opt.encrypt_default = !!SendDlgItemMessage
-                  (hDlg, IDC_ENCRYPT_DEFAULT, BM_GETCHECK, 0, 0L);
-                opt.sign_default = !!SendDlgItemMessage
-                  (hDlg, IDC_SIGN_DEFAULT, BM_GETCHECK, 0, 0L);
-                opt.inline_pgp = !!SendDlgItemMessage
-                  (hDlg, IDC_INLINE_PGP, BM_GETCHECK, 0, 0L);
-
-                opt.reply_crypt = !!SendDlgItemMessage
-                  (hDlg, IDC_REPLYCRYPT, BM_GETCHECK, 0, 0L);
-
-                opt.autoresolve = !!SendDlgItemMessage
-                  (hDlg, IDC_AUTORRESOLVE, BM_GETCHECK, 0, 0L);
-
-                write_options ();
-                EndDialog (hDlg, TRUE);
-                break;
-              }
-            case IDC_GPG_CONF:
-              launch_kleo_config (hDlg);
-              break;
-            case IDC_GPG_OPTIONS:
-              config_dialog_box (hDlg);
-              break;
-          }
-      case WM_SYSCOMMAND:
-        switch (LOWORD (wParam))
-          {
-            case SC_CLOSE:
-              EndDialog (hDlg, TRUE);
-          }
-
-      break;
+      log_error ("%s:%s: Err code: %i asString: %s",
+                 SRCNAME, __func__, err.code(), err.asString());
     }
+  dlg_open = false;
+
+  log_debug ("%s:%s:finished stdout:\n'%s'",
+             SRCNAME, __func__, mystdout.toString ().c_str ());
+  log_debug ("%s:%s:stderr:\n'%s'",
+             SRCNAME, __func__, mystderr.toString ().c_str ());
+  read_options ();
   return 0;
 }
 
 void
 options_dialog_box (HWND parent)
 {
-  int resid;
+  if (!parent)
+    parent = get_active_hwnd ();
 
-  resid = IDD_ADDIN_OPTIONS;
+  if (dlg_open)
+    {
+      log_debug ("%s:%s: Gpgolgui open. Not launching new dialog.",
+                 SRCNAME, __func__);
+      HWND optWindow = FindWindow (nullptr, _("Configure GpgOL"));
+      if (!optWindow) {
+        log_debug ("%s:%s: Gpgolgui open but could not find window.",
+                 SRCNAME, __func__);
+        return;
+      }
+      SetForegroundWindow(optWindow);
+
+      return;
+    }
 
-  if (!parent)
-    parent = GetDesktopWindow ();
-  DialogBoxParam (glob_hinst, MAKEINTRESOURCE (resid), parent,
-                  options_window_proc, 0);
+  log_debug ("%s:%s: Launching gpgolgui.",
+             SRCNAME, __func__);
+
+  CloseHandle (CreateThread (NULL, 0, open_gpgolgui, (LPVOID) parent, 0,
+                             NULL));
 }

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

Summary of changes:
 src/addin-options.cpp | 253 ++++++++++++++++++++------------------------------
 src/dialogs.rc        | 135 ---------------------------
 2 files changed, 101 insertions(+), 287 deletions(-)


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




More information about the Gnupg-commits mailing list