File indexing completed on 2024-11-17 04:50:25
0001 /* 0002 defaultkeyfilter.h 0003 0004 This file is part of libkleopatra, the KDE keymanagement library 0005 SPDX-FileCopyrightText: 2004 Klarälvdalens Datakonsult AB 0006 0007 SPDX-FileCopyrightText: 2016 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 "keyfilter.h" 0016 #include "kleo_export.h" 0017 0018 #include <QColor> 0019 #include <QFont> 0020 #include <QString> 0021 0022 #include <gpgme++/key.h> 0023 0024 #include <memory> 0025 0026 namespace Kleo 0027 { 0028 0029 /** Default implementation of key filter class. */ 0030 class KLEO_EXPORT DefaultKeyFilter : public KeyFilter 0031 { 0032 public: 0033 DefaultKeyFilter(); 0034 ~DefaultKeyFilter() override; 0035 0036 /** Used for bool checks */ 0037 enum TriState { 0038 // clang-format off 0039 DoesNotMatter = 0, 0040 Set = 1, 0041 NotSet = 2, 0042 // clang-format on 0043 }; 0044 0045 /** Used for level checks */ 0046 enum LevelState { 0047 // clang-format off 0048 LevelDoesNotMatter = 0, 0049 Is = 1, 0050 IsNot = 2, 0051 IsAtLeast = 3, 0052 IsAtMost = 4, 0053 // clang-format on 0054 }; 0055 0056 bool matches(const GpgME::Key &key, MatchContexts ctx) const override; 0057 bool matches(const GpgME::UserID &userID, MatchContexts ctx) const override; 0058 0059 unsigned int specificity() const override; 0060 void setSpecificity(unsigned int value); 0061 QString id() const override; 0062 void setId(const QString &value); 0063 KeyFilter::MatchContexts availableMatchContexts() const override; 0064 void setMatchContexts(KeyFilter::MatchContexts value); 0065 0066 QColor fgColor() const override; 0067 void setFgColor(const QColor &value); 0068 0069 QColor bgColor() const override; 0070 void setBgColor(const QColor &value); 0071 0072 FontDescription fontDescription() const override; 0073 QString name() const override; 0074 void setName(const QString &value); 0075 QString icon() const override; 0076 void setIcon(const QString &value); 0077 QFont font() const; 0078 void setFont(const QFont &value); 0079 0080 TriState revoked() const; 0081 TriState expired() const; 0082 TriState invalid() const; 0083 TriState disabled() const; 0084 TriState root() const; 0085 TriState canEncrypt() const; 0086 TriState canSign() const; 0087 TriState canCertify() const; 0088 TriState canAuthenticate() const; 0089 TriState hasEncrypt() const; 0090 TriState hasSign() const; 0091 TriState hasCertify() const; 0092 TriState hasAuthenticate() const; 0093 TriState qualified() const; 0094 TriState cardKey() const; 0095 TriState hasSecret() const; 0096 TriState isOpenPGP() const; 0097 TriState wasValidated() const; 0098 TriState isDeVS() const; 0099 TriState isBad() const; 0100 0101 LevelState ownerTrust() const; 0102 GpgME::Key::OwnerTrust ownerTrustReferenceLevel() const; 0103 0104 LevelState validity() const; 0105 GpgME::UserID::Validity validityReferenceLevel() const; 0106 bool italic() const; 0107 bool bold() const; 0108 bool strikeOut() const; 0109 bool useFullFont() const; 0110 0111 void setRevoked(const TriState); 0112 void setExpired(const TriState); 0113 void setInvalid(const TriState); 0114 void setDisabled(const TriState); 0115 void setRoot(const TriState); 0116 void setCanEncrypt(const TriState); 0117 void setCanSign(const TriState); 0118 void setCanCertify(const TriState); 0119 void setCanAuthenticate(const TriState); 0120 void setHasEncrypt(const TriState); 0121 void setHasSign(const TriState); 0122 void setHasCertify(const TriState); 0123 void setHasAuthenticate(const TriState); 0124 void setQualified(const TriState); 0125 void setCardKey(const TriState); 0126 void setHasSecret(const TriState); 0127 void setIsOpenPGP(const TriState); 0128 void setWasValidated(const TriState); 0129 void setIsDeVs(const TriState); 0130 void setIsBad(const TriState); 0131 /** 0132 * If \p value is \c Set, then invalid S/MIME certificates do not match. 0133 * If \p value is \c NotSet, then valid S/MIME certificates do not match. 0134 */ 0135 void setValidIfSMIME(TriState value); 0136 TriState validIfSMIME() const; 0137 0138 void setOwnerTrust(const LevelState); 0139 void setOwnerTrustReferenceLevel(const GpgME::Key::OwnerTrust); 0140 0141 void setValidity(const LevelState); 0142 void setValidityReferenceLevel(const GpgME::UserID::Validity); 0143 0144 void setItalic(bool value); 0145 void setBold(bool value); 0146 void setStrikeOut(bool value); 0147 void setUseFullFont(bool value); 0148 0149 private: 0150 class Private; 0151 const std::unique_ptr<Private> d; 0152 }; 0153 0154 } // namespace Kleo