Messagelib

objecttreeparser.h
1 /*
2  objecttreeparser.h
3 
4  This file is part of KMail, the KDE mail client.
5  SPDX-FileCopyrightText: 2003 Marc Mutz <[email protected]>
6  SPDX-FileCopyrightText: 2002-2003, 2009 Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected]
7  SPDX-FileCopyrightText: 2009 Andras Mantia <[email protected]>
8 
9  SPDX-License-Identifier: GPL-2.0-or-later
10 */
11 
12 #ifndef MIMETREEPARSER_OBJECTTREEPARSER_H
13 #define MIMETREEPARSER_OBJECTTREEPARSER_H
14 
15 #include "mimetreeparser_export.h"
16 
17 #include "mimetreeparser/nodehelper.h"
18 #include "mimetreeparser/objecttreesource.h"
19 
20 #include <gpgme++/verificationresult.h>
21 
22 class QString;
23 
24 namespace KMime {
25 class Content;
26 }
27 
28 namespace MimeTreeParser {
29 class PartMetaData;
30 class ViewerPrivate;
31 class NodeHelper;
32 class MessagePart;
33 class MimeMessagePart;
34 
35 typedef QSharedPointer<MessagePart> MessagePartPtr;
36 typedef QSharedPointer<MimeMessagePart> MimeMessagePartPtr;
40 class MIMETREEPARSER_EXPORT ProcessResult
41 {
42 public:
43  explicit ProcessResult(NodeHelper *nodeHelper, KMMsgSignatureState inlineSignatureState = KMMsgNotSigned, KMMsgEncryptionState inlineEncryptionState = KMMsgNotEncrypted, bool neverDisplayInline = false)
44  : mInlineSignatureState(inlineSignatureState)
45  , mInlineEncryptionState(inlineEncryptionState)
46  , mNeverDisplayInline(neverDisplayInline)
47  , mNodeHelper(nodeHelper)
48  {
49  }
50 
51  Q_REQUIRED_RESULT KMMsgSignatureState inlineSignatureState() const;
52  void setInlineSignatureState(KMMsgSignatureState state);
53 
54  Q_REQUIRED_RESULT KMMsgEncryptionState inlineEncryptionState() const;
55  void setInlineEncryptionState(KMMsgEncryptionState state);
56 
57  Q_REQUIRED_RESULT bool neverDisplayInline() const;
58  void setNeverDisplayInline(bool display);
59 
60  void adjustCryptoStatesOfNode(const KMime::Content *node) const;
61 
62 private:
63  KMMsgSignatureState mInlineSignatureState;
64  KMMsgEncryptionState mInlineEncryptionState;
65  bool mNeverDisplayInline : 1;
66  NodeHelper *mNodeHelper;
67 };
68 
241 class MIMETREEPARSER_EXPORT ObjectTreeParser
242 {
247  ObjectTreeParser(const ObjectTreeParser &other);
248 
249 public:
250  explicit ObjectTreeParser(Interface::ObjectTreeSource *source, NodeHelper *nodeHelper = nullptr);
251 
252  explicit ObjectTreeParser(const ObjectTreeParser *topLevelParser);
253  virtual ~ObjectTreeParser();
254 
255  void setAllowAsync(bool allow);
256  bool allowAsync() const;
257 
258  bool hasPendingAsyncJobs() const;
259 
265  QString plainTextContent() const;
266 
273  QString htmlContent() const;
274 
281  QByteArray plainTextContentCharset() const;
282  QByteArray htmlContentCharset() const;
283 
284  NodeHelper *nodeHelper() const;
285 
288  void parseObjectTree(KMime::Content *node, bool parseOnlySingleNode = false);
289  MessagePartPtr parsedPart() const;
290 
291 private:
292  void extractNodeInfos(KMime::Content *curNode, bool isFirstTextPart);
293  void setPlainTextContent(const QString &plainTextContent);
294 
299  MessagePartPtr parseObjectTreeInternal(KMime::Content *node, bool mOnlyOneMimePart);
300  MessagePartPtr processType(KMime::Content *node, MimeTreeParser::ProcessResult &processResult, const QByteArray &mimeType);
301 
302 private:
303 
305  void init();
306 
307  const QTextCodec *codecFor(KMime::Content *node) const;
308 
309 private:
311  NodeHelper *mNodeHelper;
312  QByteArray mPlainTextContentCharset;
313  QByteArray mHtmlContentCharset;
314  QString mPlainTextContent;
315  QString mHtmlContent;
316  KMime::Content *mTopLevelContent = nullptr;
317  MessagePartPtr mParsedPart;
318 
329  bool mShowOnlyOneMimePart;
330 
331  bool mHasPendingAsyncJobs = false;
332  bool mAllowAsync;
333  // DataUrl Icons cache
334  QString mCollapseIcon;
335  QString mExpandIcon;
336  bool mDeleteNodeHelper;
337 
338  friend class PartNodeBodyPart;
339  friend class MessagePart;
340  friend class EncryptedMessagePart;
341  friend class SignedMessagePart;
342  friend class TextMessagePart;
343  friend class HtmlMessagePart;
344  friend class MultiPartSignedBodyPartFormatter;
345  friend class ApplicationPkcs7MimeBodyPartFormatter;
346 };
347 }
348 
349 #endif // MIMETREEPARSER_OBJECTTREEPARSER_H
an implementation of the BodyPart interface using KMime::Content&#39;s
QCA_EXPORT void init()
Interface for object tree sources.
Parses messages and generates HTML display code out of them.
The ProcessResult class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Jan 26 2021 23:14:07 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.