diff options
author | Sandro Knauß <sknauss@kde.org> | 2016-07-20 17:35:29 +0200 |
---|---|---|
committer | Sandro Knauß <sknauss@kde.org> | 2016-07-20 17:35:29 +0200 |
commit | cf5b3e797421e7dbf2c0d7b1efff91fc07277652 (patch) | |
tree | 89cf94a75144e21cb44fb15f197935b41f7b6619 /framework/domain | |
parent | 550aa371cbf39d7d0cb735f890b338a3ac6883ab (diff) | |
download | kube-cf5b3e797421e7dbf2c0d7b1efff91fc07277652.tar.gz kube-cf5b3e797421e7dbf2c0d7b1efff91fc07277652.zip |
new thoughts for interface
Diffstat (limited to 'framework/domain')
-rw-r--r-- | framework/domain/mimetreeparser/CMakeLists.txt | 2 | ||||
-rw-r--r-- | framework/domain/mimetreeparser/interface.cpp | 165 | ||||
-rw-r--r-- | framework/domain/mimetreeparser/interface.h | 246 |
3 files changed, 220 insertions, 193 deletions
diff --git a/framework/domain/mimetreeparser/CMakeLists.txt b/framework/domain/mimetreeparser/CMakeLists.txt index e1c04893..07ec28df 100644 --- a/framework/domain/mimetreeparser/CMakeLists.txt +++ b/framework/domain/mimetreeparser/CMakeLists.txt | |||
@@ -9,4 +9,4 @@ add_library(mimetreeparser SHARED ${mimetreeparser_SRCS}) | |||
9 | qt5_use_modules(mimetreeparser Core Gui) | 9 | qt5_use_modules(mimetreeparser Core Gui) |
10 | target_link_libraries(mimetreeparser KF5::Mime KF5::MimeTreeParser) | 10 | target_link_libraries(mimetreeparser KF5::Mime KF5::MimeTreeParser) |
11 | 11 | ||
12 | add_subdirectory(tests) \ No newline at end of file | 12 | # add_subdirectory(tests) \ No newline at end of file |
diff --git a/framework/domain/mimetreeparser/interface.cpp b/framework/domain/mimetreeparser/interface.cpp index e34ffda7..aa7e3911 100644 --- a/framework/domain/mimetreeparser/interface.cpp +++ b/framework/domain/mimetreeparser/interface.cpp | |||
@@ -89,6 +89,16 @@ QByteArray Part::type() const | |||
89 | return "Part"; | 89 | return "Part"; |
90 | } | 90 | } |
91 | 91 | ||
92 | QVector<QByteArray> Part::availableContents() const | ||
93 | { | ||
94 | return QVector<QByteArray>(); | ||
95 | } | ||
96 | |||
97 | QVector<Content::Ptr> Part::content() const | ||
98 | { | ||
99 | return QVector<Content::Ptr>(); | ||
100 | } | ||
101 | |||
92 | QVector<Encryption> Part::encryptions() const | 102 | QVector<Encryption> Part::encryptions() const |
93 | { | 103 | { |
94 | auto parent = d->parent(); | 104 | auto parent = d->parent(); |
@@ -118,7 +128,7 @@ public: | |||
118 | Content *q; | 128 | Content *q; |
119 | }; | 129 | }; |
120 | 130 | ||
121 | Content::Content(const QByteArray& content, ContentPart *parent) | 131 | Content::Content(const QByteArray& content, Part *parent) |
122 | : d(std::unique_ptr<ContentPrivate>(new ContentPrivate)) | 132 | : d(std::unique_ptr<ContentPrivate>(new ContentPrivate)) |
123 | { | 133 | { |
124 | d->q = this; | 134 | d->q = this; |
@@ -157,113 +167,141 @@ QByteArray Content::charset() const | |||
157 | return d->mCodec; | 167 | return d->mCodec; |
158 | } | 168 | } |
159 | 169 | ||
160 | class ContentPartPrivate | 170 | class AlternativePartPrivate |
161 | { | 171 | { |
162 | public: | 172 | public: |
163 | void fillFrom(MimeTreeParser::TextMessagePart::Ptr part); | ||
164 | void fillFrom(MimeTreeParser::HtmlMessagePart::Ptr part); | ||
165 | void fillFrom(MimeTreeParser::AlternativeMessagePart::Ptr part); | 173 | void fillFrom(MimeTreeParser::AlternativeMessagePart::Ptr part); |
166 | 174 | ||
167 | QVector<Content::Ptr> content(ContentPart::Type ct) const; | 175 | QVector<Content::Ptr> content(const QByteArray &ct) const; |
168 | 176 | ||
169 | ContentPart *q; | 177 | AlternativePart *q; |
170 | 178 | ||
171 | ContentPart::Types types() const; | 179 | QVector<QByteArray> types() const; |
172 | 180 | ||
173 | private: | 181 | private: |
174 | QMap<ContentPart::Type, QVector<Content::Ptr>> mContent; | 182 | QMap<QByteArray, QVector<Content::Ptr>> mContent; |
175 | ContentPart::Types mTypes; | 183 | QVector<QByteArray> mTypes; |
176 | }; | 184 | }; |
177 | 185 | ||
178 | void ContentPartPrivate::fillFrom(MimeTreeParser::TextMessagePart::Ptr part) | 186 | void AlternativePartPrivate::fillFrom(MimeTreeParser::AlternativeMessagePart::Ptr part) |
179 | { | 187 | { |
180 | qDebug() << "jepp"; | 188 | mTypes = QVector<QByteArray>() << "html" << "plaintext"; |
181 | mTypes = ContentPart::PlainText; | 189 | |
182 | foreach (const auto &mp, part->subParts()) { | 190 | auto content = std::make_shared<HtmlContent>(part->htmlContent().toLocal8Bit(), q); |
183 | auto content = std::make_shared<Content>(mp->text().toLocal8Bit(), q); | 191 | mContent["html"].append(content); |
184 | mContent[ContentPart::PlainText].append(content); | 192 | content = std::make_shared<PlainTextContent>(part->plaintextContent().toLocal8Bit(), q); |
185 | } | 193 | mContent["plaintext"].append(content); |
186 | } | 194 | } |
187 | 195 | ||
188 | void ContentPartPrivate::fillFrom(MimeTreeParser::HtmlMessagePart::Ptr part) | 196 | QVector<QByteArray> AlternativePartPrivate::types() const |
189 | { | 197 | { |
190 | mTypes = ContentPart::Html; | 198 | return mTypes; |
191 | auto content = std::make_shared<Content>(part->text().toLocal8Bit(), q); | ||
192 | mContent[ContentPart::Html].append(content); | ||
193 | } | 199 | } |
194 | 200 | ||
195 | void ContentPartPrivate::fillFrom(MimeTreeParser::AlternativeMessagePart::Ptr part) | 201 | QVector<Content::Ptr> AlternativePartPrivate::content(const QByteArray& ct) const |
196 | { | 202 | { |
197 | mTypes = ContentPart::Html | ContentPart::PlainText; | 203 | return mContent[ct]; |
204 | } | ||
198 | 205 | ||
199 | auto content = std::make_shared<Content>(part->htmlContent().toLocal8Bit(), q); | 206 | AlternativePart::AlternativePart() |
200 | mContent[ContentPart::Html].append(content); | 207 | : d(std::unique_ptr<AlternativePartPrivate>(new AlternativePartPrivate)) |
201 | content = std::make_shared<Content>(part->plaintextContent().toLocal8Bit(), q); | 208 | { |
202 | mContent[ContentPart::PlainText].append(content); | 209 | d->q = this; |
203 | } | 210 | } |
204 | 211 | ||
205 | ContentPart::Types ContentPartPrivate::types() const | 212 | AlternativePart::~AlternativePart() |
206 | { | 213 | { |
207 | return mTypes; | 214 | |
208 | } | 215 | } |
209 | 216 | ||
210 | QVector<Content::Ptr> ContentPartPrivate::content(ContentPart::Type ct) const | 217 | QByteArray AlternativePart::type() const |
211 | { | 218 | { |
212 | return mContent[ct]; | 219 | return "AlternativePart"; |
213 | } | 220 | } |
214 | 221 | ||
215 | QVector<Content::Ptr> ContentPart::content(ContentPart::Type ct) const | 222 | QVector<QByteArray> AlternativePart::availableContents() const |
216 | { | 223 | { |
217 | return d->content(ct); | 224 | return d->types(); |
218 | } | 225 | } |
219 | 226 | ||
227 | QVector<Content::Ptr> AlternativePart::content() const | ||
228 | { | ||
229 | return d->content(availableContents().first()); | ||
230 | } | ||
220 | 231 | ||
221 | ContentPart::ContentPart() | 232 | QVector<Content::Ptr> AlternativePart::content(const QByteArray& ct) const |
222 | : d(std::unique_ptr<ContentPartPrivate>(new ContentPartPrivate)) | ||
223 | { | 233 | { |
224 | d->q = this; | 234 | return d->content(ct); |
225 | } | 235 | } |
226 | 236 | ||
227 | ContentPart::~ContentPart() | 237 | class SinglePartPrivate |
228 | { | 238 | { |
239 | public: | ||
240 | void fillFrom(MimeTreeParser::TextMessagePart::Ptr part); | ||
241 | void fillFrom(MimeTreeParser::HtmlMessagePart::Ptr part); | ||
242 | void fillFrom(MimeTreeParser::AttachmentMessagePart::Ptr part); | ||
243 | SinglePart *q; | ||
244 | |||
245 | QVector<Content::Ptr> mContent; | ||
246 | QByteArray mType; | ||
247 | }; | ||
229 | 248 | ||
249 | void SinglePartPrivate::fillFrom(MimeTreeParser::TextMessagePart::Ptr part) | ||
250 | { | ||
251 | mType = "plaintext"; | ||
252 | mContent.clear(); | ||
253 | foreach (const auto &mp, part->subParts()) { | ||
254 | mContent.append(std::make_shared<PlainTextContent>(mp->text().toLocal8Bit(), q)); | ||
255 | } | ||
230 | } | 256 | } |
231 | 257 | ||
232 | QByteArray ContentPart::type() const | 258 | void SinglePartPrivate::fillFrom(MimeTreeParser::HtmlMessagePart::Ptr part) |
233 | { | 259 | { |
234 | return "ContentPart"; | 260 | mType = "html"; |
261 | mContent.clear(); | ||
262 | mContent.append(std::make_shared<HtmlContent>(part->text().toLocal8Bit(), q)); | ||
235 | } | 263 | } |
236 | 264 | ||
237 | ContentPart::Types ContentPart::availableContents() const | 265 | void SinglePartPrivate::fillFrom(MimeTreeParser::AttachmentMessagePart::Ptr part) |
238 | { | 266 | { |
239 | return d->types(); | 267 | |
240 | } | 268 | } |
241 | 269 | ||
242 | class MimePartPrivate | 270 | SinglePart::SinglePart() |
271 | : d(std::unique_ptr<SinglePartPrivate>(new SinglePartPrivate)) | ||
243 | { | 272 | { |
244 | public: | 273 | d->q = this; |
245 | void fillFrom(MimeTreeParser::MessagePart::Ptr part); | 274 | } |
246 | }; | ||
247 | 275 | ||
248 | QByteArray MimePart::type() const | 276 | SinglePart::~SinglePart() |
249 | { | 277 | { |
250 | return "MimePart"; | 278 | |
251 | } | 279 | } |
252 | 280 | ||
253 | class AttachmentPartPrivate | 281 | QVector<QByteArray> SinglePart::availableContents() const |
254 | { | 282 | { |
255 | public: | 283 | return QVector<QByteArray>() << d->mType; |
256 | void fillFrom(MimeTreeParser::AttachmentMessagePart::Ptr part); | 284 | } |
257 | }; | ||
258 | 285 | ||
259 | void AttachmentPartPrivate::fillFrom(MimeTreeParser::AttachmentMessagePart::Ptr part) | 286 | QVector< Content::Ptr > SinglePart::content() const |
260 | { | 287 | { |
288 | return d->mContent; | ||
289 | } | ||
261 | 290 | ||
291 | QByteArray SinglePart::type() const | ||
292 | { | ||
293 | return "SinglePart"; | ||
262 | } | 294 | } |
263 | 295 | ||
264 | QByteArray AttachmentPart::type() const | 296 | class MimePartPrivate |
297 | { | ||
298 | public: | ||
299 | void fillFrom(MimeTreeParser::MessagePart::Ptr part); | ||
300 | }; | ||
301 | |||
302 | QByteArray MimePart::type() const | ||
265 | { | 303 | { |
266 | return "AttachmentPart"; | 304 | return "MimePart"; |
267 | } | 305 | } |
268 | 306 | ||
269 | ParserPrivate::ParserPrivate(Parser* parser) | 307 | ParserPrivate::ParserPrivate(Parser* parser) |
@@ -309,15 +347,15 @@ void ParserPrivate::createTree(const MimeTreeParser::MessagePart::Ptr &start, co | |||
309 | part->d->fillFrom(attachment); | 347 | part->d->fillFrom(attachment); |
310 | mTree->d->appendSubPart(part); | 348 | mTree->d->appendSubPart(part); |
311 | } else if (text) { | 349 | } else if (text) { |
312 | auto part = std::make_shared<ContentPart>(); | 350 | auto part = std::make_shared<SinglePart>(); |
313 | part->d->fillFrom(text); | 351 | part->d->fillFrom(text); |
314 | mTree->d->appendSubPart(part); | 352 | mTree->d->appendSubPart(part); |
315 | } else if (alternative) { | 353 | } else if (alternative) { |
316 | auto part = std::make_shared<ContentPart>(); | 354 | auto part = std::make_shared<AlternativePart>(); |
317 | part->d->fillFrom(alternative); | 355 | part->d->fillFrom(alternative); |
318 | mTree->d->appendSubPart(part); | 356 | mTree->d->appendSubPart(part); |
319 | } else if (html) { | 357 | } else if (html) { |
320 | auto part = std::make_shared<ContentPart>(); | 358 | auto part = std::make_shared<SinglePart>(); |
321 | part->d->fillFrom(html); | 359 | part->d->fillFrom(html); |
322 | mTree->d->appendSubPart(part); | 360 | mTree->d->appendSubPart(part); |
323 | } else { | 361 | } else { |
@@ -336,18 +374,9 @@ Parser::~Parser() | |||
336 | { | 374 | { |
337 | } | 375 | } |
338 | 376 | ||
339 | ContentPart::Ptr Parser::collectContentPart(const Part::Ptr &start) const | 377 | QVector<Part::Ptr> Parser::collectContentParts() const |
340 | { | 378 | { |
341 | const auto ret = collect<ContentPart>(start, [](const Part::Ptr &p){return p->type() == "ContentPart";}, [](const ContentPart::Ptr &p){return true;}); | 379 | return collect<Part>(d->mTree, [](const Part::Ptr &p){return p->availableContents().indexOf("html") > -1 || p->availableContents().indexOf("text") > -1;}, [](const Part::Ptr &p){return true;}); |
342 | if (ret.size() > 0) { | ||
343 | return ret[0]; | ||
344 | }; | ||
345 | return ContentPart::Ptr(); | ||
346 | } | ||
347 | |||
348 | ContentPart::Ptr Parser::collectContentPart() const | ||
349 | { | ||
350 | return collectContentPart(d->mTree); | ||
351 | } | 380 | } |
352 | 381 | ||
353 | template <typename T> | 382 | template <typename T> |
@@ -364,4 +393,4 @@ QVector<typename T::Ptr> Parser::collect(const Part::Ptr &start, std::function<b | |||
364 | } | 393 | } |
365 | } | 394 | } |
366 | return ret; | 395 | return ret; |
367 | } | 396 | } \ No newline at end of file |
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; |