• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messageviewer

  • sources
  • kde-4.12
  • kdepim
  • messageviewer
  • viewer
objecttreeparser.h
Go to the documentation of this file.
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2  objecttreeparser.h
3 
4  This file is part of KMail, the KDE mail client.
5  Copyright (c) 2003 Marc Mutz <mutz@kde.org>
6  Copyright (C) 2002-2003, 2009 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.net
7  Copyright (c) 2009 Andras Mantia <andras@kdab.net>
8 
9  KMail is free software; you can redistribute it and/or modify it
10  under the terms of the GNU General Public License, version 2, as
11  published by the Free Software Foundation.
12 
13  KMail is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 
22  In addition, as a special exception, the copyright holders give
23  permission to link the code of this program with any edition of
24  the Qt library by Trolltech AS, Norway (or with modified versions
25  of Qt that use the same license as Qt), and distribute linked
26  combinations including the two. You must obey the GNU General
27  Public License in all respects for all of the code used other than
28  Qt. If you modify this file, you may extend this exception to
29  your version of the file, but you are not obligated to do so. If
30  you do not wish to do so, delete this exception statement from
31  your version.
32 */
33 
34 #ifndef _MESSAGEVIEWER_OBJECTTREEPARSER_H_
35 #define _MESSAGEVIEWER_OBJECTTREEPARSER_H_
36 
37 #include "messageviewer_export.h"
38 
39 #include "viewer/nodehelper.h"
40 #include "objecttreesourceif.h"
41 
42 #include <libkleo/kleo/cryptobackend.h>
43 #include <gpgme++/verificationresult.h>
44 
45 #include <QList>
46 #include "objecttreeemptysource.h"
47 
48 class QString;
49 
50 namespace KMime {
51  class Content;
52 }
53 
54 namespace GpgME {
55  class Error;
56  class ImportResult;
57 }
58 
59 
60 namespace MessageViewer {
61 
62 class PartMetaData;
63 class ViewerPrivate;
64 class HtmlWriter;
65 class CSSHelper;
66 class AttachmentStrategy;
67 class NodeHelper;
68 
69 class ProcessResult {
70 public:
71  explicit ProcessResult( NodeHelper *nodeHelper, KMMsgSignatureState inlineSignatureState = KMMsgNotSigned,
72  KMMsgEncryptionState inlineEncryptionState = KMMsgNotEncrypted,
73  bool neverDisplayInline = false,
74  bool isImage = false )
75  : mInlineSignatureState( inlineSignatureState ),
76  mInlineEncryptionState( inlineEncryptionState ),
77  mNeverDisplayInline( neverDisplayInline ),
78  mIsImage( isImage ),
79  mNodeHelper( nodeHelper ) {}
80 
81  KMMsgSignatureState inlineSignatureState() const {
82  return mInlineSignatureState;
83  }
84  void setInlineSignatureState( KMMsgSignatureState state ) {
85  mInlineSignatureState = state;
86  }
87 
88  KMMsgEncryptionState inlineEncryptionState() const {
89  return mInlineEncryptionState;
90  }
91  void setInlineEncryptionState( KMMsgEncryptionState state ) {
92  mInlineEncryptionState = state;
93  }
94 
95  bool neverDisplayInline() const { return mNeverDisplayInline; }
96  void setNeverDisplayInline( bool display ) {
97  mNeverDisplayInline = display;
98  }
99 
100  bool isImage() const { return mIsImage; }
101  void setIsImage( bool image ) {
102  mIsImage = image;
103  }
104 
105  void adjustCryptoStatesOfNode( KMime::Content * node ) const;
106 
107 private:
108  KMMsgSignatureState mInlineSignatureState;
109  KMMsgEncryptionState mInlineEncryptionState;
110  bool mNeverDisplayInline : 1;
111  bool mIsImage : 1;
112  NodeHelper* mNodeHelper;
113 };
114 
287 class MESSAGEVIEWER_EXPORT ObjectTreeParser {
288  class CryptoProtocolSaver;
293  ObjectTreeParser( const ObjectTreeParser & other );
294 
295 public:
296  explicit ObjectTreeParser( ObjectTreeSourceIf * source,
297  NodeHelper *nodeHelper = 0,
298  const Kleo::CryptoBackend::Protocol * protocol=0,
299  bool showOneMimePart=false, bool keepEncryptions=false,
300  bool includeSignatures=true,
301  const AttachmentStrategy * attachmentStrategy=0 );
302 
303  explicit ObjectTreeParser( const ObjectTreeParser *topLevelParser,
304  bool showOneMimePart=false, bool keepEncryptions=false,
305  bool includeSignatures=true,
306  const AttachmentStrategy * attachmentStrategy=0 );
307  virtual ~ObjectTreeParser();
308 
309  void setAllowAsync( bool allow ) { assert( !mHasPendingAsyncJobs ); mAllowAsync = allow; }
310  bool allowAsync() const { return mAllowAsync; }
311 
312  bool hasPendingAsyncJobs() const { return mHasPendingAsyncJobs; }
313 
330  KDE_DEPRECATED QByteArray rawDecryptedBody() const { return mRawDecryptedBody; }
331 
337  QString plainTextContent() const { return mPlainTextContent; }
338 
345  QString htmlContent() const { return mHtmlContent; }
346 
351  QString convertedTextContent() const;
352 
356  QString convertedHtmlContent() const;
357 
364  QByteArray plainTextContentCharset() const { return mPlainTextContentCharset; }
365  QByteArray htmlContentCharset() const { return mHtmlContentCharset; }
366 
367  void setCryptoProtocol( const Kleo::CryptoBackend::Protocol * protocol ) {
368  mCryptoProtocol = protocol;
369  }
370  const Kleo::CryptoBackend::Protocol* cryptoProtocol() const {
371  return mCryptoProtocol;
372  }
373 
374  bool showOnlyOneMimePart() const { return mShowOnlyOneMimePart; }
375  void setShowOnlyOneMimePart( bool show ) {
376  mShowOnlyOneMimePart = show;
377  }
378 
379  bool keepEncryptions() const { return mKeepEncryptions; }
380  void setKeepEncryptions( bool keep ) {
381  mKeepEncryptions = keep;
382  }
383 
384  bool includeSignatures() const { return mIncludeSignatures; }
385  void setIncludeSignatures( bool include ) {
386  mIncludeSignatures = include;
387  }
388 
389  // Controls whether Toltec invitations are displayed in their raw form or as a replacement text,
390  // which is used in processToltecMail().
391  void setShowRawToltecMail( bool showRawToltecMail ) { mShowRawToltecMail = showRawToltecMail; }
392  bool showRawToltecMail() const { return mShowRawToltecMail; }
393 
396  static QString defaultToltecReplacementText();
397 
398  const AttachmentStrategy * attachmentStrategy() const {
399  return mAttachmentStrategy;
400  }
401 
402  HtmlWriter * htmlWriter() const { return mSource->htmlWriter(); }
403 
404  CSSHelper * cssHelper() const { return mSource->cssHelper(); }
405 
406  NodeHelper * nodeHelper() const { return mNodeHelper; }
407 
410  void parseObjectTree( KMime::Content * node );
411 
412 private:
413  void extractNodeInfos( KMime::Content *curNode, bool isFirstTextPart );
414 
419  void parseObjectTreeInternal( KMime::Content * node );
420 
423  void stdChildHandling( KMime::Content * child );
424 
425  void defaultHandling( KMime::Content * node, ProcessResult & result );
426 
431  void createAndParseTempNode( KMime::Content* parentNode, const char * content, const char * cntDesc );
432 
443  bool writeOpaqueOrMultipartSignedData( KMime::Content * data,
444  KMime::Content & sign,
445  const QString & fromAddress,
446  bool doCheck=true,
447  QByteArray * cleartextData=0,
448  const std::vector<GpgME::Signature> & paramSignatures = std::vector<GpgME::Signature>(),
449  bool hideErrors=false );
450 
453  void writeDeferredDecryptionBlock();
454 
457  void writeDecryptionInProgressBlock();
458 
460  void writeCertificateImportResult( const GpgME::ImportResult & res );
461 
462 
465  bool okDecryptMIME( KMime::Content& data,
466  QByteArray& decryptedData,
467  bool& signatureFound,
468  std::vector<GpgME::Signature> &signatures,
469  bool showWarning,
470  bool& passphraseError,
471  bool& actuallyEncrypted,
472  bool& decryptionStarted,
473  PartMetaData &partMetaData );
474 
484  bool processToltecMail( KMime::Content *node );
485 
486  bool processMailmanMessage( KMime::Content* node );
487 
492  static bool containsExternalReferences(const QString & str , const QString &extraHead);
493 
494 public:// (during refactoring)
495 
496  bool processTextHtmlSubtype( KMime::Content * node, ProcessResult & result );
497  bool processTextPlainSubtype( KMime::Content *node, ProcessResult & result );
498 
499  bool processMultiPartMixedSubtype( KMime::Content * node, ProcessResult & result );
500  bool processMultiPartAlternativeSubtype( KMime::Content * node, ProcessResult & result );
501  bool processMultiPartDigestSubtype( KMime::Content * node, ProcessResult & result );
502  bool processMultiPartParallelSubtype( KMime::Content * node, ProcessResult & result );
503  bool processMultiPartSignedSubtype( KMime::Content * node, ProcessResult & result );
504  bool processMultiPartEncryptedSubtype( KMime::Content * node, ProcessResult & result );
505 
506  bool processMessageRfc822Subtype( KMime::Content * node, ProcessResult & result );
507 
508  bool processApplicationOctetStreamSubtype( KMime::Content * node, ProcessResult & result );
509  bool processApplicationPkcs7MimeSubtype( KMime::Content * node, ProcessResult & result );
510  bool processApplicationChiasmusTextSubtype( KMime::Content * node, ProcessResult & result );
511 
512  bool decryptChiasmus( const QByteArray& data, QByteArray& bodyDecoded, QString& errorText );
513  void writeBodyString( const QByteArray & bodyString,
514  const QString & fromAddress,
515  const QTextCodec * codec,
516  ProcessResult & result, bool decorate );
517 
518  void writePartIcon( KMime::Content * msgPart, bool inlineImage = false );
519 
520  QString sigStatusToString( const Kleo::CryptoBackend::Protocol * cryptProto,
521  int status_code,
522  GpgME::Signature::Summary summary,
523  int & frameColor,
524  bool & showKeyInfos );
525  QString writeSigstatHeader( PartMetaData & part,
526  const Kleo::CryptoBackend::Protocol * cryptProto,
527  const QString & fromAddress,
528  KMime::Content *node = 0);
529  QString writeSigstatFooter( PartMetaData & part );
530 
531  // The attachment mark is a div that is placed around the attchment. It is used for drawing
532  // a yellow border around the attachment when scrolling to it. When scrolling to it, the border
533  // color of the div is changed, see KMReaderWin::scrollToAttachment().
534  void writeAttachmentMarkHeader( KMime::Content *node );
535  void writeAttachmentMarkFooter();
536 
537  void writeBodyStr( const QByteArray & bodyString,
538  const QTextCodec * aCodec,
539  const QString & fromAddress,
540  KMMsgSignatureState & inlineSignatureState,
541  KMMsgEncryptionState & inlineEncryptionState,
542  bool decorate );
543 
544  bool isMailmanMessage( KMime::Content * curNode );
545 
546 public: // KMReaderWin still needs this...
547  void writeBodyStr( const QByteArray & bodyString,
548  const QTextCodec * aCodec,
549  const QString & fromAddress );
550  static KMime::Content* findType( KMime::Content* content, const QByteArray& mimeType, bool deep, bool wide );
551 
552  static KMime::Content* findType( KMime::Content* content, const QByteArray& mediaType, const QByteArray& subType, bool deep, bool wide );
553 
554  static KMime::Content* findTypeNot( KMime::Content* content, const QByteArray& mediaType, const QByteArray& subType, bool deep=true, bool wide=true );
555 
556 
557 private:
558 
560  void init();
561 
564  QString quotedHTML(const QString& pos, bool decorate);
565 
566  const QTextCodec * codecFor( KMime::Content * node ) const;
571  bool looksLikeParaBreak(const QString& s, unsigned int newLinePos) const;
572 
573 #ifdef MARCS_DEBUG
574  void dumpToFile( const char * filename, const char * dataStart, size_t dataLen );
575 #else
576  void dumpToFile( const char *, const char *, size_t ) {}
577 #endif
578 
579  void copyContentFrom( const ObjectTreeParser *other );
580 
581 private:
582  ObjectTreeSourceIf* mSource;
583  NodeHelper* mNodeHelper;
584  QByteArray mRawDecryptedBody;
585  QByteArray mPlainTextContentCharset;
586  QByteArray mHtmlContentCharset;
587  QString mPlainTextContent;
588  QString mHtmlContent;
589  KMime::Content *mTopLevelContent;
590  const Kleo::CryptoBackend::Protocol * mCryptoProtocol;
591 
602  bool mShowOnlyOneMimePart;
603 
604  bool mKeepEncryptions;
605  bool mIncludeSignatures;
606  bool mHasPendingAsyncJobs;
607  bool mAllowAsync;
608  bool mShowRawToltecMail;
609  const AttachmentStrategy * mAttachmentStrategy;
610  // DataUrl Icons cache
611  QString mCollapseIcon;
612  QString mExpandIcon;
613  bool mDeleteNodeHelper;
614 
615 };
616 
617 }
618 
619 #endif // _KMAIL_OBJECTTREEPARSER_H_
620 
MessageViewer::PartMetaData
Definition: partmetadata.h:31
MessageViewer::ObjectTreeParser::showOnlyOneMimePart
bool showOnlyOneMimePart() const
Definition: objecttreeparser.h:374
MessageViewer::ObjectTreeParser::setShowRawToltecMail
void setShowRawToltecMail(bool showRawToltecMail)
Definition: objecttreeparser.h:391
objecttreeemptysource.h
MessageViewer::ProcessResult::neverDisplayInline
bool neverDisplayInline() const
Definition: objecttreeparser.h:95
MessageViewer::KMMsgSignatureState
KMMsgSignatureState
Flags for the signature state.
Definition: nodehelper.h:58
objecttreesourceif.h
MessageViewer::ObjectTreeParser::plainTextContentCharset
QByteArray plainTextContentCharset() const
The original charset of MIME part the plain text was extracted from.
Definition: objecttreeparser.h:364
nodehelper.h
MessageViewer::ProcessResult::setNeverDisplayInline
void setNeverDisplayInline(bool display)
Definition: objecttreeparser.h:96
MessageViewer::ObjectTreeParser::setCryptoProtocol
void setCryptoProtocol(const Kleo::CryptoBackend::Protocol *protocol)
Definition: objecttreeparser.h:367
MessageViewer::ProcessResult
Definition: objecttreeparser.h:69
MessageViewer::ObjectTreeParser::hasPendingAsyncJobs
bool hasPendingAsyncJobs() const
Definition: objecttreeparser.h:312
MessageViewer::ObjectTreeParser::includeSignatures
bool includeSignatures() const
Definition: objecttreeparser.h:384
MessageViewer::ObjectTreeParser::keepEncryptions
bool keepEncryptions() const
Definition: objecttreeparser.h:379
MessageViewer::KMMsgNotSigned
Definition: nodehelper.h:61
MessageViewer::ObjectTreeParser::allowAsync
bool allowAsync() const
Definition: objecttreeparser.h:310
MessageViewer::ProcessResult::setInlineEncryptionState
void setInlineEncryptionState(KMMsgEncryptionState state)
Definition: objecttreeparser.h:91
MessageViewer::ProcessResult::adjustCryptoStatesOfNode
void adjustCryptoStatesOfNode(KMime::Content *node) const
Definition: objecttreeparser.cpp:449
MessageViewer::KMMsgNotEncrypted
Definition: nodehelper.h:51
MessageViewer::ObjectTreeParser::setShowOnlyOneMimePart
void setShowOnlyOneMimePart(bool show)
Definition: objecttreeparser.h:375
MessageViewer::ObjectTreeParser::htmlContentCharset
QByteArray htmlContentCharset() const
Definition: objecttreeparser.h:365
MessageViewer::ObjectTreeParser::nodeHelper
NodeHelper * nodeHelper() const
Definition: objecttreeparser.h:406
MessageViewer::ObjectTreeSourceIf
Interface for object tree sources.
Definition: objecttreesourceif.h:43
MessageViewer::ProcessResult::setIsImage
void setIsImage(bool image)
Definition: objecttreeparser.h:101
MessageViewer::CSSHelper
Definition: csshelper.h:41
MessageViewer::ObjectTreeParser::showRawToltecMail
bool showRawToltecMail() const
Definition: objecttreeparser.h:392
MessageViewer::ObjectTreeParser::rawDecryptedBody
KDE_DEPRECATED QByteArray rawDecryptedBody() const
The origin and purpose of this function is unknown, the ancient wisdom about it got lost during the c...
Definition: objecttreeparser.h:330
MessageViewer::ProcessResult::inlineSignatureState
KMMsgSignatureState inlineSignatureState() const
Definition: objecttreeparser.h:81
MessageViewer::ObjectTreeParser::attachmentStrategy
const AttachmentStrategy * attachmentStrategy() const
Definition: objecttreeparser.h:398
MESSAGEVIEWER_EXPORT
#define MESSAGEVIEWER_EXPORT
Definition: messageviewer_export.h:37
MessageViewer::ObjectTreeParser::htmlContent
QString htmlContent() const
Similar to plainTextContent(), but returns the HTML source of the first text/html MIME part...
Definition: objecttreeparser.h:345
MessageViewer::ObjectTreeParser::setIncludeSignatures
void setIncludeSignatures(bool include)
Definition: objecttreeparser.h:385
MessageViewer::ProcessResult::ProcessResult
ProcessResult(NodeHelper *nodeHelper, KMMsgSignatureState inlineSignatureState=KMMsgNotSigned, KMMsgEncryptionState inlineEncryptionState=KMMsgNotEncrypted, bool neverDisplayInline=false, bool isImage=false)
Definition: objecttreeparser.h:71
MessageViewer::NodeHelper
Definition: nodehelper.h:71
MessageViewer::AttachmentStrategy
Definition: attachmentstrategy.h:46
MessageViewer::ObjectTreeParser::htmlWriter
HtmlWriter * htmlWriter() const
Definition: objecttreeparser.h:402
MessageViewer::ProcessResult::inlineEncryptionState
KMMsgEncryptionState inlineEncryptionState() const
Definition: objecttreeparser.h:88
MessageViewer::ObjectTreeParser::cssHelper
CSSHelper * cssHelper() const
Definition: objecttreeparser.h:404
MessageViewer::ObjectTreeParser::cryptoProtocol
const Kleo::CryptoBackend::Protocol * cryptoProtocol() const
Definition: objecttreeparser.h:370
MessageViewer::KMMsgEncryptionState
KMMsgEncryptionState
Flags for the encryption state.
Definition: nodehelper.h:48
MessageViewer::ObjectTreeParser::setAllowAsync
void setAllowAsync(bool allow)
Definition: objecttreeparser.h:309
MessageViewer::ObjectTreeParser
Parses messages and generates HTML display code out of them.
Definition: objecttreeparser.h:287
MessageViewer::ObjectTreeParser::setKeepEncryptions
void setKeepEncryptions(bool keep)
Definition: objecttreeparser.h:380
MessageViewer::HtmlWriter
An interface to HTML sinks.
Definition: htmlwriter.h:98
MessageViewer::ProcessResult::setInlineSignatureState
void setInlineSignatureState(KMMsgSignatureState state)
Definition: objecttreeparser.h:84
MessageViewer::ProcessResult::isImage
bool isImage() const
Definition: objecttreeparser.h:100
messageviewer_export.h
MessageViewer::ObjectTreeParser::plainTextContent
QString plainTextContent() const
The text of the message, ie.
Definition: objecttreeparser.h:337
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messageviewer

Skip menu "messageviewer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal