33#ifndef _KMAIL_OBJECTTREEPARSER_H_
34#define _KMAIL_OBJECTTREEPARSER_H_
40#include <kleo/cryptobackend.h>
41#include <gpgmepp/verificationresult.h>
42#include <gpgmepp/key.h>
58 class AttachmentStrategy;
65 ProcessResult( KMMsgSignatureState inlineSignatureState = KMMsgNotSigned,
66 KMMsgEncryptionState inlineEncryptionState = KMMsgNotEncrypted,
67 bool neverDisplayInline =
false,
68 bool isImage =
false )
69 : mInlineSignatureState( inlineSignatureState ),
70 mInlineEncryptionState( inlineEncryptionState ),
71 mNeverDisplayInline( neverDisplayInline ),
72 mIsImage( isImage ) {}
74 KMMsgSignatureState inlineSignatureState()
const {
75 return mInlineSignatureState;
77 void setInlineSignatureState( KMMsgSignatureState state ) {
78 mInlineSignatureState = state;
81 KMMsgEncryptionState inlineEncryptionState()
const {
82 return mInlineEncryptionState;
84 void setInlineEncryptionState( KMMsgEncryptionState state ) {
85 mInlineEncryptionState = state;
88 bool neverDisplayInline()
const {
return mNeverDisplayInline; }
89 void setNeverDisplayInline(
bool display ) {
90 mNeverDisplayInline = display;
93 bool isImage()
const {
return mIsImage; }
94 void setIsImage(
bool image ) {
98 void adjustCryptoStatesOfNode( partNode * node )
const;
101 KMMsgSignatureState mInlineSignatureState;
102 KMMsgEncryptionState mInlineEncryptionState;
103 bool mNeverDisplayInline : 1;
107 class ObjectTreeParser {
108 class CryptoProtocolSaver;
110 ObjectTreeParser(
const ObjectTreeParser & other );
112 ObjectTreeParser(
KMReaderWin * reader=0,
const Kleo::CryptoBackend::Protocol * protocol=0,
113 bool showOneMimePart=
false,
bool keepEncryptions=
false,
114 bool includeSignatures=
true,
115 const KMail::AttachmentStrategy * attachmentStrategy=0,
117 KMail::CSSHelper * cssHelper=0 );
118 virtual ~ObjectTreeParser();
120 void setAllowAsync(
bool allow ) { assert( !mHasPendingAsyncJobs ); mAllowAsync = allow; }
121 bool allowAsync()
const {
return mAllowAsync; }
123 bool hasPendingAsyncJobs()
const {
return mHasPendingAsyncJobs; }
125 TQCString rawReplyString()
const {
return mRawReplyString; }
129 TQString textualContent()
const {
return mTextualContent; }
131 TQCString textualContentCharset()
const {
return mTextualContentCharset; }
133 void setCryptoProtocol(
const Kleo::CryptoBackend::Protocol * protocol ) {
134 mCryptoProtocol = protocol;
136 const Kleo::CryptoBackend::Protocol* cryptoProtocol()
const {
137 return mCryptoProtocol;
140 bool showOnlyOneMimePart()
const {
return mShowOnlyOneMimePart; }
141 void setShowOnlyOneMimePart(
bool show ) {
142 mShowOnlyOneMimePart = show;
145 bool keepEncryptions()
const {
return mKeepEncryptions; }
146 void setKeepEncryptions(
bool keep ) {
147 mKeepEncryptions = keep;
150 bool includeSignatures()
const {
return mIncludeSignatures; }
151 void setIncludeSignatures(
bool include ) {
152 mIncludeSignatures = include;
157 void setShowRawToltecMail(
bool showRawToltecMail ) { mShowRawToltecMail = showRawToltecMail; }
158 bool showRawToltecMail()
const {
return mShowRawToltecMail; }
162 static TQString defaultToltecReplacementText();
164 const KMail::AttachmentStrategy * attachmentStrategy()
const {
165 return mAttachmentStrategy;
170 KMail::CSSHelper * cssHelper()
const {
return mCSSHelper; }
176 void parseObjectTree( partNode * node );
181 void stdChildHandling( partNode * child );
183 void defaultHandling( partNode * node, ProcessResult & result );
198 void insertAndParseNewChildNode( partNode & node,
199 const char * content,
200 const char * cntDesc,
202 bool addToTextualContent =
true );
213 bool writeOpaqueOrMultipartSignedData( partNode * data,
215 const TQString & fromAddress,
217 bool hideErrors=
false,
218 TQCString * cleartextData=0,
219 const std::vector<GpgME::Signature> & paramSignatures = std::vector<GpgME::Signature>(),
220 const GpgME::Key & paramKey = GpgME::Key() );
224 void writeDeferredDecryptionBlock();
228 void writeDecryptionInProgressBlock();
232 bool okDecryptMIME( partNode& data,
233 TQCString& decryptedData,
234 bool& signatureFound,
235 std::vector<GpgME::Signature> &signatures,
238 bool& passphraseError,
239 bool& actuallyEncrypted,
240 bool& decryptionStarted,
241 TQString& aErrorText,
242 GpgME::Error & auditLogError,
243 TQString& auditLog );
245 bool processMailmanMessage( partNode * node );
256 bool processToltecMail( partNode * node );
262 static bool containsExternalReferences(
const TQCString & str );
266 bool processTextHtmlSubtype( partNode * node, ProcessResult & result );
267 bool processTextPlainSubtype( partNode * node, ProcessResult & result );
269 bool processMultiPartMixedSubtype( partNode * node, ProcessResult & result );
270 bool processMultiPartAlternativeSubtype( partNode * node, ProcessResult & result );
271 bool processMultiPartDigestSubtype( partNode * node, ProcessResult & result );
272 bool processMultiPartParallelSubtype( partNode * node, ProcessResult & result );
273 bool processMultiPartSignedSubtype( partNode * node, ProcessResult & result );
274 bool processMultiPartEncryptedSubtype( partNode * node, ProcessResult & result );
276 bool processMessageRfc822Subtype( partNode * node, ProcessResult & result );
278 bool processApplicationOctetStreamSubtype( partNode * node, ProcessResult & result );
279 bool processApplicationPkcs7MimeSubtype( partNode * node, ProcessResult & result );
280 bool processApplicationChiasmusTextSubtype( partNode * node, ProcessResult & result );
281 bool processApplicationMsTnefSubtype( partNode *node, ProcessResult &result );
284 bool decryptChiasmus(
const TQByteArray& data, TQByteArray& bodyDecoded, TQString& errorText );
285 void writeBodyString(
const TQCString & bodyString,
286 const TQString & fromAddress,
287 const TQTextCodec * codec,
288 ProcessResult & result,
bool decorate );
290 void writePartIcon( KMMessagePart * msgPart,
int partNumber,
bool inlineImage=
false );
292 TQString sigStatusToString(
const Kleo::CryptoBackend::Protocol * cryptProto,
294 GpgME::Signature::Summary summary,
296 bool & showKeyInfos );
297 TQString writeSigstatHeader( KMail::PartMetaData & part,
298 const Kleo::CryptoBackend::Protocol * cryptProto,
299 const TQString & fromAddress,
300 partNode *node = 0 );
301 TQString writeSigstatFooter( KMail::PartMetaData & part );
306 void writeAttachmentMarkHeader( partNode *node );
307 void writeAttachmentMarkFooter();
309 void writeBodyStr(
const TQCString & bodyString,
310 const TQTextCodec * aCodec,
311 const TQString & fromAddress,
312 KMMsgSignatureState & inlineSignatureState,
313 KMMsgEncryptionState & inlineEncryptionState,
316 void writeBodyStr(
const TQCString & bodyString,
317 const TQTextCodec * aCodec,
318 const TQString & fromAddress );
323 TQString quotedHTML(
const TQString& pos,
bool decorate);
325 const TQTextCodec * codecFor( partNode * node )
const;
328 void dumpToFile(
const char * filename,
const char * dataStart,
size_t dataLen );
330 void dumpToFile(
const char *,
const char *,
size_t ) {}
335 TQCString mRawReplyString;
336 TQCString mTextualContentCharset;
337 TQString mTextualContent;
338 const Kleo::CryptoBackend::Protocol * mCryptoProtocol;
339 bool mShowOnlyOneMimePart;
340 bool mKeepEncryptions;
341 bool mIncludeSignatures;
342 bool mHasPendingAsyncJobs;
344 bool mShowRawToltecMail;
345 const KMail::AttachmentStrategy * mAttachmentStrategy;
347 KMail::CSSHelper * mCSSHelper;
349 TQString mCollapseIcon;
350 TQString mExpandIcon;
This class implements a "reader window", that is a window used for reading or viewing messages.
An interface to HTML sinks.