[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - 2 commits - cui/source include/unotools unotools/source
Katarina Behrens
Katarina.Behrens at cib.de
Tue Dec 19 07:24:19 UTC 2017
cui/source/options/optgenrl.cxx | 38 ++++++++++++++++++++++-
include/unotools/useroptions.hxx | 9 ++++-
unotools/source/config/useroptions.cxx | 54 ++++++++++++++++++++++++++++++---
3 files changed, 94 insertions(+), 7 deletions(-)
New commits:
commit 9c885a05430cf284512e0cb79fc2a996a294aa30
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Thu Dec 14 13:14:02 2017 +0100
Read/write 'encrypt to self' bit
use some template functions to avoid duplicate code
Change-Id: Ia178ea3a0561e34e0431749262f5f8f1f49b4fe7
Reviewed-on: https://gerrit.libreoffice.org/46693
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Reviewed-on: https://gerrit.libreoffice.org/46762
diff --git a/cui/source/options/optgenrl.cxx b/cui/source/options/optgenrl.cxx
index 83a98e60c7b0..c25144f04266 100644
--- a/cui/source/options/optgenrl.cxx
+++ b/cui/source/options/optgenrl.cxx
@@ -443,11 +443,14 @@ bool SvxGeneralTabPage::GetData_Impl()
: m_pSigningKeyLB->GetSelectedEntry();
OUString aEK = m_pEncryptionKeyLB->GetSelectedEntryPos() == 0 ? OUString()
: m_pEncryptionKeyLB->GetSelectedEntry();
+
aUserOpt.SetToken( UserOptToken::SigningKey, aSK );
aUserOpt.SetToken( UserOptToken::EncryptionKey, aEK );
+ aUserOpt.SetBoolValue( UserOptToken::EncryptToSelf, m_pEncryptToSelfCB->IsChecked() );
- bModified |= m_pSigningKeyLB->IsValueChangedFromSaved();
- bModified |= m_pEncryptionKeyLB->IsValueChangedFromSaved();
+ bModified |= m_pSigningKeyLB->IsValueChangedFromSaved() ||
+ m_pEncryptionKeyLB->IsValueChangedFromSaved() ||
+ m_pEncryptToSelfCB->IsValueChangedFromSaved();
#endif
return bModified;
@@ -489,6 +492,8 @@ void SvxGeneralTabPage::SetData_Impl()
OUString aEK = aUserOpt.GetToken(UserOptToken::EncryptionKey);
aEK.isEmpty() ? m_pEncryptionKeyLB->SelectEntryPos( 0 ) //i.e. 'No Key'
: m_pEncryptionKeyLB->SelectEntry( aEK );
+
+ m_pEncryptToSelfCB->Check( aUserOpt.GetEncryptToSelf() );
#endif
}
diff --git a/include/unotools/useroptions.hxx b/include/unotools/useroptions.hxx
index 946ba8d34c10..60c18df65ae2 100644
--- a/include/unotools/useroptions.hxx
+++ b/include/unotools/useroptions.hxx
@@ -47,7 +47,8 @@ enum class UserOptToken
Apartment = 16,
SigningKey = 17,
EncryptionKey = 18,
- LAST = EncryptionKey,
+ EncryptToSelf = 19,
+ LAST = EncryptToSelf,
};
// class SvtUserOptions --------------------------------------------------
@@ -78,12 +79,14 @@ public:
OUString GetEmail () const;
OUString GetSigningKey () const;
OUString GetEncryptionKey () const;
+ bool GetEncryptToSelf () const;
OUString GetFullName () const;
bool IsTokenReadonly (UserOptToken nToken) const;
OUString GetToken (UserOptToken nToken) const;
void SetToken (UserOptToken nToken, OUString const& rNewToken);
+ void SetBoolValue (UserOptToken nToken, bool bNewValue);
private:
class Impl;
diff --git a/unotools/source/config/useroptions.cxx b/unotools/source/config/useroptions.cxx
index e19168da2885..adf58180204a 100644
--- a/unotools/source/config/useroptions.cxx
+++ b/unotools/source/config/useroptions.cxx
@@ -67,7 +67,8 @@ static o3tl::enumarray<UserOptToken, char const *> vOptionNames = {
"fathersname", // UserOptToken::FathersName
"apartment", // UserOptToken::Apartment
"signingkey", // UserOptToken::SigningKey
- "encryptionkey" // UserOptToken::EncryptionKey
+ "encryptionkey", // UserOptToken::EncryptionKey
+ "encrypttoself" // UserOptToken::EncryptToSelf
};
std::weak_ptr<SvtUserOptions::Impl> SvtUserOptions::xSharedImpl;
@@ -96,12 +97,19 @@ public:
bool IsTokenReadonly (UserOptToken nToken) const;
OUString GetToken (UserOptToken nToken) const;
void SetToken (UserOptToken nToken, OUString const& rNewToken);
+ bool GetBoolValue (UserOptToken nToken) const;
+ void SetBoolValue (UserOptToken nToken, bool& bNewValue);
void Notify ();
private:
uno::Reference<util::XChangesListener> m_xChangeListener;
uno::Reference<container::XNameAccess> m_xCfg;
uno::Reference<beans::XPropertySet> m_xData;
+
+ template < typename ValueType >
+ ValueType GetValue_Impl( UserOptToken nToken ) const;
+ template < typename ValueType >
+ void SetValue_Impl( UserOptToken nToken, ValueType const& rNewValue );
};
void SvtUserOptions::ChangeListener::changesOccurred (util::ChangesEvent const& rEvent)
@@ -153,9 +161,10 @@ SvtUserOptions::Impl::Impl() :
}
}
-OUString SvtUserOptions::Impl::GetToken (UserOptToken nToken) const
+template < typename ValueType >
+ValueType SvtUserOptions::Impl::GetValue_Impl (UserOptToken nToken) const
{
- OUString sToken;
+ ValueType sToken = ValueType();
try
{
if (m_xData.is())
@@ -168,7 +177,8 @@ OUString SvtUserOptions::Impl::GetToken (UserOptToken nToken) const
return sToken;
}
-void SvtUserOptions::Impl::SetToken (UserOptToken nToken, OUString const& sToken)
+template < typename ValueType >
+void SvtUserOptions::Impl::SetValue_Impl (UserOptToken nToken, ValueType const& sToken)
{
try
{
@@ -182,6 +192,26 @@ void SvtUserOptions::Impl::SetToken (UserOptToken nToken, OUString const& sToken
}
}
+OUString SvtUserOptions::Impl::GetToken (UserOptToken nToken) const
+{
+ return GetValue_Impl<OUString>( nToken );
+}
+
+void SvtUserOptions::Impl::SetToken (UserOptToken nToken, OUString const& sToken)
+{
+ SetValue_Impl<OUString>( nToken, sToken );
+}
+
+bool SvtUserOptions::Impl::GetBoolValue (UserOptToken nToken) const
+{
+ return GetValue_Impl<bool>( nToken );
+}
+
+void SvtUserOptions::Impl::SetBoolValue (UserOptToken nToken, bool& bNewValue)
+{
+ SetValue_Impl<bool>( nToken, bNewValue );
+}
+
OUString SvtUserOptions::Impl::GetFullName () const
{
OUString sFullName;
@@ -299,6 +329,18 @@ void SvtUserOptions::SetToken (UserOptToken nToken, OUString const& rNewToken)
xImpl->SetToken(nToken, rNewToken);
}
+void SvtUserOptions::SetBoolValue (UserOptToken nToken, bool bNewValue)
+{
+ osl::MutexGuard aGuard(GetInitMutex());
+ xImpl->SetBoolValue(nToken, bNewValue);
+}
+
+bool SvtUserOptions::GetEncryptToSelf() const
+{
+ osl::MutexGuard aGuard(GetInitMutex());
+ return xImpl->GetBoolValue(UserOptToken::EncryptToSelf);
+}
+
OUString SvtUserOptions::GetFullName () const
{
osl::MutexGuard aGuard(GetInitMutex());
commit 9bf4d471928036cdc4c0c3f6e8d7a42ecdbd032a
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Wed Dec 13 18:39:10 2017 +0100
Read/write preferred GPG signing/encryption keys
Reviewed-on: https://gerrit.libreoffice.org/46692
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
(cherry picked from commit df4fac1dbce087bbd01bbec242b93c72edcef74b)
Change-Id: I3e21469c5f4c4f199407bbe9faba2e2ddca531b3
Reviewed-on: https://gerrit.libreoffice.org/46760
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/cui/source/options/optgenrl.cxx b/cui/source/options/optgenrl.cxx
index b63fbf580b69..83a98e60c7b0 100644
--- a/cui/source/options/optgenrl.cxx
+++ b/cui/source/options/optgenrl.cxx
@@ -428,10 +428,29 @@ bool SvxGeneralTabPage::GetData_Impl()
);
// modified?
+ bool bModified = false;
for (auto const & i: vFields)
+ {
if (i->pEdit->IsValueChangedFromSaved())
- return true;
- return false;
+ {
+ bModified = true;
+ break;
+ }
+ }
+
+#if HAVE_FEATURE_GPGME
+ OUString aSK = m_pSigningKeyLB->GetSelectedEntryPos() == 0 ? OUString() //i.e. no key
+ : m_pSigningKeyLB->GetSelectedEntry();
+ OUString aEK = m_pEncryptionKeyLB->GetSelectedEntryPos() == 0 ? OUString()
+ : m_pEncryptionKeyLB->GetSelectedEntry();
+ aUserOpt.SetToken( UserOptToken::SigningKey, aSK );
+ aUserOpt.SetToken( UserOptToken::EncryptionKey, aEK );
+
+ bModified |= m_pSigningKeyLB->IsValueChangedFromSaved();
+ bModified |= m_pEncryptionKeyLB->IsValueChangedFromSaved();
+#endif
+
+ return bModified;
}
@@ -461,6 +480,16 @@ void SvxGeneralTabPage::SetData_Impl()
// saving
for (auto const & i: vFields)
i->pEdit->SaveValue();
+
+#if HAVE_FEATURE_GPGME
+ OUString aSK = aUserOpt.GetToken(UserOptToken::SigningKey);
+ aSK.isEmpty() ? m_pSigningKeyLB->SelectEntryPos( 0 ) //i.e. 'No Key'
+ : m_pSigningKeyLB->SelectEntry( aSK );
+
+ OUString aEK = aUserOpt.GetToken(UserOptToken::EncryptionKey);
+ aEK.isEmpty() ? m_pEncryptionKeyLB->SelectEntryPos( 0 ) //i.e. 'No Key'
+ : m_pEncryptionKeyLB->SelectEntry( aEK );
+#endif
}
diff --git a/include/unotools/useroptions.hxx b/include/unotools/useroptions.hxx
index f82201fdd28a..946ba8d34c10 100644
--- a/include/unotools/useroptions.hxx
+++ b/include/unotools/useroptions.hxx
@@ -45,7 +45,9 @@ enum class UserOptToken
Zip = 14,
FathersName = 15,
Apartment = 16,
- LAST = Apartment,
+ SigningKey = 17,
+ EncryptionKey = 18,
+ LAST = EncryptionKey,
};
// class SvtUserOptions --------------------------------------------------
@@ -74,6 +76,8 @@ public:
OUString GetTelephoneWork () const;
OUString GetFax () const;
OUString GetEmail () const;
+ OUString GetSigningKey () const;
+ OUString GetEncryptionKey () const;
OUString GetFullName () const;
diff --git a/unotools/source/config/useroptions.cxx b/unotools/source/config/useroptions.cxx
index 31ce8c9893d0..e19168da2885 100644
--- a/unotools/source/config/useroptions.cxx
+++ b/unotools/source/config/useroptions.cxx
@@ -65,7 +65,9 @@ static o3tl::enumarray<UserOptToken, char const *> vOptionNames = {
"initials", // UserOptToken::ID
"postalcode", // UserOptToken::Zip
"fathersname", // UserOptToken::FathersName
- "apartment" // UserOptToken::Apartment
+ "apartment", // UserOptToken::Apartment
+ "signingkey", // UserOptToken::SigningKey
+ "encryptionkey" // UserOptToken::EncryptionKey
};
std::weak_ptr<SvtUserOptions::Impl> SvtUserOptions::xSharedImpl;
@@ -276,6 +278,8 @@ OUString SvtUserOptions::GetTelephoneHome () const { return GetToken(UserOptTok
OUString SvtUserOptions::GetTelephoneWork () const { return GetToken(UserOptToken::TelephoneWork); }
OUString SvtUserOptions::GetFax () const { return GetToken(UserOptToken::Fax); }
OUString SvtUserOptions::GetEmail () const { return GetToken(UserOptToken::Email); }
+OUString SvtUserOptions::GetSigningKey () const { return GetToken(UserOptToken::SigningKey); }
+OUString SvtUserOptions::GetEncryptionKey () const { return GetToken(UserOptToken::EncryptionKey); }
bool SvtUserOptions::IsTokenReadonly (UserOptToken nToken) const
{
More information about the Libreoffice-commits
mailing list