1 /* -*- mode: c++; c-basic-offset:4 -*- 2 crypto/gui/signerresolvepage.h 3 4 This file is part of Kleopatra, the KDE keymanager 5 SPDX-FileCopyrightText: 2007 Klarälvdalens Datakonsult AB 6 7 SPDX-License-Identifier: GPL-2.0-or-later 8 */ 9 10 #pragma once 11 12 #include <crypto/gui/wizardpage.h> 13 14 #include <utils/pimpl_ptr.h> 15 16 #include <KMime/HeaderParsing> 17 #include <gpgme++/global.h> 18 19 #include <memory> 20 #include <set> 21 #include <vector> 22 23 namespace GpgME 24 { 25 class Key; 26 } 27 28 namespace Kleo 29 { 30 namespace Crypto 31 { 32 33 class SigningPreferences; 34 35 namespace Gui 36 { 37 class SignerResolvePage : public WizardPage 38 { 39 Q_OBJECT 40 public: 41 explicit SignerResolvePage(QWidget *parent = nullptr, Qt::WindowFlags f = {}); 42 ~SignerResolvePage() override; 43 44 void setSignersAndCandidates(const std::vector<KMime::Types::Mailbox> &signers, 45 const std::vector< std::vector<GpgME::Key> > &keys); 46 47 std::vector<GpgME::Key> resolvedSigners() const; 48 std::vector<GpgME::Key> signingCertificates(GpgME::Protocol protocol = GpgME::UnknownProtocol) const; 49 50 bool isComplete() const override; 51 52 bool encryptionSelected() const; 53 void setEncryptionSelected(bool selected); 54 55 bool signingSelected() const; 56 void setSigningSelected(bool selected); 57 58 bool isEncryptionUserMutable() const; 59 void setEncryptionUserMutable(bool ismutable); 60 61 bool isSigningUserMutable() const; 62 void setSigningUserMutable(bool ismutable); 63 64 bool isAsciiArmorEnabled() const; 65 void setAsciiArmorEnabled(bool enabled); 66 67 void setPresetProtocol(GpgME::Protocol protocol); 68 void setPresetProtocols(const std::vector<GpgME::Protocol> &protocols); 69 70 std::set<GpgME::Protocol> selectedProtocols() const; 71 72 std::set<GpgME::Protocol> selectedProtocolsWithoutSigningCertificate() const; 73 74 void setMultipleProtocolsAllowed(bool allowed); 75 bool multipleProtocolsAllowed() const; 76 77 void setProtocolSelectionUserMutable(bool ismutable); 78 bool protocolSelectionUserMutable() const; 79 80 enum Operation { 81 SignAndEncrypt = 0, 82 SignOnly, 83 EncryptOnly 84 }; 85 86 Operation operation() const; 87 88 class Validator 89 { 90 public: ~Validator()91 virtual ~Validator() {} 92 virtual bool isComplete() const = 0; 93 virtual QString explanation() const = 0; 94 /** 95 * returns a custom window title, or a null string if no custom 96 * title is required. 97 * (use this if the title needs dynamic adaption 98 * depending on the user's selection) 99 */ 100 virtual QString customWindowTitle() const = 0; 101 }; 102 103 void setValidator(const std::shared_ptr<Validator> &); 104 std::shared_ptr<Validator> validator() const; 105 106 void setSigningPreferences(const std::shared_ptr<SigningPreferences> &prefs); 107 std::shared_ptr<SigningPreferences> signingPreferences() const; 108 109 private: 110 void onNext() override; 111 112 private: 113 class Private; 114 kdtools::pimpl_ptr<Private> d; 115 116 Q_PRIVATE_SLOT(d, void operationButtonClicked(int)) 117 Q_PRIVATE_SLOT(d, void selectCertificates()) 118 Q_PRIVATE_SLOT(d, void updateUi()) 119 }; 120 } 121 } 122 } 123 124 125