Commit b82ebd53 authored by Volker Krause's avatar Volker Krause
Browse files

Properly handle creating document nodes from existing KMime objects

To avoid common errors we need to normalize this to KMime::Content*,
and we need to extract the context date/time here as well.
parent 9ef2a675
......@@ -64,6 +64,27 @@ ExtractorDocumentNode MimeDocumentProcessor::createNodeFromData(const QByteArray
return node;
}
ExtractorDocumentNode MimeDocumentProcessor::createNodeFromContent(const QVariant &decodedData) const
{
KMime::Content *content = decodedData.value<KMime::Content*>();
if (!content) {
content = decodedData.value<KMime::Message*>();
}
if (!content) {
return {};
}
ExtractorDocumentNode node;
node.setContent(content);
auto dateHdr = content->header<KMime::Headers::Date>();
if (dateHdr) {
node.setContextDateTime(dateHdr->dateTime());
}
return node;
}
static void expandContentNode(ExtractorDocumentNode &node, KMime::Content *content, const ExtractorEngine *engine)
{
QString fileName;
......
......@@ -17,6 +17,7 @@ class MimeDocumentProcessor : public ExtractorDocumentProcessor
public:
bool canHandleData(const QByteArray &encodedData, QStringView fileName) const override;
ExtractorDocumentNode createNodeFromData(const QByteArray &encodedData) const override;
ExtractorDocumentNode createNodeFromContent(const QVariant &decodedData) const override;
void expandNode(ExtractorDocumentNode& node, const ExtractorEngine *engine) const override;
bool matches(const ExtractorFilter &filter, const ExtractorDocumentNode &node) const override;
void destroyNode(ExtractorDocumentNode &node) const override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment