summaryrefslogtreecommitdiffstats
path: root/framework/domain/mimetreeparser/interface.h
diff options
context:
space:
mode:
Diffstat (limited to 'framework/domain/mimetreeparser/interface.h')
-rw-r--r--framework/domain/mimetreeparser/interface.h246
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 @@
29class Part; 29class Part;
30class PartPrivate; 30class PartPrivate;
31 31
32class MimePart; 32class MailMime;
33class MimePartPrivate; 33class MailMimePrivate;
34 34
35class ContentPart; 35class AlternativePart;
36class ContentPartPrivate; 36class AlternativePartPrivate;
37
38class SinglePart;
39class SinglePartPrivate;
37 40
38class EncryptionPart; 41class EncryptionPart;
39class EncryptionPartPrivate; 42class EncryptionPartPrivate;
@@ -44,12 +47,14 @@ class AttachmentPartPrivate;
44class EncapsulatedPart; 47class EncapsulatedPart;
45class EncapsulatedPartPrivate; 48class EncapsulatedPartPrivate;
46 49
47class CertPart;
48class CertPartPrivate;
49
50class Content; 50class Content;
51class ContentPrivate; 51class ContentPrivate;
52 52
53class CertContent;
54class CertContentPrivate;
55
56class EncryptionError;
57
53class Key; 58class Key;
54class Signature; 59class Signature;
55class Encryption; 60class Encryption;
@@ -57,30 +62,48 @@ class Encryption;
57class Parser; 62class Parser;
58class ParserPrivate; 63class ParserPrivate;
59 64
60class Part 65/*
66 * A MessagePart that is based on a KMime::Content
67 */
68class MailMime
61{ 69{
62public: 70public:
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;
73private: 98private:
74 std::unique_ptr<PartPrivate> d; 99 std::unique_ptr<MailMimePrivate> d;
75 friend class ParserPrivate;
76 friend class PartPrivate;
77}; 100};
78 101
79class Content 102class Content
80{ 103{
81public: 104public:
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;
98private: 123private:
99 std::unique_ptr<ContentPrivate> d; 124 std::unique_ptr<ContentPrivate> d;
100}; 125};
101 126
102/* 127class PlainTextContent : public Content
103 * A MessagePart that is based on a KMime::Content
104 */
105class MimePart : public Part
106{ 128{
107public: 129public:
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 133class HtmlContent : public Content
119 QMimeType mimetype() const; 134{
120 Disposition disposition() const; 135public:
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 144class CertContent : public Content
129 QByteArray link() const; 145{
146public:
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;
140private: 164private:
141 std::unique_ptr<MimePartPrivate> d; 165 std::unique_ptr<CertContentPrivate> d;
142}; 166};
143 167
144/* 168class 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 */
155class ContentPart : public Part
156{ 169{
157public: 170public:
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;
174private: 185private:
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
180Q_DECLARE_OPERATORS_FOR_FLAGS(ContentPart::Types); 191class AlternativePart : public Part
181
182class AttachmentPart : public MimePart
183{ 192{
184public: 193public:
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
188private: 205private:
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/* 211class 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 */
200class EncryptionError
201{ 212{
202public: 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;
223private:
224 std::unique_ptr<SinglePartPrivate> d;
225
226 friend class ParserPrivate;
205}; 227};
206 228
207class EncryptionPart : public MimePart 229
230class EncryptionPart : public Part
208{ 231{
209public: 232public:
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
215private: 237private:
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
225class EncapsulatedPart : public AttachmentPart 247class EncapsulatedPart : public SinglePart
226{ 248{
227public: 249public:
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/* 258class EncryptionError
237 * importing a cert GpgMe::ImportResult
238 * checking a cert (if it is a valid cert)
239 */
240
241class CertPart : public AttachmentPart
242{ 259{
243public: 260public:
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
261private:
262 std::unique_ptr<CertPartPrivate> d;
263}; 263};
264 264
265class Key 265class 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;