diff options
Diffstat (limited to 'src/core/function')
19 files changed, 76 insertions, 54 deletions
diff --git a/src/core/function/CacheManager.cpp b/src/core/function/CacheManager.cpp index 161f9a0c..a5eac78e 100644 --- a/src/core/function/CacheManager.cpp +++ b/src/core/function/CacheManager.cpp @@ -33,7 +33,7 @@ #include <shared_mutex> #include <utility> -#include "function/DataObjectOperator.h" +#include "core/function/DataObjectOperator.h" namespace GpgFrontend { diff --git a/src/core/function/KeyPackageOperator.cpp b/src/core/function/KeyPackageOperator.cpp index 6452c91e..e986ef44 100644 --- a/src/core/function/KeyPackageOperator.cpp +++ b/src/core/function/KeyPackageOperator.cpp @@ -36,6 +36,7 @@ #include "core/function/PassphraseGenerator.h" #include "core/function/gpg/GpgKeyGetter.h" #include "core/function/gpg/GpgKeyImportExporter.h" +#include "core/typedef/CoreTypedef.h" #include "core/utils/IOUtils.h" namespace GpgFrontend { diff --git a/src/core/function/KeyPackageOperator.h b/src/core/function/KeyPackageOperator.h index 26939271..e2fcc3e4 100644 --- a/src/core/function/KeyPackageOperator.h +++ b/src/core/function/KeyPackageOperator.h @@ -83,8 +83,7 @@ class GPGFRONTEND_CORE_EXPORT KeyPackageOperator { */ static auto ImportKeyPackage(const std::filesystem::path &key_package_path, const std::filesystem::path &phrase_path, - GpgFrontend::GpgImportInformation &import_info) - -> bool; + GpgImportInformation &import_info) -> bool; private: /** diff --git a/src/core/function/gpg/GpgBasicOperator.cpp b/src/core/function/gpg/GpgBasicOperator.cpp index 836dafaa..4f524d3d 100644 --- a/src/core/function/gpg/GpgBasicOperator.cpp +++ b/src/core/function/gpg/GpgBasicOperator.cpp @@ -28,6 +28,7 @@ #include "GpgBasicOperator.h" +#include "core/GpgModel.h" #include "core/utils/GpgUtils.h" GpgFrontend::GpgBasicOperator::GpgBasicOperator(int channel) diff --git a/src/core/function/gpg/GpgBasicOperator.h b/src/core/function/gpg/GpgBasicOperator.h index 581b6b95..e72db861 100644 --- a/src/core/function/gpg/GpgBasicOperator.h +++ b/src/core/function/gpg/GpgBasicOperator.h @@ -28,10 +28,11 @@ #pragma once -#include "core/GpgModel.h" #include "core/function/basic/GpgFunctionObject.h" #include "core/function/gpg/GpgContext.h" #include "core/function/result_analyse/GpgResultAnalyse.h" +#include "core/typedef/CoreTypedef.h" +#include "core/typedef/GpgTypedef.h" namespace GpgFrontend { diff --git a/src/core/function/gpg/GpgFileOpera.h b/src/core/function/gpg/GpgFileOpera.h index 722555fc..b20fa7db 100644 --- a/src/core/function/gpg/GpgFileOpera.h +++ b/src/core/function/gpg/GpgFileOpera.h @@ -28,8 +28,8 @@ #pragma once -#include "core/GpgModel.h" #include "core/function/result_analyse/GpgResultAnalyse.h" +#include "core/typedef/GpgTypedef.h" namespace GpgFrontend { diff --git a/src/core/function/gpg/GpgKeyGetter.cpp b/src/core/function/gpg/GpgKeyGetter.cpp index 73d40a0a..0b1c7c44 100644 --- a/src/core/function/gpg/GpgKeyGetter.cpp +++ b/src/core/function/gpg/GpgKeyGetter.cpp @@ -33,6 +33,7 @@ #include <mutex> #include <shared_mutex> +#include "core/GpgModel.h" #include "core/function/gpg/GpgContext.h" #include "core/utils/GpgUtils.h" diff --git a/src/core/function/gpg/GpgKeyGetter.h b/src/core/function/gpg/GpgKeyGetter.h index fabd1e4e..287c062a 100644 --- a/src/core/function/gpg/GpgKeyGetter.h +++ b/src/core/function/gpg/GpgKeyGetter.h @@ -28,8 +28,8 @@ #pragma once -#include "core/GpgModel.h" #include "core/function/basic/GpgFunctionObject.h" +#include "core/typedef/GpgTypedef.h" namespace GpgFrontend { diff --git a/src/core/function/gpg/GpgKeyImportExporter.cpp b/src/core/function/gpg/GpgKeyImportExporter.cpp index 29bbf60e..c0d578c8 100644 --- a/src/core/function/gpg/GpgKeyImportExporter.cpp +++ b/src/core/function/gpg/GpgKeyImportExporter.cpp @@ -28,10 +28,13 @@ #include "GpgKeyImportExporter.h" +#include "core/GpgModel.h" #include "core/function/gpg/GpgKeyGetter.h" #include "core/utils/GpgUtils.h" -GpgFrontend::GpgKeyImportExporter::GpgKeyImportExporter(int channel) +namespace GpgFrontend { + +GpgKeyImportExporter::GpgKeyImportExporter(int channel) : SingletonFunctionObject<GpgKeyImportExporter>(channel), ctx_(GpgContext::GetInstance(SingletonFunctionObject::GetChannel())) {} @@ -40,8 +43,8 @@ GpgFrontend::GpgKeyImportExporter::GpgKeyImportExporter(int channel) * @param inBuffer input byte array * @return Import information */ -auto GpgFrontend::GpgKeyImportExporter::ImportKey(StdBypeArrayPtr in_buffer) - -> GpgFrontend::GpgImportInformation { +auto GpgKeyImportExporter::ImportKey(StdBypeArrayPtr in_buffer) + -> GpgImportInformation { if (in_buffer->empty()) return {}; GpgData data_in(in_buffer->data(), in_buffer->size()); @@ -69,9 +72,9 @@ auto GpgFrontend::GpgKeyImportExporter::ImportKey(StdBypeArrayPtr in_buffer) * @param out_buffer output byte array * @return if success */ -auto GpgFrontend::GpgKeyImportExporter::ExportKeys(KeyIdArgsListPtr& uid_list, - ByteArrayPtr& out_buffer, - bool secret) const -> bool { +auto GpgKeyImportExporter::ExportKeys(KeyIdArgsListPtr& uid_list, + ByteArrayPtr& out_buffer, + bool secret) const -> bool { if (uid_list->empty()) return false; int mode = 0; @@ -108,9 +111,9 @@ auto GpgFrontend::GpgKeyImportExporter::ExportKeys(KeyIdArgsListPtr& uid_list, * @param outBuffer output byte array * @return if success */ -auto GpgFrontend::GpgKeyImportExporter::ExportKeys(const KeyArgsList& keys, - ByteArrayPtr& out_buffer, - bool secret) const -> bool { +auto GpgKeyImportExporter::ExportKeys(const KeyArgsList& keys, + ByteArrayPtr& out_buffer, + bool secret) const -> bool { KeyIdArgsListPtr key_ids = std::make_unique<std::vector<std::string>>(); for (const auto& key : keys) key_ids->push_back(key.GetId()); return ExportKeys(key_ids, out_buffer, secret); @@ -122,9 +125,9 @@ auto GpgFrontend::GpgKeyImportExporter::ExportKeys(const KeyArgsList& keys, * @param out_buffer output byte array * @return if success */ -auto GpgFrontend::GpgKeyImportExporter::ExportAllKeys( - KeyIdArgsListPtr& uid_list, ByteArrayPtr& out_buffer, bool secret) const - -> bool { +auto GpgKeyImportExporter::ExportAllKeys(KeyIdArgsListPtr& uid_list, + ByteArrayPtr& out_buffer, + bool secret) const -> bool { bool result = true; result = ((static_cast<int>(ExportKeys(uid_list, out_buffer, false)) & static_cast<int>(result)) != 0); @@ -144,8 +147,9 @@ auto GpgFrontend::GpgKeyImportExporter::ExportAllKeys( * @param outBuffer output byte array * @return if successful */ -auto GpgFrontend::GpgKeyImportExporter::ExportSecretKey( - const GpgKey& key, ByteArrayPtr& out_buffer) const -> bool { +auto GpgKeyImportExporter::ExportSecretKey(const GpgKey& key, + ByteArrayPtr& out_buffer) const + -> bool { SPDLOG_DEBUG("export secret key: {}", key.GetId().c_str()); gpgme_key_t target_key[2] = {static_cast<gpgme_key_t>(key), nullptr}; @@ -161,9 +165,8 @@ auto GpgFrontend::GpgKeyImportExporter::ExportSecretKey( return CheckGpgError(err) == GPG_ERR_NO_ERROR; } -auto GpgFrontend::GpgKeyImportExporter::ExportKey( - const GpgFrontend::GpgKey& key, GpgFrontend::ByteArrayPtr& out_buffer) const - -> bool { +auto GpgKeyImportExporter::ExportKey(const GpgKey& key, + ByteArrayPtr& out_buffer) const -> bool { GpgData data_out; auto err = gpgme_op_export(ctx_, key.GetId().c_str(), 0, data_out); @@ -175,8 +178,8 @@ auto GpgFrontend::GpgKeyImportExporter::ExportKey( return CheckGpgError(err) == GPG_ERR_NO_ERROR; } -auto GpgFrontend::GpgKeyImportExporter::ExportKeyOpenSSH( - const GpgFrontend::GpgKey& key, GpgFrontend::ByteArrayPtr& out_buffer) const +auto GpgKeyImportExporter::ExportKeyOpenSSH(const GpgKey& key, + ByteArrayPtr& out_buffer) const -> bool { GpgData data_out; auto err = gpgme_op_export(ctx_, key.GetId().c_str(), GPGME_EXPORT_MODE_SSH, @@ -189,9 +192,8 @@ auto GpgFrontend::GpgKeyImportExporter::ExportKeyOpenSSH( return CheckGpgError(err) == GPG_ERR_NO_ERROR; } -auto GpgFrontend::GpgKeyImportExporter::ExportSecretKeyShortest( - const GpgFrontend::GpgKey& key, GpgFrontend::ByteArrayPtr& out_buffer) const - -> bool { +auto GpgKeyImportExporter::ExportSecretKeyShortest( + const GpgKey& key, ByteArrayPtr& out_buffer) const -> bool { GpgData data_out; auto err = gpgme_op_export(ctx_, key.GetId().c_str(), GPGME_EXPORT_MODE_MINIMAL, data_out); @@ -203,10 +205,9 @@ auto GpgFrontend::GpgKeyImportExporter::ExportSecretKeyShortest( return CheckGpgError(err) == GPG_ERR_NO_ERROR; } -GpgFrontend::GpgImportInformation::GpgImportInformation() = default; +GpgImportInformation::GpgImportInformation() = default; -GpgFrontend::GpgImportInformation::GpgImportInformation( - gpgme_import_result_t result) { +GpgImportInformation::GpgImportInformation(gpgme_import_result_t result) { if (result->unchanged != 0) unchanged = result->unchanged; if (result->considered != 0) considered = result->considered; if (result->no_user_id != 0) no_user_id = result->no_user_id; @@ -224,3 +225,5 @@ GpgFrontend::GpgImportInformation::GpgImportInformation( } if (result->not_imported != 0) not_imported = result->not_imported; } + +} // namespace GpgFrontend diff --git a/src/core/function/gpg/GpgKeyImportExporter.h b/src/core/function/gpg/GpgKeyImportExporter.h index 75d65ada..20eacd71 100644 --- a/src/core/function/gpg/GpgKeyImportExporter.h +++ b/src/core/function/gpg/GpgKeyImportExporter.h @@ -28,9 +28,10 @@ #pragma once -#include "core/GpgModel.h" #include "core/function/basic/GpgFunctionObject.h" #include "core/function/gpg/GpgContext.h" +#include "core/typedef/CoreTypedef.h" +#include "core/typedef/GpgTypedef.h" namespace GpgFrontend { diff --git a/src/core/function/gpg/GpgKeyManager.cpp b/src/core/function/gpg/GpgKeyManager.cpp index 3e27f946..726b2b66 100644 --- a/src/core/function/gpg/GpgKeyManager.cpp +++ b/src/core/function/gpg/GpgKeyManager.cpp @@ -31,6 +31,7 @@ #include <boost/algorithm/string.hpp> #include <boost/date_time/posix_time/conversion.hpp> +#include "core/GpgModel.h" #include "core/function/gpg/GpgBasicOperator.h" #include "core/function/gpg/GpgKeyGetter.h" #include "core/utils/GpgUtils.h" diff --git a/src/core/function/gpg/GpgKeyManager.h b/src/core/function/gpg/GpgKeyManager.h index c263032f..bf0f5c02 100644 --- a/src/core/function/gpg/GpgKeyManager.h +++ b/src/core/function/gpg/GpgKeyManager.h @@ -31,9 +31,13 @@ #include <functional> #include <utility> -#include "core/GpgModel.h" #include "core/function/basic/GpgFunctionObject.h" #include "core/function/gpg/GpgContext.h" +#include "core/typedef/GpgTypedef.h" + +namespace boost::posix_time { +class ptime; +} namespace GpgFrontend { diff --git a/src/core/function/gpg/GpgKeyOpera.cpp b/src/core/function/gpg/GpgKeyOpera.cpp index c31a79e3..e48a84d8 100644 --- a/src/core/function/gpg/GpgKeyOpera.cpp +++ b/src/core/function/gpg/GpgKeyOpera.cpp @@ -35,6 +35,7 @@ #include <boost/process/async_pipe.hpp> #include "core/GpgConstants.h" +#include "core/GpgModel.h" #include "core/function/gpg/GpgCommandExecutor.h" #include "core/function/gpg/GpgKeyGetter.h" #include "core/function/result_analyse/GpgResultAnalyse.h" diff --git a/src/core/function/gpg/GpgKeyOpera.h b/src/core/function/gpg/GpgKeyOpera.h index 2c92b9b0..0186cdbb 100644 --- a/src/core/function/gpg/GpgKeyOpera.h +++ b/src/core/function/gpg/GpgKeyOpera.h @@ -28,9 +28,13 @@ #pragma once -#include "core/GpgModel.h" #include "core/function/gpg/GpgContext.h" #include "core/function/result_analyse/GpgResultAnalyse.h" +#include "core/typedef/GpgTypedef.h" + +namespace boost::posix_time { +class ptime; +} // namespace boost::posix_time namespace GpgFrontend { /** diff --git a/src/core/function/gpg/GpgUIDOperator.cpp b/src/core/function/gpg/GpgUIDOperator.cpp index 2c0445b1..a614d2ee 100644 --- a/src/core/function/gpg/GpgUIDOperator.cpp +++ b/src/core/function/gpg/GpgUIDOperator.cpp @@ -30,37 +30,38 @@ #include <boost/format.hpp> +#include "core/GpgModel.h" #include "core/utils/GpgUtils.h" -GpgFrontend::GpgUIDOperator::GpgUIDOperator(int channel) +namespace GpgFrontend { + +GpgUIDOperator::GpgUIDOperator(int channel) : SingletonFunctionObject<GpgUIDOperator>(channel) {} -auto GpgFrontend::GpgUIDOperator::AddUID(const GpgFrontend::GpgKey& key, - const std::string& uid) -> bool { +auto GpgUIDOperator::AddUID(const GpgKey& key, const std::string& uid) -> bool { auto err = gpgme_op_adduid(ctx_, static_cast<gpgme_key_t>(key), uid.c_str(), 0); return CheckGpgError(err) == GPG_ERR_NO_ERROR; } -auto GpgFrontend::GpgUIDOperator::RevUID(const GpgFrontend::GpgKey& key, - const std::string& uid) -> bool { +auto GpgUIDOperator::RevUID(const GpgKey& key, const std::string& uid) -> bool { auto err = CheckGpgError( gpgme_op_revuid(ctx_, static_cast<gpgme_key_t>(key), uid.c_str(), 0)); return CheckGpgError(err) == GPG_ERR_NO_ERROR; } -auto GpgFrontend::GpgUIDOperator::SetPrimaryUID(const GpgFrontend::GpgKey& key, - const std::string& uid) +auto GpgUIDOperator::SetPrimaryUID(const GpgKey& key, const std::string& uid) -> bool { auto err = CheckGpgError(gpgme_op_set_uid_flag( ctx_, static_cast<gpgme_key_t>(key), uid.c_str(), "primary", nullptr)); return CheckGpgError(err) == GPG_ERR_NO_ERROR; } -auto GpgFrontend::GpgUIDOperator::AddUID(const GpgFrontend::GpgKey& key, - const std::string& name, - const std::string& comment, - const std::string& email) -> bool { +auto GpgUIDOperator::AddUID(const GpgKey& key, const std::string& name, + const std::string& comment, + const std::string& email) -> bool { SPDLOG_DEBUG("new uuid: {} {} {}", name, comment, email); auto uid = boost::format("%1%(%2%)<%3%>") % name % comment % email; return AddUID(key, uid.str()); } + +} // namespace GpgFrontend diff --git a/src/core/function/gpg/GpgUIDOperator.h b/src/core/function/gpg/GpgUIDOperator.h index 02ea7b5f..982f8d08 100644 --- a/src/core/function/gpg/GpgUIDOperator.h +++ b/src/core/function/gpg/GpgUIDOperator.h @@ -28,8 +28,8 @@ #pragma once -#include "core/GpgModel.h" #include "core/function/gpg/GpgContext.h" +#include "core/typedef/GpgTypedef.h" namespace GpgFrontend { /** diff --git a/src/core/function/result_analyse/GpgResultAnalyse.h b/src/core/function/result_analyse/GpgResultAnalyse.h index b95eb2f0..b034f40a 100644 --- a/src/core/function/result_analyse/GpgResultAnalyse.h +++ b/src/core/function/result_analyse/GpgResultAnalyse.h @@ -29,7 +29,7 @@ #include <sstream> -#include "core/GpgModel.h" +#include "core/typedef/GpgTypedef.h" namespace GpgFrontend { diff --git a/src/core/function/result_analyse/GpgSignResultAnalyse.cpp b/src/core/function/result_analyse/GpgSignResultAnalyse.cpp index 5925ced9..bb24c40f 100644 --- a/src/core/function/result_analyse/GpgSignResultAnalyse.cpp +++ b/src/core/function/result_analyse/GpgSignResultAnalyse.cpp @@ -28,13 +28,15 @@ #include "GpgSignResultAnalyse.h" -#include "function/gpg/GpgKeyGetter.h" +#include "core/GpgModel.h" +#include "core/function/gpg/GpgKeyGetter.h" -GpgFrontend::GpgSignResultAnalyse::GpgSignResultAnalyse(GpgError error, - GpgSignResult result) +namespace GpgFrontend { + +GpgSignResultAnalyse::GpgSignResultAnalyse(GpgError error, GpgSignResult result) : error_(error), result_(std::move(result)) {} -void GpgFrontend::GpgSignResultAnalyse::doAnalyse() { +void GpgSignResultAnalyse::doAnalyse() { SPDLOG_DEBUG("start sign result analyse"); stream_ << "[#] " << _("Sign Operation") << " "; @@ -69,8 +71,7 @@ void GpgFrontend::GpgSignResultAnalyse::doAnalyse() { stream_ << std::endl; - auto singer_key = - GpgFrontend::GpgKeyGetter::GetInstance().GetKey(new_sign->fpr); + auto singer_key = GpgKeyGetter::GetInstance().GetKey(new_sign->fpr); if (singer_key.IsGood()) { stream_ << " " << _("Signer") << ": " << singer_key.GetUIDs()->front().GetUID() << std::endl; @@ -114,4 +115,6 @@ void GpgFrontend::GpgSignResultAnalyse::doAnalyse() { } stream_ << "<------------" << std::endl; } -}
\ No newline at end of file +} + +} // namespace GpgFrontend
\ No newline at end of file diff --git a/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp b/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp index fd80c6bb..e9c922ac 100644 --- a/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp +++ b/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp @@ -32,6 +32,7 @@ #include "GpgFrontend.h" #include "core/GpgConstants.h" +#include "core/GpgModel.h" #include "core/function/gpg/GpgKeyGetter.h" #include "core/utils/CommonUtils.h" |