File indexing completed on 2025-01-19 04:51:57

0001 /*
0002     Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
0003 
0004     This library is free software; you can redistribute it and/or modify it
0005     under the terms of the GNU Library General Public License as published by
0006     the Free Software Foundation; either version 2 of the License, or (at your
0007     option) any later version.
0008 
0009     This library is distributed in the hope that it will be useful, but WITHOUT
0010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
0012     License for more details.
0013 
0014     You should have received a copy of the GNU Library General Public License
0015     along with this library; see the file COPYING.LIB.  If not, write to the
0016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0017     02110-1301, USA.
0018 */
0019 #pragma once
0020 
0021 #include <QObject>
0022 
0023 #include <QAbstractItemModel>
0024 #include <QModelIndex>
0025 
0026 #include <memory>
0027 
0028 namespace MimeTreeParser {
0029     class ObjectTreeParser;
0030 }
0031 class PartModelPrivate;
0032 
0033 class PartModel : public QAbstractItemModel {
0034     Q_OBJECT
0035     Q_PROPERTY(bool showHtml READ showHtml WRITE setShowHtml NOTIFY showHtmlChanged)
0036     Q_PROPERTY(bool containsHtml READ containsHtml NOTIFY containsHtmlChanged)
0037     Q_PROPERTY(bool trimMail READ trimMail WRITE setTrimMail NOTIFY trimMailChanged)
0038     Q_PROPERTY(bool isTrimmed READ isTrimmed NOTIFY trimMailChanged)
0039 public:
0040     PartModel(std::shared_ptr<MimeTreeParser::ObjectTreeParser> parser);
0041     ~PartModel();
0042 
0043     static std::pair<QString, bool> trim(const QString &text);
0044 
0045 public:
0046     enum Roles {
0047         TypeRole  = Qt::UserRole + 1,
0048         ContentRole,
0049         IsEmbeddedRole,
0050         IsEncryptedRole,
0051         IsSignedRole,
0052         IsErrorRole,
0053         SecurityLevelRole,
0054         EncryptionSecurityLevelRole,
0055         SignatureSecurityLevelRole,
0056         SignatureDetails,
0057         EncryptionDetails,
0058         ErrorType,
0059         ErrorString,
0060         SenderRole,
0061         DateRole
0062     };
0063 
0064     QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
0065     QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
0066     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
0067     QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE;
0068     int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
0069     int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
0070 
0071     void setShowHtml(bool html);
0072     bool showHtml() const;
0073     bool containsHtml() const;
0074 
0075     void setTrimMail(bool trim);
0076     bool trimMail() const;
0077     bool isTrimmed() const;
0078 
0079 signals:
0080     void showHtmlChanged();
0081     void trimMailChanged();
0082     void containsHtmlChanged();
0083 
0084 private:
0085     std::unique_ptr<PartModelPrivate> d;
0086 };
0087 
0088 class SignatureInfo : public QObject
0089 {
0090     Q_OBJECT
0091     Q_PROPERTY(QByteArray keyId MEMBER keyId CONSTANT)
0092     Q_PROPERTY(bool keyMissing MEMBER keyMissing CONSTANT)
0093     Q_PROPERTY(bool keyRevoked MEMBER keyRevoked CONSTANT)
0094     Q_PROPERTY(bool keyExpired MEMBER keyExpired CONSTANT)
0095     Q_PROPERTY(bool sigExpired MEMBER sigExpired CONSTANT)
0096     Q_PROPERTY(bool crlMissing MEMBER crlMissing CONSTANT)
0097     Q_PROPERTY(bool crlTooOld MEMBER crlTooOld CONSTANT)
0098 
0099     Q_PROPERTY(QString signer MEMBER signer CONSTANT)
0100     Q_PROPERTY(QStringList signerMailAddresses MEMBER signerMailAddresses CONSTANT)
0101     Q_PROPERTY(bool signatureIsGood MEMBER signatureIsGood CONSTANT)
0102     Q_PROPERTY(bool keyIsTrusted MEMBER keyIsTrusted CONSTANT)
0103 
0104 public:
0105     bool keyRevoked = false;
0106     bool keyExpired = false;
0107     bool sigExpired = false;
0108     bool keyMissing = false;
0109     bool crlMissing = false;
0110     bool crlTooOld = false;
0111     QByteArray keyId;
0112 
0113     QString signer;
0114     QStringList signerMailAddresses;
0115     bool signatureIsGood = false;
0116     bool keyIsTrusted = false;
0117 };
0118