summaryrefslogtreecommitdiffstats
path: root/framework/src/domain/mime/mimetreeparser/interface.h
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/domain/mime/mimetreeparser/interface.h')
-rw-r--r--framework/src/domain/mime/mimetreeparser/interface.h379
1 files changed, 0 insertions, 379 deletions
diff --git a/framework/src/domain/mime/mimetreeparser/interface.h b/framework/src/domain/mime/mimetreeparser/interface.h
deleted file mode 100644
index 05ad32b9..00000000
--- a/framework/src/domain/mime/mimetreeparser/interface.h
+++ /dev/null
@@ -1,379 +0,0 @@
1/*
2 Copyright (c) 2016 Sandro Knauß <knauss@kolabsystems.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 <functional>
23#include <memory>
24#include <vector>
25
26#include <QDateTime>
27#include <QUrl>
28#include <QMimeType>
29
30class Part;
31class PartPrivate;
32
33class MailMime;
34class MailMimePrivate;
35
36class AlternativePart;
37class AlternativePartPrivate;
38
39class SinglePart;
40class SinglePartPrivate;
41
42class EncryptionPart;
43class EncryptionPartPrivate;
44
45class EncapsulatedPart;
46class EncapsulatedPartPrivate;
47
48class Content;
49class ContentPrivate;
50
51class CertContent;
52class CertContentPrivate;
53
54class EncryptionError;
55
56class Key;
57class KeyPrivate;
58class Signature;
59class SignaturePrivate;
60class Encryption;
61class EncryptionPrivate;
62
63typedef std::shared_ptr<Signature> SignaturePtr;
64typedef std::shared_ptr<Encryption> EncryptionPtr;
65
66class Parser;
67class ParserPrivate;
68
69/*
70 * A MessagePart that is based on a KMime::Content
71 */
72class MailMime
73{
74public:
75 typedef std::shared_ptr<MailMime> Ptr;
76 /**
77 * Various possible values for the "Content-Disposition" header.
78 */
79 enum Disposition {
80 Invalid, ///< Default, invalid value
81 Inline, ///< inline
82 Attachment ///< attachment
83 };
84
85 MailMime();
86
87 // interessting header parts of a KMime::Content
88 QMimeType mimetype() const;
89 Disposition disposition() const;
90 QUrl label() const;
91 QByteArray cid() const;
92 QByteArray charset() const;
93 QString filename() const;
94 bool isText() const;
95
96 // Unique identifier to ecactly this KMime::Content
97 QByteArray link() const;
98
99 QByteArray content() const;
100 //Use default charset
101 QString encodedContent() const;
102
103 // overwrite default charset with given charset
104 QString encodedContent(QByteArray charset) const;
105
106 QByteArray decodedContent() const;
107
108 bool isFirstTextPart() const;
109 bool isFirstPart() const;
110 bool isTopLevelPart() const;
111
112 MailMime::Ptr parent() const;
113
114private:
115 std::unique_ptr<MailMimePrivate> d;
116
117 friend class PartPrivate;
118};
119
120class Content
121{
122public:
123 typedef std::shared_ptr<Content> Ptr;
124 Content(const QByteArray &content, Part *parent);
125 Content(ContentPrivate *d_ptr);
126 virtual ~Content();
127
128 QByteArray content() const;
129
130 QByteArray charset() const;
131
132 //Use default charset
133 QString encodedContent() const;
134
135 // overwrite default charset with given charset
136 QString encodedContent(const QByteArray &charset) const;
137
138 QVector<SignaturePtr> signatures() const;
139 QVector<EncryptionPtr> encryptions() const;
140 MailMime::Ptr mailMime() const;
141 virtual QByteArray type() const;
142 Part* parent() const;
143private:
144 std::unique_ptr<ContentPrivate> d;
145};
146
147class PlainTextContent : public Content
148{
149public:
150 PlainTextContent(const QByteArray &content, Part *parent);
151 PlainTextContent(ContentPrivate *d_ptr);
152 QByteArray type() const Q_DECL_OVERRIDE;
153};
154
155class HtmlContent : public Content
156{
157public:
158 HtmlContent(const QByteArray &content, Part *parent);
159 HtmlContent(ContentPrivate* d_ptr);
160 QByteArray type() const Q_DECL_OVERRIDE;
161};
162
163/*
164 * importing a cert GpgMe::ImportResult
165 * checking a cert (if it is a valid cert)
166 */
167
168class CertContent : public Content
169{
170public:
171 typedef std::shared_ptr<CertContent> Ptr;
172 CertContent(const QByteArray &content, Part *parent);
173
174 QByteArray type() const Q_DECL_OVERRIDE;
175 enum CertType {
176 Pgp,
177 SMime
178 };
179
180 enum CertSubType {
181 Public,
182 Private
183 };
184
185 CertType certType() const;
186 CertSubType certSubType() const;
187 int keyLength() const;
188
189private:
190 std::unique_ptr<CertContentPrivate> d;
191};
192
193class Part
194{
195public:
196 typedef std::shared_ptr<Part> Ptr;
197 Part();
198 virtual QByteArray type() const;
199
200 virtual QVector<QByteArray> availableContents() const;
201 virtual QVector<Content::Ptr> content(const QByteArray& ct) const;
202 QVector<Content::Ptr> content() const;
203
204 bool hasSubParts() const;
205 QVector<Part::Ptr> subParts() const;
206 Part *parent() const;
207
208 QVector<SignaturePtr> signatures() const;
209 QVector<EncryptionPtr> encryptions() const;
210 virtual MailMime::Ptr mailMime() const;
211protected:
212 std::unique_ptr<PartPrivate> d;
213private:
214 friend class ParserPrivate;
215 friend class PartPrivate;
216};
217
218class AlternativePart : public Part
219{
220public:
221 typedef std::shared_ptr<AlternativePart> Ptr;
222
223 AlternativePart();
224 virtual ~AlternativePart();
225
226 QVector<QByteArray> availableContents() const Q_DECL_OVERRIDE;
227 QVector<Content::Ptr> content(const QByteArray& ct) const Q_DECL_OVERRIDE;
228
229 QByteArray type() const Q_DECL_OVERRIDE;
230
231private:
232 PartPrivate *reachParentD() const;
233 std::unique_ptr<AlternativePartPrivate> d;
234
235 friend class ParserPrivate;
236 friend class AlternativePartPrivate;
237};
238
239class SinglePart : public Part
240{
241 public:
242 typedef std::shared_ptr<SinglePart> Ptr;
243
244 SinglePart();
245 virtual ~SinglePart();
246
247 QVector<Content::Ptr> content(const QByteArray& ct) const Q_DECL_OVERRIDE;
248 QVector<QByteArray> availableContents() const Q_DECL_OVERRIDE;
249
250 QByteArray type() const Q_DECL_OVERRIDE;
251private:
252 PartPrivate *reachParentD() const;
253 std::unique_ptr<SinglePartPrivate> d;
254
255 friend class ParserPrivate;
256 friend class SinglePartPrivate;
257};
258
259/*
260 * we want to request complete headers like:
261 * from/to...
262 */
263
264class EncapsulatedPart : public SinglePart
265{
266public:
267 typedef std::shared_ptr<EncapsulatedPart> Ptr;
268 QByteArray type() const Q_DECL_OVERRIDE;
269
270 //template <class T> QByteArray header<T>();
271private:
272 std::unique_ptr<EncapsulatedPartPrivate> d;
273};
274
275class EncryptionError
276{
277public:
278 int errorId() const;
279 QString errorString() const;
280};
281
282class Key
283{
284public:
285 typedef std::shared_ptr<Key> Ptr;
286 Key();
287 Key(KeyPrivate *);
288 ~Key();
289
290 QString keyid() const;
291 QString name() const;
292 QString email() const;
293 QString comment() const;
294 QVector<QString> emails() const;
295 enum KeyTrust {
296 Unknown, Undefined, Never, Marginal, Full, Ultimate
297 };
298 KeyTrust keyTrust() const;
299
300 bool isRevokation() const;
301 bool isInvalid() const;
302 bool isExpired() const;
303
304 std::vector<Key::Ptr> subkeys();
305 Key parentkey() const;
306private:
307 std::unique_ptr<KeyPrivate> d;
308};
309
310class Signature
311{
312public:
313 typedef std::shared_ptr<Signature> Ptr;
314 Signature();
315 Signature(SignaturePrivate *);
316 ~Signature();
317
318 Key::Ptr key() const;
319 QDateTime creationDateTime() const;
320 QDateTime expirationDateTime() const;
321 bool neverExpires() const;
322
323 //template <> StatusObject<SignatureVerificationResult> verify() const;
324 private:
325 std::unique_ptr<SignaturePrivate> d;
326};
327
328/*
329 * Normally the Keys for encryption are subkeys
330 * for clients the parentkeys are "more interessting", because they store the name, email etc.
331 * but a client may also wants show to what subkey the mail is really encrypted, an if this subkey isRevoked or something else
332 */
333class Encryption
334{
335public:
336 enum ErrorType {
337 NoError,
338 PassphraseError,
339 KeyMissing,
340 UnknownError
341 };
342 typedef std::shared_ptr<Encryption> Ptr;
343 Encryption();
344 Encryption(EncryptionPrivate *);
345 ~Encryption();
346 std::vector<Key::Ptr> recipients() const;
347 QString errorString();
348 ErrorType errorType();
349private:
350 std::unique_ptr<EncryptionPrivate> d;
351};
352
353class Parser
354{
355public:
356 typedef std::shared_ptr<Parser> Ptr;
357 Parser(const QByteArray &mimeMessage);
358 ~Parser();
359
360 Part::Ptr getPart(const QUrl &url);
361
362 QVector<Part::Ptr> collect(const Part::Ptr &start, std::function<bool(const Part::Ptr &)> select, std::function<bool(const Content::Ptr &)> filter) const;
363 Part::Ptr find(const Part::Ptr &start, std::function<bool(const Part::Ptr &)> select) const;
364 QVector<Part::Ptr> collectContentParts() const;
365 QVector<Part::Ptr> collectAttachmentParts() const;
366 //template <> QVector<ContentPart::Ptr> collect<ContentPart>() const;
367
368 //template <> static StatusObject<SignatureVerificationResult> verifySignature(const Signature signature) const;
369 //template <> static StatusObject<Part> decrypt(const EncryptedPart part) const;
370
371signals:
372 void partsChanged();
373
374private:
375 std::unique_ptr<ParserPrivate> d;
376
377 friend class InterfaceTest;
378};
379