summaryrefslogtreecommitdiff
path: root/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
diff options
context:
space:
mode:
authorKatarina Behrens <Katarina.Behrens@cib.de>2017-03-14 13:25:37 +0100
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2017-06-07 06:19:34 +0200
commit093f469eeec48e66050127e48f4a73f5c211621c (patch)
tree05d35dc900b5af5e0164fe3e28a5fe861fec0637 /xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
parent2f25f408228528395f722f9332020ba9b13ed334 (diff)
gpg4libre: add 'Start certificate manager' button
Change-Id: Ief3239fd1b3ff1f4e2e95e4413aa9f707f3dfb50 Reviewed-on: https://gerrit.libreoffice.org/36689 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> (cherry picked from commit 28ae89f4655ee7d630f2400e3994c227dcf47f70) Reviewed-on: https://gerrit.libreoffice.org/38478 Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Diffstat (limited to 'xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx')
-rw-r--r--xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx47
1 files changed, 46 insertions, 1 deletions
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index b88dd97337f8..f691ab063157 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -35,8 +35,11 @@
#include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
#include <com/sun/star/xml/dom/XDocumentBuilder.hpp>
#include <com/sun/star/packages/manifest/ManifestReader.hpp>
+#include <com/sun/star/system/SystemShellExecute.hpp>
+#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
+#include <com/sun/star/system/SystemShellExecuteException.hpp>
-
+#include <osl/file.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/uri.hxx>
@@ -119,6 +122,7 @@ DigitalSignaturesDialog::DigitalSignaturesDialog(
get(m_pAddBtn, "sign");
get(m_pRemoveBtn, "remove");
get(m_pCloseBtn, "close");
+ get(m_pStartCertMgrBtn, "start_certmanager");
get(m_pSigsValidImg, "validimg");
get(m_pSigsValidFI, "validft");
get(m_pSigsInvalidImg, "invalidimg");
@@ -165,6 +169,8 @@ DigitalSignaturesDialog::DigitalSignaturesDialog(
m_pRemoveBtn->SetClickHdl( LINK( this, DigitalSignaturesDialog, RemoveButtonHdl ) );
m_pRemoveBtn->Disable();
+ m_pStartCertMgrBtn->SetClickHdl( LINK( this, DigitalSignaturesDialog, CertMgrButtonHdl ) );
+
m_pCloseBtn->SetClickHdl( LINK( this, DigitalSignaturesDialog, OKButtonHdl) );
switch( maSignatureManager.meSignatureMode )
@@ -205,6 +211,7 @@ void DigitalSignaturesDialog::dispose()
m_pAddBtn.clear();
m_pRemoveBtn.clear();
m_pCloseBtn.clear();
+ m_pStartCertMgrBtn.clear();
ModalDialog::dispose();
}
@@ -445,6 +452,44 @@ IMPL_LINK_NOARG(DigitalSignaturesDialog, RemoveButtonHdl, Button*, void)
}
}
+IMPL_STATIC_LINK_NOARG(DigitalSignaturesDialog, CertMgrButtonHdl, Button*, void)
+{
+ const OUString aGUIServers[] = { OUString("kleopatra"), OUString("gpa"), OUString("kgpg") };
+ // FIXME: the same for Windows + registry search for gpg4win
+ const char* cPath = getenv("PATH");
+
+ if (cPath)
+ {
+ OUString aPath(cPath, strlen(cPath), osl_getThreadTextEncoding());
+ OUString sFoundGUIServer, sExecutable;
+
+ for ( auto const &rServer : aGUIServers )
+ {
+ osl::FileBase::RC searchError = osl::File::searchFileURL(rServer, aPath, sFoundGUIServer );
+ if (searchError == osl::FileBase::E_None)
+ {
+ osl::File::getSystemPathFromFileURL( sFoundGUIServer, sExecutable );
+ break;
+ }
+
+ }
+
+ if ( !sExecutable.isEmpty() )
+ {
+ uno::Reference< uno::XComponentContext > xContext =
+ ::comphelper::getProcessComponentContext();
+ uno::Reference< css::system::XSystemShellExecute > xSystemShell(
+ css::system::SystemShellExecute::create(xContext) );
+
+ xSystemShell->execute( sExecutable, OUString(),
+ css::system::SystemShellExecuteFlags::DEFAULTS );
+ }
+ //else FIXME: none of the certificate managers' there
+
+ }
+
+}
+
IMPL_LINK_NOARG(DigitalSignaturesDialog, StartVerifySignatureHdl, LinkParamNone*, bool)
{
return mbVerifySignatures;