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

0001 /* -*- mode: c++; c-basic-offset:4 -*-
0002     newcertificatewizard/advancedsettingsdialog_p.h
0003 
0004     This file is part of Kleopatra, the KDE keymanager
0005     SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
0006     SPDX-FileCopyrightText: 2016, 2017 Bundesamt für Sicherheit in der Informationstechnik
0007     SPDX-FileContributor: Intevation GmbH
0008     SPDX-FileCopyrightText: 2022 g10 Code GmbH
0009     SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
0010 
0011     SPDX-License-Identifier: GPL-2.0-or-later
0012 */
0013 
0014 #pragma once
0015 
0016 #include "utils/metatypes_for_gpgmepp_key.h"
0017 
0018 #include <QDialog>
0019 
0020 #include <gpgme++/key.h>
0021 
0022 #include <memory>
0023 
0024 class AdvancedSettingsDialog : public QDialog
0025 {
0026     Q_OBJECT
0027     Q_PROPERTY(QStringList additionalUserIDs READ additionalUserIDs WRITE setAdditionalUserIDs)
0028     Q_PROPERTY(QStringList additionalEMailAddresses READ additionalEMailAddresses WRITE setAdditionalEMailAddresses)
0029     Q_PROPERTY(QStringList dnsNames READ dnsNames WRITE setDnsNames)
0030     Q_PROPERTY(QStringList uris READ uris WRITE setUris)
0031     Q_PROPERTY(uint keyStrength READ keyStrength WRITE setKeyStrength)
0032     Q_PROPERTY(GpgME::Subkey::PubkeyAlgo keyType READ keyType WRITE setKeyType)
0033     Q_PROPERTY(QString keyCurve READ keyCurve WRITE setKeyCurve)
0034     Q_PROPERTY(uint subkeyStrength READ subkeyStrength WRITE setSubkeyStrength)
0035     Q_PROPERTY(QString subkeyCurve READ subkeyCurve WRITE setSubkeyCurve)
0036     Q_PROPERTY(GpgME::Subkey::PubkeyAlgo subkeyType READ subkeyType WRITE setSubkeyType)
0037     Q_PROPERTY(bool signingAllowed READ signingAllowed WRITE setSigningAllowed)
0038     Q_PROPERTY(bool encryptionAllowed READ encryptionAllowed WRITE setEncryptionAllowed)
0039     Q_PROPERTY(bool certificationAllowed READ certificationAllowed WRITE setCertificationAllowed)
0040     Q_PROPERTY(bool authenticationAllowed READ authenticationAllowed WRITE setAuthenticationAllowed)
0041     Q_PROPERTY(QDate expiryDate READ expiryDate WRITE setExpiryDate)
0042 public:
0043     explicit AdvancedSettingsDialog(QWidget *parent = nullptr);
0044     ~AdvancedSettingsDialog() override;
0045 
0046     bool unlimitedValidityIsAllowed() const;
0047 
0048     void setProtocol(GpgME::Protocol proto);
0049 
0050     void setAdditionalUserIDs(const QStringList &items);
0051     QStringList additionalUserIDs() const;
0052 
0053     void setAdditionalEMailAddresses(const QStringList &items);
0054     QStringList additionalEMailAddresses() const;
0055 
0056     void setDnsNames(const QStringList &items);
0057     QStringList dnsNames() const;
0058 
0059     void setUris(const QStringList &items);
0060     QStringList uris() const;
0061 
0062     void setKeyStrength(unsigned int strength);
0063     unsigned int keyStrength() const;
0064 
0065     void setKeyType(GpgME::Subkey::PubkeyAlgo algo);
0066     GpgME::Subkey::PubkeyAlgo keyType() const;
0067 
0068     void setKeyCurve(const QString &curve);
0069     QString keyCurve() const;
0070 
0071     void setSubkeyType(GpgME::Subkey::PubkeyAlgo algo);
0072     GpgME::Subkey::PubkeyAlgo subkeyType() const;
0073 
0074     void setSubkeyCurve(const QString &curve);
0075     QString subkeyCurve() const;
0076 
0077     void setSubkeyStrength(unsigned int strength);
0078     unsigned int subkeyStrength() const;
0079 
0080     void setSigningAllowed(bool on);
0081     bool signingAllowed() const;
0082 
0083     void setEncryptionAllowed(bool on);
0084     bool encryptionAllowed() const;
0085 
0086     void setCertificationAllowed(bool on);
0087     bool certificationAllowed() const;
0088 
0089     void setAuthenticationAllowed(bool on);
0090     bool authenticationAllowed() const;
0091 
0092     QDate forceDateIntoAllowedRange(QDate date) const;
0093 
0094     void setExpiryDate(QDate date);
0095     QDate expiryDate() const;
0096 
0097 Q_SIGNALS:
0098     void changed();
0099 
0100 private Q_SLOTS:
0101     void slotKeyMaterialSelectionChanged();
0102     void slotSigningAllowedToggled(bool on);
0103     void slotEncryptionAllowedToggled(bool on);
0104 
0105 private:
0106     void fillKeySizeComboBoxen();
0107     void loadDefaultKeyType();
0108     void loadDefaultExpiration();
0109     void loadDefaultGnuPGKeyType();
0110     void loadDefaults();
0111     void updateWidgetVisibility();
0112     void setInitialFocus();
0113 
0114 protected:
0115     void accept() override;
0116     void showEvent(QShowEvent *event) override;
0117 
0118 private:
0119     struct UI;
0120     std::unique_ptr<UI> ui;
0121 
0122     GpgME::Protocol protocol = GpgME::UnknownProtocol;
0123     unsigned int pgpDefaultAlgorithm = GpgME::Subkey::AlgoELG_E;
0124     unsigned int cmsDefaultAlgorithm = GpgME::Subkey::AlgoRSA;
0125     bool keyTypeImmutable = false;
0126     bool mECCSupported;
0127     bool mEdDSASupported;
0128     bool isFirstShowEvent = true;
0129 };