File indexing completed on 2024-06-23 05:13:49
0001 /* crypto/gui/certificateselectionline.h 0002 0003 This file is part of Kleopatra, the KDE keymanager 0004 SPDX-FileCopyrightText: 2009 Klarälvdalens Datakonsult AB 0005 0006 SPDX-FileCopyrightText: 2016 Bundesamt für Sicherheit in der Informationstechnik 0007 SPDX-FileContributor: Intevation GmbH 0008 0009 SPDX-License-Identifier: GPL-2.0-or-later 0010 */ 0011 0012 #pragma once 0013 0014 #include <QGridLayout> 0015 #include <QString> 0016 #include <vector> 0017 0018 #include <gpgme++/key.h> 0019 0020 class QToolButton; 0021 class QLabel; 0022 class QStackedWidget; 0023 0024 namespace Kleo 0025 { 0026 0027 class KeysComboBox; 0028 0029 class CertificateSelectionLine 0030 { 0031 public: 0032 /** Number of columns needed in the gridlayout. */ 0033 static const unsigned int NumColumns = 4; 0034 0035 /** Create a certificateselection line that distinguishes between protocols. 0036 * 0037 * Ambiguity means here that there is not a single valid choice or that 0038 * soemthing is not selected. There are basically two modes here, one is 0039 * for a protocol specific selection, that is used mainly by GpgOL over assuan. 0040 * This is the constructor for that mode. The second mode does not care about 0041 * protocols. 0042 * 0043 * @param toFrom: An optional label. 0044 * @param mailbox: The Mailbox for which the certificate should be selected. 0045 * @param pgp: List of PGP Certificates. 0046 * @param pgpAmbig: Whether or not the PGP Cert is ambiguous. 0047 * @param cms: List of CMS Certificates. 0048 * @param cmsAmbig: Whether or not the CMS Cert is ambiguous. 0049 * @param q: Parent widget. 0050 * @param glay: Layout to add the widgets to. 0051 */ 0052 CertificateSelectionLine(const QString &toFrom, 0053 const QString &mailbox, 0054 const std::vector<GpgME::Key> &pgp, 0055 bool pgpAmbig, 0056 const std::vector<GpgME::Key> &cms, 0057 bool cmsAmbig, 0058 QWidget *q, 0059 QGridLayout &glay); 0060 0061 void showHide(GpgME::Protocol proto, bool &first, bool showAll, bool op) const; 0062 0063 bool wasInitiallyAmbiguous(GpgME::Protocol proto) const; 0064 0065 bool isStillAmbiguous(GpgME::Protocol proto) const; 0066 0067 QString mailboxText() const; 0068 0069 void addAndSelectCertificate(const GpgME::Key &key) const; 0070 0071 GpgME::Key key(GpgME::Protocol proto) const; 0072 0073 const QToolButton *toolButton() const; 0074 0075 void kill(); 0076 0077 KeysComboBox *comboBox(GpgME::Protocol proto) const; 0078 0079 private: 0080 bool pgpAmbiguous : 1; 0081 bool cmsAmbiguous : 1; 0082 0083 QLabel *mToFromLB; 0084 QLabel *mMailboxLB; 0085 QStackedWidget *mSbox; 0086 KeysComboBox *mPgpCB; 0087 KeysComboBox *mCmsCB; 0088 KeysComboBox *noProtocolCB; 0089 QToolButton *mToolTB; 0090 }; 0091 0092 } // namespace Kleo