[git] GpgOL - branch, master, updated. gpgol-2.2.0-19-ga41e34f

by Andre Heinecke cvs at cvs.gnupg.org
Fri Jun 22 17:09:11 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  a41e34fde420cff26e2c09316259cedcbde649f2 (commit)
       via  746c9df891eefe4dedb2e0c13f9fa9c8eed59405 (commit)
       via  696419405e9bba5a2c7d8dd602a42dc7d9e80990 (commit)
      from  b853a5a70e325c80628edf4720e3ccb6030f1860 (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 a41e34fde420cff26e2c09316259cedcbde649f2
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Jun 22 17:06:21 2018 +0200

    Take language from Outlook instead of the system
    
    * src/oomhelp.cpp (invoke_oom_method_with_parms_type): New.
    Helper to allow invokes with a custom type.
    (invoke_oom_method_with_parms): Use it.
    (get_ol_ui_language): New. Read out the UI language of outlook.
    * src/w32-gettext.c (_nl_locale_name): Use it.
    * src/oomhelp.h: Update accordingly.
    
    --
    It makes sense to use the same language as outlook does. Users
    will find anything else confusing and broken.
    
    This also makes it easier to switch languages for screenshots :-P

diff --git a/src/oomhelp.cpp b/src/oomhelp.cpp
index 29fca98..b0097d0 100644
--- a/src/oomhelp.cpp
+++ b/src/oomhelp.cpp
@@ -1412,9 +1412,10 @@ get_oom_base_message (LPDISPATCH mailitem)
   return ret;
 }
 
