diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2017-12-12 14:03:05 +0100 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2017-12-19 01:22:30 +0100 |
commit | e0c3e356fd9151819db13d844f87ec200e2dbee3 (patch) | |
tree | cc6044fe1d965c922045fd9b0eda8f4b6c13c9fa /cui | |
parent | 40e1cb217396c7183ea3a7379a8a15c8df3aea2e (diff) |
List private GPG keys in crypto config dialog
Change-Id: I7cb6a14adcc5424b432589120c66deeddf86b652
Reviewed-on: https://gerrit.libreoffice.org/46691
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/inc/cuioptgenrl.hxx | 6 | ||||
-rw-r--r-- | cui/source/options/optgenrl.cxx | 56 | ||||
-rw-r--r-- | cui/uiconfig/ui/optuserpage.ui | 27 |
3 files changed, 73 insertions, 16 deletions
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 <svx/optgenrl.hxx> #include <sfx2/tabdlg.hxx> #include <vcl/fixed.hxx> +#include <vcl/layout.hxx> #include <vector> @@ -40,6 +41,10 @@ class SvxGeneralTabPage : public SfxTabPage private: // the "Use data for document properties" checkbox VclPtr<CheckBox> m_pUseDataCB; + VclPtr<VclContainer> m_pCryptoFrame; + VclPtr<ListBox> m_pSigningKeyLB; + VclPtr<ListBox> m_pEncryptionKeyLB; + VclPtr<CheckBox> m_pEncryptToSelfCB; // rows struct Row; std::vector<std::shared_ptr<Row> > 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 <unotools/saveopt.hxx> #include <svl/intitem.hxx> #include <vcl/edit.hxx> +#include <vcl/lstbox.hxx> #include <vcl/settings.hxx> #include <unotools/useroptions.hxx> @@ -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<xml::crypto::XXMLSecurityContext> 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<xml::crypto::XXMLSecurityContext> xSC = xSEInitializer->createSecurityContext( OUString() ); + uno::Reference<xml::crypto::XSecurityEnvironment> xSE = xSC->getSecurityEnvironment(); + uno::Sequence<uno::Reference<security::XCertificate>> 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 @@ <!-- Generated with glade 3.20.0 --> <interface domain="cui"> <requires lib="gtk+" version="3.0"/> + <object class="GtkListStore" id="liststore1"> + <columns> + <!-- column-name gchararray1 --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes" context="optuserpage|liststore1">No key</col> + </row> + </data> + </object> <object class="GtkBox" id="OptUserPage"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -825,7 +836,8 @@ </packing> </child> <child> - <object class="GtkFrame" id="frame2"> + <object class="GtkFrame" id="cryptography"> + <property name="visible">True</property> <property name="can_focus">False</property> <property name="label_xalign">0</property> <property name="shadow_type">none</property> @@ -837,11 +849,13 @@ <property name="left_padding">12</property> <child> <object class="GtkGrid" id="grid14"> + <property name="visible">True</property> <property name="can_focus">False</property> <property name="row_spacing">6</property> <property name="column_spacing">12</property> <child> <object class="GtkLabel" id="signingkeylabel"> + <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">end</property> <property name="label" translatable="yes" context="optuserpage|signingkeylabel">OpenPGP signing key:</property> @@ -855,6 +869,7 @@ </child> <child> <object class="GtkLabel" id="encryptionkeylabel"> + <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">end</property> <property name="label" translatable="yes" context="optuserpage|encryptionkeylabel">OpenPGP encryption key:</property> @@ -869,6 +884,8 @@ <child> <object class="GtkComboBox" id="encryptionkey"> <property name="can_focus">False</property> + <property name="visible">True</property> + <property name="model">liststore1</property> </object> <packing> <property name="left_attach">1</property> @@ -877,7 +894,9 @@ </child> <child> <object class="GtkComboBox" id="signingkey"> + <property name="visible">True</property> <property name="can_focus">False</property> + <property name="model">liststore1</property> </object> <packing> <property name="left_attach">1</property> @@ -888,6 +907,7 @@ <object class="GtkCheckButton" id="encrypttoself"> <property name="label" translatable="yes" context="optuserpage|encrypttoself">When encrypting documents, always encrypt to self</property> <property name="can_focus">True</property> + <property name="visible">True</property> <property name="receives_default">False</property> <property name="draw_indicator">True</property> </object> @@ -904,9 +924,10 @@ </object> </child> <child type="label"> - <object class="GtkLabel" id="label2"> + <object class="GtkLabel" id="cryptographylabel"> <property name="can_focus">False</property> - <property name="label" translatable="yes" context="optuserpage|label2">Cryptography</property> + <property name="visible">True</property> + <property name="label" translatable="yes" context="optuserpage|cryptographylabel">Cryptography</property> <property name="use_underline">True</property> <attributes> <attribute name="weight" value="bold"/> |