aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2023-11-07 09:25:13 +0000
committersaturneric <[email protected]>2023-11-07 09:25:13 +0000
commit8f633b806baec5004d99f554c4af95e427b82258 (patch)
tree430e0d0734158d89f1af27dfcbfc0fa9daefb88e
parentrefactor: separate typedef and impl (diff)
downloadGpgFrontend-8f633b806baec5004d99f554c4af95e427b82258.tar.gz
GpgFrontend-8f633b806baec5004d99f554c4af95e427b82258.zip
style: tidy up core/model
-rw-r--r--.clang-tidy1
-rw-r--r--src/core/model/DataObject.cpp15
-rw-r--r--src/core/model/DataObject.h12
-rw-r--r--src/core/model/GpgData.cpp4
-rw-r--r--src/core/model/GpgData.h7
-rw-r--r--src/core/model/GpgGenKeyInfo.cpp410
-rw-r--r--src/core/model/GpgGenKeyInfo.h176
-rw-r--r--src/core/model/GpgKey.cpp146
-rw-r--r--src/core/model/GpgKey.h82
-rw-r--r--src/core/model/GpgKeySignature.cpp58
-rw-r--r--src/core/model/GpgKeySignature.h32
-rw-r--r--src/core/model/GpgSignature.cpp37
-rw-r--r--src/core/model/GpgSignature.h25
-rw-r--r--src/core/model/GpgSubKey.cpp79
-rw-r--r--src/core/model/GpgSubKey.h38
-rw-r--r--src/core/model/GpgTOFUInfo.cpp53
-rw-r--r--src/core/model/GpgTOFUInfo.h22
-rw-r--r--src/core/model/GpgUID.cpp35
-rw-r--r--src/core/model/GpgUID.h23
-rw-r--r--src/ui/dialog/import_export/KeyServerImportDialog.cpp72
-rw-r--r--src/ui/dialog/import_export/KeyUploadDialog.cpp8
21 files changed, 783 insertions, 552 deletions
diff --git a/.clang-tidy b/.clang-tidy
index eec3aa21..9c303aa7 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -37,6 +37,7 @@ Checks: >
-readability-identifier-length
-bugprone-easily-swappable-parameters
-readability-redundant-access-specifiers
+ -readability-identifier-length
CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: CamelCase }
diff --git a/src/core/model/DataObject.cpp b/src/core/model/DataObject.cpp
index a1eca4af..9b49d0d4 100644
--- a/src/core/model/DataObject.cpp
+++ b/src/core/model/DataObject.cpp
@@ -29,25 +29,26 @@
#include "DataObject.h"
#include <stack>
+#include <utility>
namespace GpgFrontend {
class DataObject::Impl {
public:
- Impl() {}
+ Impl() = default;
Impl(std::initializer_list<std::any> init_list) : params_(init_list) {}
- void AppendObject(std::any obj) { params_.push_back(obj); }
+ void AppendObject(const std::any& obj) { params_.push_back(obj); }
- std::any GetParameter(size_t index) {
+ auto GetParameter(size_t index) -> std::any {
if (index >= params_.size()) {
throw std::out_of_range("index out of range");
}
return params_[index];
}
- size_t GetObjectSize() { return params_.size(); }
+ auto GetObjectSize() -> size_t { return params_.size(); }
private:
std::vector<std::any> params_;
@@ -62,17 +63,17 @@ DataObject::~DataObject() = default;
DataObject::DataObject(DataObject&&) noexcept = default;
-std::any DataObject::operator[](size_t index) const {
+auto DataObject::operator[](size_t index) const -> std::any {
return p_->GetParameter(index);
}
-std::any DataObject::GetParameter(size_t index) const {
+auto DataObject::GetParameter(size_t index) const -> std::any {
return p_->GetParameter(index);
}
void DataObject::AppendObject(std::any obj) { return p_->AppendObject(obj); }
-size_t DataObject::GetObjectSize() const { return p_->GetObjectSize(); }
+auto DataObject::GetObjectSize() const -> size_t { return p_->GetObjectSize(); }
void DataObject::Swap(DataObject& other) noexcept { std::swap(p_, other.p_); }
diff --git a/src/core/model/DataObject.h b/src/core/model/DataObject.h
index 4fb073ba..b1b41283 100644
--- a/src/core/model/DataObject.h
+++ b/src/core/model/DataObject.h
@@ -47,20 +47,20 @@ class GPGFRONTEND_CORE_EXPORT DataObject {
DataObject(DataObject&&) noexcept;
- std::any operator[](size_t index) const;
+ auto operator[](size_t index) const -> std::any;
void AppendObject(std::any);
- std::any GetParameter(size_t index) const;
+ [[nodiscard]] auto GetParameter(size_t index) const -> std::any;
- size_t GetObjectSize() const;
+ [[nodiscard]] auto GetObjectSize() const -> size_t;
void Swap(DataObject& other) noexcept;
void Swap(DataObject&& other) noexcept;
template <typename... Args>
- bool Check() {
+ auto Check() -> bool {
if (sizeof...(Args) != GetObjectSize()) return false;
std::vector<std::type_info const*> type_list = {&typeid(Args)...};
@@ -76,12 +76,12 @@ class GPGFRONTEND_CORE_EXPORT DataObject {
};
template <typename... Args>
-std::shared_ptr<DataObject> TransferParams(Args&&... args) {
+auto TransferParams(Args&&... args) -> std::shared_ptr<DataObject> {
return std::make_shared<DataObject>(DataObject{std::forward<Args>(args)...});
}
template <typename T>
-T ExtractParams(const std::shared_ptr<DataObject>& d_o, int index) {
+auto ExtractParams(const std::shared_ptr<DataObject>& d_o, int index) -> T {
if (!d_o) {
throw std::invalid_argument("nullptr provided for DataObjectPtr");
}
diff --git a/src/core/model/GpgData.cpp b/src/core/model/GpgData.cpp
index 1bdb2047..b4ebff18 100644
--- a/src/core/model/GpgData.cpp
+++ b/src/core/model/GpgData.cpp
@@ -34,7 +34,7 @@ GpgFrontend::GpgData::GpgData() {
auto err = gpgme_data_new(&data);
assert(gpgme_err_code(err) == GPG_ERR_NO_ERROR);
- data_ref_ = std::unique_ptr<struct gpgme_data, _data_ref_deleter>(data);
+ data_ref_ = std::unique_ptr<struct gpgme_data, DataRefDeleter>(data);
}
GpgFrontend::GpgData::GpgData(void* buffer, size_t size, bool copy) {
@@ -44,7 +44,7 @@ GpgFrontend::GpgData::GpgData(void* buffer, size_t size, bool copy) {
size, copy);
assert(gpgme_err_code(err) == GPG_ERR_NO_ERROR);
- data_ref_ = std::unique_ptr<struct gpgme_data, _data_ref_deleter>(data);
+ data_ref_ = std::unique_ptr<struct gpgme_data, DataRefDeleter>(data);
}
/**
diff --git a/src/core/model/GpgData.h b/src/core/model/GpgData.h
index eb9bd723..fa4910d5 100644
--- a/src/core/model/GpgData.h
+++ b/src/core/model/GpgData.h
@@ -64,21 +64,20 @@ class GpgData {
*
* @return ByteArrayPtr
*/
- ByteArrayPtr Read2Buffer();
+ auto Read2Buffer() -> ByteArrayPtr;
private:
/**
* @brief
*
*/
- struct _data_ref_deleter {
+ struct DataRefDeleter {
void operator()(gpgme_data_t _data) {
if (_data != nullptr) gpgme_data_release(_data);
}
};
- std::unique_ptr<struct gpgme_data, _data_ref_deleter> data_ref_ =
- nullptr; ///<
+ std::unique_ptr<struct gpgme_data, DataRefDeleter> data_ref_ = nullptr; ///<
};
} // namespace GpgFrontend
diff --git a/src/core/model/GpgGenKeyInfo.cpp b/src/core/model/GpgGenKeyInfo.cpp
index 4f0dc964..1933a1db 100644
--- a/src/core/model/GpgGenKeyInfo.cpp
+++ b/src/core/model/GpgGenKeyInfo.cpp
@@ -29,47 +29,46 @@
#include "GpgGenKeyInfo.h"
#include <algorithm>
-#include <boost/date_time/gregorian/greg_date.hpp>
-#include <boost/date_time/gregorian/greg_duration.hpp>
-#include <boost/date_time/gregorian/gregorian_types.hpp>
+#include <boost/format.hpp>
#include <cassert>
-void GpgFrontend::GenKeyInfo::SetAlgo(
- const GpgFrontend::GenKeyInfo::KeyGenAlgo &m_algo) {
+namespace GpgFrontend {
+
+void GenKeyInfo::SetAlgo(const GenKeyInfo::KeyGenAlgo &m_algo) {
SPDLOG_DEBUG("set algo name: {}", m_algo.first);
// Check algo if supported
std::string algo_args = m_algo.second;
if (standalone_) {
if (!subkey_) {
auto support_algo = GetSupportedKeyAlgoStandalone();
- auto it = std::find_if(
+ auto algo_it = std::find_if(
support_algo.begin(), support_algo.end(),
[=](const KeyGenAlgo &o) { return o.second == algo_args; });
// Algo Not Supported
- if (it == support_algo.end()) return;
+ if (algo_it == support_algo.end()) return;
} else {
auto support_algo = GetSupportedSubkeyAlgoStandalone();
- auto it = std::find_if(
+ auto algo_it = std::find_if(
support_algo.begin(), support_algo.end(),
[=](const KeyGenAlgo &o) { return o.second == algo_args; });
// Algo Not Supported
- if (it == support_algo.end()) return;
+ if (algo_it == support_algo.end()) return;
}
} else {
if (!subkey_) {
auto support_algo = GetSupportedKeyAlgo();
- auto it = std::find_if(
+ auto algo_it = std::find_if(
support_algo.begin(), support_algo.end(),
[=](const KeyGenAlgo &o) { return o.second == algo_args; });
// Algo Not Supported
- if (it == support_algo.end()) return;
+ if (algo_it == support_algo.end()) return;
} else {
auto support_algo = GetSupportedSubkeyAlgo();
- auto it = std::find_if(
+ auto algo_it = std::find_if(
support_algo.begin(), support_algo.end(),
[=](const KeyGenAlgo &o) { return o.second == algo_args; });
// Algo Not Supported
- if (it == support_algo.end()) return;
+ if (algo_it == support_algo.end()) return;
}
}
@@ -172,7 +171,7 @@ void GpgFrontend::GenKeyInfo::SetAlgo(
this->algo_ = algo_args;
}
-void GpgFrontend::GenKeyInfo::reset_options() {
+void GenKeyInfo::reset_options() {
allow_change_encryption_ = true;
SetAllowEncryption(true);
@@ -188,15 +187,14 @@ void GpgFrontend::GenKeyInfo::reset_options() {
passphrase_.clear();
}
-std::string GpgFrontend::GenKeyInfo::GetKeySizeStr() const {
+auto GenKeyInfo::GetKeySizeStr() const -> std::string {
if (key_size_ > 0) {
return std::to_string(key_size_);
- } else {
- return {};
}
+ return {};
}
-void GpgFrontend::GenKeyInfo::SetKeyLength(int m_key_size) {
+void GenKeyInfo::SetKeyLength(int m_key_size) {
if (m_key_size < suggest_min_key_size_ ||
m_key_size > suggest_max_key_size_) {
return;
@@ -204,79 +202,365 @@ void GpgFrontend::GenKeyInfo::SetKeyLength(int m_key_size) {
GenKeyInfo::key_size_ = m_key_size;
}
-void GpgFrontend::GenKeyInfo::SetExpireTime(
- const boost::posix_time::ptime &m_expired) {
- using namespace boost::gregorian;
+void GenKeyInfo::SetExpireTime(const boost::posix_time::ptime &m_expired) {
if (!IsNonExpired()) {
GenKeyInfo::expired_ = m_expired;
}
}
-void GpgFrontend::GenKeyInfo::SetNonExpired(bool m_non_expired) {
- using namespace boost::posix_time;
- if (!m_non_expired) this->expired_ = from_time_t(0);
+void GenKeyInfo::SetNonExpired(bool m_non_expired) {
+ if (!m_non_expired) this->expired_ = boost::posix_time::from_time_t(0);
GenKeyInfo::non_expired_ = m_non_expired;
}
-void GpgFrontend::GenKeyInfo::SetAllowEncryption(bool m_allow_encryption) {
- if (allow_change_encryption_)
+void GenKeyInfo::SetAllowEncryption(bool m_allow_encryption) {
+ if (allow_change_encryption_) {
GenKeyInfo::allow_encryption_ = m_allow_encryption;
+ }
}
-void GpgFrontend::GenKeyInfo::SetAllowCertification(
- bool m_allow_certification) {
- if (allow_change_certification_)
+void GenKeyInfo::SetAllowCertification(bool m_allow_certification) {
+ if (allow_change_certification_) {
GenKeyInfo::allow_certification_ = m_allow_certification;
+ }
}
-GpgFrontend::GenKeyInfo::GenKeyInfo(bool m_is_sub_key, bool m_standalone)
+GenKeyInfo::GenKeyInfo(bool m_is_sub_key, bool m_standalone)
: standalone_(m_standalone), subkey_(m_is_sub_key) {
- assert(GetSupportedKeyAlgo().size() > 0);
+ assert(!GetSupportedKeyAlgo().empty());
SetAlgo(GetSupportedKeyAlgo()[0]);
}
-const std::vector<GpgFrontend::GenKeyInfo::KeyGenAlgo> &
-GpgFrontend::GenKeyInfo::GetSupportedKeyAlgo() {
- static const std::vector<GpgFrontend::GenKeyInfo::KeyGenAlgo>
- support_key_algo = {
- {"RSA", "RSA"},
- {"DSA", "DSA"},
- {"ECDSA", "ED25519"},
- };
- return support_key_algo;
+auto GenKeyInfo::GetSupportedKeyAlgo()
+ -> const std::vector<GenKeyInfo::KeyGenAlgo> & {
+ static const std::vector<GenKeyInfo::KeyGenAlgo> kSupportKeyAlgo = {
+ {"RSA", "RSA"},
+ {"DSA", "DSA"},
+ {"ECDSA", "ED25519"},
+ };
+ return kSupportKeyAlgo;
}
-const std::vector<GpgFrontend::GenKeyInfo::KeyGenAlgo> &
-GpgFrontend::GenKeyInfo::GetSupportedSubkeyAlgo() {
- static const std::vector<GpgFrontend::GenKeyInfo::KeyGenAlgo>
- support_subkey_algo = {
- {"RSA", "RSA"},
- {"DSA", "DSA"},
- {"ECDSA", "ED25519"},
- {"ECDH NIST P-256", "NISTP256"},
- {"ECDH NIST P-384", "NISTP384"},
- {"ECDH NIST P-521", "NISTP521"},
- // {"ECDH BrainPool P-256", "BRAINPOOlP256R1"}
- };
- return support_subkey_algo;
+auto GenKeyInfo::GetSupportedSubkeyAlgo()
+ -> const std::vector<GenKeyInfo::KeyGenAlgo> & {
+ static const std::vector<GenKeyInfo::KeyGenAlgo> kSupportSubkeyAlgo = {
+ {"RSA", "RSA"},
+ {"DSA", "DSA"},
+ {"ECDSA", "ED25519"},
+ {"ECDH NIST P-256", "NISTP256"},
+ {"ECDH NIST P-384", "NISTP384"},
+ {"ECDH NIST P-521", "NISTP521"},
+ // {"ECDH BrainPool P-256", "BRAINPOOlP256R1"}
+ };
+ return kSupportSubkeyAlgo;
}
-const std::vector<GpgFrontend::GenKeyInfo::KeyGenAlgo> &
-GpgFrontend::GenKeyInfo::GetSupportedKeyAlgoStandalone() {
- static const std::vector<GpgFrontend::GenKeyInfo::KeyGenAlgo>
- support_subkey_algo_standalone = {
+auto GenKeyInfo::GetSupportedKeyAlgoStandalone()
+ -> const std::vector<GenKeyInfo::KeyGenAlgo> & {
+ static const std::vector<GenKeyInfo::KeyGenAlgo>
+ kSupportSubkeyAlgoStandalone = {
{"RSA", "RSA"},
{"DSA", "DSA"},
};
- return support_subkey_algo_standalone;
+ return kSupportSubkeyAlgoStandalone;
}
-const std::vector<GpgFrontend::GenKeyInfo::KeyGenAlgo> &
-GpgFrontend::GenKeyInfo::GetSupportedSubkeyAlgoStandalone() {
- static const std::vector<GpgFrontend::GenKeyInfo::KeyGenAlgo>
- support_subkey_algo_standalone = {
+auto GenKeyInfo::GetSupportedSubkeyAlgoStandalone()
+ -> const std::vector<GenKeyInfo::KeyGenAlgo> & {
+ static const std::vector<GenKeyInfo::KeyGenAlgo>
+ kSupportSubkeyAlgoStandalone = {
{"RSA", "RSA"},
{"DSA", "DSA"},
};
- return support_subkey_algo_standalone;
+ return kSupportSubkeyAlgoStandalone;
+}
+
+/**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+[[nodiscard]] auto GenKeyInfo::IsSubKey() const -> bool { return subkey_; }
+
+/**
+ * @brief Set the Is Sub Key object
+ *
+ * @param m_sub_key
+ */
+void GenKeyInfo::SetIsSubKey(bool m_sub_key) {
+ GenKeyInfo::subkey_ = m_sub_key;
+}
+
+/**
+ * @brief Get the Userid object
+ *
+ * @return std::string
+ */
+[[nodiscard]] auto GenKeyInfo::GetUserid() const -> std::string {
+ auto uid_format = boost::format("%1%(%2%)<%3%>") % this->name_ %
+ this->comment_ % this->email_;
+ return uid_format.str();
+}
+
+/**
+ * @brief Set the Name object
+ *
+ * @param m_name
+ */
+void GenKeyInfo::SetName(const std::string &m_name) { this->name_ = m_name; }
+
+/**
+ * @brief Set the Email object
+ *
+ * @param m_email
+ */
+void GenKeyInfo::SetEmail(const std::string &m_email) {
+ this->email_ = m_email;
+}
+
+/**
+ * @brief Set the Comment object
+ *
+ * @param m_comment
+ */
+void GenKeyInfo::SetComment(const std::string &m_comment) {
+ this->comment_ = m_comment;
+}
+
+/**
+ * @brief Get the Name object
+ *
+ * @return std::string
+ */
+[[nodiscard]] auto GenKeyInfo::GetName() const -> std::string { return name_; }
+
+/**
+ * @brief Get the Email object
+ *
+ * @return std::string
+ */
+[[nodiscard]] auto GenKeyInfo::GetEmail() const -> std::string {
+ return email_;
+}
+
+/**
+ * @brief Get the Comment object
+ *
+ * @return std::string
+ */
+[[nodiscard]] auto GenKeyInfo::GetComment() const -> std::string {
+ return comment_;
}
+
+/**
+ * @brief Get the Algo object
+ *
+ * @return const std::string&
+ */
+[[nodiscard]] auto GenKeyInfo::GetAlgo() const -> const std::string & {
+ return algo_;
+}
+
+/**
+ * @brief Get the Key Size object
+ *
+ * @return int
+ */
+[[nodiscard]] auto GenKeyInfo::GetKeyLength() const -> int { return key_size_; }
+
+/**
+ * @brief Get the Expired object
+ *
+ * @return const boost::posix_time::ptime&
+ */
+[[nodiscard]] auto GenKeyInfo::GetExpireTime() const
+ -> const boost::posix_time::ptime & {
+ return expired_;
+}
+
+/**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+[[nodiscard]] auto GenKeyInfo::IsNonExpired() const -> bool {
+ return non_expired_;
+}
+
+/**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+[[nodiscard]] auto GenKeyInfo::IsNoPassPhrase() const -> bool {
+ return this->no_passphrase_;
+}
+
+/**
+ * @brief Set the Non Pass Phrase object
+ *
+ * @param m_non_pass_phrase
+ */
+void GenKeyInfo::SetNonPassPhrase(bool m_non_pass_phrase) {
+ GenKeyInfo::no_passphrase_ = m_non_pass_phrase;
+}
+
+/**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+[[nodiscard]] auto GenKeyInfo::IsAllowSigning() const -> bool {
+ return allow_signing_;
+}
+
+/**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+[[nodiscard]] auto GenKeyInfo::IsAllowNoPassPhrase() const -> bool {
+ return allow_no_pass_phrase_;
+}
+
+/**
+ * @brief Set the Allow Signing object
+ *
+ * @param m_allow_signing
+ */
+void GenKeyInfo::SetAllowSigning(bool m_allow_signing) {
+ if (allow_change_signing_) GenKeyInfo::allow_signing_ = m_allow_signing;
+}
+
+/**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+[[nodiscard]] auto GenKeyInfo::IsAllowEncryption() const -> bool {
+ return allow_encryption_;
+}
+
+/**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+[[nodiscard]] auto GenKeyInfo::IsAllowCertification() const -> bool {
+ return allow_certification_;
+}
+
+/**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+[[nodiscard]] auto GenKeyInfo::IsAllowAuthentication() const -> bool {
+ return allow_authentication_;
+}
+
+/**
+ * @brief Set the Allow Authentication object
+ *
+ * @param m_allow_authentication
+ */
+void GenKeyInfo::SetAllowAuthentication(bool m_allow_authentication) {
+ if (allow_change_authentication_) {
+ GenKeyInfo::allow_authentication_ = m_allow_authentication;
+ }
+}
+
+/**
+ * @brief Get the Pass Phrase object
+ *
+ * @return const std::string&
+ */
+[[nodiscard]] auto GenKeyInfo::GetPassPhrase() const -> const std::string & {
+ return passphrase_;
+}
+
+/**
+ * @brief Set the Pass Phrase object
+ *
+ * @param m_pass_phrase
+ */
+void GenKeyInfo::SetPassPhrase(const std::string &m_pass_phrase) {
+ GenKeyInfo::passphrase_ = m_pass_phrase;
+}
+
+/**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+[[nodiscard]] auto GenKeyInfo::IsAllowChangeSigning() const -> bool {
+ return allow_change_signing_;
+}
+
+/**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+[[nodiscard]] auto GenKeyInfo::IsAllowChangeEncryption() const -> bool {
+ return allow_change_encryption_;
+}
+
+/**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+[[nodiscard]] auto GenKeyInfo::IsAllowChangeCertification() const -> bool {
+ return allow_change_certification_;
+}
+
+/**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+[[nodiscard]] auto GenKeyInfo::IsAllowChangeAuthentication() const -> bool {
+ return allow_change_authentication_;
+}
+
+/**
+ * @brief Get the Suggest Max Key Size object
+ *
+ * @return int
+ */
+[[nodiscard]] auto GenKeyInfo::GetSuggestMaxKeySize() const -> int {
+ return suggest_max_key_size_;
+}
+
+/**
+ * @brief Get the Suggest Min Key Size object
+ *
+ * @return int
+ */
+[[nodiscard]] auto GenKeyInfo::GetSuggestMinKeySize() const -> int {
+ return suggest_min_key_size_;
+}
+
+/**
+ * @brief Get the Size Change Step object
+ *
+ * @return int
+ */
+[[nodiscard]] auto GenKeyInfo::GetSizeChangeStep() const -> int {
+ return suggest_size_addition_step_;
+}
+
+} // namespace GpgFrontend
diff --git a/src/core/model/GpgGenKeyInfo.h b/src/core/model/GpgGenKeyInfo.h
index b25fe889..2c53f17a 100644
--- a/src/core/model/GpgGenKeyInfo.h
+++ b/src/core/model/GpgGenKeyInfo.h
@@ -29,64 +29,50 @@
#pragma once
#include <boost/date_time.hpp>
-#include <boost/date_time/gregorian/greg_duration_types.hpp>
-#include <boost/format.hpp>
namespace GpgFrontend {
class GPGFRONTEND_CORE_EXPORT GenKeyInfo {
- bool standalone_ = false; ///<
- bool subkey_ = false; ///<
- std::string name_; ///<
- std::string email_; ///<
- std::string comment_; ///<
-
- std::string algo_; ///<
- int key_size_ = 2048;
- boost::posix_time::ptime expired_ =
- boost::posix_time::second_clock::local_time() +
- boost::gregorian::years(2); ///<
- bool non_expired_ = false; ///<
-
- bool no_passphrase_ = false; ///<
- bool allow_no_pass_phrase_ = true; ///<
-
- int suggest_max_key_size_ = 4096; ///<
- int suggest_size_addition_step_ = 1024; ///<
- int suggest_min_key_size_ = 1024; ///<
-
- std::string passphrase_; ///<
-
+ public:
using KeyGenAlgo = std::pair<std::string, std::string>;
- public:
+ /**
+ * @brief Construct a new Gen Key Info object
+ *
+ * @param m_is_sub_key
+ * @param m_standalone
+ */
+ explicit GenKeyInfo(bool m_is_sub_key = false, bool m_standalone = false);
+
/**
* @brief Get the Supported Key Algo object
*
* @return const std::vector<std::string>&
*/
- static const std::vector<KeyGenAlgo> &GetSupportedKeyAlgo();
+ static auto GetSupportedKeyAlgo() -> const std::vector<KeyGenAlgo> &;
/**
* @brief Get the Supported Subkey Algo object
*
* @return const std::vector<std::string>&
*/
- static const std::vector<KeyGenAlgo> &GetSupportedSubkeyAlgo();
+ static auto GetSupportedSubkeyAlgo() -> const std::vector<KeyGenAlgo> &;
/**
* @brief Get the Supported Key Algo Standalone object
*
* @return const std::vector<std::string>&
*/
- static const std::vector<KeyGenAlgo> &GetSupportedKeyAlgoStandalone();
+ static auto GetSupportedKeyAlgoStandalone()
+ -> const std::vector<KeyGenAlgo> &;
/**
* @brief Get the Supported Subkey Algo Standalone object
*
* @return const std::vector<std::string>&
*/
- static const std::vector<KeyGenAlgo> &GetSupportedSubkeyAlgoStandalone();
+ static auto GetSupportedSubkeyAlgoStandalone()
+ -> const std::vector<KeyGenAlgo> &;
/**
* @brief
@@ -94,95 +80,91 @@ class GPGFRONTEND_CORE_EXPORT GenKeyInfo {
* @return true
* @return false
*/
- [[nodiscard]] bool IsSubKey() const { return subkey_; }
+ [[nodiscard]] auto IsSubKey() const -> bool;
/**
* @brief Set the Is Sub Key object
*
* @param m_sub_key
*/
- void SetIsSubKey(bool m_sub_key) { GenKeyInfo::subkey_ = m_sub_key; }
+ void SetIsSubKey(bool m_sub_key);
/**
* @brief Get the Userid object
*
* @return std::string
*/
- [[nodiscard]] std::string GetUserid() const {
- auto uid_format = boost::format("%1%(%2%)<%3%>") % this->name_ %
- this->comment_ % this->email_;
- return uid_format.str();
- }
+ [[nodiscard]] auto GetUserid() const -> std::string;
/**
* @brief Set the Name object
*
* @param m_name
*/
- void SetName(const std::string &m_name) { this->name_ = m_name; }
+ void SetName(const std::string &m_name);
/**
* @brief Set the Email object
*
* @param m_email
*/
- void SetEmail(const std::string &m_email) { this->email_ = m_email; }
+ void SetEmail(const std::string &m_email);
/**
* @brief Set the Comment object
*
* @param m_comment
*/
- void SetComment(const std::string &m_comment) { this->comment_ = m_comment; }
+ void SetComment(const std::string &m_comment);
/**
* @brief Get the Name object
*
* @return std::string
*/
- [[nodiscard]] std::string GetName() const { return name_; }
+ [[nodiscard]] auto GetName() const -> std::string;
/**
* @brief Get the Email object
*
* @return std::string
*/
- [[nodiscard]] std::string GetEmail() const { return email_; }
+ [[nodiscard]] auto GetEmail() const -> std::string;
/**
* @brief Get the Comment object
*
* @return std::string
*/
- [[nodiscard]] std::string GetComment() const { return comment_; }
+ [[nodiscard]] auto GetComment() const -> std::string;
/**
* @brief Get the Algo object
*
* @return const std::string&
*/
- [[nodiscard]] const std::string &GetAlgo() const { return algo_; }
+ [[nodiscard]] auto GetAlgo() const -> const std::string &;
/**
* @brief Set the Algo object
*
* @param m_algo
*/
- void SetAlgo(const GpgFrontend::GenKeyInfo::KeyGenAlgo &m_algo);
+ void SetAlgo(const GenKeyInfo::KeyGenAlgo &m_algo);
/**
* @brief Get the Key Size Str object
*
* @return std::string
*/
- [[nodiscard]] std::string GetKeySizeStr() const;
+ [[nodiscard]] auto GetKeySizeStr() const -> std::string;
/**
* @brief Get the Key Size object
*
* @return int
*/
- [[nodiscard]] int GetKeyLength() const { return key_size_; }
+ [[nodiscard]] auto GetKeyLength() const -> int;
/**
* @brief Set the Key Size object
@@ -196,9 +178,7 @@ class GPGFRONTEND_CORE_EXPORT GenKeyInfo {
*
* @return const boost::posix_time::ptime&
*/
- [[nodiscard]] const boost::posix_time::ptime &GetExpireTime() const {
- return expired_;
- }
+ [[nodiscard]] auto GetExpireTime() const -> const boost::posix_time::ptime &;
/**
* @brief Set the Expired object
@@ -213,7 +193,7 @@ class GPGFRONTEND_CORE_EXPORT GenKeyInfo {
* @return true
* @return false
*/
- [[nodiscard]] bool IsNonExpired() const { return non_expired_; }
+ [[nodiscard]] auto IsNonExpired() const -> bool;
/**
* @brief Set the Non Expired object
@@ -228,16 +208,14 @@ class GPGFRONTEND_CORE_EXPORT GenKeyInfo {
* @return true
* @return false
*/
- [[nodiscard]] bool IsNoPassPhrase() const { return this->no_passphrase_; }
+ [[nodiscard]] auto IsNoPassPhrase() const -> bool;
/**
* @brief Set the Non Pass Phrase object
*
* @param m_non_pass_phrase
*/
- void SetNonPassPhrase(bool m_non_pass_phrase) {
- GenKeyInfo::no_passphrase_ = m_non_pass_phrase;
- }
+ void SetNonPassPhrase(bool m_non_pass_phrase);
/**
* @brief
@@ -245,7 +223,7 @@ class GPGFRONTEND_CORE_EXPORT GenKeyInfo {
* @return true
* @return false
*/
- [[nodiscard]] bool IsAllowSigning() const { return allow_signing_; }
+ [[nodiscard]] auto IsAllowSigning() const -> bool;
/**
* @brief
@@ -253,18 +231,14 @@ class GPGFRONTEND_CORE_EXPORT GenKeyInfo {
* @return true
* @return false
*/
- [[nodiscard]] bool IsAllowNoPassPhrase() const {
- return allow_no_pass_phrase_;
- }
+ [[nodiscard]] auto IsAllowNoPassPhrase() const -> bool;
/**
* @brief Set the Allow Signing object
*
* @param m_allow_signing
*/
- void SetAllowSigning(bool m_allow_signing) {
- if (allow_change_signing_) GenKeyInfo::allow_signing_ = m_allow_signing;
- }
+ void SetAllowSigning(bool m_allow_signing);
/**
* @brief
@@ -272,7 +246,7 @@ class GPGFRONTEND_CORE_EXPORT GenKeyInfo {
* @return true
* @return false
*/
- [[nodiscard]] bool IsAllowEncryption() const { return allow_encryption_; }
+ [[nodiscard]] auto IsAllowEncryption() const -> bool;
/**
* @brief Set the Allow Encryption object
@@ -287,9 +261,7 @@ class GPGFRONTEND_CORE_EXPORT GenKeyInfo {
* @return true
* @return false
*/
- [[nodiscard]] bool IsAllowCertification() const {
- return allow_certification_;
- }
+ [[nodiscard]] auto IsAllowCertification() const -> bool;
/**
* @brief Set the Allow Certification object
@@ -304,35 +276,28 @@ class GPGFRONTEND_CORE_EXPORT GenKeyInfo {
* @return true
* @return false
*/
- [[nodiscard]] bool IsAllowAuthentication() const {
- return allow_authentication_;
- }
+ [[nodiscard]] auto IsAllowAuthentication() const -> bool;
/**
* @brief Set the Allow Authentication object
*
* @param m_allow_authentication
*/
- void SetAllowAuthentication(bool m_allow_authentication) {
- if (allow_change_authentication_)
- GenKeyInfo::allow_authentication_ = m_allow_authentication;
- }
+ void SetAllowAuthentication(bool m_allow_authentication);
/**
* @brief Get the Pass Phrase object
*
* @return const std::string&
*/
- [[nodiscard]] const std::string &GetPassPhrase() const { return passphrase_; }
+ [[nodiscard]] auto GetPassPhrase() const -> const std::string &;
/**
* @brief Set the Pass Phrase object
*
* @param m_pass_phrase
*/
- void SetPassPhrase(const std::string &m_pass_phrase) {
- GenKeyInfo::passphrase_ = m_pass_phrase;
- }
+ void SetPassPhrase(const std::string &m_pass_phrase);
/**
* @brief
@@ -340,9 +305,7 @@ class GPGFRONTEND_CORE_EXPORT GenKeyInfo {
* @return true
* @return false
*/
- [[nodiscard]] bool IsAllowChangeSigning() const {
- return allow_change_signing_;
- }
+ [[nodiscard]] auto IsAllowChangeSigning() const -> bool;
/**
* @brief
@@ -350,9 +313,7 @@ class GPGFRONTEND_CORE_EXPORT GenKeyInfo {
* @return true
* @return false
*/
- [[nodiscard]] bool IsAllowChangeEncryption() const {
- return allow_change_encryption_;
- }
+ [[nodiscard]] auto IsAllowChangeEncryption() const -> bool;
/**
* @brief
@@ -360,9 +321,7 @@ class GPGFRONTEND_CORE_EXPORT GenKeyInfo {
* @return true
* @return false
*/
- [[nodiscard]] bool IsAllowChangeCertification() const {
- return allow_change_certification_;
- }
+ [[nodiscard]] auto IsAllowChangeCertification() const -> bool;
/**
* @brief
@@ -370,38 +329,52 @@ class GPGFRONTEND_CORE_EXPORT GenKeyInfo {
* @return true
* @return false
*/
- [[nodiscard]] bool IsAllowChangeAuthentication() const {
- return allow_change_authentication_;
- }
+ [[nodiscard]] auto IsAllowChangeAuthentication() const -> bool;
/**
* @brief Get the Suggest Max Key Size object
*
* @return int
*/
- [[nodiscard]] int GetSuggestMaxKeySize() const {
- return suggest_max_key_size_;
- }
+ [[nodiscard]] auto GetSuggestMaxKeySize() const -> int;
/**
* @brief Get the Suggest Min Key Size object
*
* @return int
*/
- [[nodiscard]] int GetSuggestMinKeySize() const {
- return suggest_min_key_size_;
- }
+ [[nodiscard]] auto GetSuggestMinKeySize() const -> int;
/**
* @brief Get the Size Change Step object
*
* @return int
*/
- [[nodiscard]] int GetSizeChangeStep() const {
- return suggest_size_addition_step_;
- }
+ [[nodiscard]] auto GetSizeChangeStep() const -> int;
private:
+ bool standalone_ = false; ///<
+ bool subkey_ = false; ///<
+ std::string name_; ///<
+ std::string email_; ///<
+ std::string comment_; ///<
+
+ std::string algo_; ///<
+ int key_size_ = 2048;
+ boost::posix_time::ptime expired_ =
+ boost::posix_time::second_clock::local_time() +
+ boost::gregorian::years(2); ///<
+ bool non_expired_ = false; ///<
+
+ bool no_passphrase_ = false; ///<
+ bool allow_no_pass_phrase_ = true; ///<
+
+ int suggest_max_key_size_ = 4096; ///<
+ int suggest_size_addition_step_ = 1024; ///<
+ int suggest_min_key_size_ = 1024; ///<
+
+ std::string passphrase_; ///<
+
bool allow_encryption_ = true; ///<
bool allow_change_encryption_ = true; ///<
bool allow_certification_ = true; ///<
@@ -416,15 +389,6 @@ class GPGFRONTEND_CORE_EXPORT GenKeyInfo {
*
*/
void reset_options();
-
- public:
- /**
- * @brief Construct a new Gen Key Info object
- *
- * @param m_is_sub_key
- * @param m_standalone
- */
- explicit GenKeyInfo(bool m_is_sub_key = false, bool m_standalone = false);
};
} // namespace GpgFrontend
diff --git a/src/core/model/GpgKey.cpp b/src/core/model/GpgKey.cpp
index 1ddb73d9..a183c240 100644
--- a/src/core/model/GpgKey.cpp
+++ b/src/core/model/GpgKey.cpp
@@ -30,52 +30,46 @@
#include <mutex>
-GpgFrontend::GpgKey::GpgKey(gpgme_key_t &&key) : key_ref_(std::move(key)) {}
+namespace GpgFrontend {
-GpgFrontend::GpgKey::GpgKey(GpgKey &&k) noexcept { swap(key_ref_, k.key_ref_); }
+GpgKey::GpgKey(gpgme_key_t &&key) : key_ref_(key) {}
-GpgFrontend::GpgKey &GpgFrontend::GpgKey::operator=(GpgKey &&k) noexcept {
+GpgKey::GpgKey(GpgKey &&k) noexcept { swap(key_ref_, k.key_ref_); }
+
+auto GpgKey::operator=(GpgKey &&k) noexcept -> GpgKey & {
swap(key_ref_, k.key_ref_);
return *this;
}
-bool GpgFrontend::GpgKey::operator==(const GpgKey &o) const {
+auto GpgKey::operator==(const GpgKey &o) const -> bool {
return o.GetId() == this->GetId();
}
-bool GpgFrontend::GpgKey::operator<=(const GpgKey &o) const {
+auto GpgKey::operator<=(const GpgKey &o) const -> bool {
return this->GetId() < o.GetId();
}
-GpgFrontend::GpgKey::operator gpgme_key_t() const { return key_ref_.get(); }
+GpgKey::operator gpgme_key_t() const { return key_ref_.get(); }
-bool GpgFrontend::GpgKey::IsGood() const { return key_ref_ != nullptr; }
+auto GpgKey::IsGood() const -> bool { return key_ref_ != nullptr; }
-std::string GpgFrontend::GpgKey::GetId() const {
- return key_ref_->subkeys->keyid;
-}
+auto GpgKey::GetId() const -> std::string { return key_ref_->subkeys->keyid; }
-std::string GpgFrontend::GpgKey::GetName() const {
- return key_ref_->uids->name;
-};
+auto GpgKey::GetName() const -> std::string { return key_ref_->uids->name; };
-std::string GpgFrontend::GpgKey::GetEmail() const {
- return key_ref_->uids->email;
-}
+auto GpgKey::GetEmail() const -> std::string { return key_ref_->uids->email; }
-std::string GpgFrontend::GpgKey::GetComment() const {
+auto GpgKey::GetComment() const -> std::string {
return key_ref_->uids->comment;
}
-std::string GpgFrontend::GpgKey::GetFingerprint() const {
- return key_ref_->fpr;
-}
+auto GpgKey::GetFingerprint() const -> std::string { return key_ref_->fpr; }
-std::string GpgFrontend::GpgKey::GetProtocol() const {
+auto GpgKey::GetProtocol() const -> std::string {
return gpgme_get_protocol_name(key_ref_->protocol);
}
-std::string GpgFrontend::GpgKey::GetOwnerTrust() const {
+auto GpgKey::GetOwnerTrust() const -> std::string {
switch (key_ref_->owner_trust) {
case GPGME_VALIDITY_UNKNOWN:
return _("Unknown");
@@ -93,7 +87,7 @@ std::string GpgFrontend::GpgKey::GetOwnerTrust() const {
return "Invalid";
}
-int GpgFrontend::GpgKey::GetOwnerTrustLevel() const {
+auto GpgKey::GetOwnerTrustLevel() const -> int {
switch (key_ref_->owner_trust) {
case GPGME_VALIDITY_UNKNOWN:
return 0;
@@ -111,66 +105,65 @@ int GpgFrontend::GpgKey::GetOwnerTrustLevel() const {
return 0;
}
-std::string GpgFrontend::GpgKey::GetPublicKeyAlgo() const {
+auto GpgKey::GetPublicKeyAlgo() const -> std::string {
return gpgme_pubkey_algo_name(key_ref_->subkeys->pubkey_algo);
}
-boost::posix_time::ptime GpgFrontend::GpgKey::GetLastUpdateTime() const {
+auto GpgKey::GetLastUpdateTime() const -> boost::posix_time::ptime {
return boost::posix_time::from_time_t(
static_cast<time_t>(key_ref_->last_update));
}
-boost::posix_time::ptime GpgFrontend::GpgKey::GetExpireTime() const {
+auto GpgKey::GetExpireTime() const -> boost::posix_time::ptime {
return boost::posix_time::from_time_t(key_ref_->subkeys->expires);
};
-boost::posix_time::ptime GpgFrontend::GpgKey::GetCreateTime() const {
+auto GpgKey::GetCreateTime() const -> boost::posix_time::ptime {
return boost::posix_time::from_time_t(key_ref_->subkeys->timestamp);
};
-unsigned int GpgFrontend::GpgKey::GetPrimaryKeyLength() const {
+auto GpgKey::GetPrimaryKeyLength() const -> unsigned int {
return key_ref_->subkeys->length;
}
-bool GpgFrontend::GpgKey::IsHasEncryptionCapability() const {
+auto GpgKey::IsHasEncryptionCapability() const -> bool {
return key_ref_->can_encrypt;
}
-bool GpgFrontend::GpgKey::IsHasSigningCapability() const {
+auto GpgKey::IsHasSigningCapability() const -> bool {
return key_ref_->can_sign;
}
-bool GpgFrontend::GpgKey::IsHasCertificationCapability() const {
+auto GpgKey::IsHasCertificationCapability() const -> bool {
return key_ref_->can_certify;
}
-bool GpgFrontend::GpgKey::IsHasAuthenticationCapability() const {
+auto GpgKey::IsHasAuthenticationCapability() const -> bool {
return key_ref_->can_authenticate;
}
-bool GpgFrontend::GpgKey::IsHasCardKey() const {
+auto GpgKey::IsHasCardKey() const -> bool {
auto subkeys = GetSubKeys();
return std::any_of(
subkeys->begin(), subkeys->end(),
[](const GpgSubKey &subkey) -> bool { return subkey.IsCardKey(); });
}
-bool GpgFrontend::GpgKey::IsPrivateKey() const { return key_ref_->secret; }
+auto GpgKey::IsPrivateKey() const -> bool { return key_ref_->secret; }
-bool GpgFrontend::GpgKey::IsExpired() const { return key_ref_->expired; }
+auto GpgKey::IsExpired() const -> bool { return key_ref_->expired; }
-bool GpgFrontend::GpgKey::IsRevoked() const { return key_ref_->revoked; }
+auto GpgKey::IsRevoked() const -> bool { return key_ref_->revoked; }
-bool GpgFrontend::GpgKey::IsDisabled() const { return key_ref_->disabled; }
+auto GpgKey::IsDisabled() const -> bool { return key_ref_->disabled; }
-bool GpgFrontend::GpgKey::IsHasMasterKey() const {
+auto GpgKey::IsHasMasterKey() const -> bool {
return key_ref_->subkeys->secret;
}
-std::unique_ptr<std::vector<GpgFrontend::GpgSubKey>>
-GpgFrontend::GpgKey::GetSubKeys() const {
+auto GpgKey::GetSubKeys() const -> std::unique_ptr<std::vector<GpgSubKey>> {
auto p_keys = std::make_unique<std::vector<GpgSubKey>>();
- auto next = key_ref_->subkeys;
+ auto *next = key_ref_->subkeys;
while (next != nullptr) {
p_keys->push_back(GpgSubKey(next));
next = next->next;
@@ -178,10 +171,9 @@ GpgFrontend::GpgKey::GetSubKeys() const {
return p_keys;
}
-std::unique_ptr<std::vector<GpgFrontend::GpgUID>> GpgFrontend::GpgKey::GetUIDs()
- const {
+auto GpgKey::GetUIDs() const -> std::unique_ptr<std::vector<GpgUID>> {
auto p_uids = std::make_unique<std::vector<GpgUID>>();
- auto uid_next = key_ref_->uids;
+ auto *uid_next = key_ref_->uids;
while (uid_next != nullptr) {
p_uids->push_back(GpgUID(uid_next));
uid_next = uid_next->next;
@@ -189,32 +181,24 @@ std::unique_ptr<std::vector<GpgFrontend::GpgUID>> GpgFrontend::GpgKey::GetUIDs()
return p_uids;
}
-bool GpgFrontend::GpgKey::IsHasActualSigningCapability() const {
+auto GpgKey::IsHasActualSigningCapability() const -> bool {
auto subkeys = GetSubKeys();
- if (std::any_of(subkeys->begin(), subkeys->end(),
- [](const GpgSubKey &subkey) -> bool {
- return subkey.IsSecretKey() &&
- subkey.IsHasSigningCapability() &&
- !subkey.IsDisabled() && !subkey.IsRevoked() &&
- !subkey.IsExpired();
- }))
- return true;
- else
- return false;
+ return std::any_of(
+ subkeys->begin(), subkeys->end(), [](const GpgSubKey &subkey) -> bool {
+ return subkey.IsSecretKey() && subkey.IsHasSigningCapability() &&
+ !subkey.IsDisabled() && !subkey.IsRevoked() &&
+ !subkey.IsExpired();
+ });
}
-bool GpgFrontend::GpgKey::IsHasActualAuthenticationCapability() const {
+auto GpgKey::IsHasActualAuthenticationCapability() const -> bool {
auto subkeys = GetSubKeys();
- if (std::any_of(subkeys->begin(), subkeys->end(),
- [](const GpgSubKey &subkey) -> bool {
- return subkey.IsSecretKey() &&
- subkey.IsHasAuthenticationCapability() &&
- !subkey.IsDisabled() && !subkey.IsRevoked() &&
- !subkey.IsExpired();
- }))
- return true;
- else
- return false;
+ return std::any_of(
+ subkeys->begin(), subkeys->end(), [](const GpgSubKey &subkey) -> bool {
+ return subkey.IsSecretKey() && subkey.IsHasAuthenticationCapability() &&
+ !subkey.IsDisabled() && !subkey.IsRevoked() &&
+ !subkey.IsExpired();
+ });
}
/**
@@ -222,7 +206,7 @@ bool GpgFrontend::GpgKey::IsHasActualAuthenticationCapability() const {
* @param key target key
* @return if key certify
*/
-bool GpgFrontend::GpgKey::IsHasActualCertificationCapability() const {
+auto GpgKey::IsHasActualCertificationCapability() const -> bool {
return IsHasMasterKey() && !IsExpired() && !IsRevoked() && !IsDisabled();
}
@@ -231,28 +215,26 @@ bool GpgFrontend::GpgKey::IsHasActualCertificationCapability() const {
* @param key target key
* @return if key encrypt
*/
-bool GpgFrontend::GpgKey::IsHasActualEncryptionCapability() const {
+auto GpgKey::IsHasActualEncryptionCapability() const -> bool {
auto subkeys = GetSubKeys();
- if (std::any_of(subkeys->begin(), subkeys->end(),
- [](const GpgSubKey &subkey) -> bool {
- return subkey.IsHasEncryptionCapability() &&
- !subkey.IsDisabled() && !subkey.IsRevoked() &&
- !subkey.IsExpired();
- }))
- return true;
- else
- return false;
+ return std::any_of(
+ subkeys->begin(), subkeys->end(), [](const GpgSubKey &subkey) -> bool {
+ return subkey.IsHasEncryptionCapability() && !subkey.IsDisabled() &&
+ !subkey.IsRevoked() && !subkey.IsExpired();
+ });
}
-GpgFrontend::GpgKey GpgFrontend::GpgKey::Copy() const {
+auto GpgKey::Copy() const -> GpgKey {
{
- const std::lock_guard<std::mutex> guard(gpgme_key_opera_mutex);
+ const std::lock_guard<std::mutex> guard(gpgme_key_opera_mutex_);
gpgme_key_ref(key_ref_.get());
}
- auto *_new_key_ref = key_ref_.get();
- return GpgKey(std::move(_new_key_ref));
+ auto *new_key_ref = key_ref_.get();
+ return GpgKey(std::move(new_key_ref));
}
-void GpgFrontend::GpgKey::_key_ref_deleter::operator()(gpgme_key_t _key) {
+void GpgKey::KeyRefDeleter::operator()(gpgme_key_t _key) {
if (_key != nullptr) gpgme_key_unref(_key);
}
+
+} // namespace GpgFrontend \ No newline at end of file
diff --git a/src/core/model/GpgKey.h b/src/core/model/GpgKey.h
index 0d455f2e..6dfd5cb7 100644
--- a/src/core/model/GpgKey.h
+++ b/src/core/model/GpgKey.h
@@ -30,8 +30,8 @@
#include <mutex>
-#include "GpgSubKey.h"
-#include "GpgUID.h"
+#include "core/model/GpgSubKey.h"
+#include "core/model/GpgUID.h"
namespace GpgFrontend {
@@ -47,98 +47,98 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsGood() const;
+ [[nodiscard]] auto IsGood() const -> bool;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetId() const;
+ [[nodiscard]] auto GetId() const -> std::string;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetName() const;
+ [[nodiscard]] auto GetName() const -> std::string;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetEmail() const;
+ [[nodiscard]] auto GetEmail() const -> std::string;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetComment() const;
+ [[nodiscard]] auto GetComment() const -> std::string;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetFingerprint() const;
+ [[nodiscard]] auto GetFingerprint() const -> std::string;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetProtocol() const;
+ [[nodiscard]] auto GetProtocol() const -> std::string;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetOwnerTrust() const;
+ [[nodiscard]] auto GetOwnerTrust() const -> std::string;
/**
* @brief
*
* @return int
*/
- [[nodiscard]] int GetOwnerTrustLevel() const;
+ [[nodiscard]] auto GetOwnerTrustLevel() const -> int;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetPublicKeyAlgo() const;
+ [[nodiscard]] auto GetPublicKeyAlgo() const -> std::string;
/**
* @brief
*
* @return boost::posix_time::ptime
*/
- [[nodiscard]] boost::posix_time::ptime GetLastUpdateTime() const;
+ [[nodiscard]] auto GetLastUpdateTime() const -> boost::posix_time::ptime;
/**
* @brief
*
* @return boost::posix_time::ptime
*/
- [[nodiscard]] boost::posix_time::ptime GetExpireTime() const;
+ [[nodiscard]] auto GetExpireTime() const -> boost::posix_time::ptime;
/**
* @brief Create a time object
*
* @return boost::posix_time::ptime
*/
- [[nodiscard]] boost::posix_time::ptime GetCreateTime() const;
+ [[nodiscard]] auto GetCreateTime() const -> boost::posix_time::ptime;
/**
* @brief s
*
* @return unsigned int
*/
- [[nodiscard]] unsigned int GetPrimaryKeyLength() const;
+ [[nodiscard]] auto GetPrimaryKeyLength() const -> unsigned int;
/**
* @brief
@@ -146,7 +146,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasEncryptionCapability() const;
+ [[nodiscard]] auto IsHasEncryptionCapability() const -> bool;
/**
* @brief
@@ -155,7 +155,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasActualEncryptionCapability() const;
+ [[nodiscard]] auto IsHasActualEncryptionCapability() const -> bool;
/**
* @brief
@@ -163,7 +163,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasSigningCapability() const;
+ [[nodiscard]] auto IsHasSigningCapability() const -> bool;
/**
* @brief
@@ -171,7 +171,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasActualSigningCapability() const;
+ [[nodiscard]] auto IsHasActualSigningCapability() const -> bool;
/**
* @brief
@@ -179,7 +179,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasCertificationCapability() const;
+ [[nodiscard]] auto IsHasCertificationCapability() const -> bool;
/**
* @brief
@@ -187,7 +187,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasActualCertificationCapability() const;
+ [[nodiscard]] auto IsHasActualCertificationCapability() const -> bool;
/**
* @brief
@@ -195,7 +195,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasAuthenticationCapability() const;
+ [[nodiscard]] auto IsHasAuthenticationCapability() const -> bool;
/**
* @brief
@@ -203,7 +203,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasActualAuthenticationCapability() const;
+ [[nodiscard]] auto IsHasActualAuthenticationCapability() const -> bool;
/**
* @brief
@@ -211,7 +211,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasCardKey() const;
+ [[nodiscard]] auto IsHasCardKey() const -> bool;
/**
* @brief
@@ -219,7 +219,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsPrivateKey() const;
+ [[nodiscard]] auto IsPrivateKey() const -> bool;
/**
* @brief
@@ -227,7 +227,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsExpired() const;
+ [[nodiscard]] auto IsExpired() const -> bool;
/**
* @brief
@@ -235,7 +235,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsRevoked() const;
+ [[nodiscard]] auto IsRevoked() const -> bool;
/**
* @brief
@@ -243,7 +243,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsDisabled() const;
+ [[nodiscard]] auto IsDisabled() const -> bool;
/**
* @brief
@@ -251,21 +251,22 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasMasterKey() const;
+ [[nodiscard]] auto IsHasMasterKey() const -> bool;
/**
* @brief
*
* @return std::unique_ptr<std::vector<GpgSubKey>>
*/
- [[nodiscard]] std::unique_ptr<std::vector<GpgSubKey>> GetSubKeys() const;
+ [[nodiscard]] auto GetSubKeys() const
+ -> std::unique_ptr<std::vector<GpgSubKey>>;
/**
* @brief
*
* @return std::unique_ptr<std::vector<GpgUID>>
*/
- [[nodiscard]] std::unique_ptr<std::vector<GpgUID>> GetUIDs() const;
+ [[nodiscard]] auto GetUIDs() const -> std::unique_ptr<std::vector<GpgUID>>;
/**
* @brief Construct a new Gpg Key object
@@ -306,7 +307,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @param k
* @return GpgKey&
*/
- GpgKey& operator=(GpgKey&& k) noexcept;
+ auto operator=(GpgKey&& k) noexcept -> GpgKey&;
/**
* @brief
@@ -314,7 +315,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @param key
* @return GpgKey&
*/
- GpgKey& operator=(const gpgme_key_t& key) = delete;
+ auto operator=(const gpgme_key_t& key) -> GpgKey& = delete;
/**
* @brief
@@ -323,7 +324,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @return true
* @return false
*/
- bool operator==(const GpgKey& o) const;
+ auto operator==(const GpgKey& o) const -> bool;
/**
* @brief
@@ -332,7 +333,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
* @return true
* @return false
*/
- bool operator<=(const GpgKey& o) const;
+ auto operator<=(const GpgKey& o) const -> bool;
/**
* @brief
@@ -346,23 +347,22 @@ class GPGFRONTEND_CORE_EXPORT GpgKey {
*
* @return GpgKey
*/
- [[nodiscard]] GpgKey Copy() const;
+ [[nodiscard]] auto Copy() const -> GpgKey;
private:
/**
* @brief
*
*/
- struct GPGFRONTEND_CORE_EXPORT _key_ref_deleter {
+ struct GPGFRONTEND_CORE_EXPORT KeyRefDeleter {
void operator()(gpgme_key_t _key);
};
- using KeyRefHandler =
- std::unique_ptr<struct _gpgme_key, _key_ref_deleter>; ///<
+ using KeyRefHandler = std::unique_ptr<struct _gpgme_key, KeyRefDeleter>; ///<
KeyRefHandler key_ref_ = nullptr; ///<
- mutable std::mutex gpgme_key_opera_mutex; // mutex for gpgme key operations
+ mutable std::mutex gpgme_key_opera_mutex_; // mutex for gpgme key operations
};
} // namespace GpgFrontend
diff --git a/src/core/model/GpgKeySignature.cpp b/src/core/model/GpgKeySignature.cpp
index ffbd2e6f..14dc8f1a 100644
--- a/src/core/model/GpgKeySignature.cpp
+++ b/src/core/model/GpgKeySignature.cpp
@@ -28,67 +28,55 @@
#include "core/model/GpgKeySignature.h"
-GpgFrontend::GpgKeySignature::GpgKeySignature() = default;
+namespace GpgFrontend {
-GpgFrontend::GpgKeySignature::~GpgKeySignature() = default;
+GpgKeySignature::GpgKeySignature() = default;
-GpgFrontend::GpgKeySignature::GpgKeySignature(gpgme_key_sig_t sig)
+GpgKeySignature::~GpgKeySignature() = default;
+
+GpgKeySignature::GpgKeySignature(gpgme_key_sig_t sig)
: signature_ref_(sig, [&](gpgme_key_sig_t signature) {}) {}
-GpgFrontend::GpgKeySignature::GpgKeySignature(GpgKeySignature &&) noexcept =
- default;
+GpgKeySignature::GpgKeySignature(GpgKeySignature &&) noexcept = default;
-GpgFrontend::GpgKeySignature &GpgFrontend::GpgKeySignature::operator=(
- GpgKeySignature &&) noexcept = default;
+GpgKeySignature &GpgKeySignature::operator=(GpgKeySignature &&) noexcept =
+ default;
-bool GpgFrontend::GpgKeySignature::IsRevoked() const {
- return signature_ref_->revoked;
-}
+bool GpgKeySignature::IsRevoked() const { return signature_ref_->revoked; }
-bool GpgFrontend::GpgKeySignature::IsExpired() const {
- return signature_ref_->expired;
-}
+bool GpgKeySignature::IsExpired() const { return signature_ref_->expired; }
-bool GpgFrontend::GpgKeySignature::IsInvalid() const {
- return signature_ref_->invalid;
-}
+bool GpgKeySignature::IsInvalid() const { return signature_ref_->invalid; }
-bool GpgFrontend::GpgKeySignature::IsExportable() const {
+bool GpgKeySignature::IsExportable() const {
return signature_ref_->exportable;
}
-gpgme_error_t GpgFrontend::GpgKeySignature::GetStatus() const {
+gpgme_error_t GpgKeySignature::GetStatus() const {
return signature_ref_->status;
}
-std::string GpgFrontend::GpgKeySignature::GetKeyID() const {
- return signature_ref_->keyid;
-}
+std::string GpgKeySignature::GetKeyID() const { return signature_ref_->keyid; }
-std::string GpgFrontend::GpgKeySignature::GetPubkeyAlgo() const {
+std::string GpgKeySignature::GetPubkeyAlgo() const {
return gpgme_pubkey_algo_name(signature_ref_->pubkey_algo);
}
-boost::posix_time::ptime GpgFrontend::GpgKeySignature::GetCreateTime() const {
+boost::posix_time::ptime GpgKeySignature::GetCreateTime() const {
return boost::posix_time::from_time_t(signature_ref_->timestamp);
}
-boost::posix_time::ptime GpgFrontend::GpgKeySignature::GetExpireTime() const {
+boost::posix_time::ptime GpgKeySignature::GetExpireTime() const {
return boost::posix_time::from_time_t(signature_ref_->expires);
}
-std::string GpgFrontend::GpgKeySignature::GetUID() const {
- return signature_ref_->uid;
-}
+std::string GpgKeySignature::GetUID() const { return signature_ref_->uid; }
-std::string GpgFrontend::GpgKeySignature::GetName() const {
- return signature_ref_->name;
-}
+std::string GpgKeySignature::GetName() const { return signature_ref_->name; }
-std::string GpgFrontend::GpgKeySignature::GetEmail() const {
- return signature_ref_->email;
-}
+std::string GpgKeySignature::GetEmail() const { return signature_ref_->email; }
-std::string GpgFrontend::GpgKeySignature::GetComment() const {
+std::string GpgKeySignature::GetComment() const {
return signature_ref_->comment;
-} \ No newline at end of file
+}
+} // namespace GpgFrontend \ No newline at end of file
diff --git a/src/core/model/GpgKeySignature.h b/src/core/model/GpgKeySignature.h
index 395a9dcb..fa000749 100644
--- a/src/core/model/GpgKeySignature.h
+++ b/src/core/model/GpgKeySignature.h
@@ -30,7 +30,7 @@
#include <boost/date_time.hpp>
-#include "core/GpgConstants.h"
+#include "core/typedef/GpgTypedef.h"
/**
* @brief
@@ -50,7 +50,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKeySignature {
* @return true
* @return false
*/
- [[nodiscard]] bool IsRevoked() const;
+ [[nodiscard]] auto IsRevoked() const -> bool;
/**
* @brief
@@ -58,7 +58,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKeySignature {
* @return true
* @return false
*/
- [[nodiscard]] bool IsExpired() const;
+ [[nodiscard]] auto IsExpired() const -> bool;
/**
* @brief
@@ -66,7 +66,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKeySignature {
* @return true
* @return false
*/
- [[nodiscard]] bool IsInvalid() const;
+ [[nodiscard]] auto IsInvalid() const -> bool;
/**
* @brief
@@ -74,70 +74,70 @@ class GPGFRONTEND_CORE_EXPORT GpgKeySignature {
* @return true
* @return false
*/
- [[nodiscard]] bool IsExportable() const;
+ [[nodiscard]] auto IsExportable() const -> bool;
/**
* @brief
*
* @return gpgme_error_t
*/
- [[nodiscard]] gpgme_error_t GetStatus() const;
+ [[nodiscard]] auto GetStatus() const -> GpgError;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetKeyID() const;
+ [[nodiscard]] auto GetKeyID() const -> std::string;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetPubkeyAlgo() const;
+ [[nodiscard]] auto GetPubkeyAlgo() const -> std::string;
/**
* @brief Create a time object
*
* @return boost::posix_time::ptime
*/
- [[nodiscard]] boost::posix_time::ptime GetCreateTime() const;
+ [[nodiscard]] auto GetCreateTime() const -> boost::posix_time::ptime;
/**
* @brief
*
* @return boost::posix_time::ptime
*/
- [[nodiscard]] boost::posix_time::ptime GetExpireTime() const;
+ [[nodiscard]] auto GetExpireTime() const -> boost::posix_time::ptime;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetUID() const;
+ [[nodiscard]] auto GetUID() const -> std::string;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetName() const;
+ [[nodiscard]] auto GetName() const -> std::string;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetEmail() const;
+ [[nodiscard]] auto GetEmail() const -> std::string;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetComment() const;
+ [[nodiscard]] auto GetComment() const -> std::string;
/**
* @brief Construct a new Gpg Key Signature object
@@ -175,14 +175,14 @@ class GPGFRONTEND_CORE_EXPORT GpgKeySignature {
*
* @return GpgKeySignature&
*/
- GpgKeySignature &operator=(GpgKeySignature &&) noexcept;
+ auto operator=(GpgKeySignature &&) noexcept -> GpgKeySignature &;
/**
* @brief
*
* @return GpgKeySignature&
*/
- GpgKeySignature &operator=(const GpgKeySignature &) = delete;
+ auto operator=(const GpgKeySignature &) -> GpgKeySignature & = delete;
private:
using KeySignatrueRefHandler =
diff --git a/src/core/model/GpgSignature.cpp b/src/core/model/GpgSignature.cpp
index bf7b0b9d..727942f5 100644
--- a/src/core/model/GpgSignature.cpp
+++ b/src/core/model/GpgSignature.cpp
@@ -28,21 +28,28 @@
#include "GpgSignature.h"
+namespace GpgFrontend {
+
/**
* @brief Construct a new Gpg Signature object
*
*/
-GpgFrontend::GpgSignature::GpgSignature(GpgSignature &&) noexcept = default;
+GpgSignature::GpgSignature(GpgSignature &&) noexcept = default;
/**
* @brief
*
* @return GpgSignature&
*/
-GpgFrontend::GpgSignature &GpgFrontend::GpgSignature::operator=(
- GpgFrontend::GpgSignature &&) noexcept = default;
+auto GpgSignature::operator=(GpgSignature &&) noexcept
+ -> GpgSignature & = default;
-GpgFrontend::GpgSignature::GpgSignature(gpgme_signature_t sig)
+/**
+ * @brief Construct a new Gpg Signature:: Gpg Signature object
+ *
+ * @param sig
+ */
+GpgSignature::GpgSignature(gpgme_signature_t sig)
: signature_ref_(sig, [&](gpgme_signature_t signature) {}) {}
/**
@@ -50,7 +57,7 @@ GpgFrontend::GpgSignature::GpgSignature(gpgme_signature_t sig)
*
* @return gpgme_validity_t
*/
-gpgme_validity_t GpgFrontend::GpgSignature::GetValidity() const {
+auto GpgSignature::GetValidity() const -> gpgme_validity_t {
return signature_ref_->validity;
}
@@ -59,7 +66,7 @@ gpgme_validity_t GpgFrontend::GpgSignature::GetValidity() const {
*
* @return gpgme_error_t
*/
-gpgme_error_t GpgFrontend::GpgSignature::GetStatus() const {
+auto GpgSignature::GetStatus() const -> gpgme_error_t {
return signature_ref_->status;
}
@@ -68,7 +75,7 @@ gpgme_error_t GpgFrontend::GpgSignature::GetStatus() const {
*
* @return gpgme_error_t
*/
-gpgme_error_t GpgFrontend::GpgSignature::GetSummary() const {
+auto GpgSignature::GetSummary() const -> gpgme_error_t {
return signature_ref_->summary;
}
@@ -77,7 +84,7 @@ gpgme_error_t GpgFrontend::GpgSignature::GetSummary() const {
*
* @return std::string
*/
-std::string GpgFrontend::GpgSignature::GetPubkeyAlgo() const {
+auto GpgSignature::GetPubkeyAlgo() const -> std::string {
return gpgme_pubkey_algo_name(signature_ref_->pubkey_algo);
}
@@ -86,7 +93,7 @@ std::string GpgFrontend::GpgSignature::GetPubkeyAlgo() const {
*
* @return std::string
*/
-std::string GpgFrontend::GpgSignature::GetHashAlgo() const {
+auto GpgSignature::GetHashAlgo() const -> std::string {
return gpgme_hash_algo_name(signature_ref_->hash_algo);
}
@@ -95,7 +102,7 @@ std::string GpgFrontend::GpgSignature::GetHashAlgo() const {
*
* @return boost::posix_time::ptime
*/
-boost::posix_time::ptime GpgFrontend::GpgSignature::GetCreateTime() const {
+auto GpgSignature::GetCreateTime() const -> boost::posix_time::ptime {
return boost::posix_time::from_time_t(signature_ref_->timestamp);
}
@@ -104,7 +111,7 @@ boost::posix_time::ptime GpgFrontend::GpgSignature::GetCreateTime() const {
*
* @return boost::posix_time::ptime
*/
-boost::posix_time::ptime GpgFrontend::GpgSignature::GetExpireTime() const {
+auto GpgSignature::GetExpireTime() const -> boost::posix_time::ptime {
return boost::posix_time::from_time_t(signature_ref_->exp_timestamp);
}
@@ -113,7 +120,7 @@ boost::posix_time::ptime GpgFrontend::GpgSignature::GetExpireTime() const {
*
* @return std::string
*/
-std::string GpgFrontend::GpgSignature::GetFingerprint() const {
+auto GpgSignature::GetFingerprint() const -> std::string {
return signature_ref_->fpr;
}
@@ -121,10 +128,12 @@ std::string GpgFrontend::GpgSignature::GetFingerprint() const {
* @brief Construct a new Gpg Signature object
*
*/
-GpgFrontend::GpgSignature::GpgSignature() = default;
+GpgSignature::GpgSignature() = default;
/**
* @brief Destroy the Gpg Signature object
*
*/
-GpgFrontend::GpgSignature::~GpgSignature() = default;
+GpgSignature::~GpgSignature() = default;
+
+} // namespace GpgFrontend
diff --git a/src/core/model/GpgSignature.h b/src/core/model/GpgSignature.h
index d34d89ce..4e01d728 100644
--- a/src/core/model/GpgSignature.h
+++ b/src/core/model/GpgSignature.h
@@ -28,10 +28,9 @@
#pragma once
-#include <boost/date_time/gregorian/greg_date.hpp>
-#include <boost/date_time/posix_time/conversion.hpp>
+#include <boost/date_time.hpp>
-#include "core/GpgConstants.h"
+#include "core/typedef/GpgTypedef.h"
namespace GpgFrontend {
@@ -46,56 +45,56 @@ class GPGFRONTEND_CORE_EXPORT GpgSignature {
*
* @return gpgme_validity_t
*/
- [[nodiscard]] gpgme_validity_t GetValidity() const;
+ [[nodiscard]] auto GetValidity() const -> gpgme_validity_t;
/**
* @brief
*
* @return gpgme_error_t
*/
- [[nodiscard]] gpgme_error_t GetStatus() const;
+ [[nodiscard]] auto GetStatus() const -> GpgError;
/**
* @brief
*
* @return gpgme_error_t
*/
- [[nodiscard]] gpgme_error_t GetSummary() const;
+ [[nodiscard]] auto GetSummary() const -> GpgError;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetPubkeyAlgo() const;
+ [[nodiscard]] auto GetPubkeyAlgo() const -> std::string;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetHashAlgo() const;
+ [[nodiscard]] auto GetHashAlgo() const -> std::string;
/**
* @brief Create a time object
*
* @return boost::posix_time::ptime
*/
- [[nodiscard]] boost::posix_time::ptime GetCreateTime() const;
+ [[nodiscard]] auto GetCreateTime() const -> boost::posix_time::ptime;
/**
* @brief
*
* @return boost::posix_time::ptime
*/
- [[nodiscard]] boost::posix_time::ptime GetExpireTime() const;
+ [[nodiscard]] auto GetExpireTime() const -> boost::posix_time::ptime;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetFingerprint() const;
+ [[nodiscard]] auto GetFingerprint() const -> std::string;
/**
* @brief Construct a new Gpg Signature object
@@ -133,14 +132,14 @@ class GPGFRONTEND_CORE_EXPORT GpgSignature {
*
* @return GpgSignature&
*/
- GpgSignature &operator=(GpgSignature &&) noexcept;
+ auto operator=(GpgSignature &&) noexcept -> GpgSignature &;
/**
* @brief
*
* @return GpgSignature&
*/
- GpgSignature &operator=(const GpgSignature &) = delete;
+ auto operator=(const GpgSignature &) -> GpgSignature & = delete;
private:
using KeySignatrueRefHandler =
diff --git a/src/core/model/GpgSubKey.cpp b/src/core/model/GpgSubKey.cpp
index b85df7f3..e4103d50 100644
--- a/src/core/model/GpgSubKey.cpp
+++ b/src/core/model/GpgSubKey.cpp
@@ -25,79 +25,76 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*
*/
-#include "core/model/GpgSubKey.h"
+#include "GpgSubKey.h"
-GpgFrontend::GpgSubKey::GpgSubKey() = default;
+namespace GpgFrontend {
-GpgFrontend::GpgSubKey::GpgSubKey(gpgme_subkey_t subkey)
- : _subkey_ref(subkey, [&](gpgme_subkey_t subkey) {}) {}
+GpgSubKey::GpgSubKey() = default;
-GpgFrontend::GpgSubKey::GpgSubKey(GpgSubKey&& o) noexcept {
- swap(_subkey_ref, o._subkey_ref);
+GpgSubKey::GpgSubKey(gpgme_subkey_t subkey)
+ : subkey_ref_(subkey, [&](gpgme_subkey_t subkey) {}) {}
+
+GpgSubKey::GpgSubKey(GpgSubKey&& o) noexcept {
+ swap(subkey_ref_, o.subkey_ref_);
}
-GpgFrontend::GpgSubKey& GpgFrontend::GpgSubKey::operator=(
- GpgSubKey&& o) noexcept {
- swap(_subkey_ref, o._subkey_ref);
+auto GpgSubKey::operator=(GpgSubKey&& o) noexcept -> GpgSubKey& {
+ swap(subkey_ref_, o.subkey_ref_);
return *this;
};
-bool GpgFrontend::GpgSubKey::operator==(const GpgSubKey& o) const {
+auto GpgSubKey::operator==(const GpgSubKey& o) const -> bool {
return GetFingerprint() == o.GetFingerprint();
}
-std::string GpgFrontend::GpgSubKey::GetID() const { return _subkey_ref->keyid; }
+auto GpgSubKey::GetID() const -> std::string { return subkey_ref_->keyid; }
-std::string GpgFrontend::GpgSubKey::GetFingerprint() const {
- return _subkey_ref->fpr;
+auto GpgSubKey::GetFingerprint() const -> std::string {
+ return subkey_ref_->fpr;
}
-std::string GpgFrontend::GpgSubKey::GetPubkeyAlgo() const {
- return gpgme_pubkey_algo_name(_subkey_ref->pubkey_algo);
+auto GpgSubKey::GetPubkeyAlgo() const -> std::string {
+ return gpgme_pubkey_algo_name(subkey_ref_->pubkey_algo);
}
-unsigned int GpgFrontend::GpgSubKey::GetKeyLength() const {
- return _subkey_ref->length;
+auto GpgSubKey::GetKeyLength() const -> unsigned int {
+ return subkey_ref_->length;
}
-bool GpgFrontend::GpgSubKey::IsHasEncryptionCapability() const {
- return _subkey_ref->can_encrypt;
+auto GpgSubKey::IsHasEncryptionCapability() const -> bool {
+ return subkey_ref_->can_encrypt;
}
-bool GpgFrontend::GpgSubKey::IsHasSigningCapability() const {
- return _subkey_ref->can_sign;
+auto GpgSubKey::IsHasSigningCapability() const -> bool {
+ return subkey_ref_->can_sign;
}
-bool GpgFrontend::GpgSubKey::IsHasCertificationCapability() const {
- return _subkey_ref->can_certify;
+auto GpgSubKey::IsHasCertificationCapability() const -> bool {
+ return subkey_ref_->can_certify;
}
-bool GpgFrontend::GpgSubKey::IsHasAuthenticationCapability() const {
- return _subkey_ref->can_authenticate;
+auto GpgSubKey::IsHasAuthenticationCapability() const -> bool {
+ return subkey_ref_->can_authenticate;
}
-bool GpgFrontend::GpgSubKey::IsPrivateKey() const {
- return _subkey_ref->secret;
-}
+auto GpgSubKey::IsPrivateKey() const -> bool { return subkey_ref_->secret; }
-bool GpgFrontend::GpgSubKey::IsExpired() const { return _subkey_ref->expired; }
+auto GpgSubKey::IsExpired() const -> bool { return subkey_ref_->expired; }
-bool GpgFrontend::GpgSubKey::IsRevoked() const { return _subkey_ref->revoked; }
+auto GpgSubKey::IsRevoked() const -> bool { return subkey_ref_->revoked; }
-bool GpgFrontend::GpgSubKey::IsDisabled() const {
- return _subkey_ref->disabled;
-}
+auto GpgSubKey::IsDisabled() const -> bool { return subkey_ref_->disabled; }
-bool GpgFrontend::GpgSubKey::IsSecretKey() const { return _subkey_ref->secret; }
+auto GpgSubKey::IsSecretKey() const -> bool { return subkey_ref_->secret; }
-bool GpgFrontend::GpgSubKey::IsCardKey() const {
- return _subkey_ref->is_cardkey;
-}
+auto GpgSubKey::IsCardKey() const -> bool { return subkey_ref_->is_cardkey; }
-boost::posix_time::ptime GpgFrontend::GpgSubKey::GetCreateTime() const {
- return boost::posix_time::from_time_t(_subkey_ref->timestamp);
+auto GpgSubKey::GetCreateTime() const -> boost::posix_time::ptime {
+ return boost::posix_time::from_time_t(subkey_ref_->timestamp);
}
-boost::posix_time::ptime GpgFrontend::GpgSubKey::GetExpireTime() const {
- return boost::posix_time::from_time_t(_subkey_ref->expires);
+auto GpgSubKey::GetExpireTime() const -> boost::posix_time::ptime {
+ return boost::posix_time::from_time_t(subkey_ref_->expires);
}
+
+} // namespace GpgFrontend
diff --git a/src/core/model/GpgSubKey.h b/src/core/model/GpgSubKey.h
index 906a5fda..f70f7e9c 100644
--- a/src/core/model/GpgSubKey.h
+++ b/src/core/model/GpgSubKey.h
@@ -43,28 +43,28 @@ class GPGFRONTEND_CORE_EXPORT GpgSubKey {
*
* @return std::string
*/
- [[nodiscard]] std::string GetID() const;
+ [[nodiscard]] auto GetID() const -> std::string;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetFingerprint() const;
+ [[nodiscard]] auto GetFingerprint() const -> std::string;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetPubkeyAlgo() const;
+ [[nodiscard]] auto GetPubkeyAlgo() const -> std::string;
/**
* @brief
*
* @return unsigned int
*/
- [[nodiscard]] unsigned int GetKeyLength() const;
+ [[nodiscard]] auto GetKeyLength() const -> unsigned int;
/**
* @brief
@@ -72,7 +72,7 @@ class GPGFRONTEND_CORE_EXPORT GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasEncryptionCapability() const;
+ [[nodiscard]] auto IsHasEncryptionCapability() const -> bool;
/**
* @brief
@@ -80,7 +80,7 @@ class GPGFRONTEND_CORE_EXPORT GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasSigningCapability() const;
+ [[nodiscard]] auto IsHasSigningCapability() const -> bool;
/**
* @brief
@@ -88,7 +88,7 @@ class GPGFRONTEND_CORE_EXPORT GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasCertificationCapability() const;
+ [[nodiscard]] auto IsHasCertificationCapability() const -> bool;
/**
* @brief
@@ -96,7 +96,7 @@ class GPGFRONTEND_CORE_EXPORT GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasAuthenticationCapability() const;
+ [[nodiscard]] auto IsHasAuthenticationCapability() const -> bool;
/**
* @brief
@@ -104,7 +104,7 @@ class GPGFRONTEND_CORE_EXPORT GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsPrivateKey() const;
+ [[nodiscard]] auto IsPrivateKey() const -> bool;
/**
* @brief
@@ -112,7 +112,7 @@ class GPGFRONTEND_CORE_EXPORT GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsExpired() const;
+ [[nodiscard]] auto IsExpired() const -> bool;
/**
* @brief
@@ -120,7 +120,7 @@ class GPGFRONTEND_CORE_EXPORT GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsRevoked() const;
+ [[nodiscard]] auto IsRevoked() const -> bool;
/**
* @brief
@@ -128,7 +128,7 @@ class GPGFRONTEND_CORE_EXPORT GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsDisabled() const;
+ [[nodiscard]] auto IsDisabled() const -> bool;
/**
* @brief
@@ -136,7 +136,7 @@ class GPGFRONTEND_CORE_EXPORT GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsSecretKey() const;
+ [[nodiscard]] auto IsSecretKey() const -> bool;
/**
* @brief
@@ -144,14 +144,14 @@ class GPGFRONTEND_CORE_EXPORT GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsCardKey() const;
+ [[nodiscard]] auto IsCardKey() const -> bool;
/**
* @brief
*
* @return boost::posix_time::ptime
*/
- [[nodiscard]] boost::posix_time::ptime GetCreateTime() const;
+ [[nodiscard]] auto GetCreateTime() const -> boost::posix_time::ptime;
/**
* @brief
@@ -192,14 +192,14 @@ class GPGFRONTEND_CORE_EXPORT GpgSubKey {
* @param o
* @return GpgSubKey&
*/
- GpgSubKey& operator=(GpgSubKey&& o) noexcept;
+ auto operator=(GpgSubKey&& o) noexcept -> GpgSubKey&;
/**
* @brief
*
* @return GpgSubKey&
*/
- GpgSubKey& operator=(const GpgSubKey&) = delete;
+ auto operator=(const GpgSubKey&) -> GpgSubKey& = delete;
/**
* @brief
@@ -208,14 +208,14 @@ class GPGFRONTEND_CORE_EXPORT GpgSubKey {
* @return true
* @return false
*/
- bool operator==(const GpgSubKey& o) const;
+ auto operator==(const GpgSubKey& o) const -> bool;
private:
using SubkeyRefHandler =
std::unique_ptr<struct _gpgme_subkey,
std::function<void(gpgme_subkey_t)>>; ///<
- SubkeyRefHandler _subkey_ref = nullptr; ///<
+ SubkeyRefHandler subkey_ref_ = nullptr; ///<
};
} // namespace GpgFrontend
diff --git a/src/core/model/GpgTOFUInfo.cpp b/src/core/model/GpgTOFUInfo.cpp
index fb313b7f..4e99ebf5 100644
--- a/src/core/model/GpgTOFUInfo.cpp
+++ b/src/core/model/GpgTOFUInfo.cpp
@@ -28,39 +28,40 @@
#include "GpgTOFUInfo.h"
-GpgFrontend::GpgTOFUInfo::GpgTOFUInfo() = default;
+namespace GpgFrontend {
-GpgFrontend::GpgTOFUInfo::GpgTOFUInfo(gpgme_tofu_info_t tofu_info)
- : _tofu_info_ref(tofu_info, [&](gpgme_tofu_info_t tofu_info) {}) {}
+GpgTOFUInfo::GpgTOFUInfo() = default;
-GpgFrontend::GpgTOFUInfo::GpgTOFUInfo(GpgTOFUInfo&& o) noexcept {
- swap(_tofu_info_ref, o._tofu_info_ref);
+GpgTOFUInfo::GpgTOFUInfo(gpgme_tofu_info_t tofu_info)
+ : tofu_info_ref_(tofu_info, [&](gpgme_tofu_info_t tofu_info) {}) {}
+
+GpgTOFUInfo::GpgTOFUInfo(GpgTOFUInfo&& o) noexcept {
+ swap(tofu_info_ref_, o.tofu_info_ref_);
}
-GpgFrontend::GpgTOFUInfo& GpgFrontend::GpgTOFUInfo::operator=(
- GpgTOFUInfo&& o) noexcept {
- swap(_tofu_info_ref, o._tofu_info_ref);
+auto GpgTOFUInfo::operator=(GpgTOFUInfo&& o) noexcept -> GpgTOFUInfo& {
+ swap(tofu_info_ref_, o.tofu_info_ref_);
return *this;
};
-unsigned GpgFrontend::GpgTOFUInfo::GetValidity() const {
- return _tofu_info_ref->validity;
+auto GpgTOFUInfo::GetValidity() const -> unsigned {
+ return tofu_info_ref_->validity;
}
-unsigned GpgFrontend::GpgTOFUInfo::GetPolicy() const {
- return _tofu_info_ref->policy;
+auto GpgTOFUInfo::GetPolicy() const -> unsigned {
+ return tofu_info_ref_->policy;
}
-unsigned long GpgFrontend::GpgTOFUInfo::GetSignCount() const {
- return _tofu_info_ref->signcount;
+auto GpgTOFUInfo::GetSignCount() const -> unsigned long {
+ return tofu_info_ref_->signcount;
}
-unsigned long GpgFrontend::GpgTOFUInfo::GetEncrCount() const {
- return _tofu_info_ref->encrcount;
+auto GpgTOFUInfo::GetEncrCount() const -> unsigned long {
+ return tofu_info_ref_->encrcount;
}
-unsigned long GpgFrontend::GpgTOFUInfo::GetSignFirst() const {
- return _tofu_info_ref->signfirst;
+auto GpgTOFUInfo::GetSignFirst() const -> unsigned long {
+ return tofu_info_ref_->signfirst;
}
/**
@@ -68,8 +69,8 @@ unsigned long GpgFrontend::GpgTOFUInfo::GetSignFirst() const {
*
* @return unsigned long
*/
-unsigned long GpgFrontend::GpgTOFUInfo::GetSignLast() const {
- return _tofu_info_ref->signlast;
+auto GpgTOFUInfo::GetSignLast() const -> unsigned long {
+ return tofu_info_ref_->signlast;
}
/**
@@ -77,8 +78,8 @@ unsigned long GpgFrontend::GpgTOFUInfo::GetSignLast() const {
*
* @return unsigned long
*/
-unsigned long GpgFrontend::GpgTOFUInfo::GetEncrLast() const {
- return _tofu_info_ref->encrlast;
+auto GpgTOFUInfo::GetEncrLast() const -> unsigned long {
+ return tofu_info_ref_->encrlast;
}
/**
@@ -86,6 +87,8 @@ unsigned long GpgFrontend::GpgTOFUInfo::GetEncrLast() const {
*
* @return std::string
*/
-std::string GpgFrontend::GpgTOFUInfo::GetDescription() const {
- return _tofu_info_ref->description;
-} \ No newline at end of file
+auto GpgTOFUInfo::GetDescription() const -> std::string {
+ return tofu_info_ref_->description;
+}
+
+} // namespace GpgFrontend \ No newline at end of file
diff --git a/src/core/model/GpgTOFUInfo.h b/src/core/model/GpgTOFUInfo.h
index 9deec33f..c9f52bca 100644
--- a/src/core/model/GpgTOFUInfo.h
+++ b/src/core/model/GpgTOFUInfo.h
@@ -40,55 +40,55 @@ class GPGFRONTEND_CORE_EXPORT GpgTOFUInfo {
*
* @return unsigned
*/
- [[nodiscard]] unsigned GetValidity() const;
+ [[nodiscard]] auto GetValidity() const -> unsigned;
/**
* @brief
*
* @return unsigned
*/
- [[nodiscard]] unsigned GetPolicy() const;
+ [[nodiscard]] auto GetPolicy() const -> unsigned;
/**
* @brief
*
* @return unsigned long
*/
- [[nodiscard]] unsigned long GetSignCount() const;
+ [[nodiscard]] auto GetSignCount() const -> unsigned long;
/**
* @brief
*
* @return unsigned long
*/
- [[nodiscard]] unsigned long GetEncrCount() const;
+ [[nodiscard]] auto GetEncrCount() const -> unsigned long;
/**
* @brief
*
* @return unsigned long
*/
- [[nodiscard]] unsigned long GetSignFirst() const;
+ [[nodiscard]] auto GetSignFirst() const -> unsigned long;
/**
* @brief
*
* @return unsigned long
*/
- [[nodiscard]] unsigned long GetSignLast() const;
+ [[nodiscard]] auto GetSignLast() const -> unsigned long;
/**
* @brief
*
* @return unsigned long
*/
- [[nodiscard]] unsigned long GetEncrLast() const;
+ [[nodiscard]] auto GetEncrLast() const -> unsigned long;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetDescription() const;
+ [[nodiscard]] auto GetDescription() const -> std::string;
/**
* @brief Construct a new Gpg T O F U Info object
@@ -122,21 +122,21 @@ class GPGFRONTEND_CORE_EXPORT GpgTOFUInfo {
* @param o
* @return GpgTOFUInfo&
*/
- GpgTOFUInfo& operator=(GpgTOFUInfo&& o) noexcept;
+ auto operator=(GpgTOFUInfo&& o) noexcept -> GpgTOFUInfo&;
/**
* @brief
*
* @return GpgTOFUInfo&
*/
- GpgTOFUInfo& operator=(const GpgTOFUInfo&) = delete;
+ auto operator=(const GpgTOFUInfo&) -> GpgTOFUInfo& = delete;
private:
using SubkeyRefHandler =
std::unique_ptr<struct _gpgme_tofu_info,
std::function<void(gpgme_tofu_info_t)>>; ///<
- SubkeyRefHandler _tofu_info_ref = nullptr; ///<
+ SubkeyRefHandler tofu_info_ref_ = nullptr; ///<
};
} // namespace GpgFrontend
diff --git a/src/core/model/GpgUID.cpp b/src/core/model/GpgUID.cpp
index 2ac8f335..4327ae6a 100644
--- a/src/core/model/GpgUID.cpp
+++ b/src/core/model/GpgUID.cpp
@@ -28,31 +28,30 @@
#include "core/model/GpgUID.h"
-GpgFrontend::GpgUID::GpgUID() = default;
+namespace GpgFrontend {
-GpgFrontend::GpgUID::GpgUID(gpgme_user_id_t uid)
+GpgUID::GpgUID() = default;
+
+GpgUID::GpgUID(gpgme_user_id_t uid)
: uid_ref_(uid, [&](gpgme_user_id_t uid) {}) {}
-GpgFrontend::GpgUID::GpgUID(GpgUID &&o) noexcept { swap(uid_ref_, o.uid_ref_); }
+GpgUID::GpgUID(GpgUID &&o) noexcept { swap(uid_ref_, o.uid_ref_); }
-std::string GpgFrontend::GpgUID::GetName() const { return uid_ref_->name; }
+auto GpgUID::GetName() const -> std::string { return uid_ref_->name; }
-std::string GpgFrontend::GpgUID::GetEmail() const { return uid_ref_->email; }
+auto GpgUID::GetEmail() const -> std::string { return uid_ref_->email; }
-std::string GpgFrontend::GpgUID::GetComment() const {
- return uid_ref_->comment;
-}
+auto GpgUID::GetComment() const -> std::string { return uid_ref_->comment; }
-std::string GpgFrontend::GpgUID::GetUID() const { return uid_ref_->uid; }
+auto GpgUID::GetUID() const -> std::string { return uid_ref_->uid; }
-bool GpgFrontend::GpgUID::GetRevoked() const { return uid_ref_->revoked; }
+auto GpgUID::GetRevoked() const -> bool { return uid_ref_->revoked; }
-bool GpgFrontend::GpgUID::GetInvalid() const { return uid_ref_->invalid; }
+auto GpgUID::GetInvalid() const -> bool { return uid_ref_->invalid; }
-std::unique_ptr<std::vector<GpgFrontend::GpgTOFUInfo>>
-GpgFrontend::GpgUID::GetTofuInfos() const {
+auto GpgUID::GetTofuInfos() const -> std::unique_ptr<std::vector<GpgTOFUInfo>> {
auto infos = std::make_unique<std::vector<GpgTOFUInfo>>();
- auto info_next = uid_ref_->tofu;
+ auto *info_next = uid_ref_->tofu;
while (info_next != nullptr) {
infos->push_back(GpgTOFUInfo(info_next));
info_next = info_next->next;
@@ -60,13 +59,15 @@ GpgFrontend::GpgUID::GetTofuInfos() const {
return infos;
}
-std::unique_ptr<std::vector<GpgFrontend::GpgKeySignature>>
-GpgFrontend::GpgUID::GetSignatures() const {
+auto GpgUID::GetSignatures() const
+ -> std::unique_ptr<std::vector<GpgKeySignature>> {
auto sigs = std::make_unique<std::vector<GpgKeySignature>>();
- auto sig_next = uid_ref_->signatures;
+ auto *sig_next = uid_ref_->signatures;
while (sig_next != nullptr) {
sigs->push_back(GpgKeySignature(sig_next));
sig_next = sig_next->next;
}
return sigs;
}
+
+} // namespace GpgFrontend \ No newline at end of file
diff --git a/src/core/model/GpgUID.h b/src/core/model/GpgUID.h
index 1d35d993..b8ed8d14 100644
--- a/src/core/model/GpgUID.h
+++ b/src/core/model/GpgUID.h
@@ -43,28 +43,28 @@ class GPGFRONTEND_CORE_EXPORT GpgUID {
*
* @return std::string
*/
- [[nodiscard]] std::string GetName() const;
+ [[nodiscard]] auto GetName() const -> std::string;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetEmail() const;
+ [[nodiscard]] auto GetEmail() const -> std::string;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetComment() const;
+ [[nodiscard]] auto GetComment() const -> std::string;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetUID() const;
+ [[nodiscard]] auto GetUID() const -> std::string;
/**
* @brief
@@ -72,7 +72,7 @@ class GPGFRONTEND_CORE_EXPORT GpgUID {
* @return true
* @return false
*/
- [[nodiscard]] bool GetRevoked() const;
+ [[nodiscard]] auto GetRevoked() const -> bool;
/**
* @brief
@@ -80,22 +80,23 @@ class GPGFRONTEND_CORE_EXPORT GpgUID {
* @return true
* @return false
*/
- [[nodiscard]] bool GetInvalid() const;
+ [[nodiscard]] auto GetInvalid() const -> bool;
/**
* @brief
*
* @return std::unique_ptr<std::vector<GpgTOFUInfo>>
*/
- [[nodiscard]] std::unique_ptr<std::vector<GpgTOFUInfo>> GetTofuInfos() const;
+ [[nodiscard]] auto GetTofuInfos() const
+ -> std::unique_ptr<std::vector<GpgTOFUInfo>>;
/**
* @brief
*
* @return std::unique_ptr<std::vector<GpgKeySignature>>
*/
- [[nodiscard]] std::unique_ptr<std::vector<GpgKeySignature>> GetSignatures()
- const;
+ [[nodiscard]] auto GetSignatures() const
+ -> std::unique_ptr<std::vector<GpgKeySignature>>;
/**
* @brief Construct a new Gpg U I D object
@@ -129,14 +130,14 @@ class GPGFRONTEND_CORE_EXPORT GpgUID {
* @param o
* @return GpgUID&
*/
- GpgUID &operator=(GpgUID &&o) noexcept;
+ auto operator=(GpgUID &&o) noexcept -> GpgUID &;
/**
* @brief
*
* @return GpgUID&
*/
- GpgUID &operator=(const GpgUID &) = delete;
+ auto operator=(const GpgUID &) -> GpgUID & = delete;
private:
using UidRefHandler =
diff --git a/src/ui/dialog/import_export/KeyServerImportDialog.cpp b/src/ui/dialog/import_export/KeyServerImportDialog.cpp
index 09943098..806b5da3 100644
--- a/src/ui/dialog/import_export/KeyServerImportDialog.cpp
+++ b/src/ui/dialog/import_export/KeyServerImportDialog.cpp
@@ -101,33 +101,34 @@ KeyServerImportDialog::KeyServerImportDialog(bool automatic, QWidget* parent)
waiting_bar_->setFixedWidth(200);
message_layout->addWidget(waiting_bar_);
- auto* mainLayout = new QGridLayout;
+ auto* main_layout = new QGridLayout;
// 自动化调用界面布局
if (automatic) {
- mainLayout->addLayout(message_layout, 0, 0, 1, 3);
+ main_layout->addLayout(message_layout, 0, 0, 1, 3);
} else {
- mainLayout->addWidget(search_label_, 1, 0);
- mainLayout->addWidget(search_line_edit_, 1, 1);
- mainLayout->addWidget(search_button_, 1, 2);
- mainLayout->addWidget(key_server_label_, 2, 0);
- mainLayout->addWidget(key_server_combo_box_, 2, 1);
- mainLayout->addWidget(keys_table_, 3, 0, 1, 3);
- mainLayout->addLayout(message_layout, 4, 0, 1, 3);
+ main_layout->addWidget(search_label_, 1, 0);
+ main_layout->addWidget(search_line_edit_, 1, 1);
+ main_layout->addWidget(search_button_, 1, 2);
+ main_layout->addWidget(key_server_label_, 2, 0);
+ main_layout->addWidget(key_server_combo_box_, 2, 1);
+ main_layout->addWidget(keys_table_, 3, 0, 1, 3);
+ main_layout->addLayout(message_layout, 4, 0, 1, 3);
// Layout for import and close button
- auto* buttonsLayout = new QHBoxLayout;
- buttonsLayout->addStretch();
- buttonsLayout->addWidget(import_button_);
- buttonsLayout->addWidget(close_button_);
- mainLayout->addLayout(buttonsLayout, 6, 0, 1, 3);
+ auto* buttons_layout = new QHBoxLayout;
+ buttons_layout->addStretch();
+ buttons_layout->addWidget(import_button_);
+ buttons_layout->addWidget(close_button_);
+ main_layout->addLayout(buttons_layout, 6, 0, 1, 3);
}
- this->setLayout(mainLayout);
- if (automatic)
+ this->setLayout(main_layout);
+ if (automatic) {
this->setWindowTitle(_("Update Keys from Keyserver"));
- else
+ } else {
this->setWindowTitle(_("Import Keys from Keyserver"));
+ }
if (automatic) {
this->setFixedSize(240, 42);
@@ -165,9 +166,9 @@ KeyServerImportDialog::KeyServerImportDialog(QWidget* parent)
this->setModal(true);
}
-QComboBox* KeyServerImportDialog::create_comboBox() {
- auto* comboBox = new QComboBox;
- comboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+auto KeyServerImportDialog::create_comboBox() -> QComboBox* {
+ auto* combo_box = new QComboBox;
+ combo_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
try {
SettingsObject key_server_json("key_server");
@@ -177,7 +178,7 @@ QComboBox* KeyServerImportDialog::create_comboBox() {
for (const auto& key_server : key_server_list) {
const auto key_server_str = key_server.get<std::string>();
- comboBox->addItem(key_server_str.c_str());
+ combo_box->addItem(key_server_str.c_str());
}
size_t default_key_server_index =
@@ -185,15 +186,15 @@ QComboBox* KeyServerImportDialog::create_comboBox() {
if (default_key_server_index >= key_server_list.size()) {
throw std::runtime_error("default_server index out of range");
}
- std::string default_key_server =
+ auto default_key_server =
key_server_list[default_key_server_index].get<std::string>();
- comboBox->setCurrentText(default_key_server.c_str());
+ combo_box->setCurrentText(default_key_server.c_str());
} catch (...) {
SPDLOG_ERROR("setting operation error", "server_list", "default_server");
}
- return comboBox;
+ return combo_box;
}
void KeyServerImportDialog::create_keys_table() {
@@ -317,13 +318,13 @@ void KeyServerImportDialog::slot_search_finished(
search_line_edit_->setText(query.prepend("0x"));
this->slot_search();
return;
- } else {
- set_message(
- "<h4>" + QString(_("No keys found containing the search string!")) +
- "</h4>",
- true);
- return;
}
+ set_message(
+ "<h4>" + QString(_("No keys found containing the search string!")) +
+ "</h4>",
+ true);
+ return;
+
} else if (text.contains("Insufficiently specific words")) {
set_message("<h4>" +
QString(_("Insufficiently specific search string!")) +
@@ -457,7 +458,7 @@ void KeyServerImportDialog::SlotImport(const KeyIdArgsListPtr& keys) {
if (default_key_server_index >= key_server_list.size()) {
throw std::runtime_error("default_server index out of range");
}
- std::string default_key_server =
+ auto default_key_server =
key_server_list[default_key_server_index].get<std::string>();
target_keyserver = default_key_server;
@@ -479,7 +480,8 @@ void KeyServerImportDialog::SlotImport(const KeyIdArgsListPtr& keys) {
void KeyServerImportDialog::SlotImport(std::vector<std::string> key_ids,
std::string keyserver_url) {
- auto* task = new KeyServerImportTask(keyserver_url, key_ids);
+ auto* task =
+ new KeyServerImportTask(std::move(keyserver_url), std::move(key_ids));
connect(task, &KeyServerImportTask::SignalKeyServerImportResult, this,
&KeyServerImportDialog::slot_import_finished);
@@ -547,13 +549,13 @@ void KeyServerImportDialog::import_keys(ByteArrayPtr in_data) {
// refresh the key database
emit SignalKeyImported();
- QWidget* _parent = qobject_cast<QWidget*>(parent());
+ QWidget* p_parent = qobject_cast<QWidget*>(parent());
if (m_automatic_) {
- auto dialog = new KeyImportDetailDialog(result, true, _parent);
+ auto* dialog = new KeyImportDetailDialog(result, true, p_parent);
dialog->show();
this->accept();
} else {
- auto dialog = new KeyImportDetailDialog(result, false, this);
+ auto* dialog = new KeyImportDetailDialog(result, false, this);
dialog->exec();
}
}
diff --git a/src/ui/dialog/import_export/KeyUploadDialog.cpp b/src/ui/dialog/import_export/KeyUploadDialog.cpp
index dbf9dd00..0d9c1311 100644
--- a/src/ui/dialog/import_export/KeyUploadDialog.cpp
+++ b/src/ui/dialog/import_export/KeyUploadDialog.cpp
@@ -101,10 +101,10 @@ void KeyUploadDialog::slot_upload_key_to_server(
}
QUrl req_url(QString::fromStdString(target_keyserver + "/pks/add"));
- auto qnam = new QNetworkAccessManager(this);
+ auto* qnam = new QNetworkAccessManager(this);
// Building Post Data
- QByteArray postData;
+ QByteArray post_data;
auto data = std::string(keys_data);
@@ -122,11 +122,11 @@ void KeyUploadDialog::slot_upload_key_to_server(
request.setHeader(QNetworkRequest::ContentTypeHeader,
"application/x-www-form-urlencoded");
- postData.append("keytext").append("=").append(
+ post_data.append("keytext").append("=").append(
QString::fromStdString(data).toUtf8());
// Send Post Data
- QNetworkReply* reply = qnam->post(request, postData);
+ QNetworkReply* reply = qnam->post(request, post_data);
connect(reply, &QNetworkReply::finished, this,
&KeyUploadDialog::slot_upload_finished);