diff options
author | Sandro Knauß <sknauss@kde.org> | 2016-07-14 18:36:02 +0200 |
---|---|---|
committer | Sandro Knauß <sknauss@kde.org> | 2016-07-19 09:26:49 +0200 |
commit | 7815e94c52d092701804521eee850ac35d7f7781 (patch) | |
tree | e0131346db1f826e5c8052a00c98083a0f8733bb /framework/domain/mimetreeparser/interface.h | |
parent | 234daf6935043775ffce6b5a3ca78e06f56fd81e (diff) | |
download | kube-7815e94c52d092701804521eee850ac35d7f7781.tar.gz kube-7815e94c52d092701804521eee850ac35d7f7781.zip |
updated
Diffstat (limited to 'framework/domain/mimetreeparser/interface.h')
-rw-r--r-- | framework/domain/mimetreeparser/interface.h | 81 |
1 files changed, 62 insertions, 19 deletions
diff --git a/framework/domain/mimetreeparser/interface.h b/framework/domain/mimetreeparser/interface.h index a9e394db..320030b7 100644 --- a/framework/domain/mimetreeparser/interface.h +++ b/framework/domain/mimetreeparser/interface.h | |||
@@ -23,32 +23,41 @@ | |||
23 | #include <QMimeType> | 23 | #include <QMimeType> |
24 | 24 | ||
25 | class Part; | 25 | class Part; |
26 | typedef std::shared_ptr<Part> Part::Ptr; | ||
26 | class EncryptionPart; | 27 | class EncryptionPart; |
28 | typedef std::shared_ptr<Part> EncryptionPart::Ptr; | ||
27 | class SignaturePart; | 29 | class SignaturePart; |
30 | typedef std::shared_ptr<Part> SignaturePart::Ptr; | ||
28 | 31 | ||
29 | class MimePart; | 32 | class MimePart; |
33 | typedef std::shared_ptr<Part> MimePart::Ptr; | ||
30 | class MimePartPrivate; | 34 | class MimePartPrivate; |
31 | 35 | ||
32 | class ContentPart; | 36 | class ContentPart; |
37 | typedef std::shared_ptr<Part> ContentPart::Ptr; | ||
33 | class ContentPartPrivate; | 38 | class ContentPartPrivate; |
34 | 39 | ||
35 | class EncryptionErrorPart; | 40 | class EncryptionErrorPart; |
41 | typedef std::shared_ptr<Part> EncryptionErrorPart::Ptr; | ||
36 | class EncryptionErrorPartPrivate; | 42 | class EncryptionErrorPartPrivate; |
37 | 43 | ||
38 | class AttachmentPart; | 44 | class AttachmentPart; |
45 | typedef std::shared_ptr<Part> AttachmentPart::Ptr; | ||
39 | class AttachmentPartPrivate; | 46 | class AttachmentPartPrivate; |
40 | 47 | ||
41 | class EncapsulatedPart; | 48 | class EncapsulatedPart; |
49 | typedef std::shared_ptr<Part> EncapsulatedPart::Ptr; | ||
42 | class EncapsulatedPart; | 50 | class EncapsulatedPart; |
43 | 51 | ||
44 | class CertPart; | 52 | class CertPart; |
45 | class CertPart; | 53 | typedef std::shared_ptr<Part> CertPart::Ptr; |
46 | 54 | ||
47 | class Key; | 55 | class Key; |
48 | class Signature; | 56 | class Signature; |
49 | class Encryption; | 57 | class Encryption; |
50 | 58 | ||
51 | class Parser; | 59 | class Parser; |
60 | typedef std::shared_ptr<Parser> Parser::Ptr; | ||
52 | class ParserPrivate; | 61 | class ParserPrivate; |
53 | 62 | ||
54 | class Parser | 63 | class Parser |
@@ -56,30 +65,71 @@ class Parser | |||
56 | public: | 65 | public: |
57 | Parser(const QByteArray &mimeMessage); | 66 | Parser(const QByteArray &mimeMessage); |
58 | 67 | ||
59 | std::shared_ptr<Part> getPart(QUrl url); | 68 | Part::Ptr getPart(QUrl url); |
60 | 69 | ||
61 | QVector<std::shared_ptr<AttachmentPart>> collect<AttachmentPart>() const; | 70 | QVector<AttachmentPart::Ptr> collect<AttachmentPart>() const; |
62 | QVector<std::shared_ptr<ContentPart>> collect<ContentPart>() const; | 71 | QVector<ContentPart:Ptr> collect<ContentPart>() const; |
63 | QVector<std::shared_ptr<T>> collect<T>(Part start, std::function<bool(const Part &)> select, std::function<bool(const std::shared_ptr<T> &)> filter) const; | 72 | QVector<T::Ptr> collect<T>(Part start, std::function<bool(const Part &)> select, std::function<bool(const T::Ptr &)> filter) const; |
64 | 73 | ||
65 | private: | 74 | private: |
66 | std::unique_ptr<ParserPrivate> d; | 75 | std::unique_ptr<ParserPrivate> d; |
67 | }; | 76 | }; |
68 | 77 | ||
78 | |||
69 | class Part | 79 | class Part |
70 | { | 80 | { |
71 | public: | 81 | public: |
72 | virtual QByteArray type() const = 0; | 82 | virtual QByteArray type() const = 0; |
73 | 83 | ||
74 | bool hasSubParts() const; | 84 | bool hasSubParts() const; |
75 | QList<Part> subParts() const; | 85 | QList<Part::Ptr> subParts() const; |
76 | Part partent() const; | 86 | Part parent() const; |
87 | |||
88 | virtual QVector<Signature> signatures() const; | ||
89 | virtual QVector<Encryption> encryptions() const; | ||
77 | }; | 90 | }; |
78 | 91 | ||
92 | //A structure element, that we need to reflect, that there is a Encryption starts | ||
93 | // only add a new Encrption block to encryptions block | ||
94 | class EncryptionPart : public Part | ||
95 | { | ||
96 | public: | ||
97 | QVector<Encryption> encryptions() const Q_DECL_OVERRIDE; | ||
98 | QByteArray type() const Q_DECL_OVERRIDE; | ||
99 | }; | ||
100 | |||
101 | // A structure element, that we need to reflect, that there is a Signature starts | ||
102 | // only add a new Signature block to signature block | ||
103 | // With this we can a new Singature type like pep aka | ||
104 | /* | ||
105 | * add a bodypartformatter, that returns a PEPSignaturePart with all signed subparts that are signed with pep. | ||
106 | * subclass Signature aka PEPSignature to reflect different way of properties of PEPSignatures. | ||
107 | */ | ||
108 | class SignaturePart : public Part | ||
109 | { | ||
110 | public: | ||
111 | QVector<Signature> signatures() const Q_DECL_OVERRIDE; | ||
112 | QByteArray type() const Q_DECL_OVERRIDE; | ||
113 | }; | ||
114 | |||
115 | |||
116 | |||
117 | class TextPart : public Part | ||
118 | { | ||
119 | public: | ||
120 | QByteArray content() const; | ||
121 | |||
122 | //Use default charset | ||
123 | QString encodedContent() const; | ||
124 | |||
125 | // overwrite default charset with given charset | ||
126 | QString encodedContent(QByteArray charset) const; | ||
127 | } | ||
128 | |||
79 | /* | 129 | /* |
80 | * A MessagePart that is based on a KMime::Content | 130 | * A MessagePart that is based on a KMime::Content |
81 | */ | 131 | */ |
82 | class MimePart : public Part | 132 | class MimePart : public TextPart |
83 | { | 133 | { |
84 | public: | 134 | public: |
85 | /** | 135 | /** |
@@ -88,14 +138,12 @@ public: | |||
88 | enum Disposition { | 138 | enum Disposition { |
89 | Invalid, ///< Default, invalid value | 139 | Invalid, ///< Default, invalid value |
90 | Inline, ///< inline | 140 | Inline, ///< inline |
91 | Attachment, ///< attachment | 141 | Attachment ///< attachment |
92 | Parallel ///< parallel (invalid, do not use) | ||
93 | }; | 142 | }; |
94 | 143 | ||
95 | // interessting header parts of a KMime::Content | 144 | // interessting header parts of a KMime::Content |
96 | QByteArray content() const; | ||
97 | QMimeType mimetype() const; | 145 | QMimeType mimetype() const; |
98 | Disposition dispossition() const | 146 | Disposition disposition() const; |
99 | QUrl label() const; | 147 | QUrl label() const; |
100 | QByteArray cid() const; | 148 | QByteArray cid() const; |
101 | QByteArray charset() const; | 149 | QByteArray charset() const; |
@@ -123,7 +171,7 @@ private: | |||
123 | * for alternative, we are represating three messageparts | 171 | * for alternative, we are represating three messageparts |
124 | * - "headers" do we return?, we can use setType to make it possible to select and than return these headers | 172 | * - "headers" do we return?, we can use setType to make it possible to select and than return these headers |
125 | */ | 173 | */ |
126 | class ContentPart : public MimePart | 174 | class MainContentPart : public MimePart |
127 | { | 175 | { |
128 | public: | 176 | public: |
129 | enum Types { | 177 | enum Types { |
@@ -132,14 +180,9 @@ public: | |||
132 | }; | 180 | }; |
133 | Q_DECLARE_FLAGS(Types, Type) | 181 | Q_DECLARE_FLAGS(Types, Type) |
134 | 182 | ||
135 | QByteArray content(Content::Type ct) const; | 183 | QVector<TextPart> content(Content::Type ct) const; |
136 | |||
137 | // convert content with charset | ||
138 | QString content(Content::Type ct) const; | ||
139 | 184 | ||
140 | Content::Types availableContent() const; | 185 | Content::Types availableContent() const; |
141 | QVector<Signature> signature() const; | ||
142 | QVector<Encryption> encryption() const; | ||
143 | 186 | ||
144 | QByteArray type() const Q_DECL_OVERRIDE; | 187 | QByteArray type() const Q_DECL_OVERRIDE; |
145 | 188 | ||