diff options
Diffstat (limited to 'src/core/model')
-rw-r--r-- | src/core/model/GpgData.cpp | 4 | ||||
-rw-r--r-- | src/core/model/GpgData.h | 2 | ||||
-rw-r--r-- | src/core/model/GpgKey.cpp | 123 | ||||
-rw-r--r-- | src/core/model/GpgKey.h | 112 | ||||
-rw-r--r-- | src/core/model/GpgKeySignature.cpp | 62 | ||||
-rw-r--r-- | src/core/model/GpgKeySignature.h | 46 | ||||
-rw-r--r-- | src/core/model/GpgSignature.cpp | 98 | ||||
-rw-r--r-- | src/core/model/GpgSignature.h | 42 | ||||
-rw-r--r-- | src/core/model/GpgSubKey.cpp | 72 | ||||
-rw-r--r-- | src/core/model/GpgSubKey.h | 63 | ||||
-rw-r--r-- | src/core/model/GpgTOFUInfo.cpp | 59 | ||||
-rw-r--r-- | src/core/model/GpgTOFUInfo.h | 44 | ||||
-rw-r--r-- | src/core/model/GpgUID.cpp | 42 | ||||
-rw-r--r-- | src/core/model/GpgUID.h | 43 |
14 files changed, 565 insertions, 247 deletions
diff --git a/src/core/model/GpgData.cpp b/src/core/model/GpgData.cpp index 7fda4416..5aa95dc6 100644 --- a/src/core/model/GpgData.cpp +++ b/src/core/model/GpgData.cpp @@ -73,4 +73,6 @@ GpgFrontend::ByteArrayPtr GpgFrontend::GpgData::Read2Buffer() { } } return out_buffer; -}
\ No newline at end of file +} + +GpgFrontend::GpgData::operator gpgme_data_t() { return data_ref_.get(); }
\ No newline at end of file diff --git a/src/core/model/GpgData.h b/src/core/model/GpgData.h index c06f78d6..816465d3 100644 --- a/src/core/model/GpgData.h +++ b/src/core/model/GpgData.h @@ -58,7 +58,7 @@ class GpgData { * * @return gpgme_data_t */ - operator gpgme_data_t() { return data_ref_.get(); } + operator gpgme_data_t(); /** * @brief diff --git a/src/core/model/GpgKey.cpp b/src/core/model/GpgKey.cpp index b0952cfa..4b9d11d3 100644 --- a/src/core/model/GpgKey.cpp +++ b/src/core/model/GpgKey.cpp @@ -37,6 +37,118 @@ GpgFrontend::GpgKey &GpgFrontend::GpgKey::operator=(GpgKey &&k) noexcept { return *this; } +bool GpgFrontend::GpgKey::operator==(const GpgKey &o) const { + return o.GetId() == this->GetId(); +} + +bool GpgFrontend::GpgKey::operator<=(const GpgKey &o) const { + return this->GetId() < o.GetId(); +} + +GpgFrontend::GpgKey::operator gpgme_key_t() const { + return key_ref_.get(); +} + +bool GpgFrontend::GpgKey::IsGood() const { return key_ref_ != nullptr; } + +std::string GpgFrontend::GpgKey::GetId() const { + return key_ref_->subkeys->keyid; +} + +std::string GpgFrontend::GpgKey::GetName() const { + return key_ref_->uids->name; +}; + +std::string GpgFrontend::GpgKey::GetEmail() const { + return key_ref_->uids->email; +} + +std::string GpgFrontend::GpgKey::GetComment() const { + return key_ref_->uids->comment; +} + +std::string GpgFrontend::GpgKey::GetFingerprint() const { + return key_ref_->fpr; +} + +std::string GpgFrontend::GpgKey::GetProtocol() const { + return gpgme_get_protocol_name(key_ref_->protocol); +} + +std::string GpgFrontend::GpgKey::GetOwnerTrust() const { + switch (key_ref_->owner_trust) { + case GPGME_VALIDITY_UNKNOWN: + return "Unknown"; + case GPGME_VALIDITY_UNDEFINED: + return "Undefined"; + case GPGME_VALIDITY_NEVER: + return "Never"; + case GPGME_VALIDITY_MARGINAL: + return "Marginal"; + case GPGME_VALIDITY_FULL: + return "FULL"; + case GPGME_VALIDITY_ULTIMATE: + return "Ultimate"; + } + return "Invalid"; +} + +std::string GpgFrontend::GpgKey::GetPublicKeyAlgo() const { + return gpgme_pubkey_algo_name(key_ref_->subkeys->pubkey_algo); +} + +boost::posix_time::ptime GpgFrontend::GpgKey::GetLastUpdateTime() const { + return boost::posix_time::from_time_t( + static_cast<time_t>(key_ref_->last_update)); +} + +boost::posix_time::ptime GpgFrontend::GpgKey::GetExpireTime() const { + return boost::posix_time::from_time_t(key_ref_->subkeys->expires); +}; + +boost::posix_time::ptime GpgFrontend::GpgKey::GetCreateTime() const { + return boost::posix_time::from_time_t(key_ref_->subkeys->timestamp); +}; + +unsigned int GpgFrontend::GpgKey::GetPrimaryKeyLength() const { + return key_ref_->subkeys->length; +} + +bool GpgFrontend::GpgKey::IsHasEncryptionCapability() const { + return key_ref_->can_encrypt; +} + +bool GpgFrontend::GpgKey::IsHasSigningCapability() const { + return key_ref_->can_sign; +} + +bool GpgFrontend::GpgKey::IsHasCertificationCapability() const { + return key_ref_->can_certify; +} + +bool GpgFrontend::GpgKey::IsHasAuthenticationCapability() const { + return key_ref_->can_authenticate; +} + +bool GpgFrontend::GpgKey::IsHasCardKey() const { + 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; } + +bool GpgFrontend::GpgKey::IsExpired() const { return key_ref_->expired; } + +bool GpgFrontend::GpgKey::IsRevoked() const { return key_ref_->revoked; } + +bool GpgFrontend::GpgKey::IsDisabled() const { return key_ref_->disabled; } + +bool GpgFrontend::GpgKey::IsHasMasterKey() const { + return key_ref_->subkeys->secret; +} + std::unique_ptr<std::vector<GpgFrontend::GpgSubKey>> GpgFrontend::GpgKey::GetSubKeys() const { auto p_keys = std::make_unique<std::vector<GpgSubKey>>(); @@ -113,3 +225,14 @@ bool GpgFrontend::GpgKey::IsHasActualEncryptionCapability() const { else return false; } + + +GpgFrontend::GpgKey GpgFrontend::GpgKey::Copy() const { + gpgme_key_ref(key_ref_.get()); + 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) { + if (_key != nullptr) gpgme_key_unref(_key); +} diff --git a/src/core/model/GpgKey.h b/src/core/model/GpgKey.h index 14315d4c..457b6540 100644 --- a/src/core/model/GpgKey.h +++ b/src/core/model/GpgKey.h @@ -41,7 +41,7 @@ namespace GpgFrontend { * @brief * */ -class GpgKey { +class GPGFRONTEND_CORE_EXPORT GpgKey { public: /** * @brief @@ -49,122 +49,91 @@ class GpgKey { * @return true * @return false */ - [[nodiscard]] bool IsGood() const { return key_ref_ != nullptr; } + [[nodiscard]] bool IsGood() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetId() const { return key_ref_->subkeys->keyid; } + [[nodiscard]] std::string GetId() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetName() const { return key_ref_->uids->name; }; + [[nodiscard]] std::string GetName() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetEmail() const { return key_ref_->uids->email; } + [[nodiscard]] std::string GetEmail() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetComment() const { - return key_ref_->uids->comment; - } + [[nodiscard]] std::string GetComment() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetFingerprint() const { return key_ref_->fpr; } + [[nodiscard]] std::string GetFingerprint() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetProtocol() const { - return gpgme_get_protocol_name(key_ref_->protocol); - } + [[nodiscard]] std::string GetProtocol() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetOwnerTrust() const { - switch (key_ref_->owner_trust) { - case GPGME_VALIDITY_UNKNOWN: - return "Unknown"; - case GPGME_VALIDITY_UNDEFINED: - return "Undefined"; - case GPGME_VALIDITY_NEVER: - return "Never"; - case GPGME_VALIDITY_MARGINAL: - return "Marginal"; - case GPGME_VALIDITY_FULL: - return "FULL"; - case GPGME_VALIDITY_ULTIMATE: - return "Ultimate"; - } - return "Invalid"; - } + [[nodiscard]] std::string GetOwnerTrust() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetPublicKeyAlgo() const { - return gpgme_pubkey_algo_name(key_ref_->subkeys->pubkey_algo); - } + [[nodiscard]] std::string GetPublicKeyAlgo() const; /** * @brief * * @return boost::posix_time::ptime */ - [[nodiscard]] boost::posix_time::ptime GetLastUpdateTime() const { - return boost::posix_time::from_time_t( - static_cast<time_t>(key_ref_->last_update)); - } + [[nodiscard]] boost::posix_time::ptime GetLastUpdateTime() const; /** * @brief * * @return boost::posix_time::ptime */ - [[nodiscard]] boost::posix_time::ptime GetExpireTime() const { - return boost::posix_time::from_time_t(key_ref_->subkeys->expires); - }; + [[nodiscard]] boost::posix_time::ptime GetExpireTime() const; /** * @brief Create a time object * * @return boost::posix_time::ptime */ - [[nodiscard]] boost::posix_time::ptime GetCreateTime() const { - return boost::posix_time::from_time_t(key_ref_->subkeys->timestamp); - }; + [[nodiscard]] boost::posix_time::ptime GetCreateTime() const; /** * @brief s * * @return unsigned int */ - [[nodiscard]] unsigned int GetPrimaryKeyLength() const { - return key_ref_->subkeys->length; - } + [[nodiscard]] unsigned int GetPrimaryKeyLength() const; /** * @brief @@ -172,9 +141,7 @@ class GpgKey { * @return true * @return false */ - [[nodiscard]] bool IsHasEncryptionCapability() const { - return key_ref_->can_encrypt; - } + [[nodiscard]] bool IsHasEncryptionCapability() const; /** * @brief @@ -191,9 +158,7 @@ class GpgKey { * @return true * @return false */ - [[nodiscard]] bool IsHasSigningCapability() const { - return key_ref_->can_sign; - } + [[nodiscard]] bool IsHasSigningCapability() const; /** * @brief @@ -209,9 +174,7 @@ class GpgKey { * @return true * @return false */ - [[nodiscard]] bool IsHasCertificationCapability() const { - return key_ref_->can_certify; - } + [[nodiscard]] bool IsHasCertificationCapability() const; /** * @brief @@ -227,9 +190,7 @@ class GpgKey { * @return true * @return false */ - [[nodiscard]] bool IsHasAuthenticationCapability() const { - return key_ref_->can_authenticate; - } + [[nodiscard]] bool IsHasAuthenticationCapability() const; /** * @brief @@ -245,12 +206,7 @@ class GpgKey { * @return true * @return false */ - [[nodiscard]] bool IsHasCardKey() const { - auto subkeys = GetSubKeys(); - return std::any_of( - subkeys->begin(), subkeys->end(), - [](const GpgSubKey& subkey) -> bool { return subkey.IsCardKey(); }); - } + [[nodiscard]] bool IsHasCardKey() const; /** * @brief @@ -258,7 +214,7 @@ class GpgKey { * @return true * @return false */ - [[nodiscard]] bool IsPrivateKey() const { return key_ref_->secret; } + [[nodiscard]] bool IsPrivateKey() const; /** * @brief @@ -266,7 +222,7 @@ class GpgKey { * @return true * @return false */ - [[nodiscard]] bool IsExpired() const { return key_ref_->expired; } + [[nodiscard]] bool IsExpired() const; /** * @brief @@ -274,7 +230,7 @@ class GpgKey { * @return true * @return false */ - [[nodiscard]] bool IsRevoked() const { return key_ref_->revoked; } + [[nodiscard]] bool IsRevoked() const; /** * @brief @@ -282,7 +238,7 @@ class GpgKey { * @return true * @return false */ - [[nodiscard]] bool IsDisabled() const { return key_ref_->disabled; } + [[nodiscard]] bool IsDisabled() const; /** * @brief @@ -290,9 +246,7 @@ class GpgKey { * @return true * @return false */ - [[nodiscard]] bool IsHasMasterKey() const { - return key_ref_->subkeys->secret; - } + [[nodiscard]] bool IsHasMasterKey() const; /** * @brief @@ -364,7 +318,7 @@ class GpgKey { * @return true * @return false */ - bool operator==(const GpgKey& o) const { return o.GetId() == this->GetId(); } + bool operator==(const GpgKey& o) const; /** * @brief @@ -373,35 +327,29 @@ class GpgKey { * @return true * @return false */ - bool operator<=(const GpgKey& o) const { return this->GetId() < o.GetId(); } + bool operator<=(const GpgKey& o) const; /** * @brief * * @return gpgme_key_t */ - explicit operator gpgme_key_t() const { return key_ref_.get(); } + explicit operator gpgme_key_t() const; /** * @brief * * @return GpgKey */ - [[nodiscard]] GpgKey Copy() const { - gpgme_key_ref(key_ref_.get()); - auto* _new_key_ref = key_ref_.get(); - return GpgKey(std::move(_new_key_ref)); - } + [[nodiscard]] GpgKey Copy() const; private: /** * @brief * */ - struct _key_ref_deleter { - void operator()(gpgme_key_t _key) { - if (_key != nullptr) gpgme_key_unref(_key); - } + struct GPGFRONTEND_CORE_EXPORT _key_ref_deleter { + void operator()(gpgme_key_t _key); }; using KeyRefHandler = diff --git a/src/core/model/GpgKeySignature.cpp b/src/core/model/GpgKeySignature.cpp index 0c11a93b..aa196391 100644 --- a/src/core/model/GpgKeySignature.cpp +++ b/src/core/model/GpgKeySignature.cpp @@ -28,5 +28,67 @@ #include "core/model/GpgKeySignature.h" +GpgFrontend::GpgKeySignature::GpgKeySignature() = default; + +GpgFrontend::GpgKeySignature::~GpgKeySignature() = default; + GpgFrontend::GpgKeySignature::GpgKeySignature(gpgme_key_sig_t sig) : signature_ref_(sig, [&](gpgme_key_sig_t signature) {}) {} + +GpgFrontend::GpgKeySignature::GpgKeySignature(GpgKeySignature &&) noexcept = + default; + +GpgFrontend::GpgKeySignature &GpgFrontend::GpgKeySignature::operator=( + GpgKeySignature &&) noexcept = default; + +bool GpgFrontend::GpgKeySignature::IsRevoked() const { + return signature_ref_->revoked; +} + +bool GpgFrontend::GpgKeySignature::IsExpired() const { + return signature_ref_->expired; +} + +bool GpgFrontend::GpgKeySignature::IsInvalid() const { + return signature_ref_->invalid; +} + +bool GpgFrontend::GpgKeySignature::IsExportable() const { + return signature_ref_->exportable; +} + +gpgme_error_t GpgFrontend::GpgKeySignature::GetStatus() const { + return signature_ref_->status; +} + +std::string GpgFrontend::GpgKeySignature::GetKeyID() const { + return signature_ref_->keyid; +} + +std::string GpgFrontend::GpgKeySignature::GetPubkeyAlgo() const { + return gpgme_pubkey_algo_name(signature_ref_->pubkey_algo); +} + +boost::posix_time::ptime GpgFrontend::GpgKeySignature::GetCreateTime() const { + return boost::posix_time::from_time_t(signature_ref_->timestamp); +} + +boost::posix_time::ptime GpgFrontend::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 GpgFrontend::GpgKeySignature::GetName() const { + return signature_ref_->name; +} + +std::string GpgFrontend::GpgKeySignature::GetEmail() const { + return signature_ref_->email; +} + +std::string GpgFrontend::GpgKeySignature::GetComment() const { + return signature_ref_->comment; +}
\ No newline at end of file diff --git a/src/core/model/GpgKeySignature.h b/src/core/model/GpgKeySignature.h index 33b84904..25de2c75 100644 --- a/src/core/model/GpgKeySignature.h +++ b/src/core/model/GpgKeySignature.h @@ -44,7 +44,7 @@ namespace GpgFrontend { * @brief * */ -class GpgKeySignature { +class GPGFRONTEND_CORE_EXPORT GpgKeySignature { public: /** * @brief @@ -52,7 +52,7 @@ class GpgKeySignature { * @return true * @return false */ - [[nodiscard]] bool IsRevoked() const { return signature_ref_->revoked; } + [[nodiscard]] bool IsRevoked() const; /** * @brief @@ -60,7 +60,7 @@ class GpgKeySignature { * @return true * @return false */ - [[nodiscard]] bool IsExpired() const { return signature_ref_->expired; } + [[nodiscard]] bool IsExpired() const; /** * @brief @@ -68,7 +68,7 @@ class GpgKeySignature { * @return true * @return false */ - [[nodiscard]] bool IsInvalid() const { return signature_ref_->invalid; } + [[nodiscard]] bool IsInvalid() const; /** * @brief @@ -76,92 +76,82 @@ class GpgKeySignature { * @return true * @return false */ - [[nodiscard]] bool IsExportable() const { return signature_ref_->exportable; } + [[nodiscard]] bool IsExportable() const; /** * @brief * * @return gpgme_error_t */ - [[nodiscard]] gpgme_error_t GetStatus() const { - return signature_ref_->status; - } + [[nodiscard]] gpgme_error_t GetStatus() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetKeyID() const { return signature_ref_->keyid; } + [[nodiscard]] std::string GetKeyID() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetPubkeyAlgo() const { - return gpgme_pubkey_algo_name(signature_ref_->pubkey_algo); - } + [[nodiscard]] std::string GetPubkeyAlgo() const; /** * @brief Create a time object * * @return boost::posix_time::ptime */ - [[nodiscard]] boost::posix_time::ptime GetCreateTime() const { - return boost::posix_time::from_time_t(signature_ref_->timestamp); - } + [[nodiscard]] boost::posix_time::ptime GetCreateTime() const; /** * @brief * * @return boost::posix_time::ptime */ - [[nodiscard]] boost::posix_time::ptime GetExpireTime() const { - return boost::posix_time::from_time_t(signature_ref_->expires); - } + [[nodiscard]] boost::posix_time::ptime GetExpireTime() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetUID() const { return signature_ref_->uid; } + [[nodiscard]] std::string GetUID() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetName() const { return signature_ref_->name; } + [[nodiscard]] std::string GetName() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetEmail() const { return signature_ref_->email; } + [[nodiscard]] std::string GetEmail() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetComment() const { - return signature_ref_->comment; - } + [[nodiscard]] std::string GetComment() const; /** * @brief Construct a new Gpg Key Signature object * */ - GpgKeySignature() = default; + GpgKeySignature(); /** * @brief Destroy the Gpg Key Signature object * */ - ~GpgKeySignature() = default; + ~GpgKeySignature(); /** * @brief Construct a new Gpg Key Signature object @@ -174,7 +164,7 @@ class GpgKeySignature { * @brief Construct a new Gpg Key Signature object * */ - GpgKeySignature(GpgKeySignature &&) noexcept = default; + GpgKeySignature(GpgKeySignature &&) noexcept; /** * @brief Construct a new Gpg Key Signature object @@ -187,7 +177,7 @@ class GpgKeySignature { * * @return GpgKeySignature& */ - GpgKeySignature &operator=(GpgKeySignature &&) noexcept = default; + GpgKeySignature &operator=(GpgKeySignature &&) noexcept; /** * @brief diff --git a/src/core/model/GpgSignature.cpp b/src/core/model/GpgSignature.cpp index f8084442..73f9179d 100644 --- a/src/core/model/GpgSignature.cpp +++ b/src/core/model/GpgSignature.cpp @@ -28,5 +28,103 @@ #include "GpgSignature.h" +/** + * @brief Construct a new Gpg Signature object + * + */ +GpgFrontend::GpgSignature::GpgSignature(GpgSignature &&) noexcept = default; + +/** + * @brief + * + * @return GpgSignature& + */ +GpgFrontend::GpgSignature &GpgFrontend::GpgSignature::operator=( + GpgFrontend::GpgSignature &&) noexcept = default; + GpgFrontend::GpgSignature::GpgSignature(gpgme_signature_t sig) : signature_ref_(sig, [&](gpgme_signature_t signature) {}) {} + +/** + * @brief + * + * @return gpgme_validity_t + */ +gpgme_validity_t GpgFrontend::GpgSignature::GetValidity() const { + return signature_ref_->validity; +} + +/** + * @brief + * + * @return gpgme_error_t + */ +gpgme_error_t GpgFrontend::GpgSignature::GetStatus() const { + return signature_ref_->status; +} + +/** + * @brief + * + * @return gpgme_error_t + */ +gpgme_error_t GpgFrontend::GpgSignature::GetSummary() const { + return signature_ref_->summary; +} + +/** + * @brief + * + * @return std::string + */ +std::string GpgFrontend::GpgSignature::GetPubkeyAlgo() const { + return gpgme_pubkey_algo_name(signature_ref_->pubkey_algo); +} + +/** + * @brief + * + * @return std::string + */ +std::string GpgFrontend::GpgSignature::GetHashAlgo() const { + return gpgme_hash_algo_name(signature_ref_->hash_algo); +} + +/** + * @brief Create a time object + * + * @return boost::posix_time::ptime + */ +boost::posix_time::ptime GpgFrontend::GpgSignature::GetCreateTime() const { + return boost::posix_time::from_time_t(signature_ref_->timestamp); +} + +/** + * @brief + * + * @return boost::posix_time::ptime + */ +boost::posix_time::ptime GpgFrontend::GpgSignature::GetExpireTime() const { + return boost::posix_time::from_time_t(signature_ref_->exp_timestamp); +} + +/** + * @brief + * + * @return std::string + */ +std::string GpgFrontend::GpgSignature::GetFingerprint() const { + return signature_ref_->fpr; +} + +/** + * @brief Construct a new Gpg Signature object + * + */ +GpgFrontend::GpgSignature::GpgSignature() = default; + +/** + * @brief Destroy the Gpg Signature object + * + */ +GpgFrontend::GpgSignature::~GpgSignature() = default; diff --git a/src/core/model/GpgSignature.h b/src/core/model/GpgSignature.h index 942f0097..2e49c4d7 100644 --- a/src/core/model/GpgSignature.h +++ b/src/core/model/GpgSignature.h @@ -40,91 +40,75 @@ namespace GpgFrontend { * @brief * */ -class GpgSignature { +class GPGFRONTEND_CORE_EXPORT GpgSignature { public: /** * @brief * * @return gpgme_validity_t */ - [[nodiscard]] gpgme_validity_t GetValidity() const { - return signature_ref_->validity; - } + [[nodiscard]] gpgme_validity_t GetValidity() const; /** * @brief * * @return gpgme_error_t */ - [[nodiscard]] gpgme_error_t GetStatus() const { - return signature_ref_->status; - } + [[nodiscard]] gpgme_error_t GetStatus() const; /** * @brief * * @return gpgme_error_t */ - [[nodiscard]] gpgme_error_t GetSummary() const { - return signature_ref_->summary; - } + [[nodiscard]] gpgme_error_t GetSummary() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetPubkeyAlgo() const { - return gpgme_pubkey_algo_name(signature_ref_->pubkey_algo); - } + [[nodiscard]] std::string GetPubkeyAlgo() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetHashAlgo() const { - return gpgme_hash_algo_name(signature_ref_->hash_algo); - } + [[nodiscard]] std::string GetHashAlgo() const; /** * @brief Create a time object * * @return boost::posix_time::ptime */ - [[nodiscard]] boost::posix_time::ptime GetCreateTime() const { - return boost::posix_time::from_time_t(signature_ref_->timestamp); - } + [[nodiscard]] boost::posix_time::ptime GetCreateTime() const; /** * @brief * * @return boost::posix_time::ptime */ - [[nodiscard]] boost::posix_time::ptime GetExpireTime() const { - return boost::posix_time::from_time_t(signature_ref_->exp_timestamp); - } + [[nodiscard]] boost::posix_time::ptime GetExpireTime() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetFingerprint() const { - return signature_ref_->fpr; - } + [[nodiscard]] std::string GetFingerprint() const; /** * @brief Construct a new Gpg Signature object * */ - GpgSignature() = default; + GpgSignature(); /** * @brief Destroy the Gpg Signature object * */ - ~GpgSignature() = default; + ~GpgSignature(); /** * @brief Construct a new Gpg Signature object @@ -137,7 +121,7 @@ class GpgSignature { * @brief Construct a new Gpg Signature object * */ - GpgSignature(GpgSignature &&) noexcept = default; + GpgSignature(GpgSignature &&) noexcept; /** * @brief Construct a new Gpg Signature object @@ -150,7 +134,7 @@ class GpgSignature { * * @return GpgSignature& */ - GpgSignature &operator=(GpgSignature &&) noexcept = default; + GpgSignature &operator=(GpgSignature &&) noexcept; /** * @brief diff --git a/src/core/model/GpgSubKey.cpp b/src/core/model/GpgSubKey.cpp index 767f9c5d..e63816b1 100644 --- a/src/core/model/GpgSubKey.cpp +++ b/src/core/model/GpgSubKey.cpp @@ -27,5 +27,77 @@ */ #include "core/model/GpgSubKey.h" +GpgFrontend::GpgSubKey::GpgSubKey() = default; + GpgFrontend::GpgSubKey::GpgSubKey(gpgme_subkey_t subkey) : _subkey_ref(subkey, [&](gpgme_subkey_t subkey) {}) {} + +GpgFrontend::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); + return *this; +}; + +bool GpgFrontend::GpgSubKey::operator==(const GpgSubKey& o) const { + return GetFingerprint() == o.GetFingerprint(); +} + +std::string GpgFrontend::GpgSubKey::GetID() const { return _subkey_ref->keyid; } + +std::string GpgFrontend::GpgSubKey::GetFingerprint() const { + return _subkey_ref->fpr; +} + +std::string GpgFrontend::GpgSubKey::GetPubkeyAlgo() const { + return gpgme_pubkey_algo_name(_subkey_ref->pubkey_algo); +} + +unsigned int GpgFrontend::GpgSubKey::GetKeyLength() const { + return _subkey_ref->length; +} + +bool GpgFrontend::GpgSubKey::IsHasEncryptionCapability() const { + return _subkey_ref->can_encrypt; +} + +bool GpgFrontend::GpgSubKey::IsHasSigningCapability() const { + return _subkey_ref->can_sign; +} + +bool GpgFrontend::GpgSubKey::IsHasCertificationCapability() const { + return _subkey_ref->can_certify; +} + +bool GpgFrontend::GpgSubKey::IsHasAuthenticationCapability() const { + return _subkey_ref->can_authenticate; +} + +bool GpgFrontend::GpgSubKey::IsPrivateKey() const { + return _subkey_ref->secret; +} + +bool GpgFrontend::GpgSubKey::IsExpired() const { return _subkey_ref->expired; } + +bool GpgFrontend::GpgSubKey::IsRevoked() const { return _subkey_ref->revoked; } + +bool GpgFrontend::GpgSubKey::IsDisabled() const { + return _subkey_ref->disabled; +} + +bool GpgFrontend::GpgSubKey::IsSecretKey() const { return _subkey_ref->secret; } + +bool GpgFrontend::GpgSubKey::IsCardKey() const { + return _subkey_ref->is_cardkey; +} + +boost::posix_time::ptime GpgFrontend::GpgSubKey::GetCreateTime() const { + 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); +} diff --git a/src/core/model/GpgSubKey.h b/src/core/model/GpgSubKey.h index 1aadcdac..5a86d21d 100644 --- a/src/core/model/GpgSubKey.h +++ b/src/core/model/GpgSubKey.h @@ -40,39 +40,35 @@ namespace GpgFrontend { * @brief * */ -class GpgSubKey { +class GPGFRONTEND_CORE_EXPORT GpgSubKey { public: /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetID() const { return _subkey_ref->keyid; } + [[nodiscard]] std::string GetID() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetFingerprint() const { return _subkey_ref->fpr; } + [[nodiscard]] std::string GetFingerprint() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetPubkeyAlgo() const { - return gpgme_pubkey_algo_name(_subkey_ref->pubkey_algo); - } + [[nodiscard]] std::string GetPubkeyAlgo() const; /** * @brief * * @return unsigned int */ - [[nodiscard]] unsigned int GetKeyLength() const { - return _subkey_ref->length; - } + [[nodiscard]] unsigned int GetKeyLength() const; /** * @brief @@ -80,9 +76,7 @@ class GpgSubKey { * @return true * @return false */ - [[nodiscard]] bool IsHasEncryptionCapability() const { - return _subkey_ref->can_encrypt; - } + [[nodiscard]] bool IsHasEncryptionCapability() const; /** * @brief @@ -90,9 +84,7 @@ class GpgSubKey { * @return true * @return false */ - [[nodiscard]] bool IsHasSigningCapability() const { - return _subkey_ref->can_sign; - } + [[nodiscard]] bool IsHasSigningCapability() const; /** * @brief @@ -100,9 +92,7 @@ class GpgSubKey { * @return true * @return false */ - [[nodiscard]] bool IsHasCertificationCapability() const { - return _subkey_ref->can_certify; - } + [[nodiscard]] bool IsHasCertificationCapability() const; /** * @brief @@ -110,9 +100,7 @@ class GpgSubKey { * @return true * @return false */ - [[nodiscard]] bool IsHasAuthenticationCapability() const { - return _subkey_ref->can_authenticate; - } + [[nodiscard]] bool IsHasAuthenticationCapability() const; /** * @brief @@ -120,7 +108,7 @@ class GpgSubKey { * @return true * @return false */ - [[nodiscard]] bool IsPrivateKey() const { return _subkey_ref->secret; } + [[nodiscard]] bool IsPrivateKey() const; /** * @brief @@ -128,7 +116,7 @@ class GpgSubKey { * @return true * @return false */ - [[nodiscard]] bool IsExpired() const { return _subkey_ref->expired; } + [[nodiscard]] bool IsExpired() const; /** * @brief @@ -136,7 +124,7 @@ class GpgSubKey { * @return true * @return false */ - [[nodiscard]] bool IsRevoked() const { return _subkey_ref->revoked; } + [[nodiscard]] bool IsRevoked() const; /** * @brief @@ -144,7 +132,7 @@ class GpgSubKey { * @return true * @return false */ - [[nodiscard]] bool IsDisabled() const { return _subkey_ref->disabled; } + [[nodiscard]] bool IsDisabled() const; /** * @brief @@ -152,7 +140,7 @@ class GpgSubKey { * @return true * @return false */ - [[nodiscard]] bool IsSecretKey() const { return _subkey_ref->secret; } + [[nodiscard]] bool IsSecretKey() const; /** * @brief @@ -160,31 +148,27 @@ class GpgSubKey { * @return true * @return false */ - [[nodiscard]] bool IsCardKey() const { return _subkey_ref->is_cardkey; } + [[nodiscard]] bool IsCardKey() const; /** * @brief * * @return boost::posix_time::ptime */ - [[nodiscard]] boost::posix_time::ptime GetCreateTime() const { - return boost::posix_time::from_time_t(_subkey_ref->timestamp); - } + [[nodiscard]] boost::posix_time::ptime GetCreateTime() const; /** * @brief * * @return boost::posix_time::ptime */ - [[nodiscard]] boost::posix_time::ptime GetExpireTime() const { - return boost::posix_time::from_time_t(_subkey_ref->expires); - } + [[nodiscard]] boost::posix_time::ptime GetExpireTime() const; /** * @brief Construct a new Gpg Sub Key object * */ - GpgSubKey() = default; + GpgSubKey(); /** * @brief Construct a new Gpg Sub Key object @@ -198,7 +182,7 @@ class GpgSubKey { * * @param o */ - GpgSubKey(GpgSubKey&& o) noexcept { swap(_subkey_ref, o._subkey_ref); } + GpgSubKey(GpgSubKey&& o) noexcept; /** * @brief Construct a new Gpg Sub Key object @@ -212,10 +196,7 @@ class GpgSubKey { * @param o * @return GpgSubKey& */ - GpgSubKey& operator=(GpgSubKey&& o) noexcept { - swap(_subkey_ref, o._subkey_ref); - return *this; - }; + GpgSubKey& operator=(GpgSubKey&& o) noexcept; /** * @brief @@ -231,9 +212,7 @@ class GpgSubKey { * @return true * @return false */ - bool operator==(const GpgSubKey& o) const { - return GetFingerprint() == o.GetFingerprint(); - } + bool operator==(const GpgSubKey& o) const; private: using SubkeyRefHandler = diff --git a/src/core/model/GpgTOFUInfo.cpp b/src/core/model/GpgTOFUInfo.cpp index 8c83b360..84ce1e29 100644 --- a/src/core/model/GpgTOFUInfo.cpp +++ b/src/core/model/GpgTOFUInfo.cpp @@ -28,5 +28,64 @@ #include "GpgTOFUInfo.h" +GpgFrontend::GpgTOFUInfo::GpgTOFUInfo() = default; + GpgFrontend::GpgTOFUInfo::GpgTOFUInfo(gpgme_tofu_info_t tofu_info) : _tofu_info_ref(tofu_info, [&](gpgme_tofu_info_t tofu_info) {}) {} + +GpgFrontend::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); + return *this; +}; + +unsigned GpgFrontend::GpgTOFUInfo::GetValidity() const { + return _tofu_info_ref->validity; +} + +unsigned GpgFrontend::GpgTOFUInfo::GetPolicy() const { + return _tofu_info_ref->policy; +} + +unsigned long GpgFrontend::GpgTOFUInfo::GetSignCount() const { + return _tofu_info_ref->signcount; +} + +unsigned long GpgFrontend::GpgTOFUInfo::GetEncrCount() const { + return _tofu_info_ref->encrcount; +} + +unsigned long GpgFrontend::GpgTOFUInfo::GetSignFirst() const { + return _tofu_info_ref->signfirst; +} + +/** + * @brief + * + * @return unsigned long + */ +unsigned long GpgFrontend::GpgTOFUInfo::GetSignLast() const { + return _tofu_info_ref->signlast; +} + +/** + * @brief + * + * @return unsigned long + */ +unsigned long GpgFrontend::GpgTOFUInfo::GetEncrLast() const { + return _tofu_info_ref->encrlast; +} + +/** + * @brief + * + * @return std::string + */ +std::string GpgFrontend::GpgTOFUInfo::GetDescription() const { + return _tofu_info_ref->description; +}
\ No newline at end of file diff --git a/src/core/model/GpgTOFUInfo.h b/src/core/model/GpgTOFUInfo.h index b2fea4cf..b82a4eb2 100644 --- a/src/core/model/GpgTOFUInfo.h +++ b/src/core/model/GpgTOFUInfo.h @@ -36,83 +36,68 @@ namespace GpgFrontend { * @brief * */ -class GpgTOFUInfo { +class GPGFRONTEND_CORE_EXPORT GpgTOFUInfo { public: /** * @brief * * @return unsigned */ - [[nodiscard]] unsigned GetValidity() const { - return _tofu_info_ref->validity; - } - + [[nodiscard]] unsigned GetValidity() const; /** * @brief * * @return unsigned */ - [[nodiscard]] unsigned GetPolicy() const { return _tofu_info_ref->policy; } + [[nodiscard]] unsigned GetPolicy() const; /** * @brief * * @return unsigned long */ - [[nodiscard]] unsigned long GetSignCount() const { - return _tofu_info_ref->signcount; - } + [[nodiscard]] unsigned long GetSignCount() const; /** * @brief * * @return unsigned long */ - [[nodiscard]] unsigned long GetEncrCount() const { - return _tofu_info_ref->encrcount; - } + [[nodiscard]] unsigned long GetEncrCount() const; /** * @brief * * @return unsigned long */ - [[nodiscard]] unsigned long GetSignFirst() const { - return _tofu_info_ref->signfirst; - } + [[nodiscard]] unsigned long GetSignFirst() const; /** * @brief * * @return unsigned long */ - [[nodiscard]] unsigned long GetSignLast() const { - return _tofu_info_ref->signlast; - } + [[nodiscard]] unsigned long GetSignLast() const; /** * @brief * * @return unsigned long */ - [[nodiscard]] unsigned long GetEncrLast() const { - return _tofu_info_ref->encrlast; - } + [[nodiscard]] unsigned long GetEncrLast() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetDescription() const { - return _tofu_info_ref->description; - } + [[nodiscard]] std::string GetDescription() const; /** * @brief Construct a new Gpg T O F U Info object * */ - GpgTOFUInfo() = default; + GpgTOFUInfo(); /** * @brief Construct a new Gpg T O F U Info object @@ -126,9 +111,7 @@ class GpgTOFUInfo { * * @param o */ - GpgTOFUInfo(GpgTOFUInfo&& o) noexcept { - swap(_tofu_info_ref, o._tofu_info_ref); - } + GpgTOFUInfo(GpgTOFUInfo&& o) noexcept; /** * @brief Construct a new Gpg T O F U Info object @@ -142,10 +125,7 @@ class GpgTOFUInfo { * @param o * @return GpgTOFUInfo& */ - GpgTOFUInfo& operator=(GpgTOFUInfo&& o) noexcept { - swap(_tofu_info_ref, o._tofu_info_ref); - return *this; - }; + GpgTOFUInfo& operator=(GpgTOFUInfo&& o) noexcept; /** * @brief diff --git a/src/core/model/GpgUID.cpp b/src/core/model/GpgUID.cpp index 6d98c882..d87192c3 100644 --- a/src/core/model/GpgUID.cpp +++ b/src/core/model/GpgUID.cpp @@ -28,5 +28,45 @@ #include "core/model/GpgUID.h" +GpgFrontend::GpgUID::GpgUID() = default; + GpgFrontend::GpgUID::GpgUID(gpgme_user_id_t uid) - : uid_ref_(uid, [&](gpgme_user_id_t uid) {}) {}
\ No newline at end of file + : uid_ref_(uid, [&](gpgme_user_id_t uid) {}) {} + +GpgFrontend::GpgUID::GpgUID(GpgUID &&o) noexcept { swap(uid_ref_, o.uid_ref_); } + +std::string GpgFrontend::GpgUID::GetName() const { return uid_ref_->name; } + +std::string GpgFrontend::GpgUID::GetEmail() const { return uid_ref_->email; } + +std::string GpgFrontend::GpgUID::GetComment() const { + return uid_ref_->comment; +} + +std::string GpgFrontend::GpgUID::GetUID() const { return uid_ref_->uid; } + +bool GpgFrontend::GpgUID::GetRevoked() const { return uid_ref_->revoked; } + +bool GpgFrontend::GpgUID::GetInvalid() const { return uid_ref_->invalid; } + +std::unique_ptr<std::vector<GpgFrontend::GpgTOFUInfo>> +GpgFrontend::GpgUID::GetTofuInfos() const { + auto infos = std::make_unique<std::vector<GpgTOFUInfo>>(); + auto info_next = uid_ref_->tofu; + while (info_next != nullptr) { + infos->push_back(GpgTOFUInfo(info_next)); + info_next = info_next->next; + } + return infos; +} + +std::unique_ptr<std::vector<GpgFrontend::GpgKeySignature>> +GpgFrontend::GpgUID::GetSignatures() const { + auto sigs = std::make_unique<std::vector<GpgKeySignature>>(); + auto sig_next = uid_ref_->signatures; + while (sig_next != nullptr) { + sigs->push_back(GpgKeySignature(sig_next)); + sig_next = sig_next->next; + } + return sigs; +} diff --git a/src/core/model/GpgUID.h b/src/core/model/GpgUID.h index 7f8daf98..670c318d 100644 --- a/src/core/model/GpgUID.h +++ b/src/core/model/GpgUID.h @@ -37,35 +37,35 @@ namespace GpgFrontend { * @brief * */ -class GpgUID { +class GPGFRONTEND_CORE_EXPORT GpgUID { public: /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetName() const { return uid_ref_->name; } + [[nodiscard]] std::string GetName() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetEmail() const { return uid_ref_->email; } + [[nodiscard]] std::string GetEmail() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetComment() const { return uid_ref_->comment; } + [[nodiscard]] std::string GetComment() const; /** * @brief * * @return std::string */ - [[nodiscard]] std::string GetUID() const { return uid_ref_->uid; } + [[nodiscard]] std::string GetUID() const; /** * @brief @@ -73,7 +73,7 @@ class GpgUID { * @return true * @return false */ - [[nodiscard]] bool GetRevoked() const { return uid_ref_->revoked; } + [[nodiscard]] bool GetRevoked() const; /** * @brief @@ -81,22 +81,14 @@ class GpgUID { * @return true * @return false */ - [[nodiscard]] bool GetInvalid() const { return uid_ref_->invalid; } + [[nodiscard]] bool GetInvalid() const; /** * @brief * * @return std::unique_ptr<std::vector<GpgTOFUInfo>> */ - [[nodiscard]] std::unique_ptr<std::vector<GpgTOFUInfo>> GetTofuInfos() const { - auto infos = std::make_unique<std::vector<GpgTOFUInfo>>(); - auto info_next = uid_ref_->tofu; - while (info_next != nullptr) { - infos->push_back(GpgTOFUInfo(info_next)); - info_next = info_next->next; - } - return infos; - } + [[nodiscard]] std::unique_ptr<std::vector<GpgTOFUInfo>> GetTofuInfos() const; /** * @brief @@ -104,21 +96,13 @@ class GpgUID { * @return std::unique_ptr<std::vector<GpgKeySignature>> */ [[nodiscard]] std::unique_ptr<std::vector<GpgKeySignature>> GetSignatures() - const { - auto sigs = std::make_unique<std::vector<GpgKeySignature>>(); - auto sig_next = uid_ref_->signatures; - while (sig_next != nullptr) { - sigs->push_back(GpgKeySignature(sig_next)); - sig_next = sig_next->next; - } - return sigs; - } + const; /** * @brief Construct a new Gpg U I D object * */ - GpgUID() = default; + GpgUID(); /** * @brief Construct a new Gpg U I D object @@ -132,7 +116,7 @@ class GpgUID { * * @param o */ - GpgUID(GpgUID &&o) noexcept { swap(uid_ref_, o.uid_ref_); } + GpgUID(GpgUID &&o) noexcept; /** * @brief Construct a new Gpg U I D object @@ -146,10 +130,7 @@ class GpgUID { * @param o * @return GpgUID& */ - GpgUID &operator=(GpgUID &&o) noexcept { - swap(uid_ref_, o.uid_ref_); - return *this; - } + GpgUID &operator=(GpgUID &&o) noexcept; /** * @brief |