File indexing completed on 2024-12-22 05:05:20
0001 // SPDX-FileCopyrightText: 2016 Christian Mollekopf <mollekopf@kolabsys.com> 0002 // SPDX-License-Identifier: LGPL-2.0-or-later 0003 0004 #pragma once 0005 0006 #include <QAbstractItemModel> 0007 #include <QModelIndex> 0008 #include <gpgme++/decryptionresult.h> 0009 #include <gpgme++/key.h> 0010 0011 #include "mimetreeparser_core_export.h" 0012 #include <memory> 0013 0014 namespace QGpgME 0015 { 0016 class Protocol; 0017 } 0018 0019 namespace MimeTreeParser 0020 { 0021 class ObjectTreeParser; 0022 } 0023 class PartModelPrivate; 0024 0025 class MIMETREEPARSER_CORE_EXPORT PartModel : public QAbstractItemModel 0026 { 0027 Q_OBJECT 0028 Q_PROPERTY(bool showHtml READ showHtml WRITE setShowHtml NOTIFY showHtmlChanged) 0029 Q_PROPERTY(bool containsHtml READ containsHtml NOTIFY containsHtmlChanged) 0030 Q_PROPERTY(bool trimMail READ trimMail WRITE setTrimMail NOTIFY trimMailChanged) 0031 Q_PROPERTY(bool isTrimmed READ isTrimmed NOTIFY trimMailChanged) 0032 public: 0033 PartModel(std::shared_ptr<MimeTreeParser::ObjectTreeParser> parser); 0034 ~PartModel(); 0035 0036 static std::pair<QString, bool> trim(const QString &text); 0037 0038 public: 0039 enum class Types : quint8 { 0040 Error, 0041 Encapsulated, 0042 Ical, 0043 Plain, 0044 None, 0045 Html, 0046 }; 0047 Q_ENUM(Types); 0048 0049 enum Roles { 0050 TypeRole = Qt::UserRole + 1, 0051 ContentRole, 0052 IsEmbeddedRole, 0053 IsEncryptedRole, 0054 IsSignedRole, 0055 IsErrorRole, 0056 SecurityLevelRole, 0057 EncryptionSecurityLevelRole, 0058 SignatureSecurityLevelRole, 0059 SignatureDetails, 0060 EncryptionDetails, 0061 ErrorType, 0062 ErrorString, 0063 SenderRole, 0064 DateRole 0065 }; 0066 0067 enum SecurityLevel { 0068 Unknow, 0069 Good, 0070 NotSoGood, 0071 Bad, 0072 }; 0073 Q_ENUM(SecurityLevel); 0074 0075 QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; 0076 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; 0077 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; 0078 QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE; 0079 int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; 0080 int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; 0081 0082 void setShowHtml(bool html); 0083 bool showHtml() const; 0084 bool containsHtml() const; 0085 0086 void setTrimMail(bool trim); 0087 bool trimMail() const; 0088 bool isTrimmed() const; 0089 0090 Q_SIGNALS: 0091 void showHtmlChanged(); 0092 void trimMailChanged(); 0093 void containsHtmlChanged(); 0094 0095 private: 0096 std::unique_ptr<PartModelPrivate> d; 0097 }; 0098 0099 class MIMETREEPARSER_CORE_EXPORT SignatureInfo 0100 { 0101 Q_GADGET 0102 Q_PROPERTY(QByteArray keyId MEMBER keyId CONSTANT) 0103 Q_PROPERTY(bool keyMissing MEMBER keyMissing CONSTANT) 0104 Q_PROPERTY(bool keyRevoked MEMBER keyRevoked CONSTANT) 0105 Q_PROPERTY(bool keyExpired MEMBER keyExpired CONSTANT) 0106 Q_PROPERTY(bool sigExpired MEMBER sigExpired CONSTANT) 0107 Q_PROPERTY(bool crlMissing MEMBER crlMissing CONSTANT) 0108 Q_PROPERTY(bool crlTooOld MEMBER crlTooOld CONSTANT) 0109 0110 Q_PROPERTY(QString signer MEMBER signer CONSTANT) 0111 Q_PROPERTY(QStringList signerMailAddresses MEMBER signerMailAddresses CONSTANT) 0112 Q_PROPERTY(bool signatureIsGood MEMBER signatureIsGood CONSTANT) 0113 Q_PROPERTY(bool isCompliant MEMBER isCompliant CONSTANT) 0114 Q_PROPERTY(GpgME::Signature::Validity keyTrust MEMBER keyTrust CONSTANT) 0115 0116 public: 0117 bool keyRevoked = false; 0118 bool keyExpired = false; 0119 bool sigExpired = false; 0120 bool keyMissing = false; 0121 bool crlMissing = false; 0122 bool crlTooOld = false; 0123 bool isCompliant = false; 0124 GpgME::Signature::Validity keyTrust; 0125 QByteArray keyId; 0126 const QGpgME::Protocol *cryptoProto = nullptr; 0127 std::vector<std::pair<GpgME::DecryptionResult::Recipient, GpgME::Key>> decryptRecipients; 0128 0129 QString signer; 0130 QStringList signerMailAddresses; 0131 bool signatureIsGood = false; 0132 };