aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/gpg
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/function/gpg')
-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
16 files changed, 149 insertions, 104 deletions
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