aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/model')
-rw-r--r--src/core/model/GpgKeyGenerateInfo.cpp26
-rw-r--r--src/core/model/GpgKeyGenerateInfo.h6
2 files changed, 14 insertions, 18 deletions
diff --git a/src/core/model/GpgKeyGenerateInfo.cpp b/src/core/model/GpgKeyGenerateInfo.cpp
index b1dcaa7a..0d8aa23c 100644
--- a/src/core/model/GpgKeyGenerateInfo.cpp
+++ b/src/core/model/GpgKeyGenerateInfo.cpp
@@ -30,8 +30,9 @@
#include <cassert>
-#include "module/ModuleManager.h"
-#include "utils/CommonUtils.h"
+#include "core/module/ModuleManager.h"
+#include "core/utils/CommonUtils.h"
+#include "core/utils/GpgUtils.h"
namespace GpgFrontend {
@@ -98,14 +99,12 @@ const QContainer<KeyAlgo> KeyGenerateInfo::kSubKeyAlgos = {
{"elg4096", "ELG-E", "ELG-E", 4096, kENCRYPT, "2.2.0"},
};
-auto KeyGenerateInfo::GetSupportedKeyAlgo() -> QContainer<KeyAlgo> {
- const auto gnupg_version = Module::RetrieveRTValueTypedOrDefault<>(
- "core", "gpgme.ctx.gnupg_version", QString{"2.0.0"});
-
+auto KeyGenerateInfo::GetSupportedKeyAlgo(int channel) -> QContainer<KeyAlgo> {
QContainer<KeyAlgo> algos;
for (const auto &algo : kPrimaryKeyAlgos) {
- if (!algo.IsSupported(gnupg_version)) continue;
+ if (!CheckGpgVersion(channel, algo.SupportedVersion())) continue;
+
algos.append(algo);
}
@@ -116,14 +115,13 @@ auto KeyGenerateInfo::GetSupportedKeyAlgo() -> QContainer<KeyAlgo> {
return algos;
}
-auto KeyGenerateInfo::GetSupportedSubkeyAlgo() -> QContainer<KeyAlgo> {
- const auto gnupg_version = Module::RetrieveRTValueTypedOrDefault<>(
- "core", "gpgme.ctx.gnupg_version", QString{"2.0.0"});
-
+auto KeyGenerateInfo::GetSupportedSubkeyAlgo(int channel)
+ -> QContainer<KeyAlgo> {
QContainer<KeyAlgo> algos;
for (const auto &algo : kSubKeyAlgos) {
- if (!algo.IsSupported(gnupg_version)) continue;
+ if (!CheckGpgVersion(channel, algo.SupportedVersion())) continue;
+
algos.append(algo);
}
@@ -490,9 +488,7 @@ auto KeyAlgo::CanAuth() const -> bool { return auth_; }
auto KeyAlgo::CanCert() const -> bool { return cert_; }
-auto KeyAlgo::IsSupported(const QString &version) const -> bool {
- return GFCompareSoftwareVersion(version, supported_version_) >= 0;
-}
+auto KeyAlgo::SupportedVersion() const -> QString { return supported_version_; }
auto KeyAlgo::operator==(const KeyAlgo &o) const -> bool {
return this->id_ == o.id_;
diff --git a/src/core/model/GpgKeyGenerateInfo.h b/src/core/model/GpgKeyGenerateInfo.h
index 2956a00d..b3f3b2c7 100644
--- a/src/core/model/GpgKeyGenerateInfo.h
+++ b/src/core/model/GpgKeyGenerateInfo.h
@@ -62,7 +62,7 @@ class GPGFRONTEND_CORE_EXPORT KeyAlgo {
[[nodiscard]] auto CanCert() const -> bool;
- [[nodiscard]] auto IsSupported(const QString &version) const -> bool;
+ [[nodiscard]] auto SupportedVersion() const -> QString;
private:
QString id_;
@@ -96,14 +96,14 @@ class GPGFRONTEND_CORE_EXPORT KeyGenerateInfo : public QObject {
*
* @return const QContainer<KeyGenAlgo>&
*/
- static auto GetSupportedKeyAlgo() -> QContainer<KeyAlgo>;
+ static auto GetSupportedKeyAlgo(int channel) -> QContainer<KeyAlgo>;
/**
* @brief Get the Supported Subkey Algo object
*
* @return const QContainer<KeyGenAlgo>&
*/
- static auto GetSupportedSubkeyAlgo() -> QContainer<KeyAlgo>;
+ static auto GetSupportedSubkeyAlgo(int channel) -> QContainer<KeyAlgo>;
/**
* @brief