diff options
author | Sune Vuorela <sune@vuorela.dk> | 2023-04-14 17:12:24 +0200 |
---|---|---|
committer | Sune Vuorela <sune@vuorela.dk> | 2023-04-28 15:09:13 +0200 |
commit | 39d0009741465344f8a30a3129081cd18bb378bb (patch) | |
tree | 97bd983ff8436d9a33d2158cc19bc66ea8fc798f | |
parent | 2cf3cf58ed9f70b99e6ee93c57bb434a52a0e857 (diff) |
API fixup: Use optional instead of a 'None' backend
Let's fix the cryptosign backend code before release.
-rw-r--r-- | poppler/CryptoSignBackend.cc | 13 | ||||
-rw-r--r-- | poppler/CryptoSignBackend.h | 3 |
2 files changed, 8 insertions, 8 deletions
diff --git a/poppler/CryptoSignBackend.cc b/poppler/CryptoSignBackend.cc index 86703470..1bd28363 100644 --- a/poppler/CryptoSignBackend.cc +++ b/poppler/CryptoSignBackend.cc @@ -37,7 +37,7 @@ std::optional<CryptoSign::Backend::Type> Factory::typeFromString(std::string_vie return std::nullopt; } -CryptoSign::Backend::Type Factory::getActive() +std::optional<CryptoSign::Backend::Type> Factory::getActive() { if (preferredBackend) { return *preferredBackend; @@ -51,7 +51,7 @@ CryptoSign::Backend::Type Factory::getActive() return *backendFromCompiledDefault; } - return Backend::Type::None; + return std::nullopt; } static std::vector<Backend::Type> createAvailableBackends() { @@ -68,7 +68,11 @@ std::vector<Backend::Type> Factory::getAvailable() } std::unique_ptr<Backend> Factory::createActive() { - return create(getActive()); + auto active = getActive(); + if (active) { + return create(active.value()); + } + return nullptr; } std::unique_ptr<CryptoSign::Backend> CryptoSign::Factory::create(Backend::Type backend) { @@ -79,9 +83,6 @@ std::unique_ptr<CryptoSign::Backend> CryptoSign::Factory::create(Backend::Type b #else return nullptr; #endif - case Backend::Type::None: { - return nullptr; - } } return nullptr; } diff --git a/poppler/CryptoSignBackend.h b/poppler/CryptoSignBackend.h index b106ec47..a763e27c 100644 --- a/poppler/CryptoSignBackend.h +++ b/poppler/CryptoSignBackend.h @@ -63,7 +63,6 @@ class Backend public: enum class Type { - None, NSS3 }; virtual std::unique_ptr<VerificationInterface> createVerificationHandler(std::vector<unsigned char> &&pkcs7) = 0; @@ -84,7 +83,7 @@ public: // prioritized from 1) setPreferredBackend, // 2) POPPLER_SIGNATURE_BACKEND // 3) Compiled in default - static Backend::Type getActive(); + static std::optional<Backend::Type> getActive(); static std::vector<Backend::Type> getAvailable(); static std::unique_ptr<Backend> createActive(); static std::unique_ptr<Backend> create(Backend::Type); |