[poppler] poppler/CryptoSignBackend.cc poppler/CryptoSignBackend.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Apr 29 09:46:24 UTC 2023


 poppler/CryptoSignBackend.cc |   13 +++++++------
 poppler/CryptoSignBackend.h  |    3 +--
 2 files changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 39d0009741465344f8a30a3129081cd18bb378bb
Author: Sune Vuorela <sune at vuorela.dk>
Date:   Fri Apr 14 17:12:24 2023 +0200

    API fixup: Use optional instead of a 'None' backend
    
    Let's fix the cryptosign backend code before release.

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);


More information about the poppler mailing list