Changeset View
Changeset View
Standalone View
Standalone View
mimetreeparser/src/objecttreeparser.cpp
Show First 20 Lines • Show All 187 Lines • ▼ Show 20 Line(s) | |||||
188 | } | 188 | } | ||
189 | 189 | | |||
190 | MessagePartPtr ObjectTreeParser::parsedPart() const | 190 | MessagePartPtr ObjectTreeParser::parsedPart() const | ||
191 | { | 191 | { | ||
192 | return mParsedPart; | 192 | return mParsedPart; | ||
193 | } | 193 | } | ||
194 | 194 | | |||
195 | MessagePartPtr ObjectTreeParser::processType(KMime::Content *node, ProcessResult &processResult, const QByteArray &mimeType) | 195 | MessagePartPtr ObjectTreeParser::processType(KMime::Content *node, ProcessResult &processResult, const QByteArray &mimeType) | ||
196 | { | 196 | { | ||
knauss: getting rid of "bool onlyOneMimePart" is seperated patch (simple cleanup) | |||||
197 | const auto formatters = mSource->bodyPartFormatterFactory()->formattersForType(QString::fromUtf8(mimeType)); | 197 | const auto formatters = mSource->bodyPartFormatterFactory()->formattersForType(QString::fromUtf8(mimeType)); | ||
198 | Q_ASSERT(!formatters.empty()); | 198 | Q_ASSERT(!formatters.empty()); | ||
199 | for (auto formatter : formatters) { | 199 | for (auto formatter : formatters) { | ||
200 | PartNodeBodyPart part(this, &processResult, mTopLevelContent, node, mNodeHelper); | 200 | PartNodeBodyPart part(this, &processResult, mTopLevelContent, node, mNodeHelper); | ||
201 | // Set the default display strategy for this body part relying on the | 201 | // Set the default display strategy for this body part relying on the | ||
202 | // identity of Interface::BodyPart::Display and AttachmentStrategy::Display | 202 | // identity of Interface::BodyPart::Display and AttachmentStrategy::Display | ||
203 | part.setDefaultDisplay((Interface::BodyPart::Display)attachmentStrategy()->defaultDisplay(node)); | 203 | part.setDefaultDisplay((Interface::BodyPart::Display)attachmentStrategy()->defaultDisplay(node)); | ||
204 | 204 | | |||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 253 | for (; i < contents.size(); ++i) { | |||
257 | } | 257 | } | ||
258 | 258 | | |||
259 | ProcessResult processResult(mNodeHelper); | 259 | ProcessResult processResult(mNodeHelper); | ||
260 | 260 | | |||
261 | QByteArray mimeType("text/plain"); | 261 | QByteArray mimeType("text/plain"); | ||
262 | if (node->contentType(false) && !node->contentType()->mimeType().isEmpty()) { | 262 | if (node->contentType(false) && !node->contentType()->mimeType().isEmpty()) { | ||
263 | mimeType = node->contentType()->mimeType(); | 263 | mimeType = node->contentType()->mimeType(); | ||
264 | } | 264 | } | ||
265 | // unfortunately there's many emails where we can't trust the attachment mimetype | ||||
266 | // so try to see if we can find something better | ||||
267 | if (mimeType == "application/octet-stream") { | ||||
268 | NodeHelper::magicSetType(node); | ||||
269 | mimeType = node->contentType()->mimeType(); | ||||
Do we really need to write the the content to file before getting the propper mimetype? isn't that possible with QTextStream? knauss: Do we really need to write the the content to file before getting the propper mimetype? isn't… | |||||
maybe you want use NodeHelper::magicSetType / maybe without modifiing the contentType... This method is called later on from AttachmentMessagePartRenderer::render ... knauss: maybe you want use NodeHelper::magicSetType / maybe without modifiing the contentType... This… | |||||
Yep, that works much better, with a lot less code changes required, plugins just work out of the box :) There's just one little issue in KMime breaking some stuff as a result of this change, as changing the content type will currently lose all other parameters in the Content-Type header. vkrause: Yep, that works much better, with a lot less code changes required, plugins just work out of… | |||||
270 | } | ||||
265 | 271 | | |||
266 | const auto mp = processType(node, processResult, mimeType); | 272 | const auto mp = processType(node, processResult, mimeType); | ||
267 | Q_ASSERT(mp); | 273 | Q_ASSERT(mp); | ||
268 | parsedPart->appendSubPart(mp); | 274 | parsedPart->appendSubPart(mp); | ||
269 | mNodeHelper->setNodeProcessed(node, false); | 275 | mNodeHelper->setNodeProcessed(node, false); | ||
270 | 276 | | |||
271 | // adjust signed/encrypted flags if inline PGP was found | 277 | // adjust signed/encrypted flags if inline PGP was found | ||
272 | processResult.adjustCryptoStatesOfNode(node); | 278 | processResult.adjustCryptoStatesOfNode(node); | ||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |
getting rid of "bool onlyOneMimePart" is seperated patch (simple cleanup)