1/* poppler-form.h: qt interface to poppler
2 * Copyright (C) 2007-2008, Pino Toscano <pino@kde.org>
3 * Copyright (C) 2008, 2011, 2016, 2017, 2019-2022, Albert Astals Cid <aacid@kde.org>
4 * Copyright (C) 2012, Adam Reichold <adamreichold@myopera.com>
5 * Copyright (C) 2016, Hanno Meyer-Thurow <h.mth@web.de>
6 * Copyright (C) 2017, Hans-Ulrich Jüttner <huj@froreich-bioscientia.de>
7 * Copyright (C) 2017, Tobias C. Berner <tcberner@freebsd.org>
8 * Copyright (C) 2018, Andre Heinecke <aheinecke@intevation.de>
9 * Copyright (C) 2018, Chinmoy Ranjan Pradhan <chinmoyrp65@protonmail.com>
10 * Copyright (C) 2018, 2021 Oliver Sander <oliver.sander@tu-dresden.de>
11 * Copyright (C) 2019 João Netto <joaonetto901@gmail.com>
12 * Copyright (C) 2019, Adrian Johnson <ajohnson@redneon.com>
13 * Copyright (C) 2020, Thorsten Behrens <Thorsten.Behrens@CIB.de>
14 * Copyright (C) 2020, Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by Technische Universität Dresden
15 * Copyright (C) 2021, Theofilos Intzoglou <int.teo@gmail.com>
16 * Copyright (C) 2023, 2024, g10 Code GmbH, Author: Sune Stolborg Vuorela <sune@vuorela.dk>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2, or (at your option)
21 * any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
31 */
32
33#ifndef _POPPLER_QT6_FORM_H_
34#define _POPPLER_QT6_FORM_H_
35
36#include <functional>
37#include <memory>
38#include <ctime>
39#include <optional>
40#include <QtCore/QDateTime>
41#include <QtCore/QVector>
42#include <QtCore/QList>
43#include <QtCore/QRectF>
44#include <QtCore/QStringList>
45#include <QtCore/QSharedPointer>
46#include "poppler-export.h"
47#include "poppler-annotation.h"
48#include "poppler-qt6.h"
49
50class Object;
51class Page;
52class FormWidget;
53class FormWidgetButton;
54class FormWidgetText;
55class FormWidgetChoice;
56class FormWidgetSignature;
57
58namespace Poppler {
59
60class DocumentData;
61class Link;
62
63class FormFieldData;
64class FormFieldIconData;
65
66/**
67 The class containing the appearance information
68 */
69
70class POPPLER_QT6_EXPORT FormFieldIcon
71{
72
73 friend class FormFieldIconData;
74
75public:
76 explicit FormFieldIcon(FormFieldIconData *data);
77 FormFieldIcon(const FormFieldIcon &ffIcon);
78 ~FormFieldIcon();
79
80 FormFieldIcon &operator=(const FormFieldIcon &ffIcon);
81
82private:
83 FormFieldIconData *d_ptr;
84};
85/**
86 The base class representing a form field.
87 */
88class POPPLER_QT6_EXPORT FormField
89{
90
91 friend class FormFieldData;
92
93public:
94 /**
95 The different types of form field.
96 */
97 enum FormType
98 {
99 FormButton, ///< A button field. See \ref Poppler::FormFieldButton::ButtonType "ButtonType"
100 FormText, ///< A text field. See \ref Poppler::FormFieldText::TextType "TextType"
101 FormChoice, ///< A single choice field. See \ref Poppler::FormFieldChoice::ChoiceType "ChoiceType"
102 FormSignature ///< A signature field.
103 };
104
105 virtual ~FormField();
106
107 /**
108 The type of the field.
109 */
110 virtual FormType type() const = 0;
111
112 /**
113 \return The size of the field, in normalized coordinates, i.e.
114 [0..1] with regard to the dimensions (cropbox) of the page
115 */
116 QRectF rect() const;
117
118 /**
119 The ID of the field.
120 */
121 int id() const;
122
123 /**
124 The internal name (T) of the field.
125 */
126 QString name() const;
127
128 /**
129 Sets the internal name (T) of the field.
130 */
131 void setName(const QString &name) const;
132
133 /**
134 The internal fully qualified name of the field.
135 */
136 QString fullyQualifiedName() const;
137
138 /**
139 The name of the field to be used in user interface (eg messages to
140 the user).
141 */
142 QString uiName() const;
143
144 /**
145 Whether this form field is read-only.
146 */
147 bool isReadOnly() const;
148
149 /**
150 Set whether this form field is read-only.
151 */
152 void setReadOnly(bool value);
153
154 /**
155 Whether this form field is visible.
156 */
157 bool isVisible() const;
158
159 /**
160 Set whether this form field is visible.
161 */
162 void setVisible(bool value);
163
164 /**
165 Whether this field is printable.
166 */
167 bool isPrintable() const;
168
169 /**
170 Set whether this field is printable.
171 */
172 void setPrintable(bool value);
173
174 /**
175 The activation action of this form field.
176
177 \note It may be null.
178 */
179 std::unique_ptr<Link> activationAction() const;
180
181 /**
182 * Describes the flags from the form 'AA' dictionary.
183 */
184 enum AdditionalActionType
185 {
186 FieldModified, ///< A JavaScript action to be performed when the user modifies the field
187 FormatField, ///< A JavaScript action to be performed before the field is formatted to display its value
188 ValidateField, ///< A JavaScript action to be performed when the field value changes
189 CalculateField, ///< A JavaScript action to be performed when the field needs to be recalculated
190 };
191 /**
192 * Returns a given form additional action
193 */
194 std::unique_ptr<Link> additionalAction(AdditionalActionType type) const;
195
196 /**
197 * Returns a given widget annotation additional action
198 */
199 std::unique_ptr<Link> additionalAction(Annotation::AdditionalActionType type) const;
200
201protected:
202 /// \cond PRIVATE
203 explicit FormField(std::unique_ptr<FormFieldData> dd);
204
205 std::unique_ptr<FormFieldData> m_formData;
206 /// \endcond
207
208private:
209 Q_DISABLE_COPY(FormField)
210};
211
212/**
213 A form field that represents a "button".
214 */
215class POPPLER_QT6_EXPORT FormFieldButton : public FormField
216{
217public:
218 /**
219 * The types of button field.
220 */
221 enum ButtonType
222 {
223 Push, ///< A simple push button.
224 CheckBox, ///< A check box.
225 Radio ///< A radio button.
226 };
227
228 /// \cond PRIVATE
229 FormFieldButton(DocumentData *doc, ::Page *p, ::FormWidgetButton *w);
230 /// \endcond
231 ~FormFieldButton() override;
232
233 FormType type() const override;
234
235 /**
236 The particular type of the button field.
237 */
238 ButtonType buttonType() const;
239
240 /**
241 * The caption to be used for the button.
242 */
243 QString caption() const;
244
245 /**
246 * Gets the icon used by the button
247 */
248 FormFieldIcon icon() const;
249
250 /**
251 * Sets a new icon for the button, it has to be a icon
252 * returned by FormFieldButton::icon.
253 */
254 void setIcon(const FormFieldIcon &icon);
255
256 /**
257 The state of the button.
258 */
259 bool state() const;
260
261 /**
262 Sets the state of the button to the new \p state .
263 */
264 void setState(bool state);
265
266 /**
267 The list with the IDs of siblings (ie, buttons belonging to the same
268 group as the current one.
269
270 Valid only for \ref Radio buttons, an empty list otherwise.
271 */
272 QList<int> siblings() const;
273
274private:
275 Q_DISABLE_COPY(FormFieldButton)
276};
277
278/**
279 A form field that represents a text input.
280 */
281class POPPLER_QT6_EXPORT FormFieldText : public FormField
282{
283public:
284 /**
285 The particular type of this text field.
286 */
287 enum TextType
288 {
289 Normal, ///< A simple singleline text field.
290 Multiline, ///< A multiline text field.
291 FileSelect ///< An input field to select the path of a file on disk.
292 };
293
294 /// \cond PRIVATE
295 FormFieldText(DocumentData *doc, ::Page *p, ::FormWidgetText *w);
296 /// \endcond
297 ~FormFieldText() override;
298
299 FormType type() const override;
300
301 /**
302 The text type of the text field.
303 */
304 TextType textType() const;
305
306 /**
307 The text associated with the text field.
308 */
309 QString text() const;
310
311 /**
312 Sets the text associated with the text field to the specified
313 \p text.
314 */
315 void setText(const QString &text);
316
317 /**
318 Sets the text inside the Appearance Stream to the specified
319 \p text
320 */
321 void setAppearanceText(const QString &text);
322
323 /**
324 Whether this text field is a password input, eg its text \b must be
325 replaced with asterisks.
326
327 Always false for \ref FileSelect text fields.
328 */
329 bool isPassword() const;
330
331 /**
332 Whether this text field should allow rich text.
333 */
334 bool isRichText() const;
335
336 /**
337 The maximum length for the text of this field, or -1 if not set.
338 */
339 int maximumLength() const;
340
341 /**
342 The horizontal alignment for the text of this text field.
343 */
344 Qt::Alignment textAlignment() const;
345
346 /**
347 Whether the text inserted manually in the field (where possible)
348 can be spell-checked.
349 */
350 bool canBeSpellChecked() const;
351
352 /**
353 The font size of the text in the form field
354 */
355 double getFontSize() const;
356
357 /**
358 Set the font size of the text in the form field (currently only as integer)
359 */
360 void setFontSize(int fontSize);
361
362private:
363 Q_DISABLE_COPY(FormFieldText)
364};
365
366/**
367 A form field that represents a choice field.
368 */
369class POPPLER_QT6_EXPORT FormFieldChoice : public FormField
370{
371public:
372 /**
373 The particular type of this choice field.
374 */
375 enum ChoiceType
376 {
377 ComboBox, ///< A simple singleline text field.
378 ListBox ///< A multiline text field.
379 };
380
381 /// \cond PRIVATE
382 FormFieldChoice(DocumentData *doc, ::Page *p, ::FormWidgetChoice *w);
383 /// \endcond
384 ~FormFieldChoice() override;
385
386 FormType type() const override;
387
388 /**
389 The choice type of the choice field.
390 */
391 ChoiceType choiceType() const;
392
393 /**
394 The possible choices of the choice field.
395 */
396 QStringList choices() const;
397
398 /**
399 The possible choices of the choice field.
400 The first value of the pair is the display name of the choice,
401 The second value is the export value (i.e. for use in javascript, etc) of the choice
402 */
403 QVector<QPair<QString, QString>> choicesWithExportValues() const;
404
405 /**
406 Whether this FormFieldChoice::ComboBox is editable, i.e. the user
407 can type in a custom value.
408
409 Always false for the other types of choices.
410 */
411 bool isEditable() const;
412
413 /**
414 Whether more than one choice of this FormFieldChoice::ListBox
415 can be selected at the same time.
416
417 Always false for the other types of choices.
418 */
419 bool multiSelect() const;
420
421 /**
422 The currently selected choices.
423 */
424 QList<int> currentChoices() const;
425
426 /**
427 Sets the selected choices to \p choice.
428 */
429 void setCurrentChoices(const QList<int> &choice);
430
431 /**
432 The text entered into an editable combo box choice field. Otherwise a null string.
433 */
434 QString editChoice() const;
435
436 /**
437 Sets the text entered into an editable combo box choice field. Otherwise does nothing.
438 */
439 void setEditChoice(const QString &text);
440
441 /**
442 The horizontal alignment for the text of this text field.
443 */
444 Qt::Alignment textAlignment() const;
445
446 /**
447 Whether the text inserted manually in the field (where possible)
448 can be spell-checked.
449
450 Returns false if the field is not an editable text field.
451 */
452 bool canBeSpellChecked() const;
453
454private:
455 Q_DISABLE_COPY(FormFieldChoice)
456};
457
458/**
459 A helper class to store x509 certificate information.
460 */
461class CertificateInfoPrivate;
462class POPPLER_QT6_EXPORT CertificateInfo
463{
464public:
465 /**
466 The algorithm of public key.
467 */
468 enum PublicKeyType
469 {
470 RsaKey,
471 DsaKey,
472 EcKey,
473 OtherKey
474 };
475
476 /**
477 Certificate key usage extensions.
478 */
479 enum KeyUsageExtension
480 {
481 KuDigitalSignature = 0x80,
482 KuNonRepudiation = 0x40,
483 KuKeyEncipherment = 0x20,
484 KuDataEncipherment = 0x10,
485 KuKeyAgreement = 0x08,
486 KuKeyCertSign = 0x04,
487 KuClrSign = 0x02,
488 KuEncipherOnly = 0x01,
489 KuNone = 0x00
490 };
491 Q_DECLARE_FLAGS(KeyUsageExtensions, KeyUsageExtension)
492
493 /**
494 Predefined keys for elements in an entity's distinguished name.
495 */
496 enum EntityInfoKey
497 {
498 CommonName,
499 DistinguishedName,
500 EmailAddress,
501 Organization,
502 };
503
504 /** A signing key can be located in different places
505 sometimes. For the user, it might be easier to pick
506 the key located on a card if it has some visual
507 indicator that it is somehow removable.
508
509 \note a keylocation for a certificate without a private
510 key (cannot be used for signing) will likely be "Unknown"
511
512 \since 23.09
513 */
514 enum class KeyLocation
515 {
516 Unknown, /** We don't know the location */
517 Other, /** We know the location, but it is somehow not covered by this enum */
518 Computer, /** The key is on this computer */
519 HardwareToken /** The key is on a dedicated hardware token, either a smartcard or a dedicated usb token (e.g. gnuk, nitrokey or yubikey) */
520 };
521
522 CertificateInfo();
523 explicit CertificateInfo(CertificateInfoPrivate *priv);
524 ~CertificateInfo();
525
526 /**
527 Returns true if certificate has no contents; otherwise returns false
528 */
529 bool isNull() const;
530
531 /**
532 The certificate version string.
533 */
534 int version() const;
535
536 /**
537 The certificate serial number.
538 */
539 QByteArray serialNumber() const;
540
541 /**
542 Information about the issuer.
543 */
544 QString issuerInfo(EntityInfoKey key) const;
545
546 /**
547 Information about the subject
548 */
549 QString subjectInfo(EntityInfoKey key) const;
550
551 /**
552 The certificate internal database nickname
553
554 \since 21.01
555 */
556 QString nickName() const;
557
558 /**
559 The date-time when certificate becomes valid.
560 */
561 QDateTime validityStart() const;
562
563 /**
564 The date-time when certificate expires.
565 */
566 QDateTime validityEnd() const;
567
568 /**
569 The uses allowed for the certificate.
570 */
571 KeyUsageExtensions keyUsageExtensions() const;
572
573 /**
574 The public key value.
575 */
576 QByteArray publicKey() const;
577
578 /**
579 The public key type.
580 */
581 PublicKeyType publicKeyType() const;
582
583 /**
584 The strength of public key in bits.
585 */
586 int publicKeyStrength() const;
587
588 /**
589 Returns true if certificate is self-signed otherwise returns false.
590 */
591 bool isSelfSigned() const;
592
593 /**
594 The DER encoded certificate.
595 */
596 QByteArray certificateData() const;
597
598 /**
599 Checks if the given password is the correct one for this certificate
600
601 \since 21.01
602 */
603 bool checkPassword(const QString &password) const;
604
605 /**
606 The storage location for this key
607
608 \since 23.09
609 */
610 KeyLocation keyLocation() const;
611
612 CertificateInfo(const CertificateInfo &other);
613 CertificateInfo &operator=(const CertificateInfo &other);
614
615private:
616 Q_DECLARE_PRIVATE(CertificateInfo)
617
618 QSharedPointer<CertificateInfoPrivate> d_ptr;
619};
620Q_DECLARE_OPERATORS_FOR_FLAGS(CertificateInfo::KeyUsageExtensions)
621
622/**
623 A signature validation info helper class.
624 */
625class SignatureValidationInfoPrivate;
626class POPPLER_QT6_EXPORT SignatureValidationInfo
627{
628public:
629 /**
630 The verification result of the signature.
631 */
632 enum SignatureStatus
633 {
634 SignatureValid, ///< The signature is cryptographically valid.
635 SignatureInvalid, ///< The signature is cryptographically invalid.
636 SignatureDigestMismatch, ///< The document content was changed after the signature was applied.
637 SignatureDecodingError, ///< The signature CMS/PKCS7 structure is malformed.
638 SignatureGenericError, ///< The signature could not be verified.
639 SignatureNotFound, ///< The requested signature is not present in the document.
640 SignatureNotVerified ///< The signature is not yet verified.
641 };
642
643 /**
644 The verification result of the certificate.
645 */
646 enum CertificateStatus
647 {
648 CertificateTrusted, ///< The certificate is considered trusted.
649 CertificateUntrustedIssuer, ///< The issuer of this certificate has been marked as untrusted by the user.
650 CertificateUnknownIssuer, ///< The certificate trust chain has not finished in a trusted root certificate.
651 CertificateRevoked, ///< The certificate was revoked by the issuing certificate authority.
652 CertificateExpired, ///< The signing time is outside the validity bounds of this certificate.
653 CertificateGenericError, ///< The certificate could not be verified.
654 CertificateNotVerified, ///< The certificate is not yet verified.
655 CertificateVerificationInProgress ///< The certificate is not yet verified but is in progress in the background. See \ref validateAsync \since 24.05
656 };
657
658 /**
659 The hash algorithm of the signature
660 */
661 enum HashAlgorithm
662 {
663 HashAlgorithmUnknown,
664 HashAlgorithmMd2,
665 HashAlgorithmMd5,
666 HashAlgorithmSha1,
667 HashAlgorithmSha256,
668 HashAlgorithmSha384,
669 HashAlgorithmSha512,
670 HashAlgorithmSha224
671 };
672
673 /// \cond PRIVATE
674 explicit SignatureValidationInfo(SignatureValidationInfoPrivate *priv);
675 /// \endcond
676 ~SignatureValidationInfo();
677
678 /**
679 The signature status of the signature.
680 */
681 SignatureStatus signatureStatus() const;
682
683 /**
684 The certificate status of the signature.
685 */
686 CertificateStatus certificateStatus() const;
687
688 /**
689 The signer name associated with the signature.
690 */
691 QString signerName() const;
692
693 /**
694 The signer subject distinguished name associated with the signature.
695 */
696 QString signerSubjectDN() const;
697
698 /**
699 Get signing location.
700 */
701 QString location() const;
702
703 /**
704 Get signing reason.
705 */
706 QString reason() const;
707
708 /**
709 The hash algorithm used for the signature.
710 */
711 HashAlgorithm hashAlgorithm() const;
712
713 /**
714 The signing time associated with the signature.
715 */
716 time_t signingTime() const;
717
718 /**
719 Get the signature binary data.
720 */
721 QByteArray signature() const;
722
723 /**
724 Get the bounds of the ranges of the document which are signed.
725 */
726 QList<qint64> signedRangeBounds() const;
727
728 /**
729 Checks whether the signature authenticates the total document
730 except for the signature itself.
731 */
732 bool signsTotalDocument() const;
733
734 /**
735 The signer certificate info.
736 */
737 CertificateInfo certificateInfo() const;
738
739 SignatureValidationInfo(const SignatureValidationInfo &other);
740 SignatureValidationInfo &operator=(const SignatureValidationInfo &other);
741
742private:
743 Q_DECLARE_PRIVATE(SignatureValidationInfo)
744 friend class FormFieldSignature;
745 QSharedPointer<SignatureValidationInfoPrivate> d_ptr;
746};
747
748/**
749 * Object help waiting for some async event
750 *
751 * \since 24.05
752 */
753class AsyncObjectPrivate;
754class POPPLER_QT6_EXPORT AsyncObject : public QObject // clazy:exclude=ctor-missing-parent-argument
755{
756 Q_OBJECT
757public:
758 /* Constructor. On purpose not having a QObject parameter
759 It will be returned by shared_ptr or unique_ptr
760 */
761 AsyncObject();
762 ~AsyncObject() override;
763Q_SIGNALS:
764 void done();
765public Q_SLOTS:
766private:
767 std::unique_ptr<AsyncObjectPrivate> d;
768};
769
770/**
771 A form field that represents a signature.
772 */
773class POPPLER_QT6_EXPORT FormFieldSignature : public FormField
774{
775public:
776 /**
777 The types of signature fields.
778 */
779 enum SignatureType
780 {
781 UnknownSignatureType,
782 AdbePkcs7sha1,
783 AdbePkcs7detached,
784 EtsiCAdESdetached,
785 UnsignedSignature ///< \since 22.02
786 };
787
788 /**
789 The validation options of this signature.
790 */
791 enum ValidateOptions
792 {
793 ValidateVerifyCertificate = 1, ///< Validate the certificate.
794 ValidateForceRevalidation = 2, ///< Force revalidation of the certificate.
795 ValidateWithoutOCSPRevocationCheck = 4, ///< Do not contact OCSP servers to check for certificate revocation status \since 21.10
796 ValidateUseAIACertFetch = 8 ///< Use the AIA extension for certificate fetching \since 21.10
797 };
798
799 /// \cond PRIVATE
800 FormFieldSignature(DocumentData *doc, ::Page *p, ::FormWidgetSignature *w);
801 /// \endcond
802 ~FormFieldSignature() override;
803
804 FormType type() const override;
805
806 /**
807 The signature type
808 */
809 SignatureType signatureType() const;
810
811 /**
812 Validate the signature with now as validation time.
813
814 Reset signature validatation info of scoped instance.
815
816 \note depending on the backend, some options are only
817 partially respected. In case of the NSS backend, the two options
818 requiring network access, AIAFetch and OCSP,
819 can be toggled individually. In case of the GPG backend, if either
820 OCSP is used or AIAFetch is used, the other one is also used.
821
822 \deprecated Please rewrite to the async version, that allows the network traffic part of fetching to happen in the background
823 */
824 POPPLER_QT6_DEPRECATED SignatureValidationInfo validate(ValidateOptions opt) const;
825
826 /**
827 Validate the signature with @p validationTime as validation time.
828
829 Reset signature validatation info of scoped instance.
830
831 \note depending on the backend, some options are only
832 partially respected. In case of the NSS backend, the two options
833 requiring network access, AIAFetch and OCSP,
834 can be toggled individually. In case of the GPG backend, if either
835 OCSP is used or AIAFetch is used, the other one is also used.
836
837 \deprecated Please rewrite to the async version, that allows the network traffic part of fetching to happen in the background
838 */
839 POPPLER_QT6_DEPRECATED SignatureValidationInfo validate(int opt, const QDateTime &validationTime) const;
840
841 /**
842 Validate the signature with @p validationTime as validation time.
843
844 Reset signature validatation info of scoped instance.
845
846 \since 24.05
847
848 \note depending on the backend, some options are only
849 partially respected. In case of the NSS backend, the two options
850 requiring network access, AIAFetch and OCSP,
851 can be toggled individually. In case of the GPG backend, if either
852 OCSP is used or AIAFetch is used, the other one is also used.
853
854 \note certificate validation will have started when this function return. See \ref validateResult on how to get certifcate validation
855 \note connections to \ref AsyncObject must happen by the caller
856 before returning control to the event loop, else signals is not guaranteed to be delivered
857 */
858 std::pair<SignatureValidationInfo, std::shared_ptr<AsyncObject>> validateAsync(ValidateOptions opt, const QDateTime &validationTime = {}) const;
859
860 /**
861 * \return the updated signature validation info from validateAsync
862 * \note that this function will block if the result is not yet ready.
863 * Wait for the \ref AsyncObject::done signal to avoid this function blocking on an inconvenient time
864 *
865 * \since 24.05
866 */
867 SignatureValidationInfo::CertificateStatus validateResult() const;
868
869 /**
870 * \since 22.02
871 */
872 enum SigningResult
873 {
874 FieldAlreadySigned, ///< Trying to sign a field that is already signed
875 GenericSigningError,
876 SigningSuccess
877 };
878
879 /**
880 Signs a field of UnsignedSignature type.
881
882 Ignores data.page(), data.fieldPartialName() and data.boundingRectangle()
883
884 \since 22.02
885 */
886 SigningResult sign(const QString &outputFileName, const PDFConverter::NewSignatureData &data) const;
887
888private:
889 Q_DISABLE_COPY(FormFieldSignature)
890};
891/**
892 * Possible compiled in backends for signature handling
893 *
894 * \since 23.06
895 */
896enum class CryptoSignBackend
897{
898 NSS,
899 GPG
900};
901
902/**
903 * The available compiled-in backends
904 *
905 * \since 23.06
906 */
907QVector<CryptoSignBackend> POPPLER_QT6_EXPORT availableCryptoSignBackends();
908
909/**
910 * Returns current active backend or nullopt if none is active
911 *
912 * \note there will always be an active backend if there is available backends
913 *
914 * \since 23.06
915 */
916std::optional<CryptoSignBackend> POPPLER_QT6_EXPORT activeCryptoSignBackend();
917
918/**
919 * Sets active backend
920 *
921 * \return true on success
922 *
923 * \since 23.06
924 */
925bool POPPLER_QT6_EXPORT setActiveCryptoSignBackend(CryptoSignBackend backend);
926
927enum class CryptoSignBackendFeature
928{
929 /// If the backend itself out of band requests passwords
930 /// or if the host applicaion somehow must do it
931 BackendAsksPassphrase
932};
933
934/**
935 * Queries if a backend supports or not supports a given feature.
936 *
937 * \since 23.06
938 */
939bool POPPLER_QT6_EXPORT hasCryptoSignBackendFeature(CryptoSignBackend, CryptoSignBackendFeature);
940
941/**
942 Returns is poppler was compiled with NSS support
943
944 \deprecated Use availableBackends instead
945
946 \since 21.01
947*/
948bool POPPLER_QT6_DEPRECATED POPPLER_QT6_EXPORT hasNSSSupport();
949
950/**
951 Return vector of suitable signing certificates
952
953 \since 21.01
954*/
955QVector<CertificateInfo> POPPLER_QT6_EXPORT getAvailableSigningCertificates();
956
957/**
958 Gets the current NSS CertDB directory
959
960 \since 21.01
961*/
962QString POPPLER_QT6_EXPORT getNSSDir();
963
964/**
965 Set a custom NSS CertDB directory. Needs to be called before doing any other signature operation
966
967 \since 21.01
968*/
969void POPPLER_QT6_EXPORT setNSSDir(const QString &pathURL);
970
971/**
972 Sets the callback for NSS password requests
973
974 \since 21.01
975*/
976void POPPLER_QT6_EXPORT setNSSPasswordCallback(const std::function<char *(const char *)> &f);
977}
978
979#endif
980

source code of poppler/qt6/src/poppler-form.h