From e0c3e356fd9151819db13d844f87ec200e2dbee3 Mon Sep 17 00:00:00 2001 From: Katarina Behrens Date: Tue, 12 Dec 2017 14:03:05 +0100 Subject: List private GPG keys in crypto config dialog Change-Id: I7cb6a14adcc5424b432589120c66deeddf86b652 Reviewed-on: https://gerrit.libreoffice.org/46691 Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens --- cui/source/inc/cuioptgenrl.hxx | 6 +++++ cui/source/options/optgenrl.cxx | 56 +++++++++++++++++++++++++++++++---------- cui/uiconfig/ui/optuserpage.ui | 27 +++++++++++++++++--- 3 files changed, 73 insertions(+), 16 deletions(-) (limited to 'cui') diff --git a/cui/source/inc/cuioptgenrl.hxx b/cui/source/inc/cuioptgenrl.hxx index 0c56b6cdcde6..b612ccf687ff 100644 --- a/cui/source/inc/cuioptgenrl.hxx +++ b/cui/source/inc/cuioptgenrl.hxx @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -40,6 +41,10 @@ class SvxGeneralTabPage : public SfxTabPage private: // the "Use data for document properties" checkbox VclPtr m_pUseDataCB; + VclPtr m_pCryptoFrame; + VclPtr m_pSigningKeyLB; + VclPtr m_pEncryptionKeyLB; + VclPtr m_pEncryptToSelfCB; // rows struct Row; std::vector > vRows; @@ -56,6 +61,7 @@ private: void SetData_Impl(); void InitControls (); + void InitCryptography(); void SetLinks (); protected: diff --git a/cui/source/options/optgenrl.cxx b/cui/source/options/optgenrl.cxx index 5750cc9ff7a0..b63fbf580b69 100644 --- a/cui/source/options/optgenrl.cxx +++ b/cui/source/options/optgenrl.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -211,22 +212,20 @@ SvxGeneralTabPage::SvxGeneralTabPage(vcl::Window* pParent, const SfxItemSet& rCo : SfxTabPage(pParent, "OptUserPage", "cui/ui/optuserpage.ui", &rCoreSet) { get(m_pUseDataCB, "usefordocprop"); + + get(m_pCryptoFrame, "cryptography"); + get(m_pSigningKeyLB, "signingkey"); + get(m_pEncryptionKeyLB, "encryptionkey"); + get(m_pEncryptToSelfCB, "encrypttoself"); InitControls(); - SetExchangeSupport(); // this page needs ExchangeSupport - SetLinks(); #if HAVE_FEATURE_GPGME - // unused yet, I just wanted to see if this delivers the desired results - uno::Reference< xml::crypto::XSEInitializer > xSEInitializer; - try - { - xSEInitializer = xml::crypto::GPGSEInitializer::create( comphelper::getProcessComponentContext() ); - uno::Reference xSC = xSEInitializer->createSecurityContext( OUString() ); - // completely bogus, this is just to appease loplugins - xSEInitializer->freeSecurityContext( xSC ); - } - catch ( uno::Exception const & ) - {} + InitCryptography(); +#else + m_pCryptoFrame->Hide(); #endif + + SetExchangeSupport(); // this page needs ExchangeSupport + SetLinks(); } SvxGeneralTabPage::~SvxGeneralTabPage() @@ -237,6 +236,10 @@ SvxGeneralTabPage::~SvxGeneralTabPage() void SvxGeneralTabPage::dispose() { m_pUseDataCB.clear(); + m_pSigningKeyLB.clear(); + m_pEncryptionKeyLB.clear(); + m_pEncryptToSelfCB.clear(); + m_pCryptoFrame.clear(); SfxTabPage::dispose(); } @@ -295,6 +298,33 @@ void SvxGeneralTabPage::InitControls () } } +void SvxGeneralTabPage::InitCryptography() +{ +#if HAVE_FEATURE_GPGME + m_pCryptoFrame->Show(); + // unused yet, I just wanted to see if this delivers the desired results + uno::Reference< xml::crypto::XSEInitializer > xSEInitializer; + try + { + xSEInitializer = xml::crypto::GPGSEInitializer::create( comphelper::getProcessComponentContext() ); + uno::Reference xSC = xSEInitializer->createSecurityContext( OUString() ); + uno::Reference xSE = xSC->getSecurityEnvironment(); + uno::Sequence> xCertificates = xSE->getPersonalCertificates(); + + if (xCertificates.hasElements()) + { + for (auto& xCert : xCertificates) + { + m_pSigningKeyLB->InsertEntry( xCert->getIssuerName()); + m_pEncryptionKeyLB->InsertEntry( xCert->getIssuerName()); + } + } + } + catch ( uno::Exception const & ) + {} +#endif + +} void SvxGeneralTabPage::SetLinks () { diff --git a/cui/uiconfig/ui/optuserpage.ui b/cui/uiconfig/ui/optuserpage.ui index ad893936cb0f..96c0a77cfad0 100644 --- a/cui/uiconfig/ui/optuserpage.ui +++ b/cui/uiconfig/ui/optuserpage.ui @@ -2,6 +2,17 @@ + + + + + + + + No key + + + True False @@ -825,7 +836,8 @@ - + + True False 0 none @@ -837,11 +849,13 @@ 12 + True False 6 12 + True False end OpenPGP signing key: @@ -855,6 +869,7 @@ + True False end OpenPGP encryption key: @@ -869,6 +884,8 @@ False + True + liststore1 1 @@ -877,7 +894,9 @@ + True False + liststore1 1 @@ -888,6 +907,7 @@ When encrypting documents, always encrypt to self True + True False True @@ -904,9 +924,10 @@ - + False - Cryptography + True + Cryptography True -- cgit