KHealthCertificate

kvaccinationcertificate.cpp
1 /*
2  * SPDX-FileCopyrightText: 2021 Volker Krause <[email protected]>
3  * SPDX-License-Identifier: LGPL-2.0-or-later
4  */
5 
6 #include "kvaccinationcertificate.h"
7 #include "khealthcertificatetypes_p.h"
8 
9 class KVaccinationCertificatePrivate : public QSharedData
10 {
11 public:
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;
23  QString certificateIssuer;
24  QString certificateId;
25  QDateTime certificateIssueDate;
26  QDateTime certificateExpiryDate;
27  QByteArray rawData;
29 };
30 
31 KHEALTHCERTIFICATE_MAKE_GADGET(Vaccination)
32 KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QString, name, setName)
33 KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QDate, dateOfBirth, setDateOfBirth)
34 KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QDate, date, setDate)
35 KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QString, disease, setDisease)
36 KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QString, vaccineType, setVaccineType)
37 KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QString, vaccine, setVaccine)
38 KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QUrl, vaccineUrl, setVaccineUrl)
39 KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QString, manufacturer, setManufacturer)
40 KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, int, dose, setDose)
41 KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, int, totalDoses, setTotalDoses)
42 KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QString, country, setCountry)
43 KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QString, certificateIssuer, setCertificateIssuer)
44 KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QString, certificateId, setCertificateId)
45 KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QDateTime, certificateIssueDate, setCertificateIssueDate)
46 KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QDateTime, certificateExpiryDate, setCertificateExpiryDate)
47 KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, QByteArray, rawData, setRawData)
48 KHEALTHCERTIFICATE_MAKE_PROPERTY(Vaccination, KHealthCertificate::SignatureValidation, signatureState, setSignatureState)
49 
50 KHealthCertificate::CertificateValidation KVaccinationCertificate::validationState() const
51 {
52  if (d->certificateIssueDate > QDateTime::currentDateTime() || (d->certificateExpiryDate.isValid() && d->certificateExpiryDate < QDateTime::currentDateTime())) {
53  return KHealthCertificate::Invalid;
54  }
55  if (d->signatureState == KHealthCertificate::InvalidSignature) {
56  return KHealthCertificate::Invalid;
57  }
58  if (d->date > QDate::currentDate() || (d->dose == 0 && d->totalDoses)) {
59  return KHealthCertificate::Invalid;
60  }
61 
62  if (d->date.addDays(14) >= QDate::currentDate()) {
63  return KHealthCertificate::Partial;
64  }
65  if (d->dose < d->totalDoses) {
66  return KHealthCertificate::Partial;
67  }
68  if (d->signatureState == KHealthCertificate::UnknownSignature) {
69  return KHealthCertificate::Partial;
70  }
71 
72  return KHealthCertificate::Valid;
73 }
74 
75 #include "moc_kvaccinationcertificate.cpp"
QStringView country(QStringView ifopt)
Dummy RTTI for QML, which doesn&#39;t support instanceof on Q_GADGETs...
QString name(const QVariant &location)
SignatureValidation
Result of attempting to verify the cryptographic signature of a certificate.
signature verification was attempted but didn&#39;t yield a result, e.g. due to a missing certificate of ...
QDateTime currentDateTime()
QDate currentDate()
A vaccination certificate.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 18 2021 23:21:56 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.