Changeset View
Changeset View
Standalone View
Standalone View
messageviewer/src/viewer/bodypartformatter.cpp
Show First 20 Lines • Show All 175 Lines • ▼ Show 20 Line(s) | 173 | { | |||
---|---|---|---|---|---|
176 | if (!mp.isNull()) { | 176 | if (!mp.isNull()) { | ||
177 | mp->html(false); | 177 | mp->html(false); | ||
178 | return Ok; | 178 | return Ok; | ||
179 | } | 179 | } | ||
180 | 180 | | |||
181 | return Failed; | 181 | return Failed; | ||
182 | } | 182 | } | ||
183 | 183 | | |||
184 | class MultiPartEncryptedBodyPartFormatter | ||||
185 | : public MessageViewer::Interface::BodyPartFormatter | ||||
186 | { | ||||
187 | public: | ||||
188 | MessagePart::Ptr process(const Interface::BodyPart &part) const; | ||||
189 | MessageViewer::Interface::BodyPartFormatter::Result format(Interface::BodyPart *, HtmlWriter *) const Q_DECL_OVERRIDE; | ||||
190 | using MessageViewer::Interface::BodyPartFormatter::format; | ||||
191 | static const MessageViewer::Interface::BodyPartFormatter *create(); | ||||
192 | private: | ||||
193 | static const MultiPartEncryptedBodyPartFormatter *self; | ||||
194 | }; | ||||
195 | | ||||
196 | const MultiPartEncryptedBodyPartFormatter *MultiPartEncryptedBodyPartFormatter::self; | ||||
197 | | ||||
198 | const MessageViewer::Interface::BodyPartFormatter *MultiPartEncryptedBodyPartFormatter::create() | ||||
199 | { | ||||
200 | if (!self) { | ||||
201 | self = new MultiPartEncryptedBodyPartFormatter(); | ||||
202 | } | ||||
203 | return self; | ||||
204 | } | ||||
205 | | ||||
206 | MessagePart::Ptr MultiPartEncryptedBodyPartFormatter::process(const Interface::BodyPart &part) const | ||||
207 | { | ||||
208 | return part.objectTreeParser()->processMultiPartEncryptedSubtype(part.content(), *part.processResult()); | ||||
209 | } | ||||
210 | | ||||
211 | MessageViewer::Interface::BodyPartFormatter::Result MultiPartEncryptedBodyPartFormatter::format(Interface::BodyPart *part, HtmlWriter *writer) const | ||||
212 | { | ||||
213 | Q_UNUSED(writer) | ||||
214 | MessagePart::Ptr mp = process(*part); | ||||
215 | if (!mp.isNull()) { | ||||
216 | mp->html(false); | ||||
217 | return Ok; | ||||
218 | } | ||||
219 | | ||||
220 | return Failed; | ||||
221 | } | ||||
222 | | ||||
184 | #define CREATE_BODY_PART_FORMATTER(subtype) \ | 223 | #define CREATE_BODY_PART_FORMATTER(subtype) \ | ||
185 | class subtype##BodyPartFormatter \ | 224 | class subtype##BodyPartFormatter \ | ||
186 | : public MessageViewer::Interface::BodyPartFormatter \ | 225 | : public MessageViewer::Interface::BodyPartFormatter \ | ||
187 | { \ | 226 | { \ | ||
188 | static const subtype##BodyPartFormatter *self; \ | 227 | static const subtype##BodyPartFormatter *self; \ | ||
189 | public: \ | 228 | public: \ | ||
190 | bool process(ObjectTreeParser *, KMime::Content *, ProcessResult &) const;\ | 229 | bool process(ObjectTreeParser *, KMime::Content *, ProcessResult &) const;\ | ||
191 | MessageViewer::Interface::BodyPartFormatter::Result format(Interface::BodyPart *, HtmlWriter *) const Q_DECL_OVERRIDE; \ | 230 | MessageViewer::Interface::BodyPartFormatter::Result format(Interface::BodyPart *, HtmlWriter *) const Q_DECL_OVERRIDE; \ | ||
Show All 16 Lines | |||||
208 | MessageViewer::Interface::BodyPartFormatter::Result subtype##BodyPartFormatter::format(Interface::BodyPart *part, HtmlWriter *writer) const { \ | 247 | MessageViewer::Interface::BodyPartFormatter::Result subtype##BodyPartFormatter::format(Interface::BodyPart *part, HtmlWriter *writer) const { \ | ||
209 | Q_UNUSED(writer) \ | 248 | Q_UNUSED(writer) \ | ||
210 | const bool result = process(part->objectTreeParser(), part->content(), *part->processResult()); \ | 249 | const bool result = process(part->objectTreeParser(), part->content(), *part->processResult()); \ | ||
211 | return result ? Ok : Failed; \ | 250 | return result ? Ok : Failed; \ | ||
212 | } | 251 | } | ||
213 | 252 | | |||
214 | CREATE_BODY_PART_FORMATTER(TextPlain) | 253 | CREATE_BODY_PART_FORMATTER(TextPlain) | ||
215 | CREATE_BODY_PART_FORMATTER(TextHtml) | 254 | CREATE_BODY_PART_FORMATTER(TextHtml) | ||
216 | //CREATE_BODY_PART_FORMATTER(TextEnriched) | | |||
217 | 255 | | |||
218 | CREATE_BODY_PART_FORMATTER(ApplicationPkcs7Mime) | 256 | CREATE_BODY_PART_FORMATTER(ApplicationPkcs7Mime) | ||
219 | CREATE_BODY_PART_FORMATTER(ApplicationChiasmusText) | 257 | CREATE_BODY_PART_FORMATTER(ApplicationChiasmusText) | ||
220 | //CREATE_BODY_PART_FORMATTER(ApplicationPgp) | | |||
221 | 258 | | |||
222 | CREATE_BODY_PART_FORMATTER(MultiPartMixed) | 259 | CREATE_BODY_PART_FORMATTER(MultiPartMixed) | ||
223 | CREATE_BODY_PART_FORMATTER(MultiPartAlternative) | 260 | CREATE_BODY_PART_FORMATTER(MultiPartAlternative) | ||
224 | CREATE_BODY_PART_FORMATTER(MultiPartEncrypted) | | |||
225 | 261 | | |||
226 | typedef TextPlainBodyPartFormatter ApplicationPgpBodyPartFormatter; | 262 | typedef TextPlainBodyPartFormatter ApplicationPgpBodyPartFormatter; | ||
227 | 263 | | |||
228 | #undef CREATE_BODY_PART_FORMATTER | 264 | #undef CREATE_BODY_PART_FORMATTER | ||
229 | } // anon namespace | 265 | } // anon namespace | ||
230 | 266 | | |||
231 | // FIXME: port some more BodyPartFormatters to Interface::BodyPartFormatters | 267 | // FIXME: port some more BodyPartFormatters to Interface::BodyPartFormatters | ||
232 | void BodyPartFormatterFactoryPrivate::messageviewer_create_builtin_bodypart_formatters(BodyPartFormatterFactoryPrivate::TypeRegistry *reg) | 268 | void BodyPartFormatterFactoryPrivate::messageviewer_create_builtin_bodypart_formatters(BodyPartFormatterFactoryPrivate::TypeRegistry *reg) | ||
Show All 29 Lines |