diff options
Diffstat (limited to 'framework/domain/mimetreeparser/interface.h')
-rw-r--r-- | framework/domain/mimetreeparser/interface.h | 246 |
1 files changed, 122 insertions, 124 deletions
diff --git a/framework/domain/mimetreeparser/interface.h b/framework/domain/mimetreeparser/interface.h index 0aef7fd0..5133b87e 100644 --- a/framework/domain/mimetreeparser/interface.h +++ b/framework/domain/mimetreeparser/interface.h | |||
@@ -29,11 +29,14 @@ | |||
29 | class Part; | 29 | class Part; |
30 | class PartPrivate; | 30 | class PartPrivate; |
31 | 31 | ||
32 | class MimePart; | 32 | class MailMime; |
33 | class MimePartPrivate; | 33 | class MailMimePrivate; |
34 | 34 | ||
35 | class ContentPart; | 35 | class AlternativePart; |
36 | class ContentPartPrivate; | 36 | class AlternativePartPrivate; |
37 | |||
38 | class SinglePart; | ||
39 | class SinglePartPrivate; | ||
37 | 40 | ||
38 | class EncryptionPart; | 41 | class EncryptionPart; |
39 | class EncryptionPartPrivate; | 42 | class EncryptionPartPrivate; |
@@ -44,12 +47,14 @@ class AttachmentPartPrivate; | |||
44 | class EncapsulatedPart; | 47 | class EncapsulatedPart; |
45 | class EncapsulatedPartPrivate; | 48 | class EncapsulatedPartPrivate; |
46 | 49 | ||
47 | class CertPart; | ||
48 | class CertPartPrivate; | ||
49 | |||
50 | class Content; | 50 | class Content; |
51 | class ContentPrivate; | 51 | class ContentPrivate; |
52 | 52 | ||
53 | class CertContent; | ||
54 | class CertContentPrivate; | ||
55 | |||
56 | class EncryptionError; | ||
57 | |||
53 | class Key; | 58 | class Key; |
54 | class Signature; | 59 | class Signature; |
55 | class Encryption; | 60 | class Encryption; |
@@ -57,30 +62,48 @@ class Encryption; | |||
57 | class Parser; | 62 | class Parser; |
58 | class ParserPrivate; | 63 | class ParserPrivate; |
59 | 64 | ||
60 | class Part | 65 | /* |
66 | * A MessagePart that is based on a KMime::Content | ||
67 | */ | ||
68 | class MailMime | ||
61 | { | 69 | { |
62 | public: | 70 | public: |
63 | typedef std::shared_ptr<Part> Ptr; | 71 | typedef std::shared_ptr<MailMime> Ptr; |
64 | Part(); | 72 | /** |
65 | virtual QByteArray type() const; | 73 | * Various possible values for the "Content-Disposition" header. |
74 | */ | ||
75 | enum Disposition { | ||
76 | Invalid, ///< Default, invalid value | ||
77 | Inline, ///< inline | ||
78 | Attachment ///< attachment | ||
79 | }; | ||
66 | 80 | ||
67 | bool hasSubParts() const; | 81 | // interessting header parts of a KMime::Content |
68 | QVector<Part::Ptr> subParts() const; | 82 | QMimeType mimetype() const; |
69 | Part *parent() const; | 83 | Disposition disposition() const; |
84 | QUrl label() const; | ||
85 | QByteArray cid() const; | ||
86 | QByteArray charset() const; | ||
87 | |||
88 | // Unique identifier to ecactly this KMime::Content | ||
89 | QByteArray link() const; | ||
90 | |||
91 | QByteArray content() const; | ||
92 | //Use default charset | ||
93 | QString encodedContent() const; | ||
94 | |||
95 | // overwrite default charset with given charset | ||
96 | QString encodedContent(QByteArray charset) const; | ||
70 | 97 | ||
71 | virtual QVector<Signature> signatures() const; | ||
72 | virtual QVector<Encryption> encryptions() const; | ||
73 | private: | 98 | private: |
74 | std::unique_ptr<PartPrivate> d; | 99 | std::unique_ptr<MailMimePrivate> d; |
75 | friend class ParserPrivate; | ||
76 | friend class PartPrivate; | ||
77 | }; | 100 | }; |
78 | 101 | ||
79 | class Content | 102 | class Content |
80 | { | 103 | { |
81 | public: | 104 | public: |
82 | typedef std::shared_ptr<Content> Ptr; | 105 | typedef std::shared_ptr<Content> Ptr; |
83 | Content(const QByteArray &content, ContentPart *parent); | 106 | Content(const QByteArray &content, Part *parent); |
84 | virtual ~Content(); | 107 | virtual ~Content(); |
85 | 108 | ||
86 | QByteArray content() const; | 109 | QByteArray content() const; |
@@ -95,123 +118,122 @@ public: | |||
95 | 118 | ||
96 | virtual QVector<Signature> signatures() const; | 119 | virtual QVector<Signature> signatures() const; |
97 | virtual QVector<Encryption> encryptions() const; | 120 | virtual QVector<Encryption> encryptions() const; |
121 | MailMime::Ptr mailMime() const; | ||
122 | virtual QByteArray type() const; | ||
98 | private: | 123 | private: |
99 | std::unique_ptr<ContentPrivate> d; | 124 | std::unique_ptr<ContentPrivate> d; |
100 | }; | 125 | }; |
101 | 126 | ||
102 | /* | 127 | class PlainTextContent : public Content |
103 | * A MessagePart that is based on a KMime::Content | ||
104 | */ | ||
105 | class MimePart : public Part | ||
106 | { | 128 | { |
107 | public: | 129 | public: |
108 | typedef std::shared_ptr<MimePart> Ptr; | 130 | QByteArray type() const Q_DECL_OVERRIDE; |
109 | /** | 131 | }; |
110 | * Various possible values for the "Content-Disposition" header. | ||
111 | */ | ||
112 | enum Disposition { | ||
113 | Invalid, ///< Default, invalid value | ||
114 | Inline, ///< inline | ||
115 | Attachment ///< attachment | ||
116 | }; | ||
117 | 132 | ||
118 | // interessting header parts of a KMime::Content | 133 | class HtmlContent : public Content |
119 | QMimeType mimetype() const; | 134 | { |
120 | Disposition disposition() const; | 135 | public: |
121 | QUrl label() const; | 136 | QByteArray type() const Q_DECL_OVERRIDE; |
122 | QByteArray cid() const; | 137 | }; |
123 | QByteArray charset() const; | ||
124 | 138 | ||
125 | // we wanna overrwrite the charset of the content, because some clients set the charset wrong | 139 | /* |
126 | void setCharset(QByteArray charset); | 140 | * importing a cert GpgMe::ImportResult |
141 | * checking a cert (if it is a valid cert) | ||
142 | */ | ||
127 | 143 | ||
128 | // Unique identifier to ecactly this KMime::Content | 144 | class CertContent : public Content |
129 | QByteArray link() const; | 145 | { |
146 | public: | ||
147 | typedef std::shared_ptr<CertContent> Ptr; | ||
130 | 148 | ||
131 | QByteArray content() const; | 149 | QByteArray type() const Q_DECL_OVERRIDE; |
150 | enum CertType { | ||
151 | Pgp, | ||
152 | SMime | ||
153 | }; | ||
132 | 154 | ||
133 | //Use default charset | 155 | enum CertSubType { |
134 | QString encodedContent() const; | 156 | Public, |
157 | Private | ||
158 | }; | ||
135 | 159 | ||
136 | // overwrite default charset with given charset | 160 | CertType certType() const; |
137 | QString encodedContent(QByteArray charset) const; | 161 | CertSubType certSubType() const; |
162 | int keyLength() const; | ||
138 | 163 | ||
139 | QByteArray type() const Q_DECL_OVERRIDE; | ||
140 | private: | 164 | private: |
141 | std::unique_ptr<MimePartPrivate> d; | 165 | std::unique_ptr<CertContentPrivate> d; |
142 | }; | 166 | }; |
143 | 167 | ||
144 | /* | 168 | class Part |
145 | * The main ContentPart | ||
146 | * is MimePart a good parent class? | ||
147 | * do we wanna need parts of the header of the connected KMime::Contents | ||
148 | * usecases: | ||
149 | * - | ||
150 | * for htmlonly it is representating only one MimePart (ok) | ||
151 | * for plaintext only also only one MimePart (ok) | ||
152 | * for alternative, we are represating three messageparts | ||
153 | * - "headers" do we return?, we can use setType to make it possible to select and than return these headers | ||
154 | */ | ||
155 | class ContentPart : public Part | ||
156 | { | 169 | { |
157 | public: | 170 | public: |
158 | typedef std::shared_ptr<ContentPart> Ptr; | 171 | typedef std::shared_ptr<Part> Ptr; |
159 | enum Type { | 172 | Part(); |
160 | PlainText = 0x0001, | 173 | virtual QByteArray type() const; |
161 | Html = 0x0002 | ||
162 | }; | ||
163 | Q_DECLARE_FLAGS(Types, Type) | ||
164 | |||
165 | ContentPart(); | ||
166 | virtual ~ContentPart(); | ||
167 | |||
168 | QVector<Content::Ptr> content(Type ct) const; | ||
169 | 174 | ||
170 | Types availableContents() const; | 175 | virtual QVector<QByteArray> availableContents() const; |
176 | virtual QVector<Content::Ptr> content() const; | ||
171 | 177 | ||
172 | QByteArray type() const Q_DECL_OVERRIDE; | 178 | bool hasSubParts() const; |
179 | QVector<Part::Ptr> subParts() const; | ||
180 | Part *parent() const; | ||
173 | 181 | ||
182 | virtual QVector<Signature> signatures() const; | ||
183 | virtual QVector<Encryption> encryptions() const; | ||
184 | virtual MailMime::Ptr mailMime() const; | ||
174 | private: | 185 | private: |
175 | std::unique_ptr<ContentPartPrivate> d; | 186 | std::unique_ptr<PartPrivate> d; |
176 | |||
177 | friend class ParserPrivate; | 187 | friend class ParserPrivate; |
188 | friend class PartPrivate; | ||
178 | }; | 189 | }; |
179 | 190 | ||
180 | Q_DECLARE_OPERATORS_FOR_FLAGS(ContentPart::Types); | 191 | class AlternativePart : public Part |
181 | |||
182 | class AttachmentPart : public MimePart | ||
183 | { | 192 | { |
184 | public: | 193 | public: |
185 | typedef std::shared_ptr<AttachmentPart> Ptr; | 194 | typedef std::shared_ptr<AlternativePart> Ptr; |
195 | |||
196 | AlternativePart(); | ||
197 | virtual ~AlternativePart(); | ||
198 | |||
199 | QVector<Content::Ptr> content() const Q_DECL_OVERRIDE; | ||
200 | QVector<QByteArray> availableContents() const Q_DECL_OVERRIDE; | ||
201 | QVector<Content::Ptr> content(const QByteArray& ct) const; | ||
202 | |||
186 | QByteArray type() const Q_DECL_OVERRIDE; | 203 | QByteArray type() const Q_DECL_OVERRIDE; |
187 | 204 | ||
188 | private: | 205 | private: |
189 | std::unique_ptr<AttachmentPartPrivate> d; | 206 | std::unique_ptr<AlternativePartPrivate> d; |
190 | 207 | ||
191 | friend class ParserPrivate; | 208 | friend class ParserPrivate; |
192 | }; | 209 | }; |
193 | 210 | ||
194 | /* | 211 | class SinglePart : public Part |
195 | * Open Questions: | ||
196 | * - How to make the string translateable for multiple clients, so that multiple clients can show same error messages, | ||
197 | * that helps users to understand what is going on ? | ||
198 | * - Does openpgp have translations already? | ||
199 | */ | ||
200 | class EncryptionError | ||
201 | { | 212 | { |
202 | public: | 213 | public: |
203 | int errorId() const; | 214 | typedef std::shared_ptr<SinglePart> Ptr; |
204 | QString errorString() const; | 215 | |
216 | SinglePart(); | ||
217 | virtual ~SinglePart(); | ||
218 | |||
219 | QVector<Content::Ptr> content() const Q_DECL_OVERRIDE; | ||
220 | QVector<QByteArray> availableContents() const Q_DECL_OVERRIDE; | ||
221 | |||
222 | QByteArray type() const Q_DECL_OVERRIDE; | ||
223 | private: | ||
224 | std::unique_ptr<SinglePartPrivate> d; | ||
225 | |||
226 | friend class ParserPrivate; | ||
205 | }; | 227 | }; |
206 | 228 | ||
207 | class EncryptionPart : public MimePart | 229 | |
230 | class EncryptionPart : public Part | ||
208 | { | 231 | { |
209 | public: | 232 | public: |
210 | typedef std::shared_ptr<EncryptionPart> Ptr; | 233 | typedef std::shared_ptr<EncryptionPart> Ptr; |
211 | QByteArray type() const Q_DECL_OVERRIDE; | 234 | QByteArray type() const Q_DECL_OVERRIDE; |
212 | 235 | ||
213 | EncryptionError error() const; | 236 | EncryptionError error() const; |
214 | |||
215 | private: | 237 | private: |
216 | std::unique_ptr<EncryptionPartPrivate> d; | 238 | std::unique_ptr<EncryptionPartPrivate> d; |
217 | }; | 239 | }; |
@@ -222,7 +244,7 @@ private: | |||
222 | * from/to... | 244 | * from/to... |
223 | */ | 245 | */ |
224 | 246 | ||
225 | class EncapsulatedPart : public AttachmentPart | 247 | class EncapsulatedPart : public SinglePart |
226 | { | 248 | { |
227 | public: | 249 | public: |
228 | typedef std::shared_ptr<EncapsulatedPart> Ptr; | 250 | typedef std::shared_ptr<EncapsulatedPart> Ptr; |
@@ -233,33 +255,11 @@ private: | |||
233 | std::unique_ptr<EncapsulatedPartPrivate> d; | 255 | std::unique_ptr<EncapsulatedPartPrivate> d; |
234 | }; | 256 | }; |
235 | 257 | ||
236 | /* | 258 | class EncryptionError |
237 | * importing a cert GpgMe::ImportResult | ||
238 | * checking a cert (if it is a valid cert) | ||
239 | */ | ||
240 | |||
241 | class CertPart : public AttachmentPart | ||
242 | { | 259 | { |
243 | public: | 260 | public: |
244 | typedef std::shared_ptr<CertPart> Ptr; | 261 | int errorId() const; |
245 | QByteArray type() const Q_DECL_OVERRIDE; | 262 | QString errorString() const; |
246 | |||
247 | enum CertType { | ||
248 | Pgp, | ||
249 | SMime | ||
250 | }; | ||
251 | |||
252 | enum CertSubType { | ||
253 | Public, | ||
254 | Private | ||
255 | }; | ||
256 | |||
257 | CertType certType() const; | ||
258 | CertSubType certSubType() const; | ||
259 | int keyLength() const; | ||
260 | |||
261 | private: | ||
262 | std::unique_ptr<CertPartPrivate> d; | ||
263 | }; | 263 | }; |
264 | 264 | ||
265 | class Key | 265 | class Key |
@@ -312,10 +312,8 @@ public: | |||
312 | Part::Ptr getPart(QUrl url); | 312 | Part::Ptr getPart(QUrl url); |
313 | 313 | ||
314 | template <typename T> QVector<typename T::Ptr> collect(const Part::Ptr &start, std::function<bool(const Part::Ptr &)> select, std::function<bool(const typename T::Ptr &)> filter) const; | 314 | template <typename T> QVector<typename T::Ptr> collect(const Part::Ptr &start, std::function<bool(const Part::Ptr &)> select, std::function<bool(const typename T::Ptr &)> filter) const; |
315 | QVector<AttachmentPart::Ptr> collectAttachments(Part::Ptr start, std::function<bool(const Part::Ptr &)> select, std::function<bool(const AttachmentPart::Ptr &)> filter) const; | 315 | //QVector<AttachmentPart::Ptr> collectAttachments(Part::Ptr start, std::function<bool(const Part::Ptr &)> select, std::function<bool(const AttachmentPart::Ptr &)> filter) const; |
316 | ContentPart::Ptr collectContentPart(Part::Ptr start, std::function<bool(const Part::Ptr &)> select, std::function<bool(const ContentPart::Ptr &)> filter) const; | 316 | QVector<Part::Ptr> collectContentParts() const; |
317 | ContentPart::Ptr collectContentPart(const Part::Ptr& start) const; | ||
318 | ContentPart::Ptr collectContentPart() const; | ||
319 | //template <> QVector<ContentPart::Ptr> collect<ContentPart>() const; | 317 | //template <> QVector<ContentPart::Ptr> collect<ContentPart>() const; |
320 | 318 | ||
321 | //template <> static StatusObject<SignatureVerificationResult> verifySignature(const Signature signature) const; | 319 | //template <> static StatusObject<SignatureVerificationResult> verifySignature(const Signature signature) const; |