diff options
Diffstat (limited to 'framework/src/domain/mime/mimetreeparser/objecttreeparser.cpp')
-rw-r--r-- | framework/src/domain/mime/mimetreeparser/objecttreeparser.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/framework/src/domain/mime/mimetreeparser/objecttreeparser.cpp b/framework/src/domain/mime/mimetreeparser/objecttreeparser.cpp index 0149f388..9fb73ffa 100644 --- a/framework/src/domain/mime/mimetreeparser/objecttreeparser.cpp +++ b/framework/src/domain/mime/mimetreeparser/objecttreeparser.cpp | |||
@@ -51,13 +51,11 @@ | |||
51 | #include <KMime/Headers> | 51 | #include <KMime/Headers> |
52 | #include <KMime/Message> | 52 | #include <KMime/Message> |
53 | 53 | ||
54 | // KDE includes | ||
55 | |||
56 | // Qt includes | ||
57 | #include <QByteArray> | 54 | #include <QByteArray> |
58 | #include <QTextCodec> | 55 | #include <QTextCodec> |
59 | #include <QUrl> | 56 | #include <QUrl> |
60 | #include <QMimeDatabase> | 57 | #include <QMimeDatabase> |
58 | #include <QTextStream> | ||
61 | 59 | ||
62 | using namespace MimeTreeParser; | 60 | using namespace MimeTreeParser; |
63 | 61 | ||
@@ -175,7 +173,7 @@ QString ObjectTreeParser::htmlContent() | |||
175 | return content; | 173 | return content; |
176 | } | 174 | } |
177 | 175 | ||
178 | static void print(KMime::Content *node, const QString prefix = {}) | 176 | static void print(QTextStream &s, KMime::Content *node, const QString prefix = {}) |
179 | { | 177 | { |
180 | QByteArray mediaType("text"); | 178 | QByteArray mediaType("text"); |
181 | QByteArray subType("plain"); | 179 | QByteArray subType("plain"); |
@@ -184,28 +182,37 @@ static void print(KMime::Content *node, const QString prefix = {}) | |||
184 | mediaType = node->contentType()->mediaType(); | 182 | mediaType = node->contentType()->mediaType(); |
185 | subType = node->contentType()->subType(); | 183 | subType = node->contentType()->subType(); |
186 | } | 184 | } |
187 | qWarning() << prefix << "!" << mediaType << subType << "isAttachment: " << KMime::isAttachment(node); | 185 | s << prefix << "!" << mediaType << subType << "isAttachment: " << KMime::isAttachment(node) << "\n"; |
188 | for (const auto c: node->contents()) { | 186 | for (const auto c: node->contents()) { |
189 | print(c, prefix + QLatin1String(" ")); | 187 | print(s, c, prefix + QLatin1String(" ")); |
190 | } | 188 | } |
191 | } | 189 | } |
192 | 190 | ||
193 | static void print(const MessagePart &messagePart, const QByteArray pre = {}) | 191 | static void print(QTextStream &s, const MessagePart &messagePart, const QByteArray pre = {}) |
194 | { | 192 | { |
195 | qWarning() << pre << "#" << messagePart.metaObject()->className() << "isAttachment: " << messagePart.isAttachment(); | 193 | s << pre << "#" << messagePart.metaObject()->className() << "isAttachment: " << messagePart.isAttachment() << "\n"; |
196 | for (const auto &p: messagePart.subParts()) { | 194 | for (const auto &p: messagePart.subParts()) { |
197 | print(*p, pre + " "); | 195 | print(s, *p, pre + " "); |
198 | } | 196 | } |
199 | } | 197 | } |
200 | 198 | ||
201 | void ObjectTreeParser::print() | 199 | QString ObjectTreeParser::structureAsString() const |
202 | { | 200 | { |
201 | QString string; | ||
202 | QTextStream s{&string}; | ||
203 | |||
203 | if (mTopLevelContent) { | 204 | if (mTopLevelContent) { |
204 | ::print(mTopLevelContent); | 205 | ::print(s, mTopLevelContent); |
205 | } | 206 | } |
206 | if (mParsedPart) { | 207 | if (mParsedPart) { |
207 | ::print(*mParsedPart); | 208 | ::print(s, *mParsedPart); |
208 | } | 209 | } |
210 | return string; | ||
211 | } | ||
212 | |||
213 | void ObjectTreeParser::print() | ||
214 | { | ||
215 | qInfo().noquote() << structureAsString(); | ||
209 | } | 216 | } |
210 | 217 | ||
211 | static KMime::Content *find(KMime::Content *node, const std::function<bool(KMime::Content *)> &select) | 218 | static KMime::Content *find(KMime::Content *node, const std::function<bool(KMime::Content *)> &select) |