File indexing completed on 2024-11-24 04:44:41

0001 /*
0002  * SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
0003  * SPDX-License-Identifier: LGPL-2.0-or-later
0004  */
0005 
0006 #ifndef KHEALTHCERTIFICATE_H
0007 #define KHEALTHCERTIFICATE_H
0008 
0009 #include "khealthcertificate_export.h"
0010 #include <QMetaType>
0011 
0012 /** Dummy RTTI for QML, which doesn't support `instanceof` on Q_GADGETs... */
0013 class KHEALTHCERTIFICATE_EXPORT KHealthCertificate
0014 {
0015     Q_GADGET
0016 public:
0017     enum CertificateType {
0018         Vaccination,
0019         Test,
0020         Recovery,
0021     };
0022     Q_ENUM(CertificateType)
0023 
0024     enum CertificateValidation {
0025         Valid,
0026         Partial,
0027         Invalid,
0028         Unknown
0029     };
0030     Q_ENUM(CertificateValidation)
0031 
0032     /** Result of attempting to verify the cryptographic signature of a certificate. */
0033     enum SignatureValidation {
0034         ValidSignature, ///< signature is valid
0035         InvalidSignature, ///< signature is invalid
0036         UnknownSignature, ///< signature verification was attempted but didn't yield a result, e.g. due to a missing certificate of signing entity.
0037         UncheckedSignature, ///< signature verification was not attempted, e.g. as it's not yet implemented for the specific certificate type.
0038     };
0039     Q_ENUM(SignatureValidation)
0040 
0041     /** Returns the last date until @p certificate is relevant.
0042      *  That is, past the returned date, the certificate is considered expired and thus provides
0043      *  no or only very limited use anymore.
0044      *  This is useful for sorting a set of certificate in the UI in a meaningful way.
0045      */
0046     static QDateTime relevantUntil(const QVariant &certificate);
0047 };
0048 
0049 #endif // KHEALTHCERTIFICATE_H