diff options
author | saturneric <[email protected]> | 2024-12-13 15:22:33 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-12-13 15:22:33 +0000 |
commit | f7a00c58d2824f49ecaafc0152fc0b8213772e46 (patch) | |
tree | d012e5fac4ff9f48cd10381a0b79de0294d28d18 /src/core | |
parent | doc: update SECURITY.md (diff) | |
download | GpgFrontend-f7a00c58d2824f49ecaafc0152fc0b8213772e46.tar.gz GpgFrontend-f7a00c58d2824f49ecaafc0152fc0b8213772e46.zip |
refactor: using qt containers instead of std containers
Diffstat (limited to 'src/core')
50 files changed, 205 insertions, 354 deletions
diff --git a/src/core/GpgCoreInit.cpp b/src/core/GpgCoreInit.cpp index 0659377a..7199bd2d 100644 --- a/src/core/GpgCoreInit.cpp +++ b/src/core/GpgCoreInit.cpp @@ -616,7 +616,7 @@ auto InitGpgFrontendCore(CoreInitArgs args) -> int { continue; } - if (!GpgKeyGetter::GetInstance(ctx.GetChannel()).FetchKey()) { + if (!GpgKeyGetter::GetInstance(ctx.GetChannel()).FlushKeyCache()) { FLOG_E() << "gpgme context init key cache failed, index:" << channel_index; continue; diff --git a/src/core/function/basic/GpgFunctionObject.h b/src/core/function/basic/GpgFunctionObject.h index 06ad6bfd..41a597e5 100644 --- a/src/core/function/basic/GpgFunctionObject.h +++ b/src/core/function/basic/GpgFunctionObject.h @@ -141,11 +141,11 @@ class SingletonFunctionObject : public ChannelObject { } /** - * @brief Get all the channel ids + * @brief Get the All Channel Id object * - * @return std::vector<int> + * @return QContainer<int> */ - static auto GetAllChannelId() -> std::vector<int> { + static auto GetAllChannelId() -> QContainer<int> { return SingletonStorageCollection::GetInstance(false) ->GetSingletonStorage(typeid(T)) ->GetAllChannelId(); diff --git a/src/core/function/basic/SingletonStorage.cpp b/src/core/function/basic/SingletonStorage.cpp index e51acd77..be26d0f5 100644 --- a/src/core/function/basic/SingletonStorage.cpp +++ b/src/core/function/basic/SingletonStorage.cpp @@ -31,7 +31,8 @@ #include <shared_mutex> #include "core/function/basic/ChannelObject.h" -#include "utils/MemoryUtils.h" +#include "core/typedef/CoreTypedef.h" +#include "core/utils/MemoryUtils.h" namespace GpgFrontend { @@ -60,8 +61,8 @@ class SingletonStorage::Impl { } } - auto GetAllChannelId() -> std::vector<int> { - std::vector<int> channels; + auto GetAllChannelId() -> QContainer<int> { + QContainer<int> channels; channels.reserve(instances_map_.size()); for (const auto& [key, value] : instances_map_) { channels.push_back(key); @@ -119,7 +120,7 @@ auto SingletonStorage::FindObjectInChannel(int channel) return p_->FindObjectInChannel(channel); } -auto SingletonStorage::GetAllChannelId() -> std::vector<int> { +auto SingletonStorage::GetAllChannelId() -> QContainer<int> { return p_->GetAllChannelId(); } diff --git a/src/core/function/basic/SingletonStorage.h b/src/core/function/basic/SingletonStorage.h index 81ae570f..574a16ec 100644 --- a/src/core/function/basic/SingletonStorage.h +++ b/src/core/function/basic/SingletonStorage.h @@ -29,6 +29,7 @@ #pragma once #include "core/function/SecureMemoryAllocator.h" +#include "core/typedef/GpgTypedef.h" namespace GpgFrontend { @@ -66,11 +67,11 @@ class GPGFRONTEND_CORE_EXPORT SingletonStorage { auto FindObjectInChannel(int channel) -> ChannelObject*; /** - * @brief Get all the channel ids + * @brief Get the All Channel Id object * - * @return std::vector<int> + * @return QContainer<int> */ - auto GetAllChannelId() -> std::vector<int>; + auto GetAllChannelId() -> QContainer<int>; /** * @brief Set a new object in channel object diff --git a/src/core/function/gpg/GpgBasicOperator.cpp b/src/core/function/gpg/GpgBasicOperator.cpp index 6443f242..661c1283 100644 --- a/src/core/function/gpg/GpgBasicOperator.cpp +++ b/src/core/function/gpg/GpgBasicOperator.cpp @@ -50,7 +50,7 @@ void GpgBasicOperator::Encrypt(const KeyArgsList& keys, [=](const DataObjectPtr& data_object) -> GpgError { if (keys.empty()) return GPG_ERR_CANCELED; - std::vector<gpgme_key_t> recipients(keys.begin(), keys.end()); + QContainer<gpgme_key_t> recipients(keys.begin(), keys.end()); // Last entry data_in array has to be nullptr recipients.emplace_back(nullptr); @@ -77,7 +77,7 @@ auto GpgBasicOperator::EncryptSync(const KeyArgsList& keys, [=](const DataObjectPtr& data_object) -> GpgError { if (keys.empty()) return GPG_ERR_CANCELED; - std::vector<gpgme_key_t> recipients(keys.begin(), keys.end()); + QContainer<gpgme_key_t> recipients(keys.begin(), keys.end()); // Last entry data_in array has to be nullptr recipients.emplace_back(nullptr); @@ -329,7 +329,7 @@ void GpgBasicOperator::EncryptSign(const KeyArgsList& keys, if (keys.empty() || signers.empty()) return GPG_ERR_CANCELED; GpgError err; - std::vector<gpgme_key_t> recipients(keys.begin(), keys.end()); + QContainer<gpgme_key_t> recipients(keys.begin(), keys.end()); // Last entry data_in array has to be nullptr recipients.emplace_back(nullptr); @@ -361,7 +361,7 @@ auto GpgBasicOperator::EncryptSignSync(const KeyArgsList& keys, if (keys.empty() || signers.empty()) return GPG_ERR_CANCELED; GpgError err; - std::vector<gpgme_key_t> recipients(keys.begin(), keys.end()); + QContainer<gpgme_key_t> recipients(keys.begin(), keys.end()); // Last entry data_in array has to be nullptr recipients.emplace_back(nullptr); @@ -401,14 +401,14 @@ void GpgBasicOperator::SetSigners(const KeyArgsList& signers, bool ascii) { } } -auto GpgBasicOperator::GetSigners(bool ascii) -> std::unique_ptr<KeyArgsList> { +auto GpgBasicOperator::GetSigners(bool ascii) -> KeyArgsList { auto* ctx = ascii ? ctx_.DefaultContext() : ctx_.BinaryContext(); auto count = gpgme_signers_count(ctx); - auto signers = std::make_unique<std::vector<GpgKey>>(); + auto signers = KeyArgsList{}; for (auto i = 0U; i < count; i++) { auto key = GpgKey(gpgme_signers_enum(ctx, i)); - signers->push_back(GpgKey(std::move(key))); + signers.push_back(GpgKey(std::move(key))); } return signers; } diff --git a/src/core/function/gpg/GpgBasicOperator.h b/src/core/function/gpg/GpgBasicOperator.h index 431ccf1c..990d7af5 100644 --- a/src/core/function/gpg/GpgBasicOperator.h +++ b/src/core/function/gpg/GpgBasicOperator.h @@ -226,7 +226,7 @@ class GPGFRONTEND_CORE_EXPORT GpgBasicOperator * * @return Intelligent pointer pointing to the private key list */ - auto GetSigners(bool ascii) -> std::unique_ptr<KeyArgsList>; + auto GetSigners(bool ascii) -> KeyArgsList; private: GpgContext& ctx_ = GpgContext::GetInstance( diff --git a/src/core/function/gpg/GpgCommandExecutor.cpp b/src/core/function/gpg/GpgCommandExecutor.cpp index 3e218b92..5256de60 100644 --- a/src/core/function/gpg/GpgCommandExecutor.cpp +++ b/src/core/function/gpg/GpgCommandExecutor.cpp @@ -45,8 +45,8 @@ auto BuildTaskFromExecCtx(const GpgCommandExecutor::ExecuteContext &context) Thread::Task::TaskCallback result_callback = [cmd](int /*rtn*/, const DataObjectPtr &data_object) { - FLOG_D("data object args count of cmd executor result callback: %ld", - data_object->GetObjectSize()); + LOG_D() << "data object args count of cmd executor result callback:" + << data_object->GetObjectSize(); if (!data_object->Check<int, QString, GpgCommandExecutorCallback>()) { FLOG_W("data object checking failed"); diff --git a/src/core/function/gpg/GpgFileOpera.cpp b/src/core/function/gpg/GpgFileOpera.cpp index 5d29364b..9dea413d 100644 --- a/src/core/function/gpg/GpgFileOpera.cpp +++ b/src/core/function/gpg/GpgFileOpera.cpp @@ -50,7 +50,7 @@ void GpgFileOpera::EncryptFile(const KeyArgsList& keys, const QString& in_path, const GpgOperationCallback& cb) { RunGpgOperaAsync( [=](const DataObjectPtr& data_object) -> GpgError { - std::vector<gpgme_key_t> recipients(keys.begin(), keys.end()); + QContainer<gpgme_key_t> recipients(keys.begin(), keys.end()); // Last entry data_in array has to be nullptr recipients.emplace_back(nullptr); @@ -74,7 +74,7 @@ auto GpgFileOpera::EncryptFileSync( const QString& out_path) -> std::tuple<GpgError, DataObjectPtr> { return RunGpgOperaSync( [=](const DataObjectPtr& data_object) -> GpgError { - std::vector<gpgme_key_t> recipients(keys.begin(), keys.end()); + QContainer<gpgme_key_t> recipients(keys.begin(), keys.end()); // Last entry data_in array has to be nullptr recipients.emplace_back(nullptr); @@ -102,7 +102,7 @@ void GpgFileOpera::EncryptDirectory(const KeyArgsList& keys, RunGpgOperaAsync( [=](const DataObjectPtr& data_object) -> GpgError { - std::vector<gpgme_key_t> recipients(keys.begin(), keys.end()); + QContainer<gpgme_key_t> recipients(keys.begin(), keys.end()); // Last entry data_in array has to be nullptr recipients.emplace_back(nullptr); @@ -304,7 +304,7 @@ void GpgFileOpera::EncryptSignFile(const KeyArgsList& keys, RunGpgOperaAsync( [=](const DataObjectPtr& data_object) -> GpgError { GpgError err; - std::vector<gpgme_key_t> recipients(keys.begin(), keys.end()); + QContainer<gpgme_key_t> recipients(keys.begin(), keys.end()); // Last entry data_in array has to be nullptr recipients.emplace_back(nullptr); @@ -336,7 +336,7 @@ auto GpgFileOpera::EncryptSignFileSync( return RunGpgOperaSync( [=](const DataObjectPtr& data_object) -> GpgError { GpgError err; - std::vector<gpgme_key_t> recipients(keys.begin(), keys.end()); + QContainer<gpgme_key_t> recipients(keys.begin(), keys.end()); // Last entry data_in array has to be nullptr recipients.emplace_back(nullptr); @@ -372,7 +372,7 @@ void GpgFileOpera::EncryptSignDirectory(const KeyArgsList& keys, RunGpgOperaAsync( [=](const DataObjectPtr& data_object) -> GpgError { GpgError err; - std::vector<gpgme_key_t> recipients(keys.begin(), keys.end()); + QContainer<gpgme_key_t> recipients(keys.begin(), keys.end()); // Last entry data_in array has to be nullptr recipients.emplace_back(nullptr); diff --git a/src/core/function/gpg/GpgKeyGetter.cpp b/src/core/function/gpg/GpgKeyGetter.cpp index c4526e49..e5b234f8 100644 --- a/src/core/function/gpg/GpgKeyGetter.cpp +++ b/src/core/function/gpg/GpgKeyGetter.cpp @@ -73,17 +73,17 @@ class GpgKeyGetter::Impl : public SingletonFunctionObject<GpgKeyGetter::Impl> { return GpgKey(std::move(p_key)); } - auto FetchKey() -> KeyLinkListPtr { + auto FetchKey() -> GpgKeyList { if (keys_search_cache_.empty()) { FlushKeyCache(); } - auto keys_list = std::make_unique<GpgKeyLinkList>(); + auto keys_list = GpgKeyList{}; { // get the lock std::lock_guard<std::mutex> lock(keys_cache_mutex_); for (const auto& key : keys_cache_) { - keys_list->push_back(key); + keys_list.push_back(key); } } return keys_list; @@ -149,25 +149,17 @@ class GpgKeyGetter::Impl : public SingletonFunctionObject<GpgKeyGetter::Impl> { return true; } - auto GetKeys(const KeyIdArgsListPtr& ids) -> KeyListPtr { - auto keys = std::make_unique<KeyArgsList>(); - for (const auto& key_id : *ids) keys->emplace_back(GetKey(key_id, true)); + auto GetKeys(const KeyIdArgsList& ids) -> GpgKeyList { + auto keys = GpgKeyList{}; + for (const auto& key_id : ids) keys.emplace_back(GetKey(key_id, true)); return keys; } - auto GetKeysCopy(const KeyLinkListPtr& keys) -> KeyLinkListPtr { - // get the lock - std::lock_guard<std::mutex> lock(ctx_mutex_); - auto keys_copy = std::make_unique<GpgKeyLinkList>(); - for (const auto& key : *keys) keys_copy->emplace_back(key); - return keys_copy; - } - - auto GetKeysCopy(const KeyListPtr& keys) -> KeyListPtr { + auto GetKeysCopy(const GpgKeyList& keys) -> GpgKeyList { // get the lock std::lock_guard<std::mutex> lock(ctx_mutex_); - auto keys_copy = std::make_unique<KeyArgsList>(); - for (const auto& key : *keys) keys_copy->emplace_back(key); + auto keys_copy = GpgKeyList{}; + for (const auto& key : keys) keys_copy.emplace_back(key); return keys_copy; } @@ -243,19 +235,15 @@ auto GpgKeyGetter::GetPubkey(const QString& key_id, bool use_cache) -> GpgKey { auto GpgKeyGetter::FlushKeyCache() -> bool { return p_->FlushKeyCache(); } -auto GpgKeyGetter::GetKeys(const KeyIdArgsListPtr& ids) -> KeyListPtr { +auto GpgKeyGetter::GetKeys(const KeyIdArgsList& ids) -> GpgKeyList { return p_->GetKeys(ids); } -auto GpgKeyGetter::GetKeysCopy(const KeyLinkListPtr& keys) -> KeyLinkListPtr { - return p_->GetKeysCopy(keys); -} - -auto GpgKeyGetter::GetKeysCopy(const KeyListPtr& keys) -> KeyListPtr { +auto GpgKeyGetter::GetKeysCopy(const GpgKeyList& keys) -> GpgKeyList { return p_->GetKeysCopy(keys); } -auto GpgKeyGetter::FetchKey() -> KeyLinkListPtr { return p_->FetchKey(); } +auto GpgKeyGetter::FetchKey() -> GpgKeyList { return p_->FetchKey(); } auto GpgKeyGetter::GetGpgKeyTableModel() -> QSharedPointer<GpgKeyTableModel> { return p_->GetGpgKeyTableModel(); diff --git a/src/core/function/gpg/GpgKeyGetter.h b/src/core/function/gpg/GpgKeyGetter.h index f354ff49..2ed34531 100644 --- a/src/core/function/gpg/GpgKeyGetter.h +++ b/src/core/function/gpg/GpgKeyGetter.h @@ -68,7 +68,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyGetter * @param ids * @return KeyListPtr */ - auto GetKeys(const KeyIdArgsListPtr& key_ids) -> KeyListPtr; + auto GetKeys(const KeyIdArgsList& key_ids) -> GpgKeyList; /** * @brief Get the Pubkey object @@ -83,7 +83,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyGetter * * @return KeyLinkListPtr */ - auto FetchKey() -> KeyLinkListPtr; + auto FetchKey() -> GpgKeyList; /** * @brief flush the keys in the cache @@ -97,15 +97,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyGetter * @param keys * @return KeyListPtr */ - auto GetKeysCopy(const KeyListPtr& keys) -> KeyListPtr; - - /** - * @brief Get the Keys Copy object - * - * @param keys - * @return KeyLinkListPtr - */ - auto GetKeysCopy(const KeyLinkListPtr& keys) -> KeyLinkListPtr; + auto GetKeysCopy(const GpgKeyList& keys) -> GpgKeyList; /** * @brief diff --git a/src/core/function/gpg/GpgKeyImportExporter.cpp b/src/core/function/gpg/GpgKeyImportExporter.cpp index fa1f908f..6c78f760 100644 --- a/src/core/function/gpg/GpgKeyImportExporter.cpp +++ b/src/core/function/gpg/GpgKeyImportExporter.cpp @@ -82,7 +82,7 @@ auto GpgKeyImportExporter::ExportKey(const GpgKey& key, bool secret, bool ascii, if (shortest) mode |= GPGME_EXPORT_MODE_MINIMAL; if (ssh_mode) mode |= GPGME_EXPORT_MODE_SSH; - std::vector<gpgme_key_t> keys_array; + QContainer<gpgme_key_t> keys_array; // Last entry data_in array has to be nullptr keys_array.emplace_back(key); @@ -114,7 +114,7 @@ void GpgKeyImportExporter::ExportKeys(const KeyArgsList& keys, bool secret, if (shortest) mode |= GPGME_EXPORT_MODE_MINIMAL; if (ssh_mode) mode |= GPGME_EXPORT_MODE_SSH; - std::vector<gpgme_key_t> keys_array(keys.begin(), keys.end()); + QContainer<gpgme_key_t> keys_array(keys.begin(), keys.end()); // Last entry data_in array has to be nullptr keys_array.emplace_back(nullptr); @@ -144,7 +144,7 @@ void GpgKeyImportExporter::ExportAllKeys(const KeyArgsList& keys, bool secret, if (keys.empty()) return GPG_ERR_CANCELED; int mode = 0; - std::vector<gpgme_key_t> keys_array(keys.begin(), keys.end()); + QContainer<gpgme_key_t> keys_array(keys.begin(), keys.end()); // Last entry data_in array has to be nullptr keys_array.emplace_back(nullptr); diff --git a/src/core/function/gpg/GpgKeyManager.cpp b/src/core/function/gpg/GpgKeyManager.cpp index d0576e59..674a3884 100644 --- a/src/core/function/gpg/GpgKeyManager.cpp +++ b/src/core/function/gpg/GpgKeyManager.cpp @@ -61,10 +61,10 @@ auto GpgKeyManager::SignKey(const GpgKey& target, KeyArgsList& keys, } auto GpgKeyManager::RevSign(const GpgKey& key, - const SignIdArgsListPtr& signature_id) -> bool { + const SignIdArgsList& signature_id) -> bool { auto& key_getter = GpgKeyGetter::GetInstance(GetChannel()); - for (const auto& sign_id : *signature_id) { + for (const auto& sign_id : signature_id) { auto signing_key = key_getter.GetKey(sign_id.first); assert(signing_key.IsGood()); diff --git a/src/core/function/gpg/GpgKeyManager.h b/src/core/function/gpg/GpgKeyManager.h index 7bd45a1c..817179e1 100644 --- a/src/core/function/gpg/GpgKeyManager.h +++ b/src/core/function/gpg/GpgKeyManager.h @@ -68,7 +68,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyManager * @return false */ auto RevSign(const GpgFrontend::GpgKey& key, - const GpgFrontend::SignIdArgsListPtr& signature_id) -> bool; + const GpgFrontend::SignIdArgsList& signature_id) -> bool; /** * @brief Set the Expire object diff --git a/src/core/function/gpg/GpgKeyOpera.cpp b/src/core/function/gpg/GpgKeyOpera.cpp index a5346655..92a969ae 100644 --- a/src/core/function/gpg/GpgKeyOpera.cpp +++ b/src/core/function/gpg/GpgKeyOpera.cpp @@ -51,9 +51,9 @@ GpgKeyOpera::GpgKeyOpera(int channel) * Delete keys * @param uidList key ids */ -void GpgKeyOpera::DeleteKeys(KeyIdArgsListPtr key_ids) { +void GpgKeyOpera::DeleteKeys(KeyIdArgsList key_ids) { GpgError err; - for (const auto& tmp : *key_ids) { + for (const auto& tmp : key_ids) { auto key = GpgKeyGetter::GetInstance(GetChannel()).GetKey(tmp); if (key.IsGood()) { err = CheckGpgError(gpgme_op_delete_ext( @@ -532,8 +532,8 @@ auto GpgKeyOpera::ModifyTOFUPolicy( } void GpgKeyOpera::DeleteKey(const KeyId& key_id) { - auto keys = std::make_unique<KeyIdArgsList>(); - keys->push_back(key_id); - DeleteKeys(std::move(keys)); + auto keys = KeyIdArgsList{}; + keys.push_back(key_id); + DeleteKeys(keys); } } // namespace GpgFrontend diff --git a/src/core/function/gpg/GpgKeyOpera.h b/src/core/function/gpg/GpgKeyOpera.h index 7b8a01a1..0084d473 100644 --- a/src/core/function/gpg/GpgKeyOpera.h +++ b/src/core/function/gpg/GpgKeyOpera.h @@ -60,7 +60,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyOpera * * @param key_ids */ - void DeleteKeys(KeyIdArgsListPtr key_ids); + void DeleteKeys(KeyIdArgsList key_ids); /** * @brief diff --git a/src/core/model/DataObject.cpp b/src/core/model/DataObject.cpp index 2819065d..13838941 100644 --- a/src/core/model/DataObject.cpp +++ b/src/core/model/DataObject.cpp @@ -28,7 +28,7 @@ #include "DataObject.h" -#include <stack> +#include "core/typedef/CoreTypedef.h" namespace GpgFrontend { @@ -50,7 +50,7 @@ class DataObject::Impl { auto GetObjectSize() -> size_t { return params_.size(); } private: - std::vector<std::any> params_; + QContainer<std::any> params_; }; DataObject::DataObject() : p_(SecureCreateUniqueObject<Impl>()) {} diff --git a/src/core/model/DataObject.h b/src/core/model/DataObject.h index f67cff99..1713e8dd 100644 --- a/src/core/model/DataObject.h +++ b/src/core/model/DataObject.h @@ -33,13 +33,11 @@ #include <typeinfo> #include "core/GpgFrontendCoreExport.h" +#include "core/typedef/CoreTypedef.h" #include "core/utils/MemoryUtils.h" namespace GpgFrontend { -class DataObject; -using DataObjectPtr = std::shared_ptr<DataObject>; ///< - class GPGFRONTEND_CORE_EXPORT DataObject { public: DataObject(); @@ -66,7 +64,7 @@ class GPGFRONTEND_CORE_EXPORT DataObject { auto Check() -> bool { if (sizeof...(Args) != GetObjectSize()) return false; - std::vector<std::type_info const*> type_list = {&typeid(Args)...}; + QContainer<std::type_info const*> type_list = {&typeid(Args)...}; for (size_t i = 0; i < type_list.size(); ++i) { if (std::type_index(*type_list[i]) != std::type_index((*this)[i].type())) { diff --git a/src/core/model/GpgDecryptResult.cpp b/src/core/model/GpgDecryptResult.cpp index 3b6ebd67..82398d96 100644 --- a/src/core/model/GpgDecryptResult.cpp +++ b/src/core/model/GpgDecryptResult.cpp @@ -48,8 +48,8 @@ auto GpgDecryptResult::GetRaw() -> gpgme_decrypt_result_t { return result_ref_.get(); } -auto GpgDecryptResult::Recipients() -> std::vector<GpgRecipient> { - std::vector<GpgRecipient> result; +auto GpgDecryptResult::Recipients() -> QContainer<GpgRecipient> { + QContainer<GpgRecipient> result; for (auto* reci = result_ref_->recipients; reci != nullptr; reci = reci->next) { try { diff --git a/src/core/model/GpgDecryptResult.h b/src/core/model/GpgDecryptResult.h index 8528adc8..1b755868 100644 --- a/src/core/model/GpgDecryptResult.h +++ b/src/core/model/GpgDecryptResult.h @@ -39,7 +39,7 @@ class GPGFRONTEND_CORE_EXPORT GpgDecryptResult { auto GetRaw() -> gpgme_decrypt_result_t; - auto Recipients() -> std::vector<GpgRecipient>; + auto Recipients() -> QContainer<GpgRecipient>; explicit GpgDecryptResult(gpgme_decrypt_result_t); diff --git a/src/core/model/GpgEncryptResult.cpp b/src/core/model/GpgEncryptResult.cpp index b452b6f3..b5af09b1 100644 --- a/src/core/model/GpgEncryptResult.cpp +++ b/src/core/model/GpgEncryptResult.cpp @@ -48,8 +48,8 @@ auto GpgEncryptResult::GetRaw() -> gpgme_encrypt_result_t { } auto GpgEncryptResult::InvalidRecipients() - -> std::vector<std::tuple<QString, GpgError>> { - std::vector<std::tuple<QString, GpgError>> result; + -> QContainer<std::tuple<QString, GpgError>> { + QContainer<std::tuple<QString, GpgError>> result; for (auto* invalid_key = result_ref_->invalid_recipients; invalid_key != nullptr; invalid_key = invalid_key->next) { try { diff --git a/src/core/model/GpgEncryptResult.h b/src/core/model/GpgEncryptResult.h index a534d156..97a52a03 100644 --- a/src/core/model/GpgEncryptResult.h +++ b/src/core/model/GpgEncryptResult.h @@ -38,7 +38,7 @@ class GPGFRONTEND_CORE_EXPORT GpgEncryptResult { auto GetRaw() -> gpgme_encrypt_result_t; - auto InvalidRecipients() -> std::vector<std::tuple<QString, GpgError>>; + auto InvalidRecipients() -> QContainer<std::tuple<QString, GpgError>>; explicit GpgEncryptResult(gpgme_encrypt_result_t); diff --git a/src/core/model/GpgGenKeyInfo.cpp b/src/core/model/GpgGenKeyInfo.cpp index 1aaa4cea..180a7fab 100644 --- a/src/core/model/GpgGenKeyInfo.cpp +++ b/src/core/model/GpgGenKeyInfo.cpp @@ -216,8 +216,8 @@ GenKeyInfo::GenKeyInfo(bool m_is_sub_key) : subkey_(m_is_sub_key) { } auto GenKeyInfo::GetSupportedKeyAlgo() - -> const std::vector<GenKeyInfo::KeyGenAlgo> & { - static std::vector<GenKeyInfo::KeyGenAlgo> k_support_key_algo = { + -> const QContainer<GenKeyInfo::KeyGenAlgo> & { + static QContainer<GenKeyInfo::KeyGenAlgo> k_support_key_algo = { {"RSA", "RSA", ""}, {"DSA", "DSA", ""}, }; @@ -260,8 +260,8 @@ auto GenKeyInfo::GetSupportedKeyAlgo() } auto GenKeyInfo::GetSupportedSubkeyAlgo() - -> const std::vector<GenKeyInfo::KeyGenAlgo> & { - static std::vector<GenKeyInfo::KeyGenAlgo> k_support_subkey_algo = { + -> const QContainer<GenKeyInfo::KeyGenAlgo> & { + static QContainer<GenKeyInfo::KeyGenAlgo> k_support_subkey_algo = { {"RSA", "", "RSA"}, {"DSA", "", "DSA"}, {"ELG-E", "", "ELG"}, diff --git a/src/core/model/GpgGenKeyInfo.h b/src/core/model/GpgGenKeyInfo.h index 5f6c39a6..4092c8e9 100644 --- a/src/core/model/GpgGenKeyInfo.h +++ b/src/core/model/GpgGenKeyInfo.h @@ -29,6 +29,7 @@ #pragma once #include "core/GpgFrontendCoreExport.h" +#include "core/typedef/CoreTypedef.h" namespace GpgFrontend { @@ -47,16 +48,16 @@ class GPGFRONTEND_CORE_EXPORT GenKeyInfo { /** * @brief Get the Supported Key Algo object * - * @return const std::vector<QString>& + * @return const QContainer<QString>& */ - static auto GetSupportedKeyAlgo() -> const std::vector<KeyGenAlgo> &; + static auto GetSupportedKeyAlgo() -> const QContainer<KeyGenAlgo> &; /** * @brief Get the Supported Subkey Algo object * - * @return const std::vector<QString>& + * @return const QContainer<QString>& */ - static auto GetSupportedSubkeyAlgo() -> const std::vector<KeyGenAlgo> &; + static auto GetSupportedSubkeyAlgo() -> const QContainer<KeyGenAlgo> &; /** * @brief diff --git a/src/core/model/GpgKey.cpp b/src/core/model/GpgKey.cpp index e820d6b9..9b0ce1a5 100644 --- a/src/core/model/GpgKey.cpp +++ b/src/core/model/GpgKey.cpp @@ -184,8 +184,8 @@ auto GpgKey::IsHasMasterKey() const -> bool { return key_ref_->subkeys->secret; } -auto GpgKey::GetSubKeys() const -> std::unique_ptr<std::vector<GpgSubKey>> { - auto p_keys = std::make_unique<std::vector<GpgSubKey>>(); +auto GpgKey::GetSubKeys() const -> std::unique_ptr<QContainer<GpgSubKey>> { + auto p_keys = std::make_unique<QContainer<GpgSubKey>>(); auto *next = key_ref_->subkeys; while (next != nullptr) { p_keys->push_back(GpgSubKey(next)); @@ -194,8 +194,8 @@ auto GpgKey::GetSubKeys() const -> std::unique_ptr<std::vector<GpgSubKey>> { return p_keys; } -auto GpgKey::GetUIDs() const -> std::unique_ptr<std::vector<GpgUID>> { - auto p_uids = std::make_unique<std::vector<GpgUID>>(); +auto GpgKey::GetUIDs() const -> std::unique_ptr<QContainer<GpgUID>> { + auto p_uids = std::make_unique<QContainer<GpgUID>>(); auto *uid_next = key_ref_->uids; while (uid_next != nullptr) { p_uids->push_back(GpgUID(uid_next)); diff --git a/src/core/model/GpgKey.h b/src/core/model/GpgKey.h index 8afa3c7f..adc2ffa9 100644 --- a/src/core/model/GpgKey.h +++ b/src/core/model/GpgKey.h @@ -262,17 +262,17 @@ class GPGFRONTEND_CORE_EXPORT GpgKey { /** * @brief * - * @return std::unique_ptr<std::vector<GpgSubKey>> + * @return std::unique_ptr<QContainer<GpgSubKey>> */ [[nodiscard]] auto GetSubKeys() const - -> std::unique_ptr<std::vector<GpgSubKey>>; + -> std::unique_ptr<QContainer<GpgSubKey>>; /** * @brief * - * @return std::unique_ptr<std::vector<GpgUID>> + * @return std::unique_ptr<QContainer<GpgUID>> */ - [[nodiscard]] auto GetUIDs() const -> std::unique_ptr<std::vector<GpgUID>>; + [[nodiscard]] auto GetUIDs() const -> std::unique_ptr<QContainer<GpgUID>>; /** * @brief Construct a new Gpg Key object diff --git a/src/core/model/GpgKeySignature.cpp b/src/core/model/GpgKeySignature.cpp index 836e7c7c..b3d9712e 100644 --- a/src/core/model/GpgKeySignature.cpp +++ b/src/core/model/GpgKeySignature.cpp @@ -34,47 +34,60 @@ GpgKeySignature::GpgKeySignature() = default; GpgKeySignature::~GpgKeySignature() = default; -GpgKeySignature::GpgKeySignature(gpgme_key_sig_t sig) - : signature_ref_(sig, [&](gpgme_key_sig_t signature) {}) {} +GpgKeySignature::GpgKeySignature(gpgme_key_sig_t sig) : signature_ref_(sig) {} -GpgKeySignature::GpgKeySignature(GpgKeySignature &&) noexcept = default; +GpgKeySignature::GpgKeySignature(const GpgKeySignature &) = default; +auto GpgKeySignature::operator=(const GpgKeySignature &) -> GpgKeySignature & = + default; -GpgKeySignature &GpgKeySignature::operator=(GpgKeySignature &&) noexcept = - default; - -bool GpgKeySignature::IsRevoked() const { return signature_ref_->revoked; } +auto GpgKeySignature::IsRevoked() const -> bool { + return signature_ref_->revoked; +} -bool GpgKeySignature::IsExpired() const { return signature_ref_->expired; } +auto GpgKeySignature::IsExpired() const -> bool { + return signature_ref_->expired; +} -bool GpgKeySignature::IsInvalid() const { return signature_ref_->invalid; } +auto GpgKeySignature::IsInvalid() const -> bool { + return signature_ref_->invalid; +} -bool GpgKeySignature::IsExportable() const { +auto GpgKeySignature::IsExportable() const -> bool { return signature_ref_->exportable; } -gpgme_error_t GpgKeySignature::GetStatus() const { +auto GpgKeySignature::GetStatus() const -> gpgme_error_t { return signature_ref_->status; } -QString GpgKeySignature::GetKeyID() const { return signature_ref_->keyid; } +auto GpgKeySignature::GetKeyID() const -> QString { + return signature_ref_->keyid; +} -QString GpgKeySignature::GetPubkeyAlgo() const { +auto GpgKeySignature::GetPubkeyAlgo() const -> QString { return gpgme_pubkey_algo_name(signature_ref_->pubkey_algo); } -QDateTime GpgKeySignature::GetCreateTime() const { +auto GpgKeySignature::GetCreateTime() const -> QDateTime { return QDateTime::fromSecsSinceEpoch(signature_ref_->timestamp); } -QDateTime GpgKeySignature::GetExpireTime() const { +auto GpgKeySignature::GetExpireTime() const -> QDateTime { return QDateTime::fromSecsSinceEpoch(signature_ref_->expires); } -QString GpgKeySignature::GetUID() const { return signature_ref_->uid; } +auto GpgKeySignature::GetUID() const -> QString { return signature_ref_->uid; } -QString GpgKeySignature::GetName() const { return signature_ref_->name; } +auto GpgKeySignature::GetName() const -> QString { + return signature_ref_->name; +} + +auto GpgKeySignature::GetEmail() const -> QString { + return signature_ref_->email; +} -QString GpgKeySignature::GetEmail() const { return signature_ref_->email; } +auto GpgKeySignature::GetComment() const -> QString { + return signature_ref_->comment; +} -QString GpgKeySignature::GetComment() const { return signature_ref_->comment; } } // namespace GpgFrontend
\ No newline at end of file diff --git a/src/core/model/GpgKeySignature.h b/src/core/model/GpgKeySignature.h index ccff0c9c..5f190fa2 100644 --- a/src/core/model/GpgKeySignature.h +++ b/src/core/model/GpgKeySignature.h @@ -160,34 +160,17 @@ class GPGFRONTEND_CORE_EXPORT GpgKeySignature { * @brief Construct a new Gpg Key Signature object * */ - GpgKeySignature(GpgKeySignature &&) noexcept; - - /** - * @brief Construct a new Gpg Key Signature object - * - */ - GpgKeySignature(const GpgKeySignature &) = delete; - - /** - * @brief - * - * @return GpgKeySignature& - */ - auto operator=(GpgKeySignature &&) noexcept -> GpgKeySignature &; + GpgKeySignature(const GpgKeySignature &); /** * @brief * * @return GpgKeySignature& */ - auto operator=(const GpgKeySignature &) -> GpgKeySignature & = delete; + auto operator=(const GpgKeySignature &) -> GpgKeySignature &; private: - using KeySignatrueRefHandler = - std::unique_ptr<struct _gpgme_key_sig, - std::function<void(gpgme_key_sig_t)>>; ///< - - KeySignatrueRefHandler signature_ref_ = nullptr; ///< + gpgme_key_sig_t signature_ref_ = nullptr; ///< }; } // namespace GpgFrontend diff --git a/src/core/model/GpgKeyTableModel.cpp b/src/core/model/GpgKeyTableModel.cpp index 8de07b23..efd7e69d 100644 --- a/src/core/model/GpgKeyTableModel.cpp +++ b/src/core/model/GpgKeyTableModel.cpp @@ -157,8 +157,8 @@ auto GpgKeyTableModel::setData(const QModelIndex &index, const QVariant &value, return false; } -auto GpgKeyTableModel::GetAllKeyIds() -> GpgKeyIDList { - GpgKeyIDList keys; +auto GpgKeyTableModel::GetAllKeyIds() -> KeyIdArgsList { + KeyIdArgsList keys; for (auto &key : buffered_keys_) { keys.push_back(key.GetId()); } diff --git a/src/core/model/GpgKeyTableModel.h b/src/core/model/GpgKeyTableModel.h index a2c64fd0..cc5704e5 100644 --- a/src/core/model/GpgKeyTableModel.h +++ b/src/core/model/GpgKeyTableModel.h @@ -186,7 +186,7 @@ class GPGFRONTEND_CORE_EXPORT GpgKeyTableModel : public QAbstractTableModel { * * @return auto */ - auto GetAllKeyIds() -> GpgKeyIDList; + auto GetAllKeyIds() -> KeyIdArgsList; /** * @brief Get the Key ID By Row object diff --git a/src/core/model/GpgSignResult.cpp b/src/core/model/GpgSignResult.cpp index 59c402dd..4eb28523 100644 --- a/src/core/model/GpgSignResult.cpp +++ b/src/core/model/GpgSignResult.cpp @@ -47,8 +47,8 @@ auto GpgSignResult::GetRaw() -> gpgme_sign_result_t { } auto GpgSignResult::InvalidSigners() - -> std::vector<std::tuple<QString, GpgError>> { - std::vector<std::tuple<QString, GpgError>> result; + -> QContainer<std::tuple<QString, GpgError>> { + QContainer<std::tuple<QString, GpgError>> result; for (auto* invalid_key = result_ref_->invalid_signers; invalid_key != nullptr; invalid_key = invalid_key->next) { try { diff --git a/src/core/model/GpgSignResult.h b/src/core/model/GpgSignResult.h index 3881c86f..75f106f6 100644 --- a/src/core/model/GpgSignResult.h +++ b/src/core/model/GpgSignResult.h @@ -41,7 +41,7 @@ class GPGFRONTEND_CORE_EXPORT GpgSignResult { auto HashAlgo() -> QString; - auto InvalidSigners() -> std::vector<std::tuple<QString, GpgError>>; + auto InvalidSigners() -> QContainer<std::tuple<QString, GpgError>>; explicit GpgSignResult(gpgme_sign_result_t); diff --git a/src/core/model/GpgSignature.cpp b/src/core/model/GpgSignature.cpp index 139e367c..a4314cdb 100644 --- a/src/core/model/GpgSignature.cpp +++ b/src/core/model/GpgSignature.cpp @@ -30,27 +30,15 @@ namespace GpgFrontend { -/** - * @brief Construct a new Gpg Signature object - * - */ -GpgSignature::GpgSignature(GpgSignature &&) noexcept = default; +GpgSignature::GpgSignature() = default; -/** - * @brief - * - * @return GpgSignature& - */ -auto GpgSignature::operator=(GpgSignature &&) noexcept -> GpgSignature & = - default; +GpgSignature::GpgSignature(gpgme_signature_t sig) : signature_ref_(sig) {} -/** - * @brief Construct a new Gpg Signature:: Gpg Signature object - * - * @param sig - */ -GpgSignature::GpgSignature(gpgme_signature_t sig) - : signature_ref_(sig, [&](gpgme_signature_t signature) {}) {} +GpgSignature::~GpgSignature() = default; + +GpgSignature::GpgSignature(const GpgSignature &) = default; + +auto GpgSignature::operator=(const GpgSignature &) -> GpgSignature & = default; /** * @brief @@ -124,16 +112,4 @@ auto GpgSignature::GetFingerprint() const -> QString { return signature_ref_->fpr != nullptr ? signature_ref_->fpr : ""; } -/** - * @brief Construct a new Gpg Signature object - * - */ -GpgSignature::GpgSignature() = default; - -/** - * @brief Destroy the Gpg Signature object - * - */ -GpgSignature::~GpgSignature() = default; - } // namespace GpgFrontend diff --git a/src/core/model/GpgSignature.h b/src/core/model/GpgSignature.h index ddcc943f..aa977d55 100644 --- a/src/core/model/GpgSignature.h +++ b/src/core/model/GpgSignature.h @@ -117,33 +117,16 @@ class GPGFRONTEND_CORE_EXPORT GpgSignature { * @brief Construct a new Gpg Signature object * */ - GpgSignature(GpgSignature &&) noexcept; - - /** - * @brief Construct a new Gpg Signature object - * - */ - GpgSignature(const GpgSignature &) = delete; - - /** - * @brief - * - * @return GpgSignature& - */ - auto operator=(GpgSignature &&) noexcept -> GpgSignature &; + GpgSignature(const GpgSignature &); /** * @brief * * @return GpgSignature& */ - auto operator=(const GpgSignature &) -> GpgSignature & = delete; + auto operator=(const GpgSignature &) -> GpgSignature &; private: - using KeySignatrueRefHandler = - std::unique_ptr<struct _gpgme_signature, - std::function<void(gpgme_signature_t)>>; ///< - - KeySignatrueRefHandler signature_ref_ = nullptr; ///< + gpgme_signature_t signature_ref_ = nullptr; ///< }; } // namespace GpgFrontend diff --git a/src/core/model/GpgSubKey.cpp b/src/core/model/GpgSubKey.cpp index ba2f749c..eba4167e 100644 --- a/src/core/model/GpgSubKey.cpp +++ b/src/core/model/GpgSubKey.cpp @@ -31,17 +31,11 @@ namespace GpgFrontend { GpgSubKey::GpgSubKey() = default; -GpgSubKey::GpgSubKey(gpgme_subkey_t subkey) - : subkey_ref_(subkey, [&](gpgme_subkey_t subkey) {}) {} +GpgSubKey::GpgSubKey(gpgme_subkey_t subkey) : subkey_ref_(subkey) {} -GpgSubKey::GpgSubKey(GpgSubKey&& o) noexcept { - swap(subkey_ref_, o.subkey_ref_); -} +GpgSubKey::GpgSubKey(const GpgSubKey&) = default; -auto GpgSubKey::operator=(GpgSubKey&& o) noexcept -> GpgSubKey& { - swap(subkey_ref_, o.subkey_ref_); - return *this; -}; +auto GpgSubKey::operator=(const GpgSubKey&) -> GpgSubKey& = default; auto GpgSubKey::operator==(const GpgSubKey& o) const -> bool { return GetFingerprint() == o.GetFingerprint(); @@ -56,7 +50,7 @@ auto GpgSubKey::GetPubkeyAlgo() const -> QString { } auto GpgSubKey::GetKeyAlgo() const -> QString { - auto* buffer = gpgme_pubkey_algo_string(subkey_ref_.get()); + auto* buffer = gpgme_pubkey_algo_string(subkey_ref_); auto algo = QString(buffer); gpgme_free(buffer); return algo.toUpper(); diff --git a/src/core/model/GpgSubKey.h b/src/core/model/GpgSubKey.h index e9eea6ea..58c6298a 100644 --- a/src/core/model/GpgSubKey.h +++ b/src/core/model/GpgSubKey.h @@ -185,30 +185,15 @@ class GPGFRONTEND_CORE_EXPORT GpgSubKey { /** * @brief Construct a new Gpg Sub Key object * - * @param o - */ - GpgSubKey(GpgSubKey&& o) noexcept; - - /** - * @brief Construct a new Gpg Sub Key object - * - */ - GpgSubKey(const GpgSubKey&) = delete; - - /** - * @brief - * - * @param o - * @return GpgSubKey& */ - auto operator=(GpgSubKey&& o) noexcept -> GpgSubKey&; + GpgSubKey(const GpgSubKey&); /** * @brief * * @return GpgSubKey& */ - auto operator=(const GpgSubKey&) -> GpgSubKey& = delete; + auto operator=(const GpgSubKey&) -> GpgSubKey&; /** * @brief @@ -220,11 +205,7 @@ class GPGFRONTEND_CORE_EXPORT GpgSubKey { auto operator==(const GpgSubKey& o) const -> bool; private: - using SubkeyRefHandler = - std::unique_ptr<struct _gpgme_subkey, - std::function<void(gpgme_subkey_t)>>; ///< - - SubkeyRefHandler subkey_ref_ = nullptr; ///< + gpgme_subkey_t subkey_ref_ = nullptr; ///< }; } // namespace GpgFrontend diff --git a/src/core/model/GpgTOFUInfo.cpp b/src/core/model/GpgTOFUInfo.cpp index be9320d2..3296f05b 100644 --- a/src/core/model/GpgTOFUInfo.cpp +++ b/src/core/model/GpgTOFUInfo.cpp @@ -33,16 +33,11 @@ namespace GpgFrontend { GpgTOFUInfo::GpgTOFUInfo() = default; GpgTOFUInfo::GpgTOFUInfo(gpgme_tofu_info_t tofu_info) - : tofu_info_ref_(tofu_info, [&](gpgme_tofu_info_t tofu_info) {}) {} + : tofu_info_ref_(tofu_info) {} -GpgTOFUInfo::GpgTOFUInfo(GpgTOFUInfo&& o) noexcept { - swap(tofu_info_ref_, o.tofu_info_ref_); -} +GpgTOFUInfo::GpgTOFUInfo(const GpgTOFUInfo&) = default; -auto GpgTOFUInfo::operator=(GpgTOFUInfo&& o) noexcept -> GpgTOFUInfo& { - swap(tofu_info_ref_, o.tofu_info_ref_); - return *this; -}; +auto GpgTOFUInfo::operator=(const GpgTOFUInfo&) -> GpgTOFUInfo& = default; auto GpgTOFUInfo::GetValidity() const -> unsigned { return tofu_info_ref_->validity; @@ -64,29 +59,14 @@ auto GpgTOFUInfo::GetSignFirst() const -> unsigned long { return tofu_info_ref_->signfirst; } -/** - * @brief - * - * @return unsigned long - */ auto GpgTOFUInfo::GetSignLast() const -> unsigned long { return tofu_info_ref_->signlast; } -/** - * @brief - * - * @return unsigned long - */ auto GpgTOFUInfo::GetEncrLast() const -> unsigned long { return tofu_info_ref_->encrlast; } -/** - * @brief - * - * @return QString - */ auto GpgTOFUInfo::GetDescription() const -> QString { return tofu_info_ref_->description; } diff --git a/src/core/model/GpgTOFUInfo.h b/src/core/model/GpgTOFUInfo.h index efdf62b2..816680ce 100644 --- a/src/core/model/GpgTOFUInfo.h +++ b/src/core/model/GpgTOFUInfo.h @@ -110,37 +110,18 @@ class GPGFRONTEND_CORE_EXPORT GpgTOFUInfo { /** * @brief Construct a new Gpg T O F U Info object * - * @param o */ - GpgTOFUInfo(GpgTOFUInfo&& o) noexcept; - - /** - * @brief Construct a new Gpg T O F U Info object - * - */ - GpgTOFUInfo(const GpgTOFUInfo&) = delete; - - /** - * @brief - * - * @param o - * @return GpgTOFUInfo& - */ - auto operator=(GpgTOFUInfo&& o) noexcept -> GpgTOFUInfo&; + GpgTOFUInfo(const GpgTOFUInfo&); /** * @brief * * @return GpgTOFUInfo& */ - auto operator=(const GpgTOFUInfo&) -> GpgTOFUInfo& = delete; + auto operator=(const GpgTOFUInfo&) -> GpgTOFUInfo&; private: - using SubkeyRefHandler = - std::unique_ptr<struct _gpgme_tofu_info, - std::function<void(gpgme_tofu_info_t)>>; ///< - - SubkeyRefHandler tofu_info_ref_ = nullptr; ///< + gpgme_tofu_info_t tofu_info_ref_ = nullptr; ///< }; } // namespace GpgFrontend diff --git a/src/core/model/GpgUID.cpp b/src/core/model/GpgUID.cpp index c84f2a7f..cd4be820 100644 --- a/src/core/model/GpgUID.cpp +++ b/src/core/model/GpgUID.cpp @@ -32,10 +32,11 @@ namespace GpgFrontend { GpgUID::GpgUID() = default; -GpgUID::GpgUID(gpgme_user_id_t uid) - : uid_ref_(uid, [&](gpgme_user_id_t uid) {}) {} +GpgUID::GpgUID(gpgme_user_id_t uid) : uid_ref_(uid) {} -GpgUID::GpgUID(GpgUID &&o) noexcept { swap(uid_ref_, o.uid_ref_); } +GpgUID::GpgUID(const GpgUID &) = default; + +auto GpgUID::operator=(const GpgUID &) -> GpgUID & = default; auto GpgUID::GetName() const -> QString { return uid_ref_->name; } @@ -49,8 +50,8 @@ auto GpgUID::GetRevoked() const -> bool { return uid_ref_->revoked; } auto GpgUID::GetInvalid() const -> bool { return uid_ref_->invalid; } -auto GpgUID::GetTofuInfos() const -> std::unique_ptr<std::vector<GpgTOFUInfo>> { - auto infos = std::make_unique<std::vector<GpgTOFUInfo>>(); +auto GpgUID::GetTofuInfos() const -> std::unique_ptr<QContainer<GpgTOFUInfo>> { + auto infos = std::make_unique<QContainer<GpgTOFUInfo>>(); auto *info_next = uid_ref_->tofu; while (info_next != nullptr) { infos->push_back(GpgTOFUInfo(info_next)); @@ -60,8 +61,8 @@ auto GpgUID::GetTofuInfos() const -> std::unique_ptr<std::vector<GpgTOFUInfo>> { } auto GpgUID::GetSignatures() const - -> std::unique_ptr<std::vector<GpgKeySignature>> { - auto sigs = std::make_unique<std::vector<GpgKeySignature>>(); + -> std::unique_ptr<QContainer<GpgKeySignature>> { + auto sigs = std::make_unique<QContainer<GpgKeySignature>>(); auto *sig_next = uid_ref_->signatures; while (sig_next != nullptr) { sigs->push_back(GpgKeySignature(sig_next)); diff --git a/src/core/model/GpgUID.h b/src/core/model/GpgUID.h index 316b5c68..d8ac47f2 100644 --- a/src/core/model/GpgUID.h +++ b/src/core/model/GpgUID.h @@ -85,18 +85,18 @@ class GPGFRONTEND_CORE_EXPORT GpgUID { /** * @brief * - * @return std::unique_ptr<std::vector<GpgTOFUInfo>> + * @return std::unique_ptr<QContainer<GpgTOFUInfo>> */ [[nodiscard]] auto GetTofuInfos() const - -> std::unique_ptr<std::vector<GpgTOFUInfo>>; + -> std::unique_ptr<QContainer<GpgTOFUInfo>>; /** * @brief * - * @return std::unique_ptr<std::vector<GpgKeySignature>> + * @return std::unique_ptr<QContainer<GpgKeySignature>> */ [[nodiscard]] auto GetSignatures() const - -> std::unique_ptr<std::vector<GpgKeySignature>>; + -> std::unique_ptr<QContainer<GpgKeySignature>>; /** * @brief Construct a new Gpg U I D object @@ -112,39 +112,20 @@ class GPGFRONTEND_CORE_EXPORT GpgUID { explicit GpgUID(gpgme_user_id_t uid); /** - * @brief Construct a new Gpg U I D object - * - * @param o - */ - GpgUID(GpgUID &&o) noexcept; - - /** - * @brief Construct a new Gpg U I D object - * - */ - GpgUID(const GpgUID &) = delete; - - /** * @brief * - * @param o - * @return GpgUID& */ - auto operator=(GpgUID &&o) noexcept -> GpgUID &; + GpgUID(const GpgUID &); /** * @brief * * @return GpgUID& */ - auto operator=(const GpgUID &) -> GpgUID & = delete; + auto operator=(const GpgUID &) -> GpgUID &; private: - using UidRefHandler = - std::unique_ptr<struct _gpgme_user_id, - std::function<void(gpgme_user_id_t)>>; ///< - - UidRefHandler uid_ref_ = nullptr; ///< + gpgme_user_id_t uid_ref_ = nullptr; ///< }; } // namespace GpgFrontend diff --git a/src/core/model/GpgVerifyResult.cpp b/src/core/model/GpgVerifyResult.cpp index f57900fc..cd232c02 100644 --- a/src/core/model/GpgVerifyResult.cpp +++ b/src/core/model/GpgVerifyResult.cpp @@ -49,8 +49,8 @@ auto GpgVerifyResult::GetRaw() const -> gpgme_verify_result_t { return result_ref_.get(); } -auto GpgVerifyResult::GetSignature() const -> std::vector<GpgSignature> { - std::vector<GpgSignature> sigatures; +auto GpgVerifyResult::GetSignature() const -> QContainer<GpgSignature> { + QContainer<GpgSignature> sigatures; auto* signature = result_ref_->signatures; while (signature != nullptr) { diff --git a/src/core/model/GpgVerifyResult.h b/src/core/model/GpgVerifyResult.h index 95ff10cb..c150d633 100644 --- a/src/core/model/GpgVerifyResult.h +++ b/src/core/model/GpgVerifyResult.h @@ -39,7 +39,7 @@ class GPGFRONTEND_CORE_EXPORT GpgVerifyResult { [[nodiscard]] auto GetRaw() const -> gpgme_verify_result_t; - [[nodiscard]] auto GetSignature() const -> std::vector<GpgSignature>; + [[nodiscard]] auto GetSignature() const -> QContainer<GpgSignature>; explicit GpgVerifyResult(gpgme_verify_result_t); diff --git a/src/core/module/Event.h b/src/core/module/Event.h index 6d3c0106..d37992b7 100644 --- a/src/core/module/Event.h +++ b/src/core/module/Event.h @@ -43,7 +43,7 @@ class Event; using EventReference = std::shared_ptr<Event>; using EventIdentifier = QString; using EventTriggerIdentifier = QString; -using Evnets = std::vector<Event>; +using Evnets = QContainer<Event>; class GPGFRONTEND_CORE_EXPORT Event { public: diff --git a/src/core/module/GlobalRegisterTable.cpp b/src/core/module/GlobalRegisterTable.cpp index 0f29a58a..ae0d3ee9 100644 --- a/src/core/module/GlobalRegisterTable.cpp +++ b/src/core/module/GlobalRegisterTable.cpp @@ -107,10 +107,10 @@ class GlobalRegisterTable::Impl { return rtn; } - auto ListChildKeys(const Namespace& n, const Key& k) -> std::vector<Key> { + auto ListChildKeys(const Namespace& n, const Key& k) -> QContainer<Key> { QStringList const segments = (n + "." + k).split('.'); - std::vector<Key> rtn; + QContainer<Key> rtn; { std::shared_lock lock(lock_); @@ -302,8 +302,7 @@ auto GlobalRegisterTable::ListenPublish(QObject* o, Namespace n, Key k, return p_->ListenPublish(o, n, k, c); } -auto GlobalRegisterTable::ListChildKeys(Namespace n, - Key k) -> std::vector<Key> { +auto GlobalRegisterTable::ListChildKeys(Namespace n, Key k) -> QContainer<Key> { return p_->ListChildKeys(n, k); } diff --git a/src/core/module/GlobalRegisterTable.h b/src/core/module/GlobalRegisterTable.h index 15fab0ce..491f0a87 100644 --- a/src/core/module/GlobalRegisterTable.h +++ b/src/core/module/GlobalRegisterTable.h @@ -33,6 +33,7 @@ #include <optional> #include "core/function/SecureMemoryAllocator.h" +#include "core/typedef/CoreTypedef.h" namespace GpgFrontend::Module { @@ -55,7 +56,7 @@ class GlobalRegisterTable : public QObject { auto ListenPublish(QObject *, Namespace, Key, LPCallback) -> bool; - auto ListChildKeys(Namespace n, Key k) -> std::vector<Key>; + auto ListChildKeys(Namespace n, Key k) -> QContainer<Key>; signals: void SignalPublish(Namespace, Key, int, std::any); diff --git a/src/core/module/ModuleManager.cpp b/src/core/module/ModuleManager.cpp index 8f97adc3..d340a561 100644 --- a/src/core/module/ModuleManager.cpp +++ b/src/core/module/ModuleManager.cpp @@ -220,7 +220,7 @@ class ModuleManager::Impl { return grt_->ListenPublish(o, n, k, c); } - auto ListRTChildKeys(const QString& n, const QString& k) -> std::vector<Key> { + auto ListRTChildKeys(const QString& n, const QString& k) -> QContainer<Key> { return grt_->ListChildKeys(n, k); } @@ -271,7 +271,7 @@ auto ListenRTPublishEvent(QObject* o, Namespace n, Key k, } auto ListRTChildKeys(const QString& namespace_, - const QString& key) -> std::vector<Key> { + const QString& key) -> QContainer<Key> { return ModuleManager::GetInstance().ListRTChildKeys(namespace_, key); } @@ -341,7 +341,7 @@ auto ModuleManager::ListenRTPublish(QObject* o, Namespace n, Key k, } auto ModuleManager::ListRTChildKeys(const QString& n, - const QString& k) -> std::vector<Key> { + const QString& k) -> QContainer<Key> { return p_->ListRTChildKeys(n, k); } diff --git a/src/core/module/ModuleManager.h b/src/core/module/ModuleManager.h index 5c703bf3..3ac35b98 100644 --- a/src/core/module/ModuleManager.h +++ b/src/core/module/ModuleManager.h @@ -101,7 +101,7 @@ class GPGFRONTEND_CORE_EXPORT ModuleManager auto ListenRTPublish(QObject*, Namespace, Key, LPCallback) -> bool; - auto ListRTChildKeys(const QString&, const QString&) -> std::vector<Key>; + auto ListRTChildKeys(const QString&, const QString&) -> QContainer<Key>; auto GRT() -> GlobalRegisterTable*; @@ -175,10 +175,10 @@ auto GPGFRONTEND_CORE_EXPORT ListenRTPublishEvent(QObject*, Namespace, Key, * * @param namespace_ * @param key - * @return std::vector<Key> + * @return QContainer<Key> */ auto GPGFRONTEND_CORE_EXPORT ListRTChildKeys( - const QString& namespace_, const QString& key) -> std::vector<Key>; + const QString& namespace_, const QString& key) -> QContainer<Key>; template <typename T> auto RetrieveRTValueTyped(const QString& namespace_, diff --git a/src/core/typedef/CoreTypedef.h b/src/core/typedef/CoreTypedef.h index 7bc0bc25..7d62cf20 100644 --- a/src/core/typedef/CoreTypedef.h +++ b/src/core/typedef/CoreTypedef.h @@ -28,22 +28,25 @@ #pragma once -#include "core/model/DataObject.h" - namespace GpgFrontend { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +template <typename T> +using QContainer = QVector<T>; +#else +template <typename T> +using QContainer = QList<T>; +#endif + using GFError = uint32_t; -using ByteArray = QByteArray; ///< -using ByteArrayPtr = std::shared_ptr<ByteArray>; ///< -using StdBypeArrayPtr = std::shared_ptr<ByteArray>; ///< -using BypeArrayRef = ByteArray&; ///< -using ConstBypeArrayRef = const ByteArray&; ///< -using BypeArrayConstRef = const ByteArray&; ///< -using StringArgsPtr = std::unique_ptr<std::vector<QString>>; ///< -using StringArgsRef = std::vector<QString>&; ///< - /// - /// +using ByteArray = QByteArray; ///< +using BypeArrayRef = ByteArray&; ///< +using BypeArrayConstRef = const ByteArray&; ///< +using StringArgsPtr = QStringList; ///< +using StringArgsRef = QStringList&; ///< +class DataObject; +using DataObjectPtr = std::shared_ptr<DataObject>; ///< using OperaRunnable = std::function<GFError(DataObjectPtr)>; using OperationCallback = std::function<void(GFError, DataObjectPtr)>; } // namespace GpgFrontend
\ No newline at end of file diff --git a/src/core/typedef/GpgTypedef.h b/src/core/typedef/GpgTypedef.h index ecd5dc3f..41da6900 100644 --- a/src/core/typedef/GpgTypedef.h +++ b/src/core/typedef/GpgTypedef.h @@ -31,6 +31,7 @@ #include <gpgme.h> #include "core/model/DataObject.h" +#include "core/typedef/CoreTypedef.h" namespace GpgFrontend { @@ -41,25 +42,16 @@ class GpgTOFUInfo; using GpgError = gpgme_error_t; ///< gpgme error using GpgErrorCode = gpg_err_code_t; -using GpgErrorDesc = std::pair<QString, QString>; +using GpgErrorDesc = QPair<QString, QString>; -using KeyId = QString; ///< -using SubkeyId = QString; ///< -using KeyIdArgsList = std::vector<KeyId>; ///< -using KeyIdArgsListPtr = std::unique_ptr<KeyIdArgsList>; ///< -using UIDArgsList = std::vector<QString>; ///< -using UIDArgsListPtr = std::unique_ptr<UIDArgsList>; ///< -using SignIdArgsList = std::vector<std::pair<QString, QString>>; ///< -using SignIdArgsListPtr = std::unique_ptr<SignIdArgsList>; ///< -using KeyFprArgsListPtr = std::unique_ptr<std::vector<QString>>; ///< -using KeyArgsList = std::vector<GpgKey>; ///< -using KeyListPtr = std::shared_ptr<KeyArgsList>; ///< -using GpgKeyLinkList = std::list<GpgKey>; ///< -using KeyLinkListPtr = std::unique_ptr<GpgKeyLinkList>; ///< -using KeyPtr = std::unique_ptr<GpgKey>; ///< -using KeyPtrArgsList = const std::initializer_list<KeyPtr>; ///< -using GpgKeyList = QList<GpgKey>; ///< -using GpgKeyIDList = QList<QString>; ///< +using KeyId = QString; +using SubkeyId = QString; +using KeyIdArgsList = QStringList; ///< +using UIDArgsList = QContainer<QString>; ///< +using SignIdArgsList = QContainer<QPair<QString, QString>>; ///< +using KeyArgsList = QContainer<GpgKey>; ///< +using GpgKeyLinkList = QContainer<GpgKey>; ///< +using GpgKeyList = QContainer<GpgKey>; ///< using GpgSignMode = gpgme_sig_mode_t; diff --git a/src/core/utils/CommonUtils.cpp b/src/core/utils/CommonUtils.cpp index 60ce4642..526f5856 100644 --- a/src/core/utils/CommonUtils.cpp +++ b/src/core/utils/CommonUtils.cpp @@ -28,6 +28,8 @@ #include "CommonUtils.h" +#include "core/utils/MemoryUtils.h" + namespace GpgFrontend { auto BeautifyFingerprint(QString fingerprint) -> QString { diff --git a/src/core/utils/GpgUtils.cpp b/src/core/utils/GpgUtils.cpp index 29b150bd..dfedd098 100644 --- a/src/core/utils/GpgUtils.cpp +++ b/src/core/utils/GpgUtils.cpp @@ -36,7 +36,7 @@ namespace GpgFrontend { inline auto Trim(QString& s) -> QString { return s.trimmed(); } auto GetGpgmeErrorString(size_t buffer_size, gpgme_error_t err) -> QString { - std::vector<char> buffer(buffer_size); + QContainer<char> buffer(buffer_size); gpgme_error_t const ret = gpgme_strerror_r(err, buffer.data(), buffer.size()); if (ret == ERANGE && buffer_size < 1024) { |