KHealthCertificate

kvaccinationcertificate.cpp
1/*
2 * SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
3 * SPDX-License-Identifier: LGPL-2.0-or-later
4 */
5
6#include "kvaccinationcertificate.h"
7#include "khealthcertificatetypes_p.h"
8
9class KVaccinationCertificatePrivate : public QSharedData
10{
11public:
12 QString name;
13 QDate dateOfBirth;
14 QDate date;
15 QString disease;
16 QString vaccineType;
17 QString vaccine;
18 QUrl vaccineUrl;
19 QString manufacturer;
20 int dose = 0;
21 int totalDoses = 0;
22 QString country;
23 QString certificateIssuer;
24 QString certificateId;
25 QDateTime certificateIssueDate;
26 QDateTime certificateExpiryDate;
27 QByteArray rawData;
29};
30
31KHEALTHCERTIFICATE_MAKE_GADGET(Vaccination)
32KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QString, name, setName)
33KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QDate, dateOfBirth, setDateOfBirth)
34KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QDate, date, setDate)
35KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QString, disease, setDisease)
36KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QString, vaccineType, setVaccineType)
37KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QString, vaccine, setVaccine)
38KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QUrl, vaccineUrl, setVaccineUrl)
39KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QString, manufacturer, setManufacturer)
40KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, int, dose, setDose)
41KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, int, totalDoses, setTotalDoses)
42KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QString, country, setCountry)
43KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QString, certificateIssuer, setCertificateIssuer)
44KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QString, certificateId, setCertificateId)
45KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QDateTime, certificateIssueDate, setCertificateIssueDate)
46KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QDateTime, certificateExpiryDate, setCertificateExpiryDate)
47KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QByteArray, rawData, setRawData)
48KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, KHealthCertificate::SignatureValidation, signatureState, setSignatureState)
49
50KHealthCertificate::CertificateValidation KVaccinationCertificate::validationState() const
51{
52 const auto vacState = vaccinationState();
53 if (vacState == KVaccinationCertificate::Invalid || d->signatureState == KHealthCertificate::InvalidSignature) {
54 return KHealthCertificate::Invalid;
55 }
56
58 || d->signatureState == KHealthCertificate::UnknownSignature) {
59 return KHealthCertificate::Partial;
60 }
61
62 return KHealthCertificate::Valid;
63}
64
65KVaccinationCertificate::VaccinationState KVaccinationCertificate::vaccinationState() const
66{
67 if (d->certificateIssueDate > QDateTime::currentDateTime() || (d->certificateExpiryDate.isValid() && d->certificateExpiryDate < QDateTime::currentDateTime())) {
69 }
70 if (d->date > QDate::currentDate() || (d->dose == 0 && d->totalDoses)) {
72 }
73
74 if (d->date.addDays(14) >= QDate::currentDate() && (d->dose == 1 || (d->dose == 2 && d->totalDoses == 2))) {
76 }
77 if (d->dose < d->totalDoses) {
79 }
80
82}
83
84#include "moc_kvaccinationcertificate.cpp"
Dummy RTTI for QML, which doesn't support instanceof on Q_GADGETs...
SignatureValidation
Result of attempting to verify the cryptographic signature of a certificate.
@ InvalidSignature
signature is invalid
@ UnknownSignature
signature verification was attempted but didn't yield a result, e.g. due to a missing certificate of ...
A vaccination certificate.
VaccinationState
More detailed information about the vaccination certificate.
@ Invalid
certificate is invalid
@ Vaccinated
valid vaccination, but not information about a multi-dose requirement specified
@ PartiallyVaccinated
a multi-dose vaccination hasn't been fully applied yet
@ FullyVaccinated
complete vaccination with all required doses
@ VaccinationTooRecent
the vaccination happened too recently
QDate currentDate()
QDateTime currentDateTime()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:49:55 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.