Differential D8583 Diff 22184 plugins/messageviewer/bodypartformatter/semantic/semanticprocessor.cpp
Changeset View
Changeset View
Standalone View
Standalone View
plugins/messageviewer/bodypartformatter/semantic/semanticprocessor.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright (c) 2017 Volker Krause <vkrause@kde.org> | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or modify it | ||||
5 | under the terms of the GNU Library General Public License as published by | ||||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||||
7 | option) any later version. | ||||
8 | | ||||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||||
12 | License for more details. | ||||
13 | | ||||
14 | You should have received a copy of the GNU Library General Public License | ||||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||||
17 | 02110-1301, USA. | ||||
18 | */ | ||||
19 | | ||||
20 | #include "semanticprocessor.h" | ||||
21 | #include "structureddataextractor.h" | ||||
22 | #include "semanticmemento.h" | ||||
23 | #include "semantic_debug.h" | ||||
24 | | ||||
25 | #include <QDebug> | ||||
26 | | ||||
27 | MimeTreeParser::MessagePart::Ptr SemanticProcessor::process(MimeTreeParser::Interface::BodyPart &part) const | ||||
28 | { | ||||
29 | auto nodeHelper = part.nodeHelper(); | ||||
30 | if (!nodeHelper) | ||||
31 | return {}; | ||||
32 | auto memento = dynamic_cast<SemanticMemento*>(nodeHelper->bodyPartMemento(part.topLevelContent(), "org.kde.messageviewer.semanticData")); | ||||
33 | if (memento) | ||||
34 | return {}; | ||||
35 | | ||||
36 | qCDebug(SEMANTIC_LOG) << "-------------------------------------------- BEGIN SEMANTIC PARSING"; | ||||
37 | StructuredDataExtractor extractor; | ||||
38 | extractor.parse(part.content()->decodedText()); | ||||
39 | memento = new SemanticMemento; | ||||
40 | nodeHelper->setBodyPartMemento(part.topLevelContent(), "org.kde.messageviewer.semanticData", memento); | ||||
41 | memento->setData(extractor.data()); | ||||
42 | qCDebug(SEMANTIC_LOG) << "-------------------------------------------- END SEMANTIC PARSING"; | ||||
43 | return {}; | ||||
44 | } |