aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/gpg/GpgConstants.cpp72
-rw-r--r--src/gpg/GpgConstants.h158
-rw-r--r--src/gpg/GpgContext.h82
-rw-r--r--src/gpg/GpgCoreInit.h10
-rw-r--r--src/gpg/GpgFunctionObject.h98
-rw-r--r--src/gpg/GpgGenKeyInfo.cpp87
-rw-r--r--src/gpg/GpgGenKeyInfo.h436
-rw-r--r--src/gpg/GpgInfo.h23
-rw-r--r--src/gpg/GpgModel.h45
-rw-r--r--src/gpg/function/BasicOperator.cpp4
-rw-r--r--src/gpg/function/GpgKeyGetter.cpp4
-rw-r--r--src/gpg/function/GpgKeyImportExporter.cpp14
-rw-r--r--src/gpg/function/GpgKeyManager.cpp4
-rw-r--r--src/gpg/function/GpgKeyOpera.cpp68
-rw-r--r--src/gpg/model/GpgData.cpp6
-rw-r--r--src/gpg/model/GpgData.h37
-rw-r--r--src/gpg/model/GpgKey.cpp49
-rw-r--r--src/gpg/model/GpgKey.h371
-rw-r--r--src/gpg/model/GpgKeySignature.cpp2
-rw-r--r--src/gpg/model/GpgKeySignature.h158
-rw-r--r--src/gpg/model/GpgSignature.cpp2
-rw-r--r--src/gpg/model/GpgSignature.h113
-rw-r--r--src/gpg/model/GpgSubKey.h197
-rw-r--r--src/gpg/model/GpgTOFUInfo.h98
-rw-r--r--src/gpg/model/GpgUID.cpp2
-rw-r--r--src/gpg/model/GpgUID.h121
-rw-r--r--src/gpg/result_analyse/DecryptResultAnalyse.cpp55
-rw-r--r--src/gpg/result_analyse/DecryptResultAnalyse.h24
-rw-r--r--src/gpg/result_analyse/EncryptResultAnalyse.cpp35
-rw-r--r--src/gpg/result_analyse/EncryptResultAnalyse.h18
-rw-r--r--src/gpg/result_analyse/ResultAnalyse.cpp12
-rw-r--r--src/gpg/result_analyse/ResultAnalyse.h43
-rw-r--r--src/gpg/result_analyse/SignResultAnalyse.cpp85
-rw-r--r--src/gpg/result_analyse/SignResultAnalyse.h18
-rw-r--r--src/gpg/result_analyse/VerifyResultAnalyse.cpp146
-rw-r--r--src/gpg/result_analyse/VerifyResultAnalyse.h37
-rw-r--r--src/ui/KeyImportDetailDialog.cpp6
-rwxr-xr-xsrc/ui/KeyMgmt.cpp36
-rw-r--r--src/ui/UserInterfaceUtils.cpp8
-rw-r--r--src/ui/keygen/KeygenDialog.cpp64
-rw-r--r--src/ui/keygen/SubkeyGenerateDialog.cpp53
-rw-r--r--src/ui/keypair_details/KeyDetailsDialog.cpp9
-rw-r--r--src/ui/keypair_details/KeyPairDetailTab.cpp62
-rw-r--r--src/ui/keypair_details/KeyPairOperaTab.cpp32
-rw-r--r--src/ui/keypair_details/KeyPairSubkeyTab.cpp69
-rw-r--r--src/ui/keypair_details/KeyPairUIDTab.cpp50
-rw-r--r--src/ui/keypair_details/KeySetExpireDateDialog.cpp4
-rw-r--r--src/ui/keypair_details/KeyUIDSignDialog.cpp9
-rw-r--r--src/ui/main_window/MainWindowFileSlotFunction.cpp36
-rw-r--r--src/ui/main_window/MainWindowSlotFunction.cpp46
-rw-r--r--src/ui/main_window/MainWindowUI.cpp10
-rw-r--r--src/ui/smtp/RecipientsPicker.cpp2
-rw-r--r--src/ui/smtp/SendMailDialog.cpp13
-rw-r--r--src/ui/smtp/SenderPicker.cpp9
-rw-r--r--src/ui/widgets/ExportKeyPackageDialog.cpp4
-rw-r--r--src/ui/widgets/KeyList.cpp57
-rw-r--r--src/ui/widgets/SignersPicker.cpp4
-rw-r--r--src/ui/widgets/VerifyKeyDetailBox.cpp50
58 files changed, 2340 insertions, 1027 deletions
diff --git a/src/gpg/GpgConstants.cpp b/src/gpg/GpgConstants.cpp
index 2c9403da..97fa9f8b 100644
--- a/src/gpg/GpgConstants.cpp
+++ b/src/gpg/GpgConstants.cpp
@@ -31,27 +31,24 @@
#include <string>
const char* GpgFrontend::GpgConstants::PGP_CRYPT_BEGIN =
- "-----BEGIN PGP MESSAGE-----";
+ "-----BEGIN PGP MESSAGE-----"; ///<
const char* GpgFrontend::GpgConstants::PGP_CRYPT_END =
- "-----END PGP MESSAGE-----";
+ "-----END PGP MESSAGE-----"; ///<
const char* GpgFrontend::GpgConstants::PGP_SIGNED_BEGIN =
- "-----BEGIN PGP SIGNED MESSAGE-----";
+ "-----BEGIN PGP SIGNED MESSAGE-----"; ///<
const char* GpgFrontend::GpgConstants::PGP_SIGNED_END =
- "-----END PGP SIGNATURE-----";
+ "-----END PGP SIGNATURE-----"; ///<
const char* GpgFrontend::GpgConstants::PGP_SIGNATURE_BEGIN =
- "-----BEGIN PGP SIGNATURE-----";
+ "-----BEGIN PGP SIGNATURE-----"; ///<
const char* GpgFrontend::GpgConstants::PGP_SIGNATURE_END =
- "-----END PGP SIGNATURE-----";
+ "-----END PGP SIGNATURE-----"; ///<
const char* GpgFrontend::GpgConstants::PGP_PUBLIC_KEY_BEGIN =
- "------BEGIN PGP PUBLIC KEY BLOCK-----";
+ "------BEGIN PGP PUBLIC KEY BLOCK-----"; ///<
const char* GpgFrontend::GpgConstants::PGP_PRIVATE_KEY_BEGIN =
- "-----BEGIN PGP PRIVATE KEY BLOCK-----";
+ "-----BEGIN PGP PRIVATE KEY BLOCK-----"; ///<
const char* GpgFrontend::GpgConstants::GPG_FRONTEND_SHORT_CRYPTO_HEAD =
- "GpgF_Scpt://";
+ "GpgF_Scpt://"; ///<
-///
-/// \param err gpg_error_t
-/// \return
gpgme_error_t GpgFrontend::check_gpg_error(gpgme_error_t err) {
if (gpg_err_code(err) != GPG_ERR_NO_ERROR) {
LOG(ERROR) << "[" << _("Error") << " " << gpg_err_code(err) << "] "
@@ -61,10 +58,6 @@ gpgme_error_t GpgFrontend::check_gpg_error(gpgme_error_t err) {
return err;
}
-///
-/// \param err
-/// \param predict
-/// \return
gpg_err_code_t GpgFrontend::check_gpg_error_2_err_code(gpgme_error_t err,
gpgme_error_t predict) {
auto err_code = gpg_err_code(err);
@@ -76,10 +69,6 @@ gpg_err_code_t GpgFrontend::check_gpg_error_2_err_code(gpgme_error_t err,
return err_code;
}
-///
-/// \param err
-/// \param comment
-/// \return
gpgme_error_t GpgFrontend::check_gpg_error(gpgme_error_t err,
const std::string& comment) {
if (gpg_err_code(err) != GPG_ERR_NO_ERROR) {
@@ -90,9 +79,6 @@ gpgme_error_t GpgFrontend::check_gpg_error(gpgme_error_t err,
return err;
}
-///
-/// \param fingerprint
-/// \return
std::string GpgFrontend::beautify_fingerprint(
GpgFrontend::BypeArrayConstRef fingerprint) {
auto len = fingerprint.size();
@@ -106,16 +92,12 @@ std::string GpgFrontend::beautify_fingerprint(
return out.str();
}
-///
-/// \param s
static inline void ltrim(std::string& s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
return !std::isspace(ch);
}));
}
-///
-/// \param s
static inline void rtrim(std::string& s) {
s.erase(std::find_if(s.rbegin(), s.rend(),
[](unsigned char ch) { return !std::isspace(ch); })
@@ -123,18 +105,12 @@ static inline void rtrim(std::string& s) {
s.end());
}
-///
-/// \param s
-/// \return
static inline std::string trim(std::string& s) {
ltrim(s);
rtrim(s);
return s;
}
-///
-/// \param utf8_path
-/// \return
std::string GpgFrontend::read_all_data_in_file(const std::string& utf8_path) {
using namespace boost::filesystem;
class path file_info(utf8_path.c_str());
@@ -153,10 +129,6 @@ std::string GpgFrontend::read_all_data_in_file(const std::string& utf8_path) {
return in_buffer;
}
-///
-/// \param utf8_path
-/// \param out_buffer
-/// \return
bool GpgFrontend::write_buffer_to_file(const std::string& utf8_path,
const std::string& out_buffer) {
using namespace boost::filesystem;
@@ -173,9 +145,6 @@ bool GpgFrontend::write_buffer_to_file(const std::string& utf8_path,
return true;
}
-///
-/// \param path
-/// \return
std::string GpgFrontend::get_file_extension(const std::string& path) {
// Create a path object from given string
boost::filesystem::path path_obj(path);
@@ -189,9 +158,6 @@ std::string GpgFrontend::get_file_extension(const std::string& path) {
return {};
}
-///
-/// \param path
-/// \return
std::string GpgFrontend::get_only_file_name_with_path(const std::string& path) {
// Create a path object from given string
boost::filesystem::path path_obj(path);
@@ -204,9 +170,6 @@ std::string GpgFrontend::get_only_file_name_with_path(const std::string& path) {
return {};
}
-///
-/// \param text
-/// \return
int GpgFrontend::text_is_signed(GpgFrontend::BypeArrayRef text) {
using boost::algorithm::ends_with;
using boost::algorithm::starts_with;
@@ -222,53 +185,36 @@ int GpgFrontend::text_is_signed(GpgFrontend::BypeArrayRef text) {
return 0;
}
-///
-/// \param result
-/// \return
GpgFrontend::GpgEncrResult GpgFrontend::_new_result(
gpgme_encrypt_result_t&& result) {
gpgme_result_ref(result);
return {result, _result_ref_deletor()};
}
-///
-/// \param result
-/// \return
GpgFrontend::GpgDecrResult GpgFrontend::_new_result(
gpgme_decrypt_result_t&& result) {
gpgme_result_ref(result);
return {result, _result_ref_deletor()};
}
-///
-/// \param result
-/// \return
GpgFrontend::GpgSignResult GpgFrontend::_new_result(
gpgme_sign_result_t&& result) {
gpgme_result_ref(result);
return {result, _result_ref_deletor()};
}
-///
-/// \param result
-/// \return
GpgFrontend::GpgVerifyResult GpgFrontend::_new_result(
gpgme_verify_result_t&& result) {
gpgme_result_ref(result);
return {result, _result_ref_deletor()};
}
-///
-/// \param result
-/// \return
GpgFrontend::GpgGenKeyResult GpgFrontend::_new_result(
gpgme_genkey_result_t&& result) {
gpgme_result_ref(result);
return {result, _result_ref_deletor()};
}
-///
-/// \param _result
void GpgFrontend::_result_ref_deletor::operator()(void* _result) {
DLOG(INFO) << _("Called") << _result;
if (_result != nullptr) gpgme_result_unref(_result);
diff --git a/src/gpg/GpgConstants.h b/src/gpg/GpgConstants.h
index 9ac0d7ad..00156388 100644
--- a/src/gpg/GpgConstants.h
+++ b/src/gpg/GpgConstants.h
@@ -34,73 +34,181 @@
#include "GpgFrontend.h"
-const int RESTART_CODE = 1000;
+const int RESTART_CODE = 1000; ///<
namespace GpgFrontend {
-using ByteArray = std::string;
-using ByteArrayPtr = std::unique_ptr<ByteArray>;
-using StdBypeArrayPtr = std::unique_ptr<ByteArray>;
-using BypeArrayRef = ByteArray&;
-using BypeArrayConstRef = const ByteArray&;
-using StringArgsPtr = std::unique_ptr<std::vector<std::string>>;
-using StringArgsRef = std::vector<std::string>&;
+using ByteArray = std::string; ///<
+using ByteArrayPtr = std::unique_ptr<ByteArray>; ///<
+using StdBypeArrayPtr = std::unique_ptr<ByteArray>; ///<
+using BypeArrayRef = ByteArray&; ///<
+using BypeArrayConstRef = const ByteArray&; ///<
+using StringArgsPtr = std::unique_ptr<std::vector<std::string>>; ///<
+using StringArgsRef = std::vector<std::string>&; ///<
using GpgError = gpgme_error_t;
-// Result Deleter
+/**
+ * @brief Result Deleter
+ *
+ */
struct _result_ref_deletor {
void operator()(void* _result);
};
-using GpgEncrResult = std::shared_ptr<struct _gpgme_op_encrypt_result>;
-using GpgDecrResult = std::shared_ptr<struct _gpgme_op_decrypt_result>;
-using GpgSignResult = std::shared_ptr<struct _gpgme_op_sign_result>;
-using GpgVerifyResult = std::shared_ptr<struct _gpgme_op_verify_result>;
-using GpgGenKeyResult = std::shared_ptr<struct _gpgme_op_genkey_result>;
+using GpgEncrResult = std::shared_ptr<struct _gpgme_op_encrypt_result>; ///<
+using GpgDecrResult = std::shared_ptr<struct _gpgme_op_decrypt_result>; ///<
+using GpgSignResult = std::shared_ptr<struct _gpgme_op_sign_result>; ///<
+using GpgVerifyResult = std::shared_ptr<struct _gpgme_op_verify_result>; ///<
+using GpgGenKeyResult = std::shared_ptr<struct _gpgme_op_genkey_result>; ///<
// Convert from gpgme_xxx_result to GpgXXXResult
+
+/**
+ * @brief
+ *
+ * @param result
+ * @return GpgEncrResult
+ */
GpgEncrResult _new_result(gpgme_encrypt_result_t&& result);
+
+/**
+ * @brief
+ *
+ * @param result
+ * @return GpgDecrResult
+ */
GpgDecrResult _new_result(gpgme_decrypt_result_t&& result);
+
+/**
+ * @brief
+ *
+ * @param result
+ * @return GpgSignResult
+ */
GpgSignResult _new_result(gpgme_sign_result_t&& result);
+
+/**
+ * @brief
+ *
+ * @param result
+ * @return GpgVerifyResult
+ */
GpgVerifyResult _new_result(gpgme_verify_result_t&& result);
+
+/**
+ * @brief
+ *
+ * @param result
+ * @return GpgGenKeyResult
+ */
GpgGenKeyResult _new_result(gpgme_genkey_result_t&& result);
// Error Info Printer
+
+/**
+ * @brief
+ *
+ * @param err
+ * @return GpgError
+ */
GpgError check_gpg_error(GpgError err);
+
+/**
+ * @brief
+ *
+ * @param gpgmeError
+ * @param comment
+ * @return GpgError
+ */
GpgError check_gpg_error(GpgError gpgmeError, const std::string& comment);
+
+/**
+ * @brief
+ *
+ * @param err
+ * @param predict
+ * @return gpg_err_code_t
+ */
gpg_err_code_t check_gpg_error_2_err_code(
gpgme_error_t err, gpgme_error_t predict = GPG_ERR_NO_ERROR);
// Fingerprint
+
+/**
+ * @brief
+ *
+ * @param fingerprint
+ * @return std::string
+ */
std::string beautify_fingerprint(BypeArrayConstRef fingerprint);
// File Operation
+
+/**
+ * @brief
+ *
+ * @param path
+ * @return std::string
+ */
std::string read_all_data_in_file(const std::string& path);
+
+/**
+ * @brief
+ *
+ * @param path
+ * @param out_buffer
+ * @return true
+ * @return false
+ */
bool write_buffer_to_file(const std::string& path,
const std::string& out_buffer);
+/**
+ * @brief Get the file extension object
+ *
+ * @param path
+ * @return std::string
+ */
std::string get_file_extension(const std::string& path);
+
+/**
+ * @brief Get the only file name with path object
+ *
+ * @param path
+ * @return std::string
+ */
std::string get_only_file_name_with_path(const std::string& path);
// Check
+
+/**
+ * @brief
+ *
+ * @param text
+ * @return int
+ */
int text_is_signed(BypeArrayRef text);
// Channels
-const int GPGFRONTEND_DEFAULT_CHANNEL = 0;
-const int GPGFRONTEND_NON_ASCII_CHANNEL = 2;
+const int GPGFRONTEND_DEFAULT_CHANNEL = 0; ///<
+const int GPGFRONTEND_NON_ASCII_CHANNEL = 2; ///<
+/**
+ * @brief
+ *
+ */
class GpgConstants {
public:
- static const char* PGP_CRYPT_BEGIN;
- static const char* PGP_CRYPT_END;
- static const char* PGP_SIGNED_BEGIN;
- static const char* PGP_SIGNED_END;
- static const char* PGP_SIGNATURE_BEGIN;
- static const char* PGP_SIGNATURE_END;
- static const char* PGP_PUBLIC_KEY_BEGIN;
- static const char* PGP_PRIVATE_KEY_BEGIN;
- static const char* GPG_FRONTEND_SHORT_CRYPTO_HEAD;
+ static const char* PGP_CRYPT_BEGIN; ///<
+ static const char* PGP_CRYPT_END; ///<
+ static const char* PGP_SIGNED_BEGIN; ///<
+ static const char* PGP_SIGNED_END; ///<
+ static const char* PGP_SIGNATURE_BEGIN; ///<
+ static const char* PGP_SIGNATURE_END; ///<
+ static const char* PGP_PUBLIC_KEY_BEGIN; ///<
+ static const char* PGP_PRIVATE_KEY_BEGIN; ///<
+ static const char* GPG_FRONTEND_SHORT_CRYPTO_HEAD; ///<
};
} // namespace GpgFrontend
diff --git a/src/gpg/GpgContext.h b/src/gpg/GpgContext.h
index 146f0794..8ab2cf36 100644
--- a/src/gpg/GpgContext.h
+++ b/src/gpg/GpgContext.h
@@ -32,9 +32,13 @@
namespace GpgFrontend {
+/**
+ * @brief
+ *
+ */
struct GpgContextInitArgs {
// make no sense for gpg2
- bool independent_database = false;
+ bool independent_database = false; ///<
std::string db_path = {};
bool gpg_alone = false;
std::string gpg_path = {};
@@ -45,48 +49,110 @@ struct GpgContextInitArgs {
};
/**
- * Custom Encapsulation of GpgME APIs
+ * @brief
+ *
*/
class GpgContext : public SingletonFunctionObject<GpgContext> {
public:
+ /**
+ * @brief Construct a new Gpg Context object
+ *
+ * @param args
+ */
explicit GpgContext(const GpgContextInitArgs& args = {});
+ /**
+ * @brief Construct a new Gpg Context object
+ *
+ * @param channel
+ */
explicit GpgContext(int channel)
: SingletonFunctionObject<GpgContext>(channel) {}
+ /**
+ * @brief Destroy the Gpg Context object
+ *
+ */
~GpgContext() override = default;
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
[[nodiscard]] bool good() const;
+ /**
+ * @brief Get the Info object
+ *
+ * @return const GpgInfo&
+ */
[[nodiscard]] const GpgInfo& GetInfo() const { return info_; }
+ /**
+ * @brief
+ *
+ * @return gpgme_ctx_t
+ */
operator gpgme_ctx_t() const { return _ctx_ref.get(); }
private:
- GpgInfo info_;
- GpgContextInitArgs args_;
+ GpgInfo info_; ///<
+ GpgContextInitArgs args_; ///<
+ /**
+ * @brief
+ *
+ */
void init_ctx();
+ /**
+ * @brief
+ *
+ */
struct _ctx_ref_deleter {
void operator()(gpgme_ctx_t _ctx) {
if (_ctx != nullptr) gpgme_release(_ctx);
}
};
- using CtxRefHandler = std::unique_ptr<struct gpgme_context, _ctx_ref_deleter>;
- CtxRefHandler _ctx_ref = nullptr;
-
- bool good_ = true;
+ using CtxRefHandler =
+ std::unique_ptr<struct gpgme_context, _ctx_ref_deleter>; ///<
+ CtxRefHandler _ctx_ref = nullptr; ///<
+ bool good_ = true; ///<
public:
+ /**
+ * @brief
+ *
+ * @param opaque
+ * @param uid_hint
+ * @param passphrase_info
+ * @param last_was_bad
+ * @param fd
+ * @return gpgme_error_t
+ */
static gpgme_error_t test_passphrase_cb(void* opaque, const char* uid_hint,
const char* passphrase_info,
int last_was_bad, int fd);
+ /**
+ * @brief
+ *
+ * @param hook
+ * @param keyword
+ * @param args
+ * @return gpgme_error_t
+ */
static gpgme_error_t test_status_cb(void* hook, const char* keyword,
const char* args);
+ /**
+ * @brief Set the Passphrase Cb object
+ *
+ * @param func
+ */
void SetPassphraseCb(gpgme_passphrase_cb_t func) const;
};
} // namespace GpgFrontend
diff --git a/src/gpg/GpgCoreInit.h b/src/gpg/GpgCoreInit.h
index 577f46a3..9aa3ed16 100644
--- a/src/gpg/GpgCoreInit.h
+++ b/src/gpg/GpgCoreInit.h
@@ -29,9 +29,17 @@
namespace GpgFrontend {
-// Init
+/**
+ * @brief
+ *
+ */
void init_gpgfrontend_core();
+/**
+ * @brief
+ *
+ * @param channel
+ */
void new_default_settings_channel(
int channel = GpgFrontend::GPGFRONTEND_DEFAULT_CHANNEL);
diff --git a/src/gpg/GpgFunctionObject.h b/src/gpg/GpgFunctionObject.h
index 9a2273d7..03abd77e 100644
--- a/src/gpg/GpgFunctionObject.h
+++ b/src/gpg/GpgFunctionObject.h
@@ -36,9 +36,20 @@
namespace GpgFrontend {
+/**
+ * @brief
+ *
+ * @tparam T
+ */
template <typename T>
class SingletonFunctionObject {
public:
+ /**
+ * @brief Get the Instance object
+ *
+ * @param channel
+ * @return T&
+ */
static T& GetInstance(
int channel = GpgFrontend::GPGFRONTEND_DEFAULT_CHANNEL) {
static_assert(std::is_base_of<SingletonFunctionObject<T>, T>::value,
@@ -51,6 +62,13 @@ class SingletonFunctionObject {
return *_p_pbj;
}
+ /**
+ * @brief Create a Instance object
+ *
+ * @param channel
+ * @param factory
+ * @return T&
+ */
static T& CreateInstance(int channel,
std::function<std::unique_ptr<T>(void)> factory) {
static_assert(std::is_base_of<SingletonFunctionObject<T>, T>::value,
@@ -63,6 +81,13 @@ class SingletonFunctionObject {
return *_p_pbj;
}
+ /**
+ * @brief Create a Instance object
+ *
+ * @param channel
+ * @param p_obj
+ * @return T&
+ */
static T& CreateInstance(int channel, std::unique_ptr<T> p_obj = nullptr) {
static_assert(std::is_base_of<SingletonFunctionObject<T>, T>::value,
"T not derived from SingletonFunctionObject<T>");
@@ -74,6 +99,12 @@ class SingletonFunctionObject {
return *_p_pbj;
}
+ /**
+ * @brief
+ *
+ * @param channel
+ * @return T&
+ */
static T& ReleaseChannel(int channel) {
decltype(_instances_map.end()) _it;
{
@@ -84,33 +115,79 @@ class SingletonFunctionObject {
DLOG(INFO) << "channel" << channel << "released";
}
+ /**
+ * @brief Get the Default Channel object
+ *
+ * @return int
+ */
static int GetDefaultChannel() { return _default_channel; }
+ /**
+ * @brief Get the Channel object
+ *
+ * @return int
+ */
[[nodiscard]] int GetChannel() const { return channel_; }
+ /**
+ * @brief Construct a new Singleton Function Object object
+ *
+ */
SingletonFunctionObject(T&&) = delete;
+ /**
+ * @brief Construct a new Singleton Function Object object
+ *
+ */
SingletonFunctionObject(const T&) = delete;
+ /**
+ * @brief
+ *
+ */
void operator=(const T&) = delete;
protected:
+ /**
+ * @brief Construct a new Singleton Function Object object
+ *
+ */
SingletonFunctionObject() = default;
+ /**
+ * @brief Construct a new Singleton Function Object object
+ *
+ * @param channel
+ */
explicit SingletonFunctionObject(int channel) : channel_(channel) {}
+ /**
+ * @brief Destroy the Singleton Function Object object
+ *
+ */
virtual ~SingletonFunctionObject() = default;
+ /**
+ * @brief Set the Channel object
+ *
+ * @param channel
+ */
void SetChannel(int channel) { this->channel_ = channel; }
private:
- int channel_ = _default_channel;
- static int _default_channel;
- static std::mutex _instance_mutex;
- static std::shared_mutex _instances_mutex;
- static std::unique_ptr<T> _instance;
- static std::map<int, std::unique_ptr<T>> _instances_map;
-
+ int channel_ = _default_channel; ///<
+ static int _default_channel; ///<
+ static std::mutex _instance_mutex; ///<
+ static std::shared_mutex _instances_mutex; ///<
+ static std::unique_ptr<T> _instance; ///<
+ static std::map<int, std::unique_ptr<T>> _instances_map; ///<
+
+ /**
+ * @brief
+ *
+ * @param channel
+ * @return T*
+ */
static T* find_object_in_channel(int channel) {
// read _instances_map
decltype(_instances_map.end()) _it;
@@ -124,6 +201,13 @@ class SingletonFunctionObject {
}
}
+ /**
+ * @brief Set the object in channel object
+ *
+ * @param channel
+ * @param p_obj
+ * @return T*
+ */
static T* set_object_in_channel(int channel, std::unique_ptr<T> p_obj) {
{
if (p_obj == nullptr) p_obj = std::make_unique<T>();
diff --git a/src/gpg/GpgGenKeyInfo.cpp b/src/gpg/GpgGenKeyInfo.cpp
index 1274421d..ec552a80 100644
--- a/src/gpg/GpgGenKeyInfo.cpp
+++ b/src/gpg/GpgGenKeyInfo.cpp
@@ -30,31 +30,31 @@
#include <string>
#include <vector>
-void GpgFrontend::GenKeyInfo::setAlgo(const std::string &m_algo) {
+void GpgFrontend::GenKeyInfo::SetAlgo(const std::string &m_algo) {
LOG(INFO) << "set algo" << m_algo;
// Check algo if supported
std::string algo_args = std::string(m_algo);
boost::algorithm::to_upper(algo_args);
if (standalone_) {
if (!subkey_) {
- auto support_algo = getSupportedKeyAlgoStandalone();
+ auto support_algo = GetSupportedKeyAlgoStandalone();
auto it = std::find(support_algo.begin(), support_algo.end(), algo_args);
// Algo Not Supported
if (it == support_algo.end()) return;
} else {
- auto support_algo = getSupportedSubkeyAlgoStandalone();
+ auto support_algo = GetSupportedSubkeyAlgoStandalone();
auto it = std::find(support_algo.begin(), support_algo.end(), algo_args);
// Algo Not Supported
if (it == support_algo.end()) return;
}
} else {
if (!subkey_) {
- auto support_algo = getSupportedKeyAlgo();
+ auto support_algo = GetSupportedKeyAlgo();
auto it = std::find(support_algo.begin(), support_algo.end(), algo_args);
// Algo Not Supported
if (it == support_algo.end()) return;
} else {
- auto support_algo = getSupportedSubkeyAlgo();
+ auto support_algo = GetSupportedSubkeyAlgo();
auto it = std::find(support_algo.begin(), support_algo.end(), algo_args);
// Algo Not Supported
if (it == support_algo.end()) return;
@@ -65,12 +65,12 @@ void GpgFrontend::GenKeyInfo::setAlgo(const std::string &m_algo) {
reset_options();
if (!this->subkey_) {
- this->setAllowCertification(true);
+ this->SetAllowCertification(true);
} else {
- this->setAllowCertification(false);
+ this->SetAllowCertification(false);
}
- this->allowChangeCertification = false;
+ this->allow_change_certification_ = false;
if (!standalone_) boost::algorithm::to_lower(algo_args);
@@ -83,7 +83,7 @@ void GpgFrontend::GenKeyInfo::setAlgo(const std::string &m_algo) {
suggest_min_key_size_ = 1024;
suggest_max_key_size_ = 4096;
suggest_size_addition_step_ = 1024;
- setKeySize(2048);
+ SetKeyLength(2048);
} else if (algo_args == "dsa") {
/**
@@ -92,62 +92,62 @@ void GpgFrontend::GenKeyInfo::setAlgo(const std::string &m_algo) {
* Recently, NIST has declared 512-bit keys obsolete:
* now, DSA is available in 1024, 2048 and 3072-bit lengths.
*/
- setAllowEncryption(false);
- allowChangeEncryption = false;
+ SetAllowEncryption(false);
+ allow_change_encryption_ = false;
suggest_min_key_size_ = 1024;
suggest_max_key_size_ = 3072;
suggest_size_addition_step_ = 1024;
- setKeySize(2048);
+ SetKeyLength(2048);
} else if (algo_args == "ed25519") {
/**
* GnuPG supports the Elgamal asymmetric encryption algorithm in key lengths
* ranging from 1024 to 4096 bits.
*/
- setAllowEncryption(false);
- allowChangeEncryption = false;
+ SetAllowEncryption(false);
+ allow_change_encryption_ = false;
suggest_min_key_size_ = -1;
suggest_max_key_size_ = -1;
suggest_size_addition_step_ = -1;
- setKeySize(-1);
+ SetKeyLength(-1);
} else if (algo_args == "elg") {
/**
* GnuPG supports the Elgamal asymmetric encryption algorithm in key lengths
* ranging from 1024 to 4096 bits.
*/
- setAllowAuthentication(false);
- allowChangeAuthentication = false;
+ SetAllowAuthentication(false);
+ allow_change_authentication_ = false;
- setAllowSigning(false);
- allowChangeSigning = false;
+ SetAllowSigning(false);
+ allow_change_signing_ = false;
suggest_min_key_size_ = 1024;
suggest_max_key_size_ = 4096;
suggest_size_addition_step_ = 1024;
- setKeySize(2048);
+ SetKeyLength(2048);
}
this->algo_ = algo_args;
}
void GpgFrontend::GenKeyInfo::reset_options() {
- allowChangeEncryption = true;
- setAllowEncryption(true);
+ allow_change_encryption_ = true;
+ SetAllowEncryption(true);
- allowChangeCertification = true;
- setAllowCertification(true);
+ allow_change_certification_ = true;
+ SetAllowCertification(true);
- allowChangeSigning = true;
- setAllowSigning(true);
+ allow_change_signing_ = true;
+ SetAllowSigning(true);
- allowChangeAuthentication = true;
- setAllowAuthentication(true);
+ allow_change_authentication_ = true;
+ SetAllowAuthentication(true);
passphrase_.clear();
}
-std::string GpgFrontend::GenKeyInfo::getKeySizeStr() const {
+std::string GpgFrontend::GenKeyInfo::GetKeySizeStr() const {
if (key_size_ > 0) {
return std::to_string(key_size_);
} else {
@@ -155,7 +155,7 @@ std::string GpgFrontend::GenKeyInfo::getKeySizeStr() const {
}
}
-void GpgFrontend::GenKeyInfo::setKeySize(int m_key_size) {
+void GpgFrontend::GenKeyInfo::SetKeyLength(int m_key_size) {
if (m_key_size < suggest_min_key_size_ ||
m_key_size > suggest_max_key_size_) {
return;
@@ -163,57 +163,58 @@ void GpgFrontend::GenKeyInfo::setKeySize(int m_key_size) {
GenKeyInfo::key_size_ = m_key_size;
}
-void GpgFrontend::GenKeyInfo::setExpired(
+void GpgFrontend::GenKeyInfo::SetExpireTime(
const boost::posix_time::ptime &m_expired) {
using namespace boost::gregorian;
- if (!isNonExpired()) {
+ if (!IsNonExpired()) {
GenKeyInfo::expired_ = m_expired;
}
}
-void GpgFrontend::GenKeyInfo::setNonExpired(bool m_non_expired) {
+void GpgFrontend::GenKeyInfo::SetNonExpired(bool m_non_expired) {
using namespace boost::posix_time;
if (!m_non_expired) this->expired_ = from_time_t(0);
GenKeyInfo::non_expired_ = m_non_expired;
}
-void GpgFrontend::GenKeyInfo::setAllowEncryption(bool m_allow_encryption) {
- if (allowChangeEncryption) GenKeyInfo::allowEncryption = m_allow_encryption;
+void GpgFrontend::GenKeyInfo::SetAllowEncryption(bool m_allow_encryption) {
+ if (allow_change_encryption_)
+ GenKeyInfo::allow_encryption_ = m_allow_encryption;
}
-void GpgFrontend::GenKeyInfo::setAllowCertification(
+void GpgFrontend::GenKeyInfo::SetAllowCertification(
bool m_allow_certification) {
- if (allowChangeCertification)
- GenKeyInfo::allowCertification = m_allow_certification;
+ if (allow_change_certification_)
+ GenKeyInfo::allow_certification_ = m_allow_certification;
}
GpgFrontend::GenKeyInfo::GenKeyInfo(bool m_is_sub_key, bool m_standalone)
: standalone_(m_standalone), subkey_(m_is_sub_key) {
- setAlgo("rsa");
+ SetAlgo("rsa");
}
-const std::vector<std::string> &GpgFrontend::GenKeyInfo::getSupportedKeyAlgo() {
+const std::vector<std::string> &GpgFrontend::GenKeyInfo::GetSupportedKeyAlgo() {
static const std::vector<std::string> support_key_algo = {"RSA", "DSA",
"ED25519"};
return support_key_algo;
}
const std::vector<std::string>
- &GpgFrontend::GenKeyInfo::getSupportedSubkeyAlgo() {
+ &GpgFrontend::GenKeyInfo::GetSupportedSubkeyAlgo() {
static const std::vector<std::string> support_subkey_algo = {"RSA", "DSA",
"ED25519"};
return support_subkey_algo;
}
const std::vector<std::string>
- &GpgFrontend::GenKeyInfo::getSupportedKeyAlgoStandalone() {
+ &GpgFrontend::GenKeyInfo::GetSupportedKeyAlgoStandalone() {
static const std::vector<std::string> support_subkey_algo_standalone = {
"RSA", "DSA"};
return support_subkey_algo_standalone;
}
const std::vector<std::string>
- &GpgFrontend::GenKeyInfo::getSupportedSubkeyAlgoStandalone() {
+ &GpgFrontend::GenKeyInfo::GetSupportedSubkeyAlgoStandalone() {
static const std::vector<std::string> support_subkey_algo_standalone = {
"RSA", "DSA", "ELG-E"};
return support_subkey_algo_standalone;
diff --git a/src/gpg/GpgGenKeyInfo.h b/src/gpg/GpgGenKeyInfo.h
index 89030b15..2a904930 100644
--- a/src/gpg/GpgGenKeyInfo.h
+++ b/src/gpg/GpgGenKeyInfo.h
@@ -36,159 +36,393 @@
namespace GpgFrontend {
class GenKeyInfo {
- bool standalone_ = false;
- bool subkey_ = false;
- std::string name_;
- std::string email_;
- std::string comment_;
+ bool standalone_ = false; ///<
+ bool subkey_ = false; ///<
+ std::string name_; ///<
+ std::string email_; ///<
+ std::string comment_; ///<
- std::string algo_;
+ 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;
+ boost::gregorian::years(2); ///<
+ bool non_expired_ = false; ///<
- bool no_passphrase_ = false;
- bool allow_no_pass_phrase_ = true;
+ 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;
+ int suggest_max_key_size_ = 4096; ///<
+ int suggest_size_addition_step_ = 1024; ///<
+ int suggest_min_key_size_ = 1024; ///<
- std::string passphrase_;
+ std::string passphrase_; ///<
public:
- static const std::vector<std::string> &getSupportedKeyAlgo();
-
- static const std::vector<std::string> &getSupportedSubkeyAlgo();
-
- static const std::vector<std::string> &getSupportedKeyAlgoStandalone();
-
- static const std::vector<std::string> &getSupportedSubkeyAlgoStandalone();
-
- [[nodiscard]] bool isSubKey() const { return subkey_; }
-
- void setIsSubKey(bool m_sub_key) { GenKeyInfo::subkey_ = m_sub_key; }
-
- [[nodiscard]] std::string getUserid() const {
+ /**
+ * @brief Get the Supported Key Algo object
+ *
+ * @return const std::vector<std::string>&
+ */
+ static const std::vector<std::string> &GetSupportedKeyAlgo();
+
+ /**
+ * @brief Get the Supported Subkey Algo object
+ *
+ * @return const std::vector<std::string>&
+ */
+ static const std::vector<std::string> &GetSupportedSubkeyAlgo();
+
+ /**
+ * @brief Get the Supported Key Algo Standalone object
+ *
+ * @return const std::vector<std::string>&
+ */
+ static const std::vector<std::string> &GetSupportedKeyAlgoStandalone();
+
+ /**
+ * @brief Get the Supported Subkey Algo Standalone object
+ *
+ * @return const std::vector<std::string>&
+ */
+ static const std::vector<std::string> &GetSupportedSubkeyAlgoStandalone();
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsSubKey() const { return subkey_; }
+
+ /**
+ * @brief Set the Is Sub Key object
+ *
+ * @param m_sub_key
+ */
+ void SetIsSubKey(bool m_sub_key) { GenKeyInfo::subkey_ = 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();
}
- void setName(const std::string &m_name) { this->name_ = m_name; }
-
- void setEmail(const std::string &m_email) { this->email_ = m_email; }
-
- void setComment(const std::string &m_comment) { this->comment_ = m_comment; }
-
- [[nodiscard]] std::string getName() const { return name_; }
-
- [[nodiscard]] std::string getEmail() const { return email_; }
-
- [[nodiscard]] std::string getComment() const { return comment_; }
-
- [[nodiscard]] const std::string &getAlgo() const { return algo_; }
-
- void setAlgo(const std::string &m_algo);
-
- [[nodiscard]] std::string getKeySizeStr() const;
-
- [[nodiscard]] int getKeySize() const { return key_size_; }
-
- void setKeySize(int m_key_size);
-
- [[nodiscard]] const boost::posix_time::ptime &getExpired() const {
+ /**
+ * @brief Set the Name object
+ *
+ * @param m_name
+ */
+ void SetName(const std::string &m_name) { this->name_ = m_name; }
+
+ /**
+ * @brief Set the Email object
+ *
+ * @param m_email
+ */
+ void SetEmail(const std::string &m_email) { this->email_ = m_email; }
+
+ /**
+ * @brief Set the Comment object
+ *
+ * @param m_comment
+ */
+ void SetComment(const std::string &m_comment) { this->comment_ = m_comment; }
+
+ /**
+ * @brief Get the Name object
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetName() const { return name_; }
+
+ /**
+ * @brief Get the Email object
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetEmail() const { return email_; }
+
+ /**
+ * @brief Get the Comment object
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetComment() const { return comment_; }
+
+ /**
+ * @brief Get the Algo object
+ *
+ * @return const std::string&
+ */
+ [[nodiscard]] const std::string &GetAlgo() const { return algo_; }
+
+ /**
+ * @brief Set the Algo object
+ *
+ * @param m_algo
+ */
+ void SetAlgo(const std::string &m_algo);
+
+ /**
+ * @brief Get the Key Size Str object
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetKeySizeStr() const;
+
+ /**
+ * @brief Get the Key Size object
+ *
+ * @return int
+ */
+ [[nodiscard]] int GetKeyLength() const { return key_size_; }
+
+ /**
+ * @brief Set the Key Size object
+ *
+ * @param m_key_size
+ */
+ void SetKeyLength(int m_key_size);
+
+ /**
+ * @brief Get the Expired object
+ *
+ * @return const boost::posix_time::ptime&
+ */
+ [[nodiscard]] const boost::posix_time::ptime &GetExpireTime() const {
return expired_;
}
- void setExpired(const boost::posix_time::ptime &m_expired);
-
- [[nodiscard]] bool isNonExpired() const { return non_expired_; }
-
- void setNonExpired(bool m_non_expired);
-
- [[nodiscard]] bool isNoPassPhrase() const { return this->no_passphrase_; }
-
- void setNonPassPhrase(bool m_non_pass_phrase) {
+ /**
+ * @brief Set the Expired object
+ *
+ * @param m_expired
+ */
+ void SetExpireTime(const boost::posix_time::ptime &m_expired);
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsNonExpired() const { return non_expired_; }
+
+ /**
+ * @brief Set the Non Expired object
+ *
+ * @param m_non_expired
+ */
+ void SetNonExpired(bool m_non_expired);
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsNoPassPhrase() const { return this->no_passphrase_; }
+
+ /**
+ * @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;
}
- [[nodiscard]] bool isAllowSigning() const { return allowSigning; }
-
- [[nodiscard]] bool isAllowNoPassPhrase() const {
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsAllowSigning() const { return allow_signing_; }
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsAllowNoPassPhrase() const {
return allow_no_pass_phrase_;
}
- void setAllowSigning(bool m_allow_signing) {
- if (allowChangeSigning) GenKeyInfo::allowSigning = m_allow_signing;
+ /**
+ * @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;
}
- [[nodiscard]] bool isAllowEncryption() const { return allowEncryption; }
-
- void setAllowEncryption(bool m_allow_encryption);
-
- [[nodiscard]] bool isAllowCertification() const { return allowCertification; }
-
- void setAllowCertification(bool m_allow_certification);
-
- [[nodiscard]] bool isAllowAuthentication() const {
- return allowAuthentication;
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsAllowEncryption() const { return allow_encryption_; }
+
+ /**
+ * @brief Set the Allow Encryption object
+ *
+ * @param m_allow_encryption
+ */
+ void SetAllowEncryption(bool m_allow_encryption);
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsAllowCertification() const {
+ return allow_certification_;
}
- void setAllowAuthentication(bool m_allow_authentication) {
- if (allowChangeAuthentication)
- GenKeyInfo::allowAuthentication = m_allow_authentication;
+ /**
+ * @brief Set the Allow Certification object
+ *
+ * @param m_allow_certification
+ */
+ void SetAllowCertification(bool m_allow_certification);
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsAllowAuthentication() const {
+ return allow_authentication_;
}
- [[nodiscard]] const std::string &getPassPhrase() const { return passphrase_; }
+ /**
+ * @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 setPassPhrase(const std::string &m_pass_phrase) {
+ /**
+ * @brief Get the Pass Phrase object
+ *
+ * @return const std::string&
+ */
+ [[nodiscard]] const std::string &GetPassPhrase() const { return passphrase_; }
+
+ /**
+ * @brief Set the Pass Phrase object
+ *
+ * @param m_pass_phrase
+ */
+ void SetPassPhrase(const std::string &m_pass_phrase) {
GenKeyInfo::passphrase_ = m_pass_phrase;
}
- [[nodiscard]] bool isAllowChangeSigning() const { return allowChangeSigning; }
- [[nodiscard]] bool isAllowChangeEncryption() const {
- return allowChangeEncryption;
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsAllowChangeSigning() const {
+ return allow_change_signing_;
+ }
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsAllowChangeEncryption() const {
+ return allow_change_encryption_;
}
- [[nodiscard]] bool isAllowChangeCertification() const {
- return allowChangeCertification;
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsAllowChangeCertification() const {
+ return allow_change_certification_;
}
- [[nodiscard]] bool isAllowChangeAuthentication() const {
- return allowChangeAuthentication;
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsAllowChangeAuthentication() const {
+ return allow_change_authentication_;
}
- [[nodiscard]] int getSuggestMaxKeySize() const {
+ /**
+ * @brief Get the Suggest Max Key Size object
+ *
+ * @return int
+ */
+ [[nodiscard]] int GetSuggestMaxKeySize() const {
return suggest_max_key_size_;
}
- [[nodiscard]] int getSuggestMinKeySize() const {
+ /**
+ * @brief Get the Suggest Min Key Size object
+ *
+ * @return int
+ */
+ [[nodiscard]] int GetSuggestMinKeySize() const {
return suggest_min_key_size_;
}
- [[nodiscard]] int getSizeChangeStep() const {
+ /**
+ * @brief Get the Size Change Step object
+ *
+ * @return int
+ */
+ [[nodiscard]] int GetSizeChangeStep() const {
return suggest_size_addition_step_;
}
private:
- bool allowEncryption = true;
- bool allowChangeEncryption = true;
-
- bool allowCertification = true;
- bool allowChangeCertification = true;
-
- bool allowAuthentication = true;
- bool allowChangeAuthentication = true;
-
- bool allowSigning = true;
- bool allowChangeSigning = true;
-
+ bool allow_encryption_ = true; ///<
+ bool allow_change_encryption_ = true; ///<
+ bool allow_certification_ = true; ///<
+ bool allow_change_certification_ = true; ///<
+ bool allow_authentication_ = true; ///<
+ bool allow_change_authentication_ = true; ///<
+ bool allow_signing_ = true; ///<
+ bool allow_change_signing_ = true; ///<
+
+ /**
+ * @brief
+ *
+ */
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);
};
diff --git a/src/gpg/GpgInfo.h b/src/gpg/GpgInfo.h
index 67ac55d6..1a6ebaaa 100644
--- a/src/gpg/GpgInfo.h
+++ b/src/gpg/GpgInfo.h
@@ -28,24 +28,17 @@
#include <string>
/**
- * Use to record some info about gnupg
+ * @brief Use to record some info about gnupg
+ *
*/
class GpgInfo {
public:
- /**
- * executable binary path of gnupg
- */
- std::string AppPath;
-
- std::string DatabasePath;
-
- std::string GnupgVersion;
-
- std::string GpgConfPath;
-
- std::string CMSPath;
-
- std::string GpgMEVersion;
+ std::string AppPath; ///< executable binary path of gnupg
+ std::string DatabasePath; ///<
+ std::string GnupgVersion; ///<
+ std::string GpgConfPath; ///<
+ std::string CMSPath; ///<
+ std::string GpgMEVersion; ///<
};
#endif // GPGFRONTEND_ZH_CN_TS_GPGINFO_H
diff --git a/src/gpg/GpgModel.h b/src/gpg/GpgModel.h
index af094bf5..d1866494 100644
--- a/src/gpg/GpgModel.h
+++ b/src/gpg/GpgModel.h
@@ -35,36 +35,21 @@
namespace GpgFrontend {
-using KeyId = std::string;
-
-using SubkeyId = std::string;
-
-using KeyIdArgsList = std::vector<KeyId>;
-
-using KeyIdArgsListPtr = std::unique_ptr<KeyIdArgsList>;
-
-using UIDArgsList = std::vector<std::string>;
-
-using UIDArgsListPtr = std::unique_ptr<UIDArgsList>;
-
-// KeyID/UID
-using SignIdArgsList = std::vector<std::pair<std::string, std::string>>;
-
-using SignIdArgsListPtr = std::unique_ptr<SignIdArgsList>;
-
-using KeyFprArgsListPtr = std::unique_ptr<std::vector<std::string>>;
-
-using KeyArgsList = std::vector<GpgKey>;
-
-using KeyListPtr = std::unique_ptr<KeyArgsList>;
-
-using GpgKeyLinkList = std::list<GpgFrontend::GpgKey>;
-
-using KeyLinkListPtr = std::unique_ptr<GpgKeyLinkList>;
-
-using KeyPtr = std::unique_ptr<GpgKey>;
-
-using KeyPtrArgsList = const std::initializer_list<KeyPtr>;
+using KeyId = std::string; ///<
+using SubkeyId = std::string; ///<
+using KeyIdArgsList = std::vector<KeyId>; ///<
+using KeyIdArgsListPtr = std::unique_ptr<KeyIdArgsList>; ///<
+using UIDArgsList = std::vector<std::string>; ///<
+using UIDArgsListPtr = std::unique_ptr<UIDArgsList>; ///<
+using SignIdArgsList = std::vector<std::pair<std::string, std::string>>; ///<
+using SignIdArgsListPtr = std::unique_ptr<SignIdArgsList>; ///<
+using KeyFprArgsListPtr = std::unique_ptr<std::vector<std::string>>; ///<
+using KeyArgsList = std::vector<GpgKey>; ///<
+using KeyListPtr = std::unique_ptr<KeyArgsList>; ///<
+using GpgKeyLinkList = std::list<GpgFrontend::GpgKey>; ///<
+using KeyLinkListPtr = std::unique_ptr<GpgKeyLinkList>; ///<
+using KeyPtr = std::unique_ptr<GpgKey>; ///<
+using KeyPtrArgsList = const std::initializer_list<KeyPtr>; ///<
} // namespace GpgFrontend
diff --git a/src/gpg/function/BasicOperator.cpp b/src/gpg/function/BasicOperator.cpp
index 6c699df1..1c2aac9c 100644
--- a/src/gpg/function/BasicOperator.cpp
+++ b/src/gpg/function/BasicOperator.cpp
@@ -173,8 +173,8 @@ gpgme_error_t GpgFrontend::BasicOperator::EncryptSign(
void GpgFrontend::BasicOperator::SetSigners(KeyArgsList& signers) {
gpgme_signers_clear(ctx_);
for (const GpgKey& key : signers) {
- DLOG(INFO) << "key" << key.fpr();
- if (key.CanSignActual()) {
+ DLOG(INFO) << "key" << key.GetFingerprint();
+ if (key.IsHasActualSigningCapability()) {
DLOG(INFO) << "signer";
auto error = gpgme_signers_add(ctx_, gpgme_key_t(key));
check_gpg_error(error);
diff --git a/src/gpg/function/GpgKeyGetter.cpp b/src/gpg/function/GpgKeyGetter.cpp
index 4c036a46..62264378 100644
--- a/src/gpg/function/GpgKeyGetter.cpp
+++ b/src/gpg/function/GpgKeyGetter.cpp
@@ -80,13 +80,13 @@ GpgFrontend::KeyListPtr GpgFrontend::GpgKeyGetter::GetKeys(
GpgFrontend::KeyLinkListPtr GpgFrontend::GpgKeyGetter::GetKeysCopy(
const GpgFrontend::KeyLinkListPtr& keys) {
auto keys_copy = std::make_unique<GpgKeyLinkList>();
- for (const auto& key : *keys) keys_copy->push_back(key.copy());
+ for (const auto& key : *keys) keys_copy->push_back(key.Copy());
return keys_copy;
}
GpgFrontend::KeyListPtr GpgFrontend::GpgKeyGetter::GetKeysCopy(
const GpgFrontend::KeyListPtr& keys) {
auto keys_copy = std::make_unique<KeyArgsList>();
- for (const auto& key : *keys) keys_copy->push_back(key.copy());
+ for (const auto& key : *keys) keys_copy->push_back(key.Copy());
return keys_copy;
}
diff --git a/src/gpg/function/GpgKeyImportExporter.cpp b/src/gpg/function/GpgKeyImportExporter.cpp
index 0ea6a460..d85ec38f 100644
--- a/src/gpg/function/GpgKeyImportExporter.cpp
+++ b/src/gpg/function/GpgKeyImportExporter.cpp
@@ -104,7 +104,7 @@ bool GpgFrontend::GpgKeyImportExporter::ExportKeys(const KeyArgsList& keys,
ByteArrayPtr& out_buffer,
bool secret) const {
KeyIdArgsListPtr key_ids = std::make_unique<std::vector<std::string>>();
- for (const auto& key : keys) key_ids->push_back(key.id());
+ for (const auto& key : keys) key_ids->push_back(key.GetId());
return ExportKeys(key_ids, out_buffer, secret);
}
@@ -116,7 +116,7 @@ bool GpgFrontend::GpgKeyImportExporter::ExportKeys(const KeyArgsList& keys,
*/
bool GpgFrontend::GpgKeyImportExporter::ExportSecretKey(
const GpgKey& key, ByteArrayPtr& out_buffer) const {
- DLOG(INFO) << "Export Secret Key" << key.id().c_str();
+ DLOG(INFO) << "Export Secret Key" << key.GetId().c_str();
gpgme_key_t target_key[2] = {gpgme_key_t(key), nullptr};
@@ -135,7 +135,7 @@ bool GpgFrontend::GpgKeyImportExporter::ExportKey(
const GpgFrontend::GpgKey& key,
GpgFrontend::ByteArrayPtr& out_buffer) const {
GpgData data_out;
- auto err = gpgme_op_export(ctx_, key.id().c_str(), 0, data_out);
+ auto err = gpgme_op_export(ctx_, key.GetId().c_str(), 0, data_out);
DLOG(INFO) << "exportKeys read_bytes"
<< gpgme_data_seek(data_out, 0, SEEK_END);
@@ -149,8 +149,8 @@ bool GpgFrontend::GpgKeyImportExporter::ExportKeyOpenSSH(
const GpgFrontend::GpgKey& key,
GpgFrontend::ByteArrayPtr& out_buffer) const {
GpgData data_out;
- auto err =
- gpgme_op_export(ctx_, key.id().c_str(), GPGME_EXPORT_MODE_SSH, data_out);
+ auto err = gpgme_op_export(ctx_, key.GetId().c_str(), GPGME_EXPORT_MODE_SSH,
+ data_out);
DLOG(INFO) << "read_bytes" << gpgme_data_seek(data_out, 0, SEEK_END);
@@ -163,8 +163,8 @@ bool GpgFrontend::GpgKeyImportExporter::ExportSecretKeyShortest(
const GpgFrontend::GpgKey& key,
GpgFrontend::ByteArrayPtr& out_buffer) const {
GpgData data_out;
- auto err = gpgme_op_export(ctx_, key.id().c_str(), GPGME_EXPORT_MODE_MINIMAL,
- data_out);
+ auto err = gpgme_op_export(ctx_, key.GetId().c_str(),
+ GPGME_EXPORT_MODE_MINIMAL, data_out);
DLOG(INFO) << "read_bytes" << gpgme_data_seek(data_out, 0, SEEK_END);
diff --git a/src/gpg/function/GpgKeyManager.cpp b/src/gpg/function/GpgKeyManager.cpp
index d25c3130..12461ec2 100644
--- a/src/gpg/function/GpgKeyManager.cpp
+++ b/src/gpg/function/GpgKeyManager.cpp
@@ -59,7 +59,7 @@ bool GpgFrontend::GpgKeyManager::RevSign(
for (const auto& sign_id : *signature_id) {
auto signing_key = key_getter.GetKey(sign_id.first);
- assert(signing_key.good());
+ assert(signing_key.IsGood());
auto err = check_gpg_error(gpgme_op_revsig(ctx_, gpgme_key_t(key),
gpgme_key_t(signing_key),
sign_id.second.c_str(), 0));
@@ -79,7 +79,7 @@ bool GpgFrontend::GpgKeyManager::SetExpire(
const char* sub_fprs = nullptr;
- if (subkey != nullptr) sub_fprs = subkey->fpr().c_str();
+ if (subkey != nullptr) sub_fprs = subkey->GetFingerprint().c_str();
auto err = check_gpg_error(
gpgme_op_setexpire(ctx_, gpgme_key_t(key), expires_time, sub_fprs, 0));
diff --git a/src/gpg/function/GpgKeyOpera.cpp b/src/gpg/function/GpgKeyOpera.cpp
index d3f94c18..5e26fa54 100644
--- a/src/gpg/function/GpgKeyOpera.cpp
+++ b/src/gpg/function/GpgKeyOpera.cpp
@@ -46,7 +46,7 @@ void GpgFrontend::GpgKeyOpera::DeleteKeys(
GpgError err;
for (const auto& tmp : *key_ids) {
auto key = GpgKeyGetter::GetInstance().GetKey(tmp);
- if (key.good()) {
+ if (key.IsGood()) {
err = check_gpg_error(
gpgme_op_delete_ext(ctx_, gpgme_key_t(key),
GPGME_DELETE_ALLOW_SECRET | GPGME_DELETE_FORCE));
@@ -77,10 +77,10 @@ GpgFrontend::GpgError GpgFrontend::GpgKeyOpera::SetExpire(
to_time_t(*expires) - system_clock::to_time_t(system_clock::now());
}
- LOG(INFO) << key.id() << subkey_fpr << expires_time;
+ LOG(INFO) << key.GetId() << subkey_fpr << expires_time;
GpgError err;
- if (key.fpr() == subkey_fpr || subkey_fpr.empty())
+ if (key.GetFingerprint() == subkey_fpr || subkey_fpr.empty())
err = gpgme_op_setexpire(ctx_, gpgme_key_t(key), expires_time, nullptr, 0);
else
err = gpgme_op_setexpire(ctx_, gpgme_key_t(key), expires_time,
@@ -97,9 +97,15 @@ GpgFrontend::GpgError GpgFrontend::GpgKeyOpera::SetExpire(
*/
void GpgFrontend::GpgKeyOpera::GenerateRevokeCert(
const GpgKey& key, const std::string& output_file_name) {
- auto args = std::vector<std::string>{
- "--no-tty", "--command-fd", "0", "--status-fd", "1", "-o",
- output_file_name, "--gen-revoke", key.fpr()};
+ auto args = std::vector<std::string>{"--no-tty",
+ "--command-fd",
+ "0",
+ "--status-fd",
+ "1",
+ "-o",
+ output_file_name,
+ "--gen-revoke",
+ key.GetFingerprint()};
using boost::asio::async_write;
using boost::process::async_pipe;
@@ -151,18 +157,18 @@ void GpgFrontend::GpgKeyOpera::GenerateRevokeCert(
*/
GpgFrontend::GpgError GpgFrontend::GpgKeyOpera::GenerateKey(
const std::unique_ptr<GenKeyInfo>& params, GpgGenKeyResult& result) {
- auto userid_utf8 = params->getUserid();
+ auto userid_utf8 = params->GetUserid();
const char* userid = userid_utf8.c_str();
- auto algo_utf8 = params->getAlgo() + params->getKeySizeStr();
+ auto algo_utf8 = params->GetAlgo() + params->GetKeySizeStr();
- LOG(INFO) << "params" << params->getAlgo() << params->getKeySizeStr();
+ LOG(INFO) << "params" << params->GetAlgo() << params->GetKeySizeStr();
const char* algo = algo_utf8.c_str();
unsigned long expires = 0;
{
using namespace boost::posix_time;
using namespace std::chrono;
- expires = to_time_t(ptime(params->getExpired())) -
+ expires = to_time_t(ptime(params->GetExpireTime())) -
system_clock::to_time_t(system_clock::now());
}
@@ -171,12 +177,12 @@ GpgFrontend::GpgError GpgFrontend::GpgKeyOpera::GenerateKey(
if (ctx_.GetInfo().GnupgVersion >= "2.1.0") {
unsigned int flags = 0;
- if (!params->isSubKey()) flags |= GPGME_CREATE_CERT;
- if (params->isAllowEncryption()) flags |= GPGME_CREATE_ENCR;
- if (params->isAllowSigning()) flags |= GPGME_CREATE_SIGN;
- if (params->isAllowAuthentication()) flags |= GPGME_CREATE_AUTH;
- if (params->isNonExpired()) flags |= GPGME_CREATE_NOEXPIRE;
- if (params->isNoPassPhrase()) flags |= GPGME_CREATE_NOPASSWD;
+ if (!params->IsSubKey()) flags |= GPGME_CREATE_CERT;
+ if (params->IsAllowEncryption()) flags |= GPGME_CREATE_ENCR;
+ if (params->IsAllowSigning()) flags |= GPGME_CREATE_SIGN;
+ if (params->IsAllowAuthentication()) flags |= GPGME_CREATE_AUTH;
+ if (params->IsNonExpired()) flags |= GPGME_CREATE_NOEXPIRE;
+ if (params->IsNoPassPhrase()) flags |= GPGME_CREATE_NOPASSWD;
LOG(INFO) << "args: " << userid << algo << expires << flags;
@@ -193,17 +199,17 @@ GpgFrontend::GpgError GpgFrontend::GpgKeyOpera::GenerateKey(
"Name-Real: %3%\n"
"Name-Comment: %4%\n"
"Name-Email: %5%\n"} %
- params->getAlgo() % params->getKeySize() % params->getName() %
- params->getComment() % params->getEmail();
+ params->GetAlgo() % params->GetKeyLength() % params->GetName() %
+ params->GetComment() % params->GetEmail();
ss << param_format;
- if (!params->isNonExpired()) {
- auto date = params->getExpired().date();
+ if (!params->IsNonExpired()) {
+ auto date = params->GetExpireTime().date();
ss << boost::format{"Expire-Date: %1%\n"} % to_iso_string(date);
} else
ss << boost::format{"Expire-Date: 0\n"};
- if (!params->isNoPassPhrase())
- ss << boost::format{"Passphrase: %1%\n"} % params->getPassPhrase();
+ if (!params->IsNoPassPhrase())
+ ss << boost::format{"Passphrase: %1%\n"} % params->GetPassPhrase();
ss << "</GnupgKeyParms>";
@@ -228,28 +234,28 @@ GpgFrontend::GpgError GpgFrontend::GpgKeyOpera::GenerateKey(
*/
GpgFrontend::GpgError GpgFrontend::GpgKeyOpera::GenerateSubkey(
const GpgKey& key, const std::unique_ptr<GenKeyInfo>& params) {
- if (!params->isSubKey()) return GPG_ERR_CANCELED;
+ if (!params->IsSubKey()) return GPG_ERR_CANCELED;
- auto algo_utf8 = (params->getAlgo() + params->getKeySizeStr());
+ auto algo_utf8 = (params->GetAlgo() + params->GetKeySizeStr());
const char* algo = algo_utf8.c_str();
unsigned long expires = 0;
{
using namespace boost::posix_time;
using namespace std::chrono;
- expires = to_time_t(ptime(params->getExpired())) -
+ expires = to_time_t(ptime(params->GetExpireTime())) -
system_clock::to_time_t(system_clock::now());
}
unsigned int flags = 0;
- if (!params->isSubKey()) flags |= GPGME_CREATE_CERT;
- if (params->isAllowEncryption()) flags |= GPGME_CREATE_ENCR;
- if (params->isAllowSigning()) flags |= GPGME_CREATE_SIGN;
- if (params->isAllowAuthentication()) flags |= GPGME_CREATE_AUTH;
- if (params->isNonExpired()) flags |= GPGME_CREATE_NOEXPIRE;
+ if (!params->IsSubKey()) flags |= GPGME_CREATE_CERT;
+ if (params->IsAllowEncryption()) flags |= GPGME_CREATE_ENCR;
+ if (params->IsAllowSigning()) flags |= GPGME_CREATE_SIGN;
+ if (params->IsAllowAuthentication()) flags |= GPGME_CREATE_AUTH;
+ if (params->IsNonExpired()) flags |= GPGME_CREATE_NOEXPIRE;
flags |= GPGME_CREATE_NOPASSWD;
- LOG(INFO) << "GpgFrontend::GpgKeyOpera::GenerateSubkey Args: " << key.id()
+ LOG(INFO) << "GpgFrontend::GpgKeyOpera::GenerateSubkey Args: " << key.GetId()
<< algo << expires << flags;
auto err =
diff --git a/src/gpg/model/GpgData.cpp b/src/gpg/model/GpgData.cpp
index c6e9b2ce..4a2e4ccb 100644
--- a/src/gpg/model/GpgData.cpp
+++ b/src/gpg/model/GpgData.cpp
@@ -30,8 +30,7 @@ GpgFrontend::GpgData::GpgData() {
auto err = gpgme_data_new(&data);
assert(gpgme_err_code(err) == GPG_ERR_NO_ERROR);
- data_ =
- std::unique_ptr<struct gpgme_data, __data_ref_deletor>(std::move(data));
+ data_ref_ = std::unique_ptr<struct gpgme_data, _data_ref_deleter>(data);
}
GpgFrontend::GpgData::GpgData(void* buffer, size_t size, bool copy) {
@@ -40,8 +39,7 @@ GpgFrontend::GpgData::GpgData(void* buffer, size_t size, bool copy) {
auto err = gpgme_data_new_from_mem(&data, (const char*)buffer, size, copy);
assert(gpgme_err_code(err) == GPG_ERR_NO_ERROR);
- data_ =
- std::unique_ptr<struct gpgme_data, __data_ref_deletor>(std::move(data));
+ data_ref_ = std::unique_ptr<struct gpgme_data, _data_ref_deleter>(data);
}
/**
diff --git a/src/gpg/model/GpgData.h b/src/gpg/model/GpgData.h
index e3202af6..73ba830d 100644
--- a/src/gpg/model/GpgData.h
+++ b/src/gpg/model/GpgData.h
@@ -28,25 +28,54 @@
#include "gpg/GpgConstants.h"
namespace GpgFrontend {
-
+/**
+ * @brief
+ *
+ */
class GpgData {
public:
+ /**
+ * @brief Construct a new Gpg Data object
+ *
+ */
GpgData();
+ /**
+ * @brief Construct a new Gpg Data object
+ *
+ * @param buffer
+ * @param size
+ * @param copy
+ */
GpgData(void* buffer, size_t size, bool copy = true);
- operator gpgme_data_t() { return data_.get(); }
+ /**
+ * @brief
+ *
+ * @return gpgme_data_t
+ */
+ operator gpgme_data_t() { return data_ref_.get(); }
+ /**
+ * @brief
+ *
+ * @return ByteArrayPtr
+ */
ByteArrayPtr Read2Buffer();
private:
- struct __data_ref_deletor {
+ /**
+ * @brief
+ *
+ */
+ struct _data_ref_deleter {
void operator()(gpgme_data_t _data) {
if (_data != nullptr) gpgme_data_release(_data);
}
};
- std::unique_ptr<struct gpgme_data, __data_ref_deletor> data_ = nullptr;
+ std::unique_ptr<struct gpgme_data, _data_ref_deleter> data_ref_ =
+ nullptr; ///<
};
} // namespace GpgFrontend
diff --git a/src/gpg/model/GpgKey.cpp b/src/gpg/model/GpgKey.cpp
index c14edd2d..720167c5 100644
--- a/src/gpg/model/GpgKey.cpp
+++ b/src/gpg/model/GpgKey.cpp
@@ -24,19 +24,19 @@
#include "gpg/model/GpgKey.h"
-GpgFrontend::GpgKey::GpgKey(gpgme_key_t &&key) : _key_ref(std::move(key)) {}
+GpgFrontend::GpgKey::GpgKey(gpgme_key_t &&key) : key_ref_(std::move(key)) {}
-GpgFrontend::GpgKey::GpgKey(GpgKey &&k) noexcept { swap(_key_ref, k._key_ref); }
+GpgFrontend::GpgKey::GpgKey(GpgKey &&k) noexcept { swap(key_ref_, k.key_ref_); }
GpgFrontend::GpgKey &GpgFrontend::GpgKey::operator=(GpgKey &&k) noexcept {
- swap(_key_ref, k._key_ref);
+ swap(key_ref_, k.key_ref_);
return *this;
}
std::unique_ptr<std::vector<GpgFrontend::GpgSubKey>>
-GpgFrontend::GpgKey::subKeys() const {
+GpgFrontend::GpgKey::GetSubKeys() const {
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;
@@ -44,10 +44,10 @@ GpgFrontend::GpgKey::subKeys() const {
return p_keys;
}
-std::unique_ptr<std::vector<GpgFrontend::GpgUID>> GpgFrontend::GpgKey::uids()
+std::unique_ptr<std::vector<GpgFrontend::GpgUID>> GpgFrontend::GpgKey::GetUIDs()
const {
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;
@@ -55,26 +55,28 @@ std::unique_ptr<std::vector<GpgFrontend::GpgUID>> GpgFrontend::GpgKey::uids()
return p_uids;
}
-bool GpgFrontend::GpgKey::CanSignActual() const {
- auto subkeys = subKeys();
+bool GpgFrontend::GpgKey::IsHasActualSigningCapability() const {
+ auto subkeys = GetSubKeys();
if (std::any_of(subkeys->begin(), subkeys->end(),
[](const GpgSubKey &subkey) -> bool {
- return subkey.secret() && subkey.can_sign() &&
- !subkey.disabled() && !subkey.revoked() &&
- !subkey.expired();
+ return subkey.IsSecretKey() &&
+ subkey.IsHasSigningCapability() &&
+ !subkey.IsDisabled() && !subkey.IsRevoked() &&
+ !subkey.IsExpired();
}))
return true;
else
return false;
}
-bool GpgFrontend::GpgKey::CanAuthActual() const {
- auto subkeys = subKeys();
+bool GpgFrontend::GpgKey::IsHasActualAuthenticationCapability() const {
+ auto subkeys = GetSubKeys();
if (std::any_of(subkeys->begin(), subkeys->end(),
[](const GpgSubKey &subkey) -> bool {
- return subkey.secret() && subkey.can_authenticate() &&
- !subkey.disabled() && !subkey.revoked() &&
- !subkey.expired();
+ return subkey.IsSecretKey() &&
+ subkey.IsHasAuthenticationCapability() &&
+ !subkey.IsDisabled() && !subkey.IsRevoked() &&
+ !subkey.IsExpired();
}))
return true;
else
@@ -86,8 +88,8 @@ bool GpgFrontend::GpgKey::CanAuthActual() const {
* @param key target key
* @return if key certify
*/
-bool GpgFrontend::GpgKey::CanCertActual() const {
- return has_master_key() && !expired() && !revoked() && !disabled();
+bool GpgFrontend::GpgKey::IsHasActualCertificationCapability() const {
+ return IsHasMasterKey() && !IsExpired() && !IsRevoked() && !IsDisabled();
}
/**
@@ -95,12 +97,13 @@ bool GpgFrontend::GpgKey::CanCertActual() const {
* @param key target key
* @return if key encrypt
*/
-bool GpgFrontend::GpgKey::CanEncrActual() const {
- auto subkeys = subKeys();
+bool GpgFrontend::GpgKey::IsHasActualEncryptionCapability() const {
+ auto subkeys = GetSubKeys();
if (std::any_of(subkeys->begin(), subkeys->end(),
[](const GpgSubKey &subkey) -> bool {
- return subkey.can_encrypt() && !subkey.disabled() &&
- !subkey.revoked() && !subkey.expired();
+ return subkey.IsHasEncryptionCapability() &&
+ !subkey.IsDisabled() && !subkey.IsRevoked() &&
+ !subkey.IsExpired();
}))
return true;
else
diff --git a/src/gpg/model/GpgKey.h b/src/gpg/model/GpgKey.h
index 0ce83372..faf0d02e 100644
--- a/src/gpg/model/GpgKey.h
+++ b/src/gpg/model/GpgKey.h
@@ -33,26 +33,73 @@
namespace GpgFrontend {
+/**
+ * @brief
+ *
+ */
class GpgKey {
public:
- [[nodiscard]] bool good() const { return _key_ref != nullptr; }
-
- [[nodiscard]] std::string id() const { return _key_ref->subkeys->keyid; }
-
- [[nodiscard]] std::string name() const { return _key_ref->uids->name; };
-
- [[nodiscard]] std::string email() const { return _key_ref->uids->email; }
-
- [[nodiscard]] std::string comment() const { return _key_ref->uids->comment; }
-
- [[nodiscard]] std::string fpr() const { return _key_ref->fpr; }
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsGood() const { return key_ref_ != nullptr; }
+
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetId() const { return key_ref_->subkeys->keyid; }
+
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetName() const { return key_ref_->uids->name; };
+
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetEmail() const { return key_ref_->uids->email; }
+
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetComment() const {
+ return key_ref_->uids->comment;
+ }
- [[nodiscard]] std::string protocol() const {
- return gpgme_get_protocol_name(_key_ref->protocol);
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetFingerprint() const { return key_ref_->fpr; }
+
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetProtocol() const {
+ return gpgme_get_protocol_name(key_ref_->protocol);
}
- [[nodiscard]] std::string owner_trust() const {
- switch (_key_ref->owner_trust) {
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetOwnerTrust() const {
+ switch (key_ref_->owner_trust) {
case GPGME_VALIDITY_UNKNOWN:
return "Unknown";
case GPGME_VALIDITY_UNDEFINED:
@@ -69,104 +116,294 @@ class GpgKey {
return "Invalid";
}
- [[nodiscard]] std::string pubkey_algo() const {
- return gpgme_pubkey_algo_name(_key_ref->subkeys->pubkey_algo);
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetPublicKeyAlgo() const {
+ return gpgme_pubkey_algo_name(key_ref_->subkeys->pubkey_algo);
}
- [[nodiscard]] boost::posix_time::ptime last_update() 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));
+ static_cast<time_t>(key_ref_->last_update));
}
- [[nodiscard]] boost::posix_time::ptime expires() const {
- return boost::posix_time::from_time_t(_key_ref->subkeys->expires);
+ /**
+ * @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 create_time() const {
- return boost::posix_time::from_time_t(_key_ref->subkeys->timestamp);
+ /**
+ * @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]] unsigned int length() const {
- return _key_ref->subkeys->length;
+ /**
+ * @brief s
+ *
+ * @return unsigned int
+ */
+ [[nodiscard]] unsigned int GetPrimaryKeyLength() const {
+ return key_ref_->subkeys->length;
}
- [[nodiscard]] bool can_encrypt() const { return _key_ref->can_encrypt; }
-
- [[nodiscard]] bool CanEncrActual() const;
-
- [[nodiscard]] bool can_sign() const { return _key_ref->can_sign; }
-
- [[nodiscard]] bool CanSignActual() const;
-
- [[nodiscard]] bool can_certify() const { return _key_ref->can_certify; }
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsHasEncryptionCapability() const {
+ return key_ref_->can_encrypt;
+ }
- [[nodiscard]] bool CanCertActual() const;
+ /**
+ * @brief
+
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsHasActualEncryptionCapability() const;
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsHasSigningCapability() const {
+ return key_ref_->can_sign;
+ }
- [[nodiscard]] bool can_authenticate() const {
- return _key_ref->can_authenticate;
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsHasActualSigningCapability() const;
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsHasCertificationCapability() const {
+ return key_ref_->can_certify;
}
- [[nodiscard]] bool CanAuthActual() const;
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsHasActualCertificationCapability() const;
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsHasAuthenticationCapability() const {
+ return key_ref_->can_authenticate;
+ }
- [[nodiscard]] bool HasCardKey() const {
- auto subkeys = subKeys();
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsHasActualAuthenticationCapability() const;
+
+ /**
+ * @brief
+ *
+ * @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.is_cardkey(); });
+ [](const GpgSubKey& subkey) -> bool { return subkey.IsCardKey(); });
}
- [[nodiscard]] bool is_private_key() const { return _key_ref->secret; }
-
- [[nodiscard]] bool expired() const { return _key_ref->expired; }
-
- [[nodiscard]] bool revoked() const { return _key_ref->revoked; }
-
- [[nodiscard]] bool disabled() const { return _key_ref->disabled; }
-
- [[nodiscard]] bool has_master_key() const {
- return _key_ref->subkeys->secret;
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsPrivateKey() const { return key_ref_->secret; }
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsExpired() const { return key_ref_->expired; }
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsRevoked() const { return key_ref_->revoked; }
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsDisabled() const { return key_ref_->disabled; }
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsHasMasterKey() const {
+ return key_ref_->subkeys->secret;
}
- [[nodiscard]] std::unique_ptr<std::vector<GpgSubKey>> subKeys() const;
-
- [[nodiscard]] std::unique_ptr<std::vector<GpgUID>> uids() const;
-
+ /**
+ * @brief
+ *
+ * @return std::unique_ptr<std::vector<GpgSubKey>>
+ */
+ [[nodiscard]] std::unique_ptr<std::vector<GpgSubKey>> GetSubKeys() const;
+
+ /**
+ * @brief
+ *
+ * @return std::unique_ptr<std::vector<GpgUID>>
+ */
+ [[nodiscard]] std::unique_ptr<std::vector<GpgUID>> GetUIDs() const;
+
+ /**
+ * @brief Construct a new Gpg Key object
+ *
+ */
GpgKey() = default;
+ /**
+ * @brief Construct a new Gpg Key object
+ *
+ * @param key
+ */
explicit GpgKey(gpgme_key_t&& key);
+ /**
+ * @brief Destroy the Gpg Key objects
+ *
+ */
~GpgKey() = default;
+ /**
+ * @brief Construct a new Gpg Key object
+ *
+ * @param key
+ */
GpgKey(const gpgme_key_t& key) = delete;
+ /**
+ * @brief Construct a new Gpg Key object
+ *
+ * @param k
+ */
GpgKey(GpgKey&& k) noexcept;
+ /**
+ * @brief
+ *
+ * @param k
+ * @return GpgKey&
+ */
GpgKey& operator=(GpgKey&& k) noexcept;
+ /**
+ * @brief
+ *
+ * @param key
+ * @return GpgKey&
+ */
GpgKey& operator=(const gpgme_key_t& key) = delete;
- bool operator==(const GpgKey& o) const { return o.id() == this->id(); }
-
- bool operator<=(const GpgKey& o) const { return this->id() < o.id(); }
-
- explicit operator gpgme_key_t() const { return _key_ref.get(); }
-
- [[nodiscard]] GpgKey copy() const {
- gpgme_key_ref(_key_ref.get());
- auto* _new_key_ref = _key_ref.get();
+ /**
+ * @brief
+ *
+ * @param o
+ * @return true
+ * @return false
+ */
+ bool operator==(const GpgKey& o) const { return o.GetId() == this->GetId(); }
+
+ /**
+ * @brief
+ *
+ * @param o
+ * @return true
+ * @return false
+ */
+ bool operator<=(const GpgKey& o) const { return this->GetId() < o.GetId(); }
+
+ /**
+ * @brief
+ *
+ * @return gpgme_key_t
+ */
+ explicit operator gpgme_key_t() const { return key_ref_.get(); }
+
+ /**
+ * @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));
}
private:
- struct _key_ref_deletor {
+ /**
+ * @brief
+ *
+ */
+ struct _key_ref_deleter {
void operator()(gpgme_key_t _key) {
if (_key != nullptr) gpgme_key_unref(_key);
}
};
- using KeyRefHandler = std::unique_ptr<struct _gpgme_key, _key_ref_deletor>;
+ using KeyRefHandler =
+ std::unique_ptr<struct _gpgme_key, _key_ref_deleter>; ///<
- KeyRefHandler _key_ref = nullptr;
+ KeyRefHandler key_ref_ = nullptr; ///<
};
} // namespace GpgFrontend
diff --git a/src/gpg/model/GpgKeySignature.cpp b/src/gpg/model/GpgKeySignature.cpp
index 8f937198..478b3d38 100644
--- a/src/gpg/model/GpgKeySignature.cpp
+++ b/src/gpg/model/GpgKeySignature.cpp
@@ -25,4 +25,4 @@
#include "gpg/model/GpgKeySignature.h"
GpgFrontend::GpgKeySignature::GpgKeySignature(gpgme_key_sig_t sig)
- : _signature_ref(sig, [&](gpgme_key_sig_t signature) {}) {}
+ : signature_ref_(sig, [&](gpgme_key_sig_t signature) {}) {}
diff --git a/src/gpg/model/GpgKeySignature.h b/src/gpg/model/GpgKeySignature.h
index d08162fc..dcae3581 100644
--- a/src/gpg/model/GpgKeySignature.h
+++ b/src/gpg/model/GpgKeySignature.h
@@ -30,54 +30,174 @@
#include "gpg/GpgConstants.h"
+/**
+ * @brief
+ *
+ */
namespace GpgFrontend {
+/**
+ * @brief
+ *
+ */
class GpgKeySignature {
public:
- [[nodiscard]] bool revoked() const { return _signature_ref->revoked; }
- [[nodiscard]] bool expired() const { return _signature_ref->expired; }
- [[nodiscard]] bool invalid() const { return _signature_ref->invalid; }
- [[nodiscard]] bool exportable() const { return _signature_ref->exportable; }
-
- [[nodiscard]] gpgme_error_t status() const { return _signature_ref->status; }
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsRevoked() const { return signature_ref_->revoked; }
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsExpired() const { return signature_ref_->expired; }
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsInvalid() const { return signature_ref_->invalid; }
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsExportable() const { return signature_ref_->exportable; }
+
+ /**
+ * @brief
+ *
+ * @return gpgme_error_t
+ */
+ [[nodiscard]] gpgme_error_t GetStatus() const {
+ return signature_ref_->status;
+ }
- [[nodiscard]] std::string keyid() const { return _signature_ref->keyid; }
- [[nodiscard]] std::string pubkey_algo() const {
- return gpgme_pubkey_algo_name(_signature_ref->pubkey_algo);
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetKeyID() const { return signature_ref_->keyid; }
+
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetPubkeyAlgo() const {
+ return gpgme_pubkey_algo_name(signature_ref_->pubkey_algo);
}
- [[nodiscard]] boost::posix_time::ptime create_time() const {
- return boost::posix_time::from_time_t(_signature_ref->timestamp);
+ /**
+ * @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 expire_time() const {
- return boost::posix_time::from_time_t(_signature_ref->expires);
+
+ /**
+ * @brief
+ *
+ * @return boost::posix_time::ptime
+ */
+ [[nodiscard]] boost::posix_time::ptime GetExpireTime() const {
+ return boost::posix_time::from_time_t(signature_ref_->expires);
}
- [[nodiscard]] std::string uid() const { return _signature_ref->uid; }
- [[nodiscard]] std::string name() const { return _signature_ref->name; }
- [[nodiscard]] std::string email() const { return _signature_ref->email; }
- [[nodiscard]] std::string comment() const { return _signature_ref->comment; }
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetUID() const { return signature_ref_->uid; }
+
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetName() const { return signature_ref_->name; }
+
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetEmail() const { return signature_ref_->email; }
+
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetComment() const {
+ return signature_ref_->comment;
+ }
+ /**
+ * @brief Construct a new Gpg Key Signature object
+ *
+ */
GpgKeySignature() = default;
+ /**
+ * @brief Destroy the Gpg Key Signature object
+ *
+ */
~GpgKeySignature() = default;
+ /**
+ * @brief Construct a new Gpg Key Signature object
+ *
+ * @param sig
+ */
explicit GpgKeySignature(gpgme_key_sig_t sig);
+ /**
+ * @brief Construct a new Gpg Key Signature object
+ *
+ */
GpgKeySignature(GpgKeySignature &&) noexcept = default;
+ /**
+ * @brief Construct a new Gpg Key Signature object
+ *
+ */
GpgKeySignature(const GpgKeySignature &) = delete;
+ /**
+ * @brief
+ *
+ * @return GpgKeySignature&
+ */
GpgKeySignature &operator=(GpgKeySignature &&) noexcept = default;
+ /**
+ * @brief
+ *
+ * @return GpgKeySignature&
+ */
GpgKeySignature &operator=(const GpgKeySignature &) = delete;
private:
using KeySignatrueRefHandler =
std::unique_ptr<struct _gpgme_key_sig,
- std::function<void(gpgme_key_sig_t)>>;
+ std::function<void(gpgme_key_sig_t)>>; ///<
- KeySignatrueRefHandler _signature_ref = nullptr;
+ KeySignatrueRefHandler signature_ref_ = nullptr; ///<
};
} // namespace GpgFrontend
diff --git a/src/gpg/model/GpgSignature.cpp b/src/gpg/model/GpgSignature.cpp
index c8509edf..06180918 100644
--- a/src/gpg/model/GpgSignature.cpp
+++ b/src/gpg/model/GpgSignature.cpp
@@ -25,4 +25,4 @@
#include "GpgSignature.h"
GpgFrontend::GpgSignature::GpgSignature(gpgme_signature_t sig)
- : _signature_ref(sig, [&](gpgme_signature_t signature) {}) {}
+ : signature_ref_(sig, [&](gpgme_signature_t signature) {}) {}
diff --git a/src/gpg/model/GpgSignature.h b/src/gpg/model/GpgSignature.h
index 419bf9cf..026d2d62 100644
--- a/src/gpg/model/GpgSignature.h
+++ b/src/gpg/model/GpgSignature.h
@@ -31,55 +31,136 @@
#include "gpg/GpgConstants.h"
namespace GpgFrontend {
+
+/**
+ * @brief
+ *
+ */
class GpgSignature {
public:
- [[nodiscard]] gpgme_validity_t validity() const {
- return _signature_ref->validity;
+ /**
+ * @brief
+ *
+ * @return gpgme_validity_t
+ */
+ [[nodiscard]] gpgme_validity_t GetValidity() const {
+ return signature_ref_->validity;
}
- [[nodiscard]] gpgme_error_t status() const { return _signature_ref->status; }
+ /**
+ * @brief
+ *
+ * @return gpgme_error_t
+ */
+ [[nodiscard]] gpgme_error_t GetStatus() const {
+ return signature_ref_->status;
+ }
- [[nodiscard]] gpgme_error_t summary() const {
- return _signature_ref->summary;
+ /**
+ * @brief
+ *
+ * @return gpgme_error_t
+ */
+ [[nodiscard]] gpgme_error_t GetSummary() const {
+ return signature_ref_->summary;
}
- [[nodiscard]] std::string pubkey_algo() const {
- return gpgme_pubkey_algo_name(_signature_ref->pubkey_algo);
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetPubkeyAlgo() const {
+ return gpgme_pubkey_algo_name(signature_ref_->pubkey_algo);
}
- [[nodiscard]] std::string hash_algo() const {
- return gpgme_hash_algo_name(_signature_ref->hash_algo);
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetHashAlgo() const {
+ return gpgme_hash_algo_name(signature_ref_->hash_algo);
}
- [[nodiscard]] boost::posix_time::ptime create_time() const {
- return boost::posix_time::from_time_t(_signature_ref->timestamp);
+ /**
+ * @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 expire_time() const {
- return boost::posix_time::from_time_t(_signature_ref->exp_timestamp);
+
+ /**
+ * @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]] std::string fpr() const { return _signature_ref->fpr; }
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetFingerprint() const {
+ return signature_ref_->fpr;
+ }
+ /**
+ * @brief Construct a new Gpg Signature object
+ *
+ */
GpgSignature() = default;
+ /**
+ * @brief Destroy the Gpg Signature object
+ *
+ */
~GpgSignature() = default;
+ /**
+ * @brief Construct a new Gpg Signature object
+ *
+ * @param sig
+ */
explicit GpgSignature(gpgme_signature_t sig);
+ /**
+ * @brief Construct a new Gpg Signature object
+ *
+ */
GpgSignature(GpgSignature &&) noexcept = default;
+ /**
+ * @brief Construct a new Gpg Signature object
+ *
+ */
GpgSignature(const GpgSignature &) = delete;
+ /**
+ * @brief
+ *
+ * @return GpgSignature&
+ */
GpgSignature &operator=(GpgSignature &&) noexcept = default;
+ /**
+ * @brief
+ *
+ * @return GpgSignature&
+ */
GpgSignature &operator=(const GpgSignature &) = delete;
private:
using KeySignatrueRefHandler =
std::unique_ptr<struct _gpgme_signature,
- std::function<void(gpgme_signature_t)>>;
+ std::function<void(gpgme_signature_t)>>; ///<
- KeySignatrueRefHandler _signature_ref = nullptr;
+ KeySignatrueRefHandler signature_ref_ = nullptr; ///<
};
} // namespace GpgFrontend
diff --git a/src/gpg/model/GpgSubKey.h b/src/gpg/model/GpgSubKey.h
index 462dcbca..5c5f8e6b 100644
--- a/src/gpg/model/GpgSubKey.h
+++ b/src/gpg/model/GpgSubKey.h
@@ -32,70 +32,211 @@
namespace GpgFrontend {
+/**
+ * @brief
+ *
+ */
class GpgSubKey {
public:
- [[nodiscard]] std::string id() const { return _subkey_ref->keyid; }
-
- [[nodiscard]] std::string fpr() const { return _subkey_ref->fpr; }
-
- [[nodiscard]] std::string pubkey_algo() const {
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetID() const { return _subkey_ref->keyid; }
+
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetFingerprint() const { return _subkey_ref->fpr; }
+
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetPubkeyAlgo() const {
return gpgme_pubkey_algo_name(_subkey_ref->pubkey_algo);
}
- [[nodiscard]] unsigned int length() const { return _subkey_ref->length; }
+ /**
+ * @brief
+ *
+ * @return unsigned int
+ */
+ [[nodiscard]] unsigned int GetKeyLength() const {
+ return _subkey_ref->length;
+ }
- [[nodiscard]] bool can_encrypt() const { return _subkey_ref->can_encrypt; }
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsHasEncryptionCapability() const {
+ return _subkey_ref->can_encrypt;
+ }
- [[nodiscard]] bool can_sign() const { return _subkey_ref->can_sign; }
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsHasSigningCapability() const {
+ return _subkey_ref->can_sign;
+ }
- [[nodiscard]] bool can_certify() const { return _subkey_ref->can_certify; }
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsHasCertificationCapability() const {
+ return _subkey_ref->can_certify;
+ }
- [[nodiscard]] bool can_authenticate() const {
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsHasAuthenticationCapability() const {
return _subkey_ref->can_authenticate;
}
- [[nodiscard]] bool is_private_key() const { return _subkey_ref->secret; }
-
- [[nodiscard]] bool expired() const { return _subkey_ref->expired; }
-
- [[nodiscard]] bool revoked() const { return _subkey_ref->revoked; }
-
- [[nodiscard]] bool disabled() const { return _subkey_ref->disabled; }
-
- [[nodiscard]] bool secret() const { return _subkey_ref->secret; }
-
- [[nodiscard]] bool is_cardkey() const { return _subkey_ref->is_cardkey; }
-
- [[nodiscard]] boost::posix_time::ptime timestamp() const {
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsPrivateKey() const { return _subkey_ref->secret; }
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsExpired() const { return _subkey_ref->expired; }
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsRevoked() const { return _subkey_ref->revoked; }
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsDisabled() const { return _subkey_ref->disabled; }
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsSecretKey() const { return _subkey_ref->secret; }
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool IsCardKey() const { return _subkey_ref->is_cardkey; }
+
+ /**
+ * @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 expires() const {
+ /**
+ * @brief
+ *
+ * @return boost::posix_time::ptime
+ */
+ [[nodiscard]] boost::posix_time::ptime GetExpireTime() const {
return boost::posix_time::from_time_t(_subkey_ref->expires);
}
+ /**
+ * @brief Construct a new Gpg Sub Key object
+ *
+ */
GpgSubKey() = default;
+ /**
+ * @brief Construct a new Gpg Sub Key object
+ *
+ * @param subkey
+ */
explicit GpgSubKey(gpgme_subkey_t subkey);
+ /**
+ * @brief Construct a new Gpg Sub Key object
+ *
+ * @param o
+ */
GpgSubKey(GpgSubKey&& o) noexcept { swap(_subkey_ref, o._subkey_ref); }
+ /**
+ * @brief Construct a new Gpg Sub Key object
+ *
+ */
GpgSubKey(const GpgSubKey&) = delete;
+ /**
+ * @brief
+ *
+ * @param o
+ * @return GpgSubKey&
+ */
GpgSubKey& operator=(GpgSubKey&& o) noexcept {
swap(_subkey_ref, o._subkey_ref);
return *this;
};
+ /**
+ * @brief
+ *
+ * @return GpgSubKey&
+ */
GpgSubKey& operator=(const GpgSubKey&) = delete;
- bool operator==(const GpgSubKey& o) const { return fpr() == o.fpr(); }
+ /**
+ * @brief
+ *
+ * @param o
+ * @return true
+ * @return false
+ */
+ bool operator==(const GpgSubKey& o) const {
+ return GetFingerprint() == o.GetFingerprint();
+ }
private:
- using SubkeyRefHandler = std::unique_ptr<struct _gpgme_subkey,
- std::function<void(gpgme_subkey_t)>>;
+ 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/gpg/model/GpgTOFUInfo.h b/src/gpg/model/GpgTOFUInfo.h
index 3d1e379d..40a3a3d7 100644
--- a/src/gpg/model/GpgTOFUInfo.h
+++ b/src/gpg/model/GpgTOFUInfo.h
@@ -28,60 +28,134 @@
#include "gpg/GpgConstants.h"
namespace GpgFrontend {
-
+/**
+ * @brief
+ *
+ */
class GpgTOFUInfo {
public:
- [[nodiscard]] unsigned validity() const { return _tofu_info_ref->validity; }
-
- [[nodiscard]] unsigned policy() const { return _tofu_info_ref->policy; }
+ /**
+ * @brief
+ *
+ * @return unsigned
+ */
+ [[nodiscard]] unsigned GetValidity() const {
+ return _tofu_info_ref->validity;
+ }
- [[nodiscard]] unsigned long sign_count() const {
+ /**
+ * @brief
+ *
+ * @return unsigned
+ */
+ [[nodiscard]] unsigned GetPolicy() const { return _tofu_info_ref->policy; }
+
+ /**
+ * @brief
+ *
+ * @return unsigned long
+ */
+ [[nodiscard]] unsigned long GetSignCount() const {
return _tofu_info_ref->signcount;
}
- [[nodiscard]] unsigned long encr_count() const {
+ /**
+ * @brief
+ *
+ * @return unsigned long
+ */
+ [[nodiscard]] unsigned long GetEncrCount() const {
return _tofu_info_ref->encrcount;
}
- [[nodiscard]] unsigned long sign_first() const {
+ /**
+ * @brief
+ *
+ * @return unsigned long
+ */
+ [[nodiscard]] unsigned long GetSignFirst() const {
return _tofu_info_ref->signfirst;
}
- [[nodiscard]] unsigned long sign_last() const {
+ /**
+ * @brief
+ *
+ * @return unsigned long
+ */
+ [[nodiscard]] unsigned long GetSignLast() const {
return _tofu_info_ref->signlast;
}
- [[nodiscard]] unsigned long encr_last() const {
+ /**
+ * @brief
+ *
+ * @return unsigned long
+ */
+ [[nodiscard]] unsigned long GetEncrLast() const {
return _tofu_info_ref->encrlast;
}
- [[nodiscard]] std::string description() const {
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetDescription() const {
return _tofu_info_ref->description;
}
+ /**
+ * @brief Construct a new Gpg T O F U Info object
+ *
+ */
GpgTOFUInfo() = default;
+ /**
+ * @brief Construct a new Gpg T O F U Info object
+ *
+ * @param tofu_info
+ */
explicit GpgTOFUInfo(gpgme_tofu_info_t tofu_info);
+ /**
+ * @brief Construct a new Gpg T O F U Info object
+ *
+ * @param o
+ */
GpgTOFUInfo(GpgTOFUInfo&& o) noexcept {
swap(_tofu_info_ref, o._tofu_info_ref);
}
+ /**
+ * @brief Construct a new Gpg T O F U Info object
+ *
+ */
GpgTOFUInfo(const GpgTOFUInfo&) = delete;
+ /**
+ * @brief
+ *
+ * @param o
+ * @return GpgTOFUInfo&
+ */
GpgTOFUInfo& operator=(GpgTOFUInfo&& o) noexcept {
swap(_tofu_info_ref, o._tofu_info_ref);
return *this;
};
+ /**
+ * @brief
+ *
+ * @return GpgTOFUInfo&
+ */
GpgTOFUInfo& operator=(const GpgTOFUInfo&) = delete;
private:
using SubkeyRefHandler =
std::unique_ptr<struct _gpgme_tofu_info,
- std::function<void(gpgme_tofu_info_t)>>;
+ std::function<void(gpgme_tofu_info_t)>>; ///<
- SubkeyRefHandler _tofu_info_ref = nullptr;
+ SubkeyRefHandler _tofu_info_ref = nullptr; ///<
};
} // namespace GpgFrontend
diff --git a/src/gpg/model/GpgUID.cpp b/src/gpg/model/GpgUID.cpp
index c0a63bab..b8d86323 100644
--- a/src/gpg/model/GpgUID.cpp
+++ b/src/gpg/model/GpgUID.cpp
@@ -25,4 +25,4 @@
#include "gpg/model/GpgUID.h"
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) {}) {} \ No newline at end of file
diff --git a/src/gpg/model/GpgUID.h b/src/gpg/model/GpgUID.h
index 8cac4cf7..36c40f4f 100644
--- a/src/gpg/model/GpgUID.h
+++ b/src/gpg/model/GpgUID.h
@@ -29,24 +29,64 @@
#include "GpgTOFUInfo.h"
namespace GpgFrontend {
-
+/**
+ * @brief
+ *
+ */
class GpgUID {
public:
- [[nodiscard]] std::string name() const { return _uid_ref->name; }
-
- [[nodiscard]] std::string email() const { return _uid_ref->email; }
-
- [[nodiscard]] std::string comment() const { return _uid_ref->comment; }
-
- [[nodiscard]] std::string uid() const { return _uid_ref->uid; }
-
- [[nodiscard]] bool revoked() const { return _uid_ref->revoked; }
-
- [[nodiscard]] bool invalid() const { return _uid_ref->invalid; }
-
- [[nodiscard]] std::unique_ptr<std::vector<GpgTOFUInfo>> tofu_infos() const {
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetName() const { return uid_ref_->name; }
+
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetEmail() const { return uid_ref_->email; }
+
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetComment() const { return uid_ref_->comment; }
+
+ /**
+ * @brief
+ *
+ * @return std::string
+ */
+ [[nodiscard]] std::string GetUID() const { return uid_ref_->uid; }
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool GetRevoked() const { return uid_ref_->revoked; }
+
+ /**
+ * @brief
+ *
+ * @return true
+ * @return false
+ */
+ [[nodiscard]] bool GetInvalid() const { return uid_ref_->invalid; }
+
+ /**
+ * @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;
+ auto info_next = uid_ref_->tofu;
while (info_next != nullptr) {
infos->push_back(GpgTOFUInfo(info_next));
info_next = info_next->next;
@@ -54,10 +94,15 @@ class GpgUID {
return infos;
}
- [[nodiscard]] std::unique_ptr<std::vector<GpgKeySignature>> signatures()
+ /**
+ * @brief
+ *
+ * @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;
+ auto sig_next = uid_ref_->signatures;
while (sig_next != nullptr) {
sigs->push_back(GpgKeySignature(sig_next));
sig_next = sig_next->next;
@@ -65,26 +110,56 @@ class GpgUID {
return sigs;
}
+ /**
+ * @brief Construct a new Gpg U I D object
+ *
+ */
GpgUID() = default;
+ /**
+ * @brief Construct a new Gpg U I D object
+ *
+ * @param uid
+ */
explicit GpgUID(gpgme_user_id_t uid);
- GpgUID(GpgUID &&o) noexcept { swap(_uid_ref, o._uid_ref); }
-
+ /**
+ * @brief Construct a new Gpg U I D object
+ *
+ * @param o
+ */
+ GpgUID(GpgUID &&o) noexcept { swap(uid_ref_, o.uid_ref_); }
+
+ /**
+ * @brief Construct a new Gpg U I D object
+ *
+ */
GpgUID(const GpgUID &) = delete;
+ /**
+ * @brief
+ *
+ * @param o
+ * @return GpgUID&
+ */
GpgUID &operator=(GpgUID &&o) noexcept {
- swap(_uid_ref, o._uid_ref);
+ swap(uid_ref_, o.uid_ref_);
return *this;
}
+ /**
+ * @brief
+ *
+ * @return GpgUID&
+ */
GpgUID &operator=(const GpgUID &) = delete;
private:
- using UidRefHandler = std::unique_ptr<struct _gpgme_user_id,
- std::function<void(gpgme_user_id_t)>>;
+ using UidRefHandler =
+ std::unique_ptr<struct _gpgme_user_id,
+ std::function<void(gpgme_user_id_t)>>; ///<
- UidRefHandler _uid_ref = nullptr;
+ UidRefHandler uid_ref_ = nullptr; ///<
};
} // namespace GpgFrontend
diff --git a/src/gpg/result_analyse/DecryptResultAnalyse.cpp b/src/gpg/result_analyse/DecryptResultAnalyse.cpp
index f2e9f947..20be8244 100644
--- a/src/gpg/result_analyse/DecryptResultAnalyse.cpp
+++ b/src/gpg/result_analyse/DecryptResultAnalyse.cpp
@@ -28,43 +28,44 @@
GpgFrontend::DecryptResultAnalyse::DecryptResultAnalyse(GpgError m_error,
GpgDecrResult m_result)
- : error(m_error), result(std::move(m_result)) {}
+ : error_(m_error), result_(std::move(m_result)) {}
void GpgFrontend::DecryptResultAnalyse::do_analyse() {
- stream << "[#] " << _("Decrypt Operation");
+ stream_ << "[#] " << _("Decrypt Operation");
- if (gpgme_err_code(error) == GPG_ERR_NO_ERROR) {
- stream << "[" << _("Success") << "]" << std::endl;
+ if (gpgme_err_code(error_) == GPG_ERR_NO_ERROR) {
+ stream_ << "[" << _("Success") << "]" << std::endl;
} else {
- stream << "[" << _("Failed") << "] " << gpgme_strerror(error) << std::endl;
- setStatus(-1);
- if (result != nullptr && result->unsupported_algorithm != nullptr) {
- stream << "------------>" << std::endl;
- stream << _("Unsupported Algo") << ": " << result->unsupported_algorithm
- << std::endl;
+ stream_ << "[" << _("Failed") << "] " << gpgme_strerror(error_)
+ << std::endl;
+ set_status(-1);
+ if (result_ != nullptr && result_->unsupported_algorithm != nullptr) {
+ stream_ << "------------>" << std::endl;
+ stream_ << _("Unsupported Algo") << ": " << result_->unsupported_algorithm
+ << std::endl;
}
}
- if (result != nullptr && result->recipients != nullptr) {
- stream << "------------>" << std::endl;
- if (result->file_name != nullptr) {
- stream << _("File Name") << ": " << result->file_name << std::endl;
- stream << std::endl;
+ if (result_ != nullptr && result_->recipients != nullptr) {
+ stream_ << "------------>" << std::endl;
+ if (result_->file_name != nullptr) {
+ stream_ << _("File Name") << ": " << result_->file_name << std::endl;
+ stream_ << std::endl;
}
- if (result->is_mime) {
- stream << _("MIME") << ": " << _("true") << std::endl;
+ if (result_->is_mime) {
+ stream_ << _("MIME") << ": " << _("true") << std::endl;
}
- auto recipient = result->recipients;
- if (recipient != nullptr) stream << _("Recipient(s)") << ": " << std::endl;
+ auto recipient = result_->recipients;
+ if (recipient != nullptr) stream_ << _("Recipient(s)") << ": " << std::endl;
while (recipient != nullptr) {
- print_recipient(stream, recipient);
+ print_recipient(stream_, recipient);
recipient = recipient->next;
}
- stream << "<------------" << std::endl;
+ stream_ << "<------------" << std::endl;
}
- stream << std::endl;
+ stream_ << std::endl;
}
void GpgFrontend::DecryptResultAnalyse::print_recipient(
@@ -74,14 +75,14 @@ void GpgFrontend::DecryptResultAnalyse::print_recipient(
stream << " {>} " << _("Recipient") << ": ";
auto key = GpgFrontend::GpgKeyGetter::GetInstance().GetKey(recipient->keyid);
- if (key.good()) {
- stream << key.name().c_str();
- if (!key.email().empty()) {
- stream << "<" << key.email().c_str() << ">";
+ if (key.IsGood()) {
+ stream << key.GetName().c_str();
+ if (!key.GetEmail().empty()) {
+ stream << "<" << key.GetEmail().c_str() << ">";
}
} else {
stream << "<" << _("Unknown") << ">";
- setStatus(0);
+ set_status(0);
}
stream << std::endl;
diff --git a/src/gpg/result_analyse/DecryptResultAnalyse.h b/src/gpg/result_analyse/DecryptResultAnalyse.h
index 729d8853..7377e7d1 100644
--- a/src/gpg/result_analyse/DecryptResultAnalyse.h
+++ b/src/gpg/result_analyse/DecryptResultAnalyse.h
@@ -30,18 +30,38 @@
namespace GpgFrontend {
+/**
+ * @brief
+ *
+ */
class DecryptResultAnalyse : public ResultAnalyse {
public:
+ /**
+ * @brief Construct a new Decrypt Result Analyse object
+ *
+ * @param m_error
+ * @param m_result
+ */
explicit DecryptResultAnalyse(GpgError m_error, GpgDecrResult m_result);
protected:
+ /**
+ * @brief
+ *
+ */
void do_analyse() final;
private:
+ /**
+ * @brief
+ *
+ * @param stream
+ * @param recipient
+ */
void print_recipient(std::stringstream &stream, gpgme_recipient_t recipient);
- GpgError error;
- GpgDecrResult result;
+ GpgError error_; ///<
+ GpgDecrResult result_; ///<
};
} // namespace GpgFrontend
diff --git a/src/gpg/result_analyse/EncryptResultAnalyse.cpp b/src/gpg/result_analyse/EncryptResultAnalyse.cpp
index df240a1d..eefd62a1 100644
--- a/src/gpg/result_analyse/EncryptResultAnalyse.cpp
+++ b/src/gpg/result_analyse/EncryptResultAnalyse.cpp
@@ -26,36 +26,37 @@
GpgFrontend::EncryptResultAnalyse::EncryptResultAnalyse(GpgError error,
GpgEncrResult result)
- : error(error), result(std::move(result)) {}
+ : error_(error), result_(std::move(result)) {}
void GpgFrontend::EncryptResultAnalyse::do_analyse() {
LOG(INFO) << _("Start Encrypt Result Analyse");
- stream << "[#] " << _("Encrypt Operation") << " ";
+ stream_ << "[#] " << _("Encrypt Operation") << " ";
- if (gpgme_err_code(error) == GPG_ERR_NO_ERROR)
- stream << "[" << _("Success") << "]" << std::endl;
+ if (gpgme_err_code(error_) == GPG_ERR_NO_ERROR)
+ stream_ << "[" << _("Success") << "]" << std::endl;
else {
- stream << "[" << _("Failed") << "] " << gpgme_strerror(error) << std::endl;
- setStatus(-1);
+ stream_ << "[" << _("Failed") << "] " << gpgme_strerror(error_)
+ << std::endl;
+ set_status(-1);
}
- if (!~status) {
- stream << "------------>" << std::endl;
- if (result != nullptr) {
- stream << _("Invalid Recipients") << ": " << std::endl;
- auto inv_reci = result->invalid_recipients;
+ if (!~status_) {
+ stream_ << "------------>" << std::endl;
+ if (result_ != nullptr) {
+ stream_ << _("Invalid Recipients") << ": " << std::endl;
+ auto inv_reci = result_->invalid_recipients;
while (inv_reci != nullptr) {
- stream << _("Fingerprint") << ": " << inv_reci->fpr << std::endl;
- stream << _("Reason") << ": " << gpgme_strerror(inv_reci->reason)
- << std::endl;
- stream << std::endl;
+ stream_ << _("Fingerprint") << ": " << inv_reci->fpr << std::endl;
+ stream_ << _("Reason") << ": " << gpgme_strerror(inv_reci->reason)
+ << std::endl;
+ stream_ << std::endl;
inv_reci = inv_reci->next;
}
}
- stream << "<------------" << std::endl;
+ stream_ << "<------------" << std::endl;
}
- stream << std::endl;
+ stream_ << std::endl;
}
diff --git a/src/gpg/result_analyse/EncryptResultAnalyse.h b/src/gpg/result_analyse/EncryptResultAnalyse.h
index e0a411d1..9b03c37f 100644
--- a/src/gpg/result_analyse/EncryptResultAnalyse.h
+++ b/src/gpg/result_analyse/EncryptResultAnalyse.h
@@ -29,16 +29,30 @@
#include "gpg/GpgConstants.h"
namespace GpgFrontend {
+/**
+ * @brief
+ *
+ */
class EncryptResultAnalyse : public ResultAnalyse {
public:
+ /**
+ * @brief Construct a new Encrypt Result Analyse object
+ *
+ * @param error
+ * @param result
+ */
explicit EncryptResultAnalyse(GpgError error, GpgEncrResult result);
protected:
+ /**
+ * @brief
+ *
+ */
void do_analyse() final;
private:
- GpgError error;
- GpgEncrResult result;
+ GpgError error_; ///<
+ GpgEncrResult result_; ///<
};
} // namespace GpgFrontend
diff --git a/src/gpg/result_analyse/ResultAnalyse.cpp b/src/gpg/result_analyse/ResultAnalyse.cpp
index 821da2ee..21e46c9c 100644
--- a/src/gpg/result_analyse/ResultAnalyse.cpp
+++ b/src/gpg/result_analyse/ResultAnalyse.cpp
@@ -24,17 +24,17 @@
#include "gpg/result_analyse/ResultAnalyse.h"
-const std::string GpgFrontend::ResultAnalyse::getResultReport() const {
- return stream.str();
+const std::string GpgFrontend::ResultAnalyse::GetResultReport() const {
+ return stream_.str();
}
-int GpgFrontend::ResultAnalyse::getStatus() const { return status; }
+int GpgFrontend::ResultAnalyse::GetStatus() const { return status_; }
-void GpgFrontend::ResultAnalyse::setStatus(int mStatus) {
- if (mStatus < status) status = mStatus;
+void GpgFrontend::ResultAnalyse::set_status(int m_status) {
+ if (m_status < status_) status_ = m_status;
}
-void GpgFrontend::ResultAnalyse::analyse() {
+void GpgFrontend::ResultAnalyse::Analyse() {
if (!analysed_) {
do_analyse();
analysed_ = true;
diff --git a/src/gpg/result_analyse/ResultAnalyse.h b/src/gpg/result_analyse/ResultAnalyse.h
index 33341b44..97dc0783 100644
--- a/src/gpg/result_analyse/ResultAnalyse.h
+++ b/src/gpg/result_analyse/ResultAnalyse.h
@@ -32,24 +32,49 @@ namespace GpgFrontend {
class ResultAnalyse {
public:
+ /**
+ * @brief Construct a new Result Analyse object
+ *
+ */
ResultAnalyse() = default;
- [[nodiscard]] const std::string getResultReport() const;
+ /**
+ * @brief Get the Result Report object
+ *
+ * @return const std::string
+ */
+ [[nodiscard]] const std::string GetResultReport() const;
- [[nodiscard]] int getStatus() const;
+ /**
+ * @brief Get the Status object
+ *
+ * @return int
+ */
+ [[nodiscard]] int GetStatus() const;
- void analyse();
+ /**
+ * @brief
+ *
+ */
+ void Analyse();
protected:
+ /**
+ * @brief
+ *
+ */
virtual void do_analyse() = 0;
- std::stringstream stream;
+ /**
+ * @brief Set the status object
+ *
+ * @param m_status
+ */
+ void set_status(int m_status);
- int status = 1;
-
- bool analysed_ = false;
-
- void setStatus(int mStatus);
+ std::stringstream stream_; ///<
+ int status_ = 1; ///<
+ bool analysed_ = false; ///<
};
} // namespace GpgFrontend
diff --git a/src/gpg/result_analyse/SignResultAnalyse.cpp b/src/gpg/result_analyse/SignResultAnalyse.cpp
index a65c4a9d..511bd54d 100644
--- a/src/gpg/result_analyse/SignResultAnalyse.cpp
+++ b/src/gpg/result_analyse/SignResultAnalyse.cpp
@@ -28,83 +28,84 @@
GpgFrontend::SignResultAnalyse::SignResultAnalyse(GpgError error,
GpgSignResult result)
- : error(error), result(std::move(result)) {}
+ : error_(error), result_(std::move(result)) {}
void GpgFrontend::SignResultAnalyse::do_analyse() {
LOG(INFO) << _("Start Sign Result Analyse");
- stream << "[#] " << _("Sign Operation") << " ";
+ stream_ << "[#] " << _("Sign Operation") << " ";
- if (gpgme_err_code(error) == GPG_ERR_NO_ERROR)
- stream << "[" << _("Success") << "]" << std::endl;
+ if (gpgme_err_code(error_) == GPG_ERR_NO_ERROR)
+ stream_ << "[" << _("Success") << "]" << std::endl;
else {
- stream << "[" << _("Failed") << "] " << gpgme_strerror(error) << std::endl;
- setStatus(-1);
+ stream_ << "[" << _("Failed") << "] " << gpgme_strerror(error_)
+ << std::endl;
+ set_status(-1);
}
- if (result != nullptr &&
- (result->signatures != nullptr || result->invalid_signers != nullptr)) {
+ if (result_ != nullptr &&
+ (result_->signatures != nullptr || result_->invalid_signers != nullptr)) {
LOG(INFO) << _("Sign Result Analyse Getting Result");
- stream << "------------>" << std::endl;
- auto new_sign = result->signatures;
+ stream_ << "------------>" << std::endl;
+ auto new_sign = result_->signatures;
while (new_sign != nullptr) {
- stream << "[>]" << _("New Signature") << ": " << std::endl;
+ stream_ << "[>]" << _("New Signature") << ": " << std::endl;
LOG(INFO) << _("Signers Fingerprint") << ": " << new_sign->fpr;
- stream << " " << _("Sign Mode") << ": ";
+ stream_ << " " << _("Sign Mode") << ": ";
if (new_sign->type == GPGME_SIG_MODE_NORMAL)
- stream << _("Normal");
+ stream_ << _("Normal");
else if (new_sign->type == GPGME_SIG_MODE_CLEAR)
- stream << _("Clear");
+ stream_ << _("Clear");
else if (new_sign->type == GPGME_SIG_MODE_DETACH)
- stream << _("Detach");
+ stream_ << _("Detach");
- stream << std::endl;
+ stream_ << std::endl;
auto singerKey =
GpgFrontend::GpgKeyGetter::GetInstance().GetKey(new_sign->fpr);
- if (singerKey.good()) {
- stream << " " << _("Signer") << ": "
- << singerKey.uids()->front().uid() << std::endl;
+ if (singerKey.IsGood()) {
+ stream_ << " " << _("Signer") << ": "
+ << singerKey.GetUIDs()->front().GetUID() << std::endl;
} else {
- stream << " " << _("Signer") << ": "
- << "<unknown>" << std::endl;
+ stream_ << " " << _("Signer") << ": "
+ << "<unknown>" << std::endl;
}
- stream << " " << _("Public Key Algo") << ": "
- << gpgme_pubkey_algo_name(new_sign->pubkey_algo) << std::endl;
- stream << " " << _("Hash Algo") << ": "
- << gpgme_hash_algo_name(new_sign->hash_algo) << std::endl;
- stream << " " << _("Date") << "(" << _("UTC") << ")"
- << ": "
- << boost::posix_time::to_iso_extended_string(
- boost::posix_time::from_time_t(new_sign->timestamp))
- << std::endl;
-
- stream << std::endl;
+ stream_ << " " << _("Public Key Algo") << ": "
+ << gpgme_pubkey_algo_name(new_sign->pubkey_algo) << std::endl;
+ stream_ << " " << _("Hash Algo") << ": "
+ << gpgme_hash_algo_name(new_sign->hash_algo) << std::endl;
+ stream_ << " " << _("Date") << "(" << _("UTC") << ")"
+ << ": "
+ << boost::posix_time::to_iso_extended_string(
+ boost::posix_time::from_time_t(new_sign->timestamp))
+ << std::endl;
+
+ stream_ << std::endl;
new_sign = new_sign->next;
}
LOG(INFO) << _("Sign Result Analyse Getting Invalid Signer");
- auto invalid_signer = result->invalid_signers;
+ auto invalid_signer = result_->invalid_signers;
if (invalid_signer != nullptr)
- stream << _("Invalid Signers") << ": " << std::endl;
+ stream_ << _("Invalid Signers") << ": " << std::endl;
while (invalid_signer != nullptr) {
- setStatus(0);
- stream << "[>] " << _("Signer") << ": " << std::endl;
- stream << " " << _("Fingerprint") << ": " << invalid_signer->fpr
- << std::endl;
- stream << " " << _("Reason") << ": "
- << gpgme_strerror(invalid_signer->reason) << std::endl;
- stream << std::endl;
+ set_status(0);
+ stream_ << "[>] " << _("Signer") << ": " << std::endl;
+ stream_ << " " << _("Fingerprint") << ": " << invalid_signer->fpr
+ << std::endl;
+ stream_ << " " << _("Reason") << ": "
+ << gpgme_strerror(invalid_signer->reason) << std::endl;
+ stream_ << std::endl;
invalid_signer = invalid_signer->next;
}
- stream << "<------------" << std::endl;
+ stream_ << "<------------" << std::endl;
}
} \ No newline at end of file
diff --git a/src/gpg/result_analyse/SignResultAnalyse.h b/src/gpg/result_analyse/SignResultAnalyse.h
index 988ddf99..62f10d14 100644
--- a/src/gpg/result_analyse/SignResultAnalyse.h
+++ b/src/gpg/result_analyse/SignResultAnalyse.h
@@ -29,17 +29,31 @@
namespace GpgFrontend {
+/**
+ * @brief
+ *
+ */
class SignResultAnalyse : public ResultAnalyse {
public:
+ /**
+ * @brief Construct a new Sign Result Analyse object
+ *
+ * @param error
+ * @param result
+ */
explicit SignResultAnalyse(GpgError error, GpgSignResult result);
protected:
+ /**
+ * @brief
+ *
+ */
void do_analyse();
private:
- GpgError error;
+ GpgError error_; ///<
- GpgSignResult result;
+ GpgSignResult result_; ///<
};
} // namespace GpgFrontend
diff --git a/src/gpg/result_analyse/VerifyResultAnalyse.cpp b/src/gpg/result_analyse/VerifyResultAnalyse.cpp
index 99cbd528..c1c8d2be 100644
--- a/src/gpg/result_analyse/VerifyResultAnalyse.cpp
+++ b/src/gpg/result_analyse/VerifyResultAnalyse.cpp
@@ -32,136 +32,138 @@
GpgFrontend::VerifyResultAnalyse::VerifyResultAnalyse(GpgError error,
GpgVerifyResult result)
- : error(error), result(std::move(result)) {}
+ : error_(error), result_(std::move(result)) {}
void GpgFrontend::VerifyResultAnalyse::do_analyse() {
LOG(INFO) << _("started");
- stream << "[#] " << _("Verify Operation") << " ";
+ stream_ << "[#] " << _("Verify Operation") << " ";
- if (gpgme_err_code(error) == GPG_ERR_NO_ERROR)
- stream << "[" << _("Success") << "]" << std::endl;
+ if (gpgme_err_code(error_) == GPG_ERR_NO_ERROR)
+ stream_ << "[" << _("Success") << "]" << std::endl;
else {
- stream << "[" << _("Failed") << "] " << gpgme_strerror(error) << std::endl;
- setStatus(-1);
+ stream_ << "[" << _("Failed") << "] " << gpgme_strerror(error_)
+ << std::endl;
+ set_status(-1);
}
- if (result != nullptr && result->signatures != nullptr) {
- stream << "------------>" << std::endl;
- auto sign = result->signatures;
+ if (result_ != nullptr && result_->signatures != nullptr) {
+ stream_ << "------------>" << std::endl;
+ auto sign = result_->signatures;
- stream << "[>] " << _("Signed On") << "(" << _("UTC") << ")"
- << " "
- << boost::posix_time::to_iso_extended_string(
- boost::posix_time::from_time_t(sign->timestamp))
- << std::endl;
+ stream_ << "[>] " << _("Signed On") << "(" << _("UTC") << ")"
+ << " "
+ << boost::posix_time::to_iso_extended_string(
+ boost::posix_time::from_time_t(sign->timestamp))
+ << std::endl;
- stream << std::endl << "[>] " << _("Signatures List") << ":" << std::endl;
+ stream_ << std::endl << "[>] " << _("Signatures List") << ":" << std::endl;
bool canContinue = true;
int count = 1;
while (sign && canContinue) {
- stream << boost::format(_("Signature [%1%]:")) % count++ << std::endl;
+ stream_ << boost::format(_("Signature [%1%]:")) % count++ << std::endl;
switch (gpg_err_code(sign->status)) {
case GPG_ERR_BAD_SIGNATURE:
- stream << _("A Bad Signature.") << std::endl;
- print_signer(stream, sign);
- stream << _("This Signature is invalid.") << std::endl;
+ stream_ << _("A Bad Signature.") << std::endl;
+ print_signer(stream_, sign);
+ stream_ << _("This Signature is invalid.") << std::endl;
canContinue = false;
- setStatus(-1);
+ set_status(-1);
break;
case GPG_ERR_NO_ERROR:
- stream << _("A") << " ";
+ stream_ << _("A") << " ";
if (sign->summary & GPGME_SIGSUM_GREEN) {
- stream << _("Good") << " ";
+ stream_ << _("Good") << " ";
}
if (sign->summary & GPGME_SIGSUM_RED) {
- stream << _("Bad") << " ";
+ stream_ << _("Bad") << " ";
}
if (sign->summary & GPGME_SIGSUM_SIG_EXPIRED) {
- stream << _("Expired") << " ";
+ stream_ << _("Expired") << " ";
}
if (sign->summary & GPGME_SIGSUM_KEY_MISSING) {
- stream << _("Missing Key's") << " ";
+ stream_ << _("Missing Key's") << " ";
}
if (sign->summary & GPGME_SIGSUM_KEY_REVOKED) {
- stream << _("Revoked Key's") << " ";
+ stream_ << _("Revoked Key's") << " ";
}
if (sign->summary & GPGME_SIGSUM_KEY_EXPIRED) {
- stream << _("Expired Key's") << " ";
+ stream_ << _("Expired Key's") << " ";
}
if (sign->summary & GPGME_SIGSUM_CRL_MISSING) {
- stream << _("Missing CRL's") << " ";
+ stream_ << _("Missing CRL's") << " ";
}
if (sign->summary & GPGME_SIGSUM_VALID) {
- stream << _("Signature Fully Valid.") << std::endl;
+ stream_ << _("Signature Fully Valid.") << std::endl;
} else {
- stream << _("Signature Not Fully Valid.") << std::endl;
+ stream_ << _("Signature Not Fully Valid.") << std::endl;
}
if (!(sign->status & GPGME_SIGSUM_KEY_MISSING)) {
- if (!print_signer(stream, sign)) setStatus(0);
+ if (!print_signer(stream_, sign)) set_status(0);
} else {
- stream << _("Key is NOT present with ID 0x") << sign->fpr
- << std::endl;
+ stream_ << _("Key is NOT present with ID 0x") << sign->fpr
+ << std::endl;
}
- setStatus(1);
+ set_status(1);
break;
case GPG_ERR_NO_PUBKEY:
- stream << _("A signature could NOT be verified due to a Missing Key")
- << std::endl;
- setStatus(-2);
+ stream_ << _("A signature could NOT be verified due to a Missing Key")
+ << std::endl;
+ set_status(-2);
break;
case GPG_ERR_CERT_REVOKED:
- stream << _("A signature is valid but the key used to verify the "
- "signature has been revoked")
- << std::endl;
- if (!print_signer(stream, sign)) {
- setStatus(0);
+ stream_ << _("A signature is valid but the key used to verify the "
+ "signature has been revoked")
+ << std::endl;
+ if (!print_signer(stream_, sign)) {
+ set_status(0);
}
- setStatus(-1);
+ set_status(-1);
break;
case GPG_ERR_SIG_EXPIRED:
- stream << _("A signature is valid but expired") << std::endl;
- if (!print_signer(stream, sign)) {
- setStatus(0);
+ stream_ << _("A signature is valid but expired") << std::endl;
+ if (!print_signer(stream_, sign)) {
+ set_status(0);
}
- setStatus(-1);
+ set_status(-1);
break;
case GPG_ERR_KEY_EXPIRED:
- stream << _("A signature is valid but the key used to "
- "verify the signature has expired.")
- << std::endl;
- if (!print_signer(stream, sign)) {
- setStatus(0);
+ stream_ << _("A signature is valid but the key used to "
+ "verify the signature has expired.")
+ << std::endl;
+ if (!print_signer(stream_, sign)) {
+ set_status(0);
}
break;
case GPG_ERR_GENERAL:
- stream << _("There was some other error which prevented "
- "the signature verification.")
- << std::endl;
- status = -1;
+ stream_ << _("There was some other error which prevented "
+ "the signature verification.")
+ << std::endl;
+ status_ = -1;
canContinue = false;
break;
default:
auto fpr = std::string(sign->fpr);
- stream << _("Error for key with fingerprint") << " "
- << GpgFrontend::beautify_fingerprint(fpr);
- setStatus(-1);
+ stream_ << _("Error for key with fingerprint") << " "
+ << GpgFrontend::beautify_fingerprint(fpr);
+ set_status(-1);
}
- stream << std::endl;
+ stream_ << std::endl;
sign = sign->next;
}
- stream << "<------------" << std::endl;
+ stream_ << "<------------" << std::endl;
} else {
- stream << "[>] "
- << _("Could not find information that can be used for verification.")
- << std::endl;
- setStatus(0);
+ stream_
+ << "[>] "
+ << _("Could not find information that can be used for verification.")
+ << std::endl;
+ set_status(0);
return;
}
}
@@ -171,14 +173,14 @@ bool GpgFrontend::VerifyResultAnalyse::print_signer(std::stringstream &stream,
bool keyFound = true;
auto key = GpgFrontend::GpgKeyGetter::GetInstance().GetKey(sign->fpr);
- if (!key.good()) {
+ if (!key.IsGood()) {
stream << " " << _("Signed By") << ": "
<< "<" << _("Unknown") << ">" << std::endl;
- setStatus(0);
+ set_status(0);
keyFound = false;
} else {
- stream << " " << _("Signed By") << ": " << key.uids()->front().uid()
- << std::endl;
+ stream << " " << _("Signed By") << ": "
+ << key.GetUIDs()->front().GetUID() << std::endl;
}
if (sign->pubkey_algo)
stream << " " << _("Public Key Algo") << ": "
@@ -197,12 +199,12 @@ bool GpgFrontend::VerifyResultAnalyse::print_signer(std::stringstream &stream,
}
gpgme_signature_t GpgFrontend::VerifyResultAnalyse::GetSignatures() const {
- if (result)
- return result->signatures;
+ if (result_)
+ return result_->signatures;
else
return nullptr;
}
GpgFrontend::GpgVerifyResult
GpgFrontend::VerifyResultAnalyse::TakeChargeOfResult() {
- return std::move(result);
+ return std::move(result_);
}
diff --git a/src/gpg/result_analyse/VerifyResultAnalyse.h b/src/gpg/result_analyse/VerifyResultAnalyse.h
index 8bf75f85..c58c6afc 100644
--- a/src/gpg/result_analyse/VerifyResultAnalyse.h
+++ b/src/gpg/result_analyse/VerifyResultAnalyse.h
@@ -29,23 +29,54 @@
#include "gpg/model/GpgKeySignature.h"
namespace GpgFrontend {
-
+/**
+ * @brief
+ *
+ */
class VerifyResultAnalyse : public ResultAnalyse {
public:
+ /**
+ * @brief Construct a new Verify Result Analyse object
+ *
+ * @param error
+ * @param result
+ */
explicit VerifyResultAnalyse(GpgError error, GpgVerifyResult result);
+ /**
+ * @brief Get the Signatures object
+ *
+ * @return gpgme_signature_t
+ */
gpgme_signature_t GetSignatures() const;
+ /**
+ * @brief
+ *
+ * @return GpgVerifyResult
+ */
GpgVerifyResult TakeChargeOfResult();
private:
+ /**
+ * @brief
+ *
+ */
void do_analyse();
private:
+ /**
+ * @brief
+ *
+ * @param stream
+ * @param sign
+ * @return true
+ * @return false
+ */
bool print_signer(std::stringstream &stream, gpgme_signature_t sign);
- GpgError error;
- GpgVerifyResult result;
+ GpgError error_; ///<
+ GpgVerifyResult result_; ///<
};
} // namespace GpgFrontend
diff --git a/src/ui/KeyImportDetailDialog.cpp b/src/ui/KeyImportDetailDialog.cpp
index c4a7f6e8..1a50c64c 100644
--- a/src/ui/KeyImportDetailDialog.cpp
+++ b/src/ui/KeyImportDetailDialog.cpp
@@ -142,11 +142,11 @@ void KeyImportDetailDialog::createKeysTable() {
for (const auto& imp_key : mResult.importedKeys) {
keysTable->setRowCount(row + 1);
GpgKey key = GpgKeyGetter::GetInstance().GetKey(imp_key.fpr);
- if (!key.good()) continue;
+ if (!key.IsGood()) continue;
keysTable->setItem(
- row, 0, new QTableWidgetItem(QString::fromStdString(key.name())));
+ row, 0, new QTableWidgetItem(QString::fromStdString(key.GetName())));
keysTable->setItem(
- row, 1, new QTableWidgetItem(QString::fromStdString(key.email())));
+ row, 1, new QTableWidgetItem(QString::fromStdString(key.GetEmail())));
keysTable->setItem(
row, 2, new QTableWidgetItem(getStatusString(imp_key.import_status)));
keysTable->setItem(
diff --git a/src/ui/KeyMgmt.cpp b/src/ui/KeyMgmt.cpp
index d6656ba3..2c23d1bf 100755
--- a/src/ui/KeyMgmt.cpp
+++ b/src/ui/KeyMgmt.cpp
@@ -47,8 +47,8 @@ KeyMgmt::KeyMgmt(QWidget* parent) : QMainWindow(parent) {
KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress |
KeyListColumn::Usage | KeyListColumn::Validity,
[](const GpgKey& key) -> bool {
- return !key.is_private_key() &&
- !(key.revoked() || key.disabled() || key.expired());
+ return !key.IsPrivateKey() &&
+ !(key.IsRevoked() || key.IsDisabled() || key.IsExpired());
});
key_list_->addListGroupTab(
@@ -56,8 +56,8 @@ KeyMgmt::KeyMgmt(QWidget* parent) : QMainWindow(parent) {
KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress |
KeyListColumn::Usage | KeyListColumn::Validity,
[](const GpgKey& key) -> bool {
- return key.is_private_key() &&
- !(key.revoked() || key.disabled() || key.expired());
+ return key.IsPrivateKey() &&
+ !(key.IsRevoked() || key.IsDisabled() || key.IsExpired());
});
key_list_->addListGroupTab(
@@ -65,21 +65,21 @@ KeyMgmt::KeyMgmt(QWidget* parent) : QMainWindow(parent) {
KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress |
KeyListColumn::Usage | KeyListColumn::Validity,
[](const GpgKey& key) -> bool {
- return !key.has_master_key() &&
- !(key.revoked() || key.disabled() || key.expired());
+ return !key.IsHasMasterKey() &&
+ !(key.IsRevoked() || key.IsDisabled() || key.IsExpired());
});
key_list_->addListGroupTab(
_("Revoked"), KeyListRow::SECRET_OR_PUBLIC_KEY,
KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress |
KeyListColumn::Usage | KeyListColumn::Validity,
- [](const GpgKey& key) -> bool { return key.revoked(); });
+ [](const GpgKey& key) -> bool { return key.IsRevoked(); });
key_list_->addListGroupTab(
_("Expired"), KeyListRow::SECRET_OR_PUBLIC_KEY,
KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress |
KeyListColumn::Usage | KeyListColumn::Validity,
- [](const GpgKey& key) -> bool { return key.expired(); });
+ [](const GpgKey& key) -> bool { return key.IsExpired(); });
setCentralWidget(key_list_);
key_list_->setDoubleClickedAction([this](const GpgKey& key, QWidget* parent) {
@@ -320,10 +320,10 @@ void KeyMgmt::deleteKeysWithWarning(KeyIdArgsListPtr key_ids) {
QString keynames;
for (const auto& key_id : *key_ids) {
auto key = GpgKeyGetter::GetInstance().GetKey(key_id);
- if (!key.good()) continue;
- keynames.append(QString::fromStdString(key.name()));
+ if (!key.IsGood()) continue;
+ keynames.append(QString::fromStdString(key.GetName()));
keynames.append("<i> &lt;");
- keynames.append(QString::fromStdString(key.email()));
+ keynames.append(QString::fromStdString(key.GetEmail()));
keynames.append("&gt; </i><br/>");
}
@@ -348,7 +348,7 @@ void KeyMgmt::slotShowKeyDetails() {
auto key = GpgKeyGetter::GetInstance().GetKey(keys_selected->front());
- if (!key.good()) {
+ if (!key.IsGood()) {
QMessageBox::critical(this, _("Error"), _("Key Not Found."));
return;
}
@@ -405,18 +405,18 @@ void KeyMgmt::slotGenerateSubKey() {
return;
}
const auto key = GpgKeyGetter::GetInstance().GetKey(keys_selected->front());
- if (!key.good()) {
+ if (!key.IsGood()) {
QMessageBox::critical(this, _("Error"), _("Key Not Found."));
return;
}
- if (!key.is_private_key()) {
+ if (!key.IsPrivateKey()) {
QMessageBox::critical(this, _("Invalid Operation"),
_("If a key pair does not have a private key then "
"it will not be able to generate sub-keys."));
return;
}
- auto dialog = new SubkeyGenerateDialog(key.id(), this);
+ auto dialog = new SubkeyGenerateDialog(key.GetId(), this);
dialog->show();
}
void KeyMgmt::slotSaveWindowState() {
@@ -494,12 +494,12 @@ void KeyMgmt::slotExportAsOpenSSHFormat() {
}
key = GpgKeyGetter::GetInstance().GetKey(keys_checked->front());
- if (!key.good()) {
+ if (!key.IsGood()) {
QMessageBox::critical(this, _("Error"), _("Key Not Found."));
return;
}
- QString fileString = QString::fromStdString(key.name() + " " + key.email() +
- "(" + key.id() + ").pub");
+ QString fileString = QString::fromStdString(
+ key.GetName() + " " + key.GetEmail() + "(" + key.GetId() + ").pub");
QString file_name = QFileDialog::getSaveFileName(
this, _("Export OpenSSH Key To File"), fileString,
diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp
index 967dcc32..1a343220 100644
--- a/src/ui/UserInterfaceUtils.cpp
+++ b/src/ui/UserInterfaceUtils.cpp
@@ -111,8 +111,8 @@ void refresh_info_board(InfoBoardWidget* info_board, int status,
void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board,
const ResultAnalyse& result_analyse) {
info_board->associateTabWidget(edit->tabWidget);
- refresh_info_board(info_board, result_analyse.getStatus(),
- result_analyse.getResultReport());
+ refresh_info_board(info_board, result_analyse.GetStatus(),
+ result_analyse.GetResultReport());
}
void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board,
@@ -124,8 +124,8 @@ void process_result_analyse(TextEdit* edit, InfoBoardWidget* info_board,
refresh_info_board(
info_board,
- std::min(result_analyse_a.getStatus(), result_analyse_b.getStatus()),
- result_analyse_a.getResultReport() + result_analyse_b.getResultReport());
+ std::min(result_analyse_a.GetStatus(), result_analyse_b.GetStatus()),
+ result_analyse_a.GetResultReport() + result_analyse_b.GetResultReport());
}
void process_operation(QWidget* parent, const std::string& waiting_title,
diff --git a/src/ui/keygen/KeygenDialog.cpp b/src/ui/keygen/KeygenDialog.cpp
index 2baa22f4..e4148da8 100644
--- a/src/ui/keygen/KeygenDialog.cpp
+++ b/src/ui/keygen/KeygenDialog.cpp
@@ -110,16 +110,16 @@ void KeyGenDialog::slotKeyGenAccept() {
/**
* create the string for key generation
*/
- gen_key_info_->setName(nameEdit->text().toStdString());
- gen_key_info_->setEmail(emailEdit->text().toStdString());
- gen_key_info_->setComment(commentEdit->text().toStdString());
+ gen_key_info_->SetName(nameEdit->text().toStdString());
+ gen_key_info_->SetEmail(emailEdit->text().toStdString());
+ gen_key_info_->SetComment(commentEdit->text().toStdString());
- gen_key_info_->setKeySize(keySizeSpinBox->value());
+ gen_key_info_->SetKeyLength(keySizeSpinBox->value());
if (expireCheckBox->checkState()) {
- gen_key_info_->setNonExpired(true);
+ gen_key_info_->SetNonExpired(true);
} else {
- gen_key_info_->setExpired(
+ gen_key_info_->SetExpireTime(
boost::posix_time::from_time_t(dateEdit->dateTime().toTime_t()));
}
@@ -211,95 +211,95 @@ QGroupBox* KeyGenDialog::create_key_usage_group_box() {
void KeyGenDialog::slotEncryptionBoxChanged(int state) {
if (state == 0) {
- gen_key_info_->setAllowEncryption(false);
+ gen_key_info_->SetAllowEncryption(false);
} else {
- gen_key_info_->setAllowEncryption(true);
+ gen_key_info_->SetAllowEncryption(true);
}
}
void KeyGenDialog::slotSigningBoxChanged(int state) {
if (state == 0) {
- gen_key_info_->setAllowSigning(false);
+ gen_key_info_->SetAllowSigning(false);
} else {
- gen_key_info_->setAllowSigning(true);
+ gen_key_info_->SetAllowSigning(true);
}
}
void KeyGenDialog::slotCertificationBoxChanged(int state) {
if (state == 0) {
- gen_key_info_->setAllowCertification(false);
+ gen_key_info_->SetAllowCertification(false);
} else {
- gen_key_info_->setAllowCertification(true);
+ gen_key_info_->SetAllowCertification(true);
}
}
void KeyGenDialog::slotAuthenticationBoxChanged(int state) {
if (state == 0) {
- gen_key_info_->setAllowAuthentication(false);
+ gen_key_info_->SetAllowAuthentication(false);
} else {
- gen_key_info_->setAllowAuthentication(true);
+ gen_key_info_->SetAllowAuthentication(true);
}
}
void KeyGenDialog::slotActivatedKeyType(int index) {
qDebug() << "key type index changed " << index;
- gen_key_info_->setAlgo(this->keyTypeComboBox->itemText(index).toStdString());
+ gen_key_info_->SetAlgo(this->keyTypeComboBox->itemText(index).toStdString());
refresh_widgets_state();
}
void KeyGenDialog::refresh_widgets_state() {
qDebug() << "refresh_widgets_state called";
- if (gen_key_info_->isAllowEncryption())
+ if (gen_key_info_->IsAllowEncryption())
key_usage_check_boxes_[0]->setCheckState(Qt::CheckState::Checked);
else
key_usage_check_boxes_[0]->setCheckState(Qt::CheckState::Unchecked);
- if (gen_key_info_->isAllowChangeEncryption())
+ if (gen_key_info_->IsAllowChangeEncryption())
key_usage_check_boxes_[0]->setDisabled(false);
else
key_usage_check_boxes_[0]->setDisabled(true);
- if (gen_key_info_->isAllowSigning())
+ if (gen_key_info_->IsAllowSigning())
key_usage_check_boxes_[1]->setCheckState(Qt::CheckState::Checked);
else
key_usage_check_boxes_[1]->setCheckState(Qt::CheckState::Unchecked);
- if (gen_key_info_->isAllowChangeSigning())
+ if (gen_key_info_->IsAllowChangeSigning())
key_usage_check_boxes_[1]->setDisabled(false);
else
key_usage_check_boxes_[1]->setDisabled(true);
- if (gen_key_info_->isAllowCertification())
+ if (gen_key_info_->IsAllowCertification())
key_usage_check_boxes_[2]->setCheckState(Qt::CheckState::Checked);
else
key_usage_check_boxes_[2]->setCheckState(Qt::CheckState::Unchecked);
- if (gen_key_info_->isAllowChangeCertification())
+ if (gen_key_info_->IsAllowChangeCertification())
key_usage_check_boxes_[2]->setDisabled(false);
else
key_usage_check_boxes_[2]->setDisabled(true);
- if (gen_key_info_->isAllowAuthentication())
+ if (gen_key_info_->IsAllowAuthentication())
key_usage_check_boxes_[3]->setCheckState(Qt::CheckState::Checked);
else
key_usage_check_boxes_[3]->setCheckState(Qt::CheckState::Unchecked);
- if (gen_key_info_->isAllowChangeAuthentication())
+ if (gen_key_info_->IsAllowChangeAuthentication())
key_usage_check_boxes_[3]->setDisabled(false);
else
key_usage_check_boxes_[3]->setDisabled(true);
- if (gen_key_info_->isAllowNoPassPhrase())
+ if (gen_key_info_->IsAllowNoPassPhrase())
noPassPhraseCheckBox->setDisabled(false);
else
noPassPhraseCheckBox->setDisabled(true);
- keySizeSpinBox->setRange(gen_key_info_->getSuggestMinKeySize(),
- gen_key_info_->getSuggestMaxKeySize());
- keySizeSpinBox->setValue(gen_key_info_->getKeySize());
- keySizeSpinBox->setSingleStep(gen_key_info_->getSizeChangeStep());
+ keySizeSpinBox->setRange(gen_key_info_->GetSuggestMinKeySize(),
+ gen_key_info_->GetSuggestMaxKeySize());
+ keySizeSpinBox->setValue(gen_key_info_->GetKeyLength());
+ keySizeSpinBox->setSingleStep(gen_key_info_->GetSizeChangeStep());
}
void KeyGenDialog::set_signal_slot() {
@@ -324,9 +324,9 @@ void KeyGenDialog::set_signal_slot() {
connect(noPassPhraseCheckBox, &QCheckBox::stateChanged, this,
[this](int state) -> void {
if (state == 0) {
- gen_key_info_->setNonPassPhrase(false);
+ gen_key_info_->SetNonPassPhrase(false);
} else {
- gen_key_info_->setNonPassPhrase(true);
+ gen_key_info_->SetNonPassPhrase(true);
}
});
}
@@ -343,10 +343,10 @@ QGroupBox* KeyGenDialog::create_basic_info_group_box() {
keySizeSpinBox = new QSpinBox(this);
keyTypeComboBox = new QComboBox(this);
- for (auto& algo : GenKeyInfo::getSupportedKeyAlgo()) {
+ for (auto& algo : GenKeyInfo::GetSupportedKeyAlgo()) {
keyTypeComboBox->addItem(QString::fromStdString(algo));
}
- if (!GenKeyInfo::getSupportedKeyAlgo().empty()) {
+ if (!GenKeyInfo::GetSupportedKeyAlgo().empty()) {
keyTypeComboBox->setCurrentIndex(0);
}
diff --git a/src/ui/keygen/SubkeyGenerateDialog.cpp b/src/ui/keygen/SubkeyGenerateDialog.cpp
index 70d3ee3c..f9801ed8 100644
--- a/src/ui/keygen/SubkeyGenerateDialog.cpp
+++ b/src/ui/keygen/SubkeyGenerateDialog.cpp
@@ -116,14 +116,13 @@ QGroupBox* SubkeyGenerateDialog::create_basic_info_group_box() {
keySizeSpinBox = new QSpinBox(this);
keyTypeComboBox = new QComboBox(this);
- for (auto& algo : GenKeyInfo::getSupportedKeyAlgo()) {
+ for (auto& algo : GenKeyInfo::GetSupportedKeyAlgo()) {
keyTypeComboBox->addItem(QString::fromStdString(algo));
}
- if (!GenKeyInfo::getSupportedKeyAlgo().empty()) {
+ if (!GenKeyInfo::GetSupportedKeyAlgo().empty()) {
keyTypeComboBox->setCurrentIndex(0);
}
-
dateEdit = new QDateTimeEdit(QDateTime::currentDateTime().addYears(2), this);
dateEdit->setMinimumDateTime(QDateTime::currentDateTime());
dateEdit->setMaximumDateTime(max_date_time_);
@@ -184,50 +183,50 @@ void SubkeyGenerateDialog::slotExpireBoxChanged() {
void SubkeyGenerateDialog::refresh_widgets_state() {
qDebug() << "refresh_widgets_state called";
- if (gen_key_info_->isAllowEncryption())
+ if (gen_key_info_->IsAllowEncryption())
key_usage_check_boxes_[0]->setCheckState(Qt::CheckState::Checked);
else
key_usage_check_boxes_[0]->setCheckState(Qt::CheckState::Unchecked);
- if (gen_key_info_->isAllowChangeEncryption())
+ if (gen_key_info_->IsAllowChangeEncryption())
key_usage_check_boxes_[0]->setDisabled(false);
else
key_usage_check_boxes_[0]->setDisabled(true);
- if (gen_key_info_->isAllowSigning())
+ if (gen_key_info_->IsAllowSigning())
key_usage_check_boxes_[1]->setCheckState(Qt::CheckState::Checked);
else
key_usage_check_boxes_[1]->setCheckState(Qt::CheckState::Unchecked);
- if (gen_key_info_->isAllowChangeSigning())
+ if (gen_key_info_->IsAllowChangeSigning())
key_usage_check_boxes_[1]->setDisabled(false);
else
key_usage_check_boxes_[1]->setDisabled(true);
- if (gen_key_info_->isAllowCertification())
+ if (gen_key_info_->IsAllowCertification())
key_usage_check_boxes_[2]->setCheckState(Qt::CheckState::Checked);
else
key_usage_check_boxes_[2]->setCheckState(Qt::CheckState::Unchecked);
- if (gen_key_info_->isAllowChangeCertification())
+ if (gen_key_info_->IsAllowChangeCertification())
key_usage_check_boxes_[2]->setDisabled(false);
else
key_usage_check_boxes_[2]->setDisabled(true);
- if (gen_key_info_->isAllowAuthentication())
+ if (gen_key_info_->IsAllowAuthentication())
key_usage_check_boxes_[3]->setCheckState(Qt::CheckState::Checked);
else
key_usage_check_boxes_[3]->setCheckState(Qt::CheckState::Unchecked);
- if (gen_key_info_->isAllowChangeAuthentication())
+ if (gen_key_info_->IsAllowChangeAuthentication())
key_usage_check_boxes_[3]->setDisabled(false);
else
key_usage_check_boxes_[3]->setDisabled(true);
- keySizeSpinBox->setRange(gen_key_info_->getSuggestMinKeySize(),
- gen_key_info_->getSuggestMaxKeySize());
- keySizeSpinBox->setValue(gen_key_info_->getKeySize());
- keySizeSpinBox->setSingleStep(gen_key_info_->getSizeChangeStep());
+ keySizeSpinBox->setRange(gen_key_info_->GetSuggestMinKeySize(),
+ gen_key_info_->GetSuggestMaxKeySize());
+ keySizeSpinBox->setValue(gen_key_info_->GetKeyLength());
+ keySizeSpinBox->setSingleStep(gen_key_info_->GetSizeChangeStep());
}
void SubkeyGenerateDialog::slotKeyGenAccept() {
@@ -244,12 +243,12 @@ void SubkeyGenerateDialog::slotKeyGenAccept() {
auto err_string = err_stream.str();
if (err_string.empty()) {
- gen_key_info_->setKeySize(keySizeSpinBox->value());
+ gen_key_info_->SetKeyLength(keySizeSpinBox->value());
if (expireCheckBox->checkState()) {
- gen_key_info_->setNonExpired(true);
+ gen_key_info_->SetNonExpired(true);
} else {
- gen_key_info_->setExpired(
+ gen_key_info_->SetExpireTime(
boost::posix_time::from_time_t(dateEdit->dateTime().toTime_t()));
}
@@ -298,39 +297,39 @@ void SubkeyGenerateDialog::slotKeyGenAccept() {
void SubkeyGenerateDialog::slotEncryptionBoxChanged(int state) {
if (state == 0) {
- gen_key_info_->setAllowEncryption(false);
+ gen_key_info_->SetAllowEncryption(false);
} else {
- gen_key_info_->setAllowEncryption(true);
+ gen_key_info_->SetAllowEncryption(true);
}
}
void SubkeyGenerateDialog::slotSigningBoxChanged(int state) {
if (state == 0) {
- gen_key_info_->setAllowSigning(false);
+ gen_key_info_->SetAllowSigning(false);
} else {
- gen_key_info_->setAllowSigning(true);
+ gen_key_info_->SetAllowSigning(true);
}
}
void SubkeyGenerateDialog::slotCertificationBoxChanged(int state) {
if (state == 0) {
- gen_key_info_->setAllowCertification(false);
+ gen_key_info_->SetAllowCertification(false);
} else {
- gen_key_info_->setAllowCertification(true);
+ gen_key_info_->SetAllowCertification(true);
}
}
void SubkeyGenerateDialog::slotAuthenticationBoxChanged(int state) {
if (state == 0) {
- gen_key_info_->setAllowAuthentication(false);
+ gen_key_info_->SetAllowAuthentication(false);
} else {
- gen_key_info_->setAllowAuthentication(true);
+ gen_key_info_->SetAllowAuthentication(true);
}
}
void SubkeyGenerateDialog::slotActivatedKeyType(int index) {
qDebug() << "key type index changed " << index;
- gen_key_info_->setAlgo(this->keyTypeComboBox->itemText(index).toStdString());
+ gen_key_info_->SetAlgo(this->keyTypeComboBox->itemText(index).toStdString());
refresh_widgets_state();
}
diff --git a/src/ui/keypair_details/KeyDetailsDialog.cpp b/src/ui/keypair_details/KeyDetailsDialog.cpp
index 83be8af0..4b4c0dba 100644
--- a/src/ui/keypair_details/KeyDetailsDialog.cpp
+++ b/src/ui/keypair_details/KeyDetailsDialog.cpp
@@ -33,10 +33,11 @@ namespace GpgFrontend::UI {
KeyDetailsDialog::KeyDetailsDialog(const GpgKey& key, QWidget* parent)
: QDialog(parent) {
tabWidget = new QTabWidget();
- tabWidget->addTab(new KeyPairDetailTab(key.id(), tabWidget), _("KeyPair"));
- tabWidget->addTab(new KeyPairUIDTab(key.id(), tabWidget), _("UIDs"));
- tabWidget->addTab(new KeyPairSubkeyTab(key.id(), tabWidget), _("Subkeys"));
- tabWidget->addTab(new KeyPairOperaTab(key.id(), tabWidget), _("Operations"));
+ tabWidget->addTab(new KeyPairDetailTab(key.GetId(), tabWidget), _("KeyPair"));
+ tabWidget->addTab(new KeyPairUIDTab(key.GetId(), tabWidget), _("UIDs"));
+ tabWidget->addTab(new KeyPairSubkeyTab(key.GetId(), tabWidget), _("Subkeys"));
+ tabWidget->addTab(new KeyPairOperaTab(key.GetId(), tabWidget),
+ _("Operations"));
auto* mainLayout = new QVBoxLayout;
mainLayout->addWidget(tabWidget);
diff --git a/src/ui/keypair_details/KeyPairDetailTab.cpp b/src/ui/keypair_details/KeyPairDetailTab.cpp
index 49593d01..ed71be0f 100644
--- a/src/ui/keypair_details/KeyPairDetailTab.cpp
+++ b/src/ui/keypair_details/KeyPairDetailTab.cpp
@@ -32,8 +32,8 @@
namespace GpgFrontend::UI {
KeyPairDetailTab::KeyPairDetailTab(const std::string& key_id, QWidget* parent)
: QWidget(parent), key_(GpgKeyGetter::GetInstance().GetKey(key_id)) {
-
- LOG(INFO) << key_.email() <<key_.is_private_key() << key_.has_master_key() << key_.subKeys()->front().is_private_key();
+ LOG(INFO) << key_.GetEmail() << key_.IsPrivateKey() << key_.IsHasMasterKey()
+ << key_.GetSubKeys()->front().IsPrivateKey();
ownerBox = new QGroupBox(_("Owner"));
keyBox = new QGroupBox(_("Primary Key"));
@@ -166,9 +166,9 @@ void KeyPairDetailTab::slotCopyFingerprint() {
void KeyPairDetailTab::slotRefreshKeyInfo() {
// Show the situation that primary key not exists.
- masterKeyExistVarLabel->setText(key_.has_master_key() ? _("Exists")
+ masterKeyExistVarLabel->setText(key_.IsHasMasterKey() ? _("Exists")
: _("Not Exists"));
- if (!key_.has_master_key()) {
+ if (!key_.IsHasMasterKey()) {
auto palette_expired = masterKeyExistVarLabel->palette();
palette_expired.setColor(masterKeyExistVarLabel->foregroundRole(), Qt::red);
masterKeyExistVarLabel->setPalette(palette_expired);
@@ -179,7 +179,7 @@ void KeyPairDetailTab::slotRefreshKeyInfo() {
masterKeyExistVarLabel->setPalette(palette_valid);
}
- if (key_.expired()) {
+ if (key_.IsExpired()) {
auto paletteExpired = expireVarLabel->palette();
paletteExpired.setColor(expireVarLabel->foregroundRole(), Qt::red);
expireVarLabel->setPalette(paletteExpired);
@@ -189,67 +189,73 @@ void KeyPairDetailTab::slotRefreshKeyInfo() {
expireVarLabel->setPalette(paletteValid);
}
- nameVarLabel->setText(QString::fromStdString(key_.name()));
- emailVarLabel->setText(QString::fromStdString(key_.email()));
+ nameVarLabel->setText(QString::fromStdString(key_.GetName()));
+ emailVarLabel->setText(QString::fromStdString(key_.GetEmail()));
- commentVarLabel->setText(QString::fromStdString(key_.comment()));
- keyidVarLabel->setText(QString::fromStdString(key_.id()));
+ commentVarLabel->setText(QString::fromStdString(key_.GetComment()));
+ keyidVarLabel->setText(QString::fromStdString(key_.GetId()));
std::stringstream usage_steam;
- if (key_.can_certify()) usage_steam << _("Certificate") << " ";
- if (key_.can_encrypt()) usage_steam << _("Encrypt") << " ";
- if (key_.can_sign()) usage_steam << _("Sign") << " ";
- if (key_.can_authenticate()) usage_steam << _("Auth") << " ";
+ if (key_.IsHasCertificationCapability())
+ usage_steam << _("Certificate") << " ";
+ if (key_.IsHasEncryptionCapability()) usage_steam << _("Encrypt") << " ";
+ if (key_.IsHasSigningCapability()) usage_steam << _("Sign") << " ";
+ if (key_.IsHasAuthenticationCapability()) usage_steam << _("Auth") << " ";
usageVarLabel->setText(usage_steam.str().c_str());
std::stringstream actual_usage_steam;
- if (key_.CanCertActual()) actual_usage_steam << _("Certificate") << " ";
- if (key_.CanEncrActual()) actual_usage_steam << _("Encrypt") << " ";
- if (key_.CanSignActual()) actual_usage_steam << _("Sign") << " ";
- if (key_.CanAuthActual()) actual_usage_steam << _("Auth") << " ";
+ if (key_.IsHasActualCertificationCapability())
+ actual_usage_steam << _("Certificate") << " ";
+ if (key_.IsHasActualEncryptionCapability())
+ actual_usage_steam << _("Encrypt") << " ";
+ if (key_.IsHasActualSigningCapability())
+ actual_usage_steam << _("Sign") << " ";
+ if (key_.IsHasActualAuthenticationCapability())
+ actual_usage_steam << _("Auth") << " ";
actualUsageVarLabel->setText(actual_usage_steam.str().c_str());
std::string key_size_val, key_expire_val, key_create_time_val, key_algo_val,
key_last_update_val;
- key_size_val = std::to_string(key_.length());
+ key_size_val = std::to_string(key_.GetPrimaryKeyLength());
- if (to_time_t(boost::posix_time::ptime(key_.expires())) == 0) {
+ if (to_time_t(boost::posix_time::ptime(key_.GetExpireTime())) == 0) {
expireVarLabel->setText(_("Never Expire"));
} else {
expireVarLabel->setText(QLocale::system().toString(
- QDateTime::fromTime_t(to_time_t(key_.expires()))));
+ QDateTime::fromTime_t(to_time_t(key_.GetExpireTime()))));
}
- key_algo_val = key_.pubkey_algo();
+ key_algo_val = key_.GetPublicKeyAlgo();
createdVarLabel->setText(QLocale::system().toString(
- QDateTime::fromTime_t(to_time_t(key_.create_time()))));
+ QDateTime::fromTime_t(to_time_t(key_.GetCreateTime()))));
- if (to_time_t(boost::posix_time::ptime(key_.last_update())) == 0) {
+ if (to_time_t(boost::posix_time::ptime(key_.GetLastUpdateTime())) == 0) {
lastUpdateVarLabel->setText(_("No Data"));
} else {
lastUpdateVarLabel->setText(QLocale::system().toString(
- QDateTime::fromTime_t(to_time_t(key_.last_update()))));
+ QDateTime::fromTime_t(to_time_t(key_.GetLastUpdateTime()))));
}
keySizeVarLabel->setText(key_size_val.c_str());
algorithmVarLabel->setText(key_algo_val.c_str());
- fingerPrintVarLabel->setText(beautify_fingerprint(key_.fpr()).c_str());
+ fingerPrintVarLabel->setText(
+ beautify_fingerprint(key_.GetFingerprint()).c_str());
iconLabel->hide();
expLabel->hide();
- if (key_.expired()) {
+ if (key_.IsExpired()) {
iconLabel->show();
expLabel->show();
expLabel->setText(_("Warning: The primary key has expired."));
}
- if (key_.revoked()) {
+ if (key_.IsRevoked()) {
iconLabel->show();
expLabel->show();
expLabel->setText(_("Warning: The primary key has been revoked."));
@@ -258,7 +264,7 @@ void KeyPairDetailTab::slotRefreshKeyInfo() {
void KeyPairDetailTab::slotRefreshKey() {
LOG(INFO) << _("Called");
- this->key_ = GpgKeyGetter::GetInstance().GetKey(key_.id());
+ this->key_ = GpgKeyGetter::GetInstance().GetKey(key_.GetId());
this->slotRefreshKeyInfo();
}
diff --git a/src/ui/keypair_details/KeyPairOperaTab.cpp b/src/ui/keypair_details/KeyPairOperaTab.cpp
index 0ee61593..d5fdec0e 100644
--- a/src/ui/keypair_details/KeyPairOperaTab.cpp
+++ b/src/ui/keypair_details/KeyPairOperaTab.cpp
@@ -50,13 +50,13 @@ KeyPairOperaTab::KeyPairOperaTab(const std::string& key_id, QWidget* parent)
connect(export_public_button, SIGNAL(clicked()), this,
SLOT(slotExportPublicKey()));
- if (m_key_.is_private_key()) {
+ if (m_key_.IsPrivateKey()) {
auto* export_private_button = new QPushButton(_("Export Private Key"));
export_private_button->setStyleSheet("text-align:center;");
export_private_button->setMenu(secretKeyExportOperaMenu);
export_h_box_layout->addWidget(export_private_button);
- if (m_key_.has_master_key()) {
+ if (m_key_.IsHasMasterKey()) {
auto* edit_expires_button =
new QPushButton(_("Modify Expiration Datetime (Primary Key)"));
connect(edit_expires_button, SIGNAL(clicked()), this,
@@ -77,7 +77,7 @@ KeyPairOperaTab::KeyPairOperaTab(const std::string& key_id, QWidget* parent)
key_server_opera_button->setMenu(keyServerOperaMenu);
advance_h_box_layout->addWidget(key_server_opera_button);
- if (m_key_.is_private_key() && m_key_.has_master_key()) {
+ if (m_key_.IsPrivateKey() && m_key_.IsHasMasterKey()) {
auto* revoke_cert_gen_button =
new QPushButton(_("Generate Revoke Certificate"));
connect(revoke_cert_gen_button, SIGNAL(clicked()), this,
@@ -104,7 +104,7 @@ void KeyPairOperaTab::createOperaMenu() {
auto* uploadKeyPair = new QAction(_("Upload Key Pair to Key Server"), this);
connect(uploadKeyPair, SIGNAL(triggered()), this,
SLOT(slotUploadKeyToServer()));
- if (!(m_key_.is_private_key() && m_key_.has_master_key()))
+ if (!(m_key_.IsPrivateKey() && m_key_.IsHasMasterKey()))
uploadKeyPair->setDisabled(true);
auto* updateKeyPair = new QAction(_("Sync Key Pair From Key Server"), this);
@@ -112,7 +112,7 @@ void KeyPairOperaTab::createOperaMenu() {
SLOT(slotUpdateKeyFromServer()));
// when a key has primary key, it should always upload to keyserver.
- if (m_key_.has_master_key()) {
+ if (m_key_.IsHasMasterKey()) {
updateKeyPair->setDisabled(true);
}
@@ -124,7 +124,7 @@ void KeyPairOperaTab::createOperaMenu() {
auto* exportFullSecretKey = new QAction(_("Export Full Secret Key"), this);
connect(exportFullSecretKey, SIGNAL(triggered()), this,
SLOT(slotExportPrivateKey()));
- if (!m_key_.is_private_key()) exportFullSecretKey->setDisabled(true);
+ if (!m_key_.IsPrivateKey()) exportFullSecretKey->setDisabled(true);
auto* exportShortestSecretKey =
new QAction(_("Export Shortest Secret Key"), this);
@@ -143,8 +143,8 @@ void KeyPairOperaTab::slotExportPublicKey() {
_("An error occurred during the export operation."));
return;
}
- auto file_string =
- m_key_.name() + " " + m_key_.email() + "(" + m_key_.id() + ")_pub.asc";
+ auto file_string = m_key_.GetName() + " " + m_key_.GetEmail() + "(" +
+ m_key_.GetId() + ")_pub.asc";
auto file_name =
QFileDialog::getSaveFileName(
this, _("Export Key To File"), QString::fromStdString(file_string),
@@ -186,8 +186,8 @@ void KeyPairOperaTab::slotExportShortPrivateKey() {
_("An error occurred during the export operation."));
return;
}
- auto file_string = m_key_.name() + " " + m_key_.email() + "(" +
- m_key_.id() + ")_short_secret.asc";
+ auto file_string = m_key_.GetName() + " " + m_key_.GetEmail() + "(" +
+ m_key_.GetId() + ")_short_secret.asc";
auto file_name =
QFileDialog::getSaveFileName(
this, _("Export Key To File"), QString::fromStdString(file_string),
@@ -226,8 +226,8 @@ void KeyPairOperaTab::slotExportPrivateKey() {
_("An error occurred during the export operation."));
return;
}
- auto file_string = m_key_.name() + " " + m_key_.email() + "(" +
- m_key_.id() + ")_full_secret.asc";
+ auto file_string = m_key_.GetName() + " " + m_key_.GetEmail() + "(" +
+ m_key_.GetId() + ")_full_secret.asc";
auto file_name =
QFileDialog::getSaveFileName(
this, _("Export Key To File"), QString::fromStdString(file_string),
@@ -246,13 +246,13 @@ void KeyPairOperaTab::slotExportPrivateKey() {
}
void KeyPairOperaTab::slotModifyEditDatetime() {
- auto dialog = new KeySetExpireDateDialog(m_key_.id(), this);
+ auto dialog = new KeySetExpireDateDialog(m_key_.GetId(), this);
dialog->show();
}
void KeyPairOperaTab::slotUploadKeyToServer() {
auto keys = std::make_unique<KeyIdArgsList>();
- keys->push_back(m_key_.id());
+ keys->push_back(m_key_.GetId());
auto* dialog = new KeyUploadDialog(keys, this);
dialog->show();
dialog->slotUpload();
@@ -260,7 +260,7 @@ void KeyPairOperaTab::slotUploadKeyToServer() {
void KeyPairOperaTab::slotUpdateKeyFromServer() {
auto keys = std::make_unique<KeyIdArgsList>();
- keys->push_back(m_key_.id());
+ keys->push_back(m_key_.GetId());
auto* dialog = new KeyServerImportDialog(this);
dialog->show();
dialog->slotImport(keys);
@@ -280,7 +280,7 @@ void KeyPairOperaTab::slotGenRevokeCert() {
if (!m_output_file_name.isEmpty())
CommonUtils::GetInstance()->slotExecuteGpgCommand(
{"--command-fd", "0", "--status-fd", "1", "--no-tty", "-o",
- m_output_file_name, "--gen-revoke", m_key_.fpr().c_str()},
+ m_output_file_name, "--gen-revoke", m_key_.GetFingerprint().c_str()},
[](QProcess* proc) -> void {
// Code From Gpg4Win
while (proc->canReadLine()) {
diff --git a/src/ui/keypair_details/KeyPairSubkeyTab.cpp b/src/ui/keypair_details/KeyPairSubkeyTab.cpp
index a80eb5e4..4cbe9b1a 100644
--- a/src/ui/keypair_details/KeyPairSubkeyTab.cpp
+++ b/src/ui/keypair_details/KeyPairSubkeyTab.cpp
@@ -31,8 +31,8 @@ namespace GpgFrontend::UI {
KeyPairSubkeyTab::KeyPairSubkeyTab(const std::string& key_id, QWidget* parent)
: QWidget(parent), key_(GpgKeyGetter::GetInstance().GetKey(key_id)) {
-
- LOG(INFO) << key_.email() <<key_.is_private_key() << key_.has_master_key() << key_.subKeys()->front().is_private_key();
+ LOG(INFO) << key_.GetEmail() << key_.IsPrivateKey() << key_.IsHasMasterKey()
+ << key_.GetSubKeys()->front().IsPrivateKey();
createSubkeyList();
createSubkeyOperaMenu();
@@ -43,7 +43,7 @@ KeyPairSubkeyTab::KeyPairSubkeyTab(const std::string& key_id, QWidget* parent)
auto uidButtonsLayout = new QGridLayout();
auto addSubkeyButton = new QPushButton(_("Generate A New Subkey"));
- if (!key_.is_private_key() || !key_.has_master_key()) {
+ if (!key_.IsPrivateKey() || !key_.IsHasMasterKey()) {
addSubkeyButton->setDisabled(true);
setHidden(addSubkeyButton);
}
@@ -164,38 +164,38 @@ void KeyPairSubkeyTab::slotRefreshSubkeyList() {
subkeyList->setSelectionMode(QAbstractItemView::SingleSelection);
this->buffered_subkeys.clear();
- auto sub_keys = key_.subKeys();
+ auto sub_keys = key_.GetSubKeys();
for (auto& sub_key : *sub_keys) {
- if (sub_key.disabled() || sub_key.revoked()) continue;
+ if (sub_key.IsDisabled() || sub_key.IsRevoked()) continue;
this->buffered_subkeys.push_back(std::move(sub_key));
}
subkeyList->setRowCount(buffered_subkeys.size());
for (const auto& subkeys : buffered_subkeys) {
- auto* tmp0 = new QTableWidgetItem(QString::fromStdString(subkeys.id()));
+ auto* tmp0 = new QTableWidgetItem(QString::fromStdString(subkeys.GetID()));
tmp0->setTextAlignment(Qt::AlignCenter);
subkeyList->setItem(row, 0, tmp0);
- auto* tmp1 = new QTableWidgetItem(QString::number(subkeys.length()));
+ auto* tmp1 = new QTableWidgetItem(QString::number(subkeys.GetKeyLength()));
tmp1->setTextAlignment(Qt::AlignCenter);
subkeyList->setItem(row, 1, tmp1);
auto* tmp2 =
- new QTableWidgetItem(QString::fromStdString(subkeys.pubkey_algo()));
+ new QTableWidgetItem(QString::fromStdString(subkeys.GetPubkeyAlgo()));
tmp2->setTextAlignment(Qt::AlignCenter);
subkeyList->setItem(row, 2, tmp2);
auto* tmp3 = new QTableWidgetItem(
- QString::fromStdString(to_iso_string(subkeys.timestamp())));
+ QString::fromStdString(to_iso_string(subkeys.GetCreateTime())));
tmp3->setTextAlignment(Qt::AlignCenter);
subkeyList->setItem(row, 3, tmp3);
auto* tmp4 = new QTableWidgetItem(
boost::posix_time::to_time_t(
- boost::posix_time::ptime(subkeys.expires())) == 0
+ boost::posix_time::ptime(subkeys.GetExpireTime())) == 0
? _("Never Expire")
- : QString::fromStdString(to_iso_string(subkeys.expires())));
+ : QString::fromStdString(to_iso_string(subkeys.GetExpireTime())));
tmp4->setTextAlignment(Qt::AlignCenter);
subkeyList->setItem(row, 4, tmp4);
@@ -214,25 +214,25 @@ void KeyPairSubkeyTab::slotRefreshSubkeyList() {
}
void KeyPairSubkeyTab::slotAddSubkey() {
- auto dialog = new SubkeyGenerateDialog(key_.id(), this);
+ auto dialog = new SubkeyGenerateDialog(key_.GetId(), this);
dialog->show();
}
void KeyPairSubkeyTab::slotRefreshSubkeyDetail() {
auto& subkey = getSelectedSubkey();
- keyidVarLabel->setText(QString::fromStdString(subkey.id()));
- keySizeVarLabel->setText(QString::number(subkey.length()));
+ keyidVarLabel->setText(QString::fromStdString(subkey.GetID()));
+ keySizeVarLabel->setText(QString::number(subkey.GetKeyLength()));
- time_t subkey_time_t =
- boost::posix_time::to_time_t(boost::posix_time::ptime(subkey.expires()));
+ time_t subkey_time_t = boost::posix_time::to_time_t(
+ boost::posix_time::ptime(subkey.GetExpireTime()));
expireVarLabel->setText(
subkey_time_t == 0 ? _("Never Expires")
: QLocale::system().toString(QDateTime::fromTime_t(
- to_time_t(subkey.expires()))));
+ to_time_t(subkey.GetExpireTime()))));
if (subkey_time_t != 0 &&
- subkey.expires() < boost::posix_time::second_clock::local_time()) {
+ subkey.GetExpireTime() < boost::posix_time::second_clock::local_time()) {
auto paletteExpired = expireVarLabel->palette();
paletteExpired.setColor(expireVarLabel->foregroundRole(), Qt::red);
expireVarLabel->setPalette(paletteExpired);
@@ -242,27 +242,28 @@ void KeyPairSubkeyTab::slotRefreshSubkeyDetail() {
expireVarLabel->setPalette(paletteValid);
}
- algorithmVarLabel->setText(QString::fromStdString(subkey.pubkey_algo()));
+ algorithmVarLabel->setText(QString::fromStdString(subkey.GetPubkeyAlgo()));
createdVarLabel->setText(QLocale::system().toString(
- QDateTime::fromTime_t(to_time_t(subkey.timestamp()))));
+ QDateTime::fromTime_t(to_time_t(subkey.GetCreateTime()))));
std::stringstream usage_steam;
- if (subkey.can_certify()) usage_steam << _("Certificate") << " ";
- if (subkey.can_encrypt()) usage_steam << _("Encrypt") << " ";
- if (subkey.can_sign()) usage_steam << _("Sign") << " ";
- if (subkey.can_authenticate()) usage_steam << _("Auth") << " ";
+ if (subkey.IsHasCertificationCapability())
+ usage_steam << _("Certificate") << " ";
+ if (subkey.IsHasEncryptionCapability()) usage_steam << _("Encrypt") << " ";
+ if (subkey.IsHasSigningCapability()) usage_steam << _("Sign") << " ";
+ if (subkey.IsHasAuthenticationCapability()) usage_steam << _("Auth") << " ";
usageVarLabel->setText(usage_steam.str().c_str());
// Show the situation that secret key not exists.
- masterKeyExistVarLabel->setText(subkey.secret() ? _("Exists")
- : _("Not Exists"));
+ masterKeyExistVarLabel->setText(subkey.IsSecretKey() ? _("Exists")
+ : _("Not Exists"));
// Show the situation if key in a smart card.
- cardKeyLabel->setText(subkey.is_cardkey() ? _("Yes") : _("No"));
+ cardKeyLabel->setText(subkey.IsCardKey() ? _("Yes") : _("No"));
- if (!subkey.secret()) {
+ if (!subkey.IsSecretKey()) {
auto palette_expired = masterKeyExistVarLabel->palette();
palette_expired.setColor(masterKeyExistVarLabel->foregroundRole(), Qt::red);
masterKeyExistVarLabel->setPalette(palette_expired);
@@ -273,7 +274,7 @@ void KeyPairSubkeyTab::slotRefreshSubkeyDetail() {
masterKeyExistVarLabel->setPalette(palette_valid);
}
- if (!subkey.is_cardkey()) {
+ if (!subkey.IsCardKey()) {
auto palette_expired = cardKeyLabel->palette();
palette_expired.setColor(cardKeyLabel->foregroundRole(), Qt::red);
cardKeyLabel->setPalette(palette_expired);
@@ -283,7 +284,7 @@ void KeyPairSubkeyTab::slotRefreshSubkeyDetail() {
cardKeyLabel->setPalette(palette_valid);
}
- fingerPrintVarLabel->setText(QString::fromStdString(subkey.fpr()));
+ fingerPrintVarLabel->setText(QString::fromStdString(subkey.GetFingerprint()));
}
void KeyPairSubkeyTab::createSubkeyOperaMenu() {
@@ -297,10 +298,10 @@ void KeyPairSubkeyTab::createSubkeyOperaMenu() {
}
void KeyPairSubkeyTab::slotEditSubkey() {
- LOG(INFO) << "Fpr" << getSelectedSubkey().fpr();
+ LOG(INFO) << "Fpr" << getSelectedSubkey().GetFingerprint();
- auto dialog =
- new KeySetExpireDateDialog(key_.id(), getSelectedSubkey().fpr(), this);
+ auto dialog = new KeySetExpireDateDialog(
+ key_.GetId(), getSelectedSubkey().GetFingerprint(), this);
dialog->show();
}
@@ -323,7 +324,7 @@ const GpgSubKey& KeyPairSubkeyTab::getSelectedSubkey() {
return buffered_subkeys[row];
}
void KeyPairSubkeyTab::slotRefreshKeyInfo() {
- key_ = GpgKeyGetter::GetInstance().GetKey(key_.id());
+ key_ = GpgKeyGetter::GetInstance().GetKey(key_.GetId());
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/keypair_details/KeyPairUIDTab.cpp b/src/ui/keypair_details/KeyPairUIDTab.cpp
index 961068e5..903b93f8 100644
--- a/src/ui/keypair_details/KeyPairUIDTab.cpp
+++ b/src/ui/keypair_details/KeyPairUIDTab.cpp
@@ -45,7 +45,7 @@ KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent)
auto addUIDButton = new QPushButton(_("New UID"));
auto manageUIDButton = new QPushButton(_("UID Management"));
- if (mKey.has_master_key()) {
+ if (mKey.IsHasMasterKey()) {
manageUIDButton->setMenu(manageSelectedUIDMenu);
} else {
manageUIDButton->setDisabled(true);
@@ -165,9 +165,9 @@ void KeyPairUIDTab::slotRefreshUIDList() {
this->buffered_uids.clear();
- auto uids = mKey.uids();
+ auto uids = mKey.GetUIDs();
for (auto& uid : *uids) {
- if (uid.invalid() || uid.revoked()) {
+ if (uid.GetInvalid() || uid.GetRevoked()) {
continue;
}
this->buffered_uids.push_back(std::move(uid));
@@ -176,13 +176,13 @@ void KeyPairUIDTab::slotRefreshUIDList() {
uidList->setRowCount(buffered_uids.size());
for (const auto& uid : buffered_uids) {
- auto* tmp0 = new QTableWidgetItem(QString::fromStdString(uid.name()));
+ auto* tmp0 = new QTableWidgetItem(QString::fromStdString(uid.GetUID()));
uidList->setItem(row, 1, tmp0);
- auto* tmp1 = new QTableWidgetItem(QString::fromStdString(uid.email()));
+ auto* tmp1 = new QTableWidgetItem(QString::fromStdString(uid.GetUID()));
uidList->setItem(row, 2, tmp1);
- auto* tmp2 = new QTableWidgetItem(QString::fromStdString(uid.comment()));
+ auto* tmp2 = new QTableWidgetItem(QString::fromStdString(uid.GetUID()));
uidList->setItem(row, 3, tmp2);
auto* tmp3 = new QTableWidgetItem(QString::number(row));
@@ -219,7 +219,7 @@ void KeyPairUIDTab::slotRefreshTOFUInfo() {
if (!uidList->item(uidRow++, 0)->isSelected()) {
continue;
}
- auto tofu_infos = uid.tofu_infos();
+ auto tofu_infos = uid.GetTofuInfos();
LOG(INFO) << "tofu info size" << tofu_infos->size();
if (tofu_infos->empty()) {
tofuTabs->hide();
@@ -243,9 +243,9 @@ void KeyPairUIDTab::slotRefreshSigList() {
}
buffered_signatures.clear();
- auto signatures = uid.signatures();
+ auto signatures = uid.GetSignatures();
for (auto& sig : *signatures) {
- if (sig.invalid() || sig.revoked()) {
+ if (sig.IsInvalid() || sig.IsRevoked()) {
continue;
}
buffered_signatures.push_back(std::move(sig));
@@ -254,33 +254,35 @@ void KeyPairUIDTab::slotRefreshSigList() {
sigList->setRowCount(buffered_signatures.size());
for (const auto& sig : buffered_signatures) {
- auto* tmp0 = new QTableWidgetItem(QString::fromStdString(sig.keyid()));
+ auto* tmp0 = new QTableWidgetItem(QString::fromStdString(sig.GetKeyID()));
sigList->setItem(sigRow, 0, tmp0);
- if (gpgme_err_code(sig.status()) == GPG_ERR_NO_PUBKEY) {
+ if (gpgme_err_code(sig.GetStatus()) == GPG_ERR_NO_PUBKEY) {
auto* tmp2 = new QTableWidgetItem("<Unknown>");
sigList->setItem(sigRow, 1, tmp2);
auto* tmp3 = new QTableWidgetItem("<Unknown>");
sigList->setItem(sigRow, 2, tmp3);
} else {
- auto* tmp2 = new QTableWidgetItem(QString::fromStdString(sig.name()));
+ auto* tmp2 =
+ new QTableWidgetItem(QString::fromStdString(sig.GetName()));
sigList->setItem(sigRow, 1, tmp2);
- auto* tmp3 = new QTableWidgetItem(QString::fromStdString(sig.email()));
+ auto* tmp3 =
+ new QTableWidgetItem(QString::fromStdString(sig.GetEmail()));
sigList->setItem(sigRow, 2, tmp3);
}
auto* tmp4 = new QTableWidgetItem(QLocale::system().toString(
- QDateTime::fromTime_t(to_time_t(sig.create_time()))));
+ QDateTime::fromTime_t(to_time_t(sig.GetCreateTime()))));
sigList->setItem(sigRow, 3, tmp4);
auto* tmp5 = new QTableWidgetItem(
boost::posix_time::to_time_t(
- boost::posix_time::ptime(sig.expire_time())) == 0
+ boost::posix_time::ptime(sig.GetExpireTime())) == 0
? _("Never Expires")
: QLocale::system().toString(
- QDateTime::fromTime_t(to_time_t(sig.expire_time()))));
+ QDateTime::fromTime_t(to_time_t(sig.GetExpireTime()))));
tmp5->setTextAlignment(Qt::AlignCenter);
sigList->setItem(sigRow, 4, tmp5);
@@ -310,7 +312,7 @@ UIDArgsListPtr KeyPairUIDTab::getUIDChecked() {
auto selected_uids = std::make_unique<UIDArgsList>();
for (int i = 0; i < uidList->rowCount(); i++) {
if (uidList->item(i, 0)->checkState() == Qt::Checked)
- selected_uids->push_back(buffered_uids[i].uid());
+ selected_uids->push_back(buffered_uids[i].GetUID());
}
return selected_uids;
}
@@ -323,14 +325,14 @@ void KeyPairUIDTab::createManageUIDMenu() {
auto* delUIDAct = new QAction(_("Delete Selected UID(s)"), this);
connect(delUIDAct, SIGNAL(triggered()), this, SLOT(slotDelUID()));
- if (mKey.has_master_key()) {
+ if (mKey.IsHasMasterKey()) {
manageSelectedUIDMenu->addAction(signUIDAct);
manageSelectedUIDMenu->addAction(delUIDAct);
}
}
void KeyPairUIDTab::slotAddUID() {
- auto keyNewUIDDialog = new KeyNewUIDDialog(mKey.id(), this);
+ auto keyNewUIDDialog = new KeyNewUIDDialog(mKey.GetId(), this);
connect(keyNewUIDDialog, SIGNAL(finished(int)), this,
SLOT(slotAddUIDResult(int)));
connect(keyNewUIDDialog, SIGNAL(finished(int)), keyNewUIDDialog,
@@ -425,7 +427,7 @@ UIDArgsListPtr KeyPairUIDTab::getUIDSelected() {
auto uids = std::make_unique<UIDArgsList>();
for (int i = 0; i < uidList->rowCount(); i++) {
if (uidList->item(i, 0)->isSelected()) {
- uids->push_back(buffered_uids[i].uid());
+ uids->push_back(buffered_uids[i].GetUID());
}
}
return uids;
@@ -436,7 +438,7 @@ SignIdArgsListPtr KeyPairUIDTab::getSignSelected() {
for (int i = 0; i < sigList->rowCount(); i++) {
if (sigList->item(i, 0)->isSelected()) {
auto& sign = buffered_signatures[i];
- signatures->push_back({sign.keyid(), sign.uid()});
+ signatures->push_back({sign.GetKeyID(), sign.GetUID()});
}
}
return signatures;
@@ -453,7 +455,7 @@ void KeyPairUIDTab::createUIDPopupMenu() {
auto* delUIDAct = new QAction(_("Delete UID"), this);
connect(delUIDAct, SIGNAL(triggered()), this, SLOT(slotDelUIDSingle()));
- if (mKey.has_master_key()) {
+ if (mKey.IsHasMasterKey()) {
uidPopupMenu->addAction(serPrimaryUIDAct);
uidPopupMenu->addAction(signUIDAct);
uidPopupMenu->addAction(delUIDAct);
@@ -539,7 +541,7 @@ void KeyPairUIDTab::slotDelSign() {
if (!GpgKeyGetter::GetInstance()
.GetKey(selected_signs->front().first)
- .good()) {
+ .IsGood()) {
QMessageBox::critical(
nullptr, _("Invalid Operation"),
_("To delete the signature, you need to have its corresponding public "
@@ -569,7 +571,7 @@ void KeyPairUIDTab::slotDelSign() {
}
}
void KeyPairUIDTab::slotRefreshKey() {
- this->mKey = GpgKeyGetter::GetInstance().GetKey(this->mKey.id());
+ this->mKey = GpgKeyGetter::GetInstance().GetKey(this->mKey.GetId());
this->slotRefreshUIDList();
this->slotRefreshTOFUInfo();
this->slotRefreshSigList();
diff --git a/src/ui/keypair_details/KeySetExpireDateDialog.cpp b/src/ui/keypair_details/KeySetExpireDateDialog.cpp
index 5b592cf6..ad5b1d61 100644
--- a/src/ui/keypair_details/KeySetExpireDateDialog.cpp
+++ b/src/ui/keypair_details/KeySetExpireDateDialog.cpp
@@ -60,9 +60,9 @@ void KeySetExpireDateDialog::slotConfirm() {
if (ui->noExpirationCheckBox->checkState() == Qt::Unchecked) {
expires = std::make_unique<boost::posix_time::ptime>(
boost::posix_time::from_time_t(datetime.toLocalTime().toTime_t()));
- LOG(INFO) << "keyid" << mKey.id() << mSubkey << *expires;
+ LOG(INFO) << "keyid" << mKey.GetId() << mSubkey << *expires;
} else {
- LOG(INFO) << "keyid" << mKey.id() << mSubkey << "Non Expired";
+ LOG(INFO) << "keyid" << mKey.GetId() << mSubkey << "Non Expired";
}
auto err = GpgKeyOpera::GetInstance().SetExpire(mKey, mSubkey, expires);
diff --git a/src/ui/keypair_details/KeyUIDSignDialog.cpp b/src/ui/keypair_details/KeyUIDSignDialog.cpp
index c872eb12..fff38383 100644
--- a/src/ui/keypair_details/KeyUIDSignDialog.cpp
+++ b/src/ui/keypair_details/KeyUIDSignDialog.cpp
@@ -33,14 +33,15 @@ namespace GpgFrontend::UI {
KeyUIDSignDialog::KeyUIDSignDialog(const GpgKey& key, UIDArgsListPtr uid,
QWidget* parent)
: QDialog(parent), mUids(std::move(uid)), mKey(key) {
- const auto key_id = mKey.id();
+ const auto key_id = mKey.GetId();
mKeyList = new KeyList(KeyMenuAbility::NONE, this);
mKeyList->addListGroupTab(_("Signers"), KeyListRow::ONLY_SECRET_KEY,
KeyListColumn::NAME | KeyListColumn::EmailAddress,
[key_id](const GpgKey& key) -> bool {
- if (key.disabled() || !key.can_certify() ||
- !key.has_master_key() || key.expired() ||
- key.revoked() || key_id == key.id())
+ if (key.IsDisabled() ||
+ !key.IsHasCertificationCapability() ||
+ !key.IsHasMasterKey() || key.IsExpired() ||
+ key.IsRevoked() || key_id == key.GetId())
return false;
else
return true;
diff --git a/src/ui/main_window/MainWindowFileSlotFunction.cpp b/src/ui/main_window/MainWindowFileSlotFunction.cpp
index 3f509f3c..adf762d8 100644
--- a/src/ui/main_window/MainWindowFileSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowFileSlotFunction.cpp
@@ -117,14 +117,14 @@ void MainWindow::slotFileEncrypt() {
// check key abilities
for (const auto& key : *p_keys) {
- bool key_can_encrypt = key.CanEncrActual();
+ bool key_can_encrypt = key.IsHasActualEncryptionCapability();
if (!key_can_encrypt) {
QMessageBox::critical(
nullptr, _("Invalid KeyPair"),
QString(_("The selected keypair cannot be used for encryption.")) +
"<br/><br/>" + _("For example the Following Key:") + " <br/>" +
- QString::fromStdString(key.uids()->front().uid()));
+ QString::fromStdString(key.GetUIDs()->front().GetUID()));
return;
}
}
@@ -142,7 +142,7 @@ void MainWindow::slotFileEncrypt() {
if (!if_error) {
auto resultAnalyse = EncryptResultAnalyse(error, std::move(result));
- resultAnalyse.analyse();
+ resultAnalyse.Analyse();
process_result_analyse(edit, infoBoard, resultAnalyse);
fileTreeView->update();
} else {
@@ -189,7 +189,7 @@ void MainWindow::slotFileDecrypt() {
if (!if_error) {
auto resultAnalyse = DecryptResultAnalyse(error, std::move(result));
- resultAnalyse.analyse();
+ resultAnalyse.Analyse();
process_result_analyse(edit, infoBoard, resultAnalyse);
fileTreeView->update();
@@ -217,13 +217,13 @@ void MainWindow::slotFileSign() {
}
for (const auto& key : *keys) {
- if (!key.CanSignActual()) {
+ if (!key.IsHasActualSigningCapability()) {
QMessageBox::information(
this, _("Invalid Operation"),
QString(_("The selected key contains a key that does not actually "
"have a sign usage.")) +
"<br/><br/>" + _("for example the Following Key:") + " <br/>" +
- QString::fromStdString(key.uids()->front().uid()));
+ QString::fromStdString(key.GetUIDs()->front().GetUID()));
return;
}
}
@@ -273,7 +273,7 @@ void MainWindow::slotFileSign() {
if (!if_error) {
auto resultAnalyse = SignResultAnalyse(error, std::move(result));
- resultAnalyse.analyse();
+ resultAnalyse.Analyse();
process_result_analyse(edit, infoBoard, resultAnalyse);
fileTreeView->update();
@@ -354,13 +354,13 @@ void MainWindow::slotFileVerify() {
if (!if_error) {
auto result_analyse = VerifyResultAnalyse(error, result);
- result_analyse.analyse();
+ result_analyse.Analyse();
process_result_analyse(edit, infoBoard, result_analyse);
- if (result_analyse.getStatus() == -2)
+ if (result_analyse.GetStatus() == -2)
import_unknown_key_from_keyserver(this, result_analyse);
- if (result_analyse.getStatus() >= 0)
+ if (result_analyse.GetStatus() >= 0)
show_verify_details(this, infoBoard, error, result);
fileTreeView->update();
@@ -390,14 +390,14 @@ void MainWindow::slotFileEncryptSign() {
// check key abilities
for (const auto& key : *p_keys) {
- bool key_can_encrypt = key.CanEncrActual();
+ bool key_can_encrypt = key.IsHasActualEncryptionCapability();
if (!key_can_encrypt) {
QMessageBox::critical(
nullptr, _("Invalid KeyPair"),
QString(_("The selected keypair cannot be used for encryption.")) +
"<br/><br/>" + _("For example the Following Key:") + " <br/>" +
- QString::fromStdString(key.uids()->front().uid()));
+ QString::fromStdString(key.GetUIDs()->front().GetUID()));
return;
}
}
@@ -456,8 +456,8 @@ void MainWindow::slotFileEncryptSign() {
if (!if_error) {
auto encrypt_result = EncryptResultAnalyse(error, std::move(encr_result));
auto sign_res = SignResultAnalyse(error, std::move(sign_result));
- encrypt_result.analyse();
- sign_res.analyse();
+ encrypt_result.Analyse();
+ sign_res.Analyse();
process_result_analyse(edit, infoBoard, encrypt_result, sign_res);
fileTreeView->update();
@@ -511,14 +511,14 @@ void MainWindow::slotFileDecryptVerify() {
if (!if_error) {
auto decrypt_res = DecryptResultAnalyse(error, std::move(d_result));
auto verify_res = VerifyResultAnalyse(error, v_result);
- decrypt_res.analyse();
- verify_res.analyse();
+ decrypt_res.Analyse();
+ verify_res.Analyse();
process_result_analyse(edit, infoBoard, decrypt_res, verify_res);
- if (verify_res.getStatus() == -2)
+ if (verify_res.GetStatus() == -2)
import_unknown_key_from_keyserver(this, verify_res);
- if (verify_res.getStatus() >= 0)
+ if (verify_res.GetStatus() >= 0)
show_verify_details(this, infoBoard, error, v_result);
fileTreeView->update();
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp
index 593fe6fe..fe0408e0 100644
--- a/src/ui/main_window/MainWindowSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowSlotFunction.cpp
@@ -81,14 +81,14 @@ void MainWindow::slotEncrypt() {
auto key_getter = GpgFrontend::GpgKeyGetter::GetInstance();
auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids);
for (const auto& key : *keys) {
- if (!key.CanEncrActual()) {
+ if (!key.IsHasActualEncryptionCapability()) {
QMessageBox::information(
this, _("Invalid Operation"),
QString(_(
"The selected key contains a key that does not actually have a "
"encrypt usage.")) +
"<br/><br/>" + _("For example the Following Key:") + " <br/>" +
- QString::fromStdString(key.uids()->front().uid()));
+ QString::fromStdString(key.GetUIDs()->front().GetUID()));
return;
}
}
@@ -108,7 +108,7 @@ void MainWindow::slotEncrypt() {
if (!if_error) {
LOG(INFO) << "result" << result.get();
auto resultAnalyse = EncryptResultAnalyse(error, std::move(result));
- resultAnalyse.analyse();
+ resultAnalyse.Analyse();
process_result_analyse(edit, infoBoard, resultAnalyse);
if (check_gpg_error_2_err_code(error) == GPG_ERR_NO_ERROR)
@@ -140,14 +140,14 @@ void MainWindow::slotSign() {
auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids);
for (const auto& key : *keys) {
- if (!key.CanSignActual()) {
+ if (!key.IsHasActualSigningCapability()) {
QMessageBox::information(
this, _("Invalid Operation"),
QString(
_("The selected key contains a key that does not actually have a "
"signature usage.")) +
"<br/><br/>" + _("For example the Following Key:") + "<br/>" +
- key.uids()->front().uid().c_str());
+ key.GetUIDs()->front().GetUID().c_str());
return;
}
}
@@ -174,7 +174,7 @@ void MainWindow::slotSign() {
if (!if_error) {
auto resultAnalyse = SignResultAnalyse(error, std::move(result));
- resultAnalyse.analyse();
+ resultAnalyse.Analyse();
process_result_analyse(edit, infoBoard, resultAnalyse);
if (check_gpg_error_2_err_code(error) == GPG_ERR_NO_ERROR)
@@ -214,7 +214,7 @@ void MainWindow::slotDecrypt() {
if (!if_error) {
auto resultAnalyse = DecryptResultAnalyse(error, std::move(result));
- resultAnalyse.analyse();
+ resultAnalyse.Analyse();
process_result_analyse(edit, infoBoard, resultAnalyse);
if (check_gpg_error_2_err_code(error) == GPG_ERR_NO_ERROR)
@@ -262,13 +262,13 @@ void MainWindow::slotVerify() {
if (!if_error) {
auto result_analyse = VerifyResultAnalyse(error, result);
- result_analyse.analyse();
+ result_analyse.Analyse();
process_result_analyse(edit, infoBoard, result_analyse);
- if (result_analyse.getStatus() == -2)
+ if (result_analyse.GetStatus() == -2)
import_unknown_key_from_keyserver(this, result_analyse);
- if (result_analyse.getStatus() >= 0)
+ if (result_analyse.GetStatus() >= 0)
show_verify_details(this, infoBoard, error, result);
}
}
@@ -288,14 +288,14 @@ void MainWindow::slotEncryptSign() {
auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids);
for (const auto& key : *keys) {
- bool key_can_encrypt = key.CanEncrActual();
+ bool key_can_encrypt = key.IsHasActualEncryptionCapability();
if (!key_can_encrypt) {
QMessageBox::critical(
this, _("Invalid KeyPair"),
QString(_("The selected keypair cannot be used for encryption.")) +
"<br/><br/>" + _("For example the Following Key:") + " <br/>" +
- QString::fromStdString(key.uids()->front().uid()));
+ QString::fromStdString(key.GetUIDs()->front().GetUID()));
return;
}
}
@@ -309,11 +309,11 @@ void MainWindow::slotEncryptSign() {
auto signer_keys = GpgKeyGetter::GetInstance().GetKeys(signer_key_ids);
for (const auto& key : *keys) {
- LOG(INFO) << "Keys " << key.email();
+ LOG(INFO) << "Keys " << key.GetEmail();
}
for (const auto& signer : *signer_keys) {
- LOG(INFO) << "Signers " << signer.email();
+ LOG(INFO) << "Signers " << signer.GetEmail();
}
GpgEncrResult encr_result = nullptr;
@@ -354,8 +354,8 @@ void MainWindow::slotEncryptSign() {
LOG(INFO) << "ResultAnalyse Started";
auto encrypt_res = EncryptResultAnalyse(error, std::move(encr_result));
auto sign_res = SignResultAnalyse(error, std::move(sign_result));
- encrypt_res.analyse();
- sign_res.analyse();
+ encrypt_res.Analyse();
+ sign_res.Analyse();
process_result_analyse(edit, infoBoard, encrypt_res, sign_res);
if (check_gpg_error_2_err_code(error) == GPG_ERR_NO_ERROR)
edit->slotFillTextEditWithText(QString::fromStdString(*tmp));
@@ -434,16 +434,16 @@ void MainWindow::slotDecryptVerify() {
if (!if_error) {
auto decrypt_res = DecryptResultAnalyse(error, std::move(d_result));
auto verify_res = VerifyResultAnalyse(error, v_result);
- decrypt_res.analyse();
- verify_res.analyse();
+ decrypt_res.Analyse();
+ verify_res.Analyse();
process_result_analyse(edit, infoBoard, decrypt_res, verify_res);
if (check_gpg_error_2_err_code(error) == GPG_ERR_NO_ERROR)
edit->slotFillTextEditWithText(QString::fromStdString(*decrypted));
- if (verify_res.getStatus() == -2)
+ if (verify_res.GetStatus() == -2)
import_unknown_key_from_keyserver(this, verify_res);
- if (verify_res.getStatus() >= 0)
+ if (verify_res.GetStatus() >= 0)
show_verify_details(this, infoBoard, error, v_result);
} else {
@@ -474,12 +474,12 @@ void MainWindow::slotCopyMailAddressToClipboard() {
if (key_ids->empty()) return;
auto key = GpgKeyGetter::GetInstance().GetKey(key_ids->front());
- if (!key.good()) {
+ if (!key.IsGood()) {
QMessageBox::critical(this, _("Error"), _("Key Not Found."));
return;
}
QClipboard* cb = QApplication::clipboard();
- cb->setText(QString::fromStdString(key.email()));
+ cb->setText(QString::fromStdString(key.GetEmail()));
}
void MainWindow::slotShowKeyDetails() {
@@ -487,7 +487,7 @@ void MainWindow::slotShowKeyDetails() {
if (key_ids->empty()) return;
auto key = GpgKeyGetter::GetInstance().GetKey(key_ids->front());
- if (key.good()) {
+ if (key.IsGood()) {
new KeyDetailsDialog(key, this);
} else {
QMessageBox::critical(this, _("Error"), _("Key Not Found."));
diff --git a/src/ui/main_window/MainWindowUI.cpp b/src/ui/main_window/MainWindowUI.cpp
index c1cd5749..3d1e45b8 100644
--- a/src/ui/main_window/MainWindowUI.cpp
+++ b/src/ui/main_window/MainWindowUI.cpp
@@ -479,7 +479,7 @@ void MainWindow::createDockWindows() {
KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress |
KeyListColumn::Usage | KeyListColumn::Validity,
[](const GpgKey& key) -> bool {
- return !(key.revoked() || key.disabled() || key.expired());
+ return !(key.IsRevoked() || key.IsDisabled() || key.IsExpired());
});
mKeyList->addListGroupTab(
@@ -487,8 +487,8 @@ void MainWindow::createDockWindows() {
KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress |
KeyListColumn::Usage | KeyListColumn::Validity,
[](const GpgKey& key) -> bool {
- return !key.is_private_key() &&
- !(key.revoked() || key.disabled() || key.expired());
+ return !key.IsPrivateKey() &&
+ !(key.IsRevoked() || key.IsDisabled() || key.IsExpired());
});
mKeyList->addListGroupTab(
@@ -496,8 +496,8 @@ void MainWindow::createDockWindows() {
KeyListColumn::TYPE | KeyListColumn::NAME | KeyListColumn::EmailAddress |
KeyListColumn::Usage | KeyListColumn::Validity,
[](const GpgKey& key) -> bool {
- return key.is_private_key() &&
- !(key.revoked() || key.disabled() || key.expired());
+ return key.IsPrivateKey() &&
+ !(key.IsRevoked() || key.IsDisabled() || key.IsExpired());
});
mKeyList->slotRefresh();
diff --git a/src/ui/smtp/RecipientsPicker.cpp b/src/ui/smtp/RecipientsPicker.cpp
index eaaa683a..47c9808b 100644
--- a/src/ui/smtp/RecipientsPicker.cpp
+++ b/src/ui/smtp/RecipientsPicker.cpp
@@ -38,7 +38,7 @@ GpgFrontend::UI::RecipientsPicker::RecipientsPicker(
_("Recipient(s)"), KeyListRow::SECRET_OR_PUBLIC_KEY,
KeyListColumn::NAME | KeyListColumn::EmailAddress,
[](const GpgKey& key) -> bool {
- return !key.is_private_key() && key.CanEncrActual();
+ return !key.IsPrivateKey() && key.IsHasActualEncryptionCapability();
});
key_list_->slotRefresh();
diff --git a/src/ui/smtp/SendMailDialog.cpp b/src/ui/smtp/SendMailDialog.cpp
index badbed57..18c8beb1 100644
--- a/src/ui/smtp/SendMailDialog.cpp
+++ b/src/ui/smtp/SendMailDialog.cpp
@@ -64,8 +64,9 @@ SendMailDialog::SendMailDialog(const QString& text, QWidget* parent)
if (!default_sender_gpg_key_id.isEmpty()) {
auto key = GpgKeyGetter::GetInstance().GetKey(
default_sender_gpg_key_id.toStdString());
- if (key.good() && key.is_private_key() && key.CanSignActual()) {
- sender_key_id_ = key.id();
+ if (key.IsGood() && key.IsPrivateKey() &&
+ key.IsHasActualSigningCapability()) {
+ sender_key_id_ = key.GetId();
set_sender_value_label();
}
}
@@ -383,8 +384,8 @@ void SendMailDialog::initSettings() {
void SendMailDialog::set_sender_value_label() {
auto key = GpgKeyGetter::GetInstance().GetKey(sender_key_id_);
- if (key.good()) {
- ui->senderKeyValueLabel->setText(key.uids()->front().uid().c_str());
+ if (key.IsGood()) {
+ ui->senderKeyValueLabel->setText(key.GetUIDs()->front().GetUID().c_str());
}
}
@@ -392,8 +393,8 @@ void SendMailDialog::set_recipients_value_label() {
auto keys = GpgKeyGetter::GetInstance().GetKeys(recipients_key_ids_);
std::stringstream ss;
for (const auto& key : *keys) {
- if (key.good()) {
- ss << key.uids()->front().uid().c_str() << ";";
+ if (key.IsGood()) {
+ ss << key.GetUIDs()->front().GetUID().c_str() << ";";
}
}
ui->recipientsKeyValueLabel->setText(ss.str().c_str());
diff --git a/src/ui/smtp/SenderPicker.cpp b/src/ui/smtp/SenderPicker.cpp
index fcd3ba61..b2ad7f9f 100644
--- a/src/ui/smtp/SenderPicker.cpp
+++ b/src/ui/smtp/SenderPicker.cpp
@@ -34,10 +34,11 @@ GpgFrontend::UI::SenderPicker::SenderPicker(const KeyId& current_key_id,
// Setup KeyList
key_list_ = new KeyList(KeyMenuAbility::NONE, this);
- key_list_->addListGroupTab(
- _("Sender"), KeyListRow::ONLY_SECRET_KEY,
- KeyListColumn::NAME | KeyListColumn::EmailAddress,
- [](const GpgKey& key) -> bool { return key.CanSignActual(); });
+ key_list_->addListGroupTab(_("Sender"), KeyListRow::ONLY_SECRET_KEY,
+ KeyListColumn::NAME | KeyListColumn::EmailAddress,
+ [](const GpgKey& key) -> bool {
+ return key.IsHasActualSigningCapability();
+ });
key_list_->slotRefresh();
auto key_ids = std::make_unique<GpgFrontend::KeyIdArgsList>();
diff --git a/src/ui/widgets/ExportKeyPackageDialog.cpp b/src/ui/widgets/ExportKeyPackageDialog.cpp
index b82ceb32..04d576ad 100644
--- a/src/ui/widgets/ExportKeyPackageDialog.cpp
+++ b/src/ui/widgets/ExportKeyPackageDialog.cpp
@@ -80,10 +80,10 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog(
auto key_id_exported = std::make_unique<KeyIdArgsList>();
auto keys = GpgKeyGetter::GetInstance().GetKeys(key_ids_);
for (const auto& key : *keys) {
- if (ui->noPublicKeyCheckBox->isChecked() && !key.is_private_key()) {
+ if (ui->noPublicKeyCheckBox->isChecked() && !key.IsPrivateKey()) {
continue;
}
- key_id_exported->push_back(key.id());
+ key_id_exported->push_back(key.GetId());
}
ByteArrayPtr key_export_data = nullptr;
diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp
index 8b93a088..921195db 100644
--- a/src/ui/widgets/KeyList.cpp
+++ b/src/ui/widgets/KeyList.cpp
@@ -182,7 +182,7 @@ KeyIdArgsListPtr KeyList::getChecked(const KeyTable& key_table) {
auto ret = std::make_unique<KeyIdArgsList>();
for (int i = 0; i < key_table.key_list->rowCount(); i++) {
if (key_table.key_list->item(i, 0)->checkState() == Qt::Checked) {
- ret->push_back(key_table.buffered_keys[i].id());
+ ret->push_back(key_table.buffered_keys[i].GetId());
}
}
return ret;
@@ -195,7 +195,7 @@ KeyIdArgsListPtr KeyList::getChecked() {
auto ret = std::make_unique<KeyIdArgsList>();
for (int i = 0; i < key_list->rowCount(); i++) {
if (key_list->item(i, 0)->checkState() == Qt::Checked) {
- ret->push_back(buffered_keys[i].id());
+ ret->push_back(buffered_keys[i].GetId());
}
}
return ret;
@@ -207,8 +207,8 @@ KeyIdArgsListPtr KeyList::getAllPrivateKeys() {
mKeyTables[ui->keyGroupTab->currentIndex()].buffered_keys;
auto ret = std::make_unique<KeyIdArgsList>();
for (int i = 0; i < key_list->rowCount(); i++) {
- if (key_list->item(i, 1) && buffered_keys[i].is_private_key()) {
- ret->push_back(buffered_keys[i].id());
+ if (key_list->item(i, 1) && buffered_keys[i].IsPrivateKey()) {
+ ret->push_back(buffered_keys[i].GetId());
}
}
return ret;
@@ -225,7 +225,7 @@ KeyIdArgsListPtr KeyList::getPrivateChecked() {
for (int i = 0; i < key_list->rowCount(); i++) {
if ((key_list->item(i, 0)->checkState() == Qt::Checked) &&
(key_list->item(i, 1))) {
- ret->push_back(buffered_keys[i].id());
+ ret->push_back(buffered_keys[i].GetId());
}
}
return ret;
@@ -236,7 +236,7 @@ void KeyList::setChecked(const KeyIdArgsListPtr& keyIds,
if (!keyIds->empty()) {
for (int i = 0; i < key_table.key_list->rowCount(); i++) {
if (std::find(keyIds->begin(), keyIds->end(),
- key_table.buffered_keys[i].id()) != keyIds->end()) {
+ key_table.buffered_keys[i].GetId()) != keyIds->end()) {
key_table.key_list->item(i, 0)->setCheckState(Qt::Checked);
}
}
@@ -266,7 +266,7 @@ KeyIdArgsListPtr KeyList::getSelected() {
for (int i = 0; i < key_list->rowCount(); i++) {
if (key_list->item(i, 0)->isSelected() == 1) {
- ret->push_back(buffered_keys[i].id());
+ ret->push_back(buffered_keys[i].GetId());
}
}
return ret;
@@ -401,7 +401,7 @@ void KeyList::slotDoubleClicked(const QModelIndex& index) {
mKeyTables[ui->keyGroupTab->currentIndex()].buffered_keys;
if (mAction != nullptr) {
const auto key = GpgKeyGetter::GetInstance(_m_key_list_id)
- .GetKey(buffered_keys[index.row()].id());
+ .GetKey(buffered_keys[index.row()].GetId());
mAction(key, this);
}
}
@@ -418,7 +418,7 @@ std::string KeyList::getSelectedKey() {
for (int i = 0; i < mKeyList->rowCount(); i++) {
if (mKeyList->item(i, 0)->isSelected() == 1) {
- return buffered_keys[i].id();
+ return buffered_keys[i].GetId();
}
}
return {};
@@ -442,8 +442,8 @@ void KeyList::slotSyncWithKeyServer() {
{
std::lock_guard<std::mutex> guard(buffered_key_list_mutex);
for (const auto& key : *_buffered_keys_list) {
- if (!(key.is_private_key() && key.has_master_key()))
- key_ids.push_back(key.id());
+ if (!(key.IsPrivateKey() && key.IsHasMasterKey()))
+ key_ids.push_back(key.GetId());
}
}
@@ -461,7 +461,7 @@ void KeyList::slotSyncWithKeyServer() {
boost::format status_str = boost::format(_("Sync [%1%/%2%] %3% %4%")) %
current_index % all_index %
- key.uids()->front().uid() % status;
+ key.GetUIDs()->front().GetUID() % status;
emit signalRefreshStatusBar(status_str.str().c_str(), 1500);
if (current_index == all_index) {
@@ -505,7 +505,7 @@ KeyIdArgsListPtr& KeyTable::GetChecked() {
checked_key_ids_ = std::make_unique<KeyIdArgsList>();
auto& ret = checked_key_ids_;
for (int i = 0; i < key_list->rowCount(); i++) {
- auto key_id = buffered_keys[i].id();
+ auto key_id = buffered_keys[i].GetId();
if (key_list->item(i, 0)->checkState() == Qt::Checked &&
std::find(ret->begin(), ret->end(), key_id) == ret->end()) {
ret->push_back(key_id);
@@ -545,7 +545,7 @@ void KeyTable::Refresh(KeyLinkListPtr m_keys) {
continue;
}
}
- if (select_type == KeyListRow::ONLY_SECRET_KEY && !it->is_private_key()) {
+ if (select_type == KeyListRow::ONLY_SECRET_KEY && !it->IsPrivateKey()) {
it = keys->erase(it);
continue;
}
@@ -563,7 +563,7 @@ void KeyTable::Refresh(KeyLinkListPtr m_keys) {
table_buffered_keys.clear();
while (it != keys->end()) {
- table_buffered_keys.push_back(it->copy());
+ table_buffered_keys.push_back(it->Copy());
auto* tmp0 = new QTableWidgetItem(QString::number(row_index));
tmp0->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled |
@@ -574,51 +574,52 @@ void KeyTable::Refresh(KeyLinkListPtr m_keys) {
QString type_str;
QTextStream type_steam(&type_str);
- if (it->is_private_key()) {
+ if (it->IsPrivateKey()) {
type_steam << "pub/sec";
} else {
type_steam << "pub";
}
- if (it->is_private_key() && !it->has_master_key()) {
+ if (it->IsPrivateKey() && !it->IsHasMasterKey()) {
type_steam << "#";
}
- if (it->HasCardKey()) {
+ if (it->IsHasCardKey()) {
type_steam << "^";
}
auto* tmp1 = new QTableWidgetItem(type_str);
key_list->setItem(row_index, 1, tmp1);
- auto* tmp2 = new QTableWidgetItem(QString::fromStdString(it->name()));
+ auto* tmp2 = new QTableWidgetItem(QString::fromStdString(it->GetName()));
key_list->setItem(row_index, 2, tmp2);
- auto* tmp3 = new QTableWidgetItem(QString::fromStdString(it->email()));
+ auto* tmp3 = new QTableWidgetItem(QString::fromStdString(it->GetEmail()));
key_list->setItem(row_index, 3, tmp3);
QString usage;
QTextStream usage_steam(&usage);
- if (it->CanCertActual()) usage_steam << "C";
- if (it->CanEncrActual()) usage_steam << "E";
- if (it->CanSignActual()) usage_steam << "S";
- if (it->CanAuthActual()) usage_steam << "A";
+ if (it->IsHasActualCertificationCapability()) usage_steam << "C";
+ if (it->IsHasActualEncryptionCapability()) usage_steam << "E";
+ if (it->IsHasActualSigningCapability()) usage_steam << "S";
+ if (it->IsHasActualAuthenticationCapability()) usage_steam << "A";
auto* temp_usage = new QTableWidgetItem(usage);
temp_usage->setTextAlignment(Qt::AlignCenter);
key_list->setItem(row_index, 4, temp_usage);
auto* temp_validity =
- new QTableWidgetItem(QString::fromStdString(it->owner_trust()));
+ new QTableWidgetItem(QString::fromStdString(it->GetOwnerTrust()));
temp_validity->setTextAlignment(Qt::AlignCenter);
key_list->setItem(row_index, 5, temp_validity);
- auto* temp_fpr = new QTableWidgetItem(QString::fromStdString(it->fpr()));
+ auto* temp_fpr =
+ new QTableWidgetItem(QString::fromStdString(it->GetFingerprint()));
temp_fpr->setTextAlignment(Qt::AlignCenter);
key_list->setItem(row_index, 6, temp_fpr);
// strike out expired keys
- if (it->expired() || it->revoked()) {
+ if (it->IsExpired() || it->IsRevoked()) {
QFont strike = tmp2->font();
strike.setStrikeOut(true);
tmp0->setFont(strike);
@@ -636,7 +637,7 @@ void KeyTable::Refresh(KeyLinkListPtr m_keys) {
if (!checked_key_list->empty()) {
for (int i = 0; i < key_list->rowCount(); i++) {
if (std::find(checked_key_list->begin(), checked_key_list->end(),
- buffered_keys[i].id()) != checked_key_list->end()) {
+ buffered_keys[i].GetId()) != checked_key_list->end()) {
key_list->item(i, 0)->setCheckState(Qt::Checked);
}
}
diff --git a/src/ui/widgets/SignersPicker.cpp b/src/ui/widgets/SignersPicker.cpp
index b035bf19..d46bd4ad 100644
--- a/src/ui/widgets/SignersPicker.cpp
+++ b/src/ui/widgets/SignersPicker.cpp
@@ -37,7 +37,9 @@ SignersPicker::SignersPicker(QWidget* parent) : QDialog(parent) {
key_list_->addListGroupTab(
_("Signers"), KeyListRow::ONLY_SECRET_KEY,
KeyListColumn::NAME | KeyListColumn::EmailAddress | KeyListColumn::Usage,
- [](const GpgKey& key) -> bool { return key.CanSignActual(); });
+ [](const GpgKey& key) -> bool {
+ return key.IsHasActualSigningCapability();
+ });
key_list_->slotRefresh();
auto* vbox2 = new QVBoxLayout();
diff --git a/src/ui/widgets/VerifyKeyDetailBox.cpp b/src/ui/widgets/VerifyKeyDetailBox.cpp
index 3187e156..5e4d06d0 100644
--- a/src/ui/widgets/VerifyKeyDetailBox.cpp
+++ b/src/ui/widgets/VerifyKeyDetailBox.cpp
@@ -30,10 +30,10 @@ namespace GpgFrontend::UI {
VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
QWidget* parent)
- : QGroupBox(parent), fpr(signature.fpr()) {
+ : QGroupBox(parent), fpr(signature.GetFingerprint()) {
auto* vbox = new QVBoxLayout();
- switch (gpg_err_code(signature.status())) {
+ switch (gpg_err_code(signature.GetStatus())) {
case GPG_ERR_NO_PUBKEY: {
this->setTitle("A Error Signature");
auto* importButton = new QPushButton(_("Import from keyserver"));
@@ -60,9 +60,9 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
vbox->addLayout(gird);
} else {
vbox->addWidget(new QLabel(_("Key Information is NOT Available")));
- if (!signature.fpr().empty()) {
+ if (!signature.GetFingerprint().empty()) {
vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " +
- signature.fpr().c_str()));
+ signature.GetFingerprint().c_str()));
}
}
break;
@@ -76,9 +76,9 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
vbox->addLayout(gird);
} else {
vbox->addWidget(new QLabel(_("Key Information is NOT Available")));
- if (!signature.fpr().empty()) {
+ if (!signature.GetFingerprint().empty()) {
vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " +
- signature.fpr().c_str()));
+ signature.GetFingerprint().c_str()));
}
}
break;
@@ -92,9 +92,9 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
vbox->addLayout(gird);
} else {
vbox->addWidget(new QLabel(_("Key Information is NOT Available")));
- if (!signature.fpr().empty()) {
+ if (!signature.GetFingerprint().empty()) {
vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " +
- signature.fpr().c_str()));
+ signature.GetFingerprint().c_str()));
}
}
break;
@@ -110,9 +110,9 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
vbox->addLayout(gird);
} else {
vbox->addWidget(new QLabel(_("Key Information is NOT Available")));
- if (!signature.fpr().empty()) {
+ if (!signature.GetFingerprint().empty()) {
vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " +
- signature.fpr().c_str()));
+ signature.GetFingerprint().c_str()));
}
}
break;
@@ -126,9 +126,9 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
vbox->addLayout(gird);
} else {
vbox->addWidget(new QLabel(_("Key Information is NOT Available")));
- if (!signature.fpr().empty()) {
+ if (!signature.GetFingerprint().empty()) {
vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " +
- signature.fpr().c_str()));
+ signature.GetFingerprint().c_str()));
}
}
break;
@@ -141,9 +141,9 @@ VerifyKeyDetailBox::VerifyKeyDetailBox(const GpgSignature& signature,
vbox->addLayout(gird);
} else {
vbox->addWidget(new QLabel(_("Key Information is NOT Available")));
- if (!signature.fpr().empty()) {
+ if (!signature.GetFingerprint().empty()) {
vbox->addWidget(new QLabel(QString(_("Fingerprint")) + ": " +
- signature.fpr().c_str()));
+ signature.GetFingerprint().c_str()));
}
}
break;
@@ -164,18 +164,18 @@ QGridLayout* VerifyKeyDetailBox::createKeyInfoGrid(
auto grid = new QGridLayout();
GpgKey key = GpgKeyGetter::GetInstance().GetKey(fpr);
- if (!key.good()) return nullptr;
+ if (!key.IsGood()) return nullptr;
grid->addWidget(new QLabel(QString(_("Signer Name")) + ":"), 0, 0);
grid->addWidget(new QLabel(QString(_("Signer Email")) + ":"), 1, 0);
grid->addWidget(new QLabel(QString(_("Key's Fingerprint")) + ":"), 2, 0);
grid->addWidget(new QLabel(QString(_("Valid")) + ":"), 3, 0);
grid->addWidget(new QLabel(QString(_("Flags")) + ":"), 4, 0);
- grid->addWidget(new QLabel(QString::fromStdString(key.name())), 0, 1);
- grid->addWidget(new QLabel(QString::fromStdString(key.email())), 1, 1);
+ grid->addWidget(new QLabel(QString::fromStdString(key.GetName())), 0, 1);
+ grid->addWidget(new QLabel(QString::fromStdString(key.GetEmail())), 1, 1);
grid->addWidget(new QLabel(beautify_fingerprint(fpr).c_str()), 2, 1);
- if (signature.summary() & GPGME_SIGSUM_VALID) {
+ if (signature.GetSummary() & GPGME_SIGSUM_VALID) {
grid->addWidget(new QLabel(_("Fully Valid")), 3, 1);
} else {
grid->addWidget(new QLabel(_("NOT Fully Valid")), 3, 1);
@@ -183,25 +183,25 @@ QGridLayout* VerifyKeyDetailBox::createKeyInfoGrid(
std::stringstream text_stream;
- if (signature.summary() & GPGME_SIGSUM_GREEN) {
+ if (signature.GetSummary() & GPGME_SIGSUM_GREEN) {
text_stream << _("Good") << " ";
}
- if (signature.summary() & GPGME_SIGSUM_RED) {
+ if (signature.GetSummary() & GPGME_SIGSUM_RED) {
text_stream << _("Bad") << " ";
}
- if (signature.summary() & GPGME_SIGSUM_SIG_EXPIRED) {
+ if (signature.GetSummary() & GPGME_SIGSUM_SIG_EXPIRED) {
text_stream << _("Expired") << " ";
}
- if (signature.summary() & GPGME_SIGSUM_KEY_MISSING) {
+ if (signature.GetSummary() & GPGME_SIGSUM_KEY_MISSING) {
text_stream << _("Missing Key") << " ";
}
- if (signature.summary() & GPGME_SIGSUM_KEY_REVOKED) {
+ if (signature.GetSummary() & GPGME_SIGSUM_KEY_REVOKED) {
text_stream << _("Revoked Key") << " ";
}
- if (signature.summary() & GPGME_SIGSUM_KEY_EXPIRED) {
+ if (signature.GetSummary() & GPGME_SIGSUM_KEY_EXPIRED) {
text_stream << _("Expired Key") << " ";
}
- if (signature.summary() & GPGME_SIGSUM_CRL_MISSING) {
+ if (signature.GetSummary() & GPGME_SIGSUM_CRL_MISSING) {
text_stream << _("Missing CRL") << " ";
}