File indexing completed on 2024-06-23 05:14:10

0001 /* -*- mode: c++; c-basic-offset:4 -*-
0002     newcertificatewizard/wizardpage_p.h
0003 
0004     This file is part of Kleopatra, the KDE keymanager
0005     SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
0006 
0007     SPDX-FileCopyrightText: 2016, 2017 Bundesamt für Sicherheit in der Informationstechnik
0008     SPDX-FileContributor: Intevation GmbH
0009 
0010     SPDX-License-Identifier: GPL-2.0-or-later
0011 */
0012 
0013 #pragma once
0014 
0015 #include "newcertificatewizard.h"
0016 
0017 #include "utils/metatypes_for_gpgmepp_key.h"
0018 
0019 #include <QDate>
0020 #include <QDir>
0021 #include <QVariant>
0022 #include <QWizardPage>
0023 
0024 #include <gpgme++/key.h>
0025 
0026 namespace Kleo
0027 {
0028 namespace NewCertificateUi
0029 {
0030 
0031 class WizardPage : public QWizardPage
0032 {
0033     Q_OBJECT
0034 protected:
0035     explicit WizardPage(QWidget *parent = nullptr)
0036         : QWizardPage(parent)
0037     {
0038     }
0039 
0040     NewCertificateWizard *wizard() const
0041     {
0042         Q_ASSERT(static_cast<NewCertificateWizard *>(QWizardPage::wizard()) == qobject_cast<NewCertificateWizard *>(QWizardPage::wizard()));
0043         return static_cast<NewCertificateWizard *>(QWizardPage::wizard());
0044     }
0045 
0046     bool pgp() const
0047     {
0048         return wizard()->protocol() == GpgME::OpenPGP;
0049     }
0050 
0051     void restartAtEnterDetailsPage()
0052     {
0053         wizard()->restartAtEnterDetailsPage();
0054     }
0055 
0056     QDir tmpDir() const
0057     {
0058         return wizard()->tmpDir();
0059     }
0060 
0061 protected:
0062 #define FIELD(type, name)                                                                                                                                      \
0063     type name() const                                                                                                                                          \
0064     {                                                                                                                                                          \
0065         return field(QStringLiteral(#name)).value<type>();                                                                                                     \
0066     }
0067     FIELD(bool, signingAllowed)
0068     FIELD(bool, encryptionAllowed)
0069     FIELD(bool, certificationAllowed)
0070     FIELD(bool, authenticationAllowed)
0071 
0072     FIELD(QString, name)
0073     FIELD(QString, email)
0074     FIELD(QString, dn)
0075     FIELD(bool, protectedKey)
0076 
0077     FIELD(GpgME::Subkey::PubkeyAlgo, keyType)
0078     FIELD(int, keyStrength)
0079     FIELD(QString, keyCurve)
0080 
0081     FIELD(GpgME::Subkey::PubkeyAlgo, subkeyType)
0082     FIELD(int, subkeyStrength)
0083     FIELD(QString, subkeyCurve)
0084 
0085     FIELD(QDate, expiryDate)
0086 
0087     FIELD(QStringList, additionalUserIDs)
0088     FIELD(QStringList, additionalEMailAddresses)
0089     FIELD(QStringList, dnsNames)
0090     FIELD(QStringList, uris)
0091 
0092     FIELD(QString, url)
0093     FIELD(QString, error)
0094     FIELD(QString, result)
0095     FIELD(QString, fingerprint)
0096 #undef FIELD
0097 };
0098 
0099 } // namespace NewCertificateUi
0100 } // namespace Kleo