-int
-invoke_oom_method_with_parms (LPDISPATCH pDisp, const char *name,
-                              VARIANT *rVariant, DISPPARAMS *params)
+static int
+invoke_oom_method_with_parms_type (LPDISPATCH pDisp, const char *name,
+                                   VARIANT *rVariant, DISPPARAMS *params,
+                                   int type)
 {
   HRESULT hr;
   DISPID dispid;
@@ -1427,7 +1428,7 @@ invoke_oom_method_with_parms (LPDISPATCH pDisp, const char *name,
       DISPPARAMS dispparams = {NULL, NULL, 0, 0};
 
       hr = pDisp->Invoke (dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT,
-                          DISPATCH_METHOD, params ? params : &dispparams,
+                          type, params ? params : &dispparams,
                           rVariant, &execpinfo, NULL);
       if (hr != S_OK)
         {
@@ -1442,6 +1443,14 @@ invoke_oom_method_with_parms (LPDISPATCH pDisp, const char *name,
 }
 
 int
+invoke_oom_method_with_parms (LPDISPATCH pDisp, const char *name,
+                              VARIANT *rVariant, DISPPARAMS *params)
+{
+  return invoke_oom_method_with_parms_type (pDisp, name, rVariant, params,
+                                            DISPATCH_METHOD);
+}
+
+int
 invoke_oom_method (LPDISPATCH pDisp, const char *name, VARIANT *rVariant)
 {
   return invoke_oom_method_with_parms (pDisp, name, rVariant, NULL);
@@ -2061,3 +2070,52 @@ get_ex_major_version_for_addr (const char *mbox)
 
   return (int) version;
 }
+
+int
+get_ol_ui_language ()
+{
+  LPDISPATCH app = GpgolAddin::get_instance()->get_application();
+  if (!app)
+    {
+      TRACEPOINT;
+      return 0;
+    }
+
+  LPDISPATCH langSettings = get_oom_object (app, "LanguageSettings");
+  if (!langSettings)
+    {
+      TRACEPOINT;
+      return 0;
+    }
+
+  VARIANT var;
+  VariantInit (&var);
+
+  VARIANT aVariant[1];
+  DISPPARAMS dispparams;
+
+  dispparams.rgvarg = aVariant;
+  dispparams.rgvarg[0].vt = VT_INT;
+  dispparams.rgvarg[0].intVal = 2;
+  dispparams.cArgs = 1;
+  dispparams.cNamedArgs = 0;
+
+  if (invoke_oom_method_with_parms_type (langSettings, "LanguageID", &var,
+                                         &dispparams,
+                                         DISPATCH_PROPERTYGET))
+    {
+      TRACEPOINT;
+      return 0;
+    }
+  if (var.vt != VT_INT && var.vt != VT_I4)
+    {
+      TRACEPOINT;
+      return 0;
+    }
+
+  int result = var.intVal;
+
+  log_debug ("XXXXX %i", result);
+  VariantClear (&var);
+  return result;
+}
diff --git a/src/oomhelp.h b/src/oomhelp.h
index c2afd4a..ac6d2bb 100644
--- a/src/oomhelp.h
+++ b/src/oomhelp.h
@@ -350,6 +350,9 @@ char *get_inline_body (void);
    or exchange is not used.*/
 int get_ex_major_version_for_addr (const char *mbox);
 
+/* Get the language code used for Outlooks UI */
+int get_ol_ui_language (void);
+
 #ifdef __cplusplus
 char *get_sender_SendUsingAccount (LPDISPATCH mailitem, bool *r_is_GSuite);
 }
diff --git a/src/w32-gettext.c b/src/w32-gettext.c
index 30ff0a0..081f050 100644
--- a/src/w32-gettext.c
+++ b/src/w32-gettext.c
@@ -69,6 +69,8 @@
 #include <stdlib.h>
 #include <locale.h>
 
+#include <oomhelp.h>
+
 #ifdef HAVE_W32_SYSTEM
 # include <windows.h>
 /* List of language codes, sorted by value:
@@ -787,8 +789,14 @@ _nl_locale_name (int category, const char *categoryname)
   if (retval != NULL && retval[0] != '\0')
     return retval;
 
-  /* Use native Win32 API locale ID.  */
-  lcid = GetThreadLocale ();
+  /* Prefer the Ui language of Outlook. */
+  lcid = get_ol_ui_language ();
+
+  if (!lcid)
+    {
+      /* Use native Win32 API locale ID.  */
+      lcid = GetThreadLocale ();
+    }
 
   /* Strip off the sorting rules, keep only the language part.  */
   langid = LANGIDFROMLCID (lcid);

commit 746c9df891eefe4dedb2e0c13f9fa9c8eed59405
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Jun 22 17:05:19 2018 +0200

    Remove code about compat flags
    
    * src/main.c (read_options): Remove compat flags handling.
    
    --
    This was no longer used and contained the only i18n call
    before the "OnStartupComplete" callback.

diff --git a/src/main.c b/src/main.c
index e479bb0..e0d553d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -216,7 +216,6 @@ drop_locale_dir (char *locale_dir)
 void
 read_options (void)
 {
-  static int warnings_shown;
   char *val = NULL;
 
   /* Set the log file first so that output from this function is
@@ -333,48 +332,6 @@ read_options (void)
   load_extension_value ("autosecure", &val);
   opt.autosecure = val == NULL ? 1 : *val != '1' ? 0 : 1;
   xfree (val); val = NULL;
-  /* Note, that on purpose these flags are only Registry changeable.
-     The format of the entry is a string of of "0" and "1" digits; see
-     the switch below for a description. */
-  memset (&opt.compat, 0, sizeof opt.compat);
-  load_extension_value ("compatFlags", &val);
-  if (val)
-    {
-      const char *s = val;
-      int i, x;
-
-      for (s=val, i=0; *s; s++, i++)
-        {
-          x = *s == '1';
-          switch (i)
-            {
-            case 0: opt.compat.no_msgcache = x; break;
-            case 1: opt.compat.no_pgpmime = x; break;
-            case 2: opt.compat.no_oom_write = x; break;
-            case 3: opt.compat.no_preview_info = x; break;
-            case 4: opt.compat.old_reply_hack = x; break;
-            case 5: opt.compat.auto_decrypt = x; break;
-            case 6: opt.compat.no_attestation = x; break;
-            case 7: opt.compat.use_mwfmo = x; break;
-            }
-        }
-      log_debug ("Note: using compatibility flags: %s", val);
-    }
-
-  if (!warnings_shown)
-    {
-      char tmpbuf[512];
-
-      warnings_shown = 1;
-      if (val && *val)
-        {
-          snprintf (tmpbuf, sizeof tmpbuf,
-                    _("Note: Using compatibility flags: %s"), val);
-          MessageBox (NULL, tmpbuf, _("GpgOL"), MB_ICONWARNING|MB_OK);
-        }
-    }
-  xfree (val); val = NULL;
-
 }
 
 

commit 696419405e9bba5a2c7d8dd602a42dc7d9e80990
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Jun 22 17:03:08 2018 +0200

    Move i18n_init after the addin connecction
    
    * src/common.h (i18n_init): Expose.
    * src/main.c (DllMain): Don't init here.
    (i18n_init): No longer static.
    * src/gpgoladdin.cpp (GpgolAddin::OnStartupComplete): Call it.
    
    --
    This ensures that the Application object is accessible when
    initializing i18n.

diff --git a/src/common.h b/src/common.h
index 177bf6a..265955c 100644
--- a/src/common.h
+++ b/src/common.h
@@ -148,6 +148,7 @@ int gpgol_message_box (HWND parent, const char *utf8_text,
 /* Show a bug message with the code. */
 void gpgol_bug (HWND parent, int code);
 
+void i18n_init (void);
 #define ERR_CRYPT_RESOLVER_FAILED 1
 #define ERR_WANTS_SEND_MIME_BODY 2
 #define ERR_WANTS_SEND_INLINE_BODY 3
diff --git a/src/gpgoladdin.cpp b/src/gpgoladdin.cpp
index 95ec7c7..b43ef6f 100644
--- a/src/gpgoladdin.cpp
+++ b/src/gpgoladdin.cpp
@@ -483,6 +483,8 @@ GpgolAddin::OnStartupComplete (SAFEARRAY** custom)
   (void)custom;
   TRACEPOINT;
 
+  i18n_init ();
+
   if (!create_responder_window())
     {
       log_error ("%s:%s: Failed to create the responder window;",
diff --git a/src/main.c b/src/main.c
index 2d3590e..e479bb0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -82,7 +82,7 @@ get_crypt_random (size_t nbytes)
 }
 
 
-static void
+void
 i18n_init (void)
 {
   char *locale_dir;
@@ -158,7 +158,6 @@ DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved)
       /* Early initializations of our subsystems. */
       if (initialize_main ())
         return FALSE;
-      i18n_init ();
     }
   else if (reason == DLL_PROCESS_DETACH)
     {

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

Summary of changes:
 src/common.h       |  1 +
 src/gpgoladdin.cpp |  2 ++
 src/main.c         | 46 +------------------------------------
 src/oomhelp.cpp    | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 src/oomhelp.h      |  3 +++
 src/w32-gettext.c  | 12 ++++++++--
 6 files changed, 79 insertions(+), 51 deletions(-)


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




More information about the Gnupg-commits mailing list