aboutsummaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/CMakeLists.txt45
-rw-r--r--src/core/GpgConstants.h36
-rw-r--r--src/core/GpgContext.cpp3
-rw-r--r--src/core/GpgContext.h8
-rw-r--r--src/core/GpgCoreInit.cpp49
-rw-r--r--src/core/GpgCoreInit.h6
-rw-r--r--src/core/GpgFrontendCore.h11
-rw-r--r--src/core/GpgGenKeyInfo.h2
-rw-r--r--src/core/GpgModel.h5
-rw-r--r--src/core/common/CoreCommonUtil.cpp40
-rw-r--r--src/core/common/CoreCommonUtil.h63
-rw-r--r--src/core/function/ArchiveFileOperator.h2
-rw-r--r--src/core/function/DataObjectOperator.cpp8
-rw-r--r--src/core/function/DataObjectOperator.h3
-rw-r--r--src/core/function/FileOperator.h2
-rw-r--r--src/core/function/GlobalSettingStation.cpp47
-rw-r--r--src/core/function/GlobalSettingStation.h40
-rw-r--r--src/core/function/KeyPackageOperator.h2
-rw-r--r--src/core/function/PassphraseGenerator.h2
-rw-r--r--src/core/function/gpg/GpgBasicOperator.cpp11
-rw-r--r--src/core/function/gpg/GpgBasicOperator.h6
-rw-r--r--src/core/function/gpg/GpgCommandExecutor.cpp4
-rw-r--r--src/core/function/gpg/GpgCommandExecutor.h5
-rw-r--r--src/core/function/gpg/GpgFileOpera.cpp83
-rw-r--r--src/core/function/gpg/GpgFileOpera.h7
-rw-r--r--src/core/function/gpg/GpgKeyGetter.cpp6
-rw-r--r--src/core/function/gpg/GpgKeyGetter.h6
-rw-r--r--src/core/function/gpg/GpgKeyImportExporter.cpp23
-rw-r--r--src/core/function/gpg/GpgKeyImportExporter.h55
-rw-r--r--src/core/function/gpg/GpgKeyManager.cpp3
-rw-r--r--src/core/function/gpg/GpgKeyManager.h6
-rw-r--r--src/core/function/gpg/GpgKeyOpera.cpp6
-rw-r--r--src/core/function/gpg/GpgKeyOpera.h6
-rw-r--r--src/core/function/gpg/GpgUIDOperator.cpp15
-rw-r--r--src/core/function/gpg/GpgUIDOperator.h11
-rw-r--r--src/core/function/result_analyse/GpgDecryptResultAnalyse.h3
-rw-r--r--src/core/function/result_analyse/GpgEncryptResultAnalyse.h3
-rw-r--r--src/core/function/result_analyse/GpgResultAnalyse.h2
-rw-r--r--src/core/function/result_analyse/GpgSignResultAnalyse.h2
-rw-r--r--src/core/function/result_analyse/GpgVerifyResultAnalyse.h2
-rw-r--r--src/core/model/GpgData.cpp4
-rw-r--r--src/core/model/GpgData.h2
-rw-r--r--src/core/model/GpgKey.cpp123
-rw-r--r--src/core/model/GpgKey.h112
-rw-r--r--src/core/model/GpgKeySignature.cpp62
-rw-r--r--src/core/model/GpgKeySignature.h46
-rw-r--r--src/core/model/GpgSignature.cpp98
-rw-r--r--src/core/model/GpgSignature.h42
-rw-r--r--src/core/model/GpgSubKey.cpp72
-rw-r--r--src/core/model/GpgSubKey.h63
-rw-r--r--src/core/model/GpgTOFUInfo.cpp59
-rw-r--r--src/core/model/GpgTOFUInfo.h44
-rw-r--r--src/core/model/GpgUID.cpp42
-rw-r--r--src/core/model/GpgUID.h43
-rw-r--r--src/core/thread/CtxCheckThread.cpp54
-rw-r--r--src/core/thread/CtxCheckThread.h62
56 files changed, 1059 insertions, 508 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 7903ef80..dde81c0a 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -28,44 +28,45 @@ aux_source_directory(./function/result_analyse GPG_SOURCE)
aux_source_directory(./function/gpg GPG_SOURCE)
aux_source_directory(./function/aes GPG_SOURCE)
aux_source_directory(./function GPG_SOURCE)
+aux_source_directory(./thread GPG_SOURCE)
aux_source_directory(./model GPG_SOURCE)
+aux_source_directory(./common GPG_SOURCE)
aux_source_directory(. GPG_SOURCE)
# define libgpgfrontend_core
-add_library(gpgfrontend_core STATIC ${GPG_SOURCE})
+set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
+add_library(gpgfrontend_core SHARED ${GPG_SOURCE})
+set(_export_file "${CMAKE_CURRENT_SOURCE_DIR}/GpgFrontendCoreExport.h")
+generate_export_header(gpgfrontend_core EXPORT_FILE_NAME "${_export_file}")
set(UTILS_DIR ${CMAKE_SOURCE_DIR}/utils)
set(GPGME_LIB_DIR ${UTILS_DIR}/gpgme/lib)
# link third-party libraries
-target_link_libraries(gpgfrontend_core easyloggingpp config++)
-# link boost libraries
-target_link_libraries(gpgfrontend_core Boost::date_time Boost::system)
+target_link_libraries(gpgfrontend_core config++)
+if (NOT LINUX)
+ target_link_libraries(gpgfrontend_core config++ intl)
+endif ()
+
+# easyloggingpp
+target_include_directories(gpgfrontend_core PUBLIC
+ ${CMAKE_SOURCE_DIR}/third_party/easyloggingpp/src)
+target_sources(gpgfrontend_core PUBLIC
+ ${CMAKE_SOURCE_DIR}/third_party/easyloggingpp/src/easylogging++.cc)
+
# link gnupg libraries
target_link_libraries(gpgfrontend_core gpgme assuan gpg-error)
# link openssl
target_link_libraries(gpgfrontend_core OpenSSL::SSL OpenSSL::Crypto)
# link Qt AES
target_link_libraries(gpgfrontend_core QtAES)
-# link vmime
-if (NOT LINUX)
- # macOS
- target_link_libraries(gpgfrontend_core
- gpgfrontend_vmime intl iconv)
- if (MINGW)
- target_link_libraries(gpgfrontend_core ws2_32)
- endif ()
-else ()
- target_link_libraries(gpgfrontend_core
- gpgfrontend_vmime anl ssl crypto)
-endif ()
+# link boost libraries
+target_link_libraries(gpgfrontend_core ${Boost_LIBRARIES})
+
# link libarchive
-if (MINGW)
- find_library(LIBARCHIVE_LIB libarchive.a)
- target_link_libraries(gpgfrontend_core ${LIBARCHIVE_LIB} b2 expat lz4 zstd bcrypt lzma bz2 z)
-else ()
- target_link_libraries(gpgfrontend_core archive_static)
-endif ()
+target_link_libraries(gpgfrontend_core archive)
+
# link json
target_link_libraries(gpgfrontend_core
nlohmann_json::nlohmann_json)
diff --git a/src/core/GpgConstants.h b/src/core/GpgConstants.h
index 8c6977ac..f3f0c6e6 100644
--- a/src/core/GpgConstants.h
+++ b/src/core/GpgConstants.h
@@ -29,14 +29,14 @@
#ifndef GPG_CONSTANTS_H
#define GPG_CONSTANTS_H
+#include <GpgFrontend.h>
#include <gpgme.h>
#include <cassert>
#include <functional>
-#include <memory>
-#include <string>
-#include "GpgFrontend.h"
+// dll export macro
+#include "GpgFrontendCoreExport.h"
const int RESTART_CODE = 1000; ///<
@@ -74,7 +74,8 @@ using GpgGenKeyResult = std::shared_ptr<struct _gpgme_op_genkey_result>; ///<
* @param result
* @return GpgEncrResult
*/
-GpgEncrResult _new_result(gpgme_encrypt_result_t&& result);
+GPGFRONTEND_CORE_EXPORT GpgEncrResult
+_new_result(gpgme_encrypt_result_t&& result);
/**
* @brief
@@ -82,7 +83,8 @@ GpgEncrResult _new_result(gpgme_encrypt_result_t&& result);
* @param result
* @return GpgDecrResult
*/
-GpgDecrResult _new_result(gpgme_decrypt_result_t&& result);
+GPGFRONTEND_CORE_EXPORT GpgDecrResult
+_new_result(gpgme_decrypt_result_t&& result);
/**
* @brief
@@ -90,7 +92,7 @@ GpgDecrResult _new_result(gpgme_decrypt_result_t&& result);
* @param result
* @return GpgSignResult
*/
-GpgSignResult _new_result(gpgme_sign_result_t&& result);
+GPGFRONTEND_CORE_EXPORT GpgSignResult _new_result(gpgme_sign_result_t&& result);
/**
* @brief
@@ -98,7 +100,8 @@ GpgSignResult _new_result(gpgme_sign_result_t&& result);
* @param result
* @return GpgVerifyResult
*/
-GpgVerifyResult _new_result(gpgme_verify_result_t&& result);
+GPGFRONTEND_CORE_EXPORT GpgVerifyResult
+_new_result(gpgme_verify_result_t&& result);
/**
* @brief
@@ -106,7 +109,8 @@ GpgVerifyResult _new_result(gpgme_verify_result_t&& result);
* @param result
* @return GpgGenKeyResult
*/
-GpgGenKeyResult _new_result(gpgme_genkey_result_t&& result);
+GPGFRONTEND_CORE_EXPORT GpgGenKeyResult
+_new_result(gpgme_genkey_result_t&& result);
// Error Info Printer
@@ -116,7 +120,7 @@ GpgGenKeyResult _new_result(gpgme_genkey_result_t&& result);
* @param err
* @return GpgError
*/
-GpgError check_gpg_error(GpgError err);
+GPGFRONTEND_CORE_EXPORT GpgError check_gpg_error(GpgError err);
/**
* @brief
@@ -125,7 +129,8 @@ GpgError check_gpg_error(GpgError err);
* @param comment
* @return GpgError
*/
-GpgError check_gpg_error(GpgError gpgmeError, const std::string& comment);
+GPGFRONTEND_CORE_EXPORT GpgError check_gpg_error(GpgError gpgmeError,
+ const std::string& comment);
/**
* @brief
@@ -134,7 +139,7 @@ GpgError check_gpg_error(GpgError gpgmeError, const std::string& comment);
* @param predict
* @return gpg_err_code_t
*/
-gpg_err_code_t check_gpg_error_2_err_code(
+GPGFRONTEND_CORE_EXPORT gpg_err_code_t check_gpg_error_2_err_code(
gpgme_error_t err, gpgme_error_t predict = GPG_ERR_NO_ERROR);
// Fingerprint
@@ -145,7 +150,8 @@ gpg_err_code_t check_gpg_error_2_err_code(
* @param fingerprint
* @return std::string
*/
-std::string beautify_fingerprint(BypeArrayConstRef fingerprint);
+GPGFRONTEND_CORE_EXPORT std::string beautify_fingerprint(
+ BypeArrayConstRef fingerprint);
// File Operation
@@ -165,8 +171,8 @@ std::string read_all_data_in_file(const std::string& path);
* @return true
* @return false
*/
-bool write_buffer_to_file(const std::string& path,
- const std::string& out_buffer);
+GPGFRONTEND_CORE_EXPORT bool write_buffer_to_file(
+ const std::string& path, const std::string& out_buffer);
/**
* @brief Get the file extension object
@@ -202,7 +208,7 @@ const int GPGFRONTEND_NON_ASCII_CHANNEL = 2; ///<
* @brief
*
*/
-class GpgConstants {
+class GPGFRONTEND_CORE_EXPORT GpgConstants {
public:
static const char* PGP_CRYPT_BEGIN; ///<
static const char* PGP_CRYPT_END; ///<
diff --git a/src/core/GpgContext.cpp b/src/core/GpgContext.cpp
index 1897202f..0da963ee 100644
--- a/src/core/GpgContext.cpp
+++ b/src/core/GpgContext.cpp
@@ -43,6 +43,9 @@
namespace GpgFrontend {
+GpgContext::GpgContext(int channel)
+ : SingletonFunctionObject<GpgContext>(channel) {}
+
/**
* Constructor
* Set up gpgme-context, set paths to app-run path
diff --git a/src/core/GpgContext.h b/src/core/GpgContext.h
index 7de6bcad..b148fcb5 100644
--- a/src/core/GpgContext.h
+++ b/src/core/GpgContext.h
@@ -56,7 +56,8 @@ struct GpgContextInitArgs {
* @brief
*
*/
-class GpgContext : public SingletonFunctionObject<GpgContext> {
+class GPGFRONTEND_CORE_EXPORT GpgContext
+ : public SingletonFunctionObject<GpgContext> {
public:
/**
* @brief Construct a new Gpg Context object
@@ -70,8 +71,7 @@ class GpgContext : public SingletonFunctionObject<GpgContext> {
*
* @param channel
*/
- explicit GpgContext(int channel)
- : SingletonFunctionObject<GpgContext>(channel) {}
+ explicit GpgContext(int channel);
/**
* @brief Destroy the Gpg Context object
@@ -161,4 +161,4 @@ class GpgContext : public SingletonFunctionObject<GpgContext> {
};
} // namespace GpgFrontend
-#endif // __SGPGMEPP_CONTEXT_H__
+#endif // __SGPGMEPP_CONTEXT_H__ \ No newline at end of file
diff --git a/src/core/GpgCoreInit.cpp b/src/core/GpgCoreInit.cpp
index 6d9963d6..e9b8fcdc 100644
--- a/src/core/GpgCoreInit.cpp
+++ b/src/core/GpgCoreInit.cpp
@@ -28,9 +28,47 @@
#include "GpgCoreInit.h"
-#include "GpgContext.h"
+#include "core/GpgContext.h"
+#include "core/function/GlobalSettingStation.h"
-void GpgFrontend::init_gpgfrontend_core() {
+// init easyloggingpp library
+INITIALIZE_EASYLOGGINGPP
+
+namespace GpgFrontend {
+
+/**
+ * @brief setup logging system and do proper initialization
+ *
+ */
+void init_logging() {
+ using namespace boost::posix_time;
+ using namespace boost::gregorian;
+
+ ptime now = second_clock::local_time();
+
+ el::Loggers::addFlag(el::LoggingFlag::AutoSpacing);
+ el::Configurations defaultConf;
+ defaultConf.setToDefault();
+ el::Loggers::reconfigureLogger("default", defaultConf);
+
+ // apply settings
+ defaultConf.setGlobally(el::ConfigurationType::Format,
+ "%datetime %level %func %msg");
+
+ // get the log directory
+ auto logfile_path =
+ (GlobalSettingStation::GetInstance().GetLogDir() / to_iso_string(now));
+ logfile_path.replace_extension(".log");
+ defaultConf.setGlobally(el::ConfigurationType::Filename,
+ logfile_path.u8string());
+
+ el::Loggers::reconfigureLogger("default", defaultConf);
+
+ LOG(INFO) << _("log file path") << logfile_path;
+}
+
+void init_gpgfrontend_core() {
+ // init default channel
GpgFrontend::GpgContext::CreateInstance(
GPGFRONTEND_DEFAULT_CHANNEL,
[&]() -> std::unique_ptr<GpgFrontend::GpgContext> {
@@ -38,6 +76,7 @@ void GpgFrontend::init_gpgfrontend_core() {
return std::make_unique<GpgFrontend::GpgContext>(args);
});
+ // init non-ascii channel
GpgFrontend::GpgContext::CreateInstance(
GPGFRONTEND_NON_ASCII_CHANNEL,
[&]() -> std::unique_ptr<GpgFrontend::GpgContext> {
@@ -47,10 +86,12 @@ void GpgFrontend::init_gpgfrontend_core() {
});
}
-void GpgFrontend::new_default_settings_channel(int channel) {
+void new_default_settings_channel(int channel) {
GpgFrontend::GpgContext::CreateInstance(
channel, [&]() -> std::unique_ptr<GpgFrontend::GpgContext> {
GpgFrontend::GpgContextInitArgs args;
return std::make_unique<GpgFrontend::GpgContext>(args);
});
-} \ No newline at end of file
+}
+
+} // namespace GpgFrontend \ No newline at end of file
diff --git a/src/core/GpgCoreInit.h b/src/core/GpgCoreInit.h
index 5ac804da..752fe4c3 100644
--- a/src/core/GpgCoreInit.h
+++ b/src/core/GpgCoreInit.h
@@ -37,6 +37,12 @@ namespace GpgFrontend {
* @brief
*
*/
+void init_logging();
+
+/**
+ * @brief
+ *
+ */
void init_gpgfrontend_core();
/**
diff --git a/src/core/GpgFrontendCore.h b/src/core/GpgFrontendCore.h
index 5931695d..90bc36be 100644
--- a/src/core/GpgFrontendCore.h
+++ b/src/core/GpgFrontendCore.h
@@ -32,6 +32,7 @@
#include "GpgFrontend.h"
// std includes
+#include <random>
#include <filesystem>
// boost includes
@@ -40,22 +41,14 @@
// Qt includes
#include <QtCore>
-// vmime includes
-#define VMIME_STATIC
-#undef VMIME_HAVE_MLANG
-#include <vmime/vmime.hpp>
-
// libconfig includes
-#undef LIBCONFIGXX_STATIC
-#define LIBCONFIGXX_STATIC
#include <libconfig.h++>
-
// libarchive includes
#include <libarchive/libarchive/archive.h>
#include <libarchive/libarchive/archive_entry.h>
-#include "core/GpgModel.h"
+#include "GpgConstants.h"
#endif // GPGFRONTEND_GPGFRONTENDCORE_H
diff --git a/src/core/GpgGenKeyInfo.h b/src/core/GpgGenKeyInfo.h
index 59ced710..73dd9680 100644
--- a/src/core/GpgGenKeyInfo.h
+++ b/src/core/GpgGenKeyInfo.h
@@ -39,7 +39,7 @@
namespace GpgFrontend {
-class GenKeyInfo {
+class GPGFRONTEND_CORE_EXPORT GenKeyInfo {
bool standalone_ = false; ///<
bool subkey_ = false; ///<
std::string name_; ///<
diff --git a/src/core/GpgModel.h b/src/core/GpgModel.h
index e3d43332..d8d4e6fe 100644
--- a/src/core/GpgModel.h
+++ b/src/core/GpgModel.h
@@ -29,10 +29,7 @@
#ifndef GPGFRONTEND_ZH_CN_TS_GPGMODEL_H
#define GPGFRONTEND_ZH_CN_TS_GPGMODEL_H
-#include <list>
-#include <utility>
-
-#include "GpgConstants.h"
+#include "core/GpgConstants.h"
#include "core/model/GpgData.h"
#include "core/model/GpgKey.h"
#include "core/model/GpgSignature.h"
diff --git a/src/core/common/CoreCommonUtil.cpp b/src/core/common/CoreCommonUtil.cpp
new file mode 100644
index 00000000..69d26f72
--- /dev/null
+++ b/src/core/common/CoreCommonUtil.cpp
@@ -0,0 +1,40 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#include "CoreCommonUtil.h"
+
+namespace GpgFrontend {
+
+std::unique_ptr<CoreCommonUtil> CoreCommonUtil::instance_ = nullptr; ///<
+
+CoreCommonUtil *CoreCommonUtil::GetInstance() {
+ LOG(INFO) << "called";
+ if (instance_ == nullptr) {
+ instance_ = std::make_unique<CoreCommonUtil>();
+ }
+ return instance_.get();
+}
+} // namespace GpgFrontend
diff --git a/src/core/common/CoreCommonUtil.h b/src/core/common/CoreCommonUtil.h
new file mode 100644
index 00000000..074b4fd3
--- /dev/null
+++ b/src/core/common/CoreCommonUtil.h
@@ -0,0 +1,63 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#ifndef GPGFRONTEND_CORECOMMONUTIL_H
+#define GPGFRONTEND_CORECOMMONUTIL_H
+
+#include "core/GpgFrontendCore.h"
+
+namespace GpgFrontend {
+
+class GPGFRONTEND_CORE_EXPORT CoreCommonUtil : public QObject {
+ Q_OBJECT
+ public:
+ /**
+ * @brief Construct a new Core Common Util object
+ *
+ */
+ static CoreCommonUtil *GetInstance();
+
+ /**
+ * @brief
+ *
+ */
+ CoreCommonUtil() = default;
+
+ signals:
+
+ /**
+ * @brief
+ *
+ */
+ void SignalGnupgNotInstall();
+
+ private:
+ static std::unique_ptr<CoreCommonUtil> instance_; ///<
+};
+
+} // namespace GpgFrontend
+
+#endif // GPGFRONTEND_CORECOMMONUTIL_H
diff --git a/src/core/function/ArchiveFileOperator.h b/src/core/function/ArchiveFileOperator.h
index 324d9d53..28d1ad65 100644
--- a/src/core/function/ArchiveFileOperator.h
+++ b/src/core/function/ArchiveFileOperator.h
@@ -42,7 +42,7 @@ struct ArchiveStruct {
std::string name;
};
-class ArchiveFileOperator {
+class GPGFRONTEND_CORE_EXPORT ArchiveFileOperator {
public:
static void ListArchive(const std::filesystem::path &archive_path);
diff --git a/src/core/function/DataObjectOperator.cpp b/src/core/function/DataObjectOperator.cpp
index 1e216dd6..d5b746d6 100644
--- a/src/core/function/DataObjectOperator.cpp
+++ b/src/core/function/DataObjectOperator.cpp
@@ -29,6 +29,7 @@
#include "DataObjectOperator.h"
#include <qt-aes/qaesencryption.h>
+#include <boost/date_time.hpp>
#include "core/function/FileOperator.h"
#include "core/function/PassphraseGenerator.h"
@@ -65,7 +66,6 @@ GpgFrontend::DataObjectOperator::DataObjectOperator(int channel)
std::string GpgFrontend::DataObjectOperator::SaveDataObj(
const std::string& _key, const nlohmann::json& value) {
-
std::string _hash_obj_key = {};
if (_key.empty()) {
_hash_obj_key =
@@ -92,7 +92,8 @@ std::string GpgFrontend::DataObjectOperator::SaveDataObj(
auto encoded =
encryption.encode(QByteArray::fromStdString(to_string(value)), hash_key_);
- LOG(INFO) << _("Saving data object") << _hash_obj_key << "to" << obj_path << encoded.size() << "bytes";
+ LOG(INFO) << _("Saving data object") << _hash_obj_key << "to" << obj_path
+ << encoded.size() << "bytes";
FileOperator::WriteFileStd(obj_path.u8string(), encoded.toStdString());
@@ -128,7 +129,8 @@ std::optional<nlohmann::json> GpgFrontend::DataObjectOperator::GetDataObject(
QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::ECB,
QAESEncryption::Padding::ISO);
- LOG(INFO) << _("Decrypting data object") << encoded.size() << hash_key_.size();
+ LOG(INFO) << _("Decrypting data object") << encoded.size()
+ << hash_key_.size();
auto decoded =
encryption.removePadding(encryption.decode(encoded, hash_key_));
diff --git a/src/core/function/DataObjectOperator.h b/src/core/function/DataObjectOperator.h
index 0ce4e313..1b52ec32 100644
--- a/src/core/function/DataObjectOperator.h
+++ b/src/core/function/DataObjectOperator.h
@@ -37,7 +37,8 @@
namespace GpgFrontend {
-class DataObjectOperator : public SingletonFunctionObject<DataObjectOperator> {
+class GPGFRONTEND_CORE_EXPORT DataObjectOperator
+ : public SingletonFunctionObject<DataObjectOperator> {
public:
/**
* @brief DataObjectOperator constructor
diff --git a/src/core/function/FileOperator.h b/src/core/function/FileOperator.h
index aa2c3b73..a727b1de 100644
--- a/src/core/function/FileOperator.h
+++ b/src/core/function/FileOperator.h
@@ -37,7 +37,7 @@ namespace GpgFrontend {
* @brief provides file operations
*
*/
-class FileOperator {
+class GPGFRONTEND_CORE_EXPORT FileOperator {
public:
/**
* @brief read file content using std struct
diff --git a/src/core/function/GlobalSettingStation.cpp b/src/core/function/GlobalSettingStation.cpp
index 8850cbe4..db8d1bc3 100644
--- a/src/core/function/GlobalSettingStation.cpp
+++ b/src/core/function/GlobalSettingStation.cpp
@@ -28,12 +28,6 @@
#include "GlobalSettingStation.h"
-#include <openssl/bio.h>
-#include <openssl/pem.h>
-
-#include <vmime/security/cert/openssl/X509Certificate_OpenSSL.hpp>
-#include <vmime/vmime.hpp>
-
#include "core/function/FileOperator.h"
void GpgFrontend::GlobalSettingStation::SyncSettings() noexcept {
@@ -95,47 +89,6 @@ GpgFrontend::GlobalSettingStation::GlobalSettingStation(int channel) noexcept
}
}
-void GpgFrontend::GlobalSettingStation::AddRootCert(
- const std::filesystem::path &path) {
- std::string out_buffer;
- if (!FileOperator::ReadFileStd(path, out_buffer)) {
- LOG(ERROR) << _("Failed to read root certificate file") << path;
- return;
- }
-
- auto mem_bio = std::shared_ptr<BIO>(
- BIO_new_mem_buf(out_buffer.data(), static_cast<int>(out_buffer.size())),
- [](BIO *_p) { BIO_free(_p); });
-
- auto x509 = std::shared_ptr<X509>(
- PEM_read_bio_X509(mem_bio.get(), nullptr, nullptr, nullptr),
- [](X509 *_p) { X509_free(_p); });
-
- if (!x509) return;
-
- root_certs_.push_back(x509);
-}
-
-vmime::shared_ptr<vmime::security::cert::defaultCertificateVerifier>
-GpgFrontend::GlobalSettingStation::GetCertVerifier() const {
- auto p_cv =
- vmime::make_shared<vmime::security::cert::defaultCertificateVerifier>();
-
- std::vector<vmime::shared_ptr<vmime::security::cert::X509Certificate>>
- _root_certs;
- for (const auto &cert : root_certs_) {
- _root_certs.push_back(
- std::make_shared<vmime::security::cert::X509Certificate_OpenSSL>(
- cert.get()));
- }
- return p_cv;
-}
-
-const std::vector<std::shared_ptr<X509>>
- &GpgFrontend::GlobalSettingStation::GetRootCerts() {
- return root_certs_;
-}
-
void GpgFrontend::GlobalSettingStation::init_app_secure_key() {}
GpgFrontend::GlobalSettingStation::~GlobalSettingStation() noexcept = default;
diff --git a/src/core/function/GlobalSettingStation.h b/src/core/function/GlobalSettingStation.h
index d6521c8a..0df6bd21 100644
--- a/src/core/function/GlobalSettingStation.h
+++ b/src/core/function/GlobalSettingStation.h
@@ -38,18 +38,13 @@
#include "core/GpgFrontendCore.h"
#include "core/GpgFunctionObject.h"
-namespace vmime::security::cert {
-class defaultCertificateVerifier;
-class X509Certificate;
-} // namespace vmime::security::cert
-
namespace GpgFrontend {
/**
* @brief
*
*/
-class GlobalSettingStation
+class GPGFRONTEND_CORE_EXPORT GlobalSettingStation
: public SingletonFunctionObject<GlobalSettingStation> {
public:
/**
@@ -146,36 +141,6 @@ class GlobalSettingStation
}
/**
- * @brief Get the Cert Verifier object
- *
- * @return std::shared_ptr<
- * vmime::security::cert::defaultCertificateVerifier>
- */
- [[nodiscard]] std::shared_ptr<
- vmime::security::cert::defaultCertificateVerifier>
- GetCertVerifier() const;
-
- /**
- * @brief
- *
- * @param path
- */
- void AddRootCert(const std::filesystem::path &path);
-
- /**
- * @brief Get the Root Certs object
- *
- * @return const std::vector<std::shared_ptr<X509>>&
- */
- const std::vector<std::shared_ptr<X509>> &GetRootCerts();
-
- /**
- * @brief
- *
- */
- void ResetRootCerts() { root_certs_.clear(); }
-
- /**
* @brief sync the settings to the file
*
*/
@@ -218,8 +183,7 @@ class GlobalSettingStation
std::filesystem::path ui_config_path_ =
ui_config_dir_path_ / "ui.cfg"; ///< UI Configure File Location
- libconfig::Config ui_cfg_; ///<
- std::vector<std::shared_ptr<X509>> root_certs_; ///<
+ libconfig::Config ui_cfg_; ///< UI Configure File
/**
* @brief
diff --git a/src/core/function/KeyPackageOperator.h b/src/core/function/KeyPackageOperator.h
index cd344688..00b0dbaa 100644
--- a/src/core/function/KeyPackageOperator.h
+++ b/src/core/function/KeyPackageOperator.h
@@ -38,7 +38,7 @@ namespace GpgFrontend {
* @brief give the possibility to import or export a key package
*
*/
-class KeyPackageOperator {
+class GPGFRONTEND_CORE_EXPORT KeyPackageOperator {
public:
/**
* @brief generate passphrase for key package and save it to file
diff --git a/src/core/function/PassphraseGenerator.h b/src/core/function/PassphraseGenerator.h
index d1cc7607..a61356fe 100644
--- a/src/core/function/PassphraseGenerator.h
+++ b/src/core/function/PassphraseGenerator.h
@@ -39,7 +39,7 @@ namespace GpgFrontend {
*
* This class is used to generate a passphrase.
*/
-class PassphraseGenerator
+class GPGFRONTEND_CORE_EXPORT PassphraseGenerator
: public SingletonFunctionObject<PassphraseGenerator> {
public:
/**
diff --git a/src/core/function/gpg/GpgBasicOperator.cpp b/src/core/function/gpg/GpgBasicOperator.cpp
index b92404a9..97399b4e 100644
--- a/src/core/function/gpg/GpgBasicOperator.cpp
+++ b/src/core/function/gpg/GpgBasicOperator.cpp
@@ -32,6 +32,9 @@
#include "GpgKeyGetter.h"
+GpgFrontend::GpgBasicOperator::GpgBasicOperator(int channel)
+ : SingletonFunctionObject<GpgBasicOperator>(channel) {}
+
GpgFrontend::GpgError GpgFrontend::GpgBasicOperator::Encrypt(
KeyListPtr keys, GpgFrontend::BypeArrayRef in_buffer,
GpgFrontend::ByteArrayPtr& out_buffer, GpgFrontend::GpgEncrResult& result) {
@@ -95,11 +98,9 @@ GpgFrontend::GpgError GpgFrontend::GpgBasicOperator::Verify(
return err;
}
-GpgFrontend::GpgError GpgFrontend::GpgBasicOperator::Sign(KeyListPtr signers,
- BypeArrayRef in_buffer,
- ByteArrayPtr& out_buffer,
- gpgme_sig_mode_t mode,
- GpgSignResult& result) {
+GpgFrontend::GpgError GpgFrontend::GpgBasicOperator::Sign(
+ KeyListPtr signers, BypeArrayRef in_buffer, ByteArrayPtr& out_buffer,
+ gpgme_sig_mode_t mode, GpgSignResult& result) {
gpgme_error_t err;
// Set Singers of this opera
diff --git a/src/core/function/gpg/GpgBasicOperator.h b/src/core/function/gpg/GpgBasicOperator.h
index 9b9d9f63..696ac9dc 100644
--- a/src/core/function/gpg/GpgBasicOperator.h
+++ b/src/core/function/gpg/GpgBasicOperator.h
@@ -40,7 +40,8 @@ namespace GpgFrontend {
* @brief Basic operation collection
*
*/
-class GpgBasicOperator : public SingletonFunctionObject<GpgBasicOperator> {
+class GPGFRONTEND_CORE_EXPORT GpgBasicOperator
+ : public SingletonFunctionObject<GpgBasicOperator> {
public:
/**
* @brief Construct a new Basic Operator object
@@ -48,8 +49,7 @@ class GpgBasicOperator : public SingletonFunctionObject<GpgBasicOperator> {
* @param channel Channel corresponding to the context
*/
explicit GpgBasicOperator(
- int channel = SingletonFunctionObject::GetDefaultChannel())
- : SingletonFunctionObject<GpgBasicOperator>(channel) {}
+ int channel = SingletonFunctionObject::GetDefaultChannel());
/**
* @brief Call the interface provided by gpgme for encryption operation
diff --git a/src/core/function/gpg/GpgCommandExecutor.cpp b/src/core/function/gpg/GpgCommandExecutor.cpp
index a6a67d08..2292ed0e 100644
--- a/src/core/function/gpg/GpgCommandExecutor.cpp
+++ b/src/core/function/gpg/GpgCommandExecutor.cpp
@@ -26,6 +26,10 @@
*
*/
#include "GpgCommandExecutor.h"
+
+GpgFrontend::GpgCommandExecutor::GpgCommandExecutor(int channel)
+ : SingletonFunctionObject<GpgCommandExecutor>(channel) {}
+
#ifndef WINDOWS
#include <boost/asio.hpp>
#endif
diff --git a/src/core/function/gpg/GpgCommandExecutor.h b/src/core/function/gpg/GpgCommandExecutor.h
index 49baf406..00d9b43d 100644
--- a/src/core/function/gpg/GpgCommandExecutor.h
+++ b/src/core/function/gpg/GpgCommandExecutor.h
@@ -42,7 +42,7 @@ namespace GpgFrontend {
* @brief Extra commands related to GPG
*
*/
-class GpgCommandExecutor : public SingletonFunctionObject<GpgCommandExecutor> {
+class GPGFRONTEND_CORE_EXPORT GpgCommandExecutor : public SingletonFunctionObject<GpgCommandExecutor> {
public:
/**
* @brief Construct a new Gpg Command Executor object
@@ -50,8 +50,7 @@ class GpgCommandExecutor : public SingletonFunctionObject<GpgCommandExecutor> {
* @param channel Corresponding context
*/
explicit GpgCommandExecutor(
- int channel = SingletonFunctionObject::GetDefaultChannel())
- : SingletonFunctionObject<GpgCommandExecutor>(channel) {}
+ int channel = SingletonFunctionObject::GetDefaultChannel());
#ifndef WINDOWS
diff --git a/src/core/function/gpg/GpgFileOpera.cpp b/src/core/function/gpg/GpgFileOpera.cpp
index 25357288..30678cf0 100644
--- a/src/core/function/gpg/GpgFileOpera.cpp
+++ b/src/core/function/gpg/GpgFileOpera.cpp
@@ -30,24 +30,28 @@
#include <memory>
#include <string>
-#include "GpgConstants.h"
#include "GpgBasicOperator.h"
+#include "GpgConstants.h"
#include "function/FileOperator.h"
+GpgFrontend::GpgFileOpera::GpgFileOpera(int channel)
+ : SingletonFunctionObject<GpgFileOpera>(channel) {}
+
GpgFrontend::GpgError GpgFrontend::GpgFileOpera::EncryptFile(
KeyListPtr keys, const std::string& in_path, const std::string& out_path,
GpgEncrResult& result, int _channel) {
-
#ifdef WINDOWS
- auto in_path_std = std::filesystem::path(QString::fromStdString(in_path).toStdU16String());
- auto out_path_std = std::filesystem::path(QString::fromStdString(out_path).toStdU16String());
+ auto in_path_std =
+ std::filesystem::path(QString::fromStdString(in_path).toStdU16String());
+ auto out_path_std =
+ std::filesystem::path(QString::fromStdString(out_path).toStdU16String());
#else
- auto in_path_std = std::filesystem::path(in_path);
- auto out_path_std = std::filesystem::path(out_path);
+ auto in_path_std = std::filesystem::path(in_path);
+ auto out_path_std = std::filesystem::path(out_path);
#endif
std::string in_buffer;
- if(!FileOperator::ReadFileStd(in_path_std, in_buffer)) {
+ if (!FileOperator::ReadFileStd(in_path_std, in_buffer)) {
throw std::runtime_error("read file error");
}
@@ -67,17 +71,18 @@ GpgFrontend::GpgError GpgFrontend::GpgFileOpera::EncryptFile(
GpgFrontend::GpgError GpgFrontend::GpgFileOpera::DecryptFile(
const std::string& in_path, const std::string& out_path,
GpgDecrResult& result) {
-
#ifdef WINDOWS
- auto in_path_std = std::filesystem::path(QString::fromStdString(in_path).toStdU16String());
- auto out_path_std = std::filesystem::path(QString::fromStdString(out_path).toStdU16String());
+ auto in_path_std =
+ std::filesystem::path(QString::fromStdString(in_path).toStdU16String());
+ auto out_path_std =
+ std::filesystem::path(QString::fromStdString(out_path).toStdU16String());
#else
auto in_path_std = std::filesystem::path(in_path);
auto out_path_std = std::filesystem::path(out_path);
#endif
std::string in_buffer;
- if(!FileOperator::ReadFileStd(in_path_std, in_buffer)) {
+ if (!FileOperator::ReadFileStd(in_path_std, in_buffer)) {
throw std::runtime_error("read file error");
}
std::unique_ptr<std::string> out_buffer;
@@ -100,17 +105,18 @@ gpgme_error_t GpgFrontend::GpgFileOpera::SignFile(KeyListPtr keys,
const std::string& out_path,
GpgSignResult& result,
int _channel) {
-
#ifdef WINDOWS
- auto in_path_std = std::filesystem::path(QString::fromStdString(in_path).toStdU16String());
- auto out_path_std = std::filesystem::path(QString::fromStdString(out_path).toStdU16String());
+ auto in_path_std =
+ std::filesystem::path(QString::fromStdString(in_path).toStdU16String());
+ auto out_path_std =
+ std::filesystem::path(QString::fromStdString(out_path).toStdU16String());
#else
auto in_path_std = std::filesystem::path(in_path);
auto out_path_std = std::filesystem::path(out_path);
#endif
std::string in_buffer;
- if(!FileOperator::ReadFileStd(in_path_std, in_buffer)) {
+ if (!FileOperator::ReadFileStd(in_path_std, in_buffer)) {
throw std::runtime_error("read file error");
}
std::unique_ptr<std::string> out_buffer;
@@ -129,17 +135,18 @@ gpgme_error_t GpgFrontend::GpgFileOpera::SignFile(KeyListPtr keys,
gpgme_error_t GpgFrontend::GpgFileOpera::VerifyFile(
const std::string& data_path, const std::string& sign_path,
GpgVerifyResult& result, int _channel) {
-
#ifdef WINDOWS
- auto data_path_std = std::filesystem::path(QString::fromStdString(data_path).toStdU16String());
- auto sign_path_std = std::filesystem::path(QString::fromStdString(sign_path).toStdU16String());
+ auto data_path_std =
+ std::filesystem::path(QString::fromStdString(data_path).toStdU16String());
+ auto sign_path_std =
+ std::filesystem::path(QString::fromStdString(sign_path).toStdU16String());
#else
auto data_path_std = std::filesystem::path(data_path);
auto sign_path_std = std::filesystem::path(sign_path);
#endif
std::string in_buffer;
- if(!FileOperator::ReadFileStd(data_path_std, in_buffer)) {
+ if (!FileOperator::ReadFileStd(data_path_std, in_buffer)) {
throw std::runtime_error("read file error");
}
std::unique_ptr<std::string> sign_buffer = nullptr;
@@ -148,11 +155,10 @@ gpgme_error_t GpgFrontend::GpgFileOpera::VerifyFile(
if (!FileOperator::ReadFileStd(sign_path_std, sign_buffer_str)) {
throw std::runtime_error("read file error");
}
- sign_buffer =
- std::make_unique<std::string>(sign_buffer_str);
+ sign_buffer = std::make_unique<std::string>(sign_buffer_str);
}
- auto err = GpgBasicOperator::GetInstance(_channel).Verify(in_buffer, sign_buffer,
- result);
+ auto err = GpgBasicOperator::GetInstance(_channel).Verify(
+ in_buffer, sign_buffer, result);
return err;
}
@@ -160,17 +166,18 @@ gpg_error_t GpgFrontend::GpgFileOpera::EncryptSignFile(
KeyListPtr keys, KeyListPtr signer_keys, const std::string& in_path,
const std::string& out_path, GpgEncrResult& encr_res,
GpgSignResult& sign_res, int _channel) {
-
#ifdef WINDOWS
- auto in_path_std = std::filesystem::path(QString::fromStdString(in_path).toStdU16String());
- auto out_path_std = std::filesystem::path(QString::fromStdString(out_path).toStdU16String());
+ auto in_path_std =
+ std::filesystem::path(QString::fromStdString(in_path).toStdU16String());
+ auto out_path_std =
+ std::filesystem::path(QString::fromStdString(out_path).toStdU16String());
#else
auto in_path_std = std::filesystem::path(in_path);
auto out_path_std = std::filesystem::path(out_path);
#endif
std::string in_buffer;
- if(!FileOperator::ReadFileStd(in_path_std, in_buffer)) {
+ if (!FileOperator::ReadFileStd(in_path_std, in_buffer)) {
throw std::runtime_error("read file error");
}
std::unique_ptr<std::string> out_buffer = nullptr;
@@ -190,23 +197,24 @@ gpg_error_t GpgFrontend::GpgFileOpera::EncryptSignFile(
gpg_error_t GpgFrontend::GpgFileOpera::DecryptVerifyFile(
const std::string& in_path, const std::string& out_path,
GpgDecrResult& decr_res, GpgVerifyResult& verify_res) {
-
#ifdef WINDOWS
- auto in_path_std = std::filesystem::path(QString::fromStdString(in_path).toStdU16String());
- auto out_path_std = std::filesystem::path(QString::fromStdString(out_path).toStdU16String());
+ auto in_path_std =
+ std::filesystem::path(QString::fromStdString(in_path).toStdU16String());
+ auto out_path_std =
+ std::filesystem::path(QString::fromStdString(out_path).toStdU16String());
#else
auto in_path_std = std::filesystem::path(in_path);
auto out_path_std = std::filesystem::path(out_path);
#endif
std::string in_buffer;
- if(!FileOperator::ReadFileStd(in_path_std, in_buffer)) {
+ if (!FileOperator::ReadFileStd(in_path_std, in_buffer)) {
throw std::runtime_error("read file error");
}
std::unique_ptr<std::string> out_buffer = nullptr;
- auto err = GpgBasicOperator::GetInstance().DecryptVerify(in_buffer, out_buffer,
- decr_res, verify_res);
+ auto err = GpgBasicOperator::GetInstance().DecryptVerify(
+ in_buffer, out_buffer, decr_res, verify_res);
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR)
if (!FileOperator::WriteFileStd(out_path_std, *out_buffer)) {
@@ -218,17 +226,18 @@ gpg_error_t GpgFrontend::GpgFileOpera::DecryptVerifyFile(
unsigned int GpgFrontend::GpgFileOpera::EncryptFileSymmetric(
const std::string& in_path, const std::string& out_path,
GpgFrontend::GpgEncrResult& result, int _channel) {
-
#ifdef WINDOWS
- auto in_path_std = std::filesystem::path(QString::fromStdString(in_path).toStdU16String());
- auto out_path_std = std::filesystem::path(QString::fromStdString(out_path).toStdU16String());
+ auto in_path_std =
+ std::filesystem::path(QString::fromStdString(in_path).toStdU16String());
+ auto out_path_std =
+ std::filesystem::path(QString::fromStdString(out_path).toStdU16String());
#else
auto in_path_std = std::filesystem::path(in_path);
auto out_path_std = std::filesystem::path(out_path);
#endif
std::string in_buffer;
- if(!FileOperator::ReadFileStd(in_path_std, in_buffer)) {
+ if (!FileOperator::ReadFileStd(in_path_std, in_buffer)) {
throw std::runtime_error("read file error");
}
diff --git a/src/core/function/gpg/GpgFileOpera.h b/src/core/function/gpg/GpgFileOpera.h
index f21bf04c..3f223535 100644
--- a/src/core/function/gpg/GpgFileOpera.h
+++ b/src/core/function/gpg/GpgFileOpera.h
@@ -40,11 +40,12 @@ namespace GpgFrontend {
* GpgBasicOperator
* @class class: GpgBasicOperator
*/
-class GpgFileOpera : public SingletonFunctionObject<GpgFileOpera> {
+class GPGFRONTEND_CORE_EXPORT GpgFileOpera
+ : public SingletonFunctionObject<GpgFileOpera> {
public:
+
explicit GpgFileOpera(
- int channel = SingletonFunctionObject::GetDefaultChannel())
- : SingletonFunctionObject<GpgFileOpera>(channel) {}
+ int channel = SingletonFunctionObject::GetDefaultChannel());
/**
* @brief Encrypted file
diff --git a/src/core/function/gpg/GpgKeyGetter.cpp b/src/core/function/gpg/GpgKeyGetter.cpp
index 1a4715e7..cbd40efc 100644
--- a/src/core/function/gpg/GpgKeyGetter.cpp
+++ b/src/core/function/gpg/GpgKeyGetter.cpp
@@ -32,6 +32,9 @@
#include "GpgConstants.h"
+GpgFrontend::GpgKeyGetter::GpgKeyGetter(int channel)
+ : SingletonFunctionObject<GpgKeyGetter>(channel) {}
+
GpgFrontend::GpgKey GpgFrontend::GpgKeyGetter::GetKey(const std::string& fpr) {
gpgme_key_t _p_key = nullptr;
gpgme_get_key(ctx_, fpr.c_str(), &_p_key, 1);
@@ -57,6 +60,9 @@ GpgFrontend::KeyLinkListPtr GpgFrontend::GpgKeyGetter::FetchKey() {
auto keys_list = std::make_unique<GpgKeyLinkList>();
+ LOG(INFO) << "GpgKeyGetter FetchKey"
+ << "ctx address" << ctx_;
+
err = gpgme_op_keylist_start(ctx_, nullptr, 0);
assert(check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR);
diff --git a/src/core/function/gpg/GpgKeyGetter.h b/src/core/function/gpg/GpgKeyGetter.h
index cde027a0..d63238f5 100644
--- a/src/core/function/gpg/GpgKeyGetter.h
+++ b/src/core/function/gpg/GpgKeyGetter.h
@@ -39,7 +39,8 @@ namespace GpgFrontend {
* @brief
*
*/
-class GpgKeyGetter : public SingletonFunctionObject<GpgKeyGetter> {
+class GPGFRONTEND_CORE_EXPORT GpgKeyGetter
+ : public SingletonFunctionObject<GpgKeyGetter> {
public:
/**
* @brief Construct a new Gpg Key Getter object
@@ -47,8 +48,7 @@ class GpgKeyGetter : public SingletonFunctionObject<GpgKeyGetter> {
* @param channel
*/
explicit GpgKeyGetter(
- int channel = SingletonFunctionObject::GetDefaultChannel())
- : SingletonFunctionObject<GpgKeyGetter>(channel) {}
+ int channel = SingletonFunctionObject::GetDefaultChannel());
/**
* @brief Get the Key object
diff --git a/src/core/function/gpg/GpgKeyImportExporter.cpp b/src/core/function/gpg/GpgKeyImportExporter.cpp
index 0f1ebfa2..206282ae 100644
--- a/src/core/function/gpg/GpgKeyImportExporter.cpp
+++ b/src/core/function/gpg/GpgKeyImportExporter.cpp
@@ -31,6 +31,9 @@
#include "GpgConstants.h"
#include "GpgKeyGetter.h"
+GpgFrontend::GpgKeyImportExporter::GpgKeyImportExporter(int channel)
+ : SingletonFunctionObject<GpgKeyImportExporter>(channel) {}
+
/**
* Import key pair
* @param inBuffer input byte array
@@ -176,3 +179,23 @@ bool GpgFrontend::GpgKeyImportExporter::ExportSecretKeyShortest(
std::swap(out_buffer, temp_out_buffer);
return check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR;
}
+
+GpgFrontend::GpgImportInformation::GpgImportInformation() = default;
+
+GpgFrontend::GpgImportInformation::GpgImportInformation(
+ gpgme_import_result_t result) {
+ if (result->unchanged) unchanged = result->unchanged;
+ if (result->considered) considered = result->considered;
+ if (result->no_user_id) no_user_id = result->no_user_id;
+ if (result->imported) imported = result->imported;
+ if (result->imported_rsa) imported_rsa = result->imported_rsa;
+ if (result->unchanged) unchanged = result->unchanged;
+ if (result->new_user_ids) new_user_ids = result->new_user_ids;
+ if (result->new_sub_keys) new_sub_keys = result->new_sub_keys;
+ if (result->new_signatures) new_signatures = result->new_signatures;
+ if (result->new_revocations) new_revocations = result->new_revocations;
+ if (result->secret_read) secret_read = result->secret_read;
+ if (result->secret_imported) secret_imported = result->secret_imported;
+ if (result->secret_unchanged) secret_unchanged = result->secret_unchanged;
+ if (result->not_imported) not_imported = result->not_imported;
+}
diff --git a/src/core/function/gpg/GpgKeyImportExporter.h b/src/core/function/gpg/GpgKeyImportExporter.h
index d7e6deae..7603c17d 100644
--- a/src/core/function/gpg/GpgKeyImportExporter.h
+++ b/src/core/function/gpg/GpgKeyImportExporter.h
@@ -54,45 +54,31 @@ typedef std::list<GpgImportedKey> GpgImportedKeyList; ///<
* @brief
*
*/
-class GpgImportInformation {
+class GPGFRONTEND_CORE_EXPORT GpgImportInformation {
public:
- GpgImportInformation() = default;
+ GpgImportInformation();
/**
* @brief Construct a new Gpg Import Information object
*
* @param result
*/
- explicit GpgImportInformation(gpgme_import_result_t result) {
- if (result->unchanged) unchanged = result->unchanged;
- if (result->considered) considered = result->considered;
- if (result->no_user_id) no_user_id = result->no_user_id;
- if (result->imported) imported = result->imported;
- if (result->imported_rsa) imported_rsa = result->imported_rsa;
- if (result->unchanged) unchanged = result->unchanged;
- if (result->new_user_ids) new_user_ids = result->new_user_ids;
- if (result->new_sub_keys) new_sub_keys = result->new_sub_keys;
- if (result->new_signatures) new_signatures = result->new_signatures;
- if (result->new_revocations) new_revocations = result->new_revocations;
- if (result->secret_read) secret_read = result->secret_read;
- if (result->secret_imported) secret_imported = result->secret_imported;
- if (result->secret_unchanged) secret_unchanged = result->secret_unchanged;
- if (result->not_imported) not_imported = result->not_imported;
- }
-
- int considered = 0; ///<
- int no_user_id = 0; ///<
- int imported = 0; ///<
- int imported_rsa = 0; ///<
- int unchanged = 0; ///<
- int new_user_ids = 0; ///<
- int new_sub_keys = 0; ///<
- int new_signatures = 0; ///<
- int new_revocations = 0; ///<
- int secret_read = 0; ///<
- int secret_imported = 0; ///<
- int secret_unchanged = 0; ///<
- int not_imported = 0; ///<
+ explicit GpgImportInformation(gpgme_import_result_t result);
+
+ int considered = 0; ///<
+ int no_user_id = 0; ///<
+ int imported = 0; ///<
+ int imported_rsa = 0; ///<
+ int unchanged = 0; ///<
+ int new_user_ids = 0; ///<
+ int new_sub_keys = 0; ///<
+ int new_signatures = 0; ///<
+ int new_revocations = 0; ///<
+ int secret_read = 0; ///<
+ int secret_imported = 0; ///<
+ int secret_unchanged = 0; ///<
+ int not_imported = 0; ///<
+
GpgImportedKeyList importedKeys; ///<
};
@@ -100,7 +86,7 @@ class GpgImportInformation {
* @brief
*
*/
-class GpgKeyImportExporter
+class GPGFRONTEND_CORE_EXPORT GpgKeyImportExporter
: public SingletonFunctionObject<GpgKeyImportExporter> {
public:
/**
@@ -109,8 +95,7 @@ class GpgKeyImportExporter
* @param channel
*/
explicit GpgKeyImportExporter(
- int channel = SingletonFunctionObject::GetDefaultChannel())
- : SingletonFunctionObject<GpgKeyImportExporter>(channel) {}
+ int channel = SingletonFunctionObject::GetDefaultChannel());
/**
* @brief
diff --git a/src/core/function/gpg/GpgKeyManager.cpp b/src/core/function/gpg/GpgKeyManager.cpp
index c17df49e..050a8238 100644
--- a/src/core/function/gpg/GpgKeyManager.cpp
+++ b/src/core/function/gpg/GpgKeyManager.cpp
@@ -34,6 +34,9 @@
#include "GpgBasicOperator.h"
#include "GpgKeyGetter.h"
+GpgFrontend::GpgKeyManager::GpgKeyManager(int channel)
+ : SingletonFunctionObject<GpgKeyManager>(channel) {}
+
bool GpgFrontend::GpgKeyManager::SignKey(
const GpgFrontend::GpgKey& target, GpgFrontend::KeyArgsList& keys,
const std::string& uid,
diff --git a/src/core/function/gpg/GpgKeyManager.h b/src/core/function/gpg/GpgKeyManager.h
index 5bcac545..22738594 100644
--- a/src/core/function/gpg/GpgKeyManager.h
+++ b/src/core/function/gpg/GpgKeyManager.h
@@ -39,7 +39,8 @@ namespace GpgFrontend {
* @brief
*
*/
-class GpgKeyManager : public SingletonFunctionObject<GpgKeyManager> {
+class GPGFRONTEND_CORE_EXPORT GpgKeyManager
+ : public SingletonFunctionObject<GpgKeyManager> {
public:
/**
* @brief Construct a new Gpg Key Manager object
@@ -47,8 +48,7 @@ class GpgKeyManager : public SingletonFunctionObject<GpgKeyManager> {
* @param channel
*/
explicit GpgKeyManager(
- int channel = SingletonFunctionObject::GetDefaultChannel())
- : SingletonFunctionObject<GpgKeyManager>(channel) {}
+ int channel = SingletonFunctionObject::GetDefaultChannel());
/**
* @brief Sign a key pair(actually a certain uid)
diff --git a/src/core/function/gpg/GpgKeyOpera.cpp b/src/core/function/gpg/GpgKeyOpera.cpp
index 23dcae9f..e36edfd9 100644
--- a/src/core/function/gpg/GpgKeyOpera.cpp
+++ b/src/core/function/gpg/GpgKeyOpera.cpp
@@ -41,6 +41,10 @@
#include "GpgCommandExecutor.h"
#include "GpgKeyGetter.h"
+GpgFrontend::GpgKeyOpera::GpgKeyOpera(
+ int channel)
+ : SingletonFunctionObject<GpgKeyOpera>(channel) {}
+
/**
* Delete keys
* @param uidList key ids
@@ -178,6 +182,8 @@ GpgFrontend::GpgError GpgFrontend::GpgKeyOpera::GenerateKey(
GpgError err;
+ LOG(INFO) << "ctx version" << ctx_.GetInfo().GnupgVersion;
+
if (ctx_.GetInfo().GnupgVersion >= "2.1.0") {
unsigned int flags = 0;
diff --git a/src/core/function/gpg/GpgKeyOpera.h b/src/core/function/gpg/GpgKeyOpera.h
index 04571c10..703eb824 100644
--- a/src/core/function/gpg/GpgKeyOpera.h
+++ b/src/core/function/gpg/GpgKeyOpera.h
@@ -44,7 +44,8 @@ class GenKeyInfo;
* @brief
*
*/
-class GpgKeyOpera : public SingletonFunctionObject<GpgKeyOpera> {
+class GPGFRONTEND_CORE_EXPORT GpgKeyOpera
+ : public SingletonFunctionObject<GpgKeyOpera> {
public:
/**
* @brief Construct a new Gpg Key Opera object
@@ -52,8 +53,7 @@ class GpgKeyOpera : public SingletonFunctionObject<GpgKeyOpera> {
* @param channel
*/
explicit GpgKeyOpera(
- int channel = SingletonFunctionObject::GetDefaultChannel())
- : SingletonFunctionObject<GpgKeyOpera>(channel) {}
+ int channel = SingletonFunctionObject::GetDefaultChannel());
/**
* @brief
diff --git a/src/core/function/gpg/GpgUIDOperator.cpp b/src/core/function/gpg/GpgUIDOperator.cpp
index dd0c43f6..33c29fa4 100644
--- a/src/core/function/gpg/GpgUIDOperator.cpp
+++ b/src/core/function/gpg/GpgUIDOperator.cpp
@@ -30,8 +30,11 @@
#include "boost/format.hpp"
+GpgFrontend::GpgUIDOperator::GpgUIDOperator(int channel)
+ : SingletonFunctionObject<GpgUIDOperator>(channel) {}
+
bool GpgFrontend::GpgUIDOperator::AddUID(const GpgFrontend::GpgKey& key,
- const std::string& uid) {
+ const std::string& uid) {
auto err = gpgme_op_adduid(ctx_, gpgme_key_t(key), uid.c_str(), 0);
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR)
return true;
@@ -40,7 +43,7 @@ bool GpgFrontend::GpgUIDOperator::AddUID(const GpgFrontend::GpgKey& key,
}
bool GpgFrontend::GpgUIDOperator::RevUID(const GpgFrontend::GpgKey& key,
- const std::string& uid) {
+ const std::string& uid) {
auto err =
check_gpg_error(gpgme_op_revuid(ctx_, gpgme_key_t(key), uid.c_str(), 0));
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR)
@@ -50,7 +53,7 @@ bool GpgFrontend::GpgUIDOperator::RevUID(const GpgFrontend::GpgKey& key,
}
bool GpgFrontend::GpgUIDOperator::SetPrimaryUID(const GpgFrontend::GpgKey& key,
- const std::string& uid) {
+ const std::string& uid) {
auto err = check_gpg_error(gpgme_op_set_uid_flag(
ctx_, gpgme_key_t(key), uid.c_str(), "primary", nullptr));
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR)
@@ -59,9 +62,9 @@ bool GpgFrontend::GpgUIDOperator::SetPrimaryUID(const GpgFrontend::GpgKey& key,
return false;
}
bool GpgFrontend::GpgUIDOperator::AddUID(const GpgFrontend::GpgKey& key,
- const std::string& name,
- const std::string& comment,
- const std::string& email) {
+ const std::string& name,
+ const std::string& comment,
+ const std::string& email) {
LOG(INFO) << "GpgFrontend::UidOperator::AddUID" << name << comment << email;
auto uid = boost::format("%1%(%2%)<%3%>") % name % comment % email;
return AddUID(key, uid.str());
diff --git a/src/core/function/gpg/GpgUIDOperator.h b/src/core/function/gpg/GpgUIDOperator.h
index 479505e5..c4a7d87b 100644
--- a/src/core/function/gpg/GpgUIDOperator.h
+++ b/src/core/function/gpg/GpgUIDOperator.h
@@ -37,11 +37,16 @@ namespace GpgFrontend {
* @brief
*
*/
-class GpgUIDOperator : public SingletonFunctionObject<GpgUIDOperator> {
+class GPGFRONTEND_CORE_EXPORT GpgUIDOperator
+ : public SingletonFunctionObject<GpgUIDOperator> {
public:
+ /**
+ * @brief Construct a new Gpg UID Opera object
+ *
+ * @param channel
+ */
explicit GpgUIDOperator(
- int channel = SingletonFunctionObject::GetDefaultChannel())
- : SingletonFunctionObject<GpgUIDOperator>(channel) {}
+ int channel = SingletonFunctionObject::GetDefaultChannel());
/**
* create a new uid in certain key pair
diff --git a/src/core/function/result_analyse/GpgDecryptResultAnalyse.h b/src/core/function/result_analyse/GpgDecryptResultAnalyse.h
index af42f995..1fc08d1f 100644
--- a/src/core/function/result_analyse/GpgDecryptResultAnalyse.h
+++ b/src/core/function/result_analyse/GpgDecryptResultAnalyse.h
@@ -38,7 +38,8 @@ namespace GpgFrontend {
* @brief
*
*/
-class GpgDecryptResultAnalyse : public GpgResultAnalyse {
+class GPGFRONTEND_CORE_EXPORT GpgDecryptResultAnalyse
+ : public GpgResultAnalyse {
public:
/**
* @brief Construct a new Decrypt Result Analyse object
diff --git a/src/core/function/result_analyse/GpgEncryptResultAnalyse.h b/src/core/function/result_analyse/GpgEncryptResultAnalyse.h
index c5125fdc..6811ef06 100644
--- a/src/core/function/result_analyse/GpgEncryptResultAnalyse.h
+++ b/src/core/function/result_analyse/GpgEncryptResultAnalyse.h
@@ -37,7 +37,8 @@ namespace GpgFrontend {
* @brief
*
*/
-class GpgEncryptResultAnalyse : public GpgResultAnalyse {
+class GPGFRONTEND_CORE_EXPORT GpgEncryptResultAnalyse
+ : public GpgResultAnalyse {
public:
/**
* @brief Construct a new Encrypt Result Analyse object
diff --git a/src/core/function/result_analyse/GpgResultAnalyse.h b/src/core/function/result_analyse/GpgResultAnalyse.h
index 888c6449..e609505f 100644
--- a/src/core/function/result_analyse/GpgResultAnalyse.h
+++ b/src/core/function/result_analyse/GpgResultAnalyse.h
@@ -34,7 +34,7 @@
#include "core/GpgConstants.h"
namespace GpgFrontend {
-class GpgResultAnalyse {
+class GPGFRONTEND_CORE_EXPORT GpgResultAnalyse {
public:
/**
* @brief Construct a new Result Analyse object
diff --git a/src/core/function/result_analyse/GpgSignResultAnalyse.h b/src/core/function/result_analyse/GpgSignResultAnalyse.h
index d593b33d..43a78942 100644
--- a/src/core/function/result_analyse/GpgSignResultAnalyse.h
+++ b/src/core/function/result_analyse/GpgSignResultAnalyse.h
@@ -37,7 +37,7 @@ namespace GpgFrontend {
* @brief
*
*/
-class GpgSignResultAnalyse : public GpgResultAnalyse {
+class GPGFRONTEND_CORE_EXPORT GpgSignResultAnalyse : public GpgResultAnalyse {
public:
/**
* @brief Construct a new Sign Result Analyse object
diff --git a/src/core/function/result_analyse/GpgVerifyResultAnalyse.h b/src/core/function/result_analyse/GpgVerifyResultAnalyse.h
index 12e4b7ff..ce8e03ad 100644
--- a/src/core/function/result_analyse/GpgVerifyResultAnalyse.h
+++ b/src/core/function/result_analyse/GpgVerifyResultAnalyse.h
@@ -37,7 +37,7 @@ namespace GpgFrontend {
* @brief
*
*/
-class GpgVerifyResultAnalyse : public GpgResultAnalyse {
+class GPGFRONTEND_CORE_EXPORT GpgVerifyResultAnalyse : public GpgResultAnalyse {
public:
/**
* @brief Construct a new Verify Result Analyse object
diff --git a/src/core/model/GpgData.cpp b/src/core/model/GpgData.cpp
index 7fda4416..5aa95dc6 100644
--- a/src/core/model/GpgData.cpp
+++ b/src/core/model/GpgData.cpp
@@ -73,4 +73,6 @@ GpgFrontend::ByteArrayPtr GpgFrontend::GpgData::Read2Buffer() {
}
}
return out_buffer;
-} \ No newline at end of file
+}
+
+GpgFrontend::GpgData::operator gpgme_data_t() { return data_ref_.get(); } \ No newline at end of file
diff --git a/src/core/model/GpgData.h b/src/core/model/GpgData.h
index c06f78d6..816465d3 100644
--- a/src/core/model/GpgData.h
+++ b/src/core/model/GpgData.h
@@ -58,7 +58,7 @@ class GpgData {
*
* @return gpgme_data_t
*/
- operator gpgme_data_t() { return data_ref_.get(); }
+ operator gpgme_data_t();
/**
* @brief
diff --git a/src/core/model/GpgKey.cpp b/src/core/model/GpgKey.cpp
index b0952cfa..4b9d11d3 100644
--- a/src/core/model/GpgKey.cpp
+++ b/src/core/model/GpgKey.cpp
@@ -37,6 +37,118 @@ GpgFrontend::GpgKey &GpgFrontend::GpgKey::operator=(GpgKey &&k) noexcept {
return *this;
}
+bool GpgFrontend::GpgKey::operator==(const GpgKey &o) const {
+ return o.GetId() == this->GetId();
+}
+
+bool GpgFrontend::GpgKey::operator<=(const GpgKey &o) const {
+ return this->GetId() < o.GetId();
+}
+
+GpgFrontend::GpgKey::operator gpgme_key_t() const {
+ return key_ref_.get();
+}
+
+bool GpgFrontend::GpgKey::IsGood() const { return key_ref_ != nullptr; }
+
+std::string GpgFrontend::GpgKey::GetId() const {
+ return key_ref_->subkeys->keyid;
+}
+
+std::string GpgFrontend::GpgKey::GetName() const {
+ return key_ref_->uids->name;
+};
+
+std::string GpgFrontend::GpgKey::GetEmail() const {
+ return key_ref_->uids->email;
+}
+
+std::string GpgFrontend::GpgKey::GetComment() const {
+ return key_ref_->uids->comment;
+}
+
+std::string GpgFrontend::GpgKey::GetFingerprint() const {
+ return key_ref_->fpr;
+}
+
+std::string GpgFrontend::GpgKey::GetProtocol() const {
+ return gpgme_get_protocol_name(key_ref_->protocol);
+}
+
+std::string GpgFrontend::GpgKey::GetOwnerTrust() const {
+ switch (key_ref_->owner_trust) {
+ case GPGME_VALIDITY_UNKNOWN:
+ return "Unknown";
+ case GPGME_VALIDITY_UNDEFINED:
+ return "Undefined";
+ case GPGME_VALIDITY_NEVER:
+ return "Never";
+ case GPGME_VALIDITY_MARGINAL:
+ return "Marginal";
+ case GPGME_VALIDITY_FULL:
+ return "FULL";
+ case GPGME_VALIDITY_ULTIMATE:
+ return "Ultimate";
+ }
+ return "Invalid";
+}
+
+std::string GpgFrontend::GpgKey::GetPublicKeyAlgo() const {
+ return gpgme_pubkey_algo_name(key_ref_->subkeys->pubkey_algo);
+}
+
+boost::posix_time::ptime GpgFrontend::GpgKey::GetLastUpdateTime() const {
+ return boost::posix_time::from_time_t(
+ static_cast<time_t>(key_ref_->last_update));
+}
+
+boost::posix_time::ptime GpgFrontend::GpgKey::GetExpireTime() const {
+ return boost::posix_time::from_time_t(key_ref_->subkeys->expires);
+};
+
+boost::posix_time::ptime GpgFrontend::GpgKey::GetCreateTime() const {
+ return boost::posix_time::from_time_t(key_ref_->subkeys->timestamp);
+};
+
+unsigned int GpgFrontend::GpgKey::GetPrimaryKeyLength() const {
+ return key_ref_->subkeys->length;
+}
+
+bool GpgFrontend::GpgKey::IsHasEncryptionCapability() const {
+ return key_ref_->can_encrypt;
+}
+
+bool GpgFrontend::GpgKey::IsHasSigningCapability() const {
+ return key_ref_->can_sign;
+}
+
+bool GpgFrontend::GpgKey::IsHasCertificationCapability() const {
+ return key_ref_->can_certify;
+}
+
+bool GpgFrontend::GpgKey::IsHasAuthenticationCapability() const {
+ return key_ref_->can_authenticate;
+}
+
+bool GpgFrontend::GpgKey::IsHasCardKey() const {
+ auto subkeys = GetSubKeys();
+ return std::any_of(
+ subkeys->begin(), subkeys->end(),
+ [](const GpgSubKey &subkey) -> bool { return subkey.IsCardKey(); });
+}
+
+bool GpgFrontend::GpgKey::IsPrivateKey() const { return key_ref_->secret; }
+
+bool GpgFrontend::GpgKey::IsExpired() const { return key_ref_->expired; }
+
+bool GpgFrontend::GpgKey::IsRevoked() const { return key_ref_->revoked; }
+
+bool GpgFrontend::GpgKey::IsDisabled() const { return key_ref_->disabled; }
+
+bool GpgFrontend::GpgKey::IsHasMasterKey() const {
+ return key_ref_->subkeys->secret;
+}
+
std::unique_ptr<std::vector<GpgFrontend::GpgSubKey>>
GpgFrontend::GpgKey::GetSubKeys() const {
auto p_keys = std::make_unique<std::vector<GpgSubKey>>();
@@ -113,3 +225,14 @@ bool GpgFrontend::GpgKey::IsHasActualEncryptionCapability() const {
else
return false;
}
+
+
+GpgFrontend::GpgKey GpgFrontend::GpgKey::Copy() const {
+ gpgme_key_ref(key_ref_.get());
+ auto* _new_key_ref = key_ref_.get();
+ return GpgKey(std::move(_new_key_ref));
+}
+
+void GpgFrontend::GpgKey::_key_ref_deleter::operator()(gpgme_key_t _key) {
+ if (_key != nullptr) gpgme_key_unref(_key);
+}
diff --git a/src/core/model/GpgKey.h b/src/core/model/GpgKey.h
index 14315d4c..457b6540 100644
--- a/src/core/model/GpgKey.h
+++ b/src/core/model/GpgKey.h
@@ -41,7 +41,7 @@ namespace GpgFrontend {
* @brief
*
*/
-class GpgKey {
+class GPGFRONTEND_CORE_EXPORT GpgKey {
public:
/**
* @brief
@@ -49,122 +49,91 @@ class GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsGood() const { return key_ref_ != nullptr; }
+ [[nodiscard]] bool IsGood() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetId() const { return key_ref_->subkeys->keyid; }
+ [[nodiscard]] std::string GetId() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetName() const { return key_ref_->uids->name; };
+ [[nodiscard]] std::string GetName() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetEmail() const { return key_ref_->uids->email; }
+ [[nodiscard]] std::string GetEmail() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetComment() const {
- return key_ref_->uids->comment;
- }
+ [[nodiscard]] std::string GetComment() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetFingerprint() const { return key_ref_->fpr; }
+ [[nodiscard]] std::string GetFingerprint() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetProtocol() const {
- return gpgme_get_protocol_name(key_ref_->protocol);
- }
+ [[nodiscard]] std::string GetProtocol() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetOwnerTrust() const {
- switch (key_ref_->owner_trust) {
- case GPGME_VALIDITY_UNKNOWN:
- return "Unknown";
- case GPGME_VALIDITY_UNDEFINED:
- return "Undefined";
- case GPGME_VALIDITY_NEVER:
- return "Never";
- case GPGME_VALIDITY_MARGINAL:
- return "Marginal";
- case GPGME_VALIDITY_FULL:
- return "FULL";
- case GPGME_VALIDITY_ULTIMATE:
- return "Ultimate";
- }
- return "Invalid";
- }
+ [[nodiscard]] std::string GetOwnerTrust() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetPublicKeyAlgo() const {
- return gpgme_pubkey_algo_name(key_ref_->subkeys->pubkey_algo);
- }
+ [[nodiscard]] std::string GetPublicKeyAlgo() const;
/**
* @brief
*
* @return boost::posix_time::ptime
*/
- [[nodiscard]] boost::posix_time::ptime GetLastUpdateTime() const {
- return boost::posix_time::from_time_t(
- static_cast<time_t>(key_ref_->last_update));
- }
+ [[nodiscard]] boost::posix_time::ptime GetLastUpdateTime() const;
/**
* @brief
*
* @return boost::posix_time::ptime
*/
- [[nodiscard]] boost::posix_time::ptime GetExpireTime() const {
- return boost::posix_time::from_time_t(key_ref_->subkeys->expires);
- };
+ [[nodiscard]] boost::posix_time::ptime GetExpireTime() const;
/**
* @brief Create a time object
*
* @return boost::posix_time::ptime
*/
- [[nodiscard]] boost::posix_time::ptime GetCreateTime() const {
- return boost::posix_time::from_time_t(key_ref_->subkeys->timestamp);
- };
+ [[nodiscard]] boost::posix_time::ptime GetCreateTime() const;
/**
* @brief s
*
* @return unsigned int
*/
- [[nodiscard]] unsigned int GetPrimaryKeyLength() const {
- return key_ref_->subkeys->length;
- }
+ [[nodiscard]] unsigned int GetPrimaryKeyLength() const;
/**
* @brief
@@ -172,9 +141,7 @@ class GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasEncryptionCapability() const {
- return key_ref_->can_encrypt;
- }
+ [[nodiscard]] bool IsHasEncryptionCapability() const;
/**
* @brief
@@ -191,9 +158,7 @@ class GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasSigningCapability() const {
- return key_ref_->can_sign;
- }
+ [[nodiscard]] bool IsHasSigningCapability() const;
/**
* @brief
@@ -209,9 +174,7 @@ class GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasCertificationCapability() const {
- return key_ref_->can_certify;
- }
+ [[nodiscard]] bool IsHasCertificationCapability() const;
/**
* @brief
@@ -227,9 +190,7 @@ class GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasAuthenticationCapability() const {
- return key_ref_->can_authenticate;
- }
+ [[nodiscard]] bool IsHasAuthenticationCapability() const;
/**
* @brief
@@ -245,12 +206,7 @@ class GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasCardKey() const {
- auto subkeys = GetSubKeys();
- return std::any_of(
- subkeys->begin(), subkeys->end(),
- [](const GpgSubKey& subkey) -> bool { return subkey.IsCardKey(); });
- }
+ [[nodiscard]] bool IsHasCardKey() const;
/**
* @brief
@@ -258,7 +214,7 @@ class GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsPrivateKey() const { return key_ref_->secret; }
+ [[nodiscard]] bool IsPrivateKey() const;
/**
* @brief
@@ -266,7 +222,7 @@ class GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsExpired() const { return key_ref_->expired; }
+ [[nodiscard]] bool IsExpired() const;
/**
* @brief
@@ -274,7 +230,7 @@ class GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsRevoked() const { return key_ref_->revoked; }
+ [[nodiscard]] bool IsRevoked() const;
/**
* @brief
@@ -282,7 +238,7 @@ class GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsDisabled() const { return key_ref_->disabled; }
+ [[nodiscard]] bool IsDisabled() const;
/**
* @brief
@@ -290,9 +246,7 @@ class GpgKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasMasterKey() const {
- return key_ref_->subkeys->secret;
- }
+ [[nodiscard]] bool IsHasMasterKey() const;
/**
* @brief
@@ -364,7 +318,7 @@ class GpgKey {
* @return true
* @return false
*/
- bool operator==(const GpgKey& o) const { return o.GetId() == this->GetId(); }
+ bool operator==(const GpgKey& o) const;
/**
* @brief
@@ -373,35 +327,29 @@ class GpgKey {
* @return true
* @return false
*/
- bool operator<=(const GpgKey& o) const { return this->GetId() < o.GetId(); }
+ bool operator<=(const GpgKey& o) const;
/**
* @brief
*
* @return gpgme_key_t
*/
- explicit operator gpgme_key_t() const { return key_ref_.get(); }
+ explicit operator gpgme_key_t() const;
/**
* @brief
*
* @return GpgKey
*/
- [[nodiscard]] GpgKey Copy() const {
- gpgme_key_ref(key_ref_.get());
- auto* _new_key_ref = key_ref_.get();
- return GpgKey(std::move(_new_key_ref));
- }
+ [[nodiscard]] GpgKey Copy() const;
private:
/**
* @brief
*
*/
- struct _key_ref_deleter {
- void operator()(gpgme_key_t _key) {
- if (_key != nullptr) gpgme_key_unref(_key);
- }
+ struct GPGFRONTEND_CORE_EXPORT _key_ref_deleter {
+ void operator()(gpgme_key_t _key);
};
using KeyRefHandler =
diff --git a/src/core/model/GpgKeySignature.cpp b/src/core/model/GpgKeySignature.cpp
index 0c11a93b..aa196391 100644
--- a/src/core/model/GpgKeySignature.cpp
+++ b/src/core/model/GpgKeySignature.cpp
@@ -28,5 +28,67 @@
#include "core/model/GpgKeySignature.h"
+GpgFrontend::GpgKeySignature::GpgKeySignature() = default;
+
+GpgFrontend::GpgKeySignature::~GpgKeySignature() = default;
+
GpgFrontend::GpgKeySignature::GpgKeySignature(gpgme_key_sig_t sig)
: signature_ref_(sig, [&](gpgme_key_sig_t signature) {}) {}
+
+GpgFrontend::GpgKeySignature::GpgKeySignature(GpgKeySignature &&) noexcept =
+ default;
+
+GpgFrontend::GpgKeySignature &GpgFrontend::GpgKeySignature::operator=(
+ GpgKeySignature &&) noexcept = default;
+
+bool GpgFrontend::GpgKeySignature::IsRevoked() const {
+ return signature_ref_->revoked;
+}
+
+bool GpgFrontend::GpgKeySignature::IsExpired() const {
+ return signature_ref_->expired;
+}
+
+bool GpgFrontend::GpgKeySignature::IsInvalid() const {
+ return signature_ref_->invalid;
+}
+
+bool GpgFrontend::GpgKeySignature::IsExportable() const {
+ return signature_ref_->exportable;
+}
+
+gpgme_error_t GpgFrontend::GpgKeySignature::GetStatus() const {
+ return signature_ref_->status;
+}
+
+std::string GpgFrontend::GpgKeySignature::GetKeyID() const {
+ return signature_ref_->keyid;
+}
+
+std::string GpgFrontend::GpgKeySignature::GetPubkeyAlgo() const {
+ return gpgme_pubkey_algo_name(signature_ref_->pubkey_algo);
+}
+
+boost::posix_time::ptime GpgFrontend::GpgKeySignature::GetCreateTime() const {
+ return boost::posix_time::from_time_t(signature_ref_->timestamp);
+}
+
+boost::posix_time::ptime GpgFrontend::GpgKeySignature::GetExpireTime() const {
+ return boost::posix_time::from_time_t(signature_ref_->expires);
+}
+
+std::string GpgFrontend::GpgKeySignature::GetUID() const {
+ return signature_ref_->uid;
+}
+
+std::string GpgFrontend::GpgKeySignature::GetName() const {
+ return signature_ref_->name;
+}
+
+std::string GpgFrontend::GpgKeySignature::GetEmail() const {
+ return signature_ref_->email;
+}
+
+std::string GpgFrontend::GpgKeySignature::GetComment() const {
+ return signature_ref_->comment;
+} \ No newline at end of file
diff --git a/src/core/model/GpgKeySignature.h b/src/core/model/GpgKeySignature.h
index 33b84904..25de2c75 100644
--- a/src/core/model/GpgKeySignature.h
+++ b/src/core/model/GpgKeySignature.h
@@ -44,7 +44,7 @@ namespace GpgFrontend {
* @brief
*
*/
-class GpgKeySignature {
+class GPGFRONTEND_CORE_EXPORT GpgKeySignature {
public:
/**
* @brief
@@ -52,7 +52,7 @@ class GpgKeySignature {
* @return true
* @return false
*/
- [[nodiscard]] bool IsRevoked() const { return signature_ref_->revoked; }
+ [[nodiscard]] bool IsRevoked() const;
/**
* @brief
@@ -60,7 +60,7 @@ class GpgKeySignature {
* @return true
* @return false
*/
- [[nodiscard]] bool IsExpired() const { return signature_ref_->expired; }
+ [[nodiscard]] bool IsExpired() const;
/**
* @brief
@@ -68,7 +68,7 @@ class GpgKeySignature {
* @return true
* @return false
*/
- [[nodiscard]] bool IsInvalid() const { return signature_ref_->invalid; }
+ [[nodiscard]] bool IsInvalid() const;
/**
* @brief
@@ -76,92 +76,82 @@ class GpgKeySignature {
* @return true
* @return false
*/
- [[nodiscard]] bool IsExportable() const { return signature_ref_->exportable; }
+ [[nodiscard]] bool IsExportable() const;
/**
* @brief
*
* @return gpgme_error_t
*/
- [[nodiscard]] gpgme_error_t GetStatus() const {
- return signature_ref_->status;
- }
+ [[nodiscard]] gpgme_error_t GetStatus() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetKeyID() const { return signature_ref_->keyid; }
+ [[nodiscard]] std::string GetKeyID() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetPubkeyAlgo() const {
- return gpgme_pubkey_algo_name(signature_ref_->pubkey_algo);
- }
+ [[nodiscard]] std::string GetPubkeyAlgo() const;
/**
* @brief Create a time object
*
* @return boost::posix_time::ptime
*/
- [[nodiscard]] boost::posix_time::ptime GetCreateTime() const {
- return boost::posix_time::from_time_t(signature_ref_->timestamp);
- }
+ [[nodiscard]] boost::posix_time::ptime GetCreateTime() const;
/**
* @brief
*
* @return boost::posix_time::ptime
*/
- [[nodiscard]] boost::posix_time::ptime GetExpireTime() const {
- return boost::posix_time::from_time_t(signature_ref_->expires);
- }
+ [[nodiscard]] boost::posix_time::ptime GetExpireTime() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetUID() const { return signature_ref_->uid; }
+ [[nodiscard]] std::string GetUID() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetName() const { return signature_ref_->name; }
+ [[nodiscard]] std::string GetName() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetEmail() const { return signature_ref_->email; }
+ [[nodiscard]] std::string GetEmail() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetComment() const {
- return signature_ref_->comment;
- }
+ [[nodiscard]] std::string GetComment() const;
/**
* @brief Construct a new Gpg Key Signature object
*
*/
- GpgKeySignature() = default;
+ GpgKeySignature();
/**
* @brief Destroy the Gpg Key Signature object
*
*/
- ~GpgKeySignature() = default;
+ ~GpgKeySignature();
/**
* @brief Construct a new Gpg Key Signature object
@@ -174,7 +164,7 @@ class GpgKeySignature {
* @brief Construct a new Gpg Key Signature object
*
*/
- GpgKeySignature(GpgKeySignature &&) noexcept = default;
+ GpgKeySignature(GpgKeySignature &&) noexcept;
/**
* @brief Construct a new Gpg Key Signature object
@@ -187,7 +177,7 @@ class GpgKeySignature {
*
* @return GpgKeySignature&
*/
- GpgKeySignature &operator=(GpgKeySignature &&) noexcept = default;
+ GpgKeySignature &operator=(GpgKeySignature &&) noexcept;
/**
* @brief
diff --git a/src/core/model/GpgSignature.cpp b/src/core/model/GpgSignature.cpp
index f8084442..73f9179d 100644
--- a/src/core/model/GpgSignature.cpp
+++ b/src/core/model/GpgSignature.cpp
@@ -28,5 +28,103 @@
#include "GpgSignature.h"
+/**
+ * @brief Construct a new Gpg Signature object
+ *
+ */
+GpgFrontend::GpgSignature::GpgSignature(GpgSignature &&) noexcept = default;
+
+/**
+ * @brief
+ *
+ * @return GpgSignature&
+ */
+GpgFrontend::GpgSignature &GpgFrontend::GpgSignature::operator=(
+ GpgFrontend::GpgSignature &&) noexcept = default;
+
GpgFrontend::GpgSignature::GpgSignature(gpgme_signature_t sig)
: signature_ref_(sig, [&](gpgme_signature_t signature) {}) {}
+
+/**
+ * @brief
+ *
+ * @return gpgme_validity_t
+ */
+gpgme_validity_t GpgFrontend::GpgSignature::GetValidity() const {
+ return signature_ref_->validity;
+}
+
+/**
+ * @brief
+ *
+ * @return gpgme_error_t
+ */
+gpgme_error_t GpgFrontend::GpgSignature::GetStatus() const {
+ return signature_ref_->status;
+}
+
+/**
+ * @brief
+ *
+ * @return gpgme_error_t
+ */
+gpgme_error_t GpgFrontend::GpgSignature::GetSummary() const {
+ return signature_ref_->summary;
+}
+
+/**
+ * @brief
+ *
+ * @return std::string
+ */
+std::string GpgFrontend::GpgSignature::GetPubkeyAlgo() const {
+ return gpgme_pubkey_algo_name(signature_ref_->pubkey_algo);
+}
+
+/**
+ * @brief
+ *
+ * @return std::string
+ */
+std::string GpgFrontend::GpgSignature::GetHashAlgo() const {
+ return gpgme_hash_algo_name(signature_ref_->hash_algo);
+}
+
+/**
+ * @brief Create a time object
+ *
+ * @return boost::posix_time::ptime
+ */
+boost::posix_time::ptime GpgFrontend::GpgSignature::GetCreateTime() const {
+ return boost::posix_time::from_time_t(signature_ref_->timestamp);
+}
+
+/**
+ * @brief
+ *
+ * @return boost::posix_time::ptime
+ */
+boost::posix_time::ptime GpgFrontend::GpgSignature::GetExpireTime() const {
+ return boost::posix_time::from_time_t(signature_ref_->exp_timestamp);
+}
+
+/**
+ * @brief
+ *
+ * @return std::string
+ */
+std::string GpgFrontend::GpgSignature::GetFingerprint() const {
+ return signature_ref_->fpr;
+}
+
+/**
+ * @brief Construct a new Gpg Signature object
+ *
+ */
+GpgFrontend::GpgSignature::GpgSignature() = default;
+
+/**
+ * @brief Destroy the Gpg Signature object
+ *
+ */
+GpgFrontend::GpgSignature::~GpgSignature() = default;
diff --git a/src/core/model/GpgSignature.h b/src/core/model/GpgSignature.h
index 942f0097..2e49c4d7 100644
--- a/src/core/model/GpgSignature.h
+++ b/src/core/model/GpgSignature.h
@@ -40,91 +40,75 @@ namespace GpgFrontend {
* @brief
*
*/
-class GpgSignature {
+class GPGFRONTEND_CORE_EXPORT GpgSignature {
public:
/**
* @brief
*
* @return gpgme_validity_t
*/
- [[nodiscard]] gpgme_validity_t GetValidity() const {
- return signature_ref_->validity;
- }
+ [[nodiscard]] gpgme_validity_t GetValidity() const;
/**
* @brief
*
* @return gpgme_error_t
*/
- [[nodiscard]] gpgme_error_t GetStatus() const {
- return signature_ref_->status;
- }
+ [[nodiscard]] gpgme_error_t GetStatus() const;
/**
* @brief
*
* @return gpgme_error_t
*/
- [[nodiscard]] gpgme_error_t GetSummary() const {
- return signature_ref_->summary;
- }
+ [[nodiscard]] gpgme_error_t GetSummary() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetPubkeyAlgo() const {
- return gpgme_pubkey_algo_name(signature_ref_->pubkey_algo);
- }
+ [[nodiscard]] std::string GetPubkeyAlgo() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetHashAlgo() const {
- return gpgme_hash_algo_name(signature_ref_->hash_algo);
- }
+ [[nodiscard]] std::string GetHashAlgo() const;
/**
* @brief Create a time object
*
* @return boost::posix_time::ptime
*/
- [[nodiscard]] boost::posix_time::ptime GetCreateTime() const {
- return boost::posix_time::from_time_t(signature_ref_->timestamp);
- }
+ [[nodiscard]] boost::posix_time::ptime GetCreateTime() const;
/**
* @brief
*
* @return boost::posix_time::ptime
*/
- [[nodiscard]] boost::posix_time::ptime GetExpireTime() const {
- return boost::posix_time::from_time_t(signature_ref_->exp_timestamp);
- }
+ [[nodiscard]] boost::posix_time::ptime GetExpireTime() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetFingerprint() const {
- return signature_ref_->fpr;
- }
+ [[nodiscard]] std::string GetFingerprint() const;
/**
* @brief Construct a new Gpg Signature object
*
*/
- GpgSignature() = default;
+ GpgSignature();
/**
* @brief Destroy the Gpg Signature object
*
*/
- ~GpgSignature() = default;
+ ~GpgSignature();
/**
* @brief Construct a new Gpg Signature object
@@ -137,7 +121,7 @@ class GpgSignature {
* @brief Construct a new Gpg Signature object
*
*/
- GpgSignature(GpgSignature &&) noexcept = default;
+ GpgSignature(GpgSignature &&) noexcept;
/**
* @brief Construct a new Gpg Signature object
@@ -150,7 +134,7 @@ class GpgSignature {
*
* @return GpgSignature&
*/
- GpgSignature &operator=(GpgSignature &&) noexcept = default;
+ GpgSignature &operator=(GpgSignature &&) noexcept;
/**
* @brief
diff --git a/src/core/model/GpgSubKey.cpp b/src/core/model/GpgSubKey.cpp
index 767f9c5d..e63816b1 100644
--- a/src/core/model/GpgSubKey.cpp
+++ b/src/core/model/GpgSubKey.cpp
@@ -27,5 +27,77 @@
*/
#include "core/model/GpgSubKey.h"
+GpgFrontend::GpgSubKey::GpgSubKey() = default;
+
GpgFrontend::GpgSubKey::GpgSubKey(gpgme_subkey_t subkey)
: _subkey_ref(subkey, [&](gpgme_subkey_t subkey) {}) {}
+
+GpgFrontend::GpgSubKey::GpgSubKey(GpgSubKey&& o) noexcept {
+ swap(_subkey_ref, o._subkey_ref);
+}
+
+GpgFrontend::GpgSubKey& GpgFrontend::GpgSubKey::operator=(
+ GpgSubKey&& o) noexcept {
+ swap(_subkey_ref, o._subkey_ref);
+ return *this;
+};
+
+bool GpgFrontend::GpgSubKey::operator==(const GpgSubKey& o) const {
+ return GetFingerprint() == o.GetFingerprint();
+}
+
+std::string GpgFrontend::GpgSubKey::GetID() const { return _subkey_ref->keyid; }
+
+std::string GpgFrontend::GpgSubKey::GetFingerprint() const {
+ return _subkey_ref->fpr;
+}
+
+std::string GpgFrontend::GpgSubKey::GetPubkeyAlgo() const {
+ return gpgme_pubkey_algo_name(_subkey_ref->pubkey_algo);
+}
+
+unsigned int GpgFrontend::GpgSubKey::GetKeyLength() const {
+ return _subkey_ref->length;
+}
+
+bool GpgFrontend::GpgSubKey::IsHasEncryptionCapability() const {
+ return _subkey_ref->can_encrypt;
+}
+
+bool GpgFrontend::GpgSubKey::IsHasSigningCapability() const {
+ return _subkey_ref->can_sign;
+}
+
+bool GpgFrontend::GpgSubKey::IsHasCertificationCapability() const {
+ return _subkey_ref->can_certify;
+}
+
+bool GpgFrontend::GpgSubKey::IsHasAuthenticationCapability() const {
+ return _subkey_ref->can_authenticate;
+}
+
+bool GpgFrontend::GpgSubKey::IsPrivateKey() const {
+ return _subkey_ref->secret;
+}
+
+bool GpgFrontend::GpgSubKey::IsExpired() const { return _subkey_ref->expired; }
+
+bool GpgFrontend::GpgSubKey::IsRevoked() const { return _subkey_ref->revoked; }
+
+bool GpgFrontend::GpgSubKey::IsDisabled() const {
+ return _subkey_ref->disabled;
+}
+
+bool GpgFrontend::GpgSubKey::IsSecretKey() const { return _subkey_ref->secret; }
+
+bool GpgFrontend::GpgSubKey::IsCardKey() const {
+ return _subkey_ref->is_cardkey;
+}
+
+boost::posix_time::ptime GpgFrontend::GpgSubKey::GetCreateTime() const {
+ return boost::posix_time::from_time_t(_subkey_ref->timestamp);
+}
+
+boost::posix_time::ptime GpgFrontend::GpgSubKey::GetExpireTime() const {
+ return boost::posix_time::from_time_t(_subkey_ref->expires);
+}
diff --git a/src/core/model/GpgSubKey.h b/src/core/model/GpgSubKey.h
index 1aadcdac..5a86d21d 100644
--- a/src/core/model/GpgSubKey.h
+++ b/src/core/model/GpgSubKey.h
@@ -40,39 +40,35 @@ namespace GpgFrontend {
* @brief
*
*/
-class GpgSubKey {
+class GPGFRONTEND_CORE_EXPORT GpgSubKey {
public:
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetID() const { return _subkey_ref->keyid; }
+ [[nodiscard]] std::string GetID() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetFingerprint() const { return _subkey_ref->fpr; }
+ [[nodiscard]] std::string GetFingerprint() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetPubkeyAlgo() const {
- return gpgme_pubkey_algo_name(_subkey_ref->pubkey_algo);
- }
+ [[nodiscard]] std::string GetPubkeyAlgo() const;
/**
* @brief
*
* @return unsigned int
*/
- [[nodiscard]] unsigned int GetKeyLength() const {
- return _subkey_ref->length;
- }
+ [[nodiscard]] unsigned int GetKeyLength() const;
/**
* @brief
@@ -80,9 +76,7 @@ class GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasEncryptionCapability() const {
- return _subkey_ref->can_encrypt;
- }
+ [[nodiscard]] bool IsHasEncryptionCapability() const;
/**
* @brief
@@ -90,9 +84,7 @@ class GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasSigningCapability() const {
- return _subkey_ref->can_sign;
- }
+ [[nodiscard]] bool IsHasSigningCapability() const;
/**
* @brief
@@ -100,9 +92,7 @@ class GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasCertificationCapability() const {
- return _subkey_ref->can_certify;
- }
+ [[nodiscard]] bool IsHasCertificationCapability() const;
/**
* @brief
@@ -110,9 +100,7 @@ class GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsHasAuthenticationCapability() const {
- return _subkey_ref->can_authenticate;
- }
+ [[nodiscard]] bool IsHasAuthenticationCapability() const;
/**
* @brief
@@ -120,7 +108,7 @@ class GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsPrivateKey() const { return _subkey_ref->secret; }
+ [[nodiscard]] bool IsPrivateKey() const;
/**
* @brief
@@ -128,7 +116,7 @@ class GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsExpired() const { return _subkey_ref->expired; }
+ [[nodiscard]] bool IsExpired() const;
/**
* @brief
@@ -136,7 +124,7 @@ class GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsRevoked() const { return _subkey_ref->revoked; }
+ [[nodiscard]] bool IsRevoked() const;
/**
* @brief
@@ -144,7 +132,7 @@ class GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsDisabled() const { return _subkey_ref->disabled; }
+ [[nodiscard]] bool IsDisabled() const;
/**
* @brief
@@ -152,7 +140,7 @@ class GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsSecretKey() const { return _subkey_ref->secret; }
+ [[nodiscard]] bool IsSecretKey() const;
/**
* @brief
@@ -160,31 +148,27 @@ class GpgSubKey {
* @return true
* @return false
*/
- [[nodiscard]] bool IsCardKey() const { return _subkey_ref->is_cardkey; }
+ [[nodiscard]] bool IsCardKey() const;
/**
* @brief
*
* @return boost::posix_time::ptime
*/
- [[nodiscard]] boost::posix_time::ptime GetCreateTime() const {
- return boost::posix_time::from_time_t(_subkey_ref->timestamp);
- }
+ [[nodiscard]] boost::posix_time::ptime GetCreateTime() const;
/**
* @brief
*
* @return boost::posix_time::ptime
*/
- [[nodiscard]] boost::posix_time::ptime GetExpireTime() const {
- return boost::posix_time::from_time_t(_subkey_ref->expires);
- }
+ [[nodiscard]] boost::posix_time::ptime GetExpireTime() const;
/**
* @brief Construct a new Gpg Sub Key object
*
*/
- GpgSubKey() = default;
+ GpgSubKey();
/**
* @brief Construct a new Gpg Sub Key object
@@ -198,7 +182,7 @@ class GpgSubKey {
*
* @param o
*/
- GpgSubKey(GpgSubKey&& o) noexcept { swap(_subkey_ref, o._subkey_ref); }
+ GpgSubKey(GpgSubKey&& o) noexcept;
/**
* @brief Construct a new Gpg Sub Key object
@@ -212,10 +196,7 @@ class GpgSubKey {
* @param o
* @return GpgSubKey&
*/
- GpgSubKey& operator=(GpgSubKey&& o) noexcept {
- swap(_subkey_ref, o._subkey_ref);
- return *this;
- };
+ GpgSubKey& operator=(GpgSubKey&& o) noexcept;
/**
* @brief
@@ -231,9 +212,7 @@ class GpgSubKey {
* @return true
* @return false
*/
- bool operator==(const GpgSubKey& o) const {
- return GetFingerprint() == o.GetFingerprint();
- }
+ bool operator==(const GpgSubKey& o) const;
private:
using SubkeyRefHandler =
diff --git a/src/core/model/GpgTOFUInfo.cpp b/src/core/model/GpgTOFUInfo.cpp
index 8c83b360..84ce1e29 100644
--- a/src/core/model/GpgTOFUInfo.cpp
+++ b/src/core/model/GpgTOFUInfo.cpp
@@ -28,5 +28,64 @@
#include "GpgTOFUInfo.h"
+GpgFrontend::GpgTOFUInfo::GpgTOFUInfo() = default;
+
GpgFrontend::GpgTOFUInfo::GpgTOFUInfo(gpgme_tofu_info_t tofu_info)
: _tofu_info_ref(tofu_info, [&](gpgme_tofu_info_t tofu_info) {}) {}
+
+GpgFrontend::GpgTOFUInfo::GpgTOFUInfo(GpgTOFUInfo&& o) noexcept {
+ swap(_tofu_info_ref, o._tofu_info_ref);
+}
+
+GpgFrontend::GpgTOFUInfo& GpgFrontend::GpgTOFUInfo::operator=(
+ GpgTOFUInfo&& o) noexcept {
+ swap(_tofu_info_ref, o._tofu_info_ref);
+ return *this;
+};
+
+unsigned GpgFrontend::GpgTOFUInfo::GetValidity() const {
+ return _tofu_info_ref->validity;
+}
+
+unsigned GpgFrontend::GpgTOFUInfo::GetPolicy() const {
+ return _tofu_info_ref->policy;
+}
+
+unsigned long GpgFrontend::GpgTOFUInfo::GetSignCount() const {
+ return _tofu_info_ref->signcount;
+}
+
+unsigned long GpgFrontend::GpgTOFUInfo::GetEncrCount() const {
+ return _tofu_info_ref->encrcount;
+}
+
+unsigned long GpgFrontend::GpgTOFUInfo::GetSignFirst() const {
+ return _tofu_info_ref->signfirst;
+}
+
+/**
+ * @brief
+ *
+ * @return unsigned long
+ */
+unsigned long GpgFrontend::GpgTOFUInfo::GetSignLast() const {
+ return _tofu_info_ref->signlast;
+}
+
+/**
+ * @brief
+ *
+ * @return unsigned long
+ */
+unsigned long GpgFrontend::GpgTOFUInfo::GetEncrLast() const {
+ return _tofu_info_ref->encrlast;
+}
+
+/**
+ * @brief
+ *
+ * @return std::string
+ */
+std::string GpgFrontend::GpgTOFUInfo::GetDescription() const {
+ return _tofu_info_ref->description;
+} \ No newline at end of file
diff --git a/src/core/model/GpgTOFUInfo.h b/src/core/model/GpgTOFUInfo.h
index b2fea4cf..b82a4eb2 100644
--- a/src/core/model/GpgTOFUInfo.h
+++ b/src/core/model/GpgTOFUInfo.h
@@ -36,83 +36,68 @@ namespace GpgFrontend {
* @brief
*
*/
-class GpgTOFUInfo {
+class GPGFRONTEND_CORE_EXPORT GpgTOFUInfo {
public:
/**
* @brief
*
* @return unsigned
*/
- [[nodiscard]] unsigned GetValidity() const {
- return _tofu_info_ref->validity;
- }
-
+ [[nodiscard]] unsigned GetValidity() const;
/**
* @brief
*
* @return unsigned
*/
- [[nodiscard]] unsigned GetPolicy() const { return _tofu_info_ref->policy; }
+ [[nodiscard]] unsigned GetPolicy() const;
/**
* @brief
*
* @return unsigned long
*/
- [[nodiscard]] unsigned long GetSignCount() const {
- return _tofu_info_ref->signcount;
- }
+ [[nodiscard]] unsigned long GetSignCount() const;
/**
* @brief
*
* @return unsigned long
*/
- [[nodiscard]] unsigned long GetEncrCount() const {
- return _tofu_info_ref->encrcount;
- }
+ [[nodiscard]] unsigned long GetEncrCount() const;
/**
* @brief
*
* @return unsigned long
*/
- [[nodiscard]] unsigned long GetSignFirst() const {
- return _tofu_info_ref->signfirst;
- }
+ [[nodiscard]] unsigned long GetSignFirst() const;
/**
* @brief
*
* @return unsigned long
*/
- [[nodiscard]] unsigned long GetSignLast() const {
- return _tofu_info_ref->signlast;
- }
+ [[nodiscard]] unsigned long GetSignLast() const;
/**
* @brief
*
* @return unsigned long
*/
- [[nodiscard]] unsigned long GetEncrLast() const {
- return _tofu_info_ref->encrlast;
- }
+ [[nodiscard]] unsigned long GetEncrLast() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetDescription() const {
- return _tofu_info_ref->description;
- }
+ [[nodiscard]] std::string GetDescription() const;
/**
* @brief Construct a new Gpg T O F U Info object
*
*/
- GpgTOFUInfo() = default;
+ GpgTOFUInfo();
/**
* @brief Construct a new Gpg T O F U Info object
@@ -126,9 +111,7 @@ class GpgTOFUInfo {
*
* @param o
*/
- GpgTOFUInfo(GpgTOFUInfo&& o) noexcept {
- swap(_tofu_info_ref, o._tofu_info_ref);
- }
+ GpgTOFUInfo(GpgTOFUInfo&& o) noexcept;
/**
* @brief Construct a new Gpg T O F U Info object
@@ -142,10 +125,7 @@ class GpgTOFUInfo {
* @param o
* @return GpgTOFUInfo&
*/
- GpgTOFUInfo& operator=(GpgTOFUInfo&& o) noexcept {
- swap(_tofu_info_ref, o._tofu_info_ref);
- return *this;
- };
+ GpgTOFUInfo& operator=(GpgTOFUInfo&& o) noexcept;
/**
* @brief
diff --git a/src/core/model/GpgUID.cpp b/src/core/model/GpgUID.cpp
index 6d98c882..d87192c3 100644
--- a/src/core/model/GpgUID.cpp
+++ b/src/core/model/GpgUID.cpp
@@ -28,5 +28,45 @@
#include "core/model/GpgUID.h"
+GpgFrontend::GpgUID::GpgUID() = default;
+
GpgFrontend::GpgUID::GpgUID(gpgme_user_id_t uid)
- : uid_ref_(uid, [&](gpgme_user_id_t uid) {}) {} \ No newline at end of file
+ : uid_ref_(uid, [&](gpgme_user_id_t uid) {}) {}
+
+GpgFrontend::GpgUID::GpgUID(GpgUID &&o) noexcept { swap(uid_ref_, o.uid_ref_); }
+
+std::string GpgFrontend::GpgUID::GetName() const { return uid_ref_->name; }
+
+std::string GpgFrontend::GpgUID::GetEmail() const { return uid_ref_->email; }
+
+std::string GpgFrontend::GpgUID::GetComment() const {
+ return uid_ref_->comment;
+}
+
+std::string GpgFrontend::GpgUID::GetUID() const { return uid_ref_->uid; }
+
+bool GpgFrontend::GpgUID::GetRevoked() const { return uid_ref_->revoked; }
+
+bool GpgFrontend::GpgUID::GetInvalid() const { return uid_ref_->invalid; }
+
+std::unique_ptr<std::vector<GpgFrontend::GpgTOFUInfo>>
+GpgFrontend::GpgUID::GetTofuInfos() const {
+ auto infos = std::make_unique<std::vector<GpgTOFUInfo>>();
+ auto info_next = uid_ref_->tofu;
+ while (info_next != nullptr) {
+ infos->push_back(GpgTOFUInfo(info_next));
+ info_next = info_next->next;
+ }
+ return infos;
+}
+
+std::unique_ptr<std::vector<GpgFrontend::GpgKeySignature>>
+GpgFrontend::GpgUID::GetSignatures() const {
+ auto sigs = std::make_unique<std::vector<GpgKeySignature>>();
+ auto sig_next = uid_ref_->signatures;
+ while (sig_next != nullptr) {
+ sigs->push_back(GpgKeySignature(sig_next));
+ sig_next = sig_next->next;
+ }
+ return sigs;
+}
diff --git a/src/core/model/GpgUID.h b/src/core/model/GpgUID.h
index 7f8daf98..670c318d 100644
--- a/src/core/model/GpgUID.h
+++ b/src/core/model/GpgUID.h
@@ -37,35 +37,35 @@ namespace GpgFrontend {
* @brief
*
*/
-class GpgUID {
+class GPGFRONTEND_CORE_EXPORT GpgUID {
public:
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetName() const { return uid_ref_->name; }
+ [[nodiscard]] std::string GetName() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetEmail() const { return uid_ref_->email; }
+ [[nodiscard]] std::string GetEmail() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetComment() const { return uid_ref_->comment; }
+ [[nodiscard]] std::string GetComment() const;
/**
* @brief
*
* @return std::string
*/
- [[nodiscard]] std::string GetUID() const { return uid_ref_->uid; }
+ [[nodiscard]] std::string GetUID() const;
/**
* @brief
@@ -73,7 +73,7 @@ class GpgUID {
* @return true
* @return false
*/
- [[nodiscard]] bool GetRevoked() const { return uid_ref_->revoked; }
+ [[nodiscard]] bool GetRevoked() const;
/**
* @brief
@@ -81,22 +81,14 @@ class GpgUID {
* @return true
* @return false
*/
- [[nodiscard]] bool GetInvalid() const { return uid_ref_->invalid; }
+ [[nodiscard]] bool GetInvalid() const;
/**
* @brief
*
* @return std::unique_ptr<std::vector<GpgTOFUInfo>>
*/
- [[nodiscard]] std::unique_ptr<std::vector<GpgTOFUInfo>> GetTofuInfos() const {
- auto infos = std::make_unique<std::vector<GpgTOFUInfo>>();
- auto info_next = uid_ref_->tofu;
- while (info_next != nullptr) {
- infos->push_back(GpgTOFUInfo(info_next));
- info_next = info_next->next;
- }
- return infos;
- }
+ [[nodiscard]] std::unique_ptr<std::vector<GpgTOFUInfo>> GetTofuInfos() const;
/**
* @brief
@@ -104,21 +96,13 @@ class GpgUID {
* @return std::unique_ptr<std::vector<GpgKeySignature>>
*/
[[nodiscard]] std::unique_ptr<std::vector<GpgKeySignature>> GetSignatures()
- const {
- auto sigs = std::make_unique<std::vector<GpgKeySignature>>();
- auto sig_next = uid_ref_->signatures;
- while (sig_next != nullptr) {
- sigs->push_back(GpgKeySignature(sig_next));
- sig_next = sig_next->next;
- }
- return sigs;
- }
+ const;
/**
* @brief Construct a new Gpg U I D object
*
*/
- GpgUID() = default;
+ GpgUID();
/**
* @brief Construct a new Gpg U I D object
@@ -132,7 +116,7 @@ class GpgUID {
*
* @param o
*/
- GpgUID(GpgUID &&o) noexcept { swap(uid_ref_, o.uid_ref_); }
+ GpgUID(GpgUID &&o) noexcept;
/**
* @brief Construct a new Gpg U I D object
@@ -146,10 +130,7 @@ class GpgUID {
* @param o
* @return GpgUID&
*/
- GpgUID &operator=(GpgUID &&o) noexcept {
- swap(uid_ref_, o.uid_ref_);
- return *this;
- }
+ GpgUID &operator=(GpgUID &&o) noexcept;
/**
* @brief
diff --git a/src/core/thread/CtxCheckThread.cpp b/src/core/thread/CtxCheckThread.cpp
new file mode 100644
index 00000000..77571dfd
--- /dev/null
+++ b/src/core/thread/CtxCheckThread.cpp
@@ -0,0 +1,54 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#include "core/thread/CtxCheckThread.h"
+
+#include "core/GpgContext.h"
+#include "core/GpgCoreInit.h"
+#include "core/common/CoreCommonUtil.h"
+#include "core/function/gpg/GpgKeyGetter.h"
+
+GpgFrontend::CtxCheckThread::CtxCheckThread() : QThread(nullptr) {
+ connect(this, &CtxCheckThread::SignalGnupgNotInstall,
+ CoreCommonUtil::GetInstance(),
+ &CoreCommonUtil::SignalGnupgNotInstall);
+}
+
+void GpgFrontend::CtxCheckThread::run() {
+ // init logging
+ init_logging();
+
+ // Init GpgFrontend Core
+ init_gpgfrontend_core();
+
+ // Create & Check Gnupg Context Status
+ if (!GpgContext::GetInstance().good()) {
+ emit SignalGnupgNotInstall();
+ }
+ // Try fetching key
+ else
+ GpgFrontend::GpgKeyGetter::GetInstance().FetchKey();
+}
diff --git a/src/core/thread/CtxCheckThread.h b/src/core/thread/CtxCheckThread.h
new file mode 100644
index 00000000..c597141f
--- /dev/null
+++ b/src/core/thread/CtxCheckThread.h
@@ -0,0 +1,62 @@
+/**
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * The source code version of this software was modified and released
+ * by Saturneric<[email protected]><[email protected]> starting on May 12, 2021.
+ *
+ */
+
+#ifndef GPGFRONTEND_CTXCHECKTRHEAD_H
+#define GPGFRONTEND_CTXCHECKTRHEAD_H
+
+#include "core/GpgFrontendCore.h"
+
+namespace GpgFrontend {
+/**
+ * @brief
+ *
+ */
+class GPGFRONTEND_CORE_EXPORT CtxCheckThread : public QThread {
+ Q_OBJECT
+ public:
+ /**
+ * @brief Construct a new Ctx Check Thread object
+ *
+ */
+ CtxCheckThread();
+
+ signals:
+ /**
+ * @brief
+ *
+ */
+ void SignalGnupgNotInstall();
+
+ protected:
+ /**
+ * @brief
+ *
+ */
+ void run() override;
+};
+} // namespace GpgFrontend
+
+#endif // GPGFRONTEND_CTXCHECKTRHEAD_H