aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/gpg
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2025-04-12 11:36:45 +0000
committersaturneric <[email protected]>2025-04-12 11:36:45 +0000
commite0264d85090dd119d48df28477db2fe3b17eb60a (patch)
treee7711bfe4f03c4b97eb2f37129b07a9ec5eb85d1 /src/core/function/gpg
parentfix: wrong ui dialog order after switching apps (diff)
downloadGpgFrontend-e0264d85090dd119d48df28477db2fe3b17eb60a.tar.gz
GpgFrontend-e0264d85090dd119d48df28477db2fe3b17eb60a.zip
refactor: GpgKey and GpgSubKey
Diffstat (limited to 'src/core/function/gpg')
-rw-r--r--src/core/function/gpg/GpgAutomatonHandler.cpp2
-rw-r--r--src/core/function/gpg/GpgBasicOperator.cpp2
-rw-r--r--src/core/function/gpg/GpgKeyGetter.cpp6
-rw-r--r--src/core/function/gpg/GpgKeyManager.cpp10
-rw-r--r--src/core/function/gpg/GpgKeyOpera.cpp11
-rw-r--r--src/core/function/gpg/GpgUIDOperator.cpp8
6 files changed, 19 insertions, 20 deletions
diff --git a/src/core/function/gpg/GpgAutomatonHandler.cpp b/src/core/function/gpg/GpgAutomatonHandler.cpp
index 352400a4..802279ed 100644
--- a/src/core/function/gpg/GpgAutomatonHandler.cpp
+++ b/src/core/function/gpg/GpgAutomatonHandler.cpp
@@ -97,7 +97,7 @@ auto GpgAutomatonHandler::interator_cb_func(void* handle, const char* status,
auto GpgAutomatonHandler::DoInteract(
const GpgKey& key, AutomatonNextStateHandler next_state_handler,
AutomatonActionHandler action_handler) -> bool {
- auto key_fpr = key.GetFingerprint();
+ auto key_fpr = key.Fingerprint();
AutomatonHandelStruct handel_struct(key_fpr);
handel_struct.SetHandler(std::move(next_state_handler),
std::move(action_handler));
diff --git a/src/core/function/gpg/GpgBasicOperator.cpp b/src/core/function/gpg/GpgBasicOperator.cpp
index 30fd8912..2548409e 100644
--- a/src/core/function/gpg/GpgBasicOperator.cpp
+++ b/src/core/function/gpg/GpgBasicOperator.cpp
@@ -49,7 +49,7 @@ void SetSignersImpl(GpgContext& ctx_, const KeyArgsList& signers, bool ascii) {
gpgme_signers_clear(ctx);
for (const GpgKey& key : signers) {
- LOG_D() << "signer's key fpr: " << key.GetFingerprint();
+ LOG_D() << "signer's key fpr: " << key.Fingerprint();
if (key.IsHasActualSignCap()) {
auto error = gpgme_signers_add(ctx, gpgme_key_t(key));
CheckGpgError(error);
diff --git a/src/core/function/gpg/GpgKeyGetter.cpp b/src/core/function/gpg/GpgKeyGetter.cpp
index a4ca6021..14145f7f 100644
--- a/src/core/function/gpg/GpgKeyGetter.cpp
+++ b/src/core/function/gpg/GpgKeyGetter.cpp
@@ -131,12 +131,12 @@ class GpgKeyGetter::Impl : public SingletonFunctionObject<GpgKeyGetter::Impl> {
// if so, try to get full information using gpgme_get_key()
// this maybe a bug in gpgme
if (gpg_key.IsHasCardKey()) {
- gpg_key = GetKey(gpg_key.GetId(), false);
+ gpg_key = GetKey(gpg_key.ID(), false);
}
keys_cache_.push_back(gpg_key);
- keys_search_cache_.insert(gpg_key.GetId(), gpg_key);
- keys_search_cache_.insert(gpg_key.GetFingerprint(), gpg_key);
+ keys_search_cache_.insert(gpg_key.ID(), gpg_key);
+ keys_search_cache_.insert(gpg_key.Fingerprint(), gpg_key);
}
}
diff --git a/src/core/function/gpg/GpgKeyManager.cpp b/src/core/function/gpg/GpgKeyManager.cpp
index 36f68bdc..bd514cf3 100644
--- a/src/core/function/gpg/GpgKeyManager.cpp
+++ b/src/core/function/gpg/GpgKeyManager.cpp
@@ -85,7 +85,7 @@ auto GpgKeyManager::SetExpire(const GpgKey& key,
const char* sub_fprs = nullptr;
- if (subkey != nullptr) sub_fprs = subkey->GetFingerprint().toUtf8();
+ if (subkey != nullptr) sub_fprs = subkey->Fingerprint().toUtf8();
auto err = CheckGpgError(gpgme_op_setexpire(ctx_.DefaultContext(),
static_cast<gpgme_key_t>(key),
@@ -174,7 +174,7 @@ auto GpgKeyManager::SetOwnerTrustLevel(const GpgKey& key,
auto GpgKeyManager::DeleteSubkey(const GpgKey& key, int subkey_index) -> bool {
if (subkey_index < 0 ||
- subkey_index >= static_cast<int>(key.GetSubKeys()->size())) {
+ subkey_index >= static_cast<int>(key.SubKeys().size())) {
LOG_W() << "illegal subkey index: " << subkey_index;
return false;
}
@@ -246,7 +246,7 @@ auto GpgKeyManager::DeleteSubkey(const GpgKey& key, int subkey_index) -> bool {
return QString("");
};
- auto key_fpr = key.GetFingerprint();
+ auto key_fpr = key.Fingerprint();
AutomatonHandelStruct handel_struct(key_fpr);
handel_struct.SetHandler(next_state_handler, action_handler);
@@ -260,7 +260,7 @@ auto GpgKeyManager::RevokeSubkey(const GpgKey& key, int subkey_index,
int reason_code,
const QString& reason_text) -> bool {
if (subkey_index < 0 ||
- subkey_index >= static_cast<int>(key.GetSubKeys()->size())) {
+ subkey_index >= static_cast<int>(key.SubKeys().size())) {
LOG_W() << "illegal subkey index: " << subkey_index;
return false;
}
@@ -369,7 +369,7 @@ auto GpgKeyManager::RevokeSubkey(const GpgKey& key, int subkey_index,
return QString("");
};
- auto key_fpr = key.GetFingerprint();
+ auto key_fpr = key.Fingerprint();
AutomatonHandelStruct handel_struct(key_fpr);
handel_struct.SetHandler(next_state_handler, action_handler);
diff --git a/src/core/function/gpg/GpgKeyOpera.cpp b/src/core/function/gpg/GpgKeyOpera.cpp
index 2378b518..3d9b8eda 100644
--- a/src/core/function/gpg/GpgKeyOpera.cpp
+++ b/src/core/function/gpg/GpgKeyOpera.cpp
@@ -81,7 +81,7 @@ auto GpgKeyOpera::SetExpire(const GpgKey& key, const SubkeyId& subkey_fpr,
}
GpgError err;
- if (key.GetFingerprint() == subkey_fpr || subkey_fpr.isEmpty()) {
+ if (key.Fingerprint() == subkey_fpr || subkey_fpr.isEmpty()) {
err =
gpgme_op_setexpire(ctx_.DefaultContext(), static_cast<gpgme_key_t>(key),
expires_time, nullptr, 0);
@@ -119,7 +119,7 @@ void GpgKeyOpera::GenerateRevokeCert(const GpgKey& key,
GpgCommandExecutor::ExecuteSync(
{app_path,
QStringList{"--command-fd", "0", "--status-fd", "1", "--no-tty", "-o",
- output_path, "--gen-revoke", key.GetFingerprint()},
+ output_path, "--gen-revoke", key.Fingerprint()},
[=](int exit_code, const QString& p_out, const QString& p_err) {
if (exit_code != 0) {
LOG_W() << "gnupg gen revoke execute error, process stderr: "
@@ -246,8 +246,7 @@ auto GenerateSubKeyImpl(GpgContext& ctx, const GpgKey& key,
if (params->IsNonExpired()) flags |= GPGME_CREATE_NOEXPIRE;
if (params->IsNoPassPhrase()) flags |= GPGME_CREATE_NOPASSWD;
- LOG_D() << "subkey generation args: " << key.GetId() << algo << expires
- << flags;
+ LOG_D() << "subkey generation args: " << key.ID() << algo << expires << flags;
auto err =
gpgme_op_createsubkey(ctx.DefaultContext(), static_cast<gpgme_key_t>(key),
@@ -367,10 +366,10 @@ void GpgKeyOpera::DeleteKey(const KeyId& key_id) {
auto AddADSKImpl(GpgContext& ctx, const GpgKey& key, const GpgSubKey& adsk,
const DataObjectPtr& data_object) -> GpgError {
- auto algo = adsk.GetFingerprint();
+ auto algo = adsk.Fingerprint();
unsigned int flags = GPGME_CREATE_ADSK;
- LOG_D() << "add adsk args: " << key.GetId() << algo;
+ LOG_D() << "add adsk args: " << key.ID() << algo;
auto err =
gpgme_op_createsubkey(ctx.DefaultContext(), static_cast<gpgme_key_t>(key),
diff --git a/src/core/function/gpg/GpgUIDOperator.cpp b/src/core/function/gpg/GpgUIDOperator.cpp
index b9312745..f3e4fcc2 100644
--- a/src/core/function/gpg/GpgUIDOperator.cpp
+++ b/src/core/function/gpg/GpgUIDOperator.cpp
@@ -59,7 +59,7 @@ auto GpgUIDOperator::AddUID(const GpgKey& key, const QString& name,
}
auto GpgUIDOperator::DeleteUID(const GpgKey& key, int uid_index) -> bool {
- if (uid_index < 2 || uid_index > static_cast<int>(key.GetUIDs()->size())) {
+ if (uid_index < 2 || uid_index > static_cast<int>(key.UIDs().size())) {
LOG_W() << "illegal uid_index index: " << uid_index;
return false;
}
@@ -131,7 +131,7 @@ auto GpgUIDOperator::DeleteUID(const GpgKey& key, int uid_index) -> bool {
return QString("");
};
- auto key_fpr = key.GetFingerprint();
+ auto key_fpr = key.Fingerprint();
AutomatonHandelStruct handel_struct(key_fpr);
handel_struct.SetHandler(next_state_handler, action_handler);
@@ -144,7 +144,7 @@ auto GpgUIDOperator::DeleteUID(const GpgKey& key, int uid_index) -> bool {
auto GpgUIDOperator::RevokeUID(const GpgKey& key, int uid_index,
int reason_code,
const QString& reason_text) -> bool {
- if (uid_index < 2 || uid_index > static_cast<int>(key.GetUIDs()->size())) {
+ if (uid_index < 2 || uid_index > static_cast<int>(key.UIDs().size())) {
LOG_W() << "illegal uid index: " << uid_index;
return false;
}
@@ -253,7 +253,7 @@ auto GpgUIDOperator::RevokeUID(const GpgKey& key, int uid_index,
return QString("");
};
- auto key_fpr = key.GetFingerprint();
+ auto key_fpr = key.Fingerprint();
AutomatonHandelStruct handel_struct(key_fpr);
handel_struct.SetHandler(next_state_handler, action_handler);