summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2019-08-14 12:58:49 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2019-08-14 13:26:02 +0200
commit9c8854b7d6e5c9debc7eeae57c0d51a3f151a03e (patch)
tree7e4e41dd520d65d184eefa2cd3c6094e137e6ed4 /xmlsecurity
parent744f70386727c78a19bd7c1de7425392b98783c7 (diff)
Don't hardcode "C:\\Program Files (x86)" path on Windows
It might be simple "Program Files" on 32-bit system; or localized (see https://www.samlogic.net/articles/program-files-folder-different-languages.htm), or on a different drive (if system isn't on C:), etc. Change-Id: Id0f28b4c4920fcda53a58fbff9f42bcfde6668f6 Reviewed-on: https://gerrit.libreoffice.org/77448 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/Library_xmlsecurity.mk2
-rw-r--r--xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx23
2 files changed, 23 insertions, 2 deletions
diff --git a/xmlsecurity/Library_xmlsecurity.mk b/xmlsecurity/Library_xmlsecurity.mk
index 9a65dd2152a9..5a80e6e17591 100644
--- a/xmlsecurity/Library_xmlsecurity.mk
+++ b/xmlsecurity/Library_xmlsecurity.mk
@@ -83,6 +83,8 @@ $(eval $(call gb_Library_add_defs,xmlsecurity,\
))
$(eval $(call gb_Library_use_system_win32_libs,xmlsecurity,\
crypt32 \
+ Ole32 \
+ Shell32 \
))
else
ifneq (,$(filter DESKTOP,$(BUILD_TYPE))$(filter ANDROID,$(OS)))
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index 032171928c88..67545e3bb561 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -59,6 +59,12 @@
#include <vcl/svapp.hxx>
#include <unotools/configitem.hxx>
+#ifdef _WIN32
+#include <o3tl/char16_t2wchar_t.hxx>
+#include <prewin.h>
+#include <Shlobj.h>
+#endif
+
using namespace comphelper;
using namespace css::security;
using namespace css::uno;
@@ -457,15 +463,28 @@ IMPL_LINK_NOARG(DigitalSignaturesDialog, CertMgrButtonHdl, weld::Button&, void)
OUString("GNU\\GnuPG\\bin\\kleopatra.exe"),
OUString("GNU\\GnuPG\\bin\\launch-gpa.exe"),
OUString("GNU\\GnuPG\\bin\\gpa.exe") };
- const char* const cPath = "C:\\Program Files (x86)";
+ static const OUString aPath = [] {
+ OUString sRet;
+ PWSTR sPath = nullptr;
+ HRESULT hr
+ = SHGetKnownFolderPath(FOLDERID_ProgramFilesX86, KF_FLAG_DEFAULT, nullptr, &sPath);
+ if (SUCCEEDED(hr))
+ {
+ sRet = o3tl::toU(sPath);
+ CoTaskMemFree(sPath);
+ }
+ return sRet;
+ }();
+ if (aPath.isEmpty())
+ return;
#else
const OUString aGUIServers[] = { OUString("kleopatra"), OUString("seahorse"), OUString("gpa"), OUString("kgpg") };
const char* cPath = getenv("PATH");
if (!cPath)
return;
+ OUString aPath(cPath, strlen(cPath), osl_getThreadTextEncoding());
#endif
- OUString aPath(cPath, strlen(cPath), osl_getThreadTextEncoding());
OUString sFoundGUIServer, sExecutable;
for ( auto const &rServer : aGUIServers )