summaryrefslogtreecommitdiffstats
path: root/framework/domain/messageparser.h
diff options
context:
space:
mode:
Diffstat (limited to 'framework/domain/messageparser.h')
-rw-r--r--framework/domain/messageparser.h157
1 files changed, 0 insertions, 157 deletions
diff --git a/framework/domain/messageparser.h b/framework/domain/messageparser.h
deleted file mode 100644
index aeeed93c..00000000
--- a/framework/domain/messageparser.h
+++ /dev/null
@@ -1,157 +0,0 @@
1/*
2 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20#pragma once
21
22#include <QObject>
23#include <QString>
24#include <QStringList>
25
26#include <QAbstractItemModel>
27#include <QModelIndex>
28
29#include <memory>
30#include <MimeTreeParser/MessagePart>
31
32class QAbstractItemModel;
33
34class Parser;
35class Part;
36class Encryption;
37class Signature;
38typedef std::shared_ptr<Part> PartPtr;
39class Content;
40typedef std::shared_ptr<Content> ContentPtr;
41class MessagePartPrivate;
42
43class NewModelPrivate;
44class AttachmentModelPrivate;
45
46class MessageParser : public QObject
47{
48 Q_OBJECT
49 Q_PROPERTY (QVariant message READ message WRITE setMessage)
50 Q_PROPERTY (QString html READ html NOTIFY htmlChanged)
51 Q_PROPERTY (QAbstractItemModel* partTree READ partTree NOTIFY htmlChanged)
52 Q_PROPERTY (QAbstractItemModel* newTree READ newTree NOTIFY htmlChanged)
53 Q_PROPERTY (QAbstractItemModel* attachments READ attachments NOTIFY htmlChanged)
54
55public:
56 explicit MessageParser(QObject *parent = Q_NULLPTR);
57 ~MessageParser();
58
59 QString html() const;
60
61 QVariant message() const;
62 void setMessage(const QVariant &to);
63 QAbstractItemModel *partTree() const;
64 QAbstractItemModel *newTree() const;
65 QAbstractItemModel *attachments() const;
66
67signals:
68 void htmlChanged();
69
70private:
71 std::unique_ptr<MessagePartPrivate> d;
72};
73
74class PartModel : public QAbstractItemModel {
75 Q_OBJECT
76public:
77 PartModel(QSharedPointer<MimeTreeParser::MessagePart> partTree, std::shared_ptr<Parser> parser);
78
79public:
80 enum Roles {
81 Text = Qt::UserRole + 1,
82 IsHtml,
83 IsEncrypted,
84 IsAttachment,
85 HasContent,
86 Type,
87 IsHidden
88 };
89
90 QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
91 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
92 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
93 QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE;
94 int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
95 int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
96
97private:
98 QSharedPointer<MimeTreeParser::MessagePart> mPartTree;
99 QMap<QByteArray, QUrl> mEmbeddedPartMap;
100 std::shared_ptr<Parser> mParser;
101};
102
103
104class NewModel : public QAbstractItemModel {
105 Q_OBJECT
106public:
107 NewModel(std::shared_ptr<Parser> parser);
108 ~NewModel();
109
110public:
111 enum Roles {
112 TypeRole = Qt::UserRole + 1,
113 ContentsRole,
114 ContentRole,
115 IsEmbededRole,
116 SecurityLevelRole,
117 EncryptionErrorType,
118 EncryptionErrorString
119 };
120
121 QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
122 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
123 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
124 QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE;
125 int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
126 int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
127
128private:
129 std::unique_ptr<NewModelPrivate> d;
130};
131
132class AttachmentModel : public QAbstractItemModel {
133 Q_OBJECT
134public:
135 AttachmentModel(std::shared_ptr<Parser> parser);
136 ~AttachmentModel();
137
138public:
139 enum Roles {
140 TypeRole = Qt::UserRole + 1,
141 IconRole,
142 NameRole,
143 SizeRole,
144 IsEncryptedRole,
145 IsSignedRole
146 };
147
148 QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
149 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
150 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
151 QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE;
152 int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
153 int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
154
155private:
156 std::unique_ptr<AttachmentModelPrivate> d;
157};