File indexing completed on 2024-06-23 05:13:53

0001 /* -*- mode: c++; c-basic-offset:4 -*-
0002     crypto/gui/signerresolvepage.h
0003 
0004     This file is part of Kleopatra, the KDE keymanager
0005     SPDX-FileCopyrightText: 2007 Klarälvdalens Datakonsult AB
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #pragma once
0011 
0012 #include <crypto/gui/wizardpage.h>
0013 
0014 #include <utils/pimpl_ptr.h>
0015 
0016 #include <KMime/Types>
0017 #include <gpgme++/global.h>
0018 
0019 #include <memory>
0020 #include <set>
0021 #include <vector>
0022 
0023 namespace GpgME
0024 {
0025 class Key;
0026 }
0027 
0028 namespace Kleo
0029 {
0030 namespace Crypto
0031 {
0032 
0033 class SigningPreferences;
0034 
0035 namespace Gui
0036 {
0037 class SignerResolvePage : public WizardPage
0038 {
0039     Q_OBJECT
0040 public:
0041     explicit SignerResolvePage(QWidget *parent = nullptr, Qt::WindowFlags f = {});
0042     ~SignerResolvePage() override;
0043 
0044     void setSignersAndCandidates(const std::vector<KMime::Types::Mailbox> &signers, const std::vector<std::vector<GpgME::Key>> &keys);
0045 
0046     std::vector<GpgME::Key> resolvedSigners() const;
0047     std::vector<GpgME::Key> signingCertificates(GpgME::Protocol protocol = GpgME::UnknownProtocol) const;
0048 
0049     bool isComplete() const override;
0050 
0051     bool encryptionSelected() const;
0052     void setEncryptionSelected(bool selected);
0053 
0054     bool signingSelected() const;
0055     void setSigningSelected(bool selected);
0056 
0057     bool isEncryptionUserMutable() const;
0058     void setEncryptionUserMutable(bool ismutable);
0059 
0060     bool isSigningUserMutable() const;
0061     void setSigningUserMutable(bool ismutable);
0062 
0063     bool isAsciiArmorEnabled() const;
0064     void setAsciiArmorEnabled(bool enabled);
0065 
0066     void setPresetProtocol(GpgME::Protocol protocol);
0067     void setPresetProtocols(const std::vector<GpgME::Protocol> &protocols);
0068 
0069     std::set<GpgME::Protocol> selectedProtocols() const;
0070 
0071     std::set<GpgME::Protocol> selectedProtocolsWithoutSigningCertificate() const;
0072 
0073     void setMultipleProtocolsAllowed(bool allowed);
0074     bool multipleProtocolsAllowed() const;
0075 
0076     void setProtocolSelectionUserMutable(bool ismutable);
0077     bool protocolSelectionUserMutable() const;
0078 
0079     enum Operation {
0080         SignAndEncrypt = 0,
0081         SignOnly,
0082         EncryptOnly,
0083     };
0084 
0085     Operation operation() const;
0086 
0087     class Validator
0088     {
0089     public:
0090         virtual ~Validator()
0091         {
0092         }
0093         virtual bool isComplete() const = 0;
0094         virtual QString explanation() const = 0;
0095         /**
0096          * returns a custom window title, or a null string if no custom
0097          * title is required.
0098          * (use this if the title needs dynamic adaption
0099          * depending on the user's selection)
0100          */
0101         virtual QString customWindowTitle() const = 0;
0102     };
0103 
0104     void setValidator(const std::shared_ptr<Validator> &);
0105     std::shared_ptr<Validator> validator() const;
0106 
0107     void setSigningPreferences(const std::shared_ptr<SigningPreferences> &prefs);
0108     std::shared_ptr<SigningPreferences> signingPreferences() const;
0109 
0110 private:
0111     void onNext() override;
0112 
0113 private:
0114     class Private;
0115     kdtools::pimpl_ptr<Private> d;
0116 
0117     Q_PRIVATE_SLOT(d, void operationButtonClicked(int))
0118     Q_PRIVATE_SLOT(d, void selectCertificates())
0119     Q_PRIVATE_SLOT(d, void updateUi())
0120 };
0121 }
0122 }
0123 